fix(脑图): 输入状态下复制、剪切、粘贴快捷键功能不阻止
--bug=1045692 --user=白奇 【测试用例】脑图模式-双击复制内容-粘贴无效 https://www.tapd.cn/55049933/s/1569232
This commit is contained in:
parent
d173b3ace0
commit
84e7561988
|
@ -57,20 +57,20 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
|||
const { editor } = window;
|
||||
const { minder, fsm } = editor;
|
||||
const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes();
|
||||
if (
|
||||
!options.canShowMoreMenu ||
|
||||
!options.canShowMoreMenuNodeOperation ||
|
||||
(selectedNodes.length > 1 && options.canShowBatchCopy === false)
|
||||
) {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
}
|
||||
const state = fsm.state();
|
||||
switch (state) {
|
||||
case 'input': {
|
||||
break;
|
||||
}
|
||||
case 'normal': {
|
||||
if (
|
||||
!options.canShowMoreMenu ||
|
||||
!options.canShowMoreMenuNodeOperation ||
|
||||
(selectedNodes.length > 1 && options.canShowBatchCopy === false)
|
||||
) {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
}
|
||||
minderStore.dispatchEvent(MinderEventName.COPY_NODE, undefined, undefined, undefined, selectedNodes);
|
||||
if (e?.clipboardData) {
|
||||
e.clipboardData.setData('text/plain', encode(selectedNodes));
|
||||
|
@ -94,15 +94,6 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
|||
const { editor } = window;
|
||||
const { minder, fsm } = editor;
|
||||
const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes();
|
||||
if (
|
||||
options.disabled ||
|
||||
!options.canShowMoreMenu ||
|
||||
!options.canShowMoreMenuNodeOperation ||
|
||||
(selectedNodes.length > 1 && options.canShowBatchCut === false)
|
||||
) {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (minder.getStatus() !== 'normal') {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
|
@ -113,6 +104,15 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
|||
break;
|
||||
}
|
||||
case 'normal': {
|
||||
if (
|
||||
options.disabled ||
|
||||
!options.canShowMoreMenu ||
|
||||
!options.canShowMoreMenuNodeOperation ||
|
||||
(selectedNodes.length > 1 && options.canShowBatchCut === false)
|
||||
) {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
}
|
||||
markDeleteNode(minder);
|
||||
if (selectedNodes.length) {
|
||||
const newNodes = selectedNodes.map((node) => ({
|
||||
|
@ -140,10 +140,6 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
|||
* 执行粘贴
|
||||
*/
|
||||
const minderPaste = async (e?: ClipboardEvent) => {
|
||||
if (options.disabled || !options.canShowPasteMenu) {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
}
|
||||
const { editor } = window;
|
||||
const { minder, fsm, MimeType } = editor;
|
||||
const Data: IData = window.kityminder.data;
|
||||
|
@ -163,6 +159,10 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
|||
break;
|
||||
}
|
||||
case 'normal': {
|
||||
if (options.disabled || !options.canShowPasteMenu) {
|
||||
e?.preventDefault();
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* 针对normal状态下通过对选中节点粘贴导入子节点文本进行单独处理
|
||||
*/
|
||||
|
|
|
@ -44,14 +44,12 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
|
|||
|
||||
if (isCtrlOrCmd && combinationShortcuts[key]) {
|
||||
// 执行组合键事件
|
||||
event.preventDefault();
|
||||
const action = combinationShortcuts[key];
|
||||
if (shortcuts[action]) {
|
||||
shortcuts[action]!();
|
||||
}
|
||||
} else if (singleShortcuts[key]) {
|
||||
// 执行单键事件
|
||||
event.preventDefault();
|
||||
const action = singleShortcuts[key];
|
||||
if (shortcuts[action]) {
|
||||
shortcuts[action]!();
|
||||
|
|
Loading…
Reference in New Issue