diff --git a/components.d.ts b/components.d.ts index 0ad2d15f..70d38b10 100644 --- a/components.d.ts +++ b/components.d.ts @@ -302,6 +302,11 @@ declare module '@vue/runtime-core' { NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default'] 'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default'] NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] + NCode: typeof import('naive-ui')['NCode'] + NConfigProvider: typeof import('naive-ui')['NConfigProvider'] + NDivider: typeof import('naive-ui')['NDivider'] + NEllipsis: typeof import('naive-ui')['NEllipsis'] + NFormItem: typeof import('naive-ui')['NFormItem'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NDivider: typeof import('naive-ui')['NDivider'] NEllipsis: typeof import('naive-ui')['NEllipsis'] @@ -311,6 +316,12 @@ declare module '@vue/runtime-core' { NH1: typeof import('naive-ui')['NH1'] NH3: typeof import('naive-ui')['NH3'] NIcon: typeof import('naive-ui')['NIcon'] + NInputNumber: typeof import('naive-ui')['NInputNumber'] + NLayout: typeof import('naive-ui')['NLayout'] + NLayoutSider: typeof import('naive-ui')['NLayoutSider'] + NMenu: typeof import('naive-ui')['NMenu'] + NScrollbar: typeof import('naive-ui')['NScrollbar'] + NTable: typeof import('naive-ui')['NTable'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] diff --git a/src/components/TextareaCopyable.vue b/src/components/TextareaCopyable.vue index f87dc226..97e41db2 100644 --- a/src/components/TextareaCopyable.vue +++ b/src/components/TextareaCopyable.vue @@ -31,6 +31,8 @@ const props = withDefaults( wordWrap?: boolean downloadFileName?: string downloadButtonText?: string + scrollable?: boolean + maxHeight?: string }>(), { followHeightOf: null, @@ -39,6 +41,8 @@ const props = withDefaults( copyMessage: 'Copy to clipboard', downloadFileName: '', downloadButtonText: 'Download', + scrollable: false, + maxHeight: '400px', }, ); hljs.registerLanguage('sql', sqlHljs); @@ -62,6 +66,17 @@ hljs.registerLanguage('protobuf', protobufHljs); const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props); const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) }; +const scrollbarRef = ref(); + +// Watch for content changes and scroll to bottom +watch(value, () => { + nextTick(() => { + if (scrollbarRef.value) { + scrollbarRef.value.scrollTo({ top: scrollbarRef.value.scrollbarInstRef.containerRef.scrollHeight }); + } + }); +}, { flush: 'post' }); + const { copy, isJustCopied } = useCopy({ source: value, createToast: false }); const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value); @@ -80,9 +95,14 @@ const { download } = useDownloadFileFromBase64( :style="(copyPlacement === 'top-right' || copyPlacement === 'bottom-right') ? `padding-bottom: 50px` : ''" > @@ -90,10 +110,10 @@ const { download } = useDownloadFileFromBase64(
diff --git a/src/tools/folder-structure-diagram/folder-structure-diagram.vue b/src/tools/folder-structure-diagram/folder-structure-diagram.vue index bc215dbd..0a3dc8c9 100644 --- a/src/tools/folder-structure-diagram/folder-structure-diagram.vue +++ b/src/tools/folder-structure-diagram/folder-structure-diagram.vue @@ -1,27 +1,35 @@ diff --git a/src/tools/folder-structure-diagram/lib/convert-tree-to-structure.ts b/src/tools/folder-structure-diagram/lib/convert-tree-to-structure.ts new file mode 100644 index 00000000..f62b8692 --- /dev/null +++ b/src/tools/folder-structure-diagram/lib/convert-tree-to-structure.ts @@ -0,0 +1,46 @@ +import { LINE_STRINGS } from './line-strings'; + +export default function convertTreeToStructure(tree: string): string { + const treeLines = tree.split('\n').filter(line => line.trim()); + + if (treeLines.length === 0) { + return ''; + } + + // Detect charset by checking for unicode box drawing characters (U+2500 to U+257F) + const charset = treeLines.some(line => /[\u2500-\u257F]/.test(line)) ? 'utf-8' : 'ascii'; + const lines = LINE_STRINGS[charset]; + + // Create a single regex to match all tree connectors + const treeConnectorRegex = new RegExp(`(${lines.CHILD}|${lines.LAST_CHILD})`, 'g'); + + return treeLines + .flatMap((line) => { + // Find the last tree connector to determine depth and extract name + const matches = [...line.matchAll(treeConnectorRegex)]; + + if (matches.length === 0) { + // No tree connectors found - likely root or invalid line + return []; // Return empty array instead of null or empty string so the flatMap filters it out and doesn't leave unnecessary empty lines + } + + const lastMatch = matches[matches.length - 1]; + const connectorEnd = lastMatch.index! + lastMatch[0].length; + + // Calculate depth (assuming 4 characters per level) + const depth = Math.floor(lastMatch.index! / 4); + + // Extract folder name after the last connector + let folderName = line.substring(connectorEnd); + + // When the folder name is an empty string (because it was created with "- ") or starts with a space, add a dash and space + // to preserve the empty tree connector or the spaces before actual text characters in the folder name + if (folderName === '' || folderName.startsWith(' ')) { + folderName = `- ${folderName}`; + } + + // Create indented structure (2 spaces per level) + return [`${' '.repeat(depth * 2)}${folderName}`]; + }) + .join('\n'); +}