@g1cloud/page-builder-editor 1.0.0-alpha.14 → 1.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,9 @@ declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimePr
8
8
  locales?: string[] | undefined;
9
9
  locale?: string | undefined;
10
10
  toolbarPlugin?: PageBuilderToolbarPlugin | undefined;
11
+ plugin?: unknown;
11
12
  }>, {
12
- getLocalDesignPartContent: () => any[] | undefined;
13
+ getPageContent: () => string;
13
14
  }, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
14
15
  instanceId?: string | undefined;
15
16
  title?: string | undefined;
@@ -18,6 +19,7 @@ declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimePr
18
19
  locales?: string[] | undefined;
19
20
  locale?: string | undefined;
20
21
  toolbarPlugin?: PageBuilderToolbarPlugin | undefined;
22
+ plugin?: unknown;
21
23
  }>>>, {}, {}>;
22
24
  export default _default;
23
25
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, openBlock, createElementBlock, createElementVNode, toDisplayString, createVNode, unref } from "vue";
2
2
  import { BSTextInput } from "@g1cloud/bluesea";
3
- import { P as PbColorPicker } from "./index-CuI4K01B.js";
3
+ import { P as PbColorPicker } from "./index-BIoyBfxM.js";
4
4
  const _hoisted_1 = { class: "property-editor property-editor-color" };
5
5
  const _hoisted_2 = { class: "title" };
6
6
  const _hoisted_3 = ["textContent"];
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, openBlock, createElementBlock, createElementVNode, toDisplayString, defineAsyncComponent } from "vue";
2
2
  import { useModal } from "@g1cloud/bluesea";
3
- import { u as usePageBuilderEditor } from "./index-CuI4K01B.js";
3
+ import { u as usePageBuilderEditor } from "./index-BIoyBfxM.js";
4
4
  const _hoisted_1 = { class: "property-editor property-editor-image flex-align-center" };
5
5
  const _hoisted_2 = { class: "title" };
6
6
  const _hoisted_3 = ["textContent"];
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, openBlock, createElementBlock, createElementVNode, toDisplayString } from "vue";
2
2
  import { useModal } from "@g1cloud/bluesea";
3
- import { u as usePageBuilderEditor, a as PageBuilderEditorEvent } from "./index-CuI4K01B.js";
3
+ import { u as usePageBuilderEditor, a as PageBuilderEditorEvent } from "./index-BIoyBfxM.js";
4
4
  const _hoisted_1 = { class: "property-editor property-editor-image flex-align-center" };
5
5
  const _hoisted_2 = { class: "title" };
6
6
  const _hoisted_3 = ["textContent"];
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, toDisplayString, createBlock, unref } from "vue";
2
2
  import { BSMultiLangTextArea, BSTextArea } from "@g1cloud/bluesea";
3
- import { u as usePageBuilderEditor } from "./index-CuI4K01B.js";
3
+ import { u as usePageBuilderEditor } from "./index-BIoyBfxM.js";
4
4
  const _hoisted_1 = { class: "property-editor property-editor-multiline-text" };
5
5
  const _hoisted_2 = { class: "title" };
6
6
  const _hoisted_3 = ["textContent"];
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { ref, defineComponent, openBlock, createElementBlock, createCommentVNode, computed, normalizeClass, createElementVNode, mergeProps, toDisplayString, onMounted, watch, Fragment, renderList, provide, inject, createBlock as createBlock$1, resolveDynamicComponent, reactive, defineAsyncComponent, withDirectives, unref, createVNode, normalizeStyle, resolveComponent, vModelText, onBeforeUnmount, resolveDirective, withModifiers, renderSlot, normalizeProps, guardReactiveProps, markRaw, Teleport, toHandlers, withCtx } from "vue";
7
+ import { ref, defineComponent, openBlock, createElementBlock, createCommentVNode, computed, normalizeClass, createElementVNode, mergeProps, toDisplayString, provide, inject, onMounted, watch, createBlock as createBlock$1, resolveDynamicComponent, normalizeProps, Fragment, renderList, reactive, defineAsyncComponent, withDirectives, unref, createVNode, normalizeStyle, resolveComponent, vModelText, onBeforeUnmount, resolveDirective, withModifiers, renderSlot, guardReactiveProps, markRaw, Teleport, toHandlers, withCtx } from "vue";
8
8
  import { notNull, BSTextInput, vClickOutside, useContextMenu, useModal, BSSelect, BSTabSheet, BSTree, BSDateRange } from "@g1cloud/bluesea";
