Hi,
I use this schema:
import { Schema } from 'prosemirror-model';
import { addListNodes, bulletList, listItem, orderedList } from 'prosemirror-schema-list';
import { em, li, ol, strong, ul, underline } from './marks';
import { doc, text, paragraph } from './nodes';
type Marks = 'ul' | 'ol' | 'li' | 'em' | 'strong' | 'underline';
type Nodes = 'doc' | 'bulletList' | 'orderedList' | 'listItem' | 'text' | 'paragraph';
const localSchema = new Schema<Nodes, Marks>({
nodes: { doc, bulletList, orderedList, listItem, text, paragraph },
marks: { ul, ol, li, em, strong, underline },
});
export const mySchema = new Schema({
nodes: addListNodes(localSchema.spec.nodes, 'paragraph block*', 'block'),
marks: localSchema.spec.marks,
});
The mark for ul
is very basic:
export const ul: MarkSpec = {
parseDOM: [{ tag: 'ul' }],
toDOM: () => ['ul', 0],
};
Everything works fine, I can create and toggle lists in the editor. However, if I have a ul
in the initial HTML (on load), ór if I paste a ul
into the editor, it is not recognized as such (although it is displayed as such).
If I put the cursor somewhere in the list, the list menu button is not displayed as active, and if I press the button, a second bullet is added.
I think it is because the ul is wrapped in a paragraph on load.
What am I doing wrong?