Skip to content

Commit

Permalink
fix: Shortcut key clear format does not need to be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
1943time committed Dec 16, 2023
1 parent 859975e commit 3e3a581
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/renderer/src/editor/utils/editorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down Expand Up @@ -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) || ''}]
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/utils/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down

0 comments on commit 3e3a581

Please sign in to comment.