Plugin stuff

This commit is contained in:
Zef Hemel
2022-03-28 15:25:05 +02:00
parent 16fa05d4cc
commit bf32d6d0bd
36 changed files with 523 additions and 219 deletions
+14 -2
View File
@@ -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
+1 -1
View File
@@ -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);
},
};
}