Auto-convert on drop


is there a way to allow node types to be droppable into positions that would otherwise violate the schema, therefore triggering an auto-conversion?

I’m trying to allow you to create sub-lists by dropping list_items into other list_items. I.e., make a list_item droppable into another list_item, but still triggering it to be wrapped with a list parent node in order to satisfy the schema.

Cheers, Bjørn

I think the only way to do this is with a handleDrop hook.

So in that case (to make handleDrop even be called and the gapcusor showing) I guess I would have to make my schema allow list_items in list_items, which means auto-conversion might not happen in other cases (copy & pasting from external places etc), or?

handleDrop will be called for every drop event, regardless of schema constraints. You’ll have to figure out the drop position from the event in your handler. Getting the drop cursor to show up in the right place (which I assume is what you mean by ‘gapcursor showing’?) might be harder.

Thanks, that makes sense. Yeah, gapcursor => dropcursor :slight_smile: I guess it’d be easier if there were one or more predicate functions (canDrop() / canDropOnChild()) that could be overridden to signal to the library that nodes could be dropped on or hierarchically beneath some node - so the library’s dropcursor logic would still work.