Commit e2062d14 by pangchong

feat: 格式化代码

parent 233926ec
......@@ -392,11 +392,7 @@ function buildSequenceConstraints(model: DtdContentModel): Array<[string, string
* @param childIndex 要移动的子节点在 childTags 中的索引
* @returns { canMoveUp, canMoveDown }
*/
export function canMoveNode(
parentTagName: string,
childTags: string[],
childIndex: number
): { canMoveUp: boolean; canMoveDown: boolean } {
export function canMoveNode(parentTagName: string, childTags: string[], childIndex: number): { canMoveUp: boolean; canMoveDown: boolean } {
const atTop = childIndex <= 0
const atBottom = childIndex >= childTags.length - 1
......@@ -450,7 +446,6 @@ export function canMoveNode(
}
}
/**
* 根据父节点 DTD 定义的子节点顺序进行排序
*/
......@@ -511,18 +506,17 @@ export function checkCanMoveNode(
return { canMoveUp: false, canMoveDown: false }
}
return canMoveNode(parent.tagName, realSiblings.map((c) => c.tagName), realIdx)
return canMoveNode(
parent.tagName,
realSiblings.map((c) => c.tagName),
realIdx
)
}
/**
* 通用节点移动执行函数(支持 mixedContent 数组与结构化 children 数组同步)
*/
export function moveNodeInParent(
parent: XmlNode | null | undefined,
nodeId: string,
direction: 'up' | 'down',
isVirtual: boolean = false
): boolean {
export function moveNodeInParent(parent: XmlNode | null | undefined, nodeId: string, direction: 'up' | 'down', isVirtual: boolean = false): boolean {
if (!parent) return false
// 1. 如果父节点存在 mixedContent,优先在 mixedContent 中执行交换
......@@ -589,4 +583,3 @@ export function moveNodeInParent(
return false
}
......@@ -293,7 +293,6 @@ export function useEditAreaContextMenu(props: EditAreaContextMenuProps, emit: (e
return checkCanMoveNode(parent, nodeId, isVirtual).canMoveDown
})
// 根据 DTD 获取允许添加的子标签列表
const allowedChildrenList = computed<string[]>(() => {
const node = activeNode.value
......@@ -582,8 +581,6 @@ export function useEditAreaContextMenu(props: EditAreaContextMenuProps, emit: (e
window.$message.warning('下移失败')
}
}
}
const pasteXmlOptions = computed(() => [
......
......@@ -94,7 +94,12 @@
</n-dropdown>
<!-- 5b. 编辑顺序 -->
<n-dropdown trigger="click" :options="editOrderOptions" :disabled="isTextNode || (!canMoveUpActive && !canMoveDownActive)" @select="runAction">
<n-dropdown
trigger="click"
:options="editOrderOptions"
:disabled="isTextNode || (!canMoveUpActive && !canMoveDownActive)"
@select="runAction"
>
<CommonButton type="warning" secondary block :disabled="isTextNode || (!canMoveUpActive && !canMoveDownActive)">
<template #icon>
<n-icon><swap-vertical-outline /></n-icon>
......
......@@ -1484,7 +1484,6 @@ export function useNodeTree(
}
break
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment