Hi,
My schema includes a “replace” node which contains two child nodes: label and content. I want these to be displayed on the same line, so I’m using spans to represent them in the DOM. I visually separate the label and the content using ::before and ::after CSS pseudo elements.
replace: {
content: "replace_label replace_content",
group: "block",
defining: true,
parseDOM: [{tag: "div.replace"}],
toDOM() { return ["div", {"class": "replace"}, 0] }
},
replace_label: {
content: "text*",
marks: "",
parseDOM: [{tag: "span.replace_label"}],
toDOM() { return ["span", {"class": "replace_label"}, 0] }
},
replace_content: {
content: "inline*",
parseDOM: [{tag: "span.replace_content"}],
toDOM() { return ["span", {"class": "replace_content"}, 0] }
},
Keyboard navigation of these nodes was problematic, but I was able to fix this by binding custom functions to the Enter and ArrowLeft keys.
One issue that remains is that a <br>
element is inserted when the label is empty, splitting my replace node over two lines. From reading other forum topics, I understand this <br>
is required for things to work. I’ve tried hiding the <br>
using CSS’s display: none
, but this makes it impossible to position the cursor in the label node.
I’ve looked at making the label and content nodes inline elements. If I understand it correctly, other forum posts suggest that inline nodes with text content are not supported. My first experiments with this did result in crashes in PM code.
I’m not sure how to proceed with this. Any suggestions are appreciated! My current idea is to see whether a placeholder could perhaps replace the <br>
, which would solve the problem and provide a better user experience as a nice extra.