diff --git a/src/renderer/src/editor/utils/editorUtils.ts b/src/renderer/src/editor/utils/editorUtils.ts index 31c078b2..9c6f0532 100644 --- a/src/renderer/src/editor/utils/editorUtils.ts +++ b/src/renderer/src/editor/utils/editorUtils.ts @@ -33,6 +33,7 @@ export class EditorUtils { count++ } } + static moveAfterSpace(editor: Editor, path: Path) { const next = Editor.next(editor, {at: path}) if (!next || !Text.isText(next[0])) { @@ -99,6 +100,7 @@ export class EditorUtils { static copy(data: object) { return JSON.parse(JSON.stringify(data)) } + static cutText(editor: Editor, start: Point, end?: Point) { let leaf = Node.leaf(editor, start.path) let texts: CustomLeaf[] = [{...leaf, text: leaf.text?.slice(start.offset) || ''}] diff --git a/src/renderer/src/utils/keyboard.ts b/src/renderer/src/utils/keyboard.ts index f22f1ad2..d6ec5128 100644 --- a/src/renderer/src/utils/keyboard.ts +++ b/src/renderer/src/utils/keyboard.ts @@ -408,7 +408,7 @@ export class MenuKey { break } - if (Range.isCollapsed(sel) || !Path.equals(Path.parent(sel.focus.path), Path.parent(sel.anchor.path)) || node[0].type === 'code-line') return + if (!Path.equals(Path.parent(sel.focus.path), Path.parent(sel.anchor.path)) || node[0].type === 'code-line') return switch (task) { case 'bold': this.format('bold') @@ -423,7 +423,7 @@ export class MenuKey { this.format('code') break case 'clear': - EditorUtils.clearMarks(this.state.editor, true) + EditorUtils.clearMarks(this.state.editor, !Range.isCollapsed(sel)) break } }, 40)