fix(测试用例): 双击编辑用例-无需展示菜单栏

--bug=1044827 --user=吕梦园
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001044827
This commit is contained in:
teukkk 2024-08-13 14:19:35 +08:00 committed by Craftsman
parent 0c6223a8e2
commit 02ce1eefe7
3 changed files with 19 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import type { MinderCustomEvent } from '@/store/modules/components/minder-editor
import type { MinderEvent, MinderJsonNode } from '../props'; import type { MinderEvent, MinderJsonNode } from '../props';
export interface UseEventListenerProps { export interface UseEventListenerProps {
handleDblclick?: () => void;
handleContentChange?: (node?: MinderJsonNode) => void; handleContentChange?: (node?: MinderJsonNode) => void;
handleSelectionChange?: (nodes: MinderJsonNode[]) => void; handleSelectionChange?: (nodes: MinderJsonNode[]) => void;
handleMinderEvent?: (event: MinderCustomEvent) => void; handleMinderEvent?: (event: MinderCustomEvent) => void;
@ -24,6 +25,13 @@ export default function useEventListener(listener: UseEventListenerProps) {
// 拖拽触发时未处理的选中事件,拖拽完成后触发 // 拖拽触发时未处理的选中事件,拖拽完成后触发
let selectionchangeEvent: (() => void) | undefined; let selectionchangeEvent: (() => void) | undefined;
// 双击编辑内容
minder.on('dblclick', () => {
if (listener.handleDblclick) {
listener.handleDblclick();
}
});
// 监听脑图节点内容变化 // 监听脑图节点内容变化
minder.on('contentchange', () => { minder.on('contentchange', () => {
const node: MinderJsonNode = minder.getSelectedNode(); const node: MinderJsonNode = minder.getSelectedNode();

View File

@ -95,6 +95,8 @@
}); });
const currentTreePath = ref<MinderJsonNodeData[]>([]); const currentTreePath = ref<MinderJsonNodeData[]>([]);
const floatMenuVisible = ref(false);
async function init() { async function init() {
window.editor = new Editor(mec.value, { window.editor = new Editor(mec.value, {
sequenceEnable: props.sequenceEnable, sequenceEnable: props.sequenceEnable,
@ -153,6 +155,12 @@
}, 100); }, 100);
} }
}, },
handleDblclick() {
const state = window.editor.state();
if (state === 'input') {
floatMenuVisible.value = false;
}
},
}); });
}); });
@ -213,8 +221,6 @@
}, 300); // TODO: }, 300); // TODO:
} }
const floatMenuVisible = ref(false);
function save() { function save() {
let data = importJson.value; let data = importJson.value;
if (innerImportJson.value.treePath?.length > 1) { if (innerImportJson.value.treePath?.length > 1) {

View File

@ -251,8 +251,9 @@
await sleep(300); // 300ms await sleep(300); // 300ms
nodePosition = window.minder.getSelectedNode()?.getRenderBox(); nodePosition = window.minder.getSelectedNode()?.getRenderBox();
} }
if (nodePosition && isNodeInMinderView(undefined, nodePosition, nodePosition.width / 2)) { const state = window.editor.fsm.state();
// if (nodePosition && isNodeInMinderView(undefined, nodePosition, nodePosition.width / 2) && state !== 'input') {
//
const nodeDomHeight = nodePosition.height || 0; const nodeDomHeight = nodePosition.height || 0;
menuPopupOffset.value = [nodePosition.x, nodePosition.y + nodeDomHeight + 4]; // 4px menuPopupOffset.value = [nodePosition.x, nodePosition.y + nodeDomHeight + 4]; // 4px
menuVisible.value = true; menuVisible.value = true;