@g1cloud/page-builder-editor 1.0.0-alpha.50 → 1.0.0-alpha.52
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-Db3UUuLc.js} +1 -1
- package/dist/{PbPropertyEditorHtml-gzh9Nb2Q.js → PbPropertyEditorHtml-CoxUtACW.js} +1 -1
- package/dist/{PbPropertyEditorImage-D4wJ9fgi.js → PbPropertyEditorImage-B73oOweb.js} +1 -1
- package/dist/{PbPropertyEditorMultilineText-Bq1QUweO.js → PbPropertyEditorMultilineText-C43eDCgk.js} +1 -1
- package/dist/{PbPropertyEditorText-BGIyzz1q.js → PbPropertyEditorText-DmTjpx6J.js} +1 -1
- package/dist/{PbPropertyEditorYoutube-uRftqvVU.js → PbPropertyEditorYoutube-DPX-k3c5.js} +1 -1
- package/dist/{PbWidgetAddModal-DF7MRQUS.js → PbWidgetAddModal-CoT-pyXr.js} +1 -2
- package/dist/{index-B-YMeKky.js → index-DkU6TZPE.js} +255 -194
- package/dist/index.d.ts +2 -1
- package/dist/model/command.d.ts +1 -0
- package/dist/model/default-part-property-group.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 +248 -188
- package/package.json +3 -3
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";
|
|
@@ -11,5 +11,6 @@ export declare const alignItemsGroup: () => PartPropertyGroup;
|
|
|
11
11
|
export declare const alignSelfGroup: () => PartPropertyGroup;
|
|
12
12
|
export declare const backgroundGroup: () => PartPropertyGroup;
|
|
13
13
|
export declare const borderGroup: () => PartPropertyGroup;
|
|
14
|
+
export declare const hideParentGroup: () => PartPropertyGroup;
|
|
14
15
|
export declare const defaultPropertyGroups: () => PartPropertyGroup[];
|
|
15
16
|
export declare const defaultWidgetPropertyGroups: () => PartPropertyGroup[];
|
|
@@ -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-DkU6TZPE.js";
|
|
2
2
|
export {
|
|
3
3
|
B as BLOCK_TYPE,
|
|
4
4
|
b as Block,
|
|
@@ -6892,8 +6892,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6892
6892
|
const emit = __emit;
|
|
6893
6893
|
const visible = vue.ref(true);
|
|
6894
6894
|
const updateVisible = (value) => {
|
|
6895
|
+
var _a;
|
|
6895
6896
|
visible.value = value;
|
|
6896
|
-
emit("update:visible", value);
|
|
6897
|
+
emit("update:visible", value, !!((_a = props.part.properties) == null ? void 0 : _a.hideParentWhenInvisible));
|
|
6897
6898
|
};
|
|
6898
6899
|
const classNames = vue.computed(() => [getPartClassName(props.part), props.part.getClassNames()]);
|
|
6899
6900
|
const styleTag = vue.computed(() => props.part.getStyleTag());
|
|
@@ -6937,11 +6938,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6937
6938
|
const props = __props;
|
|
6938
6939
|
const emit = __emit;
|
|
6939
6940
|
const visible = vue.ref(true);
|
|
6940
|
-
const
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
emit("update:visible", visible.value);
|
|
6941
|
+
const updateVisible = (value, hideParentWhenInvisible) => {
|
|
6942
|
+
if (hideParentWhenInvisible && !value) {
|
|
6943
|
+
visible.value = false;
|
|
6944
|
+
}
|
|
6945
|
+
emit("update:visible", visible.value, hideParentWhenInvisible);
|
|
6945
6946
|
};
|
|
6946
6947
|
const classNames = vue.computed(() => [getPartClassName(props.part), props.part.getClassNames()]);
|
|
6947
6948
|
const styleTag = vue.computed(() => props.part.getStyleTag());
|
|
@@ -6964,8 +6965,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6964
6965
|
return vue.openBlock(), vue.createBlock(_sfc_main$c$1, {
|
|
6965
6966
|
key: child.partId,
|
|
6966
6967
|
part: child,
|
|
6967
|
-
"onUpdate:visible": (value) => updateVisible(
|
|
6968
|
-
}, null, 8, ["part"
|
|
6968
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = (value, hideParentWhenInvisible) => updateVisible(value, hideParentWhenInvisible))
|
|
6969
|
+
}, null, 8, ["part"]);
|
|
6969
6970
|
}), 128)) : vue.createCommentVNode("", true)
|
|
6970
6971
|
], 14, _hoisted_1$a$1), [
|
|
6971
6972
|
[vue.vShow, visible.value]
|
|
@@ -6984,10 +6985,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6984
6985
|
setup(__props) {
|
|
6985
6986
|
const props = __props;
|
|
6986
6987
|
const visible = vue.ref(true);
|
|
6987
|
-
const
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6988
|
+
const updateVisible = (value, hideParentWhenInvisible) => {
|
|
6989
|
+
if (hideParentWhenInvisible && !value) {
|
|
6990
|
+
visible.value = false;
|
|
6991
|
+
}
|
|
6991
6992
|
};
|
|
6992
6993
|
const classNames = vue.computed(() => [getPartClassName(props.part), props.part.getClassNames()]);
|
|
6993
6994
|
const styleTag = vue.computed(() => props.part.getStyleTag());
|
|
@@ -7011,8 +7012,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7011
7012
|
key: child.partId,
|
|
7012
7013
|
"is-mobile-page": _ctx.isMobilePage,
|
|
7013
7014
|
part: child,
|
|
7014
|
-
"onUpdate:visible": (value) => updateVisible(
|
|
7015
|
-
}, null, 8, ["is-mobile-page", "part"
|
|
7015
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = (value, hideParentWhenInvisible) => updateVisible(value, hideParentWhenInvisible))
|
|
7016
|
+
}, null, 8, ["is-mobile-page", "part"]);
|
|
7016
7017
|
}), 128)) : vue.createCommentVNode("", true)
|
|
7017
7018
|
], 14, _hoisted_1$9$1), [
|
|
7018
7019
|
[vue.vShow, visible.value]
|
|
@@ -7475,6 +7476,7 @@ ${_html.style}
|
|
|
7475
7476
|
parsePartContent(partContent) {
|
|
7476
7477
|
const part = this.createPart(partContent.partType);
|
|
7477
7478
|
if (!part) return;
|
|
7479
|
+
part.partId = partContent.partId;
|
|
7478
7480
|
part.partType = partContent.partType;
|
|
7479
7481
|
part.partName = partContent.partName;
|
|
7480
7482
|
part.properties = partContent.properties ? JSON.parse(JSON.stringify(partContent.properties)) : null;
|
|
@@ -12269,11 +12271,24 @@ ${_html.style}
|
|
|
12269
12271
|
propertyGroupEditor: () => _sfc_main$v
|
|
12270
12272
|
};
|
|
12271
12273
|
};
|
|
12274
|
+
const hideParentGroup = () => {
|
|
12275
|
+
return {
|
|
12276
|
+
groupName: "hideParentGroup",
|
|
12277
|
+
caption: "pb.prop.hideParent",
|
|
12278
|
+
properties: [
|
|
12279
|
+
{
|
|
12280
|
+
propertyName: "hideParentWhenInvisible",
|
|
12281
|
+
caption: "pb.prop.hideParentWhenInvisible",
|
|
12282
|
+
propertyType: "boolean"
|
|
12283
|
+
}
|
|
12284
|
+
]
|
|
12285
|
+
};
|
|
12286
|
+
};
|
|
12272
12287
|
const defaultPropertyGroups = () => {
|
|
12273
12288
|
return [layoutGroup(), alignGroup(), sizeGroup(), marginGroup(), paddingGroup(), backgroundGroup(), commonGroup()];
|
|
12274
12289
|
};
|
|
12275
12290
|
const defaultWidgetPropertyGroups = () => {
|
|
12276
|
-
return [alignSelfGroup(), positionGroup(), sizeGroup(), marginGroup(), paddingGroup(), borderGroup(), backgroundGroup(), commonGroup()];
|
|
12291
|
+
return [alignSelfGroup(), positionGroup(), sizeGroup(), marginGroup(), paddingGroup(), borderGroup(), backgroundGroup(), commonGroup(), hideParentGroup()];
|
|
12277
12292
|
};
|
|
12278
12293
|
const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
|
|
12279
12294
|
__name: "PbContainerWidget",
|
|
@@ -12912,6 +12927,177 @@ ${_html.style}
|
|
|
12912
12927
|
if (part) pageBuilder.context.setSelection([part]);
|
|
12913
12928
|
}
|
|
12914
12929
|
};
|
|
12930
|
+
const pasteContentJson = (pageBuilder, json) => {
|
|
12931
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12932
|
+
const object = JSON.parse(json);
|
|
12933
|
+
if (object.partType === ROOT_TYPE) {
|
|
12934
|
+
const rootPart = partFromJsonObject(object, true);
|
|
12935
|
+
if (!rootPart) throw new Error("Invalid data format");
|
|
12936
|
+
let partIdsToDelete = void 0;
|
|
12937
|
+
if ((_a = pageBuilder.model.rootPart.children) == null ? void 0 : _a.length) {
|
|
12938
|
+
partIdsToDelete = pageBuilder.model.rootPart.children.map((v) => v.partId);
|
|
12939
|
+
}
|
|
12940
|
+
const param = {
|
|
12941
|
+
delete: partIdsToDelete,
|
|
12942
|
+
insert: [
|
|
12943
|
+
{
|
|
12944
|
+
partId: pageBuilder.model.getRootPartId(),
|
|
12945
|
+
index: 0,
|
|
12946
|
+
parts: rootPart.children || []
|
|
12947
|
+
}
|
|
12948
|
+
]
|
|
12949
|
+
};
|
|
12950
|
+
pageBuilder.model.updateModel(param);
|
|
12951
|
+
} else if (Array.isArray(object) && object[0] && object[0].partType === PAGE_TYPE) {
|
|
12952
|
+
const newPages = pageBuilder.model.parseParts(json);
|
|
12953
|
+
if (!newPages) throw new Error("Invalid data format");
|
|
12954
|
+
const newPage = newPages[0];
|
|
12955
|
+
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
12956
|
+
if (!selectedPage) return;
|
|
12957
|
+
const pages = pageBuilder.model.rootPart.children;
|
|
12958
|
+
if (!pages) return;
|
|
12959
|
+
let index = 0;
|
|
12960
|
+
if (pages.length == 1) {
|
|
12961
|
+
newPage.properties = {
|
|
12962
|
+
...newPage.properties || {},
|
|
12963
|
+
name: "Page"
|
|
12964
|
+
};
|
|
12965
|
+
} else if (selectedPage === pages[0]) {
|
|
12966
|
+
newPage.properties = {
|
|
12967
|
+
...newPage.properties || {},
|
|
12968
|
+
name: "Page (Mobile)"
|
|
12969
|
+
};
|
|
12970
|
+
} else if (selectedPage === pages[1]) {
|
|
12971
|
+
newPage.properties = {
|
|
12972
|
+
...newPage.properties || {},
|
|
12973
|
+
name: "Page (PC)"
|
|
12974
|
+
};
|
|
12975
|
+
index = 1;
|
|
12976
|
+
}
|
|
12977
|
+
const param = {
|
|
12978
|
+
delete: [selectedPage.partId],
|
|
12979
|
+
insert: [
|
|
12980
|
+
{
|
|
12981
|
+
partId: pageBuilder.model.getRootPartId(),
|
|
12982
|
+
index,
|
|
12983
|
+
parts: [newPage]
|
|
12984
|
+
}
|
|
12985
|
+
]
|
|
12986
|
+
};
|
|
12987
|
+
pageBuilder.model.updateModel(param);
|
|
12988
|
+
} else {
|
|
12989
|
+
const parts = pageBuilder.model.parseParts(json);
|
|
12990
|
+
if (!parts) return;
|
|
12991
|
+
let pasteType = "";
|
|
12992
|
+
parts.forEach((part) => {
|
|
12993
|
+
if (part.partType === SECTION_TYPE) pasteType = SECTION_TYPE;
|
|
12994
|
+
else if (part.partType === BLOCK_TYPE && (!pasteType || pasteType === WIDGET_TYPE)) pasteType = BLOCK_TYPE;
|
|
12995
|
+
else if (part.partType === WIDGET_TYPE && !pasteType) pasteType = WIDGET_TYPE;
|
|
12996
|
+
});
|
|
12997
|
+
if (!pasteType) return;
|
|
12998
|
+
const partsToPaste = parts.map((part) => {
|
|
12999
|
+
if (pasteType === SECTION_TYPE) {
|
|
13000
|
+
if (part.partType === SECTION_TYPE) {
|
|
13001
|
+
return part;
|
|
13002
|
+
} else if (part.partType === BLOCK_TYPE) {
|
|
13003
|
+
const section = createSection(pageBuilder);
|
|
13004
|
+
if (!section) return;
|
|
13005
|
+
section.children = [part];
|
|
13006
|
+
return section;
|
|
13007
|
+
} else {
|
|
13008
|
+
const block = createBlock(pageBuilder);
|
|
13009
|
+
if (!block) return;
|
|
13010
|
+
block.children = [part];
|
|
13011
|
+
const section = createSection(pageBuilder);
|
|
13012
|
+
if (!section) return;
|
|
13013
|
+
section.children = [block];
|
|
13014
|
+
return section;
|
|
13015
|
+
}
|
|
13016
|
+
} else if (pasteType === BLOCK_TYPE) {
|
|
13017
|
+
if (part.partType === BLOCK_TYPE) {
|
|
13018
|
+
return part;
|
|
13019
|
+
} else {
|
|
13020
|
+
const block = createBlock(pageBuilder);
|
|
13021
|
+
if (!block) return;
|
|
13022
|
+
block.children = [part];
|
|
13023
|
+
return block;
|
|
13024
|
+
}
|
|
13025
|
+
} else {
|
|
13026
|
+
return part;
|
|
13027
|
+
}
|
|
13028
|
+
}).filter(bluesea.notNull);
|
|
13029
|
+
const selectedPage = pageBuilder.context.getSelectedPage();
|
|
13030
|
+
const selected = pageBuilder.context.getSelectedParts()[0] || selectedPage;
|
|
13031
|
+
if (!selectedPage || !selected) return;
|
|
13032
|
+
let selectedWidget;
|
|
13033
|
+
if (selected && selected.isWidget()) selectedWidget = selected;
|
|
13034
|
+
if (selectedWidget && selectedWidget.isNestedWidget()) selectedWidget = selectedWidget.parent;
|
|
13035
|
+
let selectedBlock;
|
|
13036
|
+
if (selectedWidget) selectedBlock = selectedWidget.parent;
|
|
13037
|
+
else if (selected && selected.isBlock()) selectedBlock = selected;
|
|
13038
|
+
let selectedSection;
|
|
13039
|
+
if (selectedBlock) selectedSection = selectedBlock.parent;
|
|
13040
|
+
else if (selected && selected.isSection()) selectedSection = selected;
|
|
13041
|
+
let targetPartId;
|
|
13042
|
+
let targetIndex = -1;
|
|
13043
|
+
let partsToInsert;
|
|
13044
|
+
if (pasteType === SECTION_TYPE) {
|
|
13045
|
+
targetPartId = selectedPage.partId;
|
|
13046
|
+
targetIndex = selectedSection ? selectedPage.children.indexOf(selectedSection) + 1 : ((_b = selectedPage.children) == null ? void 0 : _b.length) || 0;
|
|
13047
|
+
partsToInsert = partsToPaste;
|
|
13048
|
+
} else if (pasteType === BLOCK_TYPE) {
|
|
13049
|
+
if (selectedSection) {
|
|
13050
|
+
targetPartId = selectedSection.partId;
|
|
13051
|
+
targetIndex = selectedBlock ? selectedSection.children.indexOf(selectedBlock) + 1 : ((_c = selectedSection.children) == null ? void 0 : _c.length) || 0;
|
|
13052
|
+
partsToInsert = partsToPaste;
|
|
13053
|
+
} else if ((_d = selectedPage.children) == null ? void 0 : _d.length) {
|
|
13054
|
+
selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13055
|
+
targetPartId = selectedSection.partId;
|
|
13056
|
+
targetIndex = ((_e = selectedSection.children) == null ? void 0 : _e.length) || 0;
|
|
13057
|
+
partsToInsert = partsToPaste;
|
|
13058
|
+
} else {
|
|
13059
|
+
const newSection = createSection(pageBuilder);
|
|
13060
|
+
if (!newSection) return;
|
|
13061
|
+
newSection.children = partsToPaste;
|
|
13062
|
+
targetPartId = selectedPage.partId;
|
|
13063
|
+
targetIndex = 0;
|
|
13064
|
+
partsToInsert = [newSection];
|
|
13065
|
+
}
|
|
13066
|
+
} else if (pasteType === WIDGET_TYPE) {
|
|
13067
|
+
if (selectedBlock) {
|
|
13068
|
+
targetPartId = selectedBlock.partId;
|
|
13069
|
+
targetIndex = selectedWidget ? selectedBlock.children.indexOf(selectedWidget) + 1 : ((_f = selectedBlock.children) == null ? void 0 : _f.length) || 0;
|
|
13070
|
+
partsToInsert = partsToPaste;
|
|
13071
|
+
} else if (selectedSection || ((_g = selectedPage.children) == null ? void 0 : _g.length)) {
|
|
13072
|
+
if (!selectedSection) selectedSection = selectedPage.children[selectedPage.children.length - 1];
|
|
13073
|
+
if ((_h = selectedSection.children) == null ? void 0 : _h.length) {
|
|
13074
|
+
selectedBlock = selectedSection.children[selectedSection.children.length - 1];
|
|
13075
|
+
targetPartId = selectedBlock.partId;
|
|
13076
|
+
targetIndex = ((_i = selectedBlock.children) == null ? void 0 : _i.length) || 0;
|
|
13077
|
+
partsToInsert = partsToPaste;
|
|
13078
|
+
} else {
|
|
13079
|
+
const newBlock = createBlock(pageBuilder);
|
|
13080
|
+
if (!newBlock) return;
|
|
13081
|
+
newBlock.children = partsToPaste;
|
|
13082
|
+
targetPartId = selectedSection.partId;
|
|
13083
|
+
targetIndex = 0;
|
|
13084
|
+
partsToInsert = [newBlock];
|
|
13085
|
+
}
|
|
13086
|
+
} else {
|
|
13087
|
+
const newBlock = createBlock(pageBuilder);
|
|
13088
|
+
const newSection = createSection(pageBuilder);
|
|
13089
|
+
if (!newBlock || !newSection) return;
|
|
13090
|
+
newSection.children = [newBlock];
|
|
13091
|
+
newBlock.children = partsToPaste;
|
|
13092
|
+
targetPartId = selectedPage.partId;
|
|
13093
|
+
targetIndex = 0;
|
|
13094
|
+
partsToInsert = [newSection];
|
|
13095
|
+
}
|
|
13096
|
+
}
|
|
13097
|
+
if (!targetPartId || targetIndex < 0 || !partsToInsert) return;
|
|
13098
|
+
insertParts(pageBuilder, targetPartId, targetIndex, partsToInsert, false);
|
|
13099
|
+
}
|
|
13100
|
+
};
|
|
12915
13101
|
const _AddPartCommand = class _AddPartCommand {
|
|
12916
13102
|
constructor(modal) {
|
|
12917
13103
|
__publicField(this, "commandId", _AddPartCommand.COMMAND_ID);
|
|
@@ -13397,176 +13583,8 @@ ${_html.style}
|
|
|
13397
13583
|
__publicField(this, "commandId", _PastePartCommand.COMMAND_ID);
|
|
13398
13584
|
}
|
|
13399
13585
|
async execute(pageBuilder) {
|
|
13400
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
13401
13586
|
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
|
-
}
|
|
13587
|
+
pasteContentJson(pageBuilder, json);
|
|
13570
13588
|
}
|
|
13571
13589
|
};
|
|
13572
13590
|
__publicField(_PastePartCommand, "COMMAND_ID", "PastePart");
|
|
@@ -14145,7 +14163,7 @@ ${_html.style}
|
|
|
14145
14163
|
if (plugin.keyHandlers) this.keyHandlers.appendKeyHandlers(plugin.keyHandlers);
|
|
14146
14164
|
if (plugin.toolButtonGroups) this.toolButtonRegistry.registerToolButtonGroups(plugin.toolButtonGroups);
|
|
14147
14165
|
}
|
|
14148
|
-
registerCustomPlugin(plugin) {
|
|
14166
|
+
registerCustomPlugin(plugin, modal) {
|
|
14149
14167
|
if (plugin.widgets) {
|
|
14150
14168
|
const partDefinitions2 = {};
|
|
14151
14169
|
plugin.widgets.forEach((group) => {
|
|
@@ -14184,6 +14202,29 @@ ${_html.style}
|
|
|
14184
14202
|
this.externalCssContent = plugin.css.content;
|
|
14185
14203
|
}
|
|
14186
14204
|
}
|
|
14205
|
+
if (plugin.contextMenus) {
|
|
14206
|
+
const self2 = this;
|
|
14207
|
+
const contextMenus = plugin.contextMenus.map((menu) => {
|
|
14208
|
+
return {
|
|
14209
|
+
commandId: menu.menuId,
|
|
14210
|
+
groupId: "external",
|
|
14211
|
+
precedence: 10,
|
|
14212
|
+
getMenuItem(pageBuilder) {
|
|
14213
|
+
const selected = self2.context.getSelectedParts();
|
|
14214
|
+
if (menu.visible(selected)) {
|
|
14215
|
+
return {
|
|
14216
|
+
menuId: menu.menuId,
|
|
14217
|
+
caption: menu.caption,
|
|
14218
|
+
handler() {
|
|
14219
|
+
menu.handler(selected, self2.model, modal);
|
|
14220
|
+
}
|
|
14221
|
+
};
|
|
14222
|
+
}
|
|
14223
|
+
}
|
|
14224
|
+
};
|
|
14225
|
+
});
|
|
14226
|
+
this.contextMenuRegistry.registerContextMenus(contextMenus);
|
|
14227
|
+
}
|
|
14187
14228
|
}
|
|
14188
14229
|
initData(data) {
|
|
14189
14230
|
const _data = JSON.parse(data || "{}") || {};
|
|
@@ -15417,6 +15458,10 @@ ${_html.style}
|
|
|
15417
15458
|
{
|
|
15418
15459
|
key: "pb.modal.htmlEditor.style",
|
|
15419
15460
|
text: "Style"
|
|
15461
|
+
},
|
|
15462
|
+
{
|
|
15463
|
+
key: "pb.prop.hideParentWhenInvisible",
|
|
15464
|
+
text: "Hide block and section when invisible"
|
|
15420
15465
|
}
|
|
15421
15466
|
];
|
|
15422
15467
|
const jaTexts = [
|
|
@@ -15739,6 +15784,10 @@ ${_html.style}
|
|
|
15739
15784
|
{
|
|
15740
15785
|
key: "pb.modal.htmlEditor.style",
|
|
15741
15786
|
text: "スタイル"
|
|
15787
|
+
},
|
|
15788
|
+
{
|
|
15789
|
+
key: "pb.prop.hideParentWhenInvisible",
|
|
15790
|
+
text: "非表示の場合はブロックとセクションも隠す"
|
|
15742
15791
|
}
|
|
15743
15792
|
];
|
|
15744
15793
|
const koTexts = [
|
|
@@ -16061,6 +16110,10 @@ ${_html.style}
|
|
|
16061
16110
|
{
|
|
16062
16111
|
key: "pb.modal.htmlEditor.style",
|
|
16063
16112
|
text: "스타일"
|
|
16113
|
+
},
|
|
16114
|
+
{
|
|
16115
|
+
key: "pb.prop.hideParentWhenInvisible",
|
|
16116
|
+
text: "블록과 섹션도 함께 숨김처리하기"
|
|
16064
16117
|
}
|
|
16065
16118
|
];
|
|
16066
16119
|
const zhTexts = [
|
|
@@ -16383,6 +16436,10 @@ ${_html.style}
|
|
|
16383
16436
|
{
|
|
16384
16437
|
key: "pb.modal.htmlEditor.style",
|
|
16385
16438
|
text: "样式"
|
|
16439
|
+
},
|
|
16440
|
+
{
|
|
16441
|
+
key: "pb.prop.hideParentWhenInvisible",
|
|
16442
|
+
text: "不可见时隐藏区块和区域"
|
|
16386
16443
|
}
|
|
16387
16444
|
];
|
|
16388
16445
|
bluesea.i18n.addTexts("en", enTexts);
|
|
@@ -16415,7 +16472,7 @@ ${_html.style}
|
|
|
16415
16472
|
};
|
|
16416
16473
|
if (props.locales) pageBuilderEditor.setLocales(props.locales);
|
|
16417
16474
|
if (props.locale) pageBuilderEditor.setLocale(props.locale);
|
|
16418
|
-
if (props.plugin) pageBuilderEditor.registerCustomPlugin(props.plugin);
|
|
16475
|
+
if (props.plugin) pageBuilderEditor.registerCustomPlugin(props.plugin, modal);
|
|
16419
16476
|
pageBuilderEditor.registerPlugin({
|
|
16420
16477
|
// TODO
|
|
16421
16478
|
commands: createDefaultCommands(modal)
|
|
@@ -16435,8 +16492,12 @@ ${_html.style}
|
|
|
16435
16492
|
const getPageContent = () => {
|
|
16436
16493
|
return pageBuilderEditor.model.serializeModel((part) => pageBuilderEditor.extractMedia(part));
|
|
16437
16494
|
};
|
|
16495
|
+
const pastePageContent = (contentJson) => {
|
|
16496
|
+
pasteContentJson(pageBuilderEditor, contentJson);
|
|
16497
|
+
};
|
|
16438
16498
|
__expose({
|
|
16439
|
-
getPageContent
|
|
16499
|
+
getPageContent,
|
|
16500
|
+
pastePageContent
|
|
16440
16501
|
});
|
|
16441
16502
|
return (_ctx, _cache) => {
|
|
16442
16503
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
|
|
@@ -17005,7 +17066,6 @@ ${_html.style}
|
|
|
17005
17066
|
const modalHandle = bluesea.useModalHandle();
|
|
17006
17067
|
const customWidgets = vue.computed(() => props.pageBuilder.getCustomWidgets());
|
|
17007
17068
|
const select = (partDefinition) => {
|
|
17008
|
-
console.log(partDefinition);
|
|
17009
17069
|
emit("selectHandler", partDefinition);
|
|
17010
17070
|
modalHandle.close();
|
|
17011
17071
|
};
|
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.52",
|
|
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.52"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.12.7",
|