Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function toggleWrapList(type) {
if (blockTypeIsActive(type)) {
return lift(view.state, view.dispatch);
}
const wrapFunction = wrapInList(type);
return wrapFunction(view.state, view.dispatch);
}
/* -------------- */
function toggleWrapList(type) {
if (blockTypeIsActive(type)) {
return lift(view.state, view.dispatch);
}
const wrapFunction = wrapInList(type);
return wrapFunction(view.state, view.dispatch);
}
/* -------------- */
function wrapListItem(nodeType, options) {
return cmdItem(wrapInList(nodeType, options.attrs), options)
}
export const toggleList = (type: NodeType, itemType: NodeType): CommandFunction => (state, dispatch) => {
const isActive = nodeActive(state, type);
if (isActive) {
return liftListItem(itemType)(state, dispatch);
}
return wrapInList(type)(state, dispatch);
};
bind("Mod-BracketLeft", lift)
bind("Escape", selectParentNode)
if (type = schema.marks.strong) {
bind("Mod-b", toggleMark(type))
bind("Mod-B", toggleMark(type))
}
if (type = schema.marks.em) {
bind("Mod-i", toggleMark(type))
bind("Mod-I", toggleMark(type))
}
if (type = schema.marks.code)
bind("Mod-`", toggleMark(type))
if (type = schema.nodes.bullet_list)
bind("Shift-Ctrl-8", wrapInList(type))
if (type = schema.nodes.ordered_list)
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))
const wrapIntoList = (state, dispatch, listType) => {
return baseCommand.autoJoin(
wrapInList(listType),
(before, after) => before.type === after.type && before.type === listType
)(state, dispatch);
};
'Shift-Ctrl-9': (orderedList) => wrapInList(orderedList),
'Enter': (hardBreak) => chainCommands(exitCode, insertNode(hardBreak)),
static getMenuItem(schema) {
if (!this.isAvailable(schema)) {
throw new Error('Ordered list not available in schema!');
}
return new MenuItem({
icon: svgIcon('format-list-numbers'),
command: wrapInList(schema.nodes.ordered_list, {}),
label: LANG.plugins.prosemirror['label:orderedList'],
});
}
}
static getMenuItem(schema) {
if (!this.isAvailable(schema)) {
throw new Error('Bullet list not available in schema!');
}
return new MenuItem({
icon: svgIcon('format-list-bulleted'),
command: wrapInList(schema.nodes.bullet_list, {}),
label: LANG.plugins.prosemirror['label:bulletList'],
});
}
}