clean code

pull/252/head
fantasticit 2023-06-18 13:46:42 +08:00
parent 1c2d1338a9
commit 20908ab701
2 changed files with 3 additions and 29 deletions

View File

@ -26,12 +26,7 @@ export const Dragable = Extension.create({
let activeNode: ActiveNode | null;
let activeSelection: Selection | null;
let dragging = false;
const isMenuVisible = false;
let mouseleaveTimer = null;
const menuActions = { setVisible: (arg: boolean) => {}, update: () => {} };
const getEditorView = () => editorView;
const getActiveNode = () => activeNode;
const createDragHandleDOM = () => {
const dom = document.createElement('div');
@ -47,11 +42,6 @@ export const Dragable = Extension.create({
dragHandleDOM?.classList?.remove('hide');
};
const activeDragHandleDOM = () => {
dragHandleDOM?.classList?.add('active');
dragHandleDOM?.classList?.remove('hide');
};
const hideDragHandleDOM = () => {
dragHandleDOM?.classList?.remove('show');
dragHandleDOM?.classList?.remove('active');
@ -81,8 +71,6 @@ export const Dragable = Extension.create({
dragHandleDOM.style.left = `${left + offsetLeft}px`;
dragHandleDOM.style.top = `${top - 2}px`;
menuActions?.update?.();
showDragHandleDOM();
};
@ -95,10 +83,7 @@ export const Dragable = Extension.create({
const handleMouseLeave = () => {
if (!activeNode) return null;
if (!isMenuVisible) {
hideDragHandleDOM();
}
hideDragHandleDOM();
};
const handleMouseDown = () => {
@ -138,8 +123,6 @@ export const Dragable = Extension.create({
slice,
move: true,
};
menuActions?.setVisible?.(false);
}
};
@ -237,7 +220,6 @@ export const Dragable = Extension.create({
return false;
},
mousemove: (view, event) => {
if (isMenuVisible) return false;
if (!view.editable || !dragHandleDOM) return false;
const coords = { left: event.clientX, top: event.clientY };
@ -312,12 +294,6 @@ export const Dragable = Extension.create({
return false;
}
// if (result.el.parentElement?.classList.contains('ProseMirror')) {
// if (dragging) return false;
// hideDragHandleDOM();
// return false;
// }
activeNode = result;
renderDragHandleDOM(view, result.el);
return false;
@ -330,9 +306,7 @@ export const Dragable = Extension.create({
mouseleave: () => {
clearTimeout(mouseleaveTimer);
mouseleaveTimer = setTimeout(() => {
if (!isMenuVisible) {
hideDragHandleDOM();
}
hideDragHandleDOM();
}, 400);
return false;
},

View File

@ -27,7 +27,7 @@ const TitlePluginKey = new PluginKey(TitleExtensionName);
export const Title = Node.create<TitleOptions>({
name: TitleExtensionName,
content: 'inline*',
group: 'block',
group: TitleExtensionName,
defining: true,
isolating: true,
selectable: true,