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

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.
@@ -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,28 @@ 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
+ const w = { ...v };
7227
+ w.partType = "Widget";
7228
+ w.creator = () => _sfc_main$q;
7229
+ partDefinitions$1[v.partName] = w;
7230
+ });
7231
+ }
7232
+ }
7233
+ watchCustomWidgetData(part) {
7234
+ const def = partDefinitions$1[part.partName];
7235
+ if (!def || !def.dataWatcher)
7236
+ return false;
7237
+ return def.dataWatcher(part.properties);
7238
+ }
7239
+ provideCustomWidgetData(part) {
7240
+ const def = partDefinitions$1[part.partName];
7241
+ if (!def || !def.dataProvider)
7242
+ return Promise.resolve();
7243
+ return def.dataProvider(part.properties);
7244
+ }
7327
7245
  render(pageContent) {
7328
7246
  const rootPart = new RootPart();
7329
7247
  rootPart.pageBuilderId = this.instanceId;
@@ -7365,6 +7283,12 @@ class PageBuilderViewerImpl {
7365
7283
  return new Widget();
7366
7284
  }
7367
7285
  }
7286
+ getCustomWidgetComponent(part) {
7287
+ const def = getPartDefinition(part.partName);
7288
+ if (def) {
7289
+ return def.component;
7290
+ }
7291
+ }
7368
7292
  }
7369
7293
  const createPageBuilderViewer = () => {
7370
7294
  const viewer = new PageBuilderViewerImpl();
@@ -7403,7 +7327,7 @@ const createPartComponent = (part) => {
7403
7327
  }
7404
7328
  };
7405
7329
  const getPartDefinition = (partName) => partDefinitions$1[partName];
7406
- const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
7330
+ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
7407
7331
  __name: "PbPage",
7408
7332
  props: {
7409
7333
  page: {},
@@ -7433,19 +7357,22 @@ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
7433
7357
  }
7434
7358
  });
7435
7359
  const _hoisted_1$u = { class: "pb-viewer" };
7436
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
7360
+ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
7437
7361
  __name: "PageBuilderViewer",
7438
7362
  props: {
7439
7363
  instanceId: {},
7440
7364
  pageContent: {},
7441
7365
  isMobilePage: { type: Boolean },
7442
- language: {}
7366
+ language: {},
7367
+ plugin: {}
7443
7368
  },
7444
7369
  setup(__props) {
7445
7370
  const props = __props;
7446
7371
  const pageBuilderViewer = createPageBuilderViewer();
7447
7372
  pageBuilderViewer.instanceId = props.instanceId;
7448
7373
  pageBuilderViewer.setLocale(props.language);
7374
+ if (props.plugin)
7375
+ pageBuilderViewer.registerCustomPlugin(props.plugin);
7449
7376
  providePageBuilderViewer(pageBuilderViewer);
7450
7377
  providePageBuilder(pageBuilderViewer);
7451
7378
  const page = computed(() => pageBuilderViewer.model.rootPart.value.children && pageBuilderViewer.model.rootPart.value.children[props.isMobilePage ? 0 : 1]);
@@ -7464,7 +7391,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7464
7391
  );
