3

I want to set one specific node non-editable by

Transforms.setNodes(editor,{at:[1]},{voids:true})

But it seems not working. Does anyone know how to do it? Thanks!

Yuqin Xu
  • 187
  • 1
  • 7

2 Answers2

6

You need to make your element render with contentEditable prop to false contentEditable={false} can also add style={{ userSelect: "none" }} to make it non selectable. You can make it dynamic base on the node props and set them them with the trasnformer.

cetabio
  • 126
  • 1
  • 3
0
export default function (props: any) {
    const { attributes, children, element } = props;
    const selected = useSelected()
    const focused = useFocused()
    return (
        <span
            {...attributes}
            contentEditable={false}
            style={{ userSelect: "none" }}
        >
            {
                element.content
                    ?
                    `【${element.content}】`
                    : null
            }
            {children}
        </span>
    )
}
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
fan zhang
  • 1
  • 1