Closed Mangatt closed 7 years ago
I believe the best way to do this is to define a custom node in your schema and pass contentEditable={false}
as a prop to it when it renders.
Not sure what the best way to allow caption editing would be. I suppose you could have another Slate instance (or, if you can go without rich text editing, just have a text input instead) rendering inside the block and updating node metadata (used by your custom node to render the caption) accordingly as input is received.
I did not knew about disabling editation per block. But idea with another Slate instance puzzles me - is there a way how to render another instance of slate from node blocks instead of regular nodes? And could this work? Because when I tried that, my editor crashed.
@Mangatt Curious where you ended up with?
In the examples, the one with embed does something similar with single input field inside the node. I also think you could just make it a nested node where the caption is also an editable text node
There's a new example called check-lists
that shows how to add basic pieces around a block that aren't editable, while keeping selection behaviors intact. That's one way to do, and there are other previous issues about nesting Slate editors, although I haven't experimented with that personally. I'm going to close this in attempt to clean up issues, but feel free to keep discussing!
@ianstormtaylor I just tried implementing https://www.slatejs.org/#/check-lists. You said:
... a block that aren't editable, while keeping selection behaviors intact
But I can't select all check-lists, I can only select one.
How can I make all selectable so I can delete some or all of them at once?
Hi, is there a way how to make a block or part of the block read-only? For example to have all block not editable, but let user change caption for that block?