Merge pull request #163 from fantasticit/fix/dragable

This commit is contained in:
fantasticit 2022-08-15 16:17:45 +08:00 committed by GitHub
commit af2ee2b663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -120,10 +120,23 @@ export const Dragable = Extension.create({
drop: (view, event: DragEvent) => {
if (!view.editable || !dragHandleDOM) return false;
const eventPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
if (!eventPos) {
return true;
}
const $mouse = view.state.doc.resolve(eventPos.pos);
/**
* title
*/
if ($mouse?.parent?.type?.name === 'title') {
return true;
}
if (dragging) {
const tr = removePossibleTable(view, event);
dragging = false;
if (tr) {
view.dispatch(tr);
event.preventDefault();
@ -166,7 +179,6 @@ export const Dragable = Extension.create({
},
keydown: () => {
if (!editorView.editable || !dragHandleDOM) return false;
dragHandleDOM.classList.remove('show');
hideDragHandleDOM();
return false;
},