diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-20 10:12:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-20 15:12:27 +0000 |
commit | 0e4ae922451af967c78616057ed26b85ba5d4b5c (patch) | |
tree | 8f1aed3d93e9c6e99e6c55e846b29d8dc154e113 /ext/js/pages/settings/popup-preview-controller.js | |
parent | 088c6c17ac7b6076604fd3bc40287d4afda0d940 (diff) |
Popup preview frame API map (#712)
* Add API map type safety
* Add API map types
* Simplify names
* Remove unused type
Diffstat (limited to 'ext/js/pages/settings/popup-preview-controller.js')
-rw-r--r-- | ext/js/pages/settings/popup-preview-controller.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/js/pages/settings/popup-preview-controller.js b/ext/js/pages/settings/popup-preview-controller.js index 8361809d..e661b738 100644 --- a/ext/js/pages/settings/popup-preview-controller.js +++ b/ext/js/pages/settings/popup-preview-controller.js @@ -71,38 +71,41 @@ export class PopupPreviewController { /** */ _onCustomCssChange() { const css = /** @type {HTMLTextAreaElement} */ (this._customCss).value; - this._invoke('PopupPreviewFrame.setCustomCss', {css}); + this._invoke('setCustomCss', {css}); } /** */ _onCustomOuterCssChange() { const css = /** @type {HTMLTextAreaElement} */ (this._customOuterCss).value; - this._invoke('PopupPreviewFrame.setCustomOuterCss', {css}); + this._invoke('setCustomOuterCss', {css}); } /** */ _onOptionsContextChange() { const optionsContext = this._settingsController.getOptionsContext(); - this._invoke('PopupPreviewFrame.updateOptionsContext', {optionsContext}); + this._invoke('updateOptionsContext', {optionsContext}); } /** * @param {import('settings-controller').EventArgument<'optionsChanged'>} details */ _onOptionsChanged({options}) { - this._invoke('PopupPreviewFrame.optionsChanged', {options}); + this._invoke('setLanguageExampleText', {language: options.general.language}); } /** * @param {import('dom-data-binder').SettingChangedEvent} settingChangedEvent */ _onLanguageSelectChanged(settingChangedEvent) { - this._invoke('PopupPreviewFrame.setLanguageExampleText', {language: settingChangedEvent.detail.value}); + const {value} = settingChangedEvent.detail; + if (typeof value !== 'string') { return; } + this._invoke('setLanguageExampleText', {language: value}); } /** - * @param {string} action - * @param {import('core').SerializableObject} params + * @template {import('popup-preview-frame').ApiNames} TName + * @param {TName} action + * @param {import('popup-preview-frame').ApiParams<TName>} params */ _invoke(action, params) { if (this._frame === null || this._frame.contentWindow === null) { return; } |