9
9
  const create$5 = () => /* @__PURE__ */ new Map();
10
10
  const copy = (m) => {
@@ -6892,8 +6892,8 @@ let Model$1 = class Model {
6892
6892
  this.rootPart = ref(new RootPart());
6893
6893
  }
6894
6894
  };
6895
- const _hoisted_1$8$1 = ["data-model-id"];
6896
- const _hoisted_2$4$1 = {
6895
+ const _hoisted_1$7$1 = ["data-model-id"];
6896
+ const _hoisted_2$3$1 = {
6897
6897
  key: 1,
6898
6898
  class: "pb-nested-widget"
6899
6899
  };
@@ -6919,7 +6919,7 @@ const _sfc_main$9$1 = /* @__PURE__ */ defineComponent({
6919
6919
  key: 0,
6920
6920
  part: _ctx.part
6921
6921
  }, null, 8, ["part"])) : createCommentVNode("", true),
6922
- childComponents.value && childComponents.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_2$4$1, [
6922
+ childComponents.value && childComponents.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_2$3$1, [
6923
6923
  (openBlock(true), createElementBlock(Fragment, null, renderList(childComponents.value, (child) => {
6924
6924
  return openBlock(), createBlock$1(resolveDynamicComponent(child.component), {
6925
6925
  key: child.part.partId,
@@ -6927,11 +6927,11 @@ const _sfc_main$9$1 = /* @__PURE__ */ defineComponent({
6927
6927
  }, null, 8, ["part"]);
6928
6928
  }), 128))
6929
6929
  ])) : createCommentVNode("", true)
6930
- ], 16, _hoisted_1$8$1);
6930
+ ], 16, _hoisted_1$7$1);
6931
6931
  };
6932
6932
  }
6933
6933
  });
6934
- const _hoisted_1$7$1 = ["data-model-id"];
6934
+ const _hoisted_1$6$1 = ["data-model-id"];
6935
6935
  const _sfc_main$8$1 = /* @__PURE__ */ defineComponent({
6936
6936
  __name: "PbBlock",
6937
6937
  props: {
@@ -6955,12 +6955,12 @@ const _sfc_main$8$1 = /* @__PURE__ */ defineComponent({
6955
6955
  part: child
6956
6956
  }, null, 8, ["part"]);
6957
6957
  }), 128))
6958
- ], 16, _hoisted_1$7$1);
6958
+ ], 16, _hoisted_1$6$1);
6959
6959
  };
6960
6960
  }
6961
6961
  });
6962
- const _hoisted_1$6$1 = { class: "pb-block" };
6963
- const _hoisted_2$3$1 = /* @__PURE__ */ createElementVNode("div", {
6962
+ const _hoisted_1$5$1 = { class: "pb-block" };
6963
+ const _hoisted_2$2$1 = /* @__PURE__ */ createElementVNode("div", {
6964
6964
  class: "pb-widget",
6965
6965
  style: { "margin": "0 auto" }
6966
6966
  }, [
@@ -6968,8 +6968,8 @@ const _hoisted_2$3$1 = /* @__PURE__ */ createElementVNode("div", {
6968
6968
  /* @__PURE__ */ createElementVNode("h3", null, "Login Design Part")
6969
6969
  ])
6970
6970
  ], -1);
6971
- const _hoisted_3$2$1 = [
6972
- _hoisted_2$3$1
6971
+ const _hoisted_3$1$1 = [
6972
+ _hoisted_2$2$1
6973
6973
  ];
6974
6974
  const _sfc_main$7$1 = /* @__PURE__ */ defineComponent({
6975
6975
  __name: "PbLoginDepart",
@@ -6978,11 +6978,11 @@ const _sfc_main$7$1 = /* @__PURE__ */ defineComponent({
6978
6978
  },
6979
6979
  setup(__props) {
6980
6980
  return (_ctx, _cache) => {
6981
- return openBlock(), createElementBlock("div", _hoisted_1$6$1, _hoisted_3$2$1);
6981
+ return openBlock(), createElementBlock("div", _hoisted_1$5$1, _hoisted_3$1$1);
6982
6982
  };
6983
6983
  }
6984
6984
  });
6985
- const _hoisted_1$5$1 = ["data-model-id"];
6985
+ const _hoisted_1$4$1 = ["data-model-id"];
6986
6986
  const _sfc_main$6$1 = /* @__PURE__ */ defineComponent({
6987
6987
  __name: "PbSection",
6988
6988
  props: {
@@ -7008,19 +7008,19 @@ const _sfc_main$6$1 = /* @__PURE__ */ defineComponent({
7008
7008
  part: block
7009
7009
  }, null, 8, ["part"]);
7010
7010
  }), 128)) : createCommentVNode("", true)
7011
- ], 16, _hoisted_1$5$1);
7011
+ ], 16, _hoisted_1$4$1);
7012
7012
  };
