I made a custom attribute for my non-editable types:
const editableAttribute = new Attribute({
default: 'false'
})
editableAttribute.parseDOM = (dom, options) => dom.getAttribute('contenteditable') || 'false'
editableAttribute.serializeDOM = (dom, editable) => dom ? dom.setAttribute('contenteditable', editable) : null
let editablePred = (_, data) => data.type.prototype.isNotEditable
spec = spec.addAttribute(editablePred, 'contenteditable', editableAttribute)
(context)
It works to make the expected html, but editing behavior around the blocks needs work. It needs to
- Suppress editing: the cursor doesn’t show up, but the blocks are still editable
- (edit: added this, didn’t realize could still type without the cursor)
- Suppress the tooltip, which appears with double-click or drag select, and applies formatting
- Delete under a non-editable block combines the editable one into the non, and cursor disappears
- Clicking anywhere in a non-editable block should just select it. I’d like custom actions in the block tooltip.
Hints on the best way to do those 4 would be helpful, or I can just keep hacking on it.