Commit 1e86e866 by pangchong

refactor(editor): 优化代码格式和简化逻辑表达

- 精简 CommonNodeDetailList 组件中 targetVirtualId 的三元表达式写法
- 调整 EditAreaContextMenuModal 中删除确认对话框内容的多行三元表达式格式
- 修正 AddNodeModal 组件中 form.textContent 的赋值表达式,去除多余括号,提高可读性
parent a43883bf
...@@ -387,9 +387,7 @@ const processedItems = computed(() => { ...@@ -387,9 +387,7 @@ const processedItems = computed(() => {
let actualMcIdx = -1 let actualMcIdx = -1
let textVal = '' let textVal = ''
const targetVirtualId = (props.selectedId && props.selectedId.includes('-txt-')) const targetVirtualId = props.selectedId && props.selectedId.includes('-txt-') ? props.selectedId : leafId.includes('-txt-') ? leafId : ''
? props.selectedId
: (leafId.includes('-txt-') ? leafId : '')
if (targetVirtualId.includes('-txt-')) { if (targetVirtualId.includes('-txt-')) {
const targetIdx = parseInt(targetVirtualId.split('-txt-')[1], 10) const targetIdx = parseInt(targetVirtualId.split('-txt-')[1], 10)
......
...@@ -369,7 +369,9 @@ export function useEditAreaContextMenu(props: EditAreaContextMenuProps, emit: (e ...@@ -369,7 +369,9 @@ export function useEditAreaContextMenu(props: EditAreaContextMenuProps, emit: (e
try { try {
await window.$dialog.warning({ await window.$dialog.warning({
title: '确认删除', title: '确认删除',
content: isVirtual ? '您确定要删除此段文本内容吗?该操作不可撤销。' : `您确定要删除选中的节点 <${mapped?.node?.tagName || ''}> 吗?该操作不可撤销。` content: isVirtual
? '您确定要删除此段文本内容吗?该操作不可撤销。'
: `您确定要删除选中的节点 <${mapped?.node?.tagName || ''}> 吗?该操作不可撤销。`
}) })
if (isVirtual) { if (isVirtual) {
......
...@@ -139,7 +139,7 @@ export function useAddNodeModal(formRef: Ref<FormInst | null>) { ...@@ -139,7 +139,7 @@ export function useAddNodeModal(formRef: Ref<FormInst | null>) {
form.tagName = node.tagName form.tagName = node.tagName
if (isMixedContentElement(node.tagName) && Array.isArray(node.mixedContent) && node.mixedContent.length > 0) { if (isMixedContentElement(node.tagName) && Array.isArray(node.mixedContent) && node.mixedContent.length > 0) {
const firstText = node.mixedContent.find((i) => i.type === 'text')?.text const firstText = node.mixedContent.find((i) => i.type === 'text')?.text
form.textContent = firstText !== undefined && firstText !== '' ? firstText : (node.textContent || '') form.textContent = firstText !== undefined && firstText !== '' ? firstText : node.textContent || ''
} else { } else {
form.textContent = node.textContent || '' form.textContent = node.textContent || ''
} }
......
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