diff --git a/biome.json b/biome.json index 3f172825..6e9f6a99 100644 --- a/biome.json +++ b/biome.json @@ -107,6 +107,14 @@ "include": [ "*.json" ] + }, + { + "include": [ + "src/settings/help.ts" + ], + "formatter": { + "lineWidth": 320 + } } ], "formatter": { diff --git a/src/i18n/locales b/src/i18n/locales index 4105c68c..debedd5e 160000 --- a/src/i18n/locales +++ b/src/i18n/locales @@ -1 +1 @@ -Subproject commit 4105c68c60baa7369d409a38d064d47e57be143b +Subproject commit debedd5e5158e2a638f960a83631363e7b67b2d6 diff --git a/src/interfaces/icons.ts b/src/interfaces/icons.ts index ab78aa6e..c9b7034e 100644 --- a/src/interfaces/icons.ts +++ b/src/interfaces/icons.ts @@ -1,20 +1,38 @@ export const LOADING_ICON = - ''; + ''; export const SUCCESS_ICON = - ''; + ''; export const HOURGLASS_ICON = - ''; + ''; export const FOUND_ATTACHMENTS = - ''; + ''; export const ERROR_ICONS = - ''; + ''; export const BUG_ICONS = ''; export const BUG_OFF_ICON = ''; + +export const DISCORD_ICON = + ''; + +export const TRANSLATION_ICON = + ''; + +export const GITHUB_ICON = + ''; + +export const DISCUSSION_ICON = + ''; + +export const ISSUE = + ''; + +export const DOCUMENTATION = + ''; diff --git a/src/settings.ts b/src/settings.ts index f5b53adc..76511d8d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,44 +1,16 @@ -import { - EnumbSettingsTabId, - FolderSettings, - type GitHubPublisherSettings, - GithubTiersVersion, - type Repository, -} from "@interfaces"; +import { EnumbSettingsTabId, FolderSettings, type GitHubPublisherSettings, GithubTiersVersion, type Repository } from "@interfaces"; import i18next from "i18next"; -import { type App, Notice, PluginSettingTab, setIcon, Setting } from "obsidian"; +import { type App, Notice, PluginSettingTab, sanitizeHTMLToDom, setIcon, Setting } from "obsidian"; import type GithubPublisherPlugin from "src/main"; -import { - help, - KeyBasedOnSettings, - multipleRepoExplained, - supportMe, - usefulLinks, -} from "src/settings/help"; +import { help, KeyBasedOnSettings, multipleRepoExplained, supportMe, usefulLinks } from "src/settings/help"; import { migrateToken } from "src/settings/migrate"; -import { - ExportModal, - ImportLoadPreset, - ImportModal, - loadAllPresets, -} from "src/settings/modals/import_export"; +import { ExportModal, ImportLoadPreset, ImportModal, loadAllPresets } from "src/settings/modals/import_export"; import { ModalAddingNewRepository } from "src/settings/modals/manage_repo"; import { AutoCleanPopup } from "src/settings/modals/popup"; -import { - ModalRegexFilePathName, - ModalRegexOnContents, - OverrideAttachmentsModal, -} from "src/settings/modals/regex_edition"; +import { ModalRegexFilePathName, ModalRegexOnContents, OverrideAttachmentsModal } from "src/settings/modals/regex_edition"; import { TokenEditPath } from "src/settings/modals/token_path"; -import { - autoCleanCondition, - folderHideShowSettings, - showHideBasedOnFolder, -} from "src/settings/style"; -import { - checkRepositoryValidity, - verifyRateLimitAPI, -} from "src/utils/data_validation_test"; +import { autoCleanCondition, folderHideShowSettings, showHideBasedOnFolder } from "src/settings/style"; +import { checkRepositoryValidity, verifyRateLimitAPI } from "src/utils/data_validation_test"; export class GithubPublisherSettingsTab extends PluginSettingTab { plugin: GithubPublisherPlugin; @@ -112,13 +84,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .onClick(async () => { const octokit = await this.plugin.reloadOctokit(); const presetLists = await loadAllPresets(octokit.octokit, this.plugin); - new ImportLoadPreset( - this.app, - this.plugin, - presetLists, - octokit.octokit, - this - ).open(); + new ImportLoadPreset(this.app, this.plugin, presetLists, octokit.octokit, this).open(); }); }); const tabBar = containerEl.createEl("nav", { @@ -195,14 +161,8 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setDesc(i18next.t("settings.github.apiType.desc")) .addDropdown((dropdown) => { dropdown - .addOption( - GithubTiersVersion.Free, - i18next.t("settings.github.apiType.dropdown.free") - ) - .addOption( - GithubTiersVersion.Entreprise, - i18next.t("settings.github.apiType.dropdown.enterprise") - ) + .addOption(GithubTiersVersion.Free, i18next.t("settings.github.apiType.dropdown.free")) + .addOption(GithubTiersVersion.Entreprise, i18next.t("settings.github.apiType.dropdown.enterprise")) .setValue(githubSettings.api.tiersForApi) .onChange(async (value) => { githubSettings.api.tiersForApi = value as GithubTiersVersion; @@ -300,14 +260,12 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { }) ); - new Setting(this.settingsPage) - .setName(i18next.t("settings.github.automaticallyMergePR")) - .addToggle((toggle) => - toggle.setValue(githubSettings.automaticallyMergePR).onChange(async (value) => { - githubSettings.automaticallyMergePR = value; - await this.plugin.saveSettings(); - }) - ); + new Setting(this.settingsPage).setName(i18next.t("settings.github.automaticallyMergePR")).addToggle((toggle) => + toggle.setValue(githubSettings.automaticallyMergePR).onChange(async (value) => { + githubSettings.automaticallyMergePR = value; + await this.plugin.saveSettings(); + }) + ); new Setting(this.settingsPage) .setName(i18next.t("settings.github.dryRun.enable.title")) .setDesc(i18next.t("settings.github.dryRun.enable.desc")) @@ -340,38 +298,20 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setClass("connect-button") .onClick(async () => { const octokit = await this.plugin.reloadOctokit(); - this.settings.github.verifiedRepo = await checkRepositoryValidity( - octokit, - null, - null - ); - this.settings.github.rateLimit = await verifyRateLimitAPI( - octokit.octokit, - this.settings - ); + this.settings.github.verifiedRepo = await checkRepositoryValidity(octokit, null, null); + this.settings.github.rateLimit = await verifyRateLimitAPI(octokit.octokit, this.settings); await this.plugin.saveSettings(); }) ) .addButton((button) => - button - .setButtonText(i18next.t("settings.github.smartRepo.button")) - .onClick(async () => { - const repository: Repository[] = this.copy( - this.settings.github?.otherRepo ?? [] - ); - new ModalAddingNewRepository( - this.app, - this.settings, - this.branchName, - this.plugin, - repository, - async (result) => { - this.settings.github.otherRepo = result; - await this.plugin.saveSettings(); - this.plugin.reloadCommands(); - } - ).open(); - }) + button.setButtonText(i18next.t("settings.github.smartRepo.button")).onClick(async () => { + const repository: Repository[] = this.copy(this.settings.github?.otherRepo ?? []); + new ModalAddingNewRepository(this.app, this.settings, this.branchName, this.plugin, repository, async (result) => { + this.settings.github.otherRepo = result; + await this.plugin.saveSettings(); + this.plugin.reloadCommands(); + }).open(); + }) ); this.settingsPage.createEl("h3", { text: "GitHub Workflow" }); new Setting(this.settingsPage) @@ -430,13 +370,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setValue(uploadSettings.behavior) .onChange(async (value: string) => { uploadSettings.behavior = value as FolderSettings; - await folderHideShowSettings( - frontmatterKeySettings, - rootFolderSettings, - autoCleanSetting, - value, - this.plugin - ); + await folderHideShowSettings(frontmatterKeySettings, rootFolderSettings, autoCleanSetting, value, this.plugin); await this.plugin.saveSettings(); this.renderSettingsPage(EnumbSettingsTabId.Upload); }); @@ -462,13 +396,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setValue(uploadSettings.defaultName) .onChange(async (value) => { uploadSettings.defaultName = value.replace(/\/$/, ""); - await autoCleanCondition( - value, - autoCleanSetting, - this.plugin, - "defaultName", - this - ); + await autoCleanCondition(value, autoCleanSetting, this.plugin, "defaultName", this); await this.plugin.saveSettings(); }); }); @@ -494,13 +422,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setValue(uploadSettings.rootFolder) .onChange(async (value) => { uploadSettings.rootFolder = value.replace(/\/$/, ""); - await autoCleanCondition( - value, - autoCleanSetting, - this.plugin, - "rootFolder", - this - ); + await autoCleanCondition(value, autoCleanSetting, this.plugin, "rootFolder", this); await this.plugin.saveSettings(); }); }); @@ -509,13 +431,11 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setDesc(i18next.t("settings.upload.useFrontmatterTitle.desc")) .setClass("title") .addToggle((toggle) => { - toggle - .setValue(uploadSettings.frontmatterTitle.enable) - .onChange(async (value) => { - uploadSettings.frontmatterTitle.enable = value; - await this.plugin.saveSettings(); - this.renderSettingsPage(EnumbSettingsTabId.Upload); - }); + toggle.setValue(uploadSettings.frontmatterTitle.enable).onChange(async (value) => { + uploadSettings.frontmatterTitle.enable = value; + await this.plugin.saveSettings(); + this.renderSettingsPage(EnumbSettingsTabId.Upload); + }); }); if (uploadSettings.frontmatterTitle.enable) { frontmatterTitleSet.addText((text) => { @@ -543,20 +463,15 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { if (uploadSettings.behavior !== FolderSettings.Fixed) { allRegex = allRegex.concat(uploadSettings.replacePath); } - new ModalRegexFilePathName( - this.app, - this.settings, - this.copy(allRegex), - async (result) => { - uploadSettings.replacePath = result.filter((title) => { - return title.type === "path"; - }); - uploadSettings.replaceTitle = result.filter((title) => { - return title.type === "title"; - }); - await this.plugin.saveSettings(); - } - ).open(); + new ModalRegexFilePathName(this.app, this.settings, this.copy(allRegex), async (result) => { + uploadSettings.replacePath = result.filter((title) => { + return title.type === "path"; + }); + uploadSettings.replaceTitle = result.filter((title) => { + return title.type === "title"; + }); + await this.plugin.saveSettings(); + }).open(); }); }); @@ -581,38 +496,27 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }); }); - new Setting(this.settingsPage) - .setName(i18next.t("settings.upload.folderNote.addTitle.title")) - .addToggle((toggle) => { - toggle - .setValue(uploadSettings.folderNote.addTitle.enable) + new Setting(this.settingsPage).setName(i18next.t("settings.upload.folderNote.addTitle.title")).addToggle((toggle) => { + toggle.setValue(uploadSettings.folderNote.addTitle.enable).onChange(async (value) => { + uploadSettings.folderNote.addTitle.enable = value; + await this.plugin.saveSettings(); + this.renderSettingsPage(EnumbSettingsTabId.Upload); + }); + }); + if (uploadSettings.folderNote.addTitle.enable) { + new Setting(this.settingsPage).setName(i18next.t("settings.upload.folderNote.addTitle.key")).addText((text) => { + text + .setPlaceholder("title") + .setValue(uploadSettings.folderNote.addTitle.key) .onChange(async (value) => { - uploadSettings.folderNote.addTitle.enable = value; + uploadSettings.folderNote.addTitle.key = value; await this.plugin.saveSettings(); - this.renderSettingsPage(EnumbSettingsTabId.Upload); }); }); - if (uploadSettings.folderNote.addTitle.enable) { - new Setting(this.settingsPage) - .setName(i18next.t("settings.upload.folderNote.addTitle.key")) - .addText((text) => { - text - .setPlaceholder("title") - .setValue(uploadSettings.folderNote.addTitle.key) - .onChange(async (value) => { - uploadSettings.folderNote.addTitle.key = value; - await this.plugin.saveSettings(); - }); - }); } } - showHideBasedOnFolder( - this.settings, - frontmatterKeySettings, - rootFolderSettings, - folderNoteSettings - ); + showHideBasedOnFolder(this.settings, frontmatterKeySettings, rootFolderSettings, folderNoteSettings); if (this.app.plugins.getPlugin("metadata-extractor")) { new Setting(this.settingsPage) @@ -636,8 +540,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { toggle.setValue(uploadSettings.autoclean.enable).onChange(async (value) => { if ( value && - ((this.settings.upload.behavior === "yaml" && - this.settings.upload.defaultName.length === 0) || + ((this.settings.upload.behavior === "yaml" && this.settings.upload.defaultName.length === 0) || this.settings.upload.rootFolder.length === 0) ) new AutoCleanPopup(this.app, this.settings, (result) => { @@ -672,22 +575,14 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setName(i18next.t("settings.githubWorkflow.includeAttachments.title")) .setDesc(i18next.t("settings.githubWorkflow.includeAttachments.desc")) .addToggle((toggle) => { - toggle - .setValue(uploadSettings.autoclean.includeAttachments) - .onChange(async (value) => { - uploadSettings.autoclean.includeAttachments = value; - await this.plugin.saveSettings(); - }); + toggle.setValue(uploadSettings.autoclean.includeAttachments).onChange(async (value) => { + uploadSettings.autoclean.includeAttachments = value; + await this.plugin.saveSettings(); + }); }); } - folderHideShowSettings( - frontmatterKeySettings, - rootFolderSettings, - autoCleanSetting, - uploadSettings.behavior, - this.plugin - ); + folderHideShowSettings(frontmatterKeySettings, rootFolderSettings, autoCleanSetting, uploadSettings.behavior, this.plugin); } /** @@ -706,9 +601,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { text: i18next.t("settings.conversion.links.desc"), }); - const shareAll = this.settings.plugin.shareAll?.enable - ? ` ${i18next.t("settings.conversion.links.internals.shareAll")}` - : ""; + const shareAll = this.settings.plugin.shareAll?.enable ? ` ${i18next.t("settings.conversion.links.internals.shareAll")}` : ""; const internalLinksDesc = document.createDocumentFragment(); internalLinksDesc.createEl("p", { text: i18next.t("settings.conversion.links.internals.desc") + shareAll, @@ -756,11 +649,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { }); }); const slugifySetting = - typeof textSettings.links.slugify == "boolean" - ? textSettings.links.slugify - ? "strict" - : "disable" - : textSettings.links.slugify; + typeof textSettings.links.slugify == "boolean" ? (textSettings.links.slugify ? "strict" : "disable") : textSettings.links.slugify; if (textSettings.links.wiki || textSettings.links.internal) { new Setting(this.settingsPage) .setName(i18next.t("settings.conversion.links.slugify.title")) @@ -774,9 +663,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { }) .setValue(slugifySetting) .onChange(async (value) => { - textSettings.links.slugify = ["disable", "strict", "lower"].includes(value) - ? (value as "disable" | "strict" | "lower") - : "disable"; + textSettings.links.slugify = ["disable", "strict", "lower"].includes(value) ? (value as "disable" | "strict" | "lower") : "disable"; await this.plugin.saveSettings(); }); }); @@ -800,9 +687,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setDesc(i18next.t("settings.conversion.dataview.desc")) .addToggle((toggle) => { toggle - .setValue( - textSettings.dataview && isDataviewEnabled && textSettings.links.internal - ) + .setValue(textSettings.dataview && isDataviewEnabled && textSettings.links.internal) .setDisabled(!isDataviewEnabled || !textSettings.links.internal) .onChange(async (value) => { textSettings.dataview = value; @@ -887,28 +772,24 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { cls: "center", }); - new Setting(this.settingsPage) - .setName(i18next.t("settings.embed.transferImage.title")) - .addToggle((toggle) => { - toggle.setValue(embedSettings.attachments).onChange(async (value) => { - embedSettings.attachments = value; - await this.plugin.saveSettings(); - this.renderSettingsPage(EnumbSettingsTabId.Embed); - }); + new Setting(this.settingsPage).setName(i18next.t("settings.embed.transferImage.title")).addToggle((toggle) => { + toggle.setValue(embedSettings.attachments).onChange(async (value) => { + embedSettings.attachments = value; + await this.plugin.saveSettings(); + this.renderSettingsPage(EnumbSettingsTabId.Embed); }); + }); if (embedSettings.attachments) { new Setting(this.settingsPage) .setName(i18next.t("settings.embed.imagePath.title")) .setDesc(i18next.t("settings.embed.imagePath.desc")) .addToggle((toggle) => { - toggle - .setValue(embedSettings.useObsidianFolder ?? false) - .onChange(async (value) => { - embedSettings.useObsidianFolder = value; - await this.plugin.saveSettings(); - this.renderSettingsPage(EnumbSettingsTabId.Embed); - }); + toggle.setValue(embedSettings.useObsidianFolder ?? false).onChange(async (value) => { + embedSettings.useObsidianFolder = value; + await this.plugin.saveSettings(); + this.renderSettingsPage(EnumbSettingsTabId.Embed); + }); }); if (!embedSettings.useObsidianFolder) { new Setting(this.settingsPage) @@ -930,15 +811,10 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setDesc(i18next.t("settings.embed.overrides.desc")) .addButton((button) => { button.setIcon("pencil").onClick(async () => { - new OverrideAttachmentsModal( - this.app, - this.settings, - this.copy(embedSettings.overrideAttachments), - async (result) => { - embedSettings.overrideAttachments = result; - await this.plugin.saveSettings(); - } - ).open(); + new OverrideAttachmentsModal(this.app, this.settings, this.copy(embedSettings.overrideAttachments), async (result) => { + embedSettings.overrideAttachments = result; + await this.plugin.saveSettings(); + }).open(); }); }); @@ -1003,11 +879,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .addOption("bake", i18next.t("settings.embed.links.dp.bake")) .setValue(embedSettings.convertEmbedToLinks ?? "keep") .onChange(async (value) => { - embedSettings.convertEmbedToLinks = value as - | "keep" - | "remove" - | "links" - | "bake"; + embedSettings.convertEmbedToLinks = value as "keep" | "remove" | "links" | "bake"; await this.plugin.saveSettings(); await this.renderEmbedConfiguration(); }); @@ -1065,25 +937,19 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { cls: ["warning", "embed"], }); - new Setting(this.settingsPage) - .setName(i18next.t("settings.embed.bake.textBefore.title")) - .addTextArea((text) => { - text - .setValue(embedSettings.bake?.textBefore ?? "") - .onChange(async (value) => { - embedSettings.bake!.textBefore = value; - await this.plugin.saveSettings(); - }); + new Setting(this.settingsPage).setName(i18next.t("settings.embed.bake.textBefore.title")).addTextArea((text) => { + text.setValue(embedSettings.bake?.textBefore ?? "").onChange(async (value) => { + embedSettings.bake!.textBefore = value; + await this.plugin.saveSettings(); }); + }); - new Setting(this.settingsPage) - .setName(i18next.t("settings.embed.bake.textAfter.title")) - .addTextArea((text) => { - text.setValue(embedSettings.bake?.textAfter ?? "").onChange(async (value) => { - embedSettings.bake!.textAfter = value; - await this.plugin.saveSettings(); - }); + new Setting(this.settingsPage).setName(i18next.t("settings.embed.bake.textAfter.title")).addTextArea((text) => { + text.setValue(embedSettings.bake?.textAfter ?? "").onChange(async (value) => { + embedSettings.bake!.textAfter = value; + await this.plugin.saveSettings(); }); + }); } } } @@ -1099,17 +965,15 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setName(i18next.t("settings.plugin.shareKey.all.title")) .setDesc(i18next.t("settings.plugin.shareKey.all.desc")) .addToggle((toggle) => - toggle - .setValue(pluginSettings.shareAll?.enable ?? false) - .onChange(async (value) => { - pluginSettings.shareAll = { - enable: value, - excludedFileName: pluginSettings.shareAll?.excludedFileName ?? "DRAFT", - }; - if (value) this.settings.conversion.links.internal = true; - await this.plugin.saveSettings(); - this.renderSettingsPage(EnumbSettingsTabId.Plugin); - }) + toggle.setValue(pluginSettings.shareAll?.enable ?? false).onChange(async (value) => { + pluginSettings.shareAll = { + enable: value, + excludedFileName: pluginSettings.shareAll?.excludedFileName ?? "DRAFT", + }; + if (value) this.settings.conversion.links.internal = true; + await this.plugin.saveSettings(); + this.renderSettingsPage(EnumbSettingsTabId.Plugin); + }) ); if (!pluginSettings.shareAll || !pluginSettings.shareAll.enable) { new Setting(this.settingsPage) @@ -1125,17 +989,15 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { }) ); } else { - new Setting(this.settingsPage) - .setName(i18next.t("settings.plugin.shareKey.excludedFileName.title")) - .addText((text) => - text - .setPlaceholder("DRAFT") - .setValue(pluginSettings.shareAll?.excludedFileName ?? "DRAFT") - .onChange(async (value) => { - pluginSettings.shareAll!.excludedFileName = value.trim(); - await this.plugin.saveSettings(); - }) - ); + new Setting(this.settingsPage).setName(i18next.t("settings.plugin.shareKey.excludedFileName.title")).addText((text) => + text + .setPlaceholder("DRAFT") + .setValue(pluginSettings.shareAll?.excludedFileName ?? "DRAFT") + .onChange(async (value) => { + pluginSettings.shareAll!.excludedFileName = value.trim(); + await this.plugin.saveSettings(); + }) + ); } new Setting(this.settingsPage) @@ -1235,34 +1097,25 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setName(i18next.t("settings.plugin.copyLink.toUri.title")) .setDesc(i18next.t("settings.plugin.copyLink.toUri.desc")) .addToggle((toggle) => - toggle - .setValue(pluginSettings.copyLink.transform.toUri) - .onChange(async (value) => { - pluginSettings.copyLink.transform.toUri = value; - await this.plugin.saveSettings(); - }) + toggle.setValue(pluginSettings.copyLink.transform.toUri).onChange(async (value) => { + pluginSettings.copyLink.transform.toUri = value; + await this.plugin.saveSettings(); + }) ); - new Setting(this.settingsPage) - .setName(i18next.t("settings.plugin.copyLink.slugify.title")) - .addDropdown((dropdown) => { - dropdown - .addOptions({ - disable: i18next.t("settings.plugin.copyLink.slugify.disable"), - strict: i18next.t("settings.plugin.copyLink.slugify.strict"), - lower: i18next.t("settings.plugin.copyLink.slugify.lower"), - }) - .setValue( - pluginSettings.copyLink.transform.slugify as "disable" | "strict" | "lower" - ) - .onChange(async (value) => { - pluginSettings.copyLink.transform.slugify = value as - | "disable" - | "strict" - | "lower"; - await this.plugin.saveSettings(); - }); - }); + new Setting(this.settingsPage).setName(i18next.t("settings.plugin.copyLink.slugify.title")).addDropdown((dropdown) => { + dropdown + .addOptions({ + disable: i18next.t("settings.plugin.copyLink.slugify.disable"), + strict: i18next.t("settings.plugin.copyLink.slugify.strict"), + lower: i18next.t("settings.plugin.copyLink.slugify.lower"), + }) + .setValue(pluginSettings.copyLink.transform.slugify as "disable" | "strict" | "lower") + .onChange(async (value) => { + pluginSettings.copyLink.transform.slugify = value as "disable" | "strict" | "lower"; + await this.plugin.saveSettings(); + }); + }); new Setting(this.settingsPage) .setName(i18next.t("settings.plugin.copyLink.applyRegex.title")) @@ -1307,24 +1160,19 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setClass("max-width") .addExtraButton((button) => { button.setIcon("trash").onClick(async () => { - pluginSettings.copyLink.transform.applyRegex = - pluginSettings.copyLink.transform.applyRegex.filter( - (item) => item !== apply - ); + pluginSettings.copyLink.transform.applyRegex = pluginSettings.copyLink.transform.applyRegex.filter((item) => item !== apply); await this.plugin.saveSettings(); this.renderSettingsPage(EnumbSettingsTabId.Plugin); }); }); } - new Setting(this.settingsPage) - .setName(i18next.t("settings.plugin.copyLink.command.desc")) - .addToggle((toggle) => - toggle.setValue(pluginSettings.copyLink.addCmd).onChange(async (value) => { - pluginSettings.copyLink.addCmd = value; - await this.plugin.saveSettings(); - }) - ); + new Setting(this.settingsPage).setName(i18next.t("settings.plugin.copyLink.command.desc")).addToggle((toggle) => + toggle.setValue(pluginSettings.copyLink.addCmd).onChange(async (value) => { + pluginSettings.copyLink.addCmd = value; + await this.plugin.saveSettings(); + }) + ); } this.settingsPage.createEl("h3", { text: i18next.t("settings.plugin.head.other") }); @@ -1333,12 +1181,10 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .setName(i18next.t("settings.plugin.embedEditRepo.title")) .setDesc(i18next.t("settings.plugin.embedEditRepo.desc")) .addToggle((toggle) => - toggle - .setValue(pluginSettings.displayModalRepoEditing) - .onChange(async (value) => { - pluginSettings.displayModalRepoEditing = value; - await this.plugin.saveSettings(); - }) + toggle.setValue(pluginSettings.displayModalRepoEditing).onChange(async (value) => { + pluginSettings.displayModalRepoEditing = value; + await this.plugin.saveSettings(); + }) ); new Setting(this.settingsPage) @@ -1347,9 +1193,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { .addToggle((toggle) => toggle.setValue(pluginSettings.saveTabId ?? true).onChange(async (value) => { pluginSettings.saveTabId = value; - this.settings.tabsId = value - ? EnumbSettingsTabId.Plugin - : EnumbSettingsTabId.Github; + this.settings.tabsId = value ? EnumbSettingsTabId.Plugin : EnumbSettingsTabId.Github; await this.plugin.saveSettings(); }) ); @@ -1381,35 +1225,22 @@ export class GithubPublisherSettingsTab extends PluginSettingTab { * Render the help page */ renderHelp() { - this.settingsPage.createEl("h2", { - text: i18next.t("settings.help.usefulLinks.title"), - }); + new Setting(this.settingsPage).setName(i18next.t("settings.help.usefulLinks.title")).setHeading(); this.settingsPage.appendChild(usefulLinks()); this.settingsPage.createEl("hr"); - this.settingsPage.createEl("h2", { - text: i18next.t("settings.help.frontmatter.title"), - }); - this.settingsPage.createEl("p", { - text: i18next.t("settings.help.frontmatter.desc"), - }); - this.settingsPage - .createEl("p", { - text: i18next.t("settings.help.frontmatter.nestedKey"), - }) - .createEl("code", { - text: "key.subkey: value", - }) - .createEl("span", { - text: ".", - }); + new Setting(this.settingsPage).setName(i18next.t("settings.help.frontmatter.title")).setHeading(); + const dom = sanitizeHTMLToDom(` +

${i18next.t("settings.help.frontmatter.desc")}

+

${i18next.t("settings.help.frontmatter.nestedKey")} key.subkey: value.

`); + this.settingsPage.appendChild(dom); this.settingsPage.createEl("pre", { cls: "language-yaml" }).createEl("code", { text: KeyBasedOnSettings(this.settings), cls: "language-yaml", }); this.settingsPage.appendChild(help(this.settings)); - this.settingsPage.createEl("h2", { - text: i18next.t("settings.help.multiRepoHelp.title"), - }); + + this.settingsPage.createEl("hr"); + new Setting(this.settingsPage).setName(i18next.t("settings.help.multiRepoHelp.title")).setHeading(); this.settingsPage.appendChild(multipleRepoExplained(this.settings)); this.settingsPage.appendChild(supportMe()); } diff --git a/src/settings/help.ts b/src/settings/help.ts index a7d0a5ef..4a96f061 100644 --- a/src/settings/help.ts +++ b/src/settings/help.ts @@ -1,419 +1,157 @@ import { FolderSettings, type GitHubPublisherSettings } from "@interfaces"; +import dedent from "dedent"; import i18next from "i18next"; -import { normalizePath } from "obsidian"; +import { normalizePath, sanitizeHTMLToDom } from "obsidian"; import { regexOnPath } from "src/conversion/file_path"; - -function spanAtRule( - text: string, - code: DocumentFragment, - br: boolean = true -): HTMLElement { - if (br) code.createEl("br"); - return code.createEl("span", { text, cls: ["token", "key", "atrule"] }); -} - -function spanBoolean(text: boolean, code: DocumentFragment): HTMLElement { - const textToString = text ? "true" : "false"; - return code.createEl("span", { - text: textToString, - cls: ["token", "boolean", "important"], - }); -} - -function spanComment(text: string, code: DocumentFragment): HTMLElement { - return code.createEl("span", { text, cls: ["token", "comment"] }); -} - -function spanString(text: string, code: DocumentFragment): HTMLElement { - return code.createEl("span", { text, cls: ["token", "string"] }); -} - -function spanCategory(settings: GitHubPublisherSettings, code: DocumentFragment) { - if (settings.upload.behavior === FolderSettings.Yaml) { - const defaultPath = - settings.upload.defaultName.length > 0 ? `${settings.upload.defaultName}` : "/"; - return { - rule: spanAtRule( - settings.upload.yamlFolderKey.length > 0 - ? `${settings.upload.yamlFolderKey}: ` - : "category: ", - code - ), - token: spanString(normalizePath(defaultPath), code), - }; - } -} +import { DISCORD_ICON, DISCUSSION_ICON, DOCUMENTATION, GITHUB_ICON, ISSUE, TRANSLATION_ICON } from "../interfaces/icons"; /** * Export the YAML help to create an example of yaml with the value based on the Settings - */ + * YAML: + * ```yaml + * share: true + * path: file.md #given as an example path + * links: + * mdlinks: true + * convert: true + * internals: true + * nonShared: true + * embed: + * send: true + * remove: keep + * char: -> + * attachment: + * send: true + * folder: docs/images + * dataview: true + * hardBreak: false + * includeLinks: true + * shortRepo: test1 + * repo: + * owner: sandboxingRepo + * repo: obsidian-sandbox + * branch: main + * autoclean: true + * copylink: + * base: https://obsidian-sandbox.github.io/obsidian-sandbox +``` +*/ export function KeyBasedOnSettings(settings: GitHubPublisherSettings): DocumentFragment { - const code = document.createDocumentFragment(); - const defaultPath = - settings.upload.defaultName.length > 0 ? `${settings.upload.defaultName}` : "/"; - let path = - settings.upload.behavior === FolderSettings.Yaml - ? `${ - settings.upload.rootFolder.length > 0 ? settings.upload.rootFolder : "" - }/${defaultPath}/file.md` - : `${defaultPath}/file.md`; + const defaultPath = settings.upload.defaultName.length > 0 ? `${settings.upload.defaultName}` : "/"; + let path = settings.upload.behavior === FolderSettings.Yaml ? `${settings.upload.rootFolder.length > 0 ? settings.upload.rootFolder : ""}/${defaultPath}/file.md` : `${defaultPath}/file.md`; path = normalizePath(regexOnPath(path, settings)); - - spanAtRule(`${settings.plugin.shareKey}: `, code, false); - spanBoolean(true, code); - spanCategory(settings, code); - spanAtRule("path: ", code); - spanString(path, code); - spanComment(" #given as an example path", code); - spanAtRule("links: ", code); - spanAtRule(" mdlinks: ", code); - spanBoolean(settings.conversion.links.wiki, code); - spanAtRule(" convert: ", code); - spanBoolean(true, code); - spanAtRule(" internals: ", code); - spanBoolean(settings.conversion.links.internal, code); - spanAtRule(" nonShared: ", code); - spanBoolean(settings.conversion.links.unshared, code); - spanAtRule("embed: ", code); - spanAtRule(" send: ", code); - spanBoolean(settings.embed.notes, code); - spanAtRule(" remove: ", code); - spanString(settings.embed.convertEmbedToLinks, code); - spanAtRule(" char: ", code); - spanString(settings.embed.charConvert, code); - spanAtRule("attachment: ", code); - spanAtRule(" send: ", code); - spanBoolean(settings.embed.attachments, code); - spanAtRule(" folder: ", code); - spanString(settings.embed.folder, code); - spanAtRule("dataview: ", code); - spanBoolean(settings.conversion.dataview, code); - spanAtRule("hardBreak: ", code); - spanBoolean(settings.conversion.hardbreak, code); - spanAtRule("includeLinks: ", code); - spanBoolean(settings.embed.sendSimpleLinks, code); + const rules = "token key atrule"; + const comments = "token comment"; + const str = "token string"; + const boolean = "token boolean important"; + const category = () => { + if (settings.upload.behavior === FolderSettings.Yaml) { + const defaultPath = settings.upload.defaultName.length > 0 ? `${settings.upload.defaultName}` : "/"; + return dedent(` +
${settings.upload.yamlFolderKey.length > 0 ? `${settings.upload.yamlFolderKey}: ` : "category: "}${normalizePath(defaultPath)} + `); + } + return ""; + }; + let html = dedent(`${settings.plugin.shareKey}: true${category()} + path: file.md # given as an example path + links: + mdlinks: ${settings.conversion.links.wiki} + convert: true + internals: ${settings.conversion.links.internal} + nonShared: ${settings.conversion.links.unshared} + embed: + send: ${settings.embed.notes} + remove: ${settings.embed.convertEmbedToLinks} + char: ${settings.embed.charConvert} + attachment: + send: ${settings.embed.attachments} + folder: ${settings.embed.folder} + dataview: ${settings.conversion.dataview} + hardBreak: ${settings.conversion.hardbreak} + includeLinks: ${settings.embed.sendSimpleLinks} + `); if (settings.github.otherRepo.length > 0) { - spanAtRule("shortRepo: ", code); - spanString( - settings.github.otherRepo[0].smartKey.length > 0 - ? settings.github.otherRepo[0].smartKey - : "smartkey", - code - ); + const smartkey = settings.github.otherRepo[0].smartKey.length > 0 ? settings.github.otherRepo[0].smartKey : "smartkey"; + html += dedent(`
shortRepo: ${smartkey}`); } - spanAtRule("repo: ", code); - spanAtRule(" owner: ", code); - spanString(settings.github.user, code); - spanAtRule(" repo: ", code); - spanString(settings.github.repo, code); - spanAtRule(" branch: ", code); - spanString(settings.github.branch, code); - spanAtRule(" autoclean: ", code); - spanBoolean(settings.upload.autoclean.enable, code); - spanAtRule("copylink: ", code); - spanAtRule(" base: ", code); - spanString( - settings.plugin.copyLink.links.length > 0 - ? settings.plugin.copyLink.links - : `https://${settings.github.repo}.github.io/${settings.github.repo}`, - code - ); - const removePart = settings.plugin.copyLink.removePart - .map((val) => `"${val}"`) - .join(", "); + html += dedent(`
repo: + owner: ${settings.github.user} + repo: ${settings.github.repo} + branch: ${settings.github.branch} + autoclean: ${settings.upload.autoclean.enable} + copylink: + base: ${settings.plugin.copyLink.links.length > 0 ? settings.plugin.copyLink.links : `https://${settings.github.repo}.github.io/${settings.github.repo}`} + `); + const removePart = settings.plugin.copyLink.removePart.map((val) => `"${val}"`).join(", "); if (removePart.length > 0) { - spanAtRule(" remove: ", code); - spanString(removePart, code); + html += dedent(` remove: ${removePart}`); } - return code; + html += "
"; + return sanitizeHTMLToDom(html); } /** * Create the contents of the help settings tab */ export function help(settings: GitHubPublisherSettings) { - const explanation = document.createDocumentFragment(); - explanation.createEl("ul", undefined, (span) => { - span.createEl("li", undefined, (span) => { - span.createEl("code", { - text: `${settings.plugin.shareKey}${i18next.t("common.points")}`, - cls: "code-title", - }); - span.createEl("span", { - text: `${i18next.t("settings.help.frontmatter.share.title")}`, - }); - span.createEl("ul", undefined, (l) => { - l.createEl("span", { text: i18next.t("settings.help.frontmatter.share.other") }); - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { - text: `path${i18next.t("common.points")}`, - cls: "code-title", - }); - span.createEl("span", { - text: ` ${i18next.t("settings.help.frontmatter.path")}`, - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { - text: `links${i18next.t("common.points")}`, - cls: "code-title", - }); - }); - span.createEl("ul", undefined, (l) => { - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "mdlinks" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.mdlinks" - )}`, - }); - p.createEl("code", { - text: " [[markdown|alias]] ", - }); - p.createEl("span", { text: i18next.t("common.in") }); - p.createEl("code", { text: " [alias](markdown) " }); - }); - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "convert" }); - p.createEl("span", undefined, (span) => { - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.convert.enableOrDisable" - )} `, - }); - span.createEl("code", { text: " [[link]] " }); - span.createEl("span", { - text: i18next.t("common.or"), - }); - span.createEl("code", { text: " [](link) " }); - span.createEl("span", { - text: i18next.t("settings.help.frontmatter.convert.syntax"), - }); - }); - }); - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "internals" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.internals" - )}`, - }); - }); - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "nonShared" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.nonShared" - )}`, - }); - }); - }); - span.createEl("li", { - text: `embed${i18next.t("common.points")}`, - cls: "code code-title", - }); - span.createEl("ul", undefined, (l) => { - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "send" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.send" - )}`, - }); - }); - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "remove" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.remove.desc" - )}`, - }); - p.createEl("ul", undefined, (ul) => { - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "remove | true" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.remove.remove" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "keep | false" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.remove.keep" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "links" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.remove.links" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "bake" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.remove.bake" - )}`, - }); - }); - }); - }); - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "char" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.embed.char" - )}`, - }); - }); - }); - span.createEl("li", { - text: `attachment${i18next.t("common.points")}`, - cls: "code code-title", - }); - span.createEl("ul", undefined, (l) => { - l.createEl("li", undefined, (span) => { - span.createEl("code", { text: "send" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.attachment.send" - )}`, - }); - }); - l.createEl("li", undefined, (p) => { - p.createEl("code", { text: "folder" }); - p.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.attachment.folder" - )}`, - }); - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { text: "dataview", cls: "code-title" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.dataview" - )}`, - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { text: "hardbreak", cls: "code-title" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.hardBreak" - )}`, - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { text: "includeLinks", cls: "code-title" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.includeLinks" - )}`, - }); - span.createEl("code", { text: "[[markdown]]", cls: "code-title" }); - span.createEl("span", { text: i18next.t("common.or") }); - span.createEl("code", { text: "[](markdown)", cls: "code-title" }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { text: "shortRepo", cls: "code-title" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.shortRepo" - )}`, - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { text: "repo", cls: "code-title" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.repo.desc" - )}`, - }); - span.createEl("ul", undefined, (ul) => { - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "owner" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.repo.owner" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "repo" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.github.repoName.title" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "branch" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.repo.branch" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "autoclean" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.autoclean" - )}`, - }); - }); - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { - text: `${settings.upload.frontmatterTitle.key}`, - cls: "code-title", - }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.titleKey" - )}`, - }); - }); - span.createEl("li", undefined, (span) => { - span.createEl("code", { text: "baseLink", cls: "code-title" }); - span.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.baselink.desc" - )}`, - }); - span.createEl("code", { text: "copylink:", cls: "code-title" }); - span.createEl("ul", undefined, (ul) => { - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "base" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.plugin.copyLink.baselink.title" - )}`, - }); - }); - ul.createEl("li", undefined, (li) => { - li.createEl("code", { text: "remove" }); - li.createEl("span", { - text: `${i18next.t("common.points")}${i18next.t( - "settings.help.frontmatter.baselink.remove" - )}`, - }); - }); - }); - }); - }); - return explanation; + const els = dedent(` +
    +
  • ${settings.plugin.shareKey}${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.share.title")} +
      ${i18next.t("settings.help.frontmatter.share.other")}
    +
  • path${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.path")}
  • +
  • links${i18next.t("common.points")} +
      +
    • mdlinks${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.mdlinks")} [[markdown|alias]]${i18next.t("common.in")} [alias](markdown)
    • +
    • convert${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.convert.enableOrDisable")} [[link]]${i18next.t("common.or")} [](link)${i18next.t("settings.help.frontmatter.convert.syntax")}
    • +
    • internals${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.internals")}
    • +
    • nonShared${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.nonShared")}
    • +
    +
  • +
  • embed${i18next.t("common.points")} +
      +
    • send${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.send")}
    • +
    • remove${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.remove.desc")} +
        +
      • remove | true${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.remove.remove")}
      • +
      • keep | false${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.remove.keep")}
      • +
      • links${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.remove.links")}
      • +
      • bake${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.remove.bake")}
      • +
      +
    • +
    • char${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.embed.char")}
    • +
    +
  • +
  • attachment${i18next.t("common.points")} +
      +
    • send${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.attachment.send")}
    • +
    • folder${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.attachment.folder")}
    • +
    +
  • +
  • dataview${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.dataview")}
  • +
  • hardbreak${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.hardBreak")}
  • +
  • includeLinks${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.includeLinks")} [[markdown]] ${i18next.t("common.or")} [](markdown)
  • +
  • shortRepo${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.shortRepo")}
  • +
  • repo${i18next.t("common.points")} +
      +
    • owner${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.repo.owner")}
    • +
    • repo${i18next.t("common.points")}${i18next.t("settings.github.repoName.title")}
    • +
    • branch${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.repo.branch")}
    • +
    • autoclean${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.autoclean")}
    • +
    +
  • +
  • ${settings.upload.frontmatterTitle.key}${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.titleKey")}
  • +
  • baseLink${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.baselink.desc")} + copylink: +
      +
    • base${i18next.t("common.points")}${i18next.t("settings.plugin.copyLink.baselink.title")}
    • +
    • remove${i18next.t("common.points")}${i18next.t("settings.help.frontmatter.baselink.remove")}
    • +
    +
  • +
+ `); + return sanitizeHTMLToDom(els); } /** @@ -421,105 +159,68 @@ export function help(settings: GitHubPublisherSettings) { * @return {DocumentFragment} */ export function usefulLinks(): DocumentFragment { - const usefulLinks = document.createDocumentFragment(); - usefulLinks.createEl("ul", undefined, (el) => { - el.createEl("li", undefined, (el) => { - el.createEl("a", { - text: i18next.t("settings.help.usefulLinks.documentation"), - href: i18next.t("settings.help.usefulLinks.links"), - }); - }); - el.createEl("li", undefined, (el) => { - el.createEl("a", { - text: i18next.t("common.repository"), - href: "https://github.com/ObsidianPublisher/obsidian-github-publisher", - }); - }); - el.createEl("li", undefined, (el) => { - el.createEl("a", { - text: i18next.t("settings.help.usefulLinks.issue"), - href: "https://github.com/ObsidianPublisher/obsidian-github-publisher/issues", - }); - }); - el.createEl("li", undefined, (el) => { - el.createEl("a", { - text: i18next.t("settings.help.usefulLinks.discussion"), - href: "https://github.com/ObsidianPublisher/obsidian-github-publisher/discussions", - }); - }); - }); - return usefulLinks; + const els = dedent(` + + `); + return sanitizeHTMLToDom(els); } /** * Create the explanation of multiple repo for the help tab + * ```yaml + * multipleRepo: + * - owner: sandboxingRepo + * repo: obsidian-sandbox + * branch: main + * autoclean: false + * - owner: sandboxingRepo + * repo: my_second_blog + * branch: master + * autoclean: false + * ``` * @param {GitHubPublisherSettings} settings * @return {DocumentFragment} */ -export function multipleRepoExplained( - settings: GitHubPublisherSettings -): DocumentFragment { - const multipleRepoExplained = document.createDocumentFragment(); - multipleRepoExplained.createEl("p", undefined, (el) => { - el.createEl("span", { - text: i18next.t("settings.help.multiRepoHelp.desc"), - }); - el.createEl("code", { text: "multipleRepo" }); - el.createEl("span", { - text: ` ${i18next.t("settings.help.multiRepoHelp.desc2")}`, - }); - el.createEl("ul", undefined, (el) => { - el.createEl("li", { text: "owner" }).addClass("code"); - el.createEl("li", { text: "repo" }).addClass("code"); - el.createEl("li", { text: "branch" }).addClass("code"); - el.createEl("li", { text: "autoclean" }).addClass("code"); - }); - el.createEl("span", { - text: i18next.t("settings.help.multiRepoHelp.exampleDesc"), - }); - }); - const code = document.createDocumentFragment(); - spanAtRule("multipleRepo: ", code, false); - spanAtRule(" - owner: ", code); - spanString(settings.github.user, code); - spanAtRule(" repo: ", code); - spanString(settings.github.repo, code); - spanAtRule(" branch: ", code); - spanString(settings.github.branch, code); - spanAtRule(" autoclean: ", code); - spanBoolean(false, code); - spanAtRule(" - owner: ", code); - spanString(settings.github.user, code); - spanAtRule(" repo: ", code); - spanString("my_second_blog", code); - spanAtRule(" branch: ", code); - spanString("master", code); - spanAtRule(" autoclean: ", code); - spanBoolean(false, code); - multipleRepoExplained - .createEl("pre", { cls: "language-yaml" }) - .createEl("code", { text: code, cls: "language-yaml" }); - - return multipleRepoExplained; +export function multipleRepoExplained(settings: GitHubPublisherSettings): DocumentFragment { + const rules = "token key atrule"; + const comments = "token comment"; + const str = "token string"; + const yaml = dedent(`
multipleRepo:
+	   - owner: ${settings.github.user}
+	     repo: ${settings.github.repo}
+	     branch: ${settings.github.branch}
+	     autoclean: false
+	   - owner: sandboxingRepo
+	     repo: my_second_blog
+	     branch: master
+	     autoclean: false
+	
`); + const paragraph = dedent(` + ${i18next.t("settings.help.multiRepoHelp.desc")} multipleRepo ${i18next.t("settings.help.multiRepoHelp.desc2")}
    +
  • owner
  • +
  • repo
  • +
  • branch
  • +
  • autoclean
  • +
${i18next.t("settings.help.multiRepoHelp.exampleDesc")}
+ `); + return sanitizeHTMLToDom(paragraph + yaml); } /** * Add the link for kofi in the help tab + * Buy Me A Coffee * @return {DocumentFragment} */ export function supportMe(): DocumentFragment { - const supportMe = document.createDocumentFragment(); - supportMe.createEl("p", undefined, (el) => { - el.createEl("a", undefined, (el) => { - el.createEl("img", undefined, (img) => { - img.setAttr("src", "https://storage.ko-fi.com/cdn/kofi2.png?v=3"); - img.setAttr("alt", "Buy Me A Coffee"); - img.setAttr("style", "height: 60px !important;width: 217px !important;"); - }); - el.setAttr("href", "https://ko-fi.com/lisandra_dev"); - }); - el.setAttr("style", "text-align: center;"); - }); - return supportMe; + const supportMe = dedent(`

Buy Me A Coffee

+ `); + return sanitizeHTMLToDom(supportMe); } diff --git a/src/styles.css b/src/styles.css index e67f3013..330e4034 100644 --- a/src/styles.css +++ b/src/styles.css @@ -296,7 +296,7 @@ span.obsidian-publisher.icons { } .github-publisher.list-changed .settings-tab-page code.code-title, -.code.code-title { +.settings-tab-page code.code-title { font-size: calc(var(--code-size) * 12px); font-weight: bolder; text-decoration: underline;