7013
7013
  }
7014
7014
  });
7015
- const _hoisted_1$4$1 = { class: "pb-image-widget" };
7016
- const _hoisted_2$2$1 = ["src"];
7017
- const _hoisted_3$1$1 = {
7015
+ const _hoisted_1$3$1 = { class: "pb-image-widget" };
7016
+ const _hoisted_2$1$1 = ["src"];
7017
+ const _hoisted_3$h = {
7018
7018
  key: 1,
7019
7019
  class: "empty"
7020
7020
  };
7021
- const _hoisted_4$1$1 = /* @__PURE__ */ createElementVNode("span", { class: "font-icon" }, "image", -1);
7022
- const _hoisted_5$1$1 = [
7023
- _hoisted_4$1$1
7021
+ const _hoisted_4$e = /* @__PURE__ */ createElementVNode("span", { class: "font-icon" }, "image", -1);
7022
+ const _hoisted_5$7 = [
7023
+ _hoisted_4$e
7024
7024
  ];
7025
7025
  const _sfc_main$5$1 = /* @__PURE__ */ defineComponent({
7026
7026
  __name: "PbImageWidget",
@@ -7031,18 +7031,18 @@ const _sfc_main$5$1 = /* @__PURE__ */ defineComponent({
7031
7031
  setup(__props) {
7032
7032
  return (_ctx, _cache) => {
7033
7033
  var _a, _b;
7034
- return openBlock(), createElementBlock("div", _hoisted_1$4$1, [
7034
+ return openBlock(), createElementBlock("div", _hoisted_1$3$1, [
7035
7035
  ((_a = _ctx.part.properties) == null ? void 0 : _a.image) ? (openBlock(), createElementBlock("img", {
7036
7036
  key: 0,
7037
7037
  src: (_b = _ctx.part.properties) == null ? void 0 : _b.image,
7038
7038
  alt: "",
7039
7039
  class: "image"
7040
- }, null, 8, _hoisted_2$2$1)) : !_ctx.viewMode ? (openBlock(), createElementBlock("div", _hoisted_3$1$1, _hoisted_5$1$1)) : createCommentVNode("", true)
7040
+ }, null, 8, _hoisted_2$1$1)) : !_ctx.viewMode ? (openBlock(), createElementBlock("div", _hoisted_3$h, _hoisted_5$7)) : createCommentVNode("", true)
7041
7041
  ]);
7042
7042
  };
7043
7043
  }
7044
7044
  });
7045
- const _hoisted_1$3$1 = ["textContent"];
7045
+ const _hoisted_1$2$1 = ["textContent"];
7046
7046
  const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
7047
7047
  __name: "PbTextWidget",
7048
7048
  props: {
@@ -7104,13 +7104,13 @@ const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
7104
7104
  }, [
7105
7105
  createElementVNode("div", mergeProps({ class: "text" }, style.value, {
7106
7106
  textContent: toDisplayString(text.value)
7107
- }), null, 16, _hoisted_1$3$1)
7107
+ }), null, 16, _hoisted_1$2$1)
7108
7108
  ], 2);
7109
7109
  };
7110
7110
  }
7111
7111
  });
7112
- const _hoisted_1$2$1 = ["innerHTML"];
7113
- const _hoisted_2$1$1 = { key: 1 };
7112
+ const _hoisted_1$1$1 = ["innerHTML"];
7113
+ const _hoisted_2$k = { key: 1 };
7114
7114
  const _sfc_main$3$1 = /* @__PURE__ */ defineComponent({
7115
7115
  __name: "PbHtmlWidget",
7116
7116
  props: {
@@ -7157,112 +7157,12 @@ ${_html.style}
7157
7157
  key: 0,
7158
7158
  class: "html",
7159
7159
  innerHTML: html.value
7160
- }, null, 8, _hoisted_1$2$1)) : (openBlock(), createElementBlock("span", _hoisted_2$1$1, "Empty HTML"))
7160
+ }, null, 8, _hoisted_1$1$1)) : (openBlock(), createElementBlock("span", _hoisted_2$k, "Empty HTML"))
7161
7161
  ], 2);
