diff --git a/src/embed-widget.ts b/src/embed-widget.ts index dc2a86b..e5a6688 100644 --- a/src/embed-widget.ts +++ b/src/embed-widget.ts @@ -24,6 +24,7 @@ export class EmbedWidget extends WidgetType { ( this.embedData.width === other.embedData.width && this.embedData.height === other.embedData.height - ); + ) && + this.alt === other.alt; } } diff --git a/src/embeds/defaultFallbackEmbed.ts b/src/embeds/defaultFallbackEmbed.ts index 31b6cc6..37422bc 100644 --- a/src/embeds/defaultFallbackEmbed.ts +++ b/src/embeds/defaultFallbackEmbed.ts @@ -39,8 +39,9 @@ export class DefaultFallbackEmbed extends EmbedBase { embedContainer.appendChild(iframe); - if (this.plugin.settings.fallbackAddLink) { - const link = createEl("a", {href: iframe.src, text: embedOptions.alt}); + if (this.plugin.settings.fallbackDefaultLink || embedOptions.alt) { + const linkText = embedOptions.alt ? embedOptions.alt : this.plugin.settings.fallbackDefaultLink; + const link = createEl("a", {href: iframe.src, text: linkText.trim()}); embedContainer.appendChild(link); } diff --git a/src/settings-tab.ts b/src/settings-tab.ts index 5efc2bd..a26fbe1 100644 --- a/src/settings-tab.ts +++ b/src/settings-tab.ts @@ -28,7 +28,7 @@ export interface PluginSettings { fallbackOptions: FallbackOptions; fallbackWidth: string; fallbackHeight: string; - fallbackAddLink: boolean; + fallbackDefaultLink: string; // Advanced settings showAdvancedSettings: boolean; @@ -42,10 +42,10 @@ export const DEFAULT_SETTINGS: PluginSettings = { googleDocsViewOption: GoogleDocsViewOptions.Preview, - fallbackOptions: FallbackOptions.ShowErrorMessage, + fallbackOptions: FallbackOptions.EmbedLink, fallbackWidth: "100%", fallbackHeight: "500px", - fallbackAddLink: true, + fallbackDefaultLink: "Link", showAdvancedSettings: false, debug: false, @@ -135,7 +135,7 @@ export class AutoEmbedSettingTab extends PluginSettingTab { new Setting(containerEl) .setName("Google Docs") .setHeading() - .setDesc("Note that when the view options is editable, the default page width is too small. Try to use \"Preview\" where possible"); + .setDesc("Note that when the view options is set to editable, the default page width is too small. Try to use \"Preview\" where possible"); const googleDocsViewOptionDesc = new DocumentFragment(); googleDocsViewOptionDesc.appendText("Preview - Uneditable, only embed the content"); @@ -192,6 +192,7 @@ export class AutoEmbedSettingTab extends PluginSettingTab { fallbackSettings.push(new Setting(containerEl) .setName("Default height") + .setDesc("Default is 500px. Set to 100vh if u want it to be the height of the viewport") .addText(text => text .setValue(settings.fallbackHeight) .setPlaceholder("500px") @@ -202,12 +203,13 @@ export class AutoEmbedSettingTab extends PluginSettingTab { )) fallbackAddLinkSetting = new Setting(containerEl) - .setName("Add link to the bottom") + .setName("Sets the default text for a link below the embed") .setDesc("Add a link below the embed to easily open the link on a browser") - .addToggle(toggle => toggle - .setValue(settings.fallbackAddLink) + .addText(text => text + .setValue(settings.fallbackDefaultLink) + .setPlaceholder("Link") .onChange(async (value) => { - settings.fallbackAddLink = value; + settings.fallbackDefaultLink = value; await this.plugin.saveSettings(); }) )