7465
7392
  return (_ctx, _cache) => {
7466
7393
  return openBlock(), createElementBlock("div", _hoisted_1$u, [
7467
- page.value ? (openBlock(), createBlock$1(_sfc_main$1$1, {
7394
+ page.value ? (openBlock(), createBlock$1(_sfc_main$2$1, {
7468
7395
  key: 0,
7469
7396
  "is-mobile-page": _ctx.isMobilePage,
7470
7397
  page: page.value
@@ -7473,6 +7400,71 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7473
7400
  };
7474
7401
  }
7475
7402
  });
7403
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7404
+ __name: "PbCustomWidget",
7405
+ props: {
7406
+ part: {},
7407
+ dataWatcher: { type: Function },
7408
+ dataProvider: { type: Function }
7409
+ },
7410
+ setup(__props) {
7411
+ const props = __props;
7412
+ const pageBuilder = usePageBuilder();
7413
+ const comp = computed(() => pageBuilder.getCustomWidgetComponent(props.part));
7414
+ const data = ref({});
7415
+ const bind = computed(() => ({
7416
+ pageBuilderId: pageBuilder.instanceId,
7417
+ ...props.part.properties || {},
7418
+ placeholder: true,
7419
+ ...data.value || {}
7420
+ }));
7421
+ const updateData = async () => {
7422
+ data.value = await pageBuilder.provideCustomWidgetData(props.part);
7423
+ };
7424
+ onMounted(updateData);
7425
+ watch(
7426
+ () => pageBuilder.watchCustomWidgetData(props.part),
7427
+ () => updateData()
7428
+ );
7429
+ return (_ctx, _cache) => {
7430
+ return comp.value ? (openBlock(), createBlock$1(resolveDynamicComponent(comp.value), normalizeProps(mergeProps({ key: 0 }, bind.value)), null, 16)) : createCommentVNode("", true);
7431
+ };
7432
+ }
7433
+ });
7434
+ function mitt(n) {
7435
+ return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
7436
+ var i = n.get(t);
7437
+ i ? i.push(e) : n.set(t, [e]);
7438
+ }, off: function(t, e) {
7439
+ var i = n.get(t);
7440
+ i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
7441
+ }, emit: function(t, e) {
7442
+ var i = n.get(t);
7443
+ i && i.slice().map(function(n2) {
7444
+ n2(e);
7445
+ }), (i = n.get("*")) && i.slice().map(function(n2) {
7446
+ n2(t, e);
7447
+ });
7448
+ } };
7449
+ }
7450
+ const emitter = mitt();
7451
+ const PageBuilderViewerEvent = {
7452
+ on: {
7453
+ requestProductMapping: (listener) => {
7454
+ emitter.on("requestProductMapping", listener);
7455
+ }
7456
+ },
7457
+ off: {
7458
+ requestProductMapping: (listener) => {
7459
+ emitter.off("requestProductMapping", listener);
7460
+ }
7461
+ },
7462
+ emit: {
7463
+ requestProductMapping: (param) => {
7464
+ emitter.emit("requestProductMapping", param);
7465
+ }
7466
+ }
7467
+ };
7476
7468
  const PART_ID_KEY = "partId";
7477
7469
  const PART_NAME_KEY = "partName";
7478
7470
  const RESERVED_ATTRIBUTES = [PART_ID_KEY, PART_NAME_KEY];
@@ -7965,20 +7957,6 @@ class PartManager {
7965
7957
  }
7966
7958
  }
7967
7959
  }
7968
- getLocalDesignPartPropertyDefinitions(partName) {
7969
- let properties;
7970
- const partDef = this.getPartDefinition(partName);
7971
- if (!partDef || !partDef.propertyGroups)
7972
- return;
7973
- for (const group of partDef.propertyGroups) {
7974
- for (const property of group.properties) {
7975
- if (property.localized) {
7976
- properties = [...properties || [], property];
7977
- }
7978
- }
7979
- }
7980
- return properties;
7981
- }
7982
7960
  createPartComponent(part) {
7983
7961
  if (part) {
7984
7962
  const def = this.getPartDefinition(part.partName);
@@ -8058,12 +8036,11 @@ const defaultPartPropertyEditors = () => {
8058
8036
  return {
8059
8037
  "readonly-text": () => defineAsyncComponent(() => import("./PbPropertyEditorReadonlyText-Dgp_AVOD.js")),
8060
8038
  "text": () => defineAsyncComponent(() => import("./PbPropertyEditorText-BWOKvwD9.js")),
8061
- "multiline-text": () => defineAsyncComponent(() => import("./PbPropertyEditorMultilineText-BFGht6hc.js")),
8039
+ "multiline-text": () => defineAsyncComponent(() => import("./PbPropertyEditorMultilineText-B5HryveI.js")),
8062
8040
  "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"))
8041
+ "color": () => defineAsyncComponent(() => import("./PbPropertyEditorColor-Bw7qz0-r.js")),
8042
+ "image": () => defineAsyncComponent(() => import("./PbPropertyEditorImage-GN536Jw2.js")),
8043
+ "html": () => defineAsyncComponent(() => import("./PbPropertyEditorHtml-DH2Qep1X.js"))
8067
8044
  };
8068
8045
  };
