@g1cloud/page-builder-editor 1.0.0-alpha.50 → 1.0.0-alpha.51
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.
- package/dist/PageBuilderEditor.vue.d.ts +1 -0
- package/dist/{PbPropertyEditorColor-hFvMuUZC.js → PbPropertyEditorColor-BgdKzOQf.js} +1 -1
- package/dist/{PbPropertyEditorHtml-gzh9Nb2Q.js → PbPropertyEditorHtml-BYJROwnL.js} +1 -1
- package/dist/{PbPropertyEditorImage-D4wJ9fgi.js → PbPropertyEditorImage-DD4Da4xq.js} +1 -1
- package/dist/{PbPropertyEditorMultilineText-Bq1QUweO.js → PbPropertyEditorMultilineText-DvG2dPEk.js} +1 -1
- package/dist/{PbPropertyEditorText-BGIyzz1q.js → PbPropertyEditorText-C7ghs_Ju.js} +1 -1
- package/dist/{PbPropertyEditorYoutube-uRftqvVU.js → PbPropertyEditorYoutube-CM1sXU-v.js} +1 -1
- package/dist/{PbWidgetAddModal-DF7MRQUS.js → PbWidgetAddModal-DBa9-1_f.js} +1 -2
- package/dist/{index-B-YMeKky.js → index-UCsCqthV.js} +209 -179
- package/dist/index.d.ts +2 -1
- package/dist/model/command.d.ts +1 -0
- package/dist/model/page-builder-editor.d.ts +3 -2
- package/dist/model/plugin.d.ts +9 -1
- package/dist/page-builder-editor.js +1 -1
- package/dist/page-builder-editor.umd.cjs +202 -173
- package/package.json +3 -3
|
@@ -10,6 +10,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
10
10
|
plugin?: unknown;
|
|
11
11
|
}>>, {
|
|
12
12
|
getPageContent: () => string;
|
|
13
|
+
pastePageContent: (contentJson: string) => void;
|
|
13
14
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
15
|
"update-model": (modified: boolean) => void;
|
|
15
16
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createElementBlock, createElementVNode, withDirectives, unref, createVNode } from "vue";
|
|
2
2
|
import { vT, BSTextInput } from "@g1cloud/bluesea";
|
|
3
|
-
import { P as PbColorPicker } from "./index-
|
|
3
|
+
import { P as PbColorPicker } from "./index-UCsCqthV.js";
|
|
4
4
|
const _hoisted_1 = { class: "property-editor property-editor-color" };
|
|
5
5
|
const _hoisted_2 = { class: "title" };
|
|
6
6
|
const _hoisted_3 = { class: "bs-layout-horizontal flex-align-center color" };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createElementBlock, createElementVNode, withDirectives, unref, createTextVNode, defineAsyncComponent } from "vue";
|
|
2
2
|
import { useModal, vT } from "@g1cloud/bluesea";
|
|
3
|
-
import { u as usePageBuilderEditor } from "./index-
|
|
3
|
+
import { u as usePageBuilderEditor } from "./index-UCsCqthV.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 _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createElementBlock, createElementVNode, withDirectives, unref } from "vue";
|
|
2
|
-
import { u as usePageBuilderEditor } from "./index-
|
|
2
|
+
import { u as usePageBuilderEditor } from "./index-UCsCqthV.js";
|
|
3
3
|
import { useModal, vT } from "@g1cloud/bluesea";
|
|
4
4
|
const _hoisted_1 = { class: "property-editor property-editor-image flex-align-center" };
|
|
5
5
|
const _hoisted_2 = { class: "title" };
|
package/dist/{PbPropertyEditorMultilineText-Bq1QUweO.js → PbPropertyEditorMultilineText-DvG2dPEk.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, withDirectives, unref, createBlock } from "vue";
|
|
2
2
|
import { vT, BSMultiLangTextArea, BSTextArea } from "@g1cloud/bluesea";
|
|
3
|
-
import { u as usePageBuilderEditor } from "./index-
|
|
3
|
+
import { u as usePageBuilderEditor } from "./index-UCsCqthV.js";
|
|
4
4
|
const _hoisted_1 = { class: "property-editor property-editor-multiline-text" };
|
|
5
5
|
const _hoisted_2 = { class: "title" };
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, withDirectives, unref, createBlock } from "vue";
|
|
2
2
|
import { vT, BSMultiLangTextInput, BSTextInput } from "@g1cloud/bluesea";
|
|
3
|
-
import { u as usePageBuilderEditor } from "./index-
|
|
3
|
+
import { u as usePageBuilderEditor } from "./index-UCsCqthV.js";
|
|
4
4
|
const _hoisted_1 = { class: "property-editor property-editor-text flex-align-center" };
|
|
5
5
|
const _hoisted_2 = { class: "title" };
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createElementBlock, createElementVNode, withDirectives, unref } from "vue";
|
|
2
2
|
import { useModal, vT } from "@g1cloud/bluesea";
|
|
3
|
-
import { s as selectYoutubeVideo } from "./index-
|
|
3
|
+
import { s as selectYoutubeVideo } from "./index-UCsCqthV.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 _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, computed, openBlock, createBlock, unref, withCtx, createElementVNode, createElementBlock, Fragment, renderList, toDisplayString } from "vue";
|
|
2
2
|
import { useModalHandle, BSModalFrame } from "@g1cloud/bluesea";
|
|
3
|
-
import { w as widgetPartDefinitions } from "./index-
|
|
3
|
+
import { w as widgetPartDefinitions } from "./index-UCsCqthV.js";
|
|
4
4
|
const _hoisted_1 = { class: "bs-layout-vertical pb-part-add-modal" };
|
|
5
5
|
const _hoisted_2 = { class: "bs-layout-horizontal-wrap ml-16 mb-8 gap-8" };
|
|
6
6
|
const _hoisted_3 = ["onClick", "textContent"];
|
|
@@ -21,7 +21,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
21
21
|
const modalHandle = useModalHandle();
|
|
22
22
|
const customWidgets = computed(() => props.pageBuilder.getCustomWidgets());
|
|
23
23
|
const select = (partDefinition) => {
|
|
24
|
-
console.log(partDefinition);
|
|
25
24
|
emit("selectHandler", partDefinition);
|
|
26
25
|
modalHandle.close();
|
|
27
26
|
};
|
|
@@ -8268,15 +8268,15 @@ class PartManager {
|
|
|
8268
8268
|
const defaultPartPropertyEditors = () => {
|
|
8269
8269
|
return {
|
|
8270
8270
|
"readonly-text": () => defineAsyncComponent(() => import("./PbPropertyEditorReadonlyText-BJ5qx69O.js")),
|
|
8271
|
-
"text": () => defineAsyncComponent(() => import("./PbPropertyEditorText-
|
|
8271
|
+
"text": () => defineAsyncComponent(() => import("./PbPropertyEditorText-C7ghs_Ju.js")),
|
|
8272
8272
|
"number": () => defineAsyncComponent(() => import("./PbPropertyEditorNumber-B76ArSb5.js")),
|
|
8273
8273
|
"boolean": () => defineAsyncComponent(() => import("./PbPropertyEditorBoolean-c5CNiTpt.js")),
|
|
8274
|
-
"multiline-text": () => defineAsyncComponent(() => import("./PbPropertyEditorMultilineText-
|
|
8274
|
+
"multiline-text": () => defineAsyncComponent(() => import("./PbPropertyEditorMultilineText-DvG2dPEk.js")),
|
|
8275
8275
|
"select": () => defineAsyncComponent(() => import("./PbPropertyEditorSelect-B5sfulvx.js")),
|
|
8276
|
-
"color": () => defineAsyncComponent(() => import("./PbPropertyEditorColor-
|
|
8277
|
-
"image": () => defineAsyncComponent(() => import("./PbPropertyEditorImage-
|
|
8278
|
-
"html": () => defineAsyncComponent(() => import("./PbPropertyEditorHtml-
|
|
8279
|
-
"youtube": () => defineAsyncComponent(() => import("./PbPropertyEditorYoutube-
|
|
8276
|
+
"color": () => defineAsyncComponent(() => import("./PbPropertyEditorColor-BgdKzOQf.js")),
|
|
8277
|
+
"image": () => defineAsyncComponent(() => import("./PbPropertyEditorImage-DD4Da4xq.js")),
|
|
8278
|
+
"html": () => defineAsyncComponent(() => import("./PbPropertyEditorHtml-BYJROwnL.js")),
|
|
8279
|
+
"youtube": () => defineAsyncComponent(() => import("./PbPropertyEditorYoutube-CM1sXU-v.js"))
|
|
8280
8280
|
};
|
|
8281
8281
|
};
|
|
8282
8282
|
const getPropertyValueOfParts = (parts, propertyName) => {
|
|
@@ -12835,7 +12835,7 @@ __publicField(_OpenAddWidgetModalCommand, "COMMAND_ID", "OpenAddWidgetModal");
|
|
|
12835
12835
|
let OpenAddWidgetModalCommand = _OpenAddWidgetModalCommand;
|
|
12836
12836
|
const openWidgetAddModal = (modal, args, callback) => {
|
|
12837
12837
|
modal.openModal({
|
|
12838
|
-
component: defineAsyncComponent(() => import("./PbWidgetAddModal-
|
|
12838
|
+
component: defineAsyncComponent(() => import("./PbWidgetAddModal-DBa9-1_f.js")),
|
|
12839
12839
|
style: {
|
|
12840
12840
|
width: "80%",
|
|
12841
12841
|
height: "80%",
|
|
@@ -12911,6 +12911,177 @@ const insertParts = (pageBuilder, partId, index, parts, selectAfterInsert) => {
|
|
|
12911
12911
|
if (part) pageBuilder.context.setSelection([part]);
|
|
12912
12912
|
}
|
|
12913
12913
|
};
|
|
12914
|
+
const pasteContentJson = (pageBuilder, json) => {
|
|
12915
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12916
|
+
const object = JSON.parse(json);
|
|
12917
|
+
if (object.partType === ROOT_TYPE) {
|
|
12918
|
+
const rootPart = partFromJsonObject(object, true);
|
|
12919
|
+
if (!rootPart) throw new Error("Invalid data format");
|
|
12920
|
+
let partIdsToDelete = void 0;
|
|
12921
|
+
if ((_a = pageBuilder.model.rootPart.children) == null ? void 0 : _a.length) {
|
|
12922
|
+
partIdsToDelete = pageBuilder.model.rootPart.children.map((v) => v.partId);
|
|
12923
|
+
}
|
|
12924
|
+
const param = {
|
|
12925
|
+
delete: partIdsToDelete,
|
|
12926
|
+
insert: [
|
|
12927
|
+
{
|
|
12928
|
+
partId: pageBuilder.model.getRootPartId(),
|
|
12929
|
+
index: 0,
|
|
12930
|
+
parts: rootPart.children || []
|
|
12931
|
+
}
|
|
12932
|
+
]
|
|
12933
|
+
};
|
|
12934
|
+
pageBuilder.model.updateModel(param);
|
|
12935
|
+
} else if (Array.isArray(object) && object[0] && object[0].partType === PAGE_TYPE) {
|
|
12936
|
+
const newPages = pageBuilder.model.parseParts(json);
|
|
12937
|
+
if (!newPages) throw new Error("Invalid data format");
|
|
12938
|
+
const newPage = newPages[0];
|
|
12939
|
+
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
12940
|
+
if (!selectedPage) return;
|
|
12941
|
+
const pages = pageBuilder.model.rootPart.children;
|
|
12942
|
+
if (!pages) return;
|
|
12943
|
+
let index = 0;
|
|
12944
|
+
if (pages.length == 1) {
|
|
12945
|
+
newPage.properties = {
|
|
12946
|
+
...newPage.properties || {},
|
|
12947
|
+
name: "Page"
|
|
12948
|
+
};
|
|
12949
|
+
} else if (selectedPage === pages[0]) {
|
|
12950
|
+
newPage.properties = {
|
|
12951
|
+
...newPage.properties || {},
|
|
12952
|
+
name: "Page (Mobile)"
|
|
12953
|
+
};
|
|
12954
|
+
} else if (selectedPage === pages[1]) {
|
|
12955
|
+
newPage.properties = {
|
|
12956
|
+
...newPage.properties || {},
|
|
12957
|
+
name: "Page (PC)"
|
|
12958
|
+
};
|
|
12959
|
+
index = 1;
|
|
12960
|
+
}
|
|
12961
|
+
const param = {
|
|
12962
|
+
delete: [selectedPage.partId],
|
|
12963
|
+
insert: [
|
|
12964
|
+
{
|
|
12965
|
+
partId: pageBuilder.model.getRootPartId(),
|
|
12966
|
+
index,
|
|
12967
|
+
parts: [newPage]
|
|
12968
|
+
}
|
|
12969
|
+
]
|
|
12970
|
+
};
|
|
12971
|
+
pageBuilder.model.updateModel(param);
|
|
12972
|
+
} else {
|
|
12973
|
+
const parts = pageBuilder.model.parseParts(json);
|
|
12974
|
+
if (!parts) return;
|
|
12975
|
+
let pasteType = "";
|
|
12976
|
+
parts.forEach((part) => {
|
|
12977
|
+
if (part.partType === SECTION_TYPE) pasteType = SECTION_TYPE;
|
|
12978
|
+
else if (part.partType === BLOCK_TYPE && (!pasteType || pasteType === WIDGET_TYPE)) pasteType = BLOCK_TYPE;
|
|
12979
|
+
else if (part.partType === WIDGET_TYPE && !pasteType) pasteType = WIDGET_TYPE;
|
|
12980
|
+
});
|
|
12981
|
+
if (!pasteType) return;
|
|
12982
|
+
const partsToPaste = parts.map((part) => {
|
|
12983
|
+
if (pasteType === SECTION_TYPE) {
|
|
12984
|
+
if (part.partType === SECTION_TYPE) {
|
|
12985
|
+
return part;
|
|
12986
|
+
} else if (part.partType === BLOCK_TYPE) {
|
|
12987
|
+
const section = createSection(pageBuilder);
|
|
12988
|
+
if (!section) return;
|
|
12989
|
+
section.children = [part];
|
|
12990
|
+
return section;
|
|
12991
|
+
} else {
|
|
12992
|
+
const block = createBlock(pageBuilder);
|
|
12993
|
+
if (!block) return;
|
|
12994
|
+
block.children = [part];
|
|
12995
|
+
const section = createSection(pageBuilder);
|
|
12996
|
+
if (!section) return;
|
|
12997
|
+
section.children = [block];
|
|
12998
|
+
return section;
|
|
12999
|
+
}
|
|
13000
|
+
} else if (pasteType === BLOCK_TYPE) {
|
|
13001
|
+
if (part.partType === BLOCK_TYPE) {
|
|
13002
|
+
return part;
|
|
13003
|
+
} else {
|
|
13004
|
+
const block = createBlock(pageBuilder);
|
|
13005
|
+
if (!block) return;
|
|
13006
|
+
block.children = [part];
|
|
13007
|
+
return block;
|
|
13008
|
+
}
|
|
13009
|
+
} else {
|
|
13010
|
+
return part;
|
|
13011
|
+
}
|
|
13012
|
+
}).filter(notNull);
|
|
13013
|
+
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13014
|
+
const selected = pageBuilder.context.getSelectedParts()[0] || selectedPage;
|
|
13015
|
+
if (!selectedPage || !selected) return;
|
|
13016
|
+
let selectedWidget;
|
|
13017
|
+
if (selected && selected.isWidget()) selectedWidget = selected;
|
|
13018
|
+
if (selectedWidget && selectedWidget.isNestedWidget()) selectedWidget = selectedWidget.parent;
|
|
13019
|
+
let selectedBlock;
|
|
13020
|
+
if (selectedWidget) selectedBlock = selectedWidget.parent;
|
|
13021
|
+
else if (selected && selected.isBlock()) selectedBlock = selected;
|
|
13022
|
+
let selectedSection;
|
|
13023
|
+
if (selectedBlock) selectedSection = selectedBlock.parent;
|
|
13024
|
+
else if (selected && selected.isSection()) selectedSection = selected;
|
|
13025
|
+
let targetPartId;
|
|
13026
|
+
let targetIndex = -1;
|
|
13027
|
+
let partsToInsert;
|
|
13028
|
+
if (pasteType === SECTION_TYPE) {
|
|
13029
|
+
targetPartId = selectedPage.partId;
|
|
13030
|
+
targetIndex = selectedSection ? selectedPage.children.indexOf(selectedSection) + 1 : ((_b = selectedPage.children) == null ? void 0 : _b.length) || 0;
|
|
13031
|
+
partsToInsert = partsToPaste;
|
|
13032
|
+
} else if (pasteType === BLOCK_TYPE) {
|
|
13033
|
+
if (selectedSection) {
|
|
13034
|
+
targetPartId = selectedSection.partId;
|
|
13035
|
+
targetIndex = selectedBlock ? selectedSection.children.indexOf(selectedBlock) + 1 : ((_c = selectedSection.children) == null ? void 0 : _c.length) || 0;
|
|
13036
|
+
partsToInsert = partsToPaste;
|
|
13037
|
+
} else if ((_d = selectedPage.children) == null ? void 0 : _d.length) {
|
|
13038
|
+
selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13039
|
+
targetPartId = selectedSection.partId;
|
|
13040
|
+
targetIndex = ((_e = selectedSection.children) == null ? void 0 : _e.length) || 0;
|
|
13041
|
+
partsToInsert = partsToPaste;
|
|
13042
|
+
} else {
|
|
13043
|
+
const newSection = createSection(pageBuilder);
|
|
13044
|
+
if (!newSection) return;
|
|
13045
|
+
newSection.children = partsToPaste;
|
|
13046
|
+
targetPartId = selectedPage.partId;
|
|
13047
|
+
targetIndex = 0;
|
|
13048
|
+
partsToInsert = [newSection];
|
|
13049
|
+
}
|
|
13050
|
+
} else if (pasteType === WIDGET_TYPE) {
|
|
13051
|
+
if (selectedBlock) {
|
|
13052
|
+
targetPartId = selectedBlock.partId;
|
|
13053
|
+
targetIndex = selectedWidget ? selectedBlock.children.indexOf(selectedWidget) + 1 : ((_f = selectedBlock.children) == null ? void 0 : _f.length) || 0;
|
|
13054
|
+
partsToInsert = partsToPaste;
|
|
13055
|
+
} else if (selectedSection || ((_g = selectedPage.children) == null ? void 0 : _g.length)) {
|
|
13056
|
+
if (!selectedSection) selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13057
|
+
if ((_h = selectedSection.children) == null ? void 0 : _h.length) {
|
|
13058
|
+
selectedBlock = selectedSection.children[selectedSection.children.length - 1];
|
|
13059
|
+
targetPartId = selectedBlock.partId;
|
|
13060
|
+
targetIndex = ((_i = selectedBlock.children) == null ? void 0 : _i.length) || 0;
|
|
13061
|
+
partsToInsert = partsToPaste;
|
|
13062
|
+
} else {
|
|
13063
|
+
const newBlock = createBlock(pageBuilder);
|
|
13064
|
+
if (!newBlock) return;
|
|
13065
|
+
newBlock.children = partsToPaste;
|
|
13066
|
+
targetPartId = selectedSection.partId;
|
|
13067
|
+
targetIndex = 0;
|
|
13068
|
+
partsToInsert = [newBlock];
|
|
13069
|
+
}
|
|
13070
|
+
} else {
|
|
13071
|
+
const newBlock = createBlock(pageBuilder);
|
|
13072
|
+
const newSection = createSection(pageBuilder);
|
|
13073
|
+
if (!newBlock || !newSection) return;
|
|
13074
|
+
newSection.children = [newBlock];
|
|
13075
|
+
newBlock.children = partsToPaste;
|
|
13076
|
+
targetPartId = selectedPage.partId;
|
|
13077
|
+
targetIndex = 0;
|
|
13078
|
+
partsToInsert = [newSection];
|
|
13079
|
+
}
|
|
13080
|
+
}
|
|
13081
|
+
if (!targetPartId || targetIndex < 0 || !partsToInsert) return;
|
|
13082
|
+
insertParts(pageBuilder, targetPartId, targetIndex, partsToInsert, false);
|
|
13083
|
+
}
|
|
13084
|
+
};
|
|
12914
13085
|
const _AddPartCommand = class _AddPartCommand {
|
|
12915
13086
|
constructor(modal) {
|
|
12916
13087
|
__publicField(this, "commandId", _AddPartCommand.COMMAND_ID);
|
|
@@ -13396,176 +13567,8 @@ const _PastePartCommand = class _PastePartCommand {
|
|
|
13396
13567
|
__publicField(this, "commandId", _PastePartCommand.COMMAND_ID);
|
|
13397
13568
|
}
|
|
13398
13569
|
async execute(pageBuilder) {
|
|
13399
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
13400
13570
|
const json = await navigator.clipboard.readText();
|
|
13401
|
-
|
|
13402
|
-
if (object.partType === ROOT_TYPE) {
|
|
13403
|
-
const rootPart = partFromJsonObject(object, true);
|
|
13404
|
-
if (!rootPart) throw new Error("Invalid data format");
|
|
13405
|
-
let partIdsToDelete = void 0;
|
|
13406
|
-
if ((_a = pageBuilder.model.rootPart.children) == null ? void 0 : _a.length) {
|
|
13407
|
-
partIdsToDelete = pageBuilder.model.rootPart.children.map((v) => v.partId);
|
|
13408
|
-
}
|
|
13409
|
-
const param = {
|
|
13410
|
-
delete: partIdsToDelete,
|
|
13411
|
-
insert: [
|
|
13412
|
-
{
|
|
13413
|
-
partId: pageBuilder.model.getRootPartId(),
|
|
13414
|
-
index: 0,
|
|
13415
|
-
parts: rootPart.children || []
|
|
13416
|
-
}
|
|
13417
|
-
]
|
|
13418
|
-
};
|
|
13419
|
-
pageBuilder.model.updateModel(param);
|
|
13420
|
-
} else if (Array.isArray(object) && object[0] && object[0].partType === PAGE_TYPE) {
|
|
13421
|
-
const newPages = pageBuilder.model.parseParts(json);
|
|
13422
|
-
if (!newPages) throw new Error("Invalid data format");
|
|
13423
|
-
const newPage = newPages[0];
|
|
13424
|
-
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13425
|
-
if (!selectedPage) return;
|
|
13426
|
-
const pages = pageBuilder.model.rootPart.children;
|
|
13427
|
-
if (!pages) return;
|
|
13428
|
-
let index = 0;
|
|
13429
|
-
if (pages.length == 1) {
|
|
13430
|
-
newPage.properties = {
|
|
13431
|
-
...newPage.properties || {},
|
|
13432
|
-
name: "Page"
|
|
13433
|
-
};
|
|
13434
|
-
} else if (selectedPage === pages[0]) {
|
|
13435
|
-
newPage.properties = {
|
|
13436
|
-
...newPage.properties || {},
|
|
13437
|
-
name: "Page (Mobile)"
|
|
13438
|
-
};
|
|
13439
|
-
} else if (selectedPage === pages[1]) {
|
|
13440
|
-
newPage.properties = {
|
|
13441
|
-
...newPage.properties || {},
|
|
13442
|
-
name: "Page (PC)"
|
|
13443
|
-
};
|
|
13444
|
-
index = 1;
|
|
13445
|
-
}
|
|
13446
|
-
const param = {
|
|
13447
|
-
delete: [selectedPage.partId],
|
|
13448
|
-
insert: [
|
|
13449
|
-
{
|
|
13450
|
-
partId: pageBuilder.model.getRootPartId(),
|
|
13451
|
-
index,
|
|
13452
|
-
parts: [newPage]
|
|
13453
|
-
}
|
|
13454
|
-
]
|
|
13455
|
-
};
|
|
13456
|
-
pageBuilder.model.updateModel(param);
|
|
13457
|
-
} else {
|
|
13458
|
-
const parts = pageBuilder.model.parseParts(json);
|
|
13459
|
-
if (!parts) return;
|
|
13460
|
-
let pasteType = "";
|
|
13461
|
-
parts.forEach((part) => {
|
|
13462
|
-
if (part.partType === SECTION_TYPE) pasteType = SECTION_TYPE;
|
|
13463
|
-
else if (part.partType === BLOCK_TYPE && (!pasteType || pasteType === WIDGET_TYPE)) pasteType = BLOCK_TYPE;
|
|
13464
|
-
else if (part.partType === WIDGET_TYPE && !pasteType) pasteType = WIDGET_TYPE;
|
|
13465
|
-
});
|
|
13466
|
-
if (!pasteType) return;
|
|
13467
|
-
const partsToPaste = parts.map((part) => {
|
|
13468
|
-
if (pasteType === SECTION_TYPE) {
|
|
13469
|
-
if (part.partType === SECTION_TYPE) {
|
|
13470
|
-
return part;
|
|
13471
|
-
} else if (part.partType === BLOCK_TYPE) {
|
|
13472
|
-
const section = createSection(pageBuilder);
|
|
13473
|
-
if (!section) return;
|
|
13474
|
-
section.children = [part];
|
|
13475
|
-
return section;
|
|
13476
|
-
} else {
|
|
13477
|
-
const block = createBlock(pageBuilder);
|
|
13478
|
-
if (!block) return;
|
|
13479
|
-
block.children = [part];
|
|
13480
|
-
const section = createSection(pageBuilder);
|
|
13481
|
-
if (!section) return;
|
|
13482
|
-
section.children = [block];
|
|
13483
|
-
return section;
|
|
13484
|
-
}
|
|
13485
|
-
} else if (pasteType === BLOCK_TYPE) {
|
|
13486
|
-
if (part.partType === BLOCK_TYPE) {
|
|
13487
|
-
return part;
|
|
13488
|
-
} else {
|
|
13489
|
-
const block = createBlock(pageBuilder);
|
|
13490
|
-
if (!block) return;
|
|
13491
|
-
block.children = [part];
|
|
13492
|
-
return block;
|
|
13493
|
-
}
|
|
13494
|
-
} else {
|
|
13495
|
-
return part;
|
|
13496
|
-
}
|
|
13497
|
-
}).filter(notNull);
|
|
13498
|
-
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13499
|
-
const selected = pageBuilder.context.getSelectedParts()[0] || selectedPage;
|
|
13500
|
-
if (!selectedPage || !selected) return;
|
|
13501
|
-
let selectedWidget;
|
|
13502
|
-
if (selected && selected.isWidget()) selectedWidget = selected;
|
|
13503
|
-
if (selectedWidget && selectedWidget.isNestedWidget()) selectedWidget = selectedWidget.parent;
|
|
13504
|
-
let selectedBlock;
|
|
13505
|
-
if (selectedWidget) selectedBlock = selectedWidget.parent;
|
|
13506
|
-
else if (selected && selected.isBlock()) selectedBlock = selected;
|
|
13507
|
-
let selectedSection;
|
|
13508
|
-
if (selectedBlock) selectedSection = selectedBlock.parent;
|
|
13509
|
-
else if (selected && selected.isSection()) selectedSection = selected;
|
|
13510
|
-
let targetPartId;
|
|
13511
|
-
let targetIndex = -1;
|
|
13512
|
-
let partsToInsert;
|
|
13513
|
-
if (pasteType === SECTION_TYPE) {
|
|
13514
|
-
targetPartId = selectedPage.partId;
|
|
13515
|
-
targetIndex = selectedSection ? selectedPage.children.indexOf(selectedSection) + 1 : ((_b = selectedPage.children) == null ? void 0 : _b.length) || 0;
|
|
13516
|
-
partsToInsert = partsToPaste;
|
|
13517
|
-
} else if (pasteType === BLOCK_TYPE) {
|
|
13518
|
-
if (selectedSection) {
|
|
13519
|
-
targetPartId = selectedSection.partId;
|
|
13520
|
-
targetIndex = selectedBlock ? selectedSection.children.indexOf(selectedBlock) + 1 : ((_c = selectedSection.children) == null ? void 0 : _c.length) || 0;
|
|
13521
|
-
partsToInsert = partsToPaste;
|
|
13522
|
-
} else if ((_d = selectedPage.children) == null ? void 0 : _d.length) {
|
|
13523
|
-
selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13524
|
-
targetPartId = selectedSection.partId;
|
|
13525
|
-
targetIndex = ((_e = selectedSection.children) == null ? void 0 : _e.length) || 0;
|
|
13526
|
-
partsToInsert = partsToPaste;
|
|
13527
|
-
} else {
|
|
13528
|
-
const newSection = createSection(pageBuilder);
|
|
13529
|
-
if (!newSection) return;
|
|
13530
|
-
newSection.children = partsToPaste;
|
|
13531
|
-
targetPartId = selectedPage.partId;
|
|
13532
|
-
targetIndex = 0;
|
|
13533
|
-
partsToInsert = [newSection];
|
|
13534
|
-
}
|
|
13535
|
-
} else if (pasteType === WIDGET_TYPE) {
|
|
13536
|
-
if (selectedBlock) {
|
|
13537
|
-
targetPartId = selectedBlock.partId;
|
|
13538
|
-
targetIndex = selectedWidget ? selectedBlock.children.indexOf(selectedWidget) + 1 : ((_f = selectedBlock.children) == null ? void 0 : _f.length) || 0;
|
|
13539
|
-
partsToInsert = partsToPaste;
|
|
13540
|
-
} else if (selectedSection || ((_g = selectedPage.children) == null ? void 0 : _g.length)) {
|
|
13541
|
-
if (!selectedSection) selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13542
|
-
if ((_h = selectedSection.children) == null ? void 0 : _h.length) {
|
|
13543
|
-
selectedBlock = selectedSection.children[selectedSection.children.length - 1];
|
|
13544
|
-
targetPartId = selectedBlock.partId;
|
|
13545
|
-
targetIndex = ((_i = selectedBlock.children) == null ? void 0 : _i.length) || 0;
|
|
13546
|
-
partsToInsert = partsToPaste;
|
|
13547
|
-
} else {
|
|
13548
|
-
const newBlock = createBlock(pageBuilder);
|
|
13549
|
-
if (!newBlock) return;
|
|
13550
|
-
newBlock.children = partsToPaste;
|
|
13551
|
-
targetPartId = selectedSection.partId;
|
|
13552
|
-
targetIndex = 0;
|
|
13553
|
-
partsToInsert = [newBlock];
|
|
13554
|
-
}
|
|
13555
|
-
} else {
|
|
13556
|
-
const newBlock = createBlock(pageBuilder);
|
|
13557
|
-
const newSection = createSection(pageBuilder);
|
|
13558
|
-
if (!newBlock || !newSection) return;
|
|
13559
|
-
newSection.children = [newBlock];
|
|
13560
|
-
newBlock.children = partsToPaste;
|
|
13561
|
-
targetPartId = selectedPage.partId;
|
|
13562
|
-
targetIndex = 0;
|
|
13563
|
-
partsToInsert = [newSection];
|
|
13564
|
-
}
|
|
13565
|
-
}
|
|
13566
|
-
if (!targetPartId || targetIndex < 0 || !partsToInsert) return;
|
|
13567
|
-
insertParts(pageBuilder, targetPartId, targetIndex, partsToInsert, false);
|
|
13568
|
-
}
|
|
13571
|
+
pasteContentJson(pageBuilder, json);
|
|
13569
13572
|
}
|
|
13570
13573
|
};
|
|
13571
13574
|
__publicField(_PastePartCommand, "COMMAND_ID", "PastePart");
|
|
@@ -14144,7 +14147,7 @@ class PageBuilderEditorImpl {
|
|
|
14144
14147
|
if (plugin.keyHandlers) this.keyHandlers.appendKeyHandlers(plugin.keyHandlers);
|
|
14145
14148
|
if (plugin.toolButtonGroups) this.toolButtonRegistry.registerToolButtonGroups(plugin.toolButtonGroups);
|
|
14146
14149
|
}
|
|
14147
|
-
registerCustomPlugin(plugin) {
|
|
14150
|
+
registerCustomPlugin(plugin, modal) {
|
|
14148
14151
|
if (plugin.widgets) {
|
|
14149
14152
|
const partDefinitions2 = {};
|
|
14150
14153
|
plugin.widgets.forEach((group) => {
|
|
@@ -14183,6 +14186,29 @@ class PageBuilderEditorImpl {
|
|
|
14183
14186
|
this.externalCssContent = plugin.css.content;
|
|
14184
14187
|
}
|
|
14185
14188
|
}
|
|
14189
|
+
if (plugin.contextMenus) {
|
|
14190
|
+
const self = this;
|
|
14191
|
+
const contextMenus = plugin.contextMenus.map((menu) => {
|
|
14192
|
+
return {
|
|
14193
|
+
commandId: menu.menuId,
|
|
14194
|
+
groupId: "external",
|
|
14195
|
+
precedence: 10,
|
|
14196
|
+
getMenuItem(pageBuilder) {
|
|
14197
|
+
const selected = self.context.getSelectedParts();
|
|
14198
|
+
if (menu.visible(selected)) {
|
|
14199
|
+
return {
|
|
14200
|
+
menuId: menu.menuId,
|
|
14201
|
+
caption: menu.caption,
|
|
14202
|
+
handler() {
|
|
14203
|
+
menu.handler(selected, self.model, modal);
|
|
14204
|
+
}
|
|
14205
|
+
};
|
|
14206
|
+
}
|
|
14207
|
+
}
|
|
14208
|
+
};
|
|
14209
|
+
});
|
|
14210
|
+
this.contextMenuRegistry.registerContextMenus(contextMenus);
|
|
14211
|
+
}
|
|
14186
14212
|
}
|
|
14187
14213
|
initData(data) {
|
|
14188
14214
|
const _data = JSON.parse(data || "{}") || {};
|
|
@@ -16414,7 +16440,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16414
16440
|
};
|
|
16415
16441
|
if (props.locales) pageBuilderEditor.setLocales(props.locales);
|
|
16416
16442
|
if (props.locale) pageBuilderEditor.setLocale(props.locale);
|
|
16417
|
-
if (props.plugin) pageBuilderEditor.registerCustomPlugin(props.plugin);
|
|
16443
|
+
if (props.plugin) pageBuilderEditor.registerCustomPlugin(props.plugin, modal);
|
|
16418
16444
|
pageBuilderEditor.registerPlugin({
|
|
16419
16445
|
// TODO
|
|
16420
16446
|
commands: createDefaultCommands(modal)
|
|
@@ -16434,8 +16460,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16434
16460
|
const getPageContent = () => {
|
|
16435
16461
|
return pageBuilderEditor.model.serializeModel((part) => pageBuilderEditor.extractMedia(part));
|
|
16436
16462
|
};
|
|
16463
|
+
const pastePageContent = (contentJson) => {
|
|
16464
|
+
pasteContentJson(pageBuilderEditor, contentJson);
|
|
16465
|
+
};
|
|
16437
16466
|
__expose({
|
|
16438
|
-
getPageContent
|
|
16467
|
+
getPageContent,
|
|
16468
|
+
pastePageContent
|
|
16439
16469
|
});
|
|
16440
16470
|
return (_ctx, _cache) => {
|
|
16441
16471
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Model as PageBuilderEditorModel } from './model/model.ts';
|
|
1
2
|
import { PartDefinition, PartDefinitionGroup } from './model/part-definintion.ts';
|
|
2
3
|
import { PartProperty } from './model/part-property.ts';
|
|
3
4
|
|
|
4
5
|
export { default as PageBuilderEditor } from './PageBuilderEditor.vue';
|
|
5
|
-
export type { PartProperty, PartDefinitionGroup, PartDefinition };
|
|
6
|
+
export type { PartProperty, PartDefinitionGroup, PartDefinition, PageBuilderEditorModel };
|
|
6
7
|
export * from './model/event';
|
|
7
8
|
export * from './model/plugin';
|
|
8
9
|
export * from '@g1cloud/page-builder-viewer';
|
package/dist/model/command.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare class OpenAddWidgetModalCommand implements Command {
|
|
|
37
37
|
export declare const createSection: (pageBuilder: PageBuilderEditor) => IPart | undefined;
|
|
38
38
|
export declare const createBlock: (pageBuilder: PageBuilderEditor) => IPart | undefined;
|
|
39
39
|
export declare const findLeafPart: (part: IPart | undefined) => IPart | undefined;
|
|
40
|
+
export declare const pasteContentJson: (pageBuilder: PageBuilderEditor, json: string) => void;
|
|
40
41
|
export declare class AddPartCommand implements Command {
|
|
41
42
|
private modal;
|
|
42
43
|
static readonly COMMAND_ID = "AddPart";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BSModal } from '@g1cloud/bluesea';
|
|
1
2
|
import { PartDefinitionGroup } from './part-definintion.ts';
|
|
2
3
|
import { ContextMenuRegistry, ContextMenuRegistryImpl, KeyHandlers, PageBuilderContext, PageBuilderContextImpl } from './context.ts';
|
|
3
4
|
import { ToolButtonRegistry } from './toolbar.ts';
|
|
@@ -28,7 +29,7 @@ export interface PageBuilderEditor extends PageBuilder {
|
|
|
28
29
|
locales: Ref<string[]>;
|
|
29
30
|
onModelUpdated?: (modified: boolean) => void;
|
|
30
31
|
registerPlugin(plugin: PageBuilderPlugin): void;
|
|
31
|
-
registerCustomPlugin(plugin: any): void;
|
|
32
|
+
registerCustomPlugin(plugin: any, modal: BSModal): void;
|
|
32
33
|
initData(data?: string): void;
|
|
33
34
|
undo(): void;
|
|
34
35
|
redo(): void;
|
|
@@ -68,7 +69,7 @@ export declare class PageBuilderEditorImpl implements PageBuilderEditor {
|
|
|
68
69
|
getCustomWidgetComponent(part: IPart): Component | undefined;
|
|
69
70
|
getProvider(name: string): (args?: any, callback?: (result?: any) => void) => unknown;
|
|
70
71
|
registerPlugin(plugin: PageBuilderPlugin): void;
|
|
71
|
-
registerCustomPlugin(plugin: any): void;
|
|
72
|
+
registerCustomPlugin(plugin: any, modal: BSModal): void;
|
|
72
73
|
initData(data?: string): void;
|
|
73
74
|
undo(): void;
|
|
74
75
|
redo(): void;
|
package/dist/model/plugin.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model } from './model.ts';
|
|
2
|
+
import { IPart } from '@g1cloud/page-builder-viewer';
|
|
3
|
+
import { BSModal, MultiLangText } from '@g1cloud/bluesea';
|
|
2
4
|
import { Component } from 'vue';
|
|
3
5
|
import { PartPropertyEditor, PartPropertyGroupEditor, PartPropertyType } from './part-property.ts';
|
|
4
6
|
import { PartDefinition } from './part-definintion.ts';
|
|
@@ -24,6 +26,12 @@ export type PageBuilderToolbarPlugin = {
|
|
|
24
26
|
[key: string]: Function | Function[];
|
|
25
27
|
};
|
|
26
28
|
};
|
|
29
|
+
export type PageBuilderContextMenu = {
|
|
30
|
+
menuId: string;
|
|
31
|
+
caption: MultiLangText;
|
|
32
|
+
visible: (selected: IPart[]) => boolean;
|
|
33
|
+
handler: (selected: IPart[], model: Model, modal: BSModal) => void;
|
|
34
|
+
};
|
|
27
35
|
export type ImageProviderArg = {
|
|
28
36
|
modal: BSModal;
|
|
29
37
|
mediaTypes: string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B, b, M, c, d, e, _, a, f, g, h, i, j, k, l, m, n, o, R, p, S, q, W, r, t, v, x, y, z, A, C, D } from "./index-
|
|
1
|
+
import { B, b, M, c, d, e, _, a, f, g, h, i, j, k, l, m, n, o, R, p, S, q, W, r, t, v, x, y, z, A, C, D } from "./index-UCsCqthV.js";
|
|
2
2
|
export {
|
|
3
3
|
B as BLOCK_TYPE,
|
|
4
4
|
b as Block,
|
|
@@ -12912,6 +12912,177 @@ ${_html.style}
|
|
|
12912
12912
|
if (part) pageBuilder.context.setSelection([part]);
|
|
12913
12913
|
}
|
|
12914
12914
|
};
|
|
12915
|
+
const pasteContentJson = (pageBuilder, json) => {
|
|
12916
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12917
|
+
const object = JSON.parse(json);
|
|
12918
|
+
if (object.partType === ROOT_TYPE) {
|
|
12919
|
+
const rootPart = partFromJsonObject(object, true);
|
|
12920
|
+
if (!rootPart) throw new Error("Invalid data format");
|
|
12921
|
+
let partIdsToDelete = void 0;
|
|
12922
|
+
if ((_a = pageBuilder.model.rootPart.children) == null ? void 0 : _a.length) {
|
|
12923
|
+
partIdsToDelete = pageBuilder.model.rootPart.children.map((v) => v.partId);
|
|
12924
|
+
}
|
|
12925
|
+
const param = {
|
|
12926
|
+
delete: partIdsToDelete,
|
|
12927
|
+
insert: [
|
|
12928
|
+
{
|
|
12929
|
+
partId: pageBuilder.model.getRootPartId(),
|
|
12930
|
+
index: 0,
|
|
12931
|
+
parts: rootPart.children || []
|
|
12932
|
+
}
|
|
12933
|
+
]
|
|
12934
|
+
};
|
|
12935
|
+
pageBuilder.model.updateModel(param);
|
|
12936
|
+
} else if (Array.isArray(object) && object[0] && object[0].partType === PAGE_TYPE) {
|
|
12937
|
+
const newPages = pageBuilder.model.parseParts(json);
|
|
12938
|
+
if (!newPages) throw new Error("Invalid data format");
|
|
12939
|
+
const newPage = newPages[0];
|
|
12940
|
+
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
12941
|
+
if (!selectedPage) return;
|
|
12942
|
+
const pages = pageBuilder.model.rootPart.children;
|
|
12943
|
+
if (!pages) return;
|
|
12944
|
+
let index = 0;
|
|
12945
|
+
if (pages.length == 1) {
|
|
12946
|
+
newPage.properties = {
|
|
12947
|
+
...newPage.properties || {},
|
|
12948
|
+
name: "Page"
|
|
12949
|
+
};
|
|
12950
|
+
} else if (selectedPage === pages[0]) {
|
|
12951
|
+
newPage.properties = {
|
|
12952
|
+
...newPage.properties || {},
|
|
12953
|
+
name: "Page (Mobile)"
|
|
12954
|
+
};
|
|
12955
|
+
} else if (selectedPage === pages[1]) {
|
|
12956
|
+
newPage.properties = {
|
|
12957
|
+
...newPage.properties || {},
|
|
12958
|
+
name: "Page (PC)"
|
|
12959
|
+
};
|
|
12960
|
+
index = 1;
|
|
12961
|
+
}
|
|
12962
|
+
const param = {
|
|
12963
|
+
delete: [selectedPage.partId],
|
|
12964
|
+
insert: [
|
|
12965
|
+
{
|
|
12966
|
+
partId: pageBuilder.model.getRootPartId(),
|
|
12967
|
+
index,
|
|
12968
|
+
parts: [newPage]
|
|
12969
|
+
}
|
|
12970
|
+
]
|
|
12971
|
+
};
|
|
12972
|
+
pageBuilder.model.updateModel(param);
|
|
12973
|
+
} else {
|
|
12974
|
+
const parts = pageBuilder.model.parseParts(json);
|
|
12975
|
+
if (!parts) return;
|
|
12976
|
+
let pasteType = "";
|
|
12977
|
+
parts.forEach((part) => {
|
|
12978
|
+
if (part.partType === SECTION_TYPE) pasteType = SECTION_TYPE;
|
|
12979
|
+
else if (part.partType === BLOCK_TYPE && (!pasteType || pasteType === WIDGET_TYPE)) pasteType = BLOCK_TYPE;
|
|
12980
|
+
else if (part.partType === WIDGET_TYPE && !pasteType) pasteType = WIDGET_TYPE;
|
|
12981
|
+
});
|
|
12982
|
+
if (!pasteType) return;
|
|
12983
|
+
const partsToPaste = parts.map((part) => {
|
|
12984
|
+
if (pasteType === SECTION_TYPE) {
|
|
12985
|
+
if (part.partType === SECTION_TYPE) {
|
|
12986
|
+
return part;
|
|
12987
|
+
} else if (part.partType === BLOCK_TYPE) {
|
|
12988
|
+
const section = createSection(pageBuilder);
|
|
12989
|
+
if (!section) return;
|
|
12990
|
+
section.children = [part];
|
|
12991
|
+
return section;
|
|
12992
|
+
} else {
|
|
12993
|
+
const block = createBlock(pageBuilder);
|
|
12994
|
+
if (!block) return;
|
|
12995
|
+
block.children = [part];
|
|
12996
|
+
const section = createSection(pageBuilder);
|
|
12997
|
+
if (!section) return;
|
|
12998
|
+
section.children = [block];
|
|
12999
|
+
return section;
|
|
13000
|
+
}
|
|
13001
|
+
} else if (pasteType === BLOCK_TYPE) {
|
|
13002
|
+
if (part.partType === BLOCK_TYPE) {
|
|
13003
|
+
return part;
|
|
13004
|
+
} else {
|
|
13005
|
+
const block = createBlock(pageBuilder);
|
|
13006
|
+
if (!block) return;
|
|
13007
|
+
block.children = [part];
|
|
13008
|
+
return block;
|
|
13009
|
+
}
|
|
13010
|
+
} else {
|
|
13011
|
+
return part;
|
|
13012
|
+
}
|
|
13013
|
+
}).filter(bluesea.notNull);
|
|
13014
|
+
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13015
|
+
const selected = pageBuilder.context.getSelectedParts()[0] || selectedPage;
|
|
13016
|
+
if (!selectedPage || !selected) return;
|
|
13017
|
+
let selectedWidget;
|
|
13018
|
+
if (selected && selected.isWidget()) selectedWidget = selected;
|
|
13019
|
+
if (selectedWidget && selectedWidget.isNestedWidget()) selectedWidget = selectedWidget.parent;
|
|
13020
|
+
let selectedBlock;
|
|
13021
|
+
if (selectedWidget) selectedBlock = selectedWidget.parent;
|
|
13022
|
+
else if (selected && selected.isBlock()) selectedBlock = selected;
|
|
13023
|
+
let selectedSection;
|
|
13024
|
+
if (selectedBlock) selectedSection = selectedBlock.parent;
|
|
13025
|
+
else if (selected && selected.isSection()) selectedSection = selected;
|
|
13026
|
+
let targetPartId;
|
|
13027
|
+
let targetIndex = -1;
|
|
13028
|
+
let partsToInsert;
|
|
13029
|
+
if (pasteType === SECTION_TYPE) {
|
|
13030
|
+
targetPartId = selectedPage.partId;
|
|
13031
|
+
targetIndex = selectedSection ? selectedPage.children.indexOf(selectedSection) + 1 : ((_b = selectedPage.children) == null ? void 0 : _b.length) || 0;
|
|
13032
|
+
partsToInsert = partsToPaste;
|
|
13033
|
+
} else if (pasteType === BLOCK_TYPE) {
|
|
13034
|
+
if (selectedSection) {
|
|
13035
|
+
targetPartId = selectedSection.partId;
|
|
13036
|
+
targetIndex = selectedBlock ? selectedSection.children.indexOf(selectedBlock) + 1 : ((_c = selectedSection.children) == null ? void 0 : _c.length) || 0;
|
|
13037
|
+
partsToInsert = partsToPaste;
|
|
13038
|
+
} else if ((_d = selectedPage.children) == null ? void 0 : _d.length) {
|
|
13039
|
+
selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13040
|
+
targetPartId = selectedSection.partId;
|
|
13041
|
+
targetIndex = ((_e = selectedSection.children) == null ? void 0 : _e.length) || 0;
|
|
13042
|
+
partsToInsert = partsToPaste;
|
|
13043
|
+
} else {
|
|
13044
|
+
const newSection = createSection(pageBuilder);
|
|
13045
|
+
if (!newSection) return;
|
|
13046
|
+
newSection.children = partsToPaste;
|
|
13047
|
+
targetPartId = selectedPage.partId;
|
|
13048
|
+
targetIndex = 0;
|
|
13049
|
+
partsToInsert = [newSection];
|
|
13050
|
+
}
|
|
13051
|
+
} else if (pasteType === WIDGET_TYPE) {
|
|
13052
|
+
if (selectedBlock) {
|
|
13053
|
+
targetPartId = selectedBlock.partId;
|
|
13054
|
+
targetIndex = selectedWidget ? selectedBlock.children.indexOf(selectedWidget) + 1 : ((_f = selectedBlock.children) == null ? void 0 : _f.length) || 0;
|
|
13055
|
+
partsToInsert = partsToPaste;
|
|
13056
|
+
} else if (selectedSection || ((_g = selectedPage.children) == null ? void 0 : _g.length)) {
|
|
13057
|
+
if (!selectedSection) selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13058
|
+
if ((_h = selectedSection.children) == null ? void 0 : _h.length) {
|
|
13059
|
+
selectedBlock = selectedSection.children[selectedSection.children.length - 1];
|
|
13060
|
+
targetPartId = selectedBlock.partId;
|
|
13061
|
+
targetIndex = ((_i = selectedBlock.children) == null ? void 0 : _i.length) || 0;
|
|
13062
|
+
partsToInsert = partsToPaste;
|
|
13063
|
+
} else {
|
|
13064
|
+
const newBlock = createBlock(pageBuilder);
|
|
13065
|
+
if (!newBlock) return;
|
|
13066
|
+
newBlock.children = partsToPaste;
|
|
13067
|
+
targetPartId = selectedSection.partId;
|
|
13068
|
+
targetIndex = 0;
|
|
13069
|
+
partsToInsert = [newBlock];
|
|
13070
|
+
}
|
|
13071
|
+
} else {
|
|
13072
|
+
const newBlock = createBlock(pageBuilder);
|
|
13073
|
+
const newSection = createSection(pageBuilder);
|
|
13074
|
+
if (!newBlock || !newSection) return;
|
|
13075
|
+
newSection.children = [newBlock];
|
|
13076
|
+
newBlock.children = partsToPaste;
|
|
13077
|
+
targetPartId = selectedPage.partId;
|
|
13078
|
+
targetIndex = 0;
|
|
13079
|
+
partsToInsert = [newSection];
|
|
13080
|
+
}
|
|
13081
|
+
}
|
|
13082
|
+
if (!targetPartId || targetIndex < 0 || !partsToInsert) return;
|
|
13083
|
+
insertParts(pageBuilder, targetPartId, targetIndex, partsToInsert, false);
|
|
13084
|
+
}
|
|
13085
|
+
};
|
|
12915
13086
|
const _AddPartCommand = class _AddPartCommand {
|
|
12916
13087
|
constructor(modal) {
|
|
12917
13088
|
__publicField(this, "commandId", _AddPartCommand.COMMAND_ID);
|
|
@@ -13397,176 +13568,8 @@ ${_html.style}
|
|
|
13397
13568
|
__publicField(this, "commandId", _PastePartCommand.COMMAND_ID);
|
|
13398
13569
|
}
|
|
13399
13570
|
async execute(pageBuilder) {
|
|
13400
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
13401
13571
|
const json = await navigator.clipboard.readText();
|
|
13402
|
-
|
|
13403
|
-
if (object.partType === ROOT_TYPE) {
|
|
13404
|
-
const rootPart = partFromJsonObject(object, true);
|
|
13405
|
-
if (!rootPart) throw new Error("Invalid data format");
|
|
13406
|
-
let partIdsToDelete = void 0;
|
|
13407
|
-
if ((_a = pageBuilder.model.rootPart.children) == null ? void 0 : _a.length) {
|
|
13408
|
-
partIdsToDelete = pageBuilder.model.rootPart.children.map((v) => v.partId);
|
|
13409
|
-
}
|
|
13410
|
-
const param = {
|
|
13411
|
-
delete: partIdsToDelete,
|
|
13412
|
-
insert: [
|
|
13413
|
-
{
|
|
13414
|
-
partId: pageBuilder.model.getRootPartId(),
|
|
13415
|
-
index: 0,
|
|
13416
|
-
parts: rootPart.children || []
|
|
13417
|
-
}
|
|
13418
|
-
]
|
|
13419
|
-
};
|
|
13420
|
-
pageBuilder.model.updateModel(param);
|
|
13421
|
-
} else if (Array.isArray(object) && object[0] && object[0].partType === PAGE_TYPE) {
|
|
13422
|
-
const newPages = pageBuilder.model.parseParts(json);
|
|
13423
|
-
if (!newPages) throw new Error("Invalid data format");
|
|
13424
|
-
const newPage = newPages[0];
|
|
13425
|
-
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13426
|
-
if (!selectedPage) return;
|
|
13427
|
-
const pages = pageBuilder.model.rootPart.children;
|
|
13428
|
-
if (!pages) return;
|
|
13429
|
-
let index = 0;
|
|
13430
|
-
if (pages.length == 1) {
|
|
13431
|
-
newPage.properties = {
|
|
13432
|
-
...newPage.properties || {},
|
|
13433
|
-
name: "Page"
|
|
13434
|
-
};
|
|
13435
|
-
} else if (selectedPage === pages[0]) {
|
|
13436
|
-
newPage.properties = {
|
|
13437
|
-
...newPage.properties || {},
|
|
13438
|
-
name: "Page (Mobile)"
|
|
13439
|
-
};
|
|
13440
|
-
} else if (selectedPage === pages[1]) {
|
|
13441
|
-
newPage.properties = {
|
|
13442
|
-
...newPage.properties || {},
|
|
13443
|
-
name: "Page (PC)"
|
|
13444
|
-
};
|
|
13445
|
-
index = 1;
|
|
13446
|
-
}
|
|
13447
|
-
const param = {
|
|
13448
|
-
delete: [selectedPage.partId],
|
|
13449
|
-
insert: [
|
|
13450
|
-
{
|
|
13451
|
-
partId: pageBuilder.model.getRootPartId(),
|
|
13452
|
-
index,
|
|
13453
|
-
parts: [newPage]
|
|
13454
|
-
}
|
|
13455
|
-
]
|
|
13456
|
-
};
|
|
13457
|
-
pageBuilder.model.updateModel(param);
|
|
13458
|
-
} else {
|
|
13459
|
-
const parts = pageBuilder.model.parseParts(json);
|
|
13460
|
-
if (!parts) return;
|
|
13461
|
-
let pasteType = "";
|
|
13462
|
-
parts.forEach((part) => {
|
|
13463
|
-
if (part.partType === SECTION_TYPE) pasteType = SECTION_TYPE;
|
|
13464
|
-
else if (part.partType === BLOCK_TYPE && (!pasteType || pasteType === WIDGET_TYPE)) pasteType = BLOCK_TYPE;
|
|
13465
|
-
else if (part.partType === WIDGET_TYPE && !pasteType) pasteType = WIDGET_TYPE;
|
|
13466
|
-
});
|
|
13467
|
-
if (!pasteType) return;
|
|
13468
|
-
const partsToPaste = parts.map((part) => {
|
|
13469
|
-
if (pasteType === SECTION_TYPE) {
|
|
13470
|
-
if (part.partType === SECTION_TYPE) {
|
|
13471
|
-
return part;
|
|
13472
|
-
} else if (part.partType === BLOCK_TYPE) {
|
|
13473
|
-
const section = createSection(pageBuilder);
|
|
13474
|
-
if (!section) return;
|
|
13475
|
-
section.children = [part];
|
|
13476
|
-
return section;
|
|
13477
|
-
} else {
|
|
13478
|
-
const block = createBlock(pageBuilder);
|
|
13479
|
-
if (!block) return;
|
|
13480
|
-
block.children = [part];
|
|
13481
|
-
const section = createSection(pageBuilder);
|
|
13482
|
-
if (!section) return;
|
|
13483
|
-
section.children = [block];
|
|
13484
|
-
return section;
|
|
13485
|
-
}
|
|
13486
|
-
} else if (pasteType === BLOCK_TYPE) {
|
|
13487
|
-
if (part.partType === BLOCK_TYPE) {
|
|
13488
|
-
return part;
|
|
13489
|
-
} else {
|
|
13490
|
-
const block = createBlock(pageBuilder);
|
|
13491
|
-
if (!block) return;
|
|
13492
|
-
block.children = [part];
|
|
13493
|
-
return block;
|
|
13494
|
-
}
|
|
13495
|
-
} else {
|
|
13496
|
-
return part;
|
|
13497
|
-
}
|
|
13498
|
-
}).filter(bluesea.notNull);
|
|
13499
|
-
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13500
|
-
const selected = pageBuilder.context.getSelectedParts()[0] || selectedPage;
|
|
13501
|
-
if (!selectedPage || !selected) return;
|
|
13502
|
-
let selectedWidget;
|
|
13503
|
-
if (selected && selected.isWidget()) selectedWidget = selected;
|
|
13504
|
-
if (selectedWidget && selectedWidget.isNestedWidget()) selectedWidget = selectedWidget.parent;
|
|
13505
|
-
let selectedBlock;
|
|
13506
|
-
if (selectedWidget) selectedBlock = selectedWidget.parent;
|
|
13507
|
-
else if (selected && selected.isBlock()) selectedBlock = selected;
|
|
13508
|
-
let selectedSection;
|
|
13509
|
-
if (selectedBlock) selectedSection = selectedBlock.parent;
|
|
13510
|
-
else if (selected && selected.isSection()) selectedSection = selected;
|
|
13511
|
-
let targetPartId;
|
|
13512
|
-
let targetIndex = -1;
|
|
13513
|
-
let partsToInsert;
|
|
13514
|
-
if (pasteType === SECTION_TYPE) {
|
|
13515
|
-
targetPartId = selectedPage.partId;
|
|
13516
|
-
targetIndex = selectedSection ? selectedPage.children.indexOf(selectedSection) + 1 : ((_b = selectedPage.children) == null ? void 0 : _b.length) || 0;
|
|
13517
|
-
partsToInsert = partsToPaste;
|
|
13518
|
-
} else if (pasteType === BLOCK_TYPE) {
|
|
13519
|
-
if (selectedSection) {
|
|
13520
|
-
targetPartId = selectedSection.partId;
|
|
13521
|
-
targetIndex = selectedBlock ? selectedSection.children.indexOf(selectedBlock) + 1 : ((_c = selectedSection.children) == null ? void 0 : _c.length) || 0;
|
|
13522
|
-
partsToInsert = partsToPaste;
|
|
13523
|
-
} else if ((_d = selectedPage.children) == null ? void 0 : _d.length) {
|
|
13524
|
-
selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13525
|
-
targetPartId = selectedSection.partId;
|
|
13526
|
-
targetIndex = ((_e = selectedSection.children) == null ? void 0 : _e.length) || 0;
|
|
13527
|
-
partsToInsert = partsToPaste;
|
|
13528
|
-
} else {
|
|
13529
|
-
const newSection = createSection(pageBuilder);
|
|
13530
|
-
if (!newSection) return;
|
|
13531
|
-
newSection.children = partsToPaste;
|
|
13532
|
-
targetPartId = selectedPage.partId;
|
|
13533
|
-
targetIndex = 0;
|
|
13534
|
-
partsToInsert = [newSection];
|
|
13535
|
-
}
|
|
13536
|
-
} else if (pasteType === WIDGET_TYPE) {
|
|
13537
|
-
if (selectedBlock) {
|
|
13538
|
-
targetPartId = selectedBlock.partId;
|
|
13539
|
-
targetIndex = selectedWidget ? selectedBlock.children.indexOf(selectedWidget) + 1 : ((_f = selectedBlock.children) == null ? void 0 : _f.length) || 0;
|
|
13540
|
-
partsToInsert = partsToPaste;
|
|
13541
|
-
} else if (selectedSection || ((_g = selectedPage.children) == null ? void 0 : _g.length)) {
|
|
13542
|
-
if (!selectedSection) selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13543
|
-
if ((_h = selectedSection.children) == null ? void 0 : _h.length) {
|
|
13544
|
-
selectedBlock = selectedSection.children[selectedSection.children.length - 1];
|
|
13545
|
-
targetPartId = selectedBlock.partId;
|
|
13546
|
-
targetIndex = ((_i = selectedBlock.children) == null ? void 0 : _i.length) || 0;
|
|
13547
|
-
partsToInsert = partsToPaste;
|
|
13548
|
-
} else {
|
|
13549
|
-
const newBlock = createBlock(pageBuilder);
|
|
13550
|
-
if (!newBlock) return;
|
|
13551
|
-
newBlock.children = partsToPaste;
|
|
13552
|
-
targetPartId = selectedSection.partId;
|
|
13553
|
-
targetIndex = 0;
|
|
13554
|
-
partsToInsert = [newBlock];
|
|
13555
|
-
}
|
|
13556
|
-
} else {
|
|
13557
|
-
const newBlock = createBlock(pageBuilder);
|
|
13558
|
-
const newSection = createSection(pageBuilder);
|
|
13559
|
-
if (!newBlock || !newSection) return;
|
|
13560
|
-
newSection.children = [newBlock];
|
|
13561
|
-
newBlock.children = partsToPaste;
|
|
13562
|
-
targetPartId = selectedPage.partId;
|
|
13563
|
-
targetIndex = 0;
|
|
13564
|
-
partsToInsert = [newSection];
|
|
13565
|
-
}
|
|
13566
|
-
}
|
|
13567
|
-
if (!targetPartId || targetIndex < 0 || !partsToInsert) return;
|
|
13568
|
-
insertParts(pageBuilder, targetPartId, targetIndex, partsToInsert, false);
|
|
13569
|
-
}
|
|
13572
|
+
pasteContentJson(pageBuilder, json);
|
|
13570
13573
|
}
|
|
13571
13574
|
};
|
|
13572
13575
|
__publicField(_PastePartCommand, "COMMAND_ID", "PastePart");
|
|
@@ -14145,7 +14148,7 @@ ${_html.style}
|
|
|
14145
14148
|
if (plugin.keyHandlers) this.keyHandlers.appendKeyHandlers(plugin.keyHandlers);
|
|
14146
14149
|
if (plugin.toolButtonGroups) this.toolButtonRegistry.registerToolButtonGroups(plugin.toolButtonGroups);
|
|
14147
14150
|
}
|
|
14148
|
-
registerCustomPlugin(plugin) {
|
|
14151
|
+
registerCustomPlugin(plugin, modal) {
|
|
14149
14152
|
if (plugin.widgets) {
|
|
14150
14153
|
const partDefinitions2 = {};
|
|
14151
14154
|
plugin.widgets.forEach((group) => {
|
|
@@ -14184,6 +14187,29 @@ ${_html.style}
|
|
|
14184
14187
|
this.externalCssContent = plugin.css.content;
|
|
14185
14188
|
}
|
|
14186
14189
|
}
|
|
14190
|
+
if (plugin.contextMenus) {
|
|
14191
|
+
const self2 = this;
|
|
14192
|
+
const contextMenus = plugin.contextMenus.map((menu) => {
|
|
14193
|
+
return {
|
|
14194
|
+
commandId: menu.menuId,
|
|
14195
|
+
groupId: "external",
|
|
14196
|
+
precedence: 10,
|
|
14197
|
+
getMenuItem(pageBuilder) {
|
|
14198
|
+
const selected = self2.context.getSelectedParts();
|
|
14199
|
+
if (menu.visible(selected)) {
|
|
14200
|
+
return {
|
|
14201
|
+
menuId: menu.menuId,
|
|
14202
|
+
caption: menu.caption,
|
|
14203
|
+
handler() {
|
|
14204
|
+
menu.handler(selected, self2.model, modal);
|
|
14205
|
+
}
|
|
14206
|
+
};
|
|
14207
|
+
}
|
|
14208
|
+
}
|
|
14209
|
+
};
|
|
14210
|
+
});
|
|
14211
|
+
this.contextMenuRegistry.registerContextMenus(contextMenus);
|
|
14212
|
+
}
|
|
14187
14213
|
}
|
|
14188
14214
|
initData(data) {
|
|
14189
14215
|
const _data = JSON.parse(data || "{}") || {};
|
|
@@ -16415,7 +16441,7 @@ ${_html.style}
|
|
|
16415
16441
|
};
|
|
16416
16442
|
if (props.locales) pageBuilderEditor.setLocales(props.locales);
|
|
16417
16443
|
if (props.locale) pageBuilderEditor.setLocale(props.locale);
|
|
16418
|
-
if (props.plugin) pageBuilderEditor.registerCustomPlugin(props.plugin);
|
|
16444
|
+
if (props.plugin) pageBuilderEditor.registerCustomPlugin(props.plugin, modal);
|
|
16419
16445
|
pageBuilderEditor.registerPlugin({
|
|
16420
16446
|
// TODO
|
|
16421
16447
|
commands: createDefaultCommands(modal)
|
|
@@ -16435,8 +16461,12 @@ ${_html.style}
|
|
|
16435
16461
|
const getPageContent = () => {
|
|
16436
16462
|
return pageBuilderEditor.model.serializeModel((part) => pageBuilderEditor.extractMedia(part));
|
|
16437
16463
|
};
|
|
16464
|
+
const pastePageContent = (contentJson) => {
|
|
16465
|
+
pasteContentJson(pageBuilderEditor, contentJson);
|
|
16466
|
+
};
|
|
16438
16467
|
__expose({
|
|
16439
|
-
getPageContent
|
|
16468
|
+
getPageContent,
|
|
16469
|
+
pastePageContent
|
|
16440
16470
|
});
|
|
16441
16471
|
return (_ctx, _cache) => {
|
|
16442
16472
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
|
|
@@ -17005,7 +17035,6 @@ ${_html.style}
|
|
|
17005
17035
|
const modalHandle = bluesea.useModalHandle();
|
|
17006
17036
|
const customWidgets = vue.computed(() => props.pageBuilder.getCustomWidgets());
|
|
17007
17037
|
const select = (partDefinition) => {
|
|
17008
|
-
console.log(partDefinition);
|
|
17009
17038
|
emit("selectHandler", partDefinition);
|
|
17010
17039
|
modalHandle.close();
|
|
17011
17040
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g1cloud/page-builder-editor",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.51",
|
|
5
5
|
"engins": {
|
|
6
6
|
"node": ">= 20.0.0"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"author": "zag@g1project.net",
|
|
17
17
|
"license": "LicenseRef-LICENSE",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@g1cloud/bluesea": "5.0.0-alpha.
|
|
19
|
+
"@g1cloud/bluesea": "5.0.0-alpha.92",
|
|
20
20
|
"vue3-youtube": "^0.1.9"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"vue-router": "^4.4.3",
|
|
31
31
|
"vue3-click-away": "^1.2.4",
|
|
32
32
|
"yjs": "^13.6.14",
|
|
33
|
-
"@g1cloud/page-builder-viewer": "1.0.0-alpha.
|
|
33
|
+
"@g1cloud/page-builder-viewer": "1.0.0-alpha.51"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.12.7",
|