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);
}
/* -------------- */
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;
}
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);
}
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;
// 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})
})
})
// }
},
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)=> {
};
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;
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;
// 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`;