mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 08:31:43 +03:00
refs https://github.com/TryGhost/Ghost/issues/9505 - a card section isn't markerable so a guard is needed to prevent inserting the soft-break atom
21 lines
649 B
JavaScript
21 lines
649 B
JavaScript
// Key commands will run any time a particular key or key combination is pressed
|
|
// https://github.com/bustlelabs/mobiledoc-kit#configuring-hot-keys
|
|
|
|
export default function (editor) {
|
|
let softReturnKeyCommand = {
|
|
str: 'SHIFT+ENTER',
|
|
|
|
run(editor) {
|
|
if (!editor.range.headSection.isMarkerable) {
|
|
return;
|
|
}
|
|
|
|
editor.run((postEditor) => {
|
|
let softReturn = postEditor.builder.createAtom('soft-return');
|
|
postEditor.insertMarkers(editor.range.head, [softReturn]);
|
|
});
|
|
}
|
|
};
|
|
editor.registerKeyCommand(softReturnKeyCommand);
|
|
}
|