feat(wiki): enhance anchored form popups and internationalization updates

Add new styles for anchored form popups in the wiki browser, improving the user interface for folder actions and confirmations. Update internationalization strings for move confirmation titles in English, Korean, Russian, and Chinese locales to enhance user experience across multiple languages. Refactor existing components to integrate the new popup styles and ensure consistent behavior.
This commit is contained in:
wizardchen
2026-06-17 00:27:11 +08:00
committed by lyingbug
parent e76738d054
commit 16363623ab
8 changed files with 685 additions and 569 deletions
File diff suppressed because it is too large Load Diff
@@ -4,25 +4,11 @@
confirm) happens inside this one popup so no full-page dialog is spawned.
click.stop on the trigger and content prevents the surrounding directory
row from treating the interaction as an expand/collapse toggle. -->
<t-popup
v-model:visible="open"
trigger="click"
placement="bottom-start"
destroy-on-close
overlay-class-name="card-more-popup wiki-folder-action-overlay"
@visible-change="onVisibleChange"
>
<span
:class="[
'wiki-directory-action',
{ 'wiki-directory-action--reveal': !createOnly, 'is-open': open, 'wiki-directory-action--labeled': createOnly && label },
]"
:title="createOnly ? t('knowledgeEditor.wikiBrowser.newFolder') : t('knowledgeEditor.wikiBrowser.folderActions')"
@click.stop
@dragstart.prevent.stop
>
<t-icon :name="createOnly ? 'folder-add' : 'more'" />
<span v-if="createOnly && label" class="wiki-directory-action-label">{{ label }}</span>
<t-popup v-model:visible="open" trigger="click" placement="bottom-start" destroy-on-close
:overlay-class-name="popupOverlayClass" @visible-change="onVisibleChange">
<span :class="['wiki-directory-action', 'wiki-directory-action--reveal', { 'is-open': open }]"
:title="t('knowledgeEditor.wikiBrowser.folderActions')" @click.stop @dragstart.prevent.stop>
<t-icon name="more" />
</span>
<template #content>
<div class="wiki-folder-menu" @click.stop>
@@ -41,39 +27,42 @@
</div>
</div>
<template v-else-if="mode === 'create'">
<div v-else-if="mode === 'create'" class="anchored-form-popup-inner">
<div class="anchored-form-popup-title">{{ t('knowledgeEditor.wikiBrowser.newSubfolder') }}</div>
<t-input
ref="inputRef"
v-model="nameInput"
:placeholder="t('knowledgeEditor.wikiBrowser.folderNamePlaceholder')"
@enter="submitName"
/>
<div class="wiki-folder-menu-footer">
<t-button size="small" variant="outline" @click="open = false">
<div class="anchored-form-popup-footer">
<t-button variant="outline" @click="open = false">
{{ t('common.cancel') }}
</t-button>
<t-button size="small" theme="primary" :disabled="!nameInput.trim()" @click="submitName">
<t-button theme="primary" :disabled="!nameInput.trim()" @click="submitName">
{{ t('common.confirm') }}
</t-button>
</div>
</template>
</div>
<template v-else>
<div v-if="!deletable" class="wiki-folder-confirm">
{{ t('knowledgeEditor.wikiBrowser.deleteFolderNotEmpty') }}
<div v-else class="anchored-form-popup-inner">
<div class="anchored-form-popup-title">{{ t('knowledgeEditor.wikiBrowser.deleteFolder') }}</div>
<div class="anchored-form-popup-body">
{{
deletable
? t('knowledgeEditor.wikiBrowser.deleteFolderConfirm', { name })
: t('knowledgeEditor.wikiBrowser.deleteFolderNotEmpty')
}}
</div>
<div v-else class="wiki-folder-confirm">
{{ t('knowledgeEditor.wikiBrowser.deleteFolderConfirm', { name }) }}
</div>
<div class="wiki-folder-menu-footer">
<t-button size="small" variant="outline" @click="open = false">
<div class="anchored-form-popup-footer">
<t-button variant="outline" @click="open = false">
{{ deletable ? t('common.cancel') : t('common.confirm') }}
</t-button>
<t-button v-if="deletable" size="small" theme="danger" @click="submitDelete">
<t-button v-if="deletable" theme="danger" @click="submitDelete">
{{ t('common.confirm') }}
</t-button>
</div>
</template>
</div>
</div>
</template>
</t-popup>
@@ -87,18 +76,10 @@ const props = withDefaults(defineProps<{
name?: string
pageCount?: number
hasChildren?: boolean
// createOnly turns the trigger into a single "new folder" affordance that
// opens straight to the name input (used by the root-folder toolbar entry).
createOnly?: boolean
// label, when set on a createOnly trigger, renders text next to the icon so
// the toolbar entry reads as a button instead of a bare icon.
label?: string
}>(), {
name: '',
pageCount: 0,
hasChildren: false,
createOnly: false,
label: '',
})
const emit = defineEmits<{
@@ -116,18 +97,19 @@ const inputRef = ref<{ focus: () => void } | null>(null)
const deletable = computed(() => props.pageCount === 0 && !props.hasChildren)
const popupOverlayClass = computed(() => (
mode.value === 'menu'
? 'card-more-popup wiki-folder-action-overlay'
: 'anchored-form-popup-overlay'
))
function onVisibleChange(visible: boolean) {
if (!visible) {
mode.value = 'menu'
nameInput.value = ''
return
}
// createOnly skips the menu and lands directly on the name input.
if (props.createOnly) {
enterMode('create')
} else {
mode.value = 'menu'
}
mode.value = 'menu'
}
function enterMode(next: 'create' | 'delete') {
@@ -171,8 +153,6 @@ function submitDelete() {
}
}
// Hover-reveal for the per-folder "more" trigger: hidden by default, shown when
// the row is hovered (parent supplies that rule via :deep) or the popup is open.
.wiki-directory-action--reveal {
opacity: 0;
@@ -180,51 +160,13 @@ function submitDelete() {
opacity: 1;
}
}
// Labeled variant: the toolbar "new folder" button reads as icon + text.
.wiki-directory-action--labeled {
gap: 4px;
padding: 2px 6px;
border-radius: 6px;
font-size: 12px;
color: var(--td-text-color-secondary);
&:hover {
color: var(--td-brand-color);
background: var(--td-bg-color-container-hover);
}
}
.wiki-directory-action-label {
line-height: 1;
}
</style>
<style lang="less">
// Popup content teleports to <body>, so these must be global. The menu chrome
// (background, border, shadow, item styling) comes from the shared
// `card-more-popup` + `.popup-menu` rules in assets/dropdown-menu.less so this
// menu matches every other dropdown in the app; only the create-input and
// delete-confirm panes need a little extra layout here.
// Menu chrome comes from card-more-popup + .popup-menu in dropdown-menu.less.
.wiki-folder-action-overlay {
.wiki-folder-menu {
min-width: 188px;
}
.wiki-folder-confirm {
font-size: 13px;
line-height: 1.5;
color: var(--td-text-color-primary);
padding: 4px 6px 8px;
max-width: 280px;
}
.wiki-folder-menu-footer {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 8px;
padding: 0 2px;
}
}
</style>