How to use prosemirror-schema-list - 10 common examples

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 pubpub / pubpub-editor / src / addons / FormattingMenu / formattingMenuConfig.js View on Github external
function toggleWrapList(type) {
		if (blockTypeIsActive(type)) {
			return lift(view.state, view.dispatch);
		}
		const wrapFunction = wrapInList(type);
		return wrapFunction(view.state, view.dispatch);
	}
	/* -------------- */
github pubpub / pubpub-editor / src / addons / HeaderMenu / headerMenuConfig.js View on Github external
function toggleWrapList(type) {
		if (blockTypeIsActive(type)) {
			return lift(view.state, view.dispatch);
		}
		const wrapFunction = wrapInList(type);
		return wrapFunction(view.state, view.dispatch);
	}
	/* -------------- */
github gamejolt / frontend-lib / components / content / content-editor / plugins / commands / keymap.ts View on Github external
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;
}
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 ProseMirror / website / example / basic / index.js View on Github external
// code{
import {EditorState} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
import {Schema, DOMParser} from "prosemirror-model"
import {schema} from "prosemirror-schema-basic"
import {addListNodes} from "prosemirror-schema-list"
import {exampleSetup} from "prosemirror-example-setup"

// Mix the nodes from prosemirror-schema-list into the basic schema to
// create a schema with list support.
const mySchema = new Schema({
  nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"),
  marks: schema.spec.marks
})

window.view = new EditorView(document.querySelector("#editor"), {
  state: EditorState.create({
    doc: DOMParser.fromSchema(mySchema).parse(document.querySelector("#content")),
    plugins: exampleSetup({schema: mySchema})
  })
})
// }
github pubpub / pubpub-editor / packages / pubpub-prose / src / prosemirror-setup / schema / buildSchema.js View on Github external
},
	toDOM: function(node) {
		return ['span', node.attrs.content];
	},
	inline: true,
};


const schemaNodes = basicSchema.spec.nodes
.addBefore('horizontal_rule', 'page_break', PageBreak)
.addBefore('horizontal_rule', 'emoji', Emoji);

// const listSchema = addListNodes(schemaNodes, "paragraph block*", "block");
// const tableSchema = addTableNodes(listSchema, "paragraph block*", "block");

const listSchema = addListNodes(schemaNodes, 'paragraph block*', 'block');
const tableSchema = addTableNodes(listSchema, 'paragraph block*', 'block');

export const schema = new Schema({
	nodes: tableSchema,
	marks: basicSchema.spec.marks.addBefore('code', 'sub', SubMark).addBefore('code', 'sup', SupMark).addBefore('code', 'strike', StrikeThroughMark),
	topNode: 'doc'
});

export const createSchema = () => {
	return new Schema({
		nodes: tableSchema,
		marks: basicSchema.markSpec.addBefore('code', 'sub', SubMark).addBefore('code', 'sup', SupMark).addBefore('code', 'strike', StrikeThroughMark)
	});
};

const migrateMarks = (node)=> {
github cosmocode / dokuwiki-plugin-prosemirror / script / schema.js View on Github external
};
    nodes = nodes.update('doc', doc);

    // heading shall only contain unmarked text
    const heading = nodes.get('heading');
    heading.content = 'text*';
    heading.marks = '';
    heading.group = 'baseonly';
    nodes = nodes.update('heading', heading);

    orderedList.group = 'container';
    orderedList.content = 'list_item+';
    nodes = nodes.update('ordered_list', orderedList);

    bulletList.group = 'container';
    bulletList.content = 'list_item+';
    nodes = nodes.update('bullet_list', bulletList);

    listItem.content = '(paragraph | protected_block | substitution_block)+ (ordered_list | bullet_list)?';
    nodes = nodes.update('list_item', listItem);

    nodes = nodes.append(tableNodes({
        tableGroup: 'container',
        cellContent: '(paragraph | protected_block | substitution_block)+',
        cellAttributes: {
            align: {
                default: '',
                setDOMAttr(val, attr) {
                    if (!val) {
                        // eslint-disable-next-line no-param-reassign
                        attr.class = null;
                        return;
github cosmocode / dokuwiki-plugin-prosemirror / script / schema.js View on Github external
notoc: { default: false },
    };
    nodes = nodes.update('doc', doc);

    // heading shall only contain unmarked text
    const heading = nodes.get('heading');
    heading.content = 'text*';
    heading.marks = '';
    heading.group = 'baseonly';
    nodes = nodes.update('heading', heading);

    orderedList.group = 'container';
    orderedList.content = 'list_item+';
    nodes = nodes.update('ordered_list', orderedList);

    bulletList.group = 'container';
    bulletList.content = 'list_item+';
    nodes = nodes.update('bullet_list', bulletList);

    listItem.content = '(paragraph | protected_block | substitution_block)+ (ordered_list | bullet_list)?';
    nodes = nodes.update('list_item', listItem);

    nodes = nodes.append(tableNodes({
        tableGroup: 'container',
        cellContent: '(paragraph | protected_block | substitution_block)+',
        cellAttributes: {
            align: {
                default: '',
                setDOMAttr(val, attr) {
                    if (!val) {
                        // eslint-disable-next-line no-param-reassign
                        attr.class = null;
github cosmocode / dokuwiki-plugin-prosemirror / script / schema.js View on Github external
// heading shall only contain unmarked text
    const heading = nodes.get('heading');
    heading.content = 'text*';
    heading.marks = '';
    heading.group = 'baseonly';
    nodes = nodes.update('heading', heading);

    orderedList.group = 'container';
    orderedList.content = 'list_item+';
    nodes = nodes.update('ordered_list', orderedList);

    bulletList.group = 'container';
    bulletList.content = 'list_item+';
    nodes = nodes.update('bullet_list', bulletList);

    listItem.content = '(paragraph | protected_block | substitution_block)+ (ordered_list | bullet_list)?';
    nodes = nodes.update('list_item', listItem);

    nodes = nodes.append(tableNodes({
        tableGroup: 'container',
        cellContent: '(paragraph | protected_block | substitution_block)+',
        cellAttributes: {
            align: {
                default: '',
                setDOMAttr(val, attr) {
                    if (!val) {
                        // eslint-disable-next-line no-param-reassign
                        attr.class = null;
                        return;
                    }
                    // eslint-disable-next-line no-param-reassign
                    attr.class = `${val}align`;