mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 07:24:04 +08:00
handle enter in inline code
This commit is contained in:
@@ -142,6 +142,25 @@ export const mainExtensions = [
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
addKeyboardShortcuts() {
|
||||||
|
return {
|
||||||
|
Enter: ({ editor }) => {
|
||||||
|
const { from, to } = editor.state.selection;
|
||||||
|
if (from !== to) return false;
|
||||||
|
if (!editor.isActive("code")) return false;
|
||||||
|
|
||||||
|
const $from = editor.state.doc.resolve(from);
|
||||||
|
const codeType = editor.state.schema.marks.code;
|
||||||
|
const nodeAfter = $from.nodeAfter;
|
||||||
|
|
||||||
|
if (nodeAfter && codeType.isInSet(nodeAfter.marks)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return editor.chain().unsetCode().splitBlock().run();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
SharedStorage,
|
SharedStorage,
|
||||||
Heading,
|
Heading,
|
||||||
|
|||||||
Reference in New Issue
Block a user