diff --git a/src/plugins/registration.ts b/src/plugins/registration.ts index eb426eab..2f355519 100644 --- a/src/plugins/registration.ts +++ b/src/plugins/registration.ts @@ -3,6 +3,7 @@ import {UIPHeader} from './header/header'; import {UIPOptions} from './header/options/options'; import {UIPSnippets} from './header/snippets/snippets'; import {UIPSettings} from './settings/settings'; +import {registeredSettings} from '../registration'; export {UIPEditor, UIPOptions, UIPSettings, UIPSnippets, UIPHeader}; @@ -11,5 +12,5 @@ export const registerPlugins = () => { UIPHeader.register(); UIPOptions.register(); UIPSnippets.register(); - UIPSettings.register(); + registeredSettings().then(() => UIPSettings.register()); }; diff --git a/src/plugins/settings/setting.ts b/src/plugins/settings/setting.ts index d3027f5c..62bf6a76 100644 --- a/src/plugins/settings/setting.ts +++ b/src/plugins/settings/setting.ts @@ -18,7 +18,9 @@ export abstract class UIPSetting extends ESLBaseElement { /** [Target's]{@link target} attribute which is changed by setting. */ @attr() public attribute: string; /** Target to which setting's changes are attached. */ - @attr() public target: string; + public get target(): string { + return this.getAttribute('target') || this.$settings.target; + } @memoize() public get $settings() { @@ -29,10 +31,6 @@ export abstract class UIPSetting extends ESLBaseElement { super.connectedCallback(); this.classList.add(UIPSetting.is); this.bindEvents(); - - if (this.target) return; - const settingsTarget = this.$settings?.target; - if (settingsTarget) this.target = settingsTarget; } protected disconnectedCallback() { diff --git a/src/settings/registration.ts b/src/settings/registration.ts index d169eac2..c737cfd0 100644 --- a/src/settings/registration.ts +++ b/src/settings/registration.ts @@ -12,3 +12,12 @@ export const registerSettings = () => { UIPSelectSetting.register(); UIPSliderSetting.register(); }; + +export const registeredSettings = () => { + return Promise.all([ + UIPBoolSetting.registered, + UIPTextSetting.registered, + UIPSelectSetting.registered, + UIPSliderSetting.registered, + ]); +}