Skip to content

Commit

Permalink
refactor registering default components
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Dec 18, 2024
1 parent 2a59d3b commit 7c6eca4
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/pat/contentbrowser/contentbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7c6eca4

Please sign in to comment.