feat(脑图): 脑图屏蔽撤销重做&快捷键拦截调整

This commit is contained in:
baiqi 2024-07-31 10:34:39 +08:00 committed by 刘瑞斌
parent de69c69230
commit bd2076b718
5 changed files with 20 additions and 9 deletions

View File

@ -449,7 +449,11 @@
waitingRenderNodes.push(moreNode);
}
window.minder.renderNodeBatch(waitingRenderNodes);
node.layout();
if (node.parent) {
node.parent?.layout();
} else {
node.layout();
}
data.isLoaded = true;
// importJson
replaceNodeInTree([importJson.value.root], node.data?.id || '', window.minder.exportNode(node), 'data', 'id');

View File

@ -44,6 +44,7 @@ export default function useMinderOperation({
*/
const minderCopy = (e?: ClipboardEvent) => {
if (!canShowMoreMenuNodeOperation) {
e?.preventDefault();
return;
}
const { editor } = window;
@ -69,6 +70,7 @@ export default function useMinderOperation({
*/
const minderCut = (e?: ClipboardEvent) => {
if (!canShowMoreMenuNodeOperation) {
e?.preventDefault();
return;
}
const { editor } = window;
@ -103,7 +105,8 @@ export default function useMinderOperation({
*
*/
const minderPaste = (e?: ClipboardEvent) => {
if (!canShowMoreMenuNodeOperation || !canShowPasteMenu) {
if (!canShowMoreMenuNodeOperation && !canShowPasteMenu) {
e?.preventDefault();
return;
}
const { editor } = window;

View File

@ -15,8 +15,8 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
// 定义组合键事件
const combinationShortcuts: { [key: string]: ShortcutKey } = {
z: 'undo', // 撤销
y: 'redo', // 重做
// z: 'undo', // 撤销 TODO:暂时不上撤销和重做
// y: 'redo', // 重做
enter: 'enter', // 进入节点
};
// 定义单键事件

View File

@ -110,7 +110,7 @@
</div>
</div>
</div>
<div class="ms-minder-shortcut-trigger-listitem">
<!-- <div class="ms-minder-shortcut-trigger-listitem">
<div>{{ t('minder.main.history.undo') }}</div>
<div class="flex items-center gap-[4px]">
<div class="ms-minder-shortcut-trigger-listitem-icon">
@ -118,14 +118,14 @@
</div>
<div class="ms-minder-shortcut-trigger-listitem-icon">Z</div>
</div>
</div>
</div> -->
<div class="ms-minder-shortcut-trigger-listitem">
<div>{{ t('common.delete') }}</div>
<div class="ms-minder-shortcut-trigger-listitem-icon">
<MsIcon type="icon-icon_carriage_return1" />
</div>
</div>
<div class="ms-minder-shortcut-trigger-listitem">
<!-- <div class="ms-minder-shortcut-trigger-listitem">
<div>{{ t('minder.main.history.redo') }}</div>
<div class="flex items-center gap-[4px]">
<div class="ms-minder-shortcut-trigger-listitem-icon">
@ -133,7 +133,7 @@
</div>
<div class="ms-minder-shortcut-trigger-listitem-icon">Y</div>
</div>
</div>
</div> -->
</div>
</template>
</a-trigger>

View File

@ -117,6 +117,8 @@
const { appendChildNode, appendSiblingNode, minderDelete } = useMinderOperation({
insertNode: props.insertNode,
canShowMoreMenuNodeOperation: props.canShowMoreMenuNodeOperation,
canShowPasteMenu: props.canShowPasteMenu,
});
const { unbindShortcuts } = useShortCut(
{
@ -133,7 +135,7 @@
}
},
delete: () => {
if (props.canShowMoreMenuNodeOperation && props.canShowDeleteMenu) {
if (props.canShowMoreMenuNodeOperation && !props.disabled) {
const selectedNodes: MinderJsonNode[] = window.minder.getSelectedNodes();
minderDelete(selectedNodes);
}
@ -169,6 +171,8 @@
},
{
insertNode: props.insertNode,
canShowMoreMenuNodeOperation: props.canShowMoreMenuNodeOperation,
canShowPasteMenu: props.canShowPasteMenu,
}
);