diff --git a/src/extensions/markdown/CodeBlock/CodeBlockSpecs/index.ts b/src/extensions/markdown/CodeBlock/CodeBlockSpecs/index.ts index b6efc23b..f0a7cc64 100644 --- a/src/extensions/markdown/CodeBlock/CodeBlockSpecs/index.ts +++ b/src/extensions/markdown/CodeBlock/CodeBlockSpecs/index.ts @@ -19,7 +19,7 @@ export const CodeBlockSpecs: ExtensionAuto = (builder, op code: true, marks: '', selectable: true, - allowSelection: true, + allowSelection: false, parseDOM: [ { tag: 'pre', @@ -68,6 +68,16 @@ export const CodeBlockSpecs: ExtensionAuto = (builder, op throw new Error('Unexpected toYfm() call on fence node'); }, })); + builder.addKeymap(() => ({ + Tab: (state, dispatch) => { + const {$anchor, $head} = state.selection; + if ($anchor.sameParent($head) && $anchor.parent.type.name === codeBlockNodeName) { + dispatch?.(state.tr.replaceSelectionWith(state.schema.text('\t')).scrollIntoView()); + return true; + } + return false; + }, + })); }; function removeNewLineAtEnd(content: string): string {