Block marks wrapping behaviour


#1

Hi,

When two adjacent ProseMirror nodes have a block mark with the same attributes, the block mark DOM node wraps both nodes:

<div class="block-mark">
  <div class="node-1"></div>
  <div class="node-2"></div>
</div>

as opposed to wrapping each node as it does when mark attributes are different:

<div class="block-mark">
  <div class="node-1"></div>
</div>
<div class="block-mark">
  <div class="node-2"></div>
</div>

While this is a reasonable optimisation, I wonder if it makes sense to have the ability to opt out from that wrapping behaviour and have a separate block mark DOM node for each node?

The reason I’m asking is that we’re thinking about using it for absolute positioning UI elements relatively to the mark DOM node, and this optimisation is kinda getting in the way :slight_smile:


#2

Yes, for blocks that would make sense. (Much of the mark code was written with only inline content in mind.) Do you want to create an RFC for this?


#3

will do, thanks!


#4

I created a PR: https://github.com/ProseMirror/prosemirror-view/pull/43

I also realised that nodeView API for marks is different from the documentation where the 3rd argument is a boolean “inline” flag instead of getPos. We should probably update the docs.


#5

Could you start with a small proposal of how the feature works? We have a process where new features have to go through that, to make sure the community can take a look before they are finalized.


#6

Here’s the proposal: https://github.com/ProseMirror/rfcs/pull/11