Moved bold and italics to plug, new file: plug protocol
This commit is contained in:
+2
-12
@@ -373,16 +373,6 @@ export class Editor {
|
||||
...completionKeymap,
|
||||
indentWithTab,
|
||||
...commandKeyBindings,
|
||||
{
|
||||
key: "Ctrl-b",
|
||||
mac: "Cmd-b",
|
||||
run: commands.insertMarker("**"),
|
||||
},
|
||||
{
|
||||
key: "Ctrl-i",
|
||||
mac: "Cmd-i",
|
||||
run: commands.insertMarker("_"),
|
||||
},
|
||||
{
|
||||
key: "Ctrl-k",
|
||||
mac: "Cmd-k",
|
||||
@@ -612,7 +602,7 @@ export class Editor {
|
||||
this.viewState = viewState;
|
||||
this.viewDispatch = dispatch;
|
||||
|
||||
let editor = this;
|
||||
const editor = this;
|
||||
|
||||
useEffect(() => {
|
||||
if (viewState.currentPage) {
|
||||
@@ -641,7 +631,7 @@ export class Editor {
|
||||
<CommandPalette
|
||||
onTrigger={(cmd) => {
|
||||
dispatch({ type: "hide-palette" });
|
||||
editor!.focus();
|
||||
editor.focus();
|
||||
if (cmd) {
|
||||
dispatch({ type: "command-run", command: cmd.command.name });
|
||||
cmd.run().catch((e) => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user