-
Hi, I'm using a plate to create a document editor with a title (similar to notion). How would I disable things like italics, bold, etc. for everything inside a block-element? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I would use a normalizer that removes any formatting that you don't want to support inside the block element. To get started writing a normalizer, override Then, it's just a matter of checking for and removing formatting. For marks, you can use |
Beta Was this translation helpful? Give feedback.
I would use a normalizer that removes any formatting that you don't want to support inside the block element. To get started writing a normalizer, override
editor.normalizeNode
using thewithOverrides
plugin option. You can detect whether the node being normalized is inside the block element using!!getBlockAbove(editor, { match: { type: YOUR_ELEMENT_TYPE } })
.Then, it's just a matter of checking for and removing formatting. For marks, you can use
isMarkActive
andremoveMark
. (If you optimistically try to remove marks without checking whether they're active, that might trigger an infinite normalization loop.)