UNPKG

reactjs-tiptap-editor

Version:

A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React

2 lines (1 loc) 523 B
"use strict";function i(a,t){const{state:o}=t,n=o.selection.$anchor;let s=!1;if(n.depth)for(let e=n.depth;e>0;e--)n.node(e).type.name===a&&(t.dispatchTransaction&&t.dispatchTransaction(o.tr.delete(n.before(e),n.after(e)).scrollIntoView()),s=!0);else{const e=o.selection.node;e&&e.type.name===a&&(t.chain().deleteSelection().run(),s=!0)}if(!s){const e=n.pos;if(e){const c=o.tr.doc.nodeAt(e);c&&c.type.name===a&&(t.dispatchTransaction&&t.dispatchTransaction(o.tr.delete(e,e+c.nodeSize)),s=!0)}}return s}exports.deleteNode=i;