How to use the prosemirror-schema-list.splitListItem function in prosemirror-schema-list

To help you get started, we’ve selected a few prosemirror-schema-list examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cosmocode / dokuwiki-plugin-prosemirror / script / plugins / Keymap / keymap.js View on Github external
function getKeymapPlugin(schema) {
    const customKeymap = {};

    customKeymap.Enter = splitListItem(schema.nodes.list_item); // eslint-disable-line import/no-named-as-default-member

    const combinedKeymapUnion = Object.keys(customKeymap).reduce((acc, key) => {
        if (baseKeymap[key]) {
            acc[key] = chainCommands(customKeymap[key], baseKeymap[key]);
        }
        return acc;
    }, {});

    const mergedKeymap = {
        ...baseKeymap,
        ...customKeymap,
        ...combinedKeymapUnion,
    };

    return keymap(mergedKeymap);
}
github cosmocode / dokuwiki-plugin-prosemirror / script / keymap.js View on Github external
import { keymap } from 'prosemirror-keymap';
import { splitListItem } from 'prosemirror-schema-list';
import schema from './schema';


const customKeymap = {};

customKeymap.Enter = splitListItem(schema.nodes.list_item);

const customKeymapPlugin = keymap(customKeymap);

// exports.customKeymapPlugin = customKeymapPlugin;

export default customKeymapPlugin;
github pubpub / pubpub / src / components / AtomTypes / Document / proseEditor / keymap.js View on Github external
bind("Shift-Ctrl-Digit8", wrapInList(type))
  if (type = schema.nodes.ordered_list)
    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
    })
  }
github alidcastano / vue-prosemirror-editor / src / plugins / keys.js View on Github external
    'Shift-Enter': (listItem) => splitListItem(listItem),
    'Mod-[': (listItem) => liftListItem(listItem),
github ifiokjr / remirror / @remirror / core-extensions / src / nodes / list-item-extension.ts View on Github external
public keys({ type }: ExtensionManagerNodeTypeParams) {
    return {
      Enter: splitListItem(type),
      Tab: sinkListItem(type),
      'Shift-Tab': liftListItem(type),
    };
  }
}
github nib-edit / Nib / packages / core / src / plugins / list / commands.js View on Github external
export const splitListItemCmd = () => (state, dispatch) => {
  const {
    selection: { $anchor },
    schema: { nodes }
  } = state;
  const currentNode = $anchor.node($anchor.depth - 1);
  if (currentNode.type === nodes.listItem) {
    if (currentNode.textContent.length > 0) {
      return splitListItem(nodes.listItem)(state, dispatch);
    }
    return liftListItem(nodes.listItem)(state, dispatch);
  }
  return false;
};
github pubpub / pubpub-editor / src / schema / setup / keymap.js View on Github external
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));
	}
	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 }));
		}
	}
github ProseMirror / prosemirror-example-setup / src / keymap.js View on Github external
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))
    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
    })
  }
github tinacms / tinacms / packages / tinacms / fields / src / Wysiwyg / state / plugins / keymap / keymap.ts View on Github external
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))
    bind('Shift-Tab', liftListItem(type))
  }

  return keys
}
github pubpub / pubpub-editor / src / plugins / keymap.js View on Github external
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));
	}
	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 }));
		}
	}