From 7c6eca4370b46ff90385f31f76e4c5ed802d425d Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 17 Dec 2024 14:43:43 +0100 Subject: [PATCH] refactor registering default components --- src/pat/contentbrowser/contentbrowser.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/pat/contentbrowser/contentbrowser.js b/src/pat/contentbrowser/contentbrowser.js index 8710989a3..db7ecf35f 100644 --- a/src/pat/contentbrowser/contentbrowser.js +++ b/src/pat/contentbrowser/contentbrowser.js @@ -4,22 +4,6 @@ import registry from "@patternslib/patternslib/src/core/registry"; import utils from "../../core/utils"; import plone_registry from "@plone/registry"; -async function setup_default_component_registry() { - if (plone_registry.getComponent("pat-contentbrowser.SelectedItem").component === undefined) { - const SelectedItem = (await import("./src/SelectedItem.svelte")).default; - plone_registry.registerComponent({ - name: "pat-contentbrowser.SelectedItem", - component: SelectedItem, - }); - console.log("Loaded default 'SelectedItem' Component"); - } -} - -// register default components in @plone/registry -// here outside the pattern init() so that addons can override this -// when their bundle depends on the "plone" bundle -setup_default_component_registry() - // Contentbrowser pattern export const parser = new Parser("contentbrowser"); @@ -65,6 +49,14 @@ class Pattern extends BasePattern { async init() { this.el.style.display = "none"; + // register default components in @plone/registry + const SelectedItem = (await import("./src/SelectedItem.svelte")).default; + + plone_registry.registerComponent({ + name: "pat-contentbrowser.SelectedItem", + component: SelectedItem, + }); + // ensure an id on our element (TinyMCE doesn't have one) let nodeId = this.el.getAttribute("id"); if (!nodeId) {