Merge pull request #151 from fantasticit/fix/drag

This commit is contained in:
fantasticit 2022-08-09 22:02:50 +08:00 committed by GitHub
commit 3c11bfc121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 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;

View File

@ -2,6 +2,5 @@ import { mergeAttributes } from '@tiptap/core';
import TitapParagraph from '@tiptap/extension-paragraph'; import TitapParagraph from '@tiptap/extension-paragraph';
export const Paragraph = TitapParagraph.extend({ export const Paragraph = TitapParagraph.extend({
draggable: true,
selectable: true, selectable: true,
}); });