# Hidden nodes

**URL:** <https://discuss.prosemirror.net/t/hidden-nodes/999>\
**Category:** Uncategorized\
**Created:** [October 13, 2017, 8:09pm UTC](https://discuss.prosemirror.net/t/hidden-nodes/999 "2017-10-13T20:09:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 13, 2017, 8:09pm UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/1 "2017-10-13T20:09:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 13, 2017, 8:49pm UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/2 "2017-10-13T20:49:03Z")

</div>

> [@johanneswilm](#):
>
> 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.

I think that would work well.

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 14, 2017, 2:47am UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/3 "2017-10-14T02:47:41Z")

</div>

Done. And looks like it works!

---

<div class="post-metadata">

**Author:** ![davidka](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/davidka/32/429_2.png) [@davidka](https://discuss.prosemirror.net/u/davidka)\
**Post date:** [October 25, 2017, 9:21am UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/4 "2017-10-25T09:21:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 28, 2017, 7:27pm UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/5 "2017-10-28T19:27:05Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![xerosanyam](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/xerosanyam/32/884_2.png) [@xerosanyam](https://discuss.prosemirror.net/u/xerosanyam)\
**Post date:** [October 18, 2019, 6:27am UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/6 "2019-10-18T06:27:08Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 18, 2019, 8:28am UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/7 "2019-10-18T08:28:29Z")

</div>

@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](https://discuss.prosemirror.net/t/selection-in-nodeviews-outside-of-contentdom/2282/3)). 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.

---

<div class="post-metadata">

**Author:** ![jabberthonky](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@jabberthonky](https://discuss.prosemirror.net/u/jabberthonky)\
**Post date:** [October 25, 2019, 9:12am UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/8 "2019-10-25T09:12:30Z")

</div>

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

I am facing a similar problem as @xerosanyam

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 25, 2019, 9:22am UTC](https://discuss.prosemirror.net/t/hidden-nodes/999/9 "2019-10-25T09:22:28Z")

</div>

@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.
