Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(external-sources): add externalSourcesEmbedCss config option to set embed css on external sources iframe #769

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blocks/Config/initialConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const initialConfig = {
imgOnly: false,
accept: '',
externalSourcesPreferredTypes: '',
externalSourcesEmbedCss: '',
store: 'auto',
cameraMirror: false,
cameraCapture: '',
Expand Down
1 change: 1 addition & 0 deletions blocks/Config/normalizeConfigValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const mapping = {
imgOnly: asBoolean,
accept: asString,
externalSourcesPreferredTypes: asString,
externalSourcesEmbedCss: asString,
store: asStore,
cameraMirror: asBoolean,
cameraCapture: asCameraCapture,
Expand Down
20 changes: 18 additions & 2 deletions blocks/ExternalSource/ExternalSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
this.mountIframe();
},
});
this.sub('*currentActivityParams', (val) => {

Check warning on line 90 in blocks/ExternalSource/ExternalSource.js

View workflow job for this annotation

GitHub Actions / build

'val' is defined but never used
if (!this.isActivityActive) {
return;
}
Expand All @@ -103,9 +103,13 @@
this.$.showSelectionStatus = multiple;
});

this.subConfigValue('localeName', (val) => {

Check warning on line 106 in blocks/ExternalSource/ExternalSource.js

View workflow job for this annotation

GitHub Actions / build

'val' is defined but never used
this.setupL10n();
});

this.subConfigValue('externalSourcesEmbedCss', (embedCss) => {
this.applyEmbedCss(embedCss);
});
}

/**
Expand Down Expand Up @@ -156,18 +160,30 @@

/** @private */
handleIframeLoad() {
this.applyStyles();
this.applyEmbedCss(this.cfg.externalSourcesEmbedCss);
this.applyTheme();
this.setupL10n();
}

/** @private */
applyStyles() {
applyTheme() {
this._messageBridge?.send({
type: 'set-theme-definition',
theme: buildThemeDefinition(this),
});
}

/**
* @private
* @param {string} css
*/
applyEmbedCss(css) {
this._messageBridge?.send({
type: 'set-embed-css',
css,
});
}

/** @private */
setupL10n() {
this._messageBridge?.send({
Expand Down
2 changes: 1 addition & 1 deletion blocks/ExternalSource/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
* }
* | {
* type: 'set-embed-css';
* css: Partial<ThemeDefinition>;
* css: string;
* }} OutputMessage
*/

Expand Down
4 changes: 4 additions & 0 deletions types/exported.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export type ConfigType = {
* See [here](https://uploadcare.com/docs/file-uploader/options/#external-sources-preferred-types)
*/
externalSourcesPreferredTypes: string;
/**
* Provide custom CSS to the social sources iframe
*/
externalSourcesEmbedCss: string;
/**
* Store uploaded files.
*/
Expand Down
Loading