8069
8046
  const getPropertyValueOfParts = (parts, propertyName) => {
@@ -12026,7 +12003,7 @@ const widgets = [
12026
12003
  {
12027
12004
  partType: "Widget",
12028
12005
  partName: "TextWidget",
12029
- caption: "Text Widget",
12006
+ caption: "Text",
12030
12007
  icon: "insert_text",
12031
12008
  propertyGroups: [
12032
12009
  {
@@ -12069,7 +12046,7 @@ const widgets = [
12069
12046
  {
12070
12047
  partType: "Widget",
12071
12048
  partName: "ImageWidget",
12072
- caption: "Image Widget",
12049
+ caption: "Image",
12073
12050
  icon: "imagesmode",
12074
12051
  propertyGroups: [
12075
12052
  {
@@ -12095,7 +12072,7 @@ const widgets = [
12095
12072
  {
12096
12073
  partType: "Widget",
12097
12074
  partName: "HtmlWidget",
12098
- caption: "HTML Widget",
12075
+ caption: "HTML",
12099
12076
  icon: "code",
12100
12077
  propertyGroups: [
12101
12078
  {
@@ -12118,32 +12095,6 @@ const widgets = [
12118
12095
  localized: true,
12119
12096
  allowsChild: () => false,
12120
12097
  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
12098
  }
12148
12099
  ];
12149
12100
  const partDefinitions = {};
@@ -12176,6 +12127,13 @@ const designPartDefinitions = [
12176
12127
  ]
12177
12128
  }
12178
12129
  ];
12130
+ const widgetPartDefinitions = [
12131
+ {
12132
+ groupName: "Widget",
12133
+ caption: "Widget",
12134
+ partDefinitions: widgets
12135
+ }
12136
+ ];
12179
12137
  const blockWidgetPartDefinitions = [
12180
12138
  {
12181
12139
  groupName: "Block",
@@ -12265,7 +12223,7 @@ const openPartAddModal = (modal, args, callback) => {
12265
12223
  };
12266
12224
  const openWidgetAddModal = (modal, args, callback) => {
12267
12225
  modal.openModal({
12268
- component: defineAsyncComponent(() => import("./PbWidgetAddModal-CQvFYzfU.js")),
12226
+ component: defineAsyncComponent(() => import("./PbWidgetAddModal-Zpo-ZeNH.js")),
12269
12227
  style: {
12270
12228
  width: "80%",
12271
12229
  height: "80%",
@@ -12369,6 +12327,36 @@ const _AddPartCommand = class _AddPartCommand {
12369
12327
  };
12370
12328
  __publicField(_AddPartCommand, "COMMAND_ID", "AddPart");
12371
12329
  let AddPartCommand = _AddPartCommand;
12330
+ const _AddSectionCommand = class _AddSectionCommand {
12331
+ constructor(modal) {
12332
+ __publicField(this, "commandId", _AddSectionCommand.COMMAND_ID);
12333
+ __publicField(this, "caption", "Add Section");
12334
+ this.modal = modal;
12335
+ }
12336
+ execute(pageBuilder, args) {
12337
+ const def = pageBuilder.partManager.getSectionDefinition();
12338
+ if (!def)
12339
+ return;
12340
+ addPart(pageBuilder, def);
12341
+ }
12342
+ };
12343
+ __publicField(_AddSectionCommand, "COMMAND_ID", "AddSection");
12344
+ let AddSectionCommand = _AddSectionCommand;
12345
+ const _AddBlockCommand = class _AddBlockCommand {
12346
+ constructor(modal) {
12347
+ __publicField(this, "commandId", _AddBlockCommand.COMMAND_ID);
12348
+ __publicField(this, "caption", "Add Block");
12349
+ this.modal = modal;
12350
+ }
12351
+ execute(pageBuilder, args) {
12352
+ const def = pageBuilder.partManager.getBlockDefinition();
12353
+ if (!def)
12354
+ return;
12355
+ addPart(pageBuilder, def);
12356
+ }
12357
+ };
12358
+ __publicField(_AddBlockCommand, "COMMAND_ID", "AddBlock");
12359
+ let AddBlockCommand = _AddBlockCommand;
12372
12360
  const addPart = (pageBuilder, def, attrs) => {
12373
12361
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12374
12362
  const selected = pageBuilder.context.getSelectedParts()[0];
@@ -12457,29 +12445,13 @@ const addPart = (pageBuilder, def, attrs) => {
12457
12445
  }
12458
12446
  };
12459
12447
  const addSectionBefore = (pageBuilder, modal, args) => {
12460
- const def = args && args.partDefinition;
12461
- if (!def) {
12462
- const partDefinitionGroups = designPartDefinitions;
12463
- openPartAddModal(modal, {
12464
- ...args || {},
12465
- pageBuilder,
12466
- partDefinitionGroups
12467
- }, (part, attrs) => {
12468
- addSectionBefore(pageBuilder, modal, {
12469
- ...args || {},
12470
- partDefinition: part,
12471
- ...attrs || {}
12472
- });
12473
- });
12474
- return;
12475
- }
12476
12448
  const selected = pageBuilder.context.getSelectedParts()[0];
12477
12449
  if (!selected)
12478
12450
  return;
12479
12451
  const section = pageBuilder.partManager.findNearestSection(selected);
12480
12452
  if (!section || !section.parent || !section.parent.children)
12481
12453
  return;
12482
- const newSection = createPartWithDefinition(def);
12454
+ const newSection = createSection(pageBuilder);
12483
12455
  if (!newSection)
12484
12456
  return;
12485
12457
  const child = createBlock(pageBuilder);
@@ -12488,29 +12460,13 @@ const addSectionBefore = (pageBuilder, modal, args) => {
12488
12460
  insertParts(pageBuilder, section.parent.partId, index, [newSection], true);
12489
12461
  };
12490
12462
  const addSectionAfter = (pageBuilder, modal, args) => {
12491
- const def = args && args.partDefinition;
12492
- if (!def) {
12493
- const partDefinitionGroups = designPartDefinitions;
12494
- openPartAddModal(modal, {
12495
- ...args || {},
12496
- pageBuilder,
12497
- partDefinitionGroups
12498
- }, (part, attrs) => {
12499
- addSectionAfter(pageBuilder, modal, {
12500
- ...args || {},
12501
- partDefinition: part,
12502
- ...attrs || {}
12503
- });
12504
- });
12505
- return;
12506
- }
12507
12463
  const selected = pageBuilder.context.getSelectedParts()[0];
12508
12464
  if (!selected)
12509
12465
  return;
12510
12466
  const section = pageBuilder.partManager.findNearestSection(selected);
12511
12467
  if (!section || !section.parent || !section.parent.children)
12512
12468
  return;
12513
- const newSection = createPartWithDefinition(def);
12469
+ const newSection = createSection(pageBuilder);
12514
12470
  if (!newSection)
12515
12471
  return;
12516
12472
  const child = createBlock(pageBuilder);
@@ -12633,7 +12589,7 @@ const _AddSectionAboveCommand = class _AddSectionAboveCommand {
12633
12589
  this.modal = modal;
12634
12590
  }
12635
12591
  execute(pageBuilder, args) {
12636
- addSectionBefore(pageBuilder, this.modal, args);
12592
+ addSectionBefore(pageBuilder, this.modal);
12637
12593
  }
12638
12594
  };
12639
12595
  __publicField(_AddSectionAboveCommand, "COMMAND_ID", "AddSectionAbove");
@@ -12646,7 +12602,7 @@ const _AddSectionBelowCommand = class _AddSectionBelowCommand {
12646
12602
  this.modal = modal;
12647
12603
  }
12648
12604
  execute(pageBuilder, args) {
12649
- addSectionAfter(pageBuilder, this.modal, args);
12605
+ addSectionAfter(pageBuilder, this.modal);
12650
12606
  }
12651
12607
  };
12652
12608
  __publicField(_AddSectionBelowCommand, "COMMAND_ID", "AddSectionBelow");
@@ -12858,6 +12814,8 @@ const createDefaultCommands = (modal) => {
12858
12814
  new OpenAddPartModalCommand(modal),
12859
12815
  new OpenAddWidgetModalCommand(modal),
12860
12816
  new AddPartCommand(modal),
12817
+ new AddSectionCommand(modal),
12818
+ new AddBlockCommand(modal),
12861
12819
  new AddSectionAboveCommand(modal),
12862
12820
  new AddSectionBelowCommand(modal),
12863
12821
  new AddBlockLeftCommand(),
@@ -13150,14 +13108,20 @@ const createDefaultToolButtonGroups = () => {
13150
13108
  groupId: "add",
13151
13109
  buttons: [
13152
13110
  {
13153
- buttonId: "core:openAddPartLayer",
13154
- caption: "Add Design Part...",
13111
+ buttonId: "core:addSection",
13112
+ caption: "Add Section",
13155
13113
  icon: "add_row_below",
13156
- handler: (modeler) => modeler.commandRegistry.executeCommand(OpenAddPartModalCommand.COMMAND_ID)
13114
+ handler: (modeler) => modeler.commandRegistry.executeCommand(AddSectionCommand.COMMAND_ID)
13157
13115
  },
13158
13116
  {
13159
- buttonId: "core:openAddWidgetLayer",
13160
- caption: "Add Widget...",
13117
+ buttonId: "core:addBlock",
13118
+ caption: "Add Block",
13119
+ icon: "add_column_right",
13120
+ handler: (modeler) => modeler.commandRegistry.executeCommand(AddBlockCommand.COMMAND_ID)
13121
+ },
13122
+ {
13123
+ buttonId: "core:addWidget",
13124
+ caption: "Add Widget",
13161
13125
  icon: "desktop_landscape_add",
13162
13126
  handler: (modeler) => modeler.commandRegistry.executeCommand(OpenAddWidgetModalCommand.COMMAND_ID)
13163
13127
  }
@@ -13363,6 +13327,8 @@ class PageBuilderEditorImpl {
13363
13327
  __publicField(this, "scale", ref(1));
13364
13328
  __publicField(this, "locale", ref("en"));
13365
13329
  __publicField(this, "locales", ref(["en"]));
13330
+ __publicField(this, "customWidgets", []);
13331
+ __publicField(this, "providers", {});
13366
13332
  this.model = new Model2();
13367
13333
  this.context = new PageBuilderContextImpl(this);
13368
13334
  this.editMode = "free";
@@ -13381,6 +13347,27 @@ class PageBuilderEditorImpl {
13381
13347
  setLocales(locales) {
13382
13348
  this.locales.value = locales || ["en"];
13383
13349
  }
13350
+ getCustomWidgetComponent(part) {
13351
+ const def = this.partManager.getPartDefinition(part.partName);
13352
+ if (def) {
13353
+ return def.component;
13354
+ }
13355
+ }
13356
+ getProvider(name) {
13357
+ return this.providers[name];
13358
+ }
13359
+ watchCustomWidgetData(part) {
13360
+ const def = this.partManager.getPartDefinition(part.partName);
13361
+ if (!def || !def.dataWatcher)
13362
+ return false;
13363
+ return def.dataWatcher(part.properties);
13364
+ }
13365
+ provideCustomWidgetData(part) {
13366
+ const def = this.partManager.getPartDefinition(part.partName);
13367
+ if (!def || !def.dataProvider)
13368
+ return Promise.resolve();
13369
+ return def.dataProvider(part.properties);
13370
+ }
13384
13371
  registerPlugin(plugin) {
13385
13372
  if (plugin.partDefinitions)
13386
13373
  this.partManager.registerPartDefinitions(plugin.partDefinitions);
@@ -13397,6 +13384,32 @@ class PageBuilderEditorImpl {
13397
13384
  if (plugin.toolButtonGroups)
13398
13385
  this.toolButtonRegistry.registerToolButtonGroups(plugin.toolButtonGroups);
13399
13386
  }
13387
+ registerCustomPlugin(plugin) {
13388
+ if (plugin.widgets) {
13389
+ const partDefinitions2 = {};
13390
+ plugin.widgets.forEach((v) => {
13391
+ const w = { ...v };
13392
+ w.partType = "Widget";
13393
+ w.creator = () => _sfc_main$q;
13394
+ w.propertyGroups = [...w.propertyGroups, ...defaultWidgetPropertyGroups()];
13395
+ partDefinitions2[v.partName] = w;
13396
+ const found = this.customWidgets.find((x) => x.partName === v.partName);
13397
+ if (!found) {
13398
+ this.customWidgets.push(w);
13399
+ }
13400
+ });
13401
+ this.partManager.registerPartDefinitions(partDefinitions2);
13402
+ }
13403
+ if (plugin.providers) {
13404
+ this.providers = {
13405
+ ...this.providers,
13406
+ ...plugin.providers
13407
+ };
13408
+ }
13409
+ if (plugin.propertyEditors) {
13410
+ this.partManager.registerPartPropertyEditors(plugin.propertyEditors);
13411
+ }
13412
+ }
13400
13413
  initData(content) {
13401
13414
  this.model.rootPart.pageBuilderId = this.instanceId;
13402
13415
  this.model.rootPart.language = this.locale.value;
@@ -13468,6 +13481,9 @@ class PageBuilderEditorImpl {
13468
13481
  ]
13469
13482
  });
13470
13483
  }
13484
+ getCustomWidgets() {
13485
+ return this.customWidgets;
13486
+ }
13471
13487
  getEmptyPageContent() {
13472
13488
  const block = new Block();
13473
13489
  const section = new Section();
@@ -13513,7 +13529,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
13513
13529
  const insertSection = (index) => {
13514
13530
  if (!props.page)
13515
13531
  return;
13516
- editor.commandRegistry.executeCommand(OpenAddPartModalCommand.COMMAND_ID);
13532
+ editor.commandRegistry.executeCommand(AddSectionCommand.COMMAND_ID);
13517
13533
  };
13518
13534
  return (_ctx, _cache) => {
13519
13535
  var _a;
@@ -14364,7 +14380,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14364
14380
  pageContent: {},
14365
14381
  locales: {},
14366
14382
  locale: {},
14367
- toolbarPlugin: {}
14383
+ toolbarPlugin: {},
14384
+ plugin: {}
14368
14385
  },
14369
14386
  setup(__props, { expose: __expose }) {
14370
14387
  const props = __props;
@@ -14377,6 +14394,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14377
14394
  pageBuilderEditor.setLocales(props.locales);
14378
14395
  if (props.locale)
14379
14396
  pageBuilderEditor.setLocale(props.locale);
14397
+ if (props.plugin)
14398
+ pageBuilderEditor.registerCustomPlugin(props.plugin);
14380
14399
  pageBuilderEditor.registerPlugin({
14381
14400
  // TODO
14382
14401
  commands: createDefaultCommands(modal)
@@ -14393,57 +14412,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14393
14412
  });
14394
14413
  const colorHistory = ref([]);
14395
14414
  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;
14415
+ const getPageContent = () => {
14416
+ const partIds = (pageBuilderEditor.model.rootPart.children || []).map((v) => v.partId);
14417
+ return pageBuilderEditor.model.serializePageModel(partIds);
14444
14418
  };
14445
14419
  __expose({
14446
- getLocalDesignPartContent
14420
+ getPageContent
14447
14421
  });
14448
14422
  return (_ctx, _cache) => {
14449
14423
  return openBlock(), createElementBlock("div", _hoisted_1, [
@@ -14470,12 +14444,12 @@ export {
14470
14444
  PAGE_BUILDER_KEY as c,
14471
14445
  PAGE_TYPE$1 as d,
14472
14446
  Page as e,
14473
- _sfc_main$q as f,
14447
+ _sfc_main$1$1 as f,
14474
14448
  PageBuilderViewerEvent as g,
14475
14449
  Part as h,
14476
- _sfc_main$3$1 as i,
14477
- _sfc_main$5$1 as j,
14478
- _sfc_main$2$1 as k,
14450
+ _sfc_main$q as i,
14451
+ _sfc_main$3$1 as j,
14452
+ _sfc_main$5$1 as k,
14479
14453
  _sfc_main$4$1 as l,
14480
14454
  RootPart as m,
14481
14455
  Section as n,
@@ -14487,5 +14461,6 @@ export {
14487
14461
  providePageBuilderViewer as t,
14488
14462
  usePageBuilderEditor as u,
14489
14463
  usePageBuilder as v,
14490
- usePageBuilderViewer as w
14464
+ widgetPartDefinitions as w,
14465
+ usePageBuilderViewer as x
14491
14466
  };