tiptap: hide drag handler in empty paragraph

This commit is contained in:
fantasticit 2022-08-09 21:59:37 +08:00
parent 87a863874d
commit e41bbeec28
1 changed files with 8 additions and 6 deletions

View File

@ -147,17 +147,19 @@ export const Dragable = Extension.create({
const result = selectRootNodeByDom(dom, view); const result = selectRootNodeByDom(dom, view);
activeNode = result; activeNode = result;
if (!result) { if (
!result ||
result.node.type.name === 'title' ||
result.node.type.name === 'tableOfContents' ||
// empty paragraph
(result.node.type.name === 'paragraph' && result.node.nodeSize === 2)
) {
if (dragging) return false; if (dragging) return false;
hideDragHandleDOM(); hideDragHandleDOM();
return false; return false;
} }
if (result.node.type.name === 'title') { console.log(result);
if (dragging) return false;
hideDragHandleDOM();
return false;
}
renderDragHandleDOM(view, result.el); renderDragHandleDOM(view, result.el);
return false; return false;