Preventing text block joins


#1

Hi, I would like to prevent text blocks from being joined by UI interaction.

For example, in the gif below, the paragraph text is being joined with the text in the blockquote after deletion of the selected range, which is the behavior I would like to prevent.

text_join

The only way I can think of to do this is to filter out offending ReplaceStep(s) in Plugin#filterTransaction and rebuild and re-dispatch them to delete the text in each respective block without joining them.

I tried using a custom schema, but it appears that joining text ignores schema requirements and is joined anyway.

Is there an easier way that you can think of, or am I on the right track? Any help would be appreciated.


#2

Definitely not—schema constraints are always enforced.

Filtering transactions seems like a reasonable approach here, though.


#3

Ok, I must be doing something wrong with the schema. Thanks.


#4

The only way I found to prevent auto joining of text blocks (via schema constraints) is by defining an inline node with text content with something like this:

blockquote_text: {
      inline: true,
      content: "text*",
      parseDOM: [{ tag: "p.blockquote_text" }],
      toDOM() { return ["p", {class: "blockquote_text"}, 0]; }
},
blockquote: {
      content: "blockquote_text*",
      group: "block", 
      defining: true,
      parseDOM: [{ tag: "blockquote" }],
      toDOM() { return ["blockquote", 0]; }
}

I am wary of this because I know that inline nodes with child content are frowned upon without a custom NodeView. In addition, it introduces the BRHackViewDesc which makes me uncomfortable, because, well, it has the word hack in it, as well as introducing a <br> tag. Also, I have never seen this type of schema defined anywhere else.

Is this a bad idea, or is an inline node with text content reasonable in your expert opinion?


#5

Probably, yes. I’d handle this on the command or transaction level, not in the schema.


#6

Ok, thanks.