Fixes #100 implements a custom Markdown renderer

This commit is contained in:
Zef Hemel
2022-11-01 15:01:28 +01:00
parent b8e27b216e
commit 3d671e8195
20 changed files with 652 additions and 37 deletions
+2
View File
@@ -83,8 +83,10 @@ export function Panel({
editor.dispatchAppEvent(data.name, ...data.args);
}
};
console.log("Registering event handler");
globalThis.addEventListener("message", messageListener);
return () => {
console.log("Unregistering event handler");
globalThis.removeEventListener("message", messageListener);
};
}, []);
+14 -2
View File
@@ -1,5 +1,5 @@
import { Editor } from "../editor.tsx";
import { Transaction } from "../deps.ts";
import { EditorView, Transaction } from "../deps.ts";
import { SysCallMapping } from "../../plugos/system.ts";
import { FilterOption } from "../../common/types.ts";
@@ -113,12 +113,24 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
},
});
},
"editor.moveCursor": (_ctx, pos: number) => {
"editor.moveCursor": (_ctx, pos: number, center = false) => {
editor.editorView!.dispatch({
selection: {
anchor: pos,
},
});
if (center) {
editor.editorView!.dispatch({
effects: [
EditorView.scrollIntoView(
pos,
{
y: "center",
},
),
],
});
}
},
"editor.setSelection": (_ctx, from: number, to: number) => {
const editorView = editor.editorView!;