Plugin stuff
This commit is contained in:
@@ -36,8 +36,8 @@ export default (editor: Editor): SysCallMapping => ({
|
||||
getCursor: (): number => {
|
||||
return editor.editorView!.state.selection.main.from;
|
||||
},
|
||||
navigate: async (ctx, name: string) => {
|
||||
await editor.navigate(name);
|
||||
navigate: async (ctx, name: string, pos: number) => {
|
||||
await editor.navigate(name, pos);
|
||||
},
|
||||
openUrl: async (ctx, url: string) => {
|
||||
window.open(url, "_blank")!.focus();
|
||||
@@ -45,6 +45,12 @@ export default (editor: Editor): SysCallMapping => ({
|
||||
flashNotification: (ctx, message: string) => {
|
||||
editor.flashNotification(message);
|
||||
},
|
||||
showRhs: (ctx, html: string) => {
|
||||
editor.viewDispatch({
|
||||
type: "show-rhs",
|
||||
html: html,
|
||||
});
|
||||
},
|
||||
insertAtPos: (ctx, text: string, pos: number) => {
|
||||
editor.editorView!.dispatch({
|
||||
changes: {
|
||||
@@ -97,6 +103,12 @@ export default (editor: Editor): SysCallMapping => ({
|
||||
}
|
||||
}
|
||||
},
|
||||
getLineUnderCursor: (): string => {
|
||||
const editorState = editor.editorView!.state;
|
||||
let selection = editorState.selection.main;
|
||||
let line = editorState.doc.lineAt(selection.from);
|
||||
return editorState.sliceDoc(line.from, line.to);
|
||||
},
|
||||
matchBefore: (
|
||||
ctx,
|
||||
regexp: string
|
||||
|
||||
@@ -7,7 +7,7 @@ export function systemSyscalls(space: Space): SysCallMapping {
|
||||
if (!ctx.plug) {
|
||||
throw Error("No plug associated with context");
|
||||
}
|
||||
return await space.wsCall("invokeFunction", ctx.plug.name, name, ...args);
|
||||
return space.wsCall("invokeFunction", ctx.plug.name, name, ...args);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user