toDOM doesn't work for top doc node

toDOM doesn’t work for the top doc node (or maybe there is something else going on).

const mySchema = new Schema({
  nodes: {
    text: {},
    doc: {
      content: "text*",
      toDOM: (node) => ["span", { role: "textbox" }, 0]
  marks: {}

However, the top document node is still rendered as a div. I believe I can add the “role: textbox” attribute via editor props, but is there any way to change the top dom node?

That’s intentional—the document node just holds content, and that content is, unless you use the {mount: ...} argument format to EditorView, always rendered in a <div> created by the editor view.

1 Like

Is there any other way to change the top-level element that is used? For my use-case, the editor view is created without a parent (new EditorView(null, ...)) and mounted to its parent afterward. Is there any way to either 1. (ideally) create the editor view without a top level element, and mount it to a parent later or 2. modify the top level element used when creating the editor?