mirror of https://github.com/fantasticit/think.git
clean code
This commit is contained in:
parent
1c2d1338a9
commit
20908ab701
|
@ -26,12 +26,7 @@ export const Dragable = Extension.create({
|
||||||
let activeNode: ActiveNode | null;
|
let activeNode: ActiveNode | null;
|
||||||
let activeSelection: Selection | null;
|
let activeSelection: Selection | null;
|
||||||
let dragging = false;
|
let dragging = false;
|
||||||
const isMenuVisible = false;
|
|
||||||
let mouseleaveTimer = null;
|
let mouseleaveTimer = null;
|
||||||
const menuActions = { setVisible: (arg: boolean) => {}, update: () => {} };
|
|
||||||
|
|
||||||
const getEditorView = () => editorView;
|
|
||||||
const getActiveNode = () => activeNode;
|
|
||||||
|
|
||||||
const createDragHandleDOM = () => {
|
const createDragHandleDOM = () => {
|
||||||
const dom = document.createElement('div');
|
const dom = document.createElement('div');
|
||||||
|
@ -47,11 +42,6 @@ export const Dragable = Extension.create({
|
||||||
dragHandleDOM?.classList?.remove('hide');
|
dragHandleDOM?.classList?.remove('hide');
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeDragHandleDOM = () => {
|
|
||||||
dragHandleDOM?.classList?.add('active');
|
|
||||||
dragHandleDOM?.classList?.remove('hide');
|
|
||||||
};
|
|
||||||
|
|
||||||
const hideDragHandleDOM = () => {
|
const hideDragHandleDOM = () => {
|
||||||
dragHandleDOM?.classList?.remove('show');
|
dragHandleDOM?.classList?.remove('show');
|
||||||
dragHandleDOM?.classList?.remove('active');
|
dragHandleDOM?.classList?.remove('active');
|
||||||
|
@ -81,8 +71,6 @@ export const Dragable = Extension.create({
|
||||||
dragHandleDOM.style.left = `${left + offsetLeft}px`;
|
dragHandleDOM.style.left = `${left + offsetLeft}px`;
|
||||||
dragHandleDOM.style.top = `${top - 2}px`;
|
dragHandleDOM.style.top = `${top - 2}px`;
|
||||||
|
|
||||||
menuActions?.update?.();
|
|
||||||
|
|
||||||
showDragHandleDOM();
|
showDragHandleDOM();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,10 +83,7 @@ export const Dragable = Extension.create({
|
||||||
|
|
||||||
const handleMouseLeave = () => {
|
const handleMouseLeave = () => {
|
||||||
if (!activeNode) return null;
|
if (!activeNode) return null;
|
||||||
|
|
||||||
if (!isMenuVisible) {
|
|
||||||
hideDragHandleDOM();
|
hideDragHandleDOM();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseDown = () => {
|
const handleMouseDown = () => {
|
||||||
|
@ -138,8 +123,6 @@ export const Dragable = Extension.create({
|
||||||
slice,
|
slice,
|
||||||
move: true,
|
move: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
menuActions?.setVisible?.(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -237,7 +220,6 @@ export const Dragable = Extension.create({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
mousemove: (view, event) => {
|
mousemove: (view, event) => {
|
||||||
if (isMenuVisible) return false;
|
|
||||||
if (!view.editable || !dragHandleDOM) return false;
|
if (!view.editable || !dragHandleDOM) return false;
|
||||||
|
|
||||||
const coords = { left: event.clientX, top: event.clientY };
|
const coords = { left: event.clientX, top: event.clientY };
|
||||||
|
@ -312,12 +294,6 @@ export const Dragable = Extension.create({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (result.el.parentElement?.classList.contains('ProseMirror')) {
|
|
||||||
// if (dragging) return false;
|
|
||||||
// hideDragHandleDOM();
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
activeNode = result;
|
activeNode = result;
|
||||||
renderDragHandleDOM(view, result.el);
|
renderDragHandleDOM(view, result.el);
|
||||||
return false;
|
return false;
|
||||||
|
@ -330,9 +306,7 @@ export const Dragable = Extension.create({
|
||||||
mouseleave: () => {
|
mouseleave: () => {
|
||||||
clearTimeout(mouseleaveTimer);
|
clearTimeout(mouseleaveTimer);
|
||||||
mouseleaveTimer = setTimeout(() => {
|
mouseleaveTimer = setTimeout(() => {
|
||||||
if (!isMenuVisible) {
|
|
||||||
hideDragHandleDOM();
|
hideDragHandleDOM();
|
||||||
}
|
|
||||||
}, 400);
|
}, 400);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,7 +27,7 @@ const TitlePluginKey = new PluginKey(TitleExtensionName);
|
||||||
export const Title = Node.create<TitleOptions>({
|
export const Title = Node.create<TitleOptions>({
|
||||||
name: TitleExtensionName,
|
name: TitleExtensionName,
|
||||||
content: 'inline*',
|
content: 'inline*',
|
||||||
group: 'block',
|
group: TitleExtensionName,
|
||||||
defining: true,
|
defining: true,
|
||||||
isolating: true,
|
isolating: true,
|
||||||
selectable: true,
|
selectable: true,
|
||||||
|
|
Loading…
Reference in New Issue