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-index";
|
||||
import "./chooser";
|
||||
import { type LoadInfo } from "./item";
|
||||
import { type EmbedOpts, type LoadInfo } from "./item";
|
||||
import type { FavIconEventDetail } from "./types";
|
||||
|
||||
// ===========================================================================
|
||||
@@ -59,6 +59,9 @@ export class ReplayWebApp extends LitElement {
|
||||
@property({ type: String })
|
||||
embed: string | null = null;
|
||||
|
||||
@property({ type: Object })
|
||||
embedOpts: EmbedOpts = {};
|
||||
|
||||
@property({ type: String })
|
||||
collPageUrl = "";
|
||||
|
||||
@@ -398,6 +401,7 @@ export class ReplayWebApp extends LitElement {
|
||||
.loadInfo="${this.loadInfo}"
|
||||
sourceUrl="${this.sourceUrl || ""}"
|
||||
embed="${ifDefined(this.embed === null ? undefined : this.embed)}"
|
||||
.embedOpts="${this.embedOpts}"
|
||||
appName="${this.appName}"
|
||||
swName="${ifDefined(this.swName)}"
|
||||
@replay-favicons=${this.onFavIcons}
|
||||
@@ -587,6 +591,10 @@ export class ReplayWebApp extends LitElement {
|
||||
if (!this.loadInfo) {
|
||||
this.loadInfo = {};
|
||||
}
|
||||
|
||||
if (this.pageParams.has("noMediaDownload")) {
|
||||
this.embedOpts = { ...this.embedOpts, noMediaDownloadUI: true };
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pageParams.get("config")) {
|
||||
|
||||
@@ -66,6 +66,8 @@ class Embed extends LitElement {
|
||||
@property({ type: Boolean }) noCache = false;
|
||||
@property({ type: Boolean }) hideOffscreen: boolean | undefined;
|
||||
|
||||
@property({ type: Boolean }) noMediaDownload = false;
|
||||
|
||||
@property({ type: Boolean }) useAdblock = false;
|
||||
@property({ type: String }) adblockRulesUrl = DEFAULT_ADBLOCK_FILE;
|
||||
|
||||
@@ -324,6 +326,7 @@ class Embed extends LitElement {
|
||||
swName?: string;
|
||||
ruffle?: "1";
|
||||
adblockUrl?: string;
|
||||
noMediaDownload?: string;
|
||||
} = {
|
||||
source,
|
||||
customColl: this.coll,
|
||||
@@ -365,6 +368,10 @@ class Embed extends LitElement {
|
||||
params.adblockUrl = this.adblockRulesUrl;
|
||||
}
|
||||
|
||||
if (this.noMediaDownload) {
|
||||
params.noMediaDownload = "1";
|
||||
}
|
||||
|
||||
this.paramString = new URLSearchParams(
|
||||
// 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>,
|
||||
|
||||
+8
-1
@@ -87,6 +87,10 @@ export type LoadInfo = {
|
||||
importCollId?: string;
|
||||
};
|
||||
|
||||
export type EmbedOpts = {
|
||||
noMediaDownloadUI?: boolean;
|
||||
};
|
||||
|
||||
export type EmbedReplayData = {
|
||||
view?: "story" | "pages" | "resources";
|
||||
url?: string;
|
||||
@@ -120,6 +124,9 @@ class Item extends LitElement {
|
||||
@property({ type: Object, attribute: false })
|
||||
loadInfo: LoadInfo | null = null;
|
||||
|
||||
@property({ type: Object })
|
||||
embedOpts: EmbedOpts = {};
|
||||
|
||||
@property({ type: Boolean })
|
||||
showSidebar: boolean | null = null;
|
||||
|
||||
@@ -1417,7 +1424,7 @@ class Item extends LitElement {
|
||||
<span>Purge Cache + Full Reload</span>
|
||||
</a>`
|
||||
: html``}
|
||||
${isReplay
|
||||
${isReplay && !this.embedOpts.noMediaDownloadUI
|
||||
? html`<hr class="dropdown-divider" />
|
||||
<a
|
||||
@click="${this.clickToDownload}"
|
||||
|
||||
Reference in New Issue
Block a user