Moved bold and italics to plug, new file: plug protocol

This commit is contained in:
Zef Hemel
2022-06-23 17:08:42 +02:00
parent 94d0e31b30
commit b22775fcc4
10 changed files with 162 additions and 17 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
import { Editor } from "../editor";
import { Transaction } from "@codemirror/state";
import { SelectionRange, Transaction } from "@codemirror/state";
import { SysCallMapping } from "@plugos/plugos/system";
import { FilterOption } from "@silverbulletmd/common/types";
@@ -37,6 +37,9 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
"editor.getCursor": (): number => {
return editor.editorView!.state.selection.main.from;
},
"editor.getSelection": (): { from: number; to: number } => {
return editor.editorView!.state.selection.main;
},
"editor.save": async () => {
return editor.save(true);
},
@@ -127,6 +130,16 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
},
});
},
"editor.setSelection": (ctx, from: number, to: number) => {
let editorView = editor.editorView!;
editorView.dispatch({
selection: {
anchor: from,
head: to,
},
});
},
"editor.insertAtCursor": (ctx, text: string) => {
let editorView = editor.editorView!;
let from = editorView.state.selection.main.from;