fix(脑图): 测试规划脑图批量删除问题修复
This commit is contained in:
parent
f6e1abc18a
commit
0fa2ab5982
|
@ -206,10 +206,12 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
||||||
* @param command 插入命令
|
* @param command 插入命令
|
||||||
* @param value 携带的参数
|
* @param value 携带的参数
|
||||||
*/
|
*/
|
||||||
const execInsertCommand = (command: string, value?: string) => {
|
const execInsertCommand = (command: string, selectedNodes: MinderJsonNode[], value?: string) => {
|
||||||
const node: MinderJsonNode = window.minder.getSelectedNode();
|
if (selectedNodes.length > 1) {
|
||||||
|
return; // TODO: 批量操作暂不支持插入
|
||||||
|
}
|
||||||
if (options.insertNode) {
|
if (options.insertNode) {
|
||||||
options.insertNode(node, command, value);
|
options.insertNode(selectedNodes[0], command, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.minder.queryCommandState(command) !== -1) {
|
if (window.minder.queryCommandState(command) !== -1) {
|
||||||
|
@ -233,7 +235,7 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
||||||
* @param value 携带的参数
|
* @param value 携带的参数
|
||||||
*/
|
*/
|
||||||
const appendChildNode = (selectedNodes: MinderJsonNode[], value?: string) => {
|
const appendChildNode = (selectedNodes: MinderJsonNode[], value?: string) => {
|
||||||
execInsertCommand('AppendChildNode', value);
|
execInsertCommand('AppendChildNode', selectedNodes, value);
|
||||||
minderStore.dispatchEvent(MinderEventName.INSERT_CHILD, value, undefined, undefined, selectedNodes);
|
minderStore.dispatchEvent(MinderEventName.INSERT_CHILD, value, undefined, undefined, selectedNodes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -243,7 +245,7 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
||||||
* @param value 携带的参数
|
* @param value 携带的参数
|
||||||
*/
|
*/
|
||||||
const appendSiblingNode = (selectedNodes: MinderJsonNode[], value?: string) => {
|
const appendSiblingNode = (selectedNodes: MinderJsonNode[], value?: string) => {
|
||||||
execInsertCommand('AppendSiblingNode', value);
|
execInsertCommand('AppendSiblingNode', selectedNodes, value);
|
||||||
minderStore.dispatchEvent(MinderEventName.INSERT_SIBLING, value, undefined, undefined, selectedNodes);
|
minderStore.dispatchEvent(MinderEventName.INSERT_SIBLING, value, undefined, undefined, selectedNodes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -289,12 +291,16 @@ export default function useMinderOperation(options: MinderOperationProps) {
|
||||||
* @param selectedNodes 当前选中的节点集合
|
* @param selectedNodes 当前选中的节点集合
|
||||||
*/
|
*/
|
||||||
const minderDelete = (selectedNodes: MinderJsonNode[]) => {
|
const minderDelete = (selectedNodes: MinderJsonNode[]) => {
|
||||||
|
if (selectedNodes.length > 1 && (!options.canShowBatchDelete || options.disabled)) {
|
||||||
|
// 批量操作节点时,如果不允许批量删除或者当前操作被禁用,则不执行删除操作
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
(options.canShowDeleteMenu ||
|
selectedNodes.length === 1 &&
|
||||||
(options.canShowMoreMenu && options.canShowMoreMenuNodeOperation) ||
|
(options.canShowDeleteMenu || (options.canShowMoreMenu && options.canShowMoreMenuNodeOperation)) &&
|
||||||
options.canShowBatchDelete) &&
|
|
||||||
!options.disabled
|
!options.disabled
|
||||||
) {
|
) {
|
||||||
|
// 单个节点操作,如果允许删除操作,则执行删除操作
|
||||||
const newNodes = selectedNodes.map((node) => ({
|
const newNodes = selectedNodes.map((node) => ({
|
||||||
...node,
|
...node,
|
||||||
parent: node.parent, // 保存父节点信息,因为删除节点后 parent 会被置空
|
parent: node.parent, // 保存父节点信息,因为删除节点后 parent 会被置空
|
||||||
|
|
Loading…
Reference in New Issue