diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f6387b4..1f3bed5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -25,9 +25,9 @@ If applicable, add screenshots to help explain your problem. **System information:** -- OS: [e.g. iOS8.1, linux] -- Obsidian version [e.g. 1.1.16] _(can be found at about page in settings)_ -- Plugin version [e.g. 1.0.0] _(can be found at community plugins page in settings)_ +- OS: [e.g. iOS8.1, linux] +- Obsidian version [e.g. 1.1.16] _(can be found at about page in settings)_ +- Plugin version [e.g. 1.0.0] _(can be found at community plugins page in settings)_ **Additional context** Add any other context about the problem here. diff --git a/CHANGELOG.md b/CHANGELOG.md index b7d0d39..2cace42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,45 +2,45 @@ ### Additions and Changes -- Added multiple ways to sort files on merge +- Added multiple ways to sort files on merge ## obsidian-advanced-merger 1.4.0 ### Additions and Changes -- Added new option to include "nested folders as sections" (depends on "nested folders" setting) -- Type-safe plugin translations +- Added new option to include "nested folders as sections" (depends on "nested folders" setting) +- Type-safe plugin translations ## obsidian-advanced-merger 1.3.0 ### Additions and Changes -- Added "Overwrite existing file" dialog +- Added "Overwrite existing file" dialog ## obsidian-advanced-merger 1.2.0 ### Additions and Changes -- Translations support added (starter: English, Ukranian, Finnish, French, Russian, German) -- Added support and configuration for merging files in nested folders -- Added configuration for sorting mode (default/alphabetically) +- Translations support added (starter: English, Ukranian, Finnish, French, Russian, German) +- Added support and configuration for merging files in nested folders +- Added configuration for sorting mode (default/alphabetically) ## obsidian-advanced-merger 1.1.0 ### Additions and Changes -- Fix issue where the created file will still be collected and merged -- Remove not needed await Promise.All +- Fix issue where the created file will still be collected and merged +- Remove not needed await Promise.All ## obsidian-advanced-merger 1.0.2 ### Additions and Changes -- Added sorting alphabetically by file path +- Added sorting alphabetically by file path ## obsidian-advanced-merger 1.0.1 ### Additions and Changes -- Remove unused onunload event -- Remove redundant file check +- Remove unused onunload event +- Remove redundant file check diff --git a/README.md b/README.md index 6b868fc..4f0dac9 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ All contributions are welcome, but before making anything big please consider st # Code of conduct -- Make sure your code is formatted with the `npm/yarn run format` script. -- Use angular commit message style. More info [here](https://github.com/antoKeinanen/obsidian-advanced-merger#commit-message-format). -- Please _DO NOT_ modify `manifest.json` as it breaks the plugin download system. For beta release use [BRAT](https://tfthacker.com/Obsidian+Plugins+by+TfTHacker/BRAT+-+Beta+Reviewer's+Auto-update+Tool/Quick+guide+for+using+BRAT#Testing+Plugins) and version bump `manifest-beta.json`. +- Make sure your code is formatted with the `npm/yarn run format` script. +- Use angular commit message style. More info [here](https://github.com/antoKeinanen/obsidian-advanced-merger#commit-message-format). +- Please _DO NOT_ modify `manifest.json` as it breaks the plugin download system. For beta release use [BRAT](https://tfthacker.com/Obsidian+Plugins+by+TfTHacker/BRAT+-+Beta+Reviewer's+Auto-update+Tool/Quick+guide+for+using+BRAT#Testing+Plugins) and version bump `manifest-beta.json`. ## Commit message format @@ -74,25 +74,25 @@ The type field is always required. A summary is optional when bumping the versio **Example**: `fix(#123): fix a bug where XYZ`, `bump-version`, `feat(#123): add a feature that XYZ` Must be one of the following: -- build: Changes that affect the build system or external dependencies -- docs: Documentation only changes -- feat: A new feature -- fix: A bug fix -- refactor: A code change that neither fixes a bug nor adds a feature -- test: Adding new tests or correcting existing tests +- build: Changes that affect the build system or external dependencies +- docs: Documentation only changes +- feat: A new feature +- fix: A bug fix +- refactor: A code change that neither fixes a bug nor adds a feature +- test: Adding new tests or correcting existing tests ## Summary Use the summary field to provide a succinct description of the change: -- use the imperative, present tense: "change" not "changed" nor "changes" -- don't capitalize the first letter -- no dot (.) at the end +- use the imperative, present tense: "change" not "changed" nor "changes" +- don't capitalize the first letter +- no dot (.) at the end ## Message body -- Optional but recommended -- Just as in use imperative, present tense: “change” not “changed” nor “changes” +- Optional but recommended +- Just as in use imperative, present tense: “change” not “changed” nor “changes” # Support diff --git a/src/main.ts b/src/main.ts index 4d3ae40..4f6412e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -149,6 +149,12 @@ export default class AdvancedMerge extends Plugin { `Adding folder "${folderOrFile.name}" as section "${sectionContents}" into file "${outputFileName}"..`, ); } + + sectionContents = sectionContents.replace( + /^---\n(\w*:\s.*\n)*---/, + "", + ); + vault.append(outputFile, sectionContents); } } @@ -281,6 +287,26 @@ class AdvancedMergeSettingTab extends PluginSettingTab { }), ); + // Add "remove yaml properties" toggle in settings + new Setting(containerEl) + .setName(this.plugin.translation.get().SettingRemoveYamlProperties) + .setDesc( + this.plugin.translation.get() + .SettingRemoveYamlPropertiesDescription, + ) + .addToggle((toggle) => + toggle + .setValue(this.plugin.settings.removeYamlProperties) + .onChange(async (value) => { + this.plugin.settings.removeYamlProperties = value; + this.plugin.settings.removeYamlProperties = + value === false + ? value + : this.plugin.settings.removeYamlProperties; + await this.plugin.saveSettings(); + }), + ); + this.showIncludeFolderAsSectionSetting(containerEl); } diff --git a/src/settings.ts b/src/settings.ts index 6bfaa3d..180c765 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -6,10 +6,12 @@ export interface AdvancedMergePluginSettings { sortMode: "alphabetical" | "creationDate" | "logical"; includeNestedFolders: boolean; includeFoldersAsSections: boolean; + removeYamlProperties: boolean; } export const DEFAULT_SETTINGS: AdvancedMergePluginSettings = { sortMode: "logical", includeNestedFolders: false, includeFoldersAsSections: false, + removeYamlProperties: false, }; diff --git a/src/translation.ts b/src/translation.ts index 7fd6ba8..ed9b666 100644 --- a/src/translation.ts +++ b/src/translation.ts @@ -14,11 +14,13 @@ export interface Translation { SettingIncludeNestedFoldersDescription: string; SettingIncludeFoldersAsSections: string; SettingIncludeFoldersAsSectionsDescription: string; + SettingRemoveYamlProperties: string; + SettingRemoveYamlPropertiesDescription: string; Yes: string; No: string; } -export const TRANSLATIONS: { [name: string]: Translation } = { +export const TRANSLATIONS: Record = { de: { MergeFolder: "Ordner zusammenführen", MergedFilesuffix: "zusammengeführt", @@ -38,25 +40,32 @@ export const TRANSLATIONS: { [name: string]: Translation } = { SettingSortDateCreated: "Erstellungsdatum", SettingSortLogical: "Logisch", SettingSortAlphabetically: "Alphabetisch", + SettingRemoveYamlProperties: "YAML-Eigenschaften entfernen", + SettingRemoveYamlPropertiesDescription: + "Entfernt YAML-Eigenschaften vom Anfang der Datei während des Zusammenführens. WARNUNG: Dies könnte unbeabsichtigt nicht-YAML-Teile entfernen.", }, en: { MergeFolder: "Merge folder", MergedFilesuffix: "merged", - OverwriteFileQuestion: "Overwite exising file", + OverwriteFileQuestion: "Overwrite existing file", Settings: "Settings", SettingIncludeNestedFolders: "Include nested folders", SettingIncludeNestedFoldersDescription: - "If enabled, files in nested folders will be included in merge. Otherwise, only files in selected folder will be merged (default behaviour).", + "If enabled, files in nested folders will be included in the merge. Otherwise, only files in the selected folder will be merged (default behavior).", SettingIncludeFoldersAsSections: "Include folders as sections", SettingIncludeFoldersAsSectionsDescription: - "Folders will be included as named sections into output file.", + "Folders will be included as named sections in the output file.", Yes: "Yes", No: "No", SettingSortMode: "Sort mode", - SettingSortModeDescription: "Pick the sorting mode for merging notes.", + SettingSortModeDescription: + "Choose the sorting mode for merging notes.", SettingSortDateCreated: "Date created", SettingSortLogical: "Logical", SettingSortAlphabetically: "Alphabetical", + SettingRemoveYamlProperties: "Remove YAML properties", + SettingRemoveYamlPropertiesDescription: + "Removes YAML properties from the top of the file during the merge. WARNING: This might unintentionally remove non yaml parts.", }, fi: { MergeFolder: "Yhdistä kansio", @@ -71,12 +80,15 @@ export const TRANSLATIONS: { [name: string]: Translation } = { "Kansiot sisällytetään nimettyinä osina tulostiedostoon.", Yes: "Kyllä", No: "Ei", - SettingSortMode: "Lajittelu järjestys", + SettingSortMode: "Lajittelujärjestys", SettingSortModeDescription: "Valitse lajittelutapa muistiinpanojen yhdistämistä varten.", SettingSortDateCreated: "Luontipäivämäärä", SettingSortLogical: "Looginen", SettingSortAlphabetically: "Aakkosjärjestys", + SettingRemoveYamlProperties: "Poista YAML-osio", + SettingRemoveYamlPropertiesDescription: + "Poistaa YAML-osio tiedoston yläosasta yhdistämisen aikana. VAROITUS: Tämä voi vahingossa poistaa ei-YAML-osia.", }, fr: { MergeFolder: "Fusionner le dossier", @@ -98,6 +110,9 @@ export const TRANSLATIONS: { [name: string]: Translation } = { SettingSortDateCreated: "Date de création", SettingSortLogical: "Logique", SettingSortAlphabetically: "Alphabétique", + SettingRemoveYamlProperties: "Supprimer les propriétés YAML", + SettingRemoveYamlPropertiesDescription: + "Supprime les propriétés YAML du haut du fichier lors de la fusion. ATTENTION : Cela pourrait supprimer accidentellement des parties non YAML.", }, ru: { MergeFolder: "Объединить папку", @@ -118,6 +133,9 @@ export const TRANSLATIONS: { [name: string]: Translation } = { SettingSortDateCreated: "Дата создания", SettingSortLogical: "Логический", SettingSortAlphabetically: "Алфавитный указатель", + SettingRemoveYamlProperties: "Удалить свойства YAML", + SettingRemoveYamlPropertiesDescription: + "Удаляет свойства YAML из верхней части файла во время объединения. ВНИМАНИЕ: Это может случайно удалить не-YAML части.", }, ua: { MergeFolder: "Об'єднати папку", @@ -138,27 +156,8 @@ export const TRANSLATIONS: { [name: string]: Translation } = { SettingSortDateCreated: "Дата створення", SettingSortLogical: "Логічний", SettingSortAlphabetically: "За алфавітом", + SettingRemoveYamlProperties: "Видалити властивості YAML", + SettingRemoveYamlPropertiesDescription: + "Видаляє властивості YAML із верхньої частини файлу під час об'єднання. УВАГА: Це може випадково видалити не-YAML частини.", }, }; - -export class AdvancedMergeTranslation { - private language: string; - - /** - * Represents a plugin translation. - * @constructor - */ - constructor() { - this.language = !Object.keys(TRANSLATIONS).contains(navigator.language) - ? DEFAULT_LANGUAGE - : navigator.language; - } - - /** - * Gets translation object for current language. - * @returns {Translation} Current translation object. - */ - public get(): Translation { - return TRANSLATIONS[this.language]; - } -}