mirror of
https://github.com/antokeinanen/obsidian-advanced-merger.git
synced 2026-07-22 04:34:44 +00:00
feat(#15): add toggle to remove YAML properties in settings
This commit is contained in:
parent
47ae3e112a
commit
f89926d69c
6 changed files with 84 additions and 57 deletions
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -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.
|
||||
|
|
|
|||
24
CHANGELOG.md
24
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
|
||||
|
|
|
|||
28
README.md
28
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 <subject> use imperative, present tense: “change” not “changed” nor “changes”
|
||||
- Optional but recommended
|
||||
- Just as in <subject> use imperative, present tense: “change” not “changed” nor “changes”
|
||||
|
||||
# Support
|
||||
|
||||
|
|
|
|||
26
src/main.ts
26
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<string, Translation> = {
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue