Skip to content

Commit

Permalink
fix: select all in code block
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud committed Aug 23, 2023
1 parent 6631342 commit 5bbff5d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/nodes/CodeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ const CodeBlock = TiptapCodeBlockLowlight.extend({
return VueNodeViewRenderer(CodeBlockView)
},

addKeyboardShortcuts() {
return {
'Mod-a': () => {
if (!this.editor.isActive('codeBlock')) {
return
}

const nodeSize = this.editor.state.selection.$from.node().nodeSize
this.editor.commands.selectParentNode()
const from = this.editor.state.selection.$from.pos
const to = from + nodeSize
this.editor.commands.setTextSelection({ from, to })

return true
},
}
},

})

export default CodeBlock

0 comments on commit 5bbff5d

Please sign in to comment.