parseDOM for tab

I created a node for inserting tabs:

tab: {
	inline: true,
	group: "inline",
	parseDOM: ???
	toDOM() { return ["span", { style: "white-space:pre" }, "\t"] }	}
}

which I then use in buildKeymap like this:

  function insertTab(state, dispatch) {
    dispatch(state.tr.replaceSelectionWith(schema.nodes.tab.create()).scrollIntoView())
    return true
  }  
  if (type = schema.nodes.tab) {
    bind("Tab", insertTab)
  }

This all works quite well.

I need help writing the parseDOM method for the node. How do I parse the tag (span), white-space:pre style and the internal tab character ?

thanks !

1 Like

Iā€™d give the span a class of tab and a parse rule like [{tag: "span.tab"}].

1 Like