add option to disable the "Select Media to Download" for embeds (#485)
- Fixes #486 - Adding `nomediadownload` attr, eg. `<replay-web-page nomediadownload ...>` will hide the new option in the main menu. - Add a general EmbedOpts that setting that can be used to configure other embedding options.
This commit is contained in:
+9
-1
@@ -26,7 +26,7 @@ import { SWManager } from "./swmanager";
|
|||||||
import "./item";
|
import "./item";
|
||||||
import "./item-index";
|
import "./item-index";
|
||||||
import "./chooser";
|
import "./chooser";
|
||||||
import { type LoadInfo } from "./item";
|
import { type EmbedOpts, type LoadInfo } from "./item";
|
||||||
import type { FavIconEventDetail } from "./types";
|
import type { FavIconEventDetail } from "./types";
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -59,6 +59,9 @@ export class ReplayWebApp extends LitElement {
|
|||||||
@property({ type: String })
|
@property({ type: String })
|
||||||
embed: string | null = null;
|
embed: string | null = null;
|
||||||
|
|
||||||
|
@property({ type: Object })
|
||||||
|
embedOpts: EmbedOpts = {};
|
||||||
|
|
||||||
@property({ type: String })
|
@property({ type: String })
|
||||||
collPageUrl = "";
|
collPageUrl = "";
|
||||||
|
|
||||||
@@ -398,6 +401,7 @@ export class ReplayWebApp extends LitElement {
|
|||||||
.loadInfo="${this.loadInfo}"
|
.loadInfo="${this.loadInfo}"
|
||||||
sourceUrl="${this.sourceUrl || ""}"
|
sourceUrl="${this.sourceUrl || ""}"
|
||||||
embed="${ifDefined(this.embed === null ? undefined : this.embed)}"
|
embed="${ifDefined(this.embed === null ? undefined : this.embed)}"
|
||||||
|
.embedOpts="${this.embedOpts}"
|
||||||
appName="${this.appName}"
|
appName="${this.appName}"
|
||||||
swName="${ifDefined(this.swName)}"
|
swName="${ifDefined(this.swName)}"
|
||||||
@replay-favicons=${this.onFavIcons}
|
@replay-favicons=${this.onFavIcons}
|
||||||
@@ -587,6 +591,10 @@ export class ReplayWebApp extends LitElement {
|
|||||||
if (!this.loadInfo) {
|
if (!this.loadInfo) {
|
||||||
this.loadInfo = {};
|
this.loadInfo = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.pageParams.has("noMediaDownload")) {
|
||||||
|
this.embedOpts = { ...this.embedOpts, noMediaDownloadUI: true };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pageParams.get("config")) {
|
if (this.pageParams.get("config")) {
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ class Embed extends LitElement {
|
|||||||
@property({ type: Boolean }) noCache = false;
|
@property({ type: Boolean }) noCache = false;
|
||||||
@property({ type: Boolean }) hideOffscreen: boolean | undefined;
|
@property({ type: Boolean }) hideOffscreen: boolean | undefined;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) noMediaDownload = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) useAdblock = false;
|
@property({ type: Boolean }) useAdblock = false;
|
||||||
@property({ type: String }) adblockRulesUrl = DEFAULT_ADBLOCK_FILE;
|
@property({ type: String }) adblockRulesUrl = DEFAULT_ADBLOCK_FILE;
|
||||||
|
|
||||||
@@ -324,6 +326,7 @@ class Embed extends LitElement {
|
|||||||
swName?: string;
|
swName?: string;
|
||||||
ruffle?: "1";
|
ruffle?: "1";
|
||||||
adblockUrl?: string;
|
adblockUrl?: string;
|
||||||
|
noMediaDownload?: string;
|
||||||
} = {
|
} = {
|
||||||
source,
|
source,
|
||||||
customColl: this.coll,
|
customColl: this.coll,
|
||||||
@@ -365,6 +368,10 @@ class Embed extends LitElement {
|
|||||||
params.adblockUrl = this.adblockRulesUrl;
|
params.adblockUrl = this.adblockRulesUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.noMediaDownload) {
|
||||||
|
params.noMediaDownload = "1";
|
||||||
|
}
|
||||||
|
|
||||||
this.paramString = new URLSearchParams(
|
this.paramString = new URLSearchParams(
|
||||||
// Converting to unknown here so that we can ignore the URL -> string conversion necessary for the types to work out
|
// Converting to unknown here so that we can ignore the URL -> string conversion necessary for the types to work out
|
||||||
params as unknown as Record<string, string>,
|
params as unknown as Record<string, string>,
|
||||||
|
|||||||
+8
-1
@@ -87,6 +87,10 @@ export type LoadInfo = {
|
|||||||
importCollId?: string;
|
importCollId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type EmbedOpts = {
|
||||||
|
noMediaDownloadUI?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type EmbedReplayData = {
|
export type EmbedReplayData = {
|
||||||
view?: "story" | "pages" | "resources";
|
view?: "story" | "pages" | "resources";
|
||||||
url?: string;
|
url?: string;
|
||||||
@@ -120,6 +124,9 @@ class Item extends LitElement {
|
|||||||
@property({ type: Object, attribute: false })
|
@property({ type: Object, attribute: false })
|
||||||
loadInfo: LoadInfo | null = null;
|
loadInfo: LoadInfo | null = null;
|
||||||
|
|
||||||
|
@property({ type: Object })
|
||||||
|
embedOpts: EmbedOpts = {};
|
||||||
|
|
||||||
@property({ type: Boolean })
|
@property({ type: Boolean })
|
||||||
showSidebar: boolean | null = null;
|
showSidebar: boolean | null = null;
|
||||||
|
|
||||||
@@ -1417,7 +1424,7 @@ class Item extends LitElement {
|
|||||||
<span>Purge Cache + Full Reload</span>
|
<span>Purge Cache + Full Reload</span>
|
||||||
</a>`
|
</a>`
|
||||||
: html``}
|
: html``}
|
||||||
${isReplay
|
${isReplay && !this.embedOpts.noMediaDownloadUI
|
||||||
? html`<hr class="dropdown-divider" />
|
? html`<hr class="dropdown-divider" />
|
||||||
<a
|
<a
|
||||||
@click="${this.clickToDownload}"
|
@click="${this.clickToDownload}"
|
||||||
|
|||||||
Reference in New Issue
Block a user