Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
}
/**
* Underline – <span style="text-decoration: underline">
*/
if ((type = schema.marks.underline)) {
bind('Mod-u', toggleMark(type))
}
/**
* Hard Break – <br>
*/
if ((type = schema.nodes.hard_break)) {
const br = type,
cmd = chainCommands(exitCode, (state, dispatch) => {
// @ts-ignore
dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView())
return true
})
if (!schema.nodes.paragraph) {
bind('Enter', cmd)
}
bind('Mod-Enter', cmd)
bind('Shift-Enter', cmd)
if (mac) bind('Ctrl-Enter', cmd)
}
/**
* Headings -
*/
if ((type = schema.nodes.heading)) {</span>
EXTERNAL = "external",
FORMATTING = "autoformatting",
FLOATING_TB = "floatingToolbar",
KEYBOARD = "keyboard",
INSERT_MENU = "insertMenu",
MANUAL = "manual",
PICKER = "picker",
PICKER_CLOUD = "cloudPicker",
QUICK_INSERT = "quickInsert",
SHORTCUT = "shortcut",
TOOLBAR = "toolbar",
TYPEAHEAD = "typeAhead",
}
const not = (fn: (args: T) => boolean) => (arg: T) => !fn(arg)
const tryUndoInputRuleElseUndoHistory = chainCommands(undoInputRule, undoCmd)
export const removeBlockMarks = (
state: EditorState,
marks: Array,
): Transaction | undefined => {
// tslint:disable-next-line:no-shadowed-variable
const { selection, schema } = state
let { tr } = state
// Marks might not exist in Schema
const marksToRemove = marks.filter(Boolean)
if (marksToRemove.length === 0) {
return undefined
}
/** Saves an extra dispatch */
function bind(key: string, cmd: any) {
if (keys[key]) {
cmd = chainCommands(cmd, keys[key])
}
keys[key] = cmd
}
function bind(key: string, cmd: any) {
if (keys[key]) {
cmd = chainCommands(cmd, keys[key])
}
keys[key] = cmd
}
}
if (schema.marks.link) {
bind('Mod-k', toggleMark(schema.marks.link));
}
if (schema.nodes.bullet_list) {
bind('Shift-Ctrl-8', wrapInList(schema.nodes.bullet_list));
}
if (schema.nodes.ordered_list) {
bind('Shift-Ctrl-9', wrapInList(schema.nodes.ordered_list));
}
if (schema.nodes.blockquote) {
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));
'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;
}
public keys({ type }: ExtensionManagerNodeTypeParams) {
const command = chainCommands(exitCode, (state, dispatch) => {
if (dispatch) {
dispatch(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
}
return true;
});
return {
'Mod-Enter': command,
'Shift-Enter': command,
};
}
}
public keys({ type }: SchemaNodeTypeParams) {
const command = chainCommands(exitCode, (state, dispatch) => {
if (dispatch) {
dispatch(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
}
return true;
});
return {
'Mod-Enter': command,
'Shift-Enter': command,
};
}
}