diff --git a/src/SettingTab.tsx b/src/SettingTab.tsx index c09e32c..275eb71 100644 --- a/src/SettingTab.tsx +++ b/src/SettingTab.tsx @@ -2,11 +2,10 @@ import dayjs from "dayjs"; import { App, DropdownComponent, PluginSettingTab, Setting } from "obsidian"; import { - EN_SETTINGS, EN_SETTINGS_HEADER, SettingOptions, + SETTINGS_COPY, SettingsKey, - ZH_SETTINGS, ZH_SETTINGS_HEADER, } from "./locales/settings"; import FolderFileSplitterPlugin from "./main"; @@ -49,15 +48,10 @@ export class SettingTab extends PluginSettingTab { : EN_SETTINGS_HEADER; } - get settingsCopy() { - return this.plugin.language === "zh" ? ZH_SETTINGS : EN_SETTINGS; - } - _initSetting(settingKey: SettingsKey) { - const { settingsCopy } = this; return new Setting(this.containerEl) - .setName(settingsCopy[settingKey].name) - .setDesc(settingsCopy[settingKey].desc); + .setName(SETTINGS_COPY[settingKey][this.plugin.language].name) + .setDesc(SETTINGS_COPY[settingKey][this.plugin.language].desc); } _initToggleSetting(settingKey: K) { @@ -83,7 +77,8 @@ export class SettingTab extends PluginSettingTab { } _initDropdownSetting(settingKey: K) { - const { options = [] } = this.settingsCopy[settingKey]; + const { options = [] } = + SETTINGS_COPY[settingKey][this.plugin.language]; this._initSetting(settingKey).addDropdown((dropdown) => { this._initDropdownOptions(dropdown, options); dropdown.setValue(this.plugin.settings[settingKey] as string); @@ -150,10 +145,10 @@ export class SettingTab extends PluginSettingTab { } generateFileCreationDateFormatDesc(setting: Setting, format: string) { - const { settingsCopy, plugin } = this; + const { plugin } = this; const { language } = plugin; const fragment = document.createDocumentFragment(); - fragment.append(settingsCopy.fileCreationDateFormat.desc); + fragment.append(SETTINGS_COPY.fileCreationDateFormat[language].desc); const anchor = document.createElement("a"); const link = @@ -174,10 +169,10 @@ export class SettingTab extends PluginSettingTab { } _initFileCreationDateFormatSetting() { - const { containerEl, settingsCopy, plugin } = this; - const { settings } = plugin; + const { containerEl, plugin } = this; + const { settings, language } = plugin; const setting = new Setting(containerEl).setName( - settingsCopy.fileCreationDateFormat.name + SETTINGS_COPY.fileCreationDateFormat[language].name ); this.generateFileCreationDateFormatDesc( diff --git a/src/locales/settings.ts b/src/locales/settings.ts index 48b238a..b6cfb44 100644 --- a/src/locales/settings.ts +++ b/src/locales/settings.ts @@ -1,9 +1,17 @@ import { FILE_ITEM_SPACING, + FileDetailSettings, + FileDisplaySettings, FOLDER_NOTE_LOCATION, FOLDER_NOTE_MISSING_BEHAVIOR, + FolderAndFileBehaviorSettings, FolderFileSplitterPluginSettings, + FolderNoteSettings, + FolderSettings, LAYOUT_MODE, + LayoutSettings, + StartupSettings, + TagSettings, } from "src/settings"; export interface SettingsHeaderLocaleResource { @@ -37,330 +45,428 @@ export type SettingOptions = { text: string; }; -export type SettingsLocaleResource = { - [key in SettingsKey]: { - name: string; - desc: string; - options?: SettingOptions[]; +type LocaleResource = { + name: string; + desc: string; + options?: SettingOptions[]; +}; +export type SettingsLocaleResource = { + [key in keyof T]: { + en: LocaleResource; + zh: LocaleResource; }; }; -export const EN_SETTINGS: SettingsLocaleResource = { +export const STARTUP_SETTINGS_COPY: SettingsLocaleResource = { openPluginViewOnStartup: { - name: "Open plugin view on startup", - desc: "When enabled, the plugin view will be opened automatically when Obsidian starts.", - }, - layoutMode: { - name: "Layout mode", - desc: "Choose how to display folders and files in the plugin view. You can arrange them side-by-side, stacked vertically, or use a toggle view that switches between folders and files.", - options: [ - { - value: LAYOUT_MODE.HORIZONTAL_SPLIT, - text: "Horizontal split", - }, - { - value: LAYOUT_MODE.VERTICAL_SPLIT, - text: "Vertical split", - }, - ], - }, - boldFileTitle: { - name: "Bold file title", - desc: "When enabled, file titles will be displayed in bold for better emphasis and readability.", - }, - showFileDetail: { - name: "Show file detail", - desc: "When enabled, file details such as creation time and a content preview will be displayed below the file name.", - }, - showFileCreationDate: { - name: "Show file creation date", - desc: "When enabled, the file's creation date will be displayed in its detail section (requires 'Show file detail' to be enabled).", - }, - fileCreationDateFormat: { - name: "File creation date format", - desc: "Customize the format for displaying file creation dates. Uses dayjs format patterns. The default format is YYYY/MM/DD. See the format guide: ", - }, - stripMarkdownSyntaxInPreview: { - name: "Strip Markdown syntax in preview", - desc: "When enabled, Markdown formatting symbols will be removed from the file content preview (e.g., `**bold**` → `bold`, `### heading` → `heading`).", - }, - removeFirstHeadingInPreview: { - name: "Remove first heading in preview", - desc: "When enabled, the first heading (e.g., # Title) will be removed from the file content preview.", - }, - showFolderHierarchyLines: { - name: "Show hierarchy lines", - desc: "When enabled, a line will be displayed next to folders/tags in the same hierarchy level under an expanded parent folder/tag, visually indicating their nesting relationship.", - }, - showFolderIcon: { - name: "Show folder icon", - desc: "Display an icon next to folders to improve visual clarity and structure.", - }, - showFileItemDivider: { - name: "Show file item divider", - desc: "When enabled, a divider line will be shown between file items in the list for clearer visual separation.", - }, - fileItemSpacing: { - name: "File item spacing", - desc: "Control the vertical spacing between file items in the list. Choose a compact or comfortable layout.", - options: [ - { - value: FILE_ITEM_SPACING.COMPACT, - text: "Compact", - }, - { - value: FILE_ITEM_SPACING.COMFORTABLE, - text: "Comfortable", - }, - ], - }, - highlightActionBar: { - name: "Highlight action bar", - desc: "When enabled, the top action buttons will have a background and margin to distinguish them from surrounding elements.", - }, - autoHideActionBar: { - name: "Auto-hide action bar", - desc: "When enabled, the top action bar will be hidden by default and only appear when hovering over it.", - }, - includeSubfolderFiles: { - name: "Include subfolder files", - desc: "When enabled, files inside subfolders will be included in the file list and their count will be reflected in the folder’s file count.", - }, - showFilesCount: { - name: "Show files count", - desc: "Display the number of files next to each folder or tag. The count will appear on the right side of the item name.", - }, - openDestinationFolderAfterMove: { - name: "Open destination folder after move", - desc: "When enabled, the destination folder will automatically open after moving a file or folder.", - }, - hideRootFolder: { - name: "Hide root folder", - desc: "When enabled, the root folder will be hidden from the folder view. Only its subfolders will be shown.", - }, - autoOpenFolderNote: { - name: "Auto open folder note", - desc: "Automatically open the associated folder note when a folder is selected.", - }, - folderNoteLocation: { - name: "Folder note location", - desc: "Choose where to look for a folder’s note file.", - options: [ - { - value: FOLDER_NOTE_LOCATION.INDEX_FILE, - text: "index.md", - }, - { - value: FOLDER_NOTE_LOCATION.UNDERSCORE_FILE, - text: "_folder.md", - }, - { - value: FOLDER_NOTE_LOCATION.FOLDER_NAME_FILE, - text: "Same name as folder", - }, - { - value: FOLDER_NOTE_LOCATION.CUSTOM_LOCATION_FILE, - text: "Custom path", - }, - ], - }, - customFolderNotePath: { - name: "Custom folder note path", - desc: "Define a custom path pattern for folder notes. You can use placeholders like `{folder}` for the folder name. you can use `{folder}/index.md` or `notes/{folder}.md`.This setting only takes effect when 'Custom path' is selected above.", - }, - folderNoteMissingBehavior: { - name: "If folder note is not found", - desc: "Choose what to do when no folder note is found for a folder.", - options: [ - { - value: FOLDER_NOTE_MISSING_BEHAVIOR.IGNORE, - text: "Do nothing", - }, - { - value: FOLDER_NOTE_MISSING_BEHAVIOR.WARN, - text: "Show warning", - }, - { value: FOLDER_NOTE_MISSING_BEHAVIOR.CREATE, text: "Create new" }, - ], - }, - revealFileInExplorer: { - name: "Reveal file in file explorer", - desc: "When enabled, the selected file will be automatically revealed in plugin's file explorer when switching between files.", - }, - showFolderView: { - name: "Show folder view", - desc: "Display files by folder. Can be used together with tag view.", - }, - showTagView: { - name: "Show tag view", - desc: "Display files by tag. Can be used together with folder view.", - }, - includeSubTagFiles: { - name: "Include subtag files", - desc: "When enabled, files inside subtags will be included in the file list and their count will be reflected in the tag file count.", - }, - showTagIcon: { - name: "Show tag icon", - desc: "Display an icon next to tags to improve visual clarity and structure.", + en: { + name: "Open plugin view on startup", + desc: "When enabled, the plugin view will be opened automatically when Obsidian starts.", + }, + zh: { + name: "启动时自动打开插件视图", + desc: "启用后,Obsidian 启动时会自动打开插件视图。", + }, }, }; -export const ZH_SETTINGS: SettingsLocaleResource = { - openPluginViewOnStartup: { - name: "启动时自动打开插件视图", - desc: "启用后,Obsidian 启动时会自动打开插件视图。", - }, +export const LAYOUT_SETTINGS_COPY: SettingsLocaleResource = { layoutMode: { - name: "布局模式", - desc: "选择插件视图中文件夹和文件的显示方式:水平分割(文件夹和文件两列并排)、垂直分割(文件夹和文件列垂直堆叠),或切换视图(通过切换视图在两者间转换)。", - options: [ - { - value: LAYOUT_MODE.HORIZONTAL_SPLIT, - text: "水平分割", - }, - { - value: LAYOUT_MODE.VERTICAL_SPLIT, - text: "垂直分割", - }, - ], - }, - boldFileTitle: { - name: "加粗文件标题", - desc: "启用后,文件标题将以加粗样式显示,以增强强调和可读性。", - }, - showFileDetail: { - name: "显示文件详情", - desc: "启用后,文件名下方会显示创建时间和内容预览等详细信息。", - }, - showFileCreationDate: { - name: "显示创建日期", - desc: "启用后,文件详情中将显示文件的创建时间(需开启“显示文件详情”)。", - }, - fileCreationDateFormat: { - name: "文件创建日期格式", - desc: "自定义文件创建日期的显示格式。使用 dayjs 库的格式化语法。默认格式为 YYYY/MM/DD。格式参考文档:", - }, - stripMarkdownSyntaxInPreview: { - name: "预览中隐藏 Markdown 符号", - desc: "启用后,文件内容预览中的 Markdown 格式符号将被移除(例如:`**加粗**` → `加粗`, `### 标题` → `标题`)。", - }, - removeFirstHeadingInPreview: { - name: "移除预览中的首个标题行", - desc: "启用后,将从文件内容预览中移除首个标题(例如 # 标题)", - }, - showFolderHierarchyLines: { - name: "显示层级线", - desc: "启用后,展开的父文件夹/标签下会显示同级文件夹/标签的层级线,直观展示嵌套关系。", - }, - showFolderIcon: { - name: "显示文件夹图标", - desc: "启用后,文件夹旁会显示图标,以增强视觉层级感和结构清晰度。", - }, - fileItemSpacing: { - name: "文件项间距", - desc: "控制文件列表中各个文件项之间的垂直间距。可选择紧凑或宽松的布局风格。", - options: [ - { - value: FILE_ITEM_SPACING.COMPACT, - text: "紧凑", - }, - { - value: FILE_ITEM_SPACING.COMFORTABLE, - text: "宽松", - }, - ], - }, - showFileItemDivider: { - name: "显示文件分割线", - desc: "启用后,文件列表中每个文件之间将显示一条分割线,使视觉分隔更加清晰。", + en: { + name: "Layout mode", + desc: "Choose how to display folders and files in the plugin view. You can arrange them side-by-side, stacked vertically, or use a toggle view that switches between folders and files.", + options: [ + { + value: LAYOUT_MODE.HORIZONTAL_SPLIT, + text: "Horizontal split", + }, + { + value: LAYOUT_MODE.VERTICAL_SPLIT, + text: "Vertical split", + }, + ], + }, + zh: { + name: "Layout mode", + desc: "Choose how to display folders and files in the plugin view. You can arrange them side-by-side, stacked vertically, or use a toggle view that switches between folders and files.", + options: [ + { + value: LAYOUT_MODE.HORIZONTAL_SPLIT, + text: "Horizontal split", + }, + { + value: LAYOUT_MODE.VERTICAL_SPLIT, + text: "Vertical split", + }, + ], + }, }, highlightActionBar: { - name: "高亮操作栏", - desc: "启用后,顶部操作按钮区域将添加背景色和边距,以增强与周围内容的区分。", + en: { + name: "Highlight action bar", + desc: "When enabled, the top action buttons will have a background and margin to distinguish them from surrounding elements.", + }, + zh: { + name: "高亮操作栏", + desc: "启用后,顶部操作按钮区域将添加背景色和边距,以增强与周围内容的区分。", + }, }, autoHideActionBar: { - name: "自动隐藏操作栏", - desc: "启用后,顶部操作栏默认隐藏,鼠标悬停时才会显示。", - }, - includeSubfolderFiles: { - name: "包含子文件夹文件", - desc: "启用后,子文件夹中的文件将会显示在文件列表中,并计入所属文件夹的文件数量。", - }, - showFilesCount: { - name: "显示文件数量", - desc: "在每个文件夹或标签名称右侧显示包含的文件数量。", - }, - openDestinationFolderAfterMove: { - name: "移动后打开目标文件夹", - desc: "启用后,在移动文件或文件夹后,目标文件夹将自动展开并显示。", - }, - hideRootFolder: { - name: "隐藏根文件夹", - desc: "启用后,文件夹视图中将隐藏根文件夹,只显示其子文件夹。", - }, - autoOpenFolderNote: { - name: "自动打开 folder note", - desc: "选中某个文件夹时,若存在关联的folder note,将自动打开该笔记", - }, - folderNoteLocation: { - name: "Folder note 路径", - desc: "选择用于匹配 folder note 的路径规则", - options: [ - { - value: FOLDER_NOTE_LOCATION.INDEX_FILE, - text: "index.md", - }, - { - value: FOLDER_NOTE_LOCATION.UNDERSCORE_FILE, - text: "_folder.md", - }, - { - value: FOLDER_NOTE_LOCATION.FOLDER_NAME_FILE, - text: "文件夹同名文件", - }, - { - value: FOLDER_NOTE_LOCATION.CUSTOM_LOCATION_FILE, - text: "自定义路径", - }, - ], - }, - customFolderNotePath: { - name: "自定义 folder note 路径", - desc: "定义 folder note 的自定义路径模式。你可以使用 `{folder}` 占位符来表示当前文件夹名称。例如,你可以使用 `{folder}/index.md` 或 `notes/{folder}.md`。只有在上方选择“自定义路径”时,该设置才会生效。", - }, - folderNoteMissingBehavior: { - name: "找不到 folder note 时", - desc: "选择当文件夹未找到 folder note 时的处理行为。", - options: [ - { - value: FOLDER_NOTE_MISSING_BEHAVIOR.IGNORE, - text: "不处理", - }, - { - value: FOLDER_NOTE_MISSING_BEHAVIOR.WARN, - text: "显示提醒", - }, - { value: FOLDER_NOTE_MISSING_BEHAVIOR.CREATE, text: "自动创建" }, - ], - }, - revealFileInExplorer: { - name: "在文件管理器中定位文件", - desc: "启用后,切换文件时会自动在插件的文件管理器中定位该文件。", - }, - showFolderView: { - name: "显示文件夹视图", - desc: "按文件夹显示文件。可以与标签视图一起使用。", - }, - showTagView: { - name: "显示标签视图", - desc: "按标签显示文件。可以与文件夹视图一起使用。", - }, - includeSubTagFiles: { - name: "包含子标签文件", - desc: "启用后,子标签中的文件将会显示在文件列表中,并计入所属标签的文件数量。", - }, - showTagIcon: { - name: "显示标签图标", - desc: "启用后,标签旁会显示图标,以增强视觉层级感和结构清晰度。", + en: { + name: "Auto-hide action bar", + desc: "When enabled, the top action bar will be hidden by default and only appear when hovering over it.", + }, + zh: { + name: "自动隐藏操作栏", + desc: "启用后,顶部操作栏默认隐藏,鼠标悬停时才会显示。", + }, }, }; + +export const FOLDER_AND_FILE_BEHAVIOR_SETTINGS_COPY: SettingsLocaleResource = + { + hideRootFolder: { + en: { + name: "Hide root folder", + desc: "When enabled, the root folder will be hidden from the folder view. Only its subfolders will be shown.", + }, + zh: { + name: "隐藏根文件夹", + desc: "启用后,文件夹视图中将隐藏根文件夹,只显示其子文件夹。", + }, + }, + showFolderHierarchyLines: { + en: { + name: "Show hierarchy lines", + desc: "When enabled, a line will be displayed next to folders/tags in the same hierarchy level under an expanded parent folder/tag, visually indicating their nesting relationship.", + }, + zh: { + name: "显示层级线", + desc: "启用后,展开的父文件夹/标签下会显示同级文件夹/标签的层级线,直观展示嵌套关系。", + }, + }, + showFilesCount: { + en: { + name: "Show files count", + desc: "Display the number of files next to each folder or tag. The count will appear on the right side of the item name.", + }, + zh: { + name: "显示文件数量", + desc: "在每个文件夹或标签名称右侧显示包含的文件数量。", + }, + }, + openDestinationFolderAfterMove: { + en: { + name: "Open destination folder after move", + desc: "When enabled, the destination folder will automatically open after moving a file or folder.", + }, + zh: { + name: "移动后打开目标文件夹", + desc: "启用后,在移动文件或文件夹后,目标文件夹将自动展开并显示。", + }, + }, + revealFileInExplorer: { + en: { + name: "Reveal file in file explorer", + desc: "When enabled, the selected file will be automatically revealed in plugin's file explorer when switching between files.", + }, + zh: { + name: "在文件管理器中定位文件", + desc: "启用后,切换文件时会自动在插件的文件管理器中定位该文件。", + }, + }, + }; + +export const FOLDER_SETTINGS_COPY: SettingsLocaleResource = { + showFolderView: { + en: { + name: "Show folder view", + desc: "Display files by folder. Can be used together with tag view.", + }, + zh: { + name: "显示文件夹视图", + desc: "按文件夹显示文件。可以与标签视图一起使用。", + }, + }, + showFolderIcon: { + en: { + name: "Show folder icon", + desc: "Display an icon next to folders to improve visual clarity and structure.", + }, + zh: { + name: "显示文件夹图标", + desc: "启用后,文件夹旁会显示图标,以增强视觉层级感和结构清晰度。", + }, + }, + includeSubfolderFiles: { + en: { + name: "Include subfolder files", + desc: "When enabled, files inside subfolders will be included in the file list and their count will be reflected in the folder’s file count.", + }, + zh: { + name: "包含子文件夹文件", + desc: "启用后,子文件夹中的文件将会显示在文件列表中,并计入所属文件夹的文件数量。", + }, + }, +}; + +export const TAG_SETTINGS_COPY: SettingsLocaleResource = { + showTagView: { + en: { + name: "Show tag view", + desc: "Display files by tag. Can be used together with folder view.", + }, + zh: { + name: "显示标签视图", + desc: "按标签显示文件。可以与文件夹视图一起使用。", + }, + }, + showTagIcon: { + en: { + name: "Show tag icon", + desc: "Display an icon next to tags to improve visual clarity and structure.", + }, + zh: { + name: "显示标签图标", + desc: "启用后,标签旁会显示图标,以增强视觉层级感和结构清晰度。", + }, + }, + includeSubTagFiles: { + en: { + name: "Include subtag files", + desc: "When enabled, files inside subtags will be included in the file list and their count will be reflected in the tag file count.", + }, + zh: { + name: "包含子标签文件", + desc: "启用后,子标签中的文件将会显示在文件列表中,并计入所属标签的文件数量。", + }, + }, +}; + +export const FILE_DETAIL_SETTINGS_COPY: SettingsLocaleResource = + { + showFileDetail: { + en: { + name: "Show file detail", + desc: "When enabled, file details such as creation time and a content preview will be displayed below the file name.", + }, + zh: { + name: "显示文件详情", + desc: "启用后,文件名下方会显示创建时间和内容预览等详细信息。", + }, + }, + stripMarkdownSyntaxInPreview: { + en: { + name: "Strip Markdown syntax in preview", + desc: "When enabled, Markdown formatting symbols will be removed from the file content preview (e.g., `**bold**` → `bold`, `### heading` → `heading`).", + }, + zh: { + name: "预览中隐藏 Markdown 符号", + desc: "启用后,文件内容预览中的 Markdown 格式符号将被移除(例如:`**加粗**` → `加粗`, `### 标题` → `标题`)。", + }, + }, + removeFirstHeadingInPreview: { + en: { + name: "Remove first heading in preview", + desc: "When enabled, the first heading (e.g., # Title) will be removed from the file content preview.", + }, + zh: { + name: "移除预览中的首个标题行", + desc: "启用后,将从文件内容预览中移除首个标题(例如 # 标题)", + }, + }, + showFileCreationDate: { + en: { + name: "Show file creation date", + desc: "When enabled, the file's creation date will be displayed in its detail section (requires 'Show file detail' to be enabled).", + }, + zh: { + name: "显示创建日期", + desc: "启用后,文件详情中将显示文件的创建时间(需开启“显示文件详情”)。", + }, + }, + fileCreationDateFormat: { + en: { + name: "File creation date format", + desc: "Customize the format for displaying file creation dates. Uses dayjs format patterns. The default format is YYYY/MM/DD. See the format guide: ", + }, + zh: { + name: "文件创建日期格式", + desc: "自定义文件创建日期的显示格式。使用 dayjs 库的格式化语法。默认格式为 YYYY/MM/DD。格式参考文档:", + }, + }, + }; + +export const FILE_DISPLAY_SETTINGS_COPY: SettingsLocaleResource = + { + boldFileTitle: { + en: { + name: "Bold file title", + desc: "When enabled, file titles will be displayed in bold for better emphasis and readability.", + }, + zh: { + name: "加粗文件标题", + desc: "启用后,文件标题将以加粗样式显示,以增强强调和可读性。", + }, + }, + fileItemSpacing: { + en: { + name: "File item spacing", + desc: "Control the vertical spacing between file items in the list. Choose a compact or comfortable layout.", + options: [ + { + value: FILE_ITEM_SPACING.COMPACT, + text: "Compact", + }, + { + value: FILE_ITEM_SPACING.COMFORTABLE, + text: "Comfortable", + }, + ], + }, + zh: { + name: "文件项间距", + desc: "控制文件列表中各个文件项之间的垂直间距。可选择紧凑或宽松的布局风格。", + options: [ + { + value: FILE_ITEM_SPACING.COMPACT, + text: "紧凑", + }, + { + value: FILE_ITEM_SPACING.COMFORTABLE, + text: "宽松", + }, + ], + }, + }, + showFileItemDivider: { + en: { + name: "Show file item divider", + desc: "When enabled, a divider line will be shown between file items in the list for clearer visual separation.", + }, + zh: { + name: "显示文件分割线", + desc: "启用后,文件列表中每个文件之间将显示一条分割线,使视觉分隔更加清晰。", + }, + }, + }; + +export const FOLDER_NOTE_SETTINGS_COPY: SettingsLocaleResource = + { + autoOpenFolderNote: { + en: { + name: "Auto open folder note", + desc: "Automatically open the associated folder note when a folder is selected.", + }, + zh: { + name: "自动打开 folder note", + desc: "选中某个文件夹时,若存在关联的folder note,将自动打开该笔记", + }, + }, + folderNoteLocation: { + en: { + name: "Folder note location", + desc: "Choose where to look for a folder’s note file.", + options: [ + { + value: FOLDER_NOTE_LOCATION.INDEX_FILE, + text: "index.md", + }, + { + value: FOLDER_NOTE_LOCATION.UNDERSCORE_FILE, + text: "_folder.md", + }, + { + value: FOLDER_NOTE_LOCATION.FOLDER_NAME_FILE, + text: "Same name as folder", + }, + { + value: FOLDER_NOTE_LOCATION.CUSTOM_LOCATION_FILE, + text: "Custom path", + }, + ], + }, + zh: { + name: "Folder note 路径", + desc: "选择用于匹配 folder note 的路径规则", + options: [ + { + value: FOLDER_NOTE_LOCATION.INDEX_FILE, + text: "index.md", + }, + { + value: FOLDER_NOTE_LOCATION.UNDERSCORE_FILE, + text: "_folder.md", + }, + { + value: FOLDER_NOTE_LOCATION.FOLDER_NAME_FILE, + text: "文件夹同名文件", + }, + { + value: FOLDER_NOTE_LOCATION.CUSTOM_LOCATION_FILE, + text: "自定义路径", + }, + ], + }, + }, + customFolderNotePath: { + en: { + name: "Custom folder note path", + desc: "Define a custom path pattern for folder notes. You can use placeholders like `{folder}` for the folder name. you can use `{folder}/index.md` or `notes/{folder}.md`.This setting only takes effect when 'Custom path' is selected above.", + }, + zh: { + name: "自定义 folder note 路径", + desc: "定义 folder note 的自定义路径模式。你可以使用 `{folder}` 占位符来表示当前文件夹名称。例如,你可以使用 `{folder}/index.md` 或 `notes/{folder}.md`。只有在上方选择“自定义路径”时,该设置才会生效。", + }, + }, + folderNoteMissingBehavior: { + en: { + name: "If folder note is not found", + desc: "Choose what to do when no folder note is found for a folder.", + options: [ + { + value: FOLDER_NOTE_MISSING_BEHAVIOR.IGNORE, + text: "Do nothing", + }, + { + value: FOLDER_NOTE_MISSING_BEHAVIOR.WARN, + text: "Show warning", + }, + { + value: FOLDER_NOTE_MISSING_BEHAVIOR.CREATE, + text: "Create new", + }, + ], + }, + zh: { + name: "找不到 folder note 时", + desc: "选择当文件夹未找到 folder note 时的处理行为。", + options: [ + { + value: FOLDER_NOTE_MISSING_BEHAVIOR.IGNORE, + text: "不处理", + }, + { + value: FOLDER_NOTE_MISSING_BEHAVIOR.WARN, + text: "显示提醒", + }, + { + value: FOLDER_NOTE_MISSING_BEHAVIOR.CREATE, + text: "自动创建", + }, + ], + }, + }, + }; + +export const SETTINGS_COPY: SettingsLocaleResource = + { + ...STARTUP_SETTINGS_COPY, + ...LAYOUT_SETTINGS_COPY, + ...FOLDER_AND_FILE_BEHAVIOR_SETTINGS_COPY, + ...FOLDER_SETTINGS_COPY, + ...TAG_SETTINGS_COPY, + ...FILE_DETAIL_SETTINGS_COPY, + ...FILE_DISPLAY_SETTINGS_COPY, + ...FOLDER_NOTE_SETTINGS_COPY, + }; diff --git a/src/settings.ts b/src/settings.ts index abb0bd1..f093b29 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -31,62 +31,117 @@ export type FolderNoteMissingBehavior = ValueOf< export const DEFAULT_FILE_CREATION_DATE_FORMAT = "YYYY/MM/DD"; -export interface FolderFileSplitterPluginSettings { - includeSubfolderFiles: boolean; - showFolderHierarchyLines: boolean; - showFolderIcon: boolean; - boldFileTitle: boolean; - showFileDetail: boolean; - removeFirstHeadingInPreview: boolean; - fileCreationDateFormat: string; - showFileCreationDate: boolean; - showFileItemDivider: boolean; - showFilesCount: boolean, - stripMarkdownSyntaxInPreview: boolean; - fileItemSpacing: FileItemSpacing; +export type StartupSettings = { + openPluginViewOnStartup: boolean; +}; +export type LayoutSettings = { + layoutMode: LayoutMode; highlightActionBar: boolean; autoHideActionBar: boolean; - openPluginViewOnStartup: boolean; - layoutMode: LayoutMode; - openDestinationFolderAfterMove: boolean; +}; +export type FolderAndFileBehaviorSettings = { hideRootFolder: boolean; + showFolderHierarchyLines: boolean; + showFilesCount: boolean; + openDestinationFolderAfterMove: boolean; + revealFileInExplorer: boolean; +}; +export type FolderSettings = { + showFolderView: boolean; + showFolderIcon: boolean; + includeSubfolderFiles: boolean; +}; +export type TagSettings = { + showTagView: boolean; + showTagIcon: boolean; + includeSubTagFiles: boolean; +}; +export type FileDetailSettings = { + showFileDetail: boolean; + stripMarkdownSyntaxInPreview: boolean; + removeFirstHeadingInPreview: boolean; + showFileCreationDate: boolean; + fileCreationDateFormat: string; +}; +export type FileDisplaySettings = { + boldFileTitle: boolean; + fileItemSpacing: FileItemSpacing; + showFileItemDivider: boolean; +}; +export type FolderNoteSettings = { autoOpenFolderNote: boolean; folderNoteLocation: FolderNoteLocation; customFolderNotePath: string; folderNoteMissingBehavior: FolderNoteMissingBehavior; - revealFileInExplorer: boolean; - showFolderView: boolean; - showTagView: boolean; - includeSubTagFiles: boolean; - showTagIcon: boolean; -} +}; +export type FolderFileSplitterPluginSettings = StartupSettings & + LayoutSettings & + FolderAndFileBehaviorSettings & + FolderSettings & + TagSettings & + FileDetailSettings & + FileDisplaySettings & + FolderNoteSettings; -export const DEFAULT_SETTINGS: FolderFileSplitterPluginSettings = { - includeSubfolderFiles: false, - showFolderHierarchyLines: false, +export const STARTUP_SETTINGS: StartupSettings = { + openPluginViewOnStartup: true, +}; + +export const LAYOUT_SETTINGS: LayoutSettings = { + layoutMode: LAYOUT_MODE.HORIZONTAL_SPLIT, + highlightActionBar: false, + autoHideActionBar: false, +}; + +export const FOLDER_AND_FILE_BEHAVIOR_SETTINGS: FolderAndFileBehaviorSettings = + { + hideRootFolder: false, + showFolderHierarchyLines: false, + showFilesCount: true, + openDestinationFolderAfterMove: false, + revealFileInExplorer: false, + }; + +export const FOLDER_SETTINGS: FolderSettings = { + showFolderView: true, showFolderIcon: true, - boldFileTitle: true, + includeSubfolderFiles: false, +}; + +export const TAG_SETTINGS: TagSettings = { + showTagView: false, + showTagIcon: true, + includeSubTagFiles: false, +}; + +export const FILE_DETAIL_SETTINGS: FileDetailSettings = { showFileDetail: true, stripMarkdownSyntaxInPreview: false, removeFirstHeadingInPreview: false, showFileCreationDate: true, - showFilesCount: true, fileCreationDateFormat: DEFAULT_FILE_CREATION_DATE_FORMAT, +}; + +export const FILE_DISPLAY_SETTINGS: FileDisplaySettings = { + boldFileTitle: true, fileItemSpacing: FILE_ITEM_SPACING.COMFORTABLE, showFileItemDivider: true, - highlightActionBar: false, - autoHideActionBar: false, - openPluginViewOnStartup: true, - layoutMode: LAYOUT_MODE.HORIZONTAL_SPLIT, - openDestinationFolderAfterMove: false, - hideRootFolder: false, +}; + +export const FOLDER_NOTE_SETTINGS: FolderNoteSettings = { autoOpenFolderNote: false, folderNoteLocation: FOLDER_NOTE_LOCATION.INDEX_FILE, customFolderNotePath: "", folderNoteMissingBehavior: FOLDER_NOTE_MISSING_BEHAVIOR.IGNORE, - revealFileInExplorer: false, - showFolderView: true, - showTagView: false, - includeSubTagFiles: false, - showTagIcon: true, +}; + +export const DEFAULT_SETTINGS: FolderFileSplitterPluginSettings = { + ...STARTUP_SETTINGS, + ...LAYOUT_SETTINGS, + ...FOLDER_AND_FILE_BEHAVIOR_SETTINGS, + ...FOLDER_SETTINGS, + ...TAG_SETTINGS, + ...FILE_DETAIL_SETTINGS, + ...FILE_DISPLAY_SETTINGS, + ...FOLDER_NOTE_SETTINGS, };