7162
7162
  };
7163
7163
  }
7164
7164
  });
7165
- function mitt(n) {
7166
- return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
7167
- var i = n.get(t);
7168
- i ? i.push(e) : n.set(t, [e]);
7169
- }, off: function(t, e) {
7170
- var i = n.get(t);
7171
- i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
7172
- }, emit: function(t, e) {
7173
- var i = n.get(t);
7174
- i && i.slice().map(function(n2) {
7175
- n2(e);
7176
- }), (i = n.get("*")) && i.slice().map(function(n2) {
7177
- n2(t, e);
7178
- });
7179
- } };
7180
- }
7181
- const emitter = mitt();
7182
- const PageBuilderViewerEvent = {
7183
- on: {
7184
- requestProductMapping: (listener) => {
7185
- emitter.on("requestProductMapping", listener);
7186
- }
7187
- },
7188
- off: {
7189
- requestProductMapping: (listener) => {
7190
- emitter.off("requestProductMapping", listener);
7191
- }
7192
- },
7193
- emit: {
7194
- requestProductMapping: (param) => {
7195
- emitter.emit("requestProductMapping", param);
7196
- }
7197
- }
7198
- };
7199
- const _hoisted_1$1$1 = { class: "pb-product-list-widget" };
7200
- const _hoisted_2$k = { class: "product" };
7201
- const _hoisted_3$h = { class: "image" };
7202
- const _hoisted_4$e = ["src"];
7203
- const _hoisted_5$7 = { class: "name" };
7204
- const _hoisted_6$6 = { class: "price" };
7205
- const _hoisted_7$5 = {
7206
- key: 1,
7207
- class: "empty"
7208
- };
7209
- const _hoisted_8$5 = /* @__PURE__ */ createElementVNode("span", { class: "font-icon" }, "image", -1);
7210
- const _hoisted_9$5 = [
7211
- _hoisted_8$5
7212
- ];
7213
- const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
7214
- __name: "PbProductListWidget",
7215
- props: {
7216
- part: {},
7217
- viewMode: { type: Boolean, default: false }
7218
- },
7219
- setup(__props) {
7220
- const props = __props;
7221
- const products = ref([]);
7222
- const productCount = computed(() => props.viewMode ? products.value.length : Math.max(4, products.value.length));
7223
- const updateProducts = () => {
7224
- var _a, _b;
7225
- if ((_a = props.part.properties) == null ? void 0 : _a.products) {
7226
- PageBuilderViewerEvent.emit.requestProductMapping({
7227
- pageBuilderId: props.part.getPageBuilderId(),
7228
- itemCodes: (_b = props.part.properties) == null ? void 0 : _b.products,
7229
- callback: (_products) => {
7230
- products.value = _products;
7231
- }
7232
- });
7233
- }
7234
- };
7235
- onMounted(() => updateProducts());
7236
- watch(() => {
7237
- var _a;
7238
- return (_a = props.part.properties) == null ? void 0 : _a.products;
7239
- }, () => updateProducts());
7240
- return (_ctx, _cache) => {
7241
- return openBlock(), createElementBlock("div", _hoisted_1$1$1, [
7242
- products.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(productCount.value, (index) => {
7243
- return openBlock(), createElementBlock("div", {
7244
- key: index,
7245
- class: "product-wrapper"
7246
- }, [
7247
- createElementVNode("div", _hoisted_2$k, [
7248
- products.value[index - 1] ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
7249
- createElementVNode("div", _hoisted_3$h, [
7250
- createElementVNode("img", {
7251
- src: products.value[index - 1].image,
7252
- alt: ""
7253
- }, null, 8, _hoisted_4$e)
7254
- ]),
7255
- createElementVNode("div", _hoisted_5$7, toDisplayString(products.value[index - 1].itemName), 1),
7256
- createElementVNode("div", _hoisted_6$6, toDisplayString(products.value[index - 1].price), 1)
7257
- ], 64)) : (openBlock(), createElementBlock("div", _hoisted_7$5, _hoisted_9$5))
7258
- ])
7259
- ]);
7260
- }), 128)) : createCommentVNode("", true)
7261
- ]);
7262
- };
7263
- }
7264
- });
7265
- const partDefinitions$1 = {
7165
+ const defaultPartDefinitions = {
7266
7166
  "Section": {
7267
7167
  partType: "Section",
7268
7168
  partName: "Section",
@@ -7302,15 +7202,11 @@ const partDefinitions$1 = {
7302
7202
  partType: "Widget",
7303
7203
  partName: "HtmlWidget",
7304
7204
  creator: () => _sfc_main$3$1
7305
- },
7306
- "ProductListWidget": {
7307
- partType: "Widget",
7308
- partName: "ProductListWidget",
7309
- creator: () => _sfc_main$2$1
7310
7205
  }
7311
7206
  };
7312
7207
  const PAGE_BUILDER_KEY = "PageBuilder";
7313
7208
  const PAGE_BUILDER_VIEWER_KEY = "PageBuilderViewer";
7209
+ let partDefinitions$1 = { ...defaultPartDefinitions };
7314
7210
  class PageBuilderViewerImpl {
7315
7211
  constructor() {
7316
7212
  __publicField2(this, "instanceId");
@@ -7324,6 +7220,18 @@ class PageBuilderViewerImpl {
7324
7220
  setLocale(locale) {
7325
7221
  this.locale.value = locale || "en";
7326
7222
  }
7223
+ registerCustomPlugin(plugin) {
7224
+ if (plugin.widgets) {
7225
+ plugin.widgets.forEach((v) => {
7226
+ partDefinitions$1[v.partName] = {
7227
+ partType: "Widget",
7228
+ partName: v.partName,
7229
+ creator: () => _sfc_main$q,
7230
+ component: v.component
7231
+ };
7232
+ });
7233
+ }
7234
+ }
7327
7235
  render(pageContent) {
7328
7236
  const rootPart = new RootPart();
7329
7237
  rootPart.pageBuilderId = this.instanceId;
@@ -7365,6 +7273,12 @@ class PageBuilderViewerImpl {
7365
7273
  return new Widget();
7366
7274
  }
7367
7275
  }
7276
+ getCustomWidgetComponent(part) {
7277
+ const def = getPartDefinition(part.partName);
7278
+ if (def) {
7279
+ return def.component;
7280
+ }
7281
+ }
7368
7282
  }
7369
7283
  const createPageBuilderViewer = () => {
7370
7284
  const viewer = new PageBuilderViewerImpl();
@@ -7403,7 +7317,7 @@ const createPartComponent = (part) => {
7403
7317
  }
7404
7318
  };
7405
7319
  const getPartDefinition = (partName) => partDefinitions$1[partName];
7406
- const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
7320
+ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
7407
7321
  __name: "PbPage",
7408
7322
  props: {
7409
7323
  page: {},
@@ -7433,19 +7347,22 @@ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
7433
7347
  }
7434
7348
  });
7435
7349
  const _hoisted_1$u = { class: "pb-viewer" };
7436
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
7350
+ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
7437
7351
  __name: "PageBuilderViewer",
7438
7352
  props: {
7439
7353
  instanceId: {},
7440
7354
  pageContent: {},
7441
7355
  isMobilePage: { type: Boolean },
7442
- language: {}
7356
+ language: {},
7357
+ plugin: {}
7443
7358
  },
7444
7359
  setup(__props) {
7445
7360
  const props = __props;
7446
7361
  const pageBuilderViewer = createPageBuilderViewer();
7447
7362
  pageBuilderViewer.instanceId = props.instanceId;
7448
7363
  pageBuilderViewer.setLocale(props.language);
7364
+ if (props.plugin)
7365
+ pageBuilderViewer.registerCustomPlugin(props.plugin);
7449
7366
  providePageBuilderViewer(pageBuilderViewer);
7450
7367
  providePageBuilder(pageBuilderViewer);
7451
7368
  const page = computed(() => pageBuilderViewer.model.rootPart.value.children && pageBuilderViewer.model.rootPart.value.children[props.isMobilePage ? 0 : 1]);
@@ -7464,7 +7381,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7464
7381
  );
7465
7382
  return (_ctx, _cache) => {
7466
7383
  return openBlock(), createElementBlock("div", _hoisted_1$u, [
7467
- page.value ? (openBlock(), createBlock$1(_sfc_main$1$1, {
7384
+ page.value ? (openBlock(), createBlock$1(_sfc_main$2$1, {
7468
7385
  key: 0,
7469
7386
  "is-mobile-page": _ctx.isMobilePage,
7470
7387
  page: page.value
@@ -7473,6 +7390,60 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7473
7390
  };
7474
7391
  }
7475
7392
  });
7393
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7394
+ __name: "PbCustomWidget",
7395
+ props: {
7396
+ part: {},
7397
+ viewMode: { type: Boolean, default: false }
7398
+ },
7399
+ setup(__props) {
7400
+ const props = __props;
7401
+ const pageBuilder = usePageBuilder();
7402
+ const comp = computed(() => pageBuilder.getCustomWidgetComponent(props.part));
7403
+ const bind = computed(() => ({
7404
+ pageBuilderId: pageBuilder.instanceId,
7405
+ properties: props.part.properties,
7406
+ placeholder: true
7407
+ }));
7408
+ return (_ctx, _cache) => {
7409
+ return comp.value ? (openBlock(), createBlock$1(resolveDynamicComponent(comp.value), normalizeProps(mergeProps({ key: 0 }, bind.value)), null, 16)) : createCommentVNode("", true);
7410
+ };
7411
+ }
7412
+ });
7413
+ function mitt(n) {
7414
+ return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
7415
+ var i = n.get(t);
7416
+ i ? i.push(e) : n.set(t, [e]);
7417
+ }, off: function(t, e) {
7418
+ var i = n.get(t);
7419
+ i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
7420
+ }, emit: function(t, e) {
7421
+ var i = n.get(t);
7422
+ i && i.slice().map(function(n2) {
7423
+ n2(e);
7424
+ }), (i = n.get("*")) && i.slice().map(function(n2) {
7425
+ n2(t, e);
7426
+ });
7427
+ } };
7428
+ }
7429
+ const emitter = mitt();
7430
+ const PageBuilderViewerEvent = {
7431
+ on: {
7432
+ requestProductMapping: (listener) => {
7433
+ emitter.on("requestProductMapping", listener);
7434
+ }
7435
+ },
7436
+ off: {
7437
+ requestProductMapping: (listener) => {
7438
+ emitter.off("requestProductMapping", listener);
7439
+ }
7440
+ },
7441
+ emit: {
7442
+ requestProductMapping: (param) => {
7443
+ emitter.emit("requestProductMapping", param);
7444
+ }
7445
+ }
7446
+ };
7476
7447
  const PART_ID_KEY = "partId";
7477
7448
  const PART_NAME_KEY = "partName";
7478
7449
  const RESERVED_ATTRIBUTES = [PART_ID_KEY, PART_NAME_KEY];
@@ -8058,12 +8029,11 @@ const defaultPartPropertyEditors = () => {
8058
8029
  return {
8059
8030
  "readonly-text": () => defineAsyncComponent(() => import("./PbPropertyEditorReadonlyText-Dgp_AVOD.js")),
8060
8031
  "text": () => defineAsyncComponent(() => import("./PbPropertyEditorText-BWOKvwD9.js")),
8061
- "multiline-text": () => defineAsyncComponent(() => import("./PbPropertyEditorMultilineText-BFGht6hc.js")),
8032
+ "multiline-text": () => defineAsyncComponent(() => import("./PbPropertyEditorMultilineText-CefJbbiM.js")),
8062
8033
  "select": () => defineAsyncComponent(() => import("./PbPropertyEditorSelect-CWedbXJI.js")),
8063
- "color": () => defineAsyncComponent(() => import("./PbPropertyEditorColor-CZHXz7K6.js")),
8064
- "image": () => defineAsyncComponent(() => import("./PbPropertyEditorImage-N4VYkBhB.js")),
8065
- "html": () => defineAsyncComponent(() => import("./PbPropertyEditorHtml-Bid2WYyb.js")),
8066
- "product": () => defineAsyncComponent(() => import("./PbPropertyEditorProduct-myd2_r0t.js"))
8034
+ "color": () => defineAsyncComponent(() => import("./PbPropertyEditorColor-DI5Bm25g.js")),
8035
+ "image": () => defineAsyncComponent(() => import("./PbPropertyEditorImage-DbxF_eg7.js")),
8036
+ "html": () => defineAsyncComponent(() => import("./PbPropertyEditorHtml-Bb_kuc4m.js"))
8067
8037
  };
8068
8038
  };
8069
8039
  const getPropertyValueOfParts = (parts, propertyName) => {
@@ -12118,32 +12088,6 @@ const widgets = [
12118
12088
  localized: true,
12119
12089
  allowsChild: () => false,
12120
12090
  creator: () => _sfc_main$3$1
12121
- },
12122
- {
12123
- partType: "Widget",
12124
- partName: "ProductListWidget",
12125
- caption: "Product List Widget",
12126
- icon: "lists",
12127
- propertyGroups: [
12128
- {
12129
- groupName: "productList",
12130
- caption: "Product List",
12131
- properties: [
12132
- {
12133
- propertyName: "product",
12134
- caption: "Product",
12135
- propertyType: "product",
12136
- params: "",
12137
- localized: true
12138
- }
12139
- ]
12140
- },
12141
- ...defaultWidgetPropertyGroups()
12142
- ],
12143
- initialProperties: {},
12144
- localized: true,
12145
- allowsChild: () => false,
12146
- creator: () => _sfc_main$2$1
12147
12091
  }
12148
12092
  ];
12149
12093
  const partDefinitions = {};
@@ -13381,6 +13325,12 @@ class PageBuilderEditorImpl {
13381
13325
  setLocales(locales) {
13382
13326
  this.locales.value = locales || ["en"];
13383
13327
  }
13328
+ getCustomWidgetComponent(part) {
13329
+ const def = this.partManager.getPartDefinition(part.partName);
13330
+ if (def) {
13331
+ return def.component;
13332
+ }
13333
+ }
13384
13334
  registerPlugin(plugin) {
13385
13335
  if (plugin.partDefinitions)
13386
13336
  this.partManager.registerPartDefinitions(plugin.partDefinitions);
@@ -13397,6 +13347,22 @@ class PageBuilderEditorImpl {
13397
13347
  if (plugin.toolButtonGroups)
13398
13348
  this.toolButtonRegistry.registerToolButtonGroups(plugin.toolButtonGroups);
13399
13349
  }
13350
+ registerCustomPlugin(plugin) {
13351
+ if (plugin.widgets) {
13352
+ const partDefinitions2 = {};
13353
+ plugin.widgets.forEach((v) => {
13354
+ const w = { ...v };
13355
+ w.partName = "Widget";
13356
+ w.creator = () => _sfc_main$q;
13357
+ w.propertyGroups = [...w.propertyGroups, ...defaultWidgetPropertyGroups()];
13358
+ partDefinitions2[v.partName] = w;
13359
+ });
13360
+ this.partManager.registerPartDefinitions(partDefinitions2);
13361
+ }
13362
+ if (plugin.propertyEditors) {
13363
+ this.partManager.registerPartPropertyEditors(plugin.propertyEditors);
13364
+ }
13365
+ }
13400
13366
  initData(content) {
13401
13367
  this.model.rootPart.pageBuilderId = this.instanceId;
13402
13368
  this.model.rootPart.language = this.locale.value;
@@ -14364,7 +14330,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14364
14330
  pageContent: {},
14365
14331
  locales: {},
14366
14332
  locale: {},
14367
- toolbarPlugin: {}
14333
+ toolbarPlugin: {},
14334
+ plugin: {}
14368
14335
  },
14369
14336
  setup(__props, { expose: __expose }) {
14370
14337
  const props = __props;
@@ -14377,6 +14344,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14377
14344
  pageBuilderEditor.setLocales(props.locales);
14378
14345
  if (props.locale)
14379
14346
  pageBuilderEditor.setLocale(props.locale);
14347
+ if (props.plugin)
14348
+ pageBuilderEditor.registerCustomPlugin(props.plugin);
14380
14349
  pageBuilderEditor.registerPlugin({
14381
14350
  // TODO
14382
14351
  commands: createDefaultCommands(modal)
@@ -14393,57 +14362,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14393
14362
  });
14394
14363
  const colorHistory = ref([]);
14395
14364
  provide("colorHistory", colorHistory);
14396
- const getLocalDesignPartContent = () => {
14397
- let content;
14398
- if (pageBuilderEditor.model.rootPart) {
14399
- content = doGetLocalDesignPartContent(pageBuilderEditor.model.rootPart);
14400
- }
14401
- return content;
14402
- };
14403
- const doGetLocalDesignPartContent = (part) => {
14404
- let content;
14405
- if (part.isGlobalDesignPart() || part.isLocalMarketingPart()) {
14406
- const properties = getLocalDesignPartProperties(part);
14407
- if (properties) {
14408
- if (!content)
14409
- content = [];
14410
- content.push({ partId: part.partId, data: properties });
14411
- }
14412
- }
14413
- if (part.children) {
14414
- for (const child of part.children) {
14415
- const childContent = doGetLocalDesignPartContent(child);
14416
- if (childContent)
14417
- content = [...content || [], ...childContent];
14418
- }
14419
- }
14420
- return content;
14421
- };
14422
- const getLocalDesignPartProperties = (part) => {
14423
- let properties;
14424
- if (part.isWidget()) {
14425
- const defs = pageBuilderEditor.partManager.getLocalDesignPartPropertyDefinitions(part.partName);
14426
- if (defs) {
14427
- const data = {};
14428
- for (const def of defs) {
14429
- if (part.properties)
14430
- data[def.propertyName] = part.properties[def.propertyName];
14431
- }
14432
- properties = { [part.partId]: data };
14433
- }
14434
- }
14435
- if (part.children) {
14436
- for (const child of part.children) {
14437
- const childProperties = getLocalDesignPartProperties(child);
14438
- if (childProperties) {
14439
- properties = { ...properties, ...childProperties };
14440
- }
14441
- }
14442
- }
14443
- return properties;
14365
+ const getPageContent = () => {
14366
+ const partIds = (pageBuilderEditor.model.rootPart.children || []).map((v) => v.partId);
14367
+ return pageBuilderEditor.model.serializePageModel(partIds);
14444
14368
  };
14445
14369
  __expose({
14446
- getLocalDesignPartContent
14370
+ getPageContent
14447
14371
  });
14448
14372
  return (_ctx, _cache) => {
14449
14373
  return openBlock(), createElementBlock("div", _hoisted_1, [
@@ -14470,12 +14394,12 @@ export {
14470
14394
  PAGE_BUILDER_KEY as c,
14471
14395
  PAGE_TYPE$1 as d,
14472
14396
  Page as e,
14473
- _sfc_main$q as f,
14397
+ _sfc_main$1$1 as f,
14474
14398
  PageBuilderViewerEvent as g,
14475
14399
  Part as h,
14476
- _sfc_main$3$1 as i,
14477
- _sfc_main$5$1 as j,
14478
- _sfc_main$2$1 as k,
14400
+ _sfc_main$q as i,
14401
+ _sfc_main$3$1 as j,
14402
+ _sfc_main$5$1 as k,
14479
14403
  _sfc_main$4$1 as l,
14480
14404
  RootPart as m,
14481
14405
  Section as n,
@@ -1,11 +1,11 @@
1
1
  import { ContextMenuRegistry, ContextMenuRegistryImpl, KeyHandlers, PageBuilderContext, PageBuilderContextImpl } from './context.ts';
2
2
  import { ToolButtonRegistry } from './toolbar.ts';
3
3
  import { PageBuilderPlugin } from './plugin.ts';
4
- import { PageBuilder } from '@g1cloud/page-builder-viewer';
4
+ import { IPart, PageBuilder } from '@g1cloud/page-builder-viewer';
5
5
  import { CommandRegistry, CommandRegistryImpl } from './command';
6
6
  import { PartManager } from './part-manager';
7
7
  import { Model } from './model';
8
- import { Ref } from 'vue';
8
+ import { Component, Ref } from 'vue';
9
9
 
10
10
  export type PageBuilderEditMode = 'template' | 'global' | 'local' | 'free';
11
11
  export declare const createPageBuilderEditor: () => PageBuilderEditor;
@@ -27,6 +27,7 @@ export interface PageBuilderEditor extends PageBuilder {
27
27
  scale: Ref<number>;
28
28
  locales: Ref<string[]>;
29
29
  registerPlugin(plugin: PageBuilderPlugin): void;
30
+ registerCustomPlugin(plugin: any): void;
30
31
  initData(content?: any): void;
31
32
  undo(): void;
32
33
  redo(): void;
@@ -55,7 +56,9 @@ export declare class PageBuilderEditorImpl implements PageBuilderEditor {
55
56
  setLocale(locale?: string): void;
56
57
  getLocales(): string[];
57
58
  setLocales(locales?: string[]): void;
59
+ getCustomWidgetComponent(part: IPart): Component | undefined;
58
60
  registerPlugin(plugin: PageBuilderPlugin): void;
61
+ registerCustomPlugin(plugin: any): void;
59
62
  initData(content?: any[]): void;
60
63
  undo(): void;
61
64
  redo(): void;