Missing Rules(Tags) in schema.cached.domParser

I built an editor with several custom Tags using PM. They work fine except for copy/paste. I found that only 3 (of the 14 tags fail to be pasted properly). While debugging I came across the function:

// :: (Schema) → DOMParser
  // Construct a DOM parser using the parsing rules listed in a
  // schema's [node specs](#model.NodeSpec.parseDOM), reordered by
  // [priority](#model.ParseRule.priority).

DOMParser.fromSchema = function fromSchema(schema) {
    return schema.cached.domParser || (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));

The problem is even though the schema has all the definitions of the tags in it’s spec and nodes members, the DOMParser will ignore 3 of them for some reason and will return a parser without this 3 tags. (I can find the definitions of all tags correctly defined in the resulting js file after the bundler - rollup in my case) I.e. the resulting parser.rules contains only 11 Rules instead of 14 (and hence only the 3 missing tags could not be pasted properly). I do not get any error messages or warnings and only the paste does not work. The tags are displayed properly and appear in the document structure correctly. I can add, edit and delete them in the editor just as the rest of all tags.

Here is the definition of one of the 3 “problem” tags:

const s1DOM = ['h2', { class: 's1' }, 0]
S1: {
   content: "inline*",
   group: "block",
  draggable: false,
  parseDom: [{ tag: 'h2.s1' }],
  toDOM(node) { return s1DOM }
}, ...

The other problem tag is an img tag with some special attributes and a div tag containing one or more paragraphs.

I have similar other elements that work without any problems.

What could cause this behavior and what could I try to fix it or how to find the reason for it?

Thanks a lot for your time!

P.S. : I’m sorry I could not make a simple project to reproduce the bug and also could not paste the whole project code here. I need just a clue what could cause this strange behavior by DOMParser.fromSchema

I think the problem is the capitalization of parseDOM – your property is called paseDom, with lower-case om.

1 Like

Exactly that was the problem. I would never notice it.

Thank you very much!