Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return true;
},
// Add/remove link
'Mod-k': showLinkModal(editor.capabilities, schema),
} as { [k: string]: any };
const enterCommands = [] as PMKeymapCommand[];
if (editor.capabilities.heading) {
enterCommands.push(splitHeading());
}
if (editor.capabilities.list) {
enterCommands.push(splitListItem(schema.nodes.listItem));
keymap['Shift-Tab'] = ContentListService.liftListItem(schema.nodes.listItem);
keymap['Tab'] = sinkListItem(schema.nodes.listItem);
}
keymap['Enter'] = chainCommands(...enterCommands);
if (!isMac) {
keymap['Mod-y'] = redo;
}
return keymap;
}
bind('Ctrl->', wrapIn(schema.nodes.blockquote));
}
if (schema.nodes.hard_break) {
const cmd = chainCommands(exitCode, (state, dispatch) => {
dispatch(state.tr.replaceSelectionWith(schema.nodes.hard_break.create()).scrollIntoView());
return true;
});
bind('Mod-Enter', cmd);
bind('Shift-Enter', cmd);
if (mac) bind('Ctrl-Enter', cmd);
}
if (schema.nodes.list_item) {
bind('Enter', splitListItem(schema.nodes.list_item));
bind('Mod-[', liftListItem(schema.nodes.list_item));
bind('Mod-]', sinkListItem(schema.nodes.list_item));
bind('Tab', sinkListItem(schema.nodes.list_item));
bind('Shift-Tab', liftListItem(schema.nodes.list_item));
}
if (schema.nodes.paragraph) {
bind('Shift-Ctrl-0', setBlockType(schema.nodes.paragraph));
}
if (schema.nodes.code_block) {
bind('Shift-Ctrl-\\', setBlockType(schema.nodes.code_block));
}
if (schema.nodes.heading) {
for (let index = 1; index <= 6; index++) {
bind(`Shift-Ctrl-${index}`, setBlockType(schema.nodes.heading, { level: index }));
}
}
if (schema.nodes.horizontal_rule) {
bind('Mod-_', (state, dispatch) => {
dispatch(state.tr.replaceSelectionWith(schema.nodes.horizontal_rule.create()).scrollIntoView());
'Mod-]': (listItem) => sinkListItem(listItem),
'Shift-Ctrl-0': (paragraph) => setBlockType(paragraph),
});
const orderedList = new MenuItem({
icon: svgIcon('format-list-numbers'),
command: wrapInList(schema.nodes.ordered_list, {}),
label: 'Wrap in ordered list',
});
const liftListItemMenuItem = new MenuItem({
icon: svgIcon('arrow-expand-left'),
command: liftListItem(schema.nodes.list_item),
label: 'Lift list item',
});
const sinkListItemMenuItem = new MenuItem({
icon: svgIcon('arrow-expand-right'),
command: sinkListItem(schema.nodes.list_item),
label: 'Sink list item',
});
const paragraphMenuItem = new MenuItem({
command: setBlockType(schema.nodes.paragraph),
icon: svgIcon('format-paragraph'),
label: 'Paragraph',
});
const codeBlockMenuItem = new MenuItem({
command: setBlockTypeNoAttrCheck(schema.nodes.code_block),
icon: svgIcon('code-braces'),
label: 'Code Block',
});
const blockquoteMenuItem = new MenuItem({
if (schema.nodes.hard_break) {
const cmd = chainCommands(exitCode, (state, dispatch) => {
dispatch(
state.tr.replaceSelectionWith(schema.nodes.hard_break.create()).scrollIntoView(),
);
return true;
});
bind('Mod-Enter', cmd);
bind('Shift-Enter', cmd);
if (mac) bind('Ctrl-Enter', cmd);
}
if (schema.nodes.list_item) {
bind('Enter', splitListItem(schema.nodes.list_item));
bind('Mod-[', liftListItem(schema.nodes.list_item));
bind('Mod-]', sinkListItem(schema.nodes.list_item));
bind('Tab', sinkListItem(schema.nodes.list_item));
bind('Shift-Tab', liftListItem(schema.nodes.list_item));
}
if (schema.nodes.paragraph) {
bind('Shift-Ctrl-0', setBlockType(schema.nodes.paragraph));
}
if (schema.nodes.code_block) {
bind('Shift-Ctrl-\\', setBlockType(schema.nodes.code_block));
}
if (schema.nodes.heading) {
for (let index = 1; index <= 6; index += 1) {
bind(`Shift-Ctrl-${index}`, setBlockType(schema.nodes.heading, { level: index }));
}
}
if (schema.nodes.horizontal_rule) {
bind('Mod-_', (state, dispatch) => {
dispatch(
bind('Shift-Ctrl-0', setBlockType(type))
}
/**
* Horizontal Rule
*/
if ((type = schema.nodes.horizontal_rule)) {
bind('Mod-Enter', insertHr)
}
/**
* Lists
*/
if ((type = schema.nodes.list_item)) {
bind('Enter', splitListItem(type))
bind('Tab', sinkListItem(type))
bind('Shift-Tab', liftListItem(type))
}
return keys
}
public keys({ type }: SchemaNodeTypeParams) {
return {
Enter: splitListItem(type),
Tab: sinkListItem(type),
'Shift-Tab': liftListItem(type),
};
}
}
bind("Shift-Ctrl-Digit9", wrapInList(type))
if (type = schema.nodes.blockquote)
bind("Shift-Ctrl-Period", wrapIn(type))
if (type = schema.nodes.hard_break) {
let br = type, cmd = chainCommands(newlineInCode, (state, onAction) => {
onAction(state.tr.replaceSelection(br.create()).scrollAction())
return true
})
bind("Mod-Enter", cmd)
bind("Shift-Enter", cmd)
if (mac) bind("Ctrl-Enter", cmd)
}
if (type = schema.nodes.list_item) {
bind("Enter", splitListItem(type))
bind("Mod-BracketLeft", liftListItem(type))
bind("Mod-BracketRight", sinkListItem(type))
}
if (type = schema.nodes.paragraph)
bind("Shift-Ctrl-Digit0", setBlockType(type))
if (type = schema.nodes.code_block)
bind("Shift-Ctrl-Backslash", setBlockType(type))
if (type = schema.nodes.heading) for (let i = 1; i <= 6; i++)
bind("Shift-Ctrl-Digit" + i, setBlockType(type, {level: i}))
if (type = schema.nodes.horizontal_rule) {
let hr = type
bind("Mod-Shift-Minus", (state, onAction) => {
onAction(state.tr.replaceSelection(hr.create()).scrollAction())
return true
})
}
if (schema.nodes.table_row) {
bind("Shift-Ctrl-9", wrapInList(type))
if (type = schema.nodes.blockquote)
bind("Ctrl->", wrapIn(type))
if (type = schema.nodes.hard_break) {
let br = type, cmd = chainCommands(exitCode, (state, dispatch) => {
dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView())
return true
})
bind("Mod-Enter", cmd)
bind("Shift-Enter", cmd)
if (mac) bind("Ctrl-Enter", cmd)
}
if (type = schema.nodes.list_item) {
bind("Enter", splitListItem(type))
bind("Mod-[", liftListItem(type))
bind("Mod-]", sinkListItem(type))
}
if (type = schema.nodes.paragraph)
bind("Shift-Ctrl-0", setBlockType(type))
if (type = schema.nodes.code_block)
bind("Shift-Ctrl-\\", setBlockType(type))
if (type = schema.nodes.heading)
for (let i = 1; i <= 6; i++) bind("Shift-Ctrl-" + i, setBlockType(type, {level: i}))
if (type = schema.nodes.horizontal_rule) {
let hr = type
bind("Mod-_", (state, dispatch) => {
dispatch(state.tr.replaceSelectionWith(hr.create()).scrollIntoView())
return true
})
}
return keys
bind('Shift-Ctrl-9', wrapInList(type));
if (type = schema.nodes.blockquote)
bind('Ctrl->', wrapIn(type));
if (type = schema.nodes.hard_break) {
let br = type, cmd = chainCommands(newlineInCode, (state, onAction) => {
onAction(state.tr.replaceSelection(br.create()).scrollAction());
return true;
});
bind('Mod-Enter', cmd);
bind('Shift-Enter', cmd);
if (mac) bind('Ctrl-Enter', cmd);
}
if (type = schema.nodes.list_item) {
bind('Enter', splitListItem(type));
bind('Mod-[', liftListItem(type));
bind('Mod-]', sinkListItem(type));
}
if (type = schema.nodes.paragraph)
bind('Shift-Ctrl-0', setBlockType(type));
if (type = schema.nodes.code_block)
bind('Shift-Ctrl-\\', setBlockType(type));
if (type = schema.nodes.heading)
for (let i = 1; i <= 6; i++) bind(`Shift-Ctrl-${ i }`, setBlockType(type, { level: i }));
if (type = schema.nodes.horizontal_rule) {
const hr = type;
bind('Mod-_', (state, onAction) => {
onAction(state.tr.replaceSelection(hr.create()).scrollAction());
return true;
});
}
if (schema.nodes.table_row) {