Hidden nodes

Hey,

we have situations where we want to hide nodes under certain circumstances. They should continue to be part of the document, and their contents should not be lost, but they should not be shown (temporarily).

What has worked well in the past is to simply add an attribute (hidden) and then use CSS declaration of display: none; to make sure those nodes are not shown.

This still works in most situations, but I recently noticed that sometimes the caret is being moved so it ends up in a node that is currently hidden when using the arrow-keys. I assume this is when ProseMirror is overriding what the browser would do. Currently I am thinking that the easiest will likely be to create a plugin that checks for selection changes and in those cases where the selection ends up in a node that should be hidden, it simply moves the caret further in whatever direction it was going until it ends up in a not-hidden node.

Or does anyone here have other good ideas?

I think that would work well.

Done. And looks like it works!

@johanneswilm I have the same problem. Could you possibly share a code snippet?

Hey @davidka, we did this in this plugin: https://github.com/fiduswriter/fiduswriter/blob/develop/document/static/js/es6_modules/editor/statePlugins/jump-hidden-nodes.js

Hidden nodes have a hidden-attribute set to true. Hope that helps!

@johanneswilm what do you do when you press delete just after the hidden node? for me, it is deleting the hidden node. What I want is it to skip the hidden node altogether

@xerosanyam Things seem to have changed relatively recently for me for some reason without that being due to prosemirror (see Selection in nodeViews outside of contentDOM). But also, I was using this for hiding text block nodes that were prevented from being deleted by one of the plugins, so I wouldn’t have come across your issue anyway.

hey @johanneswilm, which plugin are you talking about here. could you please share

I am facing a similar problem as @xerosanyam

@jabberthonky One of the Fidus Writer specific plugins. We are running ProseMirror with 23 different plugins that we wrote ourselves. So it’s nothing you should worry about. I am just saying the deletion issue that @xerosanyam was facing may not have been an issue for us due to our plugins.