mirror of https://github.com/fantasticit/think.git
Merge pull request #163 from fantasticit/fix/dragable
This commit is contained in:
commit
af2ee2b663
|
@ -120,10 +120,23 @@ export const Dragable = Extension.create({
|
||||||
drop: (view, event: DragEvent) => {
|
drop: (view, event: DragEvent) => {
|
||||||
if (!view.editable || !dragHandleDOM) return false;
|
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) {
|
if (dragging) {
|
||||||
const tr = removePossibleTable(view, event);
|
const tr = removePossibleTable(view, event);
|
||||||
dragging = false;
|
dragging = false;
|
||||||
|
|
||||||
if (tr) {
|
if (tr) {
|
||||||
view.dispatch(tr);
|
view.dispatch(tr);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -166,7 +179,6 @@ export const Dragable = Extension.create({
|
||||||
},
|
},
|
||||||
keydown: () => {
|
keydown: () => {
|
||||||
if (!editorView.editable || !dragHandleDOM) return false;
|
if (!editorView.editable || !dragHandleDOM) return false;
|
||||||
dragHandleDOM.classList.remove('show');
|
|
||||||
hideDragHandleDOM();
|
hideDragHandleDOM();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue