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;
});
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(
state.tr
.replaceSelectionWith(schema.nodes.horizontal_rule.create())
.scrollIntoView(),
);
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(
state.tr
.replaceSelectionWith(schema.nodes.horizontal_rule.create())
.scrollIntoView(),
);
return true;
});
}
return (state, dispatch, view) => {
const isActive = nodeIsActive(state, type, attrs)
if (isActive) {
return setBlockType(toggletype)(state, dispatch, view)
}
return setBlockType(type, attrs)(state, dispatch, view)
}
}
bind('Mod-0', toggleMark(type))
}
/**
* Blockquote
*/
if ((type = schema.nodes.blockquote)) {
bind('Mod->', wrapIn(type))
bind('Mod-<', liftBlockquote)
}
/**
* Paragraph – <p>
*/
if ((type = schema.nodes.paragraph)) {
bind('Mod-Alt-9', setBlockType(type))
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))</p>
function blockTypeItem(nodeType, options) {
let command = setBlockType(nodeType, options.attrs)
let passedOptions = {
run: command,
select(state) { return command(state) },
active(state) {
let {$from, to, node} = state.selection
if (node) return node.hasMarkup(nodeType, options.attrs)
return to <= $from.end() && $from.parent.hasMarkup(nodeType, options.attrs)
}
}
for (let prop in options) passedOptions[prop] = options[prop]
return new MenuItem(passedOptions)
}
exports.blockTypeItem = blockTypeItem
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({
command: wrapIn(schema.nodes.blockquote),
icon: svgIcon('format-quote-close'),
label: 'Blockquote',
});
})
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
}
this.options.levels.forEach(level => {
keys[`Shift-Ctrl-${level}`] = setBlockType(type, { level });
});
return keys;
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) {
bind('Tab', selectNextCell);
bind('Shift-Tab', selectPreviousCell);
}
doHeading(e: CustomEvent) {
e.stopPropagation()
e.preventDefault()
if (this.editorView && e.detail && e.detail.value && e.detail.value.length) {
setBlockType(this.editorSchema.nodes.heading, {level: parseInt(e.detail.value.replace(/.+ ([0-9]+)/, '$1'))})(this.editorView.state, this.editorView.dispatch)
this.editorView.focus()
}
}