fix(structure): default edit view to DDL

This commit is contained in:
gggaiitx authored and GitHub committed 2026-07-10 18:14:18 +08:00
1 parent 34cf69132d
commit 2f3d1de46a
4 files changed
+139 -31

No files matched your search

+35 -5
View File
@@ -7677,8 +7677,21 @@ function clampCellDetailPanelSize(value: number, layout = cellDetailPanelLayout.
// Table info drawers are tied to a single grid instance. Keeping this state
// module-global leaks the drawer into other kept-alive tabs.
const showTableInfo = ref(false);
const activeTableInfoTab = ref<TableInfoTab>("columns");
const activeTableInfoTab = ref<TableInfoTab>("ddl");
const ddlContent = ref("");
const ddlPreRef = ref<HTMLPreElement | null>(null);
function onDdlKeydown(e: KeyboardEvent) {
if ((e.ctrlKey || e.metaKey) && e.key === "a") {
e.preventDefault();
const el = ddlPreRef.value;
if (!el) return;
const range = document.createRange();
range.selectNodeContents(el);
const sel = window.getSelection();
sel?.removeAllRanges();
sel?.addRange(range);
}
}
const ddlLoading = ref(false);
const ddlWidth = ref(settingsStore.editorSettings.tableInfoDrawerWidth);
const detailPanelHeight = ref(settingsStore.editorSettings.cellDetailDrawerWidth);
@@ -7717,6 +7730,14 @@ watch(activeTableInfoTab, () => {
searchQuery.value = "";
});
watch([activeTableInfoTab, ddlLoading], ([tab, loading]) => {
if (tab === "ddl" && !loading) {
void nextTick(() => {
ddlPreRef.value?.focus();
});
}
});
watch(
() => settingsStore.editorSettings.tableInfoDrawerWidth,
(width) => {
@@ -7779,6 +7800,9 @@ const mongoConnectionConfig = computed(() => connectionStore.getConfig(props.con
const canManageMongoIndexes = computed(() => resolvedDatabaseType.value === "mongodb" && !!props.connectionId && !!props.database && !!props.tableMeta?.tableName && mongoConnectionConfig.value?.db_type === "mongodb" && mongoConnectionConfig.value?.driver_profile !== "mongodb-legacy");
const tableInfoTabs = computed(() => {
const tabs: TableInfoTabItem[] = [];
if (tableMetadataCapabilities.value.ddl) {
tabs.push({ id: "ddl", label: "DDL", icon: Code2 });
}
if (tableMetadataCapabilities.value.columns) {
tabs.push({
id: "columns",
@@ -7801,9 +7825,6 @@ const tableInfoTabs = computed(() => {
if (tableMetadataCapabilities.value.triggers) {
tabs.push({ id: "triggers", label: t("grid.tableInfoTriggers"), icon: RotateCcw, count: triggers.value.length });
}
if (tableMetadataCapabilities.value.ddl) {
tabs.push({ id: "ddl", label: "DDL", icon: Code2 });
}
return tabs;
});
const tableInfoTabListStyle = computed(() => ({
@@ -10168,7 +10189,16 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
</div>
</div>
<pre v-else-if="activeTableInfoTab === 'ddl' && !ddlLoading" data-native-clipboard class="flex-1 min-w-0 text-xs font-mono p-3 overflow-auto ddl-code leading-5 select-text" :class="ddlWrap ? 'whitespace-pre-wrap break-words' : 'whitespace-pre'" v-html="filteredDdlContent"></pre>
<pre
v-else-if="activeTableInfoTab === 'ddl' && !ddlLoading"
ref="ddlPreRef"
data-native-clipboard
tabindex="0"
class="flex-1 min-w-0 text-xs font-mono p-3 overflow-auto ddl-code leading-5 select-text outline-none"
:class="ddlWrap ? 'whitespace-pre-wrap break-words' : 'whitespace-pre'"
v-html="filteredDdlContent"
@keydown="onDdlKeydown"
></pre>
<div v-else class="flex-1 flex items-center justify-center">
<Loader2 class="w-4 h-4 animate-spin text-muted-foreground" />
</div>