brick-pdf 0.1.1
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/README.md +5 -0
- package/dist/brick-pdf.css +1 -0
- package/dist/brick-pdf.js +1685 -0
- package/dist/brick-pdf.umd.cjs +5 -0
- package/dist/components/ActionBar.vue.d.ts +4 -0
- package/dist/components/BrickPdf.vue.d.ts +10 -0
- package/dist/components/CanvasElement.vue.d.ts +9 -0
- package/dist/components/DesignCanvas.vue.d.ts +2 -0
- package/dist/components/DocumentSettings.vue.d.ts +2 -0
- package/dist/components/DropZone.vue.d.ts +25 -0
- package/dist/components/PropertyEditor.vue.d.ts +2 -0
- package/dist/components/PropertyField.vue.d.ts +7 -0
- package/dist/components/Toolbar.vue.d.ts +2 -0
- package/dist/components/ToolbarElementList.vue.d.ts +4 -0
- package/dist/composables/index.d.ts +16 -0
- package/dist/composables/useClipboard.d.ts +12 -0
- package/dist/composables/useDocumentStore.d.ts +16 -0
- package/dist/composables/useDragDrop.d.ts +10 -0
- package/dist/composables/useElementActions.d.ts +14 -0
- package/dist/composables/useHistory.d.ts +12 -0
- package/dist/composables/usePdfExport.d.ts +11 -0
- package/dist/composables/useResize.d.ts +10 -0
- package/dist/composables/useSelection.d.ts +12 -0
- package/dist/elements/canvas/CanvasDrawPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/canvas/CanvasDrawRenderer.vue.d.ts +6 -0
- package/dist/elements/canvas/canvasDrawConverter.d.ts +2 -0
- package/dist/elements/canvas/canvasDrawDefaults.d.ts +23 -0
- package/dist/elements/canvas/index.d.ts +2 -0
- package/dist/elements/columns/ColumnsPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/columns/ColumnsRenderer.vue.d.ts +22 -0
- package/dist/elements/columns/columnsConverter.d.ts +2 -0
- package/dist/elements/columns/columnsDefaults.d.ts +3 -0
- package/dist/elements/columns/index.d.ts +2 -0
- package/dist/elements/image/ImagePropertyEditor.vue.d.ts +6 -0
- package/dist/elements/image/ImageRenderer.vue.d.ts +6 -0
- package/dist/elements/image/imageConverter.d.ts +2 -0
- package/dist/elements/image/imageDefaults.d.ts +3 -0
- package/dist/elements/image/index.d.ts +2 -0
- package/dist/elements/list/ListPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/list/ListRenderer.vue.d.ts +6 -0
- package/dist/elements/list/index.d.ts +2 -0
- package/dist/elements/list/listConverter.d.ts +2 -0
- package/dist/elements/list/listDefaults.d.ts +3 -0
- package/dist/elements/pageBreak/PageBreakPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/pageBreak/PageBreakRenderer.vue.d.ts +6 -0
- package/dist/elements/pageBreak/index.d.ts +2 -0
- package/dist/elements/pageBreak/pageBreakConverter.d.ts +2 -0
- package/dist/elements/pageBreak/pageBreakDefaults.d.ts +3 -0
- package/dist/elements/qr/QrPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/qr/QrRenderer.vue.d.ts +6 -0
- package/dist/elements/qr/index.d.ts +2 -0
- package/dist/elements/qr/qrConverter.d.ts +2 -0
- package/dist/elements/qr/qrDefaults.d.ts +3 -0
- package/dist/elements/stack/StackPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/stack/StackRenderer.vue.d.ts +22 -0
- package/dist/elements/stack/index.d.ts +2 -0
- package/dist/elements/stack/stackConverter.d.ts +2 -0
- package/dist/elements/stack/stackDefaults.d.ts +3 -0
- package/dist/elements/svg/SvgPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/svg/SvgRenderer.vue.d.ts +6 -0
- package/dist/elements/svg/index.d.ts +2 -0
- package/dist/elements/svg/svgConverter.d.ts +2 -0
- package/dist/elements/svg/svgDefaults.d.ts +3 -0
- package/dist/elements/table/TablePropertyEditor.vue.d.ts +6 -0
- package/dist/elements/table/TableRenderer.vue.d.ts +6 -0
- package/dist/elements/table/index.d.ts +2 -0
- package/dist/elements/table/tableConverter.d.ts +2 -0
- package/dist/elements/table/tableDefaults.d.ts +3 -0
- package/dist/elements/text/TextPropertyEditor.vue.d.ts +6 -0
- package/dist/elements/text/TextRenderer.vue.d.ts +6 -0
- package/dist/elements/text/index.d.ts +2 -0
- package/dist/elements/text/textConverter.d.ts +2 -0
- package/dist/elements/text/textDefaults.d.ts +3 -0
- package/dist/index.d.ts +24 -0
- package/dist/registry/builtinRegistration.d.ts +1 -0
- package/dist/registry/elementRegistry.d.ts +5 -0
- package/dist/types/document.d.ts +11 -0
- package/dist/types/element.d.ts +29 -0
- package/dist/types/history.d.ts +5 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/props.d.ts +14 -0
- package/dist/types/registry.d.ts +16 -0
- package/dist/types/selection.d.ts +3 -0
- package/dist/types/toolbar.d.ts +6 -0
- package/dist/vite.svg +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,1685 @@
|
|
|
1
|
+
import { defineComponent as _, openBlock as s, createElementBlock as a, normalizeStyle as R, toDisplayString as w, renderSlot as X, normalizeClass as K, createElementVNode as f, Fragment as C, renderList as P, reactive as Pe, provide as L, inject as M, toRaw as H, ref as E, computed as $, createTextVNode as ne, createCommentVNode as I, createBlock as B, resolveDynamicComponent as Q, withCtx as W, onMounted as se, onBeforeUnmount as ae, resolveComponent as Ee, withDirectives as G, unref as k, vModelSelect as oe, createVNode as O, vModelText as $e, watch as Ie } from "vue";
|
|
2
|
+
import { useMagicKeys as Re, whenever as re } from "@vueuse/core";
|
|
3
|
+
import le from "sortablejs";
|
|
4
|
+
function ce() {
|
|
5
|
+
return {
|
|
6
|
+
pageSize: "A4",
|
|
7
|
+
pageOrientation: "portrait",
|
|
8
|
+
pageMargins: [40, 60, 40, 60],
|
|
9
|
+
defaultStyle: {
|
|
10
|
+
fontSize: 12
|
|
11
|
+
},
|
|
12
|
+
styles: {},
|
|
13
|
+
content: []
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const J = /* @__PURE__ */ new Map();
|
|
17
|
+
function z(e) {
|
|
18
|
+
J.set(e.type, e);
|
|
19
|
+
}
|
|
20
|
+
function F(e) {
|
|
21
|
+
return J.get(e);
|
|
22
|
+
}
|
|
23
|
+
function De() {
|
|
24
|
+
return Array.from(J.values());
|
|
25
|
+
}
|
|
26
|
+
function or(e) {
|
|
27
|
+
return J.delete(e);
|
|
28
|
+
}
|
|
29
|
+
function ze() {
|
|
30
|
+
return { text: "New Text" };
|
|
31
|
+
}
|
|
32
|
+
function Te() {
|
|
33
|
+
return { fontSize: 12 };
|
|
34
|
+
}
|
|
35
|
+
function Ne(e) {
|
|
36
|
+
const t = { text: e.props.text }, n = e.style;
|
|
37
|
+
return n.fontSize && (t.fontSize = n.fontSize), n.bold && (t.bold = n.bold), n.italics && (t.italics = n.italics), n.color && (t.color = n.color), n.alignment && (t.alignment = n.alignment), n.margin && (t.margin = n.margin), n.font && (t.font = n.font), n.lineHeight && (t.lineHeight = n.lineHeight), n.characterSpacing && (t.characterSpacing = n.characterSpacing), n.decoration && (t.decoration = n.decoration), n.decorationStyle && (t.decorationStyle = n.decorationStyle), n.decorationColor && (t.decorationColor = n.decorationColor), n.background && (t.background = n.background), n.link && (t.link = n.link), n.opacity !== void 0 && (t.opacity = n.opacity), t;
|
|
38
|
+
}
|
|
39
|
+
const Le = /* @__PURE__ */ _({
|
|
40
|
+
__name: "TextRenderer",
|
|
41
|
+
props: {
|
|
42
|
+
node: {}
|
|
43
|
+
},
|
|
44
|
+
setup(e) {
|
|
45
|
+
return (t, n) => (s(), a("div", {
|
|
46
|
+
class: "brick-el-text",
|
|
47
|
+
style: R({
|
|
48
|
+
fontSize: (e.node.style.fontSize ?? 12) + "px",
|
|
49
|
+
fontWeight: e.node.style.bold ? "bold" : "normal",
|
|
50
|
+
fontStyle: e.node.style.italics ? "italic" : "normal",
|
|
51
|
+
color: e.node.style.color,
|
|
52
|
+
textAlign: e.node.style.alignment,
|
|
53
|
+
lineHeight: e.node.style.lineHeight,
|
|
54
|
+
textDecoration: e.node.style.decoration === "lineThrough" ? "line-through" : e.node.style.decoration,
|
|
55
|
+
backgroundColor: e.node.style.background,
|
|
56
|
+
opacity: e.node.style.opacity
|
|
57
|
+
})
|
|
58
|
+
}, w(e.node.props.text), 5));
|
|
59
|
+
}
|
|
60
|
+
}), S = (e, t) => {
|
|
61
|
+
const n = e.__vccOpts || e;
|
|
62
|
+
for (const [i, c] of t)
|
|
63
|
+
n[i] = c;
|
|
64
|
+
return n;
|
|
65
|
+
}, Me = /* @__PURE__ */ S(Le, [["__scopeId", "data-v-a7cd1565"]]), Be = { class: "brick-text-editor" }, Oe = /* @__PURE__ */ _({
|
|
66
|
+
__name: "TextPropertyEditor",
|
|
67
|
+
props: {
|
|
68
|
+
node: {}
|
|
69
|
+
},
|
|
70
|
+
setup(e) {
|
|
71
|
+
return (t, n) => (s(), a("div", Be));
|
|
72
|
+
}
|
|
73
|
+
}), Ve = {
|
|
74
|
+
type: "text",
|
|
75
|
+
label: "Text",
|
|
76
|
+
icon: "T",
|
|
77
|
+
isContainer: !1,
|
|
78
|
+
defaultProps: ze,
|
|
79
|
+
defaultStyle: Te,
|
|
80
|
+
rendererComponent: Me,
|
|
81
|
+
propertyEditorComponent: Oe,
|
|
82
|
+
propertyFields: [
|
|
83
|
+
{ key: "props.text", label: "Text Content", section: "content", type: "textarea", defaultValue: "New Text" },
|
|
84
|
+
{ key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
|
|
85
|
+
{ key: "style.bold", label: "Bold", section: "style", type: "toggle", defaultValue: !1 },
|
|
86
|
+
{ key: "style.italics", label: "Italic", section: "style", type: "toggle", defaultValue: !1 },
|
|
87
|
+
{ key: "style.color", label: "Color", section: "style", type: "color", defaultValue: "#000000" },
|
|
88
|
+
{ key: "style.alignment", label: "Alignment", section: "style", type: "select", options: [
|
|
89
|
+
{ label: "Left", value: "left" },
|
|
90
|
+
{ label: "Center", value: "center" },
|
|
91
|
+
{ label: "Right", value: "right" },
|
|
92
|
+
{ label: "Justify", value: "justify" }
|
|
93
|
+
], defaultValue: "left" },
|
|
94
|
+
{ key: "style.lineHeight", label: "Line Height", section: "style", type: "number", min: 0.5, max: 3, step: 0.1 },
|
|
95
|
+
{ key: "style.background", label: "Background", section: "style", type: "color" },
|
|
96
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] },
|
|
97
|
+
{ key: "style.decoration", label: "Decoration", section: "advanced", type: "select", options: [
|
|
98
|
+
{ label: "None", value: void 0 },
|
|
99
|
+
{ label: "Underline", value: "underline" },
|
|
100
|
+
{ label: "Overline", value: "overline" },
|
|
101
|
+
{ label: "Line Through", value: "lineThrough" }
|
|
102
|
+
] },
|
|
103
|
+
{ key: "style.link", label: "Link URL", section: "advanced", type: "text" },
|
|
104
|
+
{ key: "style.opacity", label: "Opacity", section: "advanced", type: "slider", min: 0, max: 1, step: 0.1, defaultValue: 1 }
|
|
105
|
+
],
|
|
106
|
+
toPdfmake: Ne
|
|
107
|
+
};
|
|
108
|
+
function Ae() {
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
function He() {
|
|
112
|
+
return {};
|
|
113
|
+
}
|
|
114
|
+
function Fe(e, t) {
|
|
115
|
+
const n = {
|
|
116
|
+
stack: t(e.children)
|
|
117
|
+
};
|
|
118
|
+
return e.style.margin && (n.margin = e.style.margin), e.style.fillColor && (n.fillColor = e.style.fillColor), n;
|
|
119
|
+
}
|
|
120
|
+
const Ue = /* @__PURE__ */ _({
|
|
121
|
+
__name: "StackRenderer",
|
|
122
|
+
props: {
|
|
123
|
+
node: {},
|
|
124
|
+
path: {}
|
|
125
|
+
},
|
|
126
|
+
setup(e) {
|
|
127
|
+
return (t, n) => (s(), a("div", {
|
|
128
|
+
class: "brick-el-stack",
|
|
129
|
+
style: R({ backgroundColor: e.node.style.fillColor })
|
|
130
|
+
}, [
|
|
131
|
+
X(t.$slots, "default", {}, void 0, !0)
|
|
132
|
+
], 4));
|
|
133
|
+
}
|
|
134
|
+
}), We = /* @__PURE__ */ S(Ue, [["__scopeId", "data-v-c59e7405"]]), Je = { class: "brick-stack-editor" }, Ye = /* @__PURE__ */ _({
|
|
135
|
+
__name: "StackPropertyEditor",
|
|
136
|
+
props: {
|
|
137
|
+
node: {}
|
|
138
|
+
},
|
|
139
|
+
setup(e) {
|
|
140
|
+
return (t, n) => (s(), a("div", Je));
|
|
141
|
+
}
|
|
142
|
+
}), qe = {
|
|
143
|
+
type: "stack",
|
|
144
|
+
label: "Stack",
|
|
145
|
+
icon: "☰",
|
|
146
|
+
isContainer: !0,
|
|
147
|
+
acceptsChildTypes: null,
|
|
148
|
+
defaultProps: Ae,
|
|
149
|
+
defaultStyle: He,
|
|
150
|
+
rendererComponent: We,
|
|
151
|
+
propertyEditorComponent: Ye,
|
|
152
|
+
propertyFields: [
|
|
153
|
+
{ key: "style.fillColor", label: "Fill Color", section: "style", type: "color" },
|
|
154
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
155
|
+
],
|
|
156
|
+
toPdfmake: Fe
|
|
157
|
+
};
|
|
158
|
+
function je() {
|
|
159
|
+
return { columnGap: 10 };
|
|
160
|
+
}
|
|
161
|
+
function Ge() {
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
function Xe(e, t) {
|
|
165
|
+
const n = {
|
|
166
|
+
columns: t(e.children),
|
|
167
|
+
columnGap: e.props.columnGap ?? 10
|
|
168
|
+
};
|
|
169
|
+
return e.style.margin && (n.margin = e.style.margin), n;
|
|
170
|
+
}
|
|
171
|
+
const Ke = /* @__PURE__ */ _({
|
|
172
|
+
__name: "ColumnsRenderer",
|
|
173
|
+
props: {
|
|
174
|
+
node: {},
|
|
175
|
+
path: {}
|
|
176
|
+
},
|
|
177
|
+
setup(e) {
|
|
178
|
+
return (t, n) => (s(), a("div", {
|
|
179
|
+
class: "brick-el-columns",
|
|
180
|
+
style: R({ "--column-gap": (e.node.props.columnGap ?? 10) + "px" })
|
|
181
|
+
}, [
|
|
182
|
+
X(t.$slots, "default", {}, void 0, !0)
|
|
183
|
+
], 4));
|
|
184
|
+
}
|
|
185
|
+
}), Qe = /* @__PURE__ */ S(Ke, [["__scopeId", "data-v-217dd721"]]), Ze = { class: "brick-columns-editor" }, et = /* @__PURE__ */ _({
|
|
186
|
+
__name: "ColumnsPropertyEditor",
|
|
187
|
+
props: {
|
|
188
|
+
node: {}
|
|
189
|
+
},
|
|
190
|
+
setup(e) {
|
|
191
|
+
return (t, n) => (s(), a("div", Ze));
|
|
192
|
+
}
|
|
193
|
+
}), tt = {
|
|
194
|
+
type: "columns",
|
|
195
|
+
label: "Columns",
|
|
196
|
+
icon: "▥",
|
|
197
|
+
isContainer: !0,
|
|
198
|
+
acceptsChildTypes: null,
|
|
199
|
+
defaultProps: je,
|
|
200
|
+
defaultStyle: Ge,
|
|
201
|
+
rendererComponent: Qe,
|
|
202
|
+
propertyEditorComponent: et,
|
|
203
|
+
propertyFields: [
|
|
204
|
+
{ key: "props.columnGap", label: "Column Gap", section: "layout", type: "number", min: 0, max: 50, step: 1, defaultValue: 10 },
|
|
205
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
206
|
+
],
|
|
207
|
+
toPdfmake: Xe
|
|
208
|
+
};
|
|
209
|
+
function nt() {
|
|
210
|
+
return {
|
|
211
|
+
headerRows: 1,
|
|
212
|
+
widths: ["*", "*"],
|
|
213
|
+
body: [
|
|
214
|
+
["Header 1", "Header 2"],
|
|
215
|
+
["Cell 1", "Cell 2"]
|
|
216
|
+
],
|
|
217
|
+
layout: "lightHorizontalLines"
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function ot() {
|
|
221
|
+
return { fontSize: 12 };
|
|
222
|
+
}
|
|
223
|
+
function rt(e) {
|
|
224
|
+
const t = e.props.body, n = {
|
|
225
|
+
table: {
|
|
226
|
+
headerRows: e.props.headerRows,
|
|
227
|
+
widths: e.props.widths,
|
|
228
|
+
body: t.map(
|
|
229
|
+
(c) => c.map((o) => ({ text: o }))
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
}, i = e.props.layout;
|
|
233
|
+
return i && i !== "none" && (n.layout = i), e.style.fontSize && (n.fontSize = e.style.fontSize), e.style.color && (n.color = e.style.color), e.style.margin && (n.margin = e.style.margin), n;
|
|
234
|
+
}
|
|
235
|
+
const lt = /* @__PURE__ */ _({
|
|
236
|
+
__name: "TableRenderer",
|
|
237
|
+
props: {
|
|
238
|
+
node: {}
|
|
239
|
+
},
|
|
240
|
+
setup(e) {
|
|
241
|
+
return (t, n) => (s(), a("div", {
|
|
242
|
+
class: K(["brick-el-table", "brick-el-table--" + (e.node.props.layout ?? "lightHorizontalLines")]),
|
|
243
|
+
style: R({ fontSize: (e.node.style.fontSize ?? 12) + "px", color: e.node.style.color })
|
|
244
|
+
}, [
|
|
245
|
+
f("table", null, [
|
|
246
|
+
f("thead", null, [
|
|
247
|
+
(s(!0), a(C, null, P(e.node.props.body.slice(0, e.node.props.headerRows), (i, c) => (s(), a("tr", {
|
|
248
|
+
key: "h" + c
|
|
249
|
+
}, [
|
|
250
|
+
(s(!0), a(C, null, P(i, (o, d) => (s(), a("th", { key: d }, w(o), 1))), 128))
|
|
251
|
+
]))), 128))
|
|
252
|
+
]),
|
|
253
|
+
f("tbody", null, [
|
|
254
|
+
(s(!0), a(C, null, P(e.node.props.body.slice(e.node.props.headerRows), (i, c) => (s(), a("tr", {
|
|
255
|
+
key: "b" + c
|
|
256
|
+
}, [
|
|
257
|
+
(s(!0), a(C, null, P(i, (o, d) => (s(), a("td", { key: d }, w(o), 1))), 128))
|
|
258
|
+
]))), 128))
|
|
259
|
+
])
|
|
260
|
+
])
|
|
261
|
+
], 6));
|
|
262
|
+
}
|
|
263
|
+
}), it = /* @__PURE__ */ S(lt, [["__scopeId", "data-v-b863b05d"]]), de = /* @__PURE__ */ Symbol("brick-pdf-document-store");
|
|
264
|
+
function st(e) {
|
|
265
|
+
const t = Pe(e ?? ce());
|
|
266
|
+
function n(u, p) {
|
|
267
|
+
const r = p ?? t.content;
|
|
268
|
+
for (let l = 0; l < r.length; l++) {
|
|
269
|
+
const y = r[l];
|
|
270
|
+
if (y) {
|
|
271
|
+
if (y.id === u)
|
|
272
|
+
return { node: y, parent: r, index: l };
|
|
273
|
+
if (y.children.length > 0) {
|
|
274
|
+
const b = n(u, y.children);
|
|
275
|
+
if (b) return b;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
function i(u) {
|
|
282
|
+
t.content.splice(0, t.content.length, ...u);
|
|
283
|
+
}
|
|
284
|
+
function c() {
|
|
285
|
+
return JSON.parse(JSON.stringify(H(t.content)));
|
|
286
|
+
}
|
|
287
|
+
function o(u) {
|
|
288
|
+
t.pageSize = u.pageSize, t.pageOrientation = u.pageOrientation, t.pageMargins = u.pageMargins, t.defaultStyle = u.defaultStyle ?? { fontSize: 12 }, t.styles = u.styles ?? {}, t.content.splice(0, t.content.length, ...u.content);
|
|
289
|
+
}
|
|
290
|
+
function d() {
|
|
291
|
+
return JSON.parse(JSON.stringify(H(t)));
|
|
292
|
+
}
|
|
293
|
+
return { document: t, findNodeById: n, replaceContent: i, snapshotContent: c, loadDocument: o, exportDocument: d };
|
|
294
|
+
}
|
|
295
|
+
function at(e) {
|
|
296
|
+
L(de, e);
|
|
297
|
+
}
|
|
298
|
+
function Z() {
|
|
299
|
+
const e = M(de);
|
|
300
|
+
if (!e)
|
|
301
|
+
throw new Error("useDocumentStore() requires a BrickPdf ancestor component");
|
|
302
|
+
return e;
|
|
303
|
+
}
|
|
304
|
+
const ue = /* @__PURE__ */ Symbol("brick-pdf-selection");
|
|
305
|
+
function ct(e) {
|
|
306
|
+
const t = E(null), n = $(() => t.value ? e.findNodeById(t.value)?.node ?? null : null);
|
|
307
|
+
function i(o) {
|
|
308
|
+
t.value = o;
|
|
309
|
+
}
|
|
310
|
+
function c() {
|
|
311
|
+
t.value = null;
|
|
312
|
+
}
|
|
313
|
+
return { selectedId: t, selectedNode: n, select: i, deselect: c };
|
|
314
|
+
}
|
|
315
|
+
function dt(e) {
|
|
316
|
+
L(ue, e);
|
|
317
|
+
}
|
|
318
|
+
function U() {
|
|
319
|
+
const e = M(ue);
|
|
320
|
+
if (!e)
|
|
321
|
+
throw new Error("useSelection() requires a BrickPdf ancestor component");
|
|
322
|
+
return e;
|
|
323
|
+
}
|
|
324
|
+
const pe = /* @__PURE__ */ Symbol("brick-pdf-element-actions");
|
|
325
|
+
let ut = 0;
|
|
326
|
+
function fe() {
|
|
327
|
+
return `el-${Date.now()}-${++ut}`;
|
|
328
|
+
}
|
|
329
|
+
function me(e) {
|
|
330
|
+
return {
|
|
331
|
+
...e,
|
|
332
|
+
id: fe(),
|
|
333
|
+
props: structuredClone(e.props),
|
|
334
|
+
style: structuredClone(e.style),
|
|
335
|
+
children: e.children.map(me)
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function pt(e, t) {
|
|
339
|
+
function n(p, r, l) {
|
|
340
|
+
const y = F(p);
|
|
341
|
+
if (!y) return null;
|
|
342
|
+
t.record();
|
|
343
|
+
const b = {
|
|
344
|
+
id: fe(),
|
|
345
|
+
type: p,
|
|
346
|
+
props: y.defaultProps(),
|
|
347
|
+
style: y.defaultStyle(),
|
|
348
|
+
children: []
|
|
349
|
+
}, m = r ? e.findNodeById(r)?.node.children : e.document.content;
|
|
350
|
+
if (!m) return null;
|
|
351
|
+
const g = l ?? m.length;
|
|
352
|
+
return m.splice(g, 0, b), b;
|
|
353
|
+
}
|
|
354
|
+
function i(p) {
|
|
355
|
+
const r = e.findNodeById(p);
|
|
356
|
+
r && (t.record(), r.parent.splice(r.index, 1));
|
|
357
|
+
}
|
|
358
|
+
function c(p, r, l) {
|
|
359
|
+
const y = e.findNodeById(p);
|
|
360
|
+
if (!y) return;
|
|
361
|
+
t.record();
|
|
362
|
+
const b = y.parent.splice(y.index, 1)[0];
|
|
363
|
+
if (!b) return;
|
|
364
|
+
const m = r ? e.findNodeById(r)?.node.children : e.document.content;
|
|
365
|
+
m && m.splice(l, 0, b);
|
|
366
|
+
}
|
|
367
|
+
function o(p) {
|
|
368
|
+
const r = e.findNodeById(p);
|
|
369
|
+
if (!r) return null;
|
|
370
|
+
t.record();
|
|
371
|
+
const l = me(r.node);
|
|
372
|
+
return r.parent.splice(r.index + 1, 0, l), l;
|
|
373
|
+
}
|
|
374
|
+
function d(p, r) {
|
|
375
|
+
const l = e.findNodeById(p);
|
|
376
|
+
l && (t.record(), Object.assign(l.node.props, r));
|
|
377
|
+
}
|
|
378
|
+
function u(p, r) {
|
|
379
|
+
const l = e.findNodeById(p);
|
|
380
|
+
l && (t.record(), Object.assign(l.node.style, r));
|
|
381
|
+
}
|
|
382
|
+
return { addElement: n, removeElement: i, moveElement: c, duplicateElement: o, updateProps: d, updateStyle: u };
|
|
383
|
+
}
|
|
384
|
+
function ft(e) {
|
|
385
|
+
L(pe, e);
|
|
386
|
+
}
|
|
387
|
+
function Y() {
|
|
388
|
+
const e = M(pe);
|
|
389
|
+
if (!e)
|
|
390
|
+
throw new Error("useElementActions() requires a BrickPdf ancestor component");
|
|
391
|
+
return e;
|
|
392
|
+
}
|
|
393
|
+
const ye = /* @__PURE__ */ Symbol("brick-pdf-history"), mt = 50;
|
|
394
|
+
function yt(e) {
|
|
395
|
+
const t = E([]), n = E([]);
|
|
396
|
+
let i = 0;
|
|
397
|
+
const c = $(() => t.value.length > 0), o = $(() => n.value.length > 0);
|
|
398
|
+
function d() {
|
|
399
|
+
const r = Date.now();
|
|
400
|
+
if (r - i < 100) return;
|
|
401
|
+
i = r;
|
|
402
|
+
const l = e.snapshotContent();
|
|
403
|
+
t.value.push(l), t.value.length > mt && t.value.shift(), n.value = [];
|
|
404
|
+
}
|
|
405
|
+
function u() {
|
|
406
|
+
const r = t.value.pop();
|
|
407
|
+
r && (n.value.push(e.snapshotContent()), e.replaceContent(r));
|
|
408
|
+
}
|
|
409
|
+
function p() {
|
|
410
|
+
const r = n.value.pop();
|
|
411
|
+
r && (t.value.push(e.snapshotContent()), e.replaceContent(r));
|
|
412
|
+
}
|
|
413
|
+
return { canUndo: c, canRedo: o, record: d, undo: u, redo: p };
|
|
414
|
+
}
|
|
415
|
+
function gt(e) {
|
|
416
|
+
L(ye, e);
|
|
417
|
+
}
|
|
418
|
+
function bt() {
|
|
419
|
+
const e = M(ye);
|
|
420
|
+
if (!e)
|
|
421
|
+
throw new Error("useHistory() requires a BrickPdf ancestor component");
|
|
422
|
+
return e;
|
|
423
|
+
}
|
|
424
|
+
const ge = /* @__PURE__ */ Symbol("brick-pdf-drag-drop");
|
|
425
|
+
function vt(e, t) {
|
|
426
|
+
function n(c) {
|
|
427
|
+
return le.create(c, {
|
|
428
|
+
group: { name: "brick-elements", pull: "clone", put: !1 },
|
|
429
|
+
sort: !1,
|
|
430
|
+
animation: 150
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function i(c, o) {
|
|
434
|
+
return le.create(c, {
|
|
435
|
+
group: { name: "brick-elements", put: !0 },
|
|
436
|
+
animation: 150,
|
|
437
|
+
fallbackOnBody: !0,
|
|
438
|
+
swapThreshold: 0.65,
|
|
439
|
+
emptyInsertThreshold: 80,
|
|
440
|
+
onAdd(d) {
|
|
441
|
+
const u = d.item, p = u.dataset.elementType;
|
|
442
|
+
if (p) {
|
|
443
|
+
if (u.parentNode?.removeChild(u), o) {
|
|
444
|
+
const r = e.findNodeById(o);
|
|
445
|
+
if (r) {
|
|
446
|
+
const l = F(r.node.type);
|
|
447
|
+
if (l?.acceptsChildTypes && !l.acceptsChildTypes.includes(p))
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
t.addElement(p, o, d.newIndex);
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
onEnd(d) {
|
|
455
|
+
if (d.from === d.to && d.oldIndex !== void 0 && d.newIndex !== void 0) {
|
|
456
|
+
const u = o ? e.findNodeById(o)?.node.children : e.document.content;
|
|
457
|
+
if (!u || d.oldIndex === d.newIndex) return;
|
|
458
|
+
const p = u.splice(d.oldIndex, 1)[0];
|
|
459
|
+
p && u.splice(d.newIndex, 0, p);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
return { initToolbar: n, initContainer: i };
|
|
465
|
+
}
|
|
466
|
+
function ht(e) {
|
|
467
|
+
L(ge, e);
|
|
468
|
+
}
|
|
469
|
+
function be() {
|
|
470
|
+
const e = M(ge);
|
|
471
|
+
if (!e)
|
|
472
|
+
throw new Error("useDragDrop() requires a BrickPdf ancestor component");
|
|
473
|
+
return e;
|
|
474
|
+
}
|
|
475
|
+
const ve = /* @__PURE__ */ Symbol("brick-pdf-export");
|
|
476
|
+
function _t(e) {
|
|
477
|
+
return e.map(he);
|
|
478
|
+
}
|
|
479
|
+
function he(e) {
|
|
480
|
+
const t = F(e.type);
|
|
481
|
+
return t ? t.toPdfmake(e, _t) : { text: `[Unknown: ${e.type}]` };
|
|
482
|
+
}
|
|
483
|
+
function kt(e) {
|
|
484
|
+
function t() {
|
|
485
|
+
const o = e.document;
|
|
486
|
+
return {
|
|
487
|
+
pageSize: o.pageSize,
|
|
488
|
+
pageOrientation: o.pageOrientation,
|
|
489
|
+
pageMargins: o.pageMargins,
|
|
490
|
+
defaultStyle: JSON.parse(JSON.stringify(H(o.defaultStyle))),
|
|
491
|
+
styles: JSON.parse(JSON.stringify(H(o.styles))),
|
|
492
|
+
content: o.content.map(he)
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
async function n() {
|
|
496
|
+
const o = await import("pdfmake/build/pdfmake"), d = await import("pdfmake/build/vfs_fonts"), u = o.default || o, p = d.pdfMake;
|
|
497
|
+
return p && p.vfs ? u.vfs = p.vfs : d.default && (u.vfs = d.default), u;
|
|
498
|
+
}
|
|
499
|
+
function i(o) {
|
|
500
|
+
const d = t();
|
|
501
|
+
n().then((u) => {
|
|
502
|
+
u.createPdf(d).download(o ?? "document.pdf");
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
function c() {
|
|
506
|
+
const o = t();
|
|
507
|
+
n().then((d) => {
|
|
508
|
+
d.createPdf(o).open();
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
return { toDocumentDefinition: t, exportPdf: i, openPdf: c };
|
|
512
|
+
}
|
|
513
|
+
function xt(e) {
|
|
514
|
+
L(ve, e);
|
|
515
|
+
}
|
|
516
|
+
function St() {
|
|
517
|
+
const e = M(ve);
|
|
518
|
+
if (!e)
|
|
519
|
+
throw new Error("usePdfExport() requires a BrickPdf ancestor component");
|
|
520
|
+
return e;
|
|
521
|
+
}
|
|
522
|
+
const _e = /* @__PURE__ */ Symbol("brick-pdf-clipboard");
|
|
523
|
+
let Ct = 0;
|
|
524
|
+
function wt() {
|
|
525
|
+
return `el-${Date.now()}-${++Ct}`;
|
|
526
|
+
}
|
|
527
|
+
function ke(e) {
|
|
528
|
+
return {
|
|
529
|
+
...e,
|
|
530
|
+
id: wt(),
|
|
531
|
+
props: structuredClone(e.props),
|
|
532
|
+
style: structuredClone(e.style),
|
|
533
|
+
children: e.children.map(ke)
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function Pt(e, t) {
|
|
537
|
+
const n = E(null), i = E(!1), c = E(null), o = E(!1);
|
|
538
|
+
function d(r) {
|
|
539
|
+
const l = e.findNodeById(r);
|
|
540
|
+
l && (n.value = structuredClone(l.node), i.value = !1, c.value = null, o.value = !0);
|
|
541
|
+
}
|
|
542
|
+
function u(r) {
|
|
543
|
+
const l = e.findNodeById(r);
|
|
544
|
+
l && (n.value = structuredClone(l.node), i.value = !0, c.value = r, o.value = !0);
|
|
545
|
+
}
|
|
546
|
+
function p(r) {
|
|
547
|
+
if (!n.value) return;
|
|
548
|
+
i.value && c.value && (t.removeElement(c.value), i.value = !1, c.value = null);
|
|
549
|
+
const l = ke(n.value), y = r ? e.findNodeById(r)?.node.children : e.document.content;
|
|
550
|
+
y && (y.push(l), i.value && (n.value = null, o.value = !1));
|
|
551
|
+
}
|
|
552
|
+
return { hasClipboard: o, copy: d, cut: u, paste: p };
|
|
553
|
+
}
|
|
554
|
+
function Et(e) {
|
|
555
|
+
L(_e, e);
|
|
556
|
+
}
|
|
557
|
+
function rr() {
|
|
558
|
+
const e = M(_e);
|
|
559
|
+
if (!e)
|
|
560
|
+
throw new Error("useClipboard() requires a BrickPdf ancestor component");
|
|
561
|
+
return e;
|
|
562
|
+
}
|
|
563
|
+
const xe = /* @__PURE__ */ Symbol("brick-pdf-resize");
|
|
564
|
+
function $t(e) {
|
|
565
|
+
const t = E(!1);
|
|
566
|
+
function n(i, c, o, d) {
|
|
567
|
+
t.value = !0;
|
|
568
|
+
const u = d.clientX, p = d.clientY, r = o.width, l = o.height;
|
|
569
|
+
function y(m) {
|
|
570
|
+
const g = m.clientX - u, v = m.clientY - p;
|
|
571
|
+
let h = r, x = l;
|
|
572
|
+
c.includes("e") && (h = r + g), c.includes("w") && (h = r - g), c.includes("s") && (x = l + v), c.includes("n") && (x = l - v), h = Math.max(20, h), x = Math.max(20, x), e.updateStyle(i, {
|
|
573
|
+
width: Math.round(h),
|
|
574
|
+
height: Math.round(x)
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
function b() {
|
|
578
|
+
t.value = !1, document.removeEventListener("pointermove", y), document.removeEventListener("pointerup", b);
|
|
579
|
+
}
|
|
580
|
+
document.addEventListener("pointermove", y), document.addEventListener("pointerup", b);
|
|
581
|
+
}
|
|
582
|
+
return { isResizing: t, startResize: n };
|
|
583
|
+
}
|
|
584
|
+
function It(e) {
|
|
585
|
+
L(xe, e);
|
|
586
|
+
}
|
|
587
|
+
function lr() {
|
|
588
|
+
const e = M(xe);
|
|
589
|
+
if (!e)
|
|
590
|
+
throw new Error("useResize() requires a BrickPdf ancestor component");
|
|
591
|
+
return e;
|
|
592
|
+
}
|
|
593
|
+
const Rt = { class: "brick-table-editor" }, Dt = { class: "brick-table-editor__grid" }, zt = ["onClick"], Tt = { class: "brick-table-editor__row-header" }, Nt = ["onClick"], Lt = ["value", "onInput"], Mt = /* @__PURE__ */ _({
|
|
594
|
+
__name: "TablePropertyEditor",
|
|
595
|
+
props: {
|
|
596
|
+
node: {}
|
|
597
|
+
},
|
|
598
|
+
setup(e) {
|
|
599
|
+
const t = e, n = Y();
|
|
600
|
+
function i() {
|
|
601
|
+
return t.node.props.body ?? [];
|
|
602
|
+
}
|
|
603
|
+
function c() {
|
|
604
|
+
return t.node.props.widths ?? [];
|
|
605
|
+
}
|
|
606
|
+
function o(l, y, b) {
|
|
607
|
+
const m = i().map((g) => [...g]);
|
|
608
|
+
m[l][y] = b, n.updateProps(t.node.id, { body: m });
|
|
609
|
+
}
|
|
610
|
+
function d() {
|
|
611
|
+
const l = i().map((b) => [...b]), y = l[0]?.length ?? 2;
|
|
612
|
+
l.push(Array(y).fill("")), n.updateProps(t.node.id, { body: l });
|
|
613
|
+
}
|
|
614
|
+
function u(l) {
|
|
615
|
+
const y = i().map((m) => [...m]);
|
|
616
|
+
if (y.length <= 1) return;
|
|
617
|
+
y.splice(l, 1), t.node.props.headerRows > y.length ? n.updateProps(t.node.id, { body: y, headerRows: y.length }) : n.updateProps(t.node.id, { body: y });
|
|
618
|
+
}
|
|
619
|
+
function p() {
|
|
620
|
+
const l = i().map((b) => [...b, ""]), y = [...c(), "*"];
|
|
621
|
+
n.updateProps(t.node.id, { body: l, widths: y });
|
|
622
|
+
}
|
|
623
|
+
function r(l) {
|
|
624
|
+
const y = i().map((m) => {
|
|
625
|
+
const g = [...m];
|
|
626
|
+
return g.splice(l, 1), g;
|
|
627
|
+
});
|
|
628
|
+
if ((y[0]?.length ?? 0) < 1) return;
|
|
629
|
+
const b = [...c()];
|
|
630
|
+
b.splice(l, 1), n.updateProps(t.node.id, { body: y, widths: b });
|
|
631
|
+
}
|
|
632
|
+
return (l, y) => (s(), a("div", Rt, [
|
|
633
|
+
f("div", { class: "brick-table-editor__actions" }, [
|
|
634
|
+
f("button", {
|
|
635
|
+
class: "brick-table-editor__btn",
|
|
636
|
+
onClick: d
|
|
637
|
+
}, "+ Row"),
|
|
638
|
+
f("button", {
|
|
639
|
+
class: "brick-table-editor__btn",
|
|
640
|
+
onClick: p
|
|
641
|
+
}, "+ Column")
|
|
642
|
+
]),
|
|
643
|
+
f("div", Dt, [
|
|
644
|
+
f("table", null, [
|
|
645
|
+
f("thead", null, [
|
|
646
|
+
f("tr", null, [
|
|
647
|
+
y[0] || (y[0] = f("th", { class: "brick-table-editor__corner" }, null, -1)),
|
|
648
|
+
(s(!0), a(C, null, P(i()[0] ?? [], (b, m) => (s(), a("th", {
|
|
649
|
+
key: m,
|
|
650
|
+
class: "brick-table-editor__col-header"
|
|
651
|
+
}, [
|
|
652
|
+
ne(" Col " + w(m + 1) + " ", 1),
|
|
653
|
+
(i()[0]?.length ?? 0) > 1 ? (s(), a("button", {
|
|
654
|
+
key: 0,
|
|
655
|
+
class: "brick-table-editor__remove-btn",
|
|
656
|
+
title: "Remove column",
|
|
657
|
+
onClick: (g) => r(m)
|
|
658
|
+
}, "x", 8, zt)) : I("", !0)
|
|
659
|
+
]))), 128))
|
|
660
|
+
])
|
|
661
|
+
]),
|
|
662
|
+
f("tbody", null, [
|
|
663
|
+
(s(!0), a(C, null, P(i(), (b, m) => (s(), a("tr", { key: m }, [
|
|
664
|
+
f("td", Tt, [
|
|
665
|
+
ne(w(m + 1) + " ", 1),
|
|
666
|
+
i().length > 1 ? (s(), a("button", {
|
|
667
|
+
key: 0,
|
|
668
|
+
class: "brick-table-editor__remove-btn",
|
|
669
|
+
title: "Remove row",
|
|
670
|
+
onClick: (g) => u(m)
|
|
671
|
+
}, "x", 8, Nt)) : I("", !0)
|
|
672
|
+
]),
|
|
673
|
+
(s(!0), a(C, null, P(b, (g, v) => (s(), a("td", { key: v }, [
|
|
674
|
+
f("input", {
|
|
675
|
+
class: "brick-table-editor__cell",
|
|
676
|
+
type: "text",
|
|
677
|
+
value: g,
|
|
678
|
+
onInput: (h) => o(m, v, h.target.value)
|
|
679
|
+
}, null, 40, Lt)
|
|
680
|
+
]))), 128))
|
|
681
|
+
]))), 128))
|
|
682
|
+
])
|
|
683
|
+
])
|
|
684
|
+
])
|
|
685
|
+
]));
|
|
686
|
+
}
|
|
687
|
+
}), Bt = /* @__PURE__ */ S(Mt, [["__scopeId", "data-v-4895020c"]]), Ot = {
|
|
688
|
+
type: "table",
|
|
689
|
+
label: "Table",
|
|
690
|
+
icon: "▦",
|
|
691
|
+
isContainer: !1,
|
|
692
|
+
defaultProps: nt,
|
|
693
|
+
defaultStyle: ot,
|
|
694
|
+
rendererComponent: it,
|
|
695
|
+
propertyEditorComponent: Bt,
|
|
696
|
+
propertyFields: [
|
|
697
|
+
{ key: "props.headerRows", label: "Header Rows", section: "content", type: "number", min: 0, max: 10, step: 1, defaultValue: 1 },
|
|
698
|
+
{ key: "props.layout", label: "Border Style", section: "style", type: "select", options: [
|
|
699
|
+
{ label: "Light Lines", value: "lightHorizontalLines" },
|
|
700
|
+
{ label: "Grid", value: "grid" },
|
|
701
|
+
{ label: "Header Only", value: "headerLineOnly" },
|
|
702
|
+
{ label: "No Borders", value: "noBorders" },
|
|
703
|
+
{ label: "None", value: "none" }
|
|
704
|
+
], defaultValue: "lightHorizontalLines" },
|
|
705
|
+
{ key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
|
|
706
|
+
{ key: "style.color", label: "Text Color", section: "style", type: "color", defaultValue: "#000000" },
|
|
707
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
708
|
+
],
|
|
709
|
+
toPdfmake: rt
|
|
710
|
+
};
|
|
711
|
+
function Vt() {
|
|
712
|
+
return { src: "", width: 200, height: 150, fit: null };
|
|
713
|
+
}
|
|
714
|
+
function At() {
|
|
715
|
+
return {};
|
|
716
|
+
}
|
|
717
|
+
function Ht(e) {
|
|
718
|
+
const t = {
|
|
719
|
+
image: e.props.src
|
|
720
|
+
};
|
|
721
|
+
return e.props.width && (t.width = e.props.width), e.props.height && (t.height = e.props.height), e.props.fit && (t.fit = e.props.fit), e.style.margin && (t.margin = e.style.margin), e.style.alignment && (t.alignment = e.style.alignment), e.style.opacity !== void 0 && (t.opacity = e.style.opacity), t;
|
|
722
|
+
}
|
|
723
|
+
const Ft = { class: "brick-el-image" }, Ut = ["src"], Wt = {
|
|
724
|
+
key: 1,
|
|
725
|
+
class: "brick-el-image__placeholder"
|
|
726
|
+
}, Jt = /* @__PURE__ */ _({
|
|
727
|
+
__name: "ImageRenderer",
|
|
728
|
+
props: {
|
|
729
|
+
node: {}
|
|
730
|
+
},
|
|
731
|
+
setup(e) {
|
|
732
|
+
return (t, n) => (s(), a("div", Ft, [
|
|
733
|
+
e.node.props.src ? (s(), a("img", {
|
|
734
|
+
key: 0,
|
|
735
|
+
src: e.node.props.src,
|
|
736
|
+
style: R({
|
|
737
|
+
width: e.node.props.width + "px",
|
|
738
|
+
height: e.node.props.height + "px",
|
|
739
|
+
objectFit: "contain",
|
|
740
|
+
opacity: e.node.style.opacity
|
|
741
|
+
})
|
|
742
|
+
}, null, 12, Ut)) : (s(), a("div", Wt, " No image selected "))
|
|
743
|
+
]));
|
|
744
|
+
}
|
|
745
|
+
}), Yt = /* @__PURE__ */ S(Jt, [["__scopeId", "data-v-38184258"]]), qt = { class: "brick-image-editor" }, jt = /* @__PURE__ */ _({
|
|
746
|
+
__name: "ImagePropertyEditor",
|
|
747
|
+
props: {
|
|
748
|
+
node: {}
|
|
749
|
+
},
|
|
750
|
+
setup(e) {
|
|
751
|
+
return (t, n) => (s(), a("div", qt));
|
|
752
|
+
}
|
|
753
|
+
}), Gt = {
|
|
754
|
+
type: "image",
|
|
755
|
+
label: "Image",
|
|
756
|
+
icon: "🖼",
|
|
757
|
+
isContainer: !1,
|
|
758
|
+
defaultProps: Vt,
|
|
759
|
+
defaultStyle: At,
|
|
760
|
+
rendererComponent: Yt,
|
|
761
|
+
propertyEditorComponent: jt,
|
|
762
|
+
propertyFields: [
|
|
763
|
+
{ key: "props.src", label: "Image (Base64)", section: "content", type: "file" },
|
|
764
|
+
{ key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
|
|
765
|
+
{ key: "props.height", label: "Height", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 150 },
|
|
766
|
+
{ key: "style.alignment", label: "Alignment", section: "style", type: "select", options: [
|
|
767
|
+
{ label: "Left", value: "left" },
|
|
768
|
+
{ label: "Center", value: "center" },
|
|
769
|
+
{ label: "Right", value: "right" }
|
|
770
|
+
] },
|
|
771
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] },
|
|
772
|
+
{ key: "style.opacity", label: "Opacity", section: "advanced", type: "slider", min: 0, max: 1, step: 0.1, defaultValue: 1 }
|
|
773
|
+
],
|
|
774
|
+
toPdfmake: Ht
|
|
775
|
+
};
|
|
776
|
+
function Xt() {
|
|
777
|
+
return { ordered: !1, items: ["Item 1", "Item 2", "Item 3"] };
|
|
778
|
+
}
|
|
779
|
+
function Kt() {
|
|
780
|
+
return { fontSize: 12 };
|
|
781
|
+
}
|
|
782
|
+
function Qt(e) {
|
|
783
|
+
const t = e.props.items, i = e.props.ordered ? { ol: t } : { ul: t };
|
|
784
|
+
return e.style.fontSize && (i.fontSize = e.style.fontSize), e.style.color && (i.color = e.style.color), e.style.margin && (i.margin = e.style.margin), i;
|
|
785
|
+
}
|
|
786
|
+
const Zt = /* @__PURE__ */ _({
|
|
787
|
+
__name: "ListRenderer",
|
|
788
|
+
props: {
|
|
789
|
+
node: {}
|
|
790
|
+
},
|
|
791
|
+
setup(e) {
|
|
792
|
+
return (t, n) => (s(), a("div", {
|
|
793
|
+
class: "brick-el-list",
|
|
794
|
+
style: R({ fontSize: (e.node.style.fontSize ?? 12) + "px", color: e.node.style.color })
|
|
795
|
+
}, [
|
|
796
|
+
(s(), B(Q(e.node.props.ordered ? "ol" : "ul"), null, {
|
|
797
|
+
default: W(() => [
|
|
798
|
+
(s(!0), a(C, null, P(e.node.props.items, (i, c) => (s(), a("li", { key: c }, w(i), 1))), 128))
|
|
799
|
+
]),
|
|
800
|
+
_: 1
|
|
801
|
+
}))
|
|
802
|
+
], 4));
|
|
803
|
+
}
|
|
804
|
+
}), en = /* @__PURE__ */ S(Zt, [["__scopeId", "data-v-8107f859"]]), tn = { class: "brick-list-editor" }, nn = /* @__PURE__ */ _({
|
|
805
|
+
__name: "ListPropertyEditor",
|
|
806
|
+
props: {
|
|
807
|
+
node: {}
|
|
808
|
+
},
|
|
809
|
+
setup(e) {
|
|
810
|
+
return (t, n) => (s(), a("div", tn));
|
|
811
|
+
}
|
|
812
|
+
}), on = {
|
|
813
|
+
type: "list",
|
|
814
|
+
label: "List",
|
|
815
|
+
icon: "☰",
|
|
816
|
+
isContainer: !1,
|
|
817
|
+
defaultProps: Xt,
|
|
818
|
+
defaultStyle: Kt,
|
|
819
|
+
rendererComponent: en,
|
|
820
|
+
propertyEditorComponent: nn,
|
|
821
|
+
propertyFields: [
|
|
822
|
+
{ key: "props.ordered", label: "Ordered", section: "content", type: "toggle", defaultValue: !1 },
|
|
823
|
+
{ key: "props.items", label: "Items", section: "content", type: "textarea", defaultValue: `Item 1
|
|
824
|
+
Item 2
|
|
825
|
+
Item 3` },
|
|
826
|
+
{ key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
|
|
827
|
+
{ key: "style.color", label: "Color", section: "style", type: "color", defaultValue: "#000000" },
|
|
828
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
829
|
+
],
|
|
830
|
+
toPdfmake: Qt
|
|
831
|
+
};
|
|
832
|
+
function rn() {
|
|
833
|
+
return { data: "https://example.com", fit: 100 };
|
|
834
|
+
}
|
|
835
|
+
function ln() {
|
|
836
|
+
return {};
|
|
837
|
+
}
|
|
838
|
+
function sn(e) {
|
|
839
|
+
const t = {
|
|
840
|
+
qr: e.props.data,
|
|
841
|
+
fit: e.props.fit ?? 100
|
|
842
|
+
};
|
|
843
|
+
return e.style.alignment && (t.alignment = e.style.alignment), e.style.margin && (t.margin = e.style.margin), t;
|
|
844
|
+
}
|
|
845
|
+
const an = { class: "brick-el-qr__preview" }, cn = /* @__PURE__ */ _({
|
|
846
|
+
__name: "QrRenderer",
|
|
847
|
+
props: {
|
|
848
|
+
node: {}
|
|
849
|
+
},
|
|
850
|
+
setup(e) {
|
|
851
|
+
return (t, n) => (s(), a("div", {
|
|
852
|
+
class: "brick-el-qr",
|
|
853
|
+
style: R({
|
|
854
|
+
width: (e.node.props.fit ?? 100) + "px",
|
|
855
|
+
height: (e.node.props.fit ?? 100) + "px"
|
|
856
|
+
})
|
|
857
|
+
}, [
|
|
858
|
+
f("div", an, "QR: " + w(e.node.props.data), 1)
|
|
859
|
+
], 4));
|
|
860
|
+
}
|
|
861
|
+
}), dn = /* @__PURE__ */ S(cn, [["__scopeId", "data-v-f106ba48"]]), un = { class: "brick-qr-editor" }, pn = /* @__PURE__ */ _({
|
|
862
|
+
__name: "QrPropertyEditor",
|
|
863
|
+
props: {
|
|
864
|
+
node: {}
|
|
865
|
+
},
|
|
866
|
+
setup(e) {
|
|
867
|
+
return (t, n) => (s(), a("div", un));
|
|
868
|
+
}
|
|
869
|
+
}), fn = {
|
|
870
|
+
type: "qr",
|
|
871
|
+
label: "QR Code",
|
|
872
|
+
icon: "⊞",
|
|
873
|
+
isContainer: !1,
|
|
874
|
+
defaultProps: rn,
|
|
875
|
+
defaultStyle: ln,
|
|
876
|
+
rendererComponent: dn,
|
|
877
|
+
propertyEditorComponent: pn,
|
|
878
|
+
propertyFields: [
|
|
879
|
+
{ key: "props.data", label: "QR Data", section: "content", type: "text", defaultValue: "https://example.com" },
|
|
880
|
+
{ key: "props.fit", label: "Size (px)", section: "layout", type: "number", min: 50, max: 500, step: 10, defaultValue: 100 },
|
|
881
|
+
{ key: "style.alignment", label: "Alignment", section: "style", type: "select", options: [
|
|
882
|
+
{ label: "Left", value: "left" },
|
|
883
|
+
{ label: "Center", value: "center" },
|
|
884
|
+
{ label: "Right", value: "right" }
|
|
885
|
+
] },
|
|
886
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
887
|
+
],
|
|
888
|
+
toPdfmake: sn
|
|
889
|
+
};
|
|
890
|
+
function mn() {
|
|
891
|
+
return {
|
|
892
|
+
svg: '<svg viewBox="0 0 100 100"><rect width="100" height="100" fill="#eee" /><text x="50" y="55" text-anchor="middle" font-size="12">SVG</text></svg>',
|
|
893
|
+
width: 200,
|
|
894
|
+
height: 200
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
function yn() {
|
|
898
|
+
return {};
|
|
899
|
+
}
|
|
900
|
+
function gn(e) {
|
|
901
|
+
const t = {
|
|
902
|
+
svg: e.props.svg
|
|
903
|
+
};
|
|
904
|
+
return e.props.width && (t.width = e.props.width), e.props.height && (t.height = e.props.height), e.style.margin && (t.margin = e.style.margin), e.style.alignment && (t.alignment = e.style.alignment), t;
|
|
905
|
+
}
|
|
906
|
+
const bn = ["innerHTML"], vn = /* @__PURE__ */ _({
|
|
907
|
+
__name: "SvgRenderer",
|
|
908
|
+
props: {
|
|
909
|
+
node: {}
|
|
910
|
+
},
|
|
911
|
+
setup(e) {
|
|
912
|
+
return (t, n) => (s(), a("div", {
|
|
913
|
+
class: "brick-el-svg",
|
|
914
|
+
style: R({
|
|
915
|
+
width: e.node.props.width + "px",
|
|
916
|
+
height: e.node.props.height + "px"
|
|
917
|
+
}),
|
|
918
|
+
innerHTML: e.node.props.svg
|
|
919
|
+
}, null, 12, bn));
|
|
920
|
+
}
|
|
921
|
+
}), hn = /* @__PURE__ */ S(vn, [["__scopeId", "data-v-5e9f3319"]]), _n = { class: "brick-svg-editor" }, kn = /* @__PURE__ */ _({
|
|
922
|
+
__name: "SvgPropertyEditor",
|
|
923
|
+
props: {
|
|
924
|
+
node: {}
|
|
925
|
+
},
|
|
926
|
+
setup(e) {
|
|
927
|
+
return (t, n) => (s(), a("div", _n));
|
|
928
|
+
}
|
|
929
|
+
}), xn = {
|
|
930
|
+
type: "svg",
|
|
931
|
+
label: "SVG",
|
|
932
|
+
icon: "◇",
|
|
933
|
+
isContainer: !1,
|
|
934
|
+
defaultProps: mn,
|
|
935
|
+
defaultStyle: yn,
|
|
936
|
+
rendererComponent: hn,
|
|
937
|
+
propertyEditorComponent: kn,
|
|
938
|
+
propertyFields: [
|
|
939
|
+
{ key: "props.svg", label: "SVG Markup", section: "content", type: "textarea" },
|
|
940
|
+
{ key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
|
|
941
|
+
{ key: "props.height", label: "Height", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
|
|
942
|
+
{ key: "style.alignment", label: "Alignment", section: "style", type: "select", options: [
|
|
943
|
+
{ label: "Left", value: "left" },
|
|
944
|
+
{ label: "Center", value: "center" },
|
|
945
|
+
{ label: "Right", value: "right" }
|
|
946
|
+
] },
|
|
947
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
948
|
+
],
|
|
949
|
+
toPdfmake: gn
|
|
950
|
+
};
|
|
951
|
+
function Sn() {
|
|
952
|
+
return {
|
|
953
|
+
commands: [
|
|
954
|
+
{ type: "rect", x: 0, y: 0, w: 200, h: 100, color: "#eeeeee" }
|
|
955
|
+
],
|
|
956
|
+
width: 200,
|
|
957
|
+
height: 100
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function Cn() {
|
|
961
|
+
return {};
|
|
962
|
+
}
|
|
963
|
+
function wn(e) {
|
|
964
|
+
const t = {
|
|
965
|
+
canvas: e.props.commands
|
|
966
|
+
};
|
|
967
|
+
return e.style.margin && (t.margin = e.style.margin), t;
|
|
968
|
+
}
|
|
969
|
+
const Pn = /* @__PURE__ */ _({
|
|
970
|
+
__name: "CanvasDrawRenderer",
|
|
971
|
+
props: {
|
|
972
|
+
node: {}
|
|
973
|
+
},
|
|
974
|
+
setup(e) {
|
|
975
|
+
return (t, n) => (s(), a("div", {
|
|
976
|
+
class: "brick-el-canvas",
|
|
977
|
+
style: R({
|
|
978
|
+
width: (e.node.props.width ?? 200) + "px",
|
|
979
|
+
height: (e.node.props.height ?? 100) + "px"
|
|
980
|
+
})
|
|
981
|
+
}, [...n[0] || (n[0] = [
|
|
982
|
+
f("div", { class: "brick-el-canvas__label" }, "Canvas Drawing", -1)
|
|
983
|
+
])], 4));
|
|
984
|
+
}
|
|
985
|
+
}), En = /* @__PURE__ */ S(Pn, [["__scopeId", "data-v-1b986707"]]), $n = { class: "brick-canvas-editor" }, In = /* @__PURE__ */ _({
|
|
986
|
+
__name: "CanvasDrawPropertyEditor",
|
|
987
|
+
props: {
|
|
988
|
+
node: {}
|
|
989
|
+
},
|
|
990
|
+
setup(e) {
|
|
991
|
+
return (t, n) => (s(), a("div", $n));
|
|
992
|
+
}
|
|
993
|
+
}), Rn = {
|
|
994
|
+
type: "canvas",
|
|
995
|
+
label: "Canvas",
|
|
996
|
+
icon: "△",
|
|
997
|
+
isContainer: !1,
|
|
998
|
+
defaultProps: Sn,
|
|
999
|
+
defaultStyle: Cn,
|
|
1000
|
+
rendererComponent: En,
|
|
1001
|
+
propertyEditorComponent: In,
|
|
1002
|
+
propertyFields: [
|
|
1003
|
+
{ key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
|
|
1004
|
+
{ key: "props.height", label: "Height", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 100 },
|
|
1005
|
+
{ key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
|
|
1006
|
+
],
|
|
1007
|
+
toPdfmake: wn
|
|
1008
|
+
};
|
|
1009
|
+
function Dn() {
|
|
1010
|
+
return {};
|
|
1011
|
+
}
|
|
1012
|
+
function zn() {
|
|
1013
|
+
return {};
|
|
1014
|
+
}
|
|
1015
|
+
function Tn(e) {
|
|
1016
|
+
return { text: "", pageBreak: "after" };
|
|
1017
|
+
}
|
|
1018
|
+
const Nn = { class: "brick-el-pagebreak" }, Ln = /* @__PURE__ */ _({
|
|
1019
|
+
__name: "PageBreakRenderer",
|
|
1020
|
+
props: {
|
|
1021
|
+
node: {}
|
|
1022
|
+
},
|
|
1023
|
+
setup(e) {
|
|
1024
|
+
return (t, n) => (s(), a("div", Nn, [...n[0] || (n[0] = [
|
|
1025
|
+
f("hr", null, null, -1),
|
|
1026
|
+
f("span", null, "Page Break", -1),
|
|
1027
|
+
f("hr", null, null, -1)
|
|
1028
|
+
])]));
|
|
1029
|
+
}
|
|
1030
|
+
}), Mn = /* @__PURE__ */ S(Ln, [["__scopeId", "data-v-60c05148"]]), Bn = { class: "brick-pagebreak-editor" }, On = /* @__PURE__ */ _({
|
|
1031
|
+
__name: "PageBreakPropertyEditor",
|
|
1032
|
+
props: {
|
|
1033
|
+
node: {}
|
|
1034
|
+
},
|
|
1035
|
+
setup(e) {
|
|
1036
|
+
return (t, n) => (s(), a("div", Bn, [...n[0] || (n[0] = [
|
|
1037
|
+
f("p", { style: { color: "#999", "font-size": "12px" } }, "No configurable properties.", -1)
|
|
1038
|
+
])]));
|
|
1039
|
+
}
|
|
1040
|
+
}), Vn = {
|
|
1041
|
+
type: "pageBreak",
|
|
1042
|
+
label: "Page Break",
|
|
1043
|
+
icon: "⏎",
|
|
1044
|
+
isContainer: !1,
|
|
1045
|
+
defaultProps: Dn,
|
|
1046
|
+
defaultStyle: zn,
|
|
1047
|
+
rendererComponent: Mn,
|
|
1048
|
+
propertyEditorComponent: On,
|
|
1049
|
+
propertyFields: [],
|
|
1050
|
+
toPdfmake: Tn
|
|
1051
|
+
};
|
|
1052
|
+
let ie = !1;
|
|
1053
|
+
function An() {
|
|
1054
|
+
ie || (ie = !0, z(Ve), z(qe), z(tt), z(Ot), z(Gt), z(on), z(fn), z(xn), z(Rn), z(Vn));
|
|
1055
|
+
}
|
|
1056
|
+
const Hn = {
|
|
1057
|
+
key: 0,
|
|
1058
|
+
class: "brick-dropzone__empty"
|
|
1059
|
+
}, Fn = /* @__PURE__ */ _({
|
|
1060
|
+
__name: "DropZone",
|
|
1061
|
+
props: {
|
|
1062
|
+
parentId: {},
|
|
1063
|
+
layout: {}
|
|
1064
|
+
},
|
|
1065
|
+
setup(e) {
|
|
1066
|
+
const t = e, n = E(null);
|
|
1067
|
+
let i = null;
|
|
1068
|
+
const c = be();
|
|
1069
|
+
return se(() => {
|
|
1070
|
+
n.value && (i = c.initContainer(n.value, t.parentId));
|
|
1071
|
+
}), ae(() => {
|
|
1072
|
+
i?.destroy();
|
|
1073
|
+
}), (o, d) => (s(), a("div", {
|
|
1074
|
+
ref_key: "el",
|
|
1075
|
+
ref: n,
|
|
1076
|
+
class: K(["brick-dropzone", { "brick-dropzone--horizontal": e.layout === "horizontal" }])
|
|
1077
|
+
}, [
|
|
1078
|
+
X(o.$slots, "default", {}, void 0, !0),
|
|
1079
|
+
o.$slots.default ? I("", !0) : (s(), a("div", Hn, " Drop elements here "))
|
|
1080
|
+
], 2));
|
|
1081
|
+
}
|
|
1082
|
+
}), Se = /* @__PURE__ */ S(Fn, [["__scopeId", "data-v-c33d3667"]]), Un = ["data-element-id", "data-element-type"], Wn = {
|
|
1083
|
+
key: 1,
|
|
1084
|
+
class: "brick-canvas-element__unknown"
|
|
1085
|
+
}, Jn = /* @__PURE__ */ _({
|
|
1086
|
+
__name: "CanvasElement",
|
|
1087
|
+
props: {
|
|
1088
|
+
node: {},
|
|
1089
|
+
path: {}
|
|
1090
|
+
},
|
|
1091
|
+
setup(e) {
|
|
1092
|
+
const t = e, n = U(), i = Y(), c = E(null), o = $(() => F(t.node.type)), d = $(() => n.selectedId.value === t.node.id), u = $(() => o.value ? o.value.propertyFields.some((m) => m.key === "props.width" || m.key === "style.width") : !1), p = $(() => o.value ? o.value.propertyFields.some((m) => m.key === "props.height" || m.key === "style.height") : !1);
|
|
1093
|
+
function r(m) {
|
|
1094
|
+
m.stopPropagation(), n.select(t.node.id);
|
|
1095
|
+
}
|
|
1096
|
+
function l(m) {
|
|
1097
|
+
m.stopPropagation(), m.preventDefault();
|
|
1098
|
+
const g = m.clientX, v = c.value?.offsetWidth ?? 200;
|
|
1099
|
+
function h(D) {
|
|
1100
|
+
const V = D.clientX - g, T = Math.max(20, v + V);
|
|
1101
|
+
o.value?.propertyFields.some((A) => A.key === "props.width") ? i.updateProps(t.node.id, { width: Math.round(T) }) : i.updateStyle(t.node.id, { width: Math.round(T) });
|
|
1102
|
+
}
|
|
1103
|
+
function x() {
|
|
1104
|
+
document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", x), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
1105
|
+
}
|
|
1106
|
+
document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", h), document.addEventListener("pointerup", x);
|
|
1107
|
+
}
|
|
1108
|
+
function y(m) {
|
|
1109
|
+
m.stopPropagation(), m.preventDefault();
|
|
1110
|
+
const g = m.clientY, v = c.value?.offsetHeight ?? 100;
|
|
1111
|
+
function h(D) {
|
|
1112
|
+
const V = D.clientY - g, T = Math.max(20, v + V);
|
|
1113
|
+
o.value?.propertyFields.some((A) => A.key === "props.height") ? i.updateProps(t.node.id, { height: Math.round(T) }) : i.updateStyle(t.node.id, { height: Math.round(T) });
|
|
1114
|
+
}
|
|
1115
|
+
function x() {
|
|
1116
|
+
document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", x), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
1117
|
+
}
|
|
1118
|
+
document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", h), document.addEventListener("pointerup", x);
|
|
1119
|
+
}
|
|
1120
|
+
function b(m) {
|
|
1121
|
+
m.stopPropagation(), m.preventDefault();
|
|
1122
|
+
const g = m.clientX, v = m.clientY, h = c.value?.offsetWidth ?? 200, x = c.value?.offsetHeight ?? 100;
|
|
1123
|
+
function D(T) {
|
|
1124
|
+
const q = T.clientX - g, A = T.clientY - v, ee = Math.max(20, h + q), te = Math.max(20, x + A), Ce = o.value?.propertyFields.some((j) => j.key === "props.width"), we = o.value?.propertyFields.some((j) => j.key === "props.height");
|
|
1125
|
+
Ce ? i.updateProps(t.node.id, { width: Math.round(ee) }) : i.updateStyle(t.node.id, { width: Math.round(ee) }), we ? i.updateProps(t.node.id, { height: Math.round(te) }) : i.updateStyle(t.node.id, { height: Math.round(te) });
|
|
1126
|
+
}
|
|
1127
|
+
function V() {
|
|
1128
|
+
document.removeEventListener("pointermove", D), document.removeEventListener("pointerup", V), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
1129
|
+
}
|
|
1130
|
+
document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", D), document.addEventListener("pointerup", V);
|
|
1131
|
+
}
|
|
1132
|
+
return (m, g) => {
|
|
1133
|
+
const v = Ee("CanvasElement", !0);
|
|
1134
|
+
return s(), a("div", {
|
|
1135
|
+
ref_key: "elRef",
|
|
1136
|
+
ref: c,
|
|
1137
|
+
class: K(["brick-canvas-element", { "brick-canvas-element--selected": d.value }]),
|
|
1138
|
+
"data-element-id": e.node.id,
|
|
1139
|
+
"data-element-type": e.node.type,
|
|
1140
|
+
style: R({
|
|
1141
|
+
width: typeof e.node.style.width == "number" ? e.node.style.width + "px" : e.node.props.width ? e.node.props.width + "px" : e.node.style.width,
|
|
1142
|
+
height: e.node.style.height ? e.node.style.height + "px" : e.node.props.height ? e.node.props.height + "px" : void 0,
|
|
1143
|
+
marginTop: e.node.style.margin?.[1] + "px",
|
|
1144
|
+
marginRight: e.node.style.margin?.[2] + "px",
|
|
1145
|
+
marginBottom: e.node.style.margin?.[3] + "px",
|
|
1146
|
+
marginLeft: e.node.style.margin?.[0] + "px",
|
|
1147
|
+
textAlign: e.node.style.alignment
|
|
1148
|
+
}),
|
|
1149
|
+
onClick: r
|
|
1150
|
+
}, [
|
|
1151
|
+
o.value ? (s(), B(Q(o.value.rendererComponent), {
|
|
1152
|
+
key: 0,
|
|
1153
|
+
node: e.node,
|
|
1154
|
+
path: e.path
|
|
1155
|
+
}, {
|
|
1156
|
+
default: W(() => [
|
|
1157
|
+
o.value.isContainer ? (s(), B(Se, {
|
|
1158
|
+
key: 0,
|
|
1159
|
+
"parent-id": e.node.id,
|
|
1160
|
+
layout: e.node.type === "columns" ? "horizontal" : "vertical"
|
|
1161
|
+
}, {
|
|
1162
|
+
default: W(() => [
|
|
1163
|
+
(s(!0), a(C, null, P(e.node.children, (h, x) => (s(), B(v, {
|
|
1164
|
+
key: h.id,
|
|
1165
|
+
node: h,
|
|
1166
|
+
path: [...e.path, x]
|
|
1167
|
+
}, null, 8, ["node", "path"]))), 128))
|
|
1168
|
+
]),
|
|
1169
|
+
_: 1
|
|
1170
|
+
}, 8, ["parent-id", "layout"])) : I("", !0)
|
|
1171
|
+
]),
|
|
1172
|
+
_: 1
|
|
1173
|
+
}, 8, ["node", "path"])) : (s(), a("div", Wn, " Unknown element: " + w(e.node.type), 1)),
|
|
1174
|
+
d.value ? (s(), a(C, { key: 2 }, [
|
|
1175
|
+
u.value ? (s(), a("div", {
|
|
1176
|
+
key: 0,
|
|
1177
|
+
class: "brick-resize-handle brick-resize-handle--e",
|
|
1178
|
+
onPointerdown: l
|
|
1179
|
+
}, null, 32)) : I("", !0),
|
|
1180
|
+
p.value ? (s(), a("div", {
|
|
1181
|
+
key: 1,
|
|
1182
|
+
class: "brick-resize-handle brick-resize-handle--s",
|
|
1183
|
+
onPointerdown: y
|
|
1184
|
+
}, null, 32)) : I("", !0),
|
|
1185
|
+
u.value && p.value ? (s(), a("div", {
|
|
1186
|
+
key: 2,
|
|
1187
|
+
class: "brick-resize-handle brick-resize-handle--se",
|
|
1188
|
+
onPointerdown: b
|
|
1189
|
+
}, null, 32)) : I("", !0)
|
|
1190
|
+
], 64)) : I("", !0)
|
|
1191
|
+
], 14, Un);
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
}), Yn = /* @__PURE__ */ S(Jn, [["__scopeId", "data-v-6b9cadc1"]]), qn = { class: "brick-doc-bar" }, jn = { class: "brick-doc-bar__field" }, Gn = ["value"], Xn = { class: "brick-doc-bar__field" }, Kn = { class: "brick-doc-bar__field brick-doc-bar__field--margins" }, Qn = { class: "brick-doc-bar__margins" }, Zn = ["placeholder", "title", "value", "onInput"], eo = { class: "brick-doc-bar__field" }, to = ["value"], no = /* @__PURE__ */ _({
|
|
1195
|
+
__name: "DocumentSettings",
|
|
1196
|
+
setup(e) {
|
|
1197
|
+
const t = Z(), n = [
|
|
1198
|
+
{ label: "A3", value: "A3" },
|
|
1199
|
+
{ label: "A4", value: "A4" },
|
|
1200
|
+
{ label: "A5", value: "A5" },
|
|
1201
|
+
{ label: "Letter", value: "LETTER" },
|
|
1202
|
+
{ label: "Legal", value: "LEGAL" }
|
|
1203
|
+
];
|
|
1204
|
+
function i(c, o) {
|
|
1205
|
+
const d = [...t.document.pageMargins];
|
|
1206
|
+
d[c] = o, t.document.pageMargins = d;
|
|
1207
|
+
}
|
|
1208
|
+
return (c, o) => (s(), a("div", qn, [
|
|
1209
|
+
f("div", jn, [
|
|
1210
|
+
o[3] || (o[3] = f("label", null, "Size", -1)),
|
|
1211
|
+
G(f("select", {
|
|
1212
|
+
"onUpdate:modelValue": o[0] || (o[0] = (d) => k(t).document.pageSize = d)
|
|
1213
|
+
}, [
|
|
1214
|
+
(s(), a(C, null, P(n, (d) => f("option", {
|
|
1215
|
+
key: d.value,
|
|
1216
|
+
value: d.value
|
|
1217
|
+
}, w(d.label), 9, Gn)), 64))
|
|
1218
|
+
], 512), [
|
|
1219
|
+
[oe, k(t).document.pageSize]
|
|
1220
|
+
])
|
|
1221
|
+
]),
|
|
1222
|
+
f("div", Xn, [
|
|
1223
|
+
o[5] || (o[5] = f("label", null, "Orientation", -1)),
|
|
1224
|
+
G(f("select", {
|
|
1225
|
+
"onUpdate:modelValue": o[1] || (o[1] = (d) => k(t).document.pageOrientation = d)
|
|
1226
|
+
}, [...o[4] || (o[4] = [
|
|
1227
|
+
f("option", { value: "portrait" }, "Portrait", -1),
|
|
1228
|
+
f("option", { value: "landscape" }, "Landscape", -1)
|
|
1229
|
+
])], 512), [
|
|
1230
|
+
[oe, k(t).document.pageOrientation]
|
|
1231
|
+
])
|
|
1232
|
+
]),
|
|
1233
|
+
f("div", Kn, [
|
|
1234
|
+
o[6] || (o[6] = f("label", null, "Margins", -1)),
|
|
1235
|
+
f("div", Qn, [
|
|
1236
|
+
(s(), a(C, null, P(["L", "T", "R", "B"], (d, u) => f("input", {
|
|
1237
|
+
key: u,
|
|
1238
|
+
type: "number",
|
|
1239
|
+
placeholder: d,
|
|
1240
|
+
title: d,
|
|
1241
|
+
value: k(t).document.pageMargins[u],
|
|
1242
|
+
onInput: (p) => i(u, Number(p.target.value))
|
|
1243
|
+
}, null, 40, Zn)), 64))
|
|
1244
|
+
])
|
|
1245
|
+
]),
|
|
1246
|
+
f("div", eo, [
|
|
1247
|
+
o[7] || (o[7] = f("label", null, "Font Size", -1)),
|
|
1248
|
+
f("input", {
|
|
1249
|
+
type: "number",
|
|
1250
|
+
value: k(t).document.defaultStyle.fontSize ?? 12,
|
|
1251
|
+
min: "6",
|
|
1252
|
+
max: "72",
|
|
1253
|
+
onInput: o[2] || (o[2] = (d) => k(t).document.defaultStyle.fontSize = Number(d.target.value))
|
|
1254
|
+
}, null, 40, to)
|
|
1255
|
+
])
|
|
1256
|
+
]));
|
|
1257
|
+
}
|
|
1258
|
+
}), oo = /* @__PURE__ */ S(no, [["__scopeId", "data-v-f05c1083"]]), ro = { class: "brick-canvas" }, N = 0.75, lo = /* @__PURE__ */ _({
|
|
1259
|
+
__name: "DesignCanvas",
|
|
1260
|
+
setup(e) {
|
|
1261
|
+
const t = Z(), n = U(), i = {
|
|
1262
|
+
A3: [841.89, 1190.55],
|
|
1263
|
+
A4: [595.28, 841.89],
|
|
1264
|
+
A5: [419.53, 595.28],
|
|
1265
|
+
LETTER: [612, 792],
|
|
1266
|
+
LEGAL: [612, 1008]
|
|
1267
|
+
}, c = $(() => {
|
|
1268
|
+
const [u, p] = i[t.document.pageSize] ?? i.A4, r = t.document.pageOrientation === "landscape" ? p : u;
|
|
1269
|
+
return Math.round(r * N);
|
|
1270
|
+
}), o = $(() => {
|
|
1271
|
+
const [u, p] = i[t.document.pageSize] ?? i.A4, r = t.document.pageOrientation === "landscape" ? u : p;
|
|
1272
|
+
return Math.round(r * N);
|
|
1273
|
+
});
|
|
1274
|
+
function d(u) {
|
|
1275
|
+
(u.target === u.currentTarget || u.target.classList.contains("brick-canvas__page")) && n.deselect();
|
|
1276
|
+
}
|
|
1277
|
+
return (u, p) => (s(), a("div", ro, [
|
|
1278
|
+
O(oo),
|
|
1279
|
+
f("div", {
|
|
1280
|
+
class: "brick-canvas__scroll",
|
|
1281
|
+
onClick: d
|
|
1282
|
+
}, [
|
|
1283
|
+
f("div", {
|
|
1284
|
+
class: "brick-canvas__page",
|
|
1285
|
+
style: R({
|
|
1286
|
+
width: c.value + "px",
|
|
1287
|
+
minHeight: o.value + "px",
|
|
1288
|
+
"--page-height": o.value + "px",
|
|
1289
|
+
"--margin-top": k(t).document.pageMargins[1] * N + "px",
|
|
1290
|
+
"--margin-bottom": k(t).document.pageMargins[3] * N + "px",
|
|
1291
|
+
paddingTop: k(t).document.pageMargins[1] * N + "px",
|
|
1292
|
+
paddingRight: k(t).document.pageMargins[2] * N + "px",
|
|
1293
|
+
paddingBottom: k(t).document.pageMargins[3] * N + "px",
|
|
1294
|
+
paddingLeft: k(t).document.pageMargins[0] * N + "px"
|
|
1295
|
+
})
|
|
1296
|
+
}, [
|
|
1297
|
+
O(Se, { "parent-id": null }, {
|
|
1298
|
+
default: W(() => [
|
|
1299
|
+
(s(!0), a(C, null, P(k(t).document.content, (r, l) => (s(), B(Yn, {
|
|
1300
|
+
key: r.id,
|
|
1301
|
+
node: r,
|
|
1302
|
+
path: [l]
|
|
1303
|
+
}, null, 8, ["node", "path"]))), 128))
|
|
1304
|
+
]),
|
|
1305
|
+
_: 1
|
|
1306
|
+
})
|
|
1307
|
+
], 4)
|
|
1308
|
+
])
|
|
1309
|
+
]));
|
|
1310
|
+
}
|
|
1311
|
+
}), io = /* @__PURE__ */ S(lo, [["__scopeId", "data-v-f40597a5"]]), so = ["data-element-type"], ao = { class: "brick-element-list__icon" }, co = { class: "brick-element-list__label" }, uo = /* @__PURE__ */ _({
|
|
1312
|
+
__name: "ToolbarElementList",
|
|
1313
|
+
setup(e) {
|
|
1314
|
+
const t = E(null);
|
|
1315
|
+
let n = null;
|
|
1316
|
+
const i = be(), c = De();
|
|
1317
|
+
return se(() => {
|
|
1318
|
+
t.value && (n = i.initToolbar(t.value));
|
|
1319
|
+
}), ae(() => {
|
|
1320
|
+
n?.destroy();
|
|
1321
|
+
}), (o, d) => (s(), a("div", {
|
|
1322
|
+
ref_key: "el",
|
|
1323
|
+
ref: t,
|
|
1324
|
+
class: "brick-element-list"
|
|
1325
|
+
}, [
|
|
1326
|
+
(s(!0), a(C, null, P(k(c), (u) => (s(), a("div", {
|
|
1327
|
+
key: u.type,
|
|
1328
|
+
class: "brick-element-list__item",
|
|
1329
|
+
"data-element-type": u.type
|
|
1330
|
+
}, [
|
|
1331
|
+
f("span", ao, w(u.icon), 1),
|
|
1332
|
+
f("span", co, w(u.label), 1)
|
|
1333
|
+
], 8, so))), 128))
|
|
1334
|
+
], 512));
|
|
1335
|
+
}
|
|
1336
|
+
}), po = /* @__PURE__ */ S(uo, [["__scopeId", "data-v-d86ebba4"]]), fo = { class: "brick-field" }, mo = { class: "brick-field__label" }, yo = ["value"], go = ["value"], bo = ["value", "min", "max", "step"], vo = ["value"], ho = ["value"], _o = ["value"], ko = {
|
|
1337
|
+
key: 5,
|
|
1338
|
+
class: "brick-field__toggle"
|
|
1339
|
+
}, xo = ["checked"], So = {
|
|
1340
|
+
key: 6,
|
|
1341
|
+
class: "brick-field__margin"
|
|
1342
|
+
}, Co = ["placeholder", "value", "onInput"], wo = {
|
|
1343
|
+
key: 7,
|
|
1344
|
+
class: "brick-field__slider"
|
|
1345
|
+
}, Po = ["value", "min", "max", "step"], Eo = { class: "brick-field__slider-value" }, $o = /* @__PURE__ */ _({
|
|
1346
|
+
__name: "PropertyField",
|
|
1347
|
+
props: {
|
|
1348
|
+
descriptor: {},
|
|
1349
|
+
node: {}
|
|
1350
|
+
},
|
|
1351
|
+
setup(e) {
|
|
1352
|
+
const t = e, n = Y(), i = $(() => {
|
|
1353
|
+
const p = t.descriptor.key.split("."), r = p[0], l = p[1];
|
|
1354
|
+
if (r === "props")
|
|
1355
|
+
return t.node.props[l];
|
|
1356
|
+
if (r === "style")
|
|
1357
|
+
return t.node.style[l];
|
|
1358
|
+
}), c = $(() => {
|
|
1359
|
+
const p = i.value;
|
|
1360
|
+
return t.descriptor.type === "textarea" && Array.isArray(p) ? p.join(`
|
|
1361
|
+
`) : p;
|
|
1362
|
+
});
|
|
1363
|
+
function o(p) {
|
|
1364
|
+
const r = t.descriptor.key.split("."), l = r[0], y = r[1];
|
|
1365
|
+
let b = p;
|
|
1366
|
+
t.descriptor.type === "textarea" && Array.isArray(i.value) && (b = p.split(`
|
|
1367
|
+
`)), l === "props" ? n.updateProps(t.node.id, { [y]: b }) : l === "style" && n.updateStyle(t.node.id, { [y]: b });
|
|
1368
|
+
}
|
|
1369
|
+
function d(p, r) {
|
|
1370
|
+
const y = [...c.value ?? [0, 0, 0, 0]];
|
|
1371
|
+
y[p] = r, o(y);
|
|
1372
|
+
}
|
|
1373
|
+
function u(p) {
|
|
1374
|
+
const l = p.target.files?.[0];
|
|
1375
|
+
if (!l) return;
|
|
1376
|
+
const y = new FileReader();
|
|
1377
|
+
y.onload = () => {
|
|
1378
|
+
o(y.result);
|
|
1379
|
+
}, y.readAsDataURL(l);
|
|
1380
|
+
}
|
|
1381
|
+
return (p, r) => (s(), a("div", fo, [
|
|
1382
|
+
f("label", mo, w(e.descriptor.label), 1),
|
|
1383
|
+
e.descriptor.type === "text" ? (s(), a("input", {
|
|
1384
|
+
key: 0,
|
|
1385
|
+
type: "text",
|
|
1386
|
+
class: "brick-field__input",
|
|
1387
|
+
value: c.value,
|
|
1388
|
+
onInput: r[0] || (r[0] = (l) => o(l.target.value))
|
|
1389
|
+
}, null, 40, yo)) : e.descriptor.type === "textarea" ? (s(), a("textarea", {
|
|
1390
|
+
key: 1,
|
|
1391
|
+
class: "brick-field__textarea",
|
|
1392
|
+
value: c.value,
|
|
1393
|
+
rows: "3",
|
|
1394
|
+
onInput: r[1] || (r[1] = (l) => o(l.target.value))
|
|
1395
|
+
}, null, 40, go)) : e.descriptor.type === "number" ? (s(), a("input", {
|
|
1396
|
+
key: 2,
|
|
1397
|
+
type: "number",
|
|
1398
|
+
class: "brick-field__input",
|
|
1399
|
+
value: c.value,
|
|
1400
|
+
min: e.descriptor.min,
|
|
1401
|
+
max: e.descriptor.max,
|
|
1402
|
+
step: e.descriptor.step,
|
|
1403
|
+
onInput: r[2] || (r[2] = (l) => o(Number(l.target.value)))
|
|
1404
|
+
}, null, 40, bo)) : e.descriptor.type === "color" ? (s(), a("input", {
|
|
1405
|
+
key: 3,
|
|
1406
|
+
type: "color",
|
|
1407
|
+
class: "brick-field__color",
|
|
1408
|
+
value: c.value ?? "#000000",
|
|
1409
|
+
onInput: r[3] || (r[3] = (l) => o(l.target.value))
|
|
1410
|
+
}, null, 40, vo)) : e.descriptor.type === "select" ? (s(), a("select", {
|
|
1411
|
+
key: 4,
|
|
1412
|
+
class: "brick-field__select",
|
|
1413
|
+
value: c.value,
|
|
1414
|
+
onChange: r[4] || (r[4] = (l) => o(l.target.value || void 0))
|
|
1415
|
+
}, [
|
|
1416
|
+
(s(!0), a(C, null, P(e.descriptor.options, (l) => (s(), a("option", {
|
|
1417
|
+
key: String(l.value),
|
|
1418
|
+
value: l.value
|
|
1419
|
+
}, w(l.label), 9, _o))), 128))
|
|
1420
|
+
], 40, ho)) : e.descriptor.type === "toggle" ? (s(), a("label", ko, [
|
|
1421
|
+
f("input", {
|
|
1422
|
+
type: "checkbox",
|
|
1423
|
+
checked: c.value,
|
|
1424
|
+
onChange: r[5] || (r[5] = (l) => o(l.target.checked))
|
|
1425
|
+
}, null, 40, xo),
|
|
1426
|
+
f("span", null, w(c.value ? "On" : "Off"), 1)
|
|
1427
|
+
])) : e.descriptor.type === "margin" ? (s(), a("div", So, [
|
|
1428
|
+
(s(), a(C, null, P(["L", "T", "R", "B"], (l, y) => f("input", {
|
|
1429
|
+
key: l,
|
|
1430
|
+
type: "number",
|
|
1431
|
+
class: "brick-field__margin-input",
|
|
1432
|
+
placeholder: l,
|
|
1433
|
+
value: (c.value ?? [0, 0, 0, 0])[y],
|
|
1434
|
+
onInput: (b) => d(y, Number(b.target.value))
|
|
1435
|
+
}, null, 40, Co)), 64))
|
|
1436
|
+
])) : e.descriptor.type === "slider" ? (s(), a("div", wo, [
|
|
1437
|
+
f("input", {
|
|
1438
|
+
type: "range",
|
|
1439
|
+
value: c.value,
|
|
1440
|
+
min: e.descriptor.min,
|
|
1441
|
+
max: e.descriptor.max,
|
|
1442
|
+
step: e.descriptor.step,
|
|
1443
|
+
onInput: r[6] || (r[6] = (l) => o(Number(l.target.value)))
|
|
1444
|
+
}, null, 40, Po),
|
|
1445
|
+
f("span", Eo, w(c.value), 1)
|
|
1446
|
+
])) : e.descriptor.type === "file" ? (s(), a("input", {
|
|
1447
|
+
key: 8,
|
|
1448
|
+
type: "file",
|
|
1449
|
+
accept: "image/*",
|
|
1450
|
+
class: "brick-field__file",
|
|
1451
|
+
onChange: u
|
|
1452
|
+
}, null, 32)) : I("", !0)
|
|
1453
|
+
]));
|
|
1454
|
+
}
|
|
1455
|
+
}), Io = /* @__PURE__ */ S($o, [["__scopeId", "data-v-e5d6e8b6"]]), Ro = {
|
|
1456
|
+
key: 0,
|
|
1457
|
+
class: "brick-property-editor"
|
|
1458
|
+
}, Do = { class: "brick-property-editor__type" }, zo = {
|
|
1459
|
+
key: 0,
|
|
1460
|
+
class: "brick-property-editor__group"
|
|
1461
|
+
}, To = { class: "brick-property-editor__group-title" }, No = /* @__PURE__ */ _({
|
|
1462
|
+
__name: "PropertyEditor",
|
|
1463
|
+
setup(e) {
|
|
1464
|
+
const t = U(), n = $(() => {
|
|
1465
|
+
const d = t.selectedNode.value;
|
|
1466
|
+
return d ? F(d.type) : null;
|
|
1467
|
+
}), i = $(() => {
|
|
1468
|
+
if (!n.value) return {};
|
|
1469
|
+
const d = {};
|
|
1470
|
+
for (const u of n.value.propertyFields)
|
|
1471
|
+
d[u.section] || (d[u.section] = []), d[u.section].push(u);
|
|
1472
|
+
return d;
|
|
1473
|
+
}), c = {
|
|
1474
|
+
content: "Content",
|
|
1475
|
+
style: "Style",
|
|
1476
|
+
layout: "Layout",
|
|
1477
|
+
advanced: "Advanced"
|
|
1478
|
+
}, o = ["content", "style", "layout", "advanced"];
|
|
1479
|
+
return (d, u) => k(t).selectedNode.value && n.value ? (s(), a("div", Ro, [
|
|
1480
|
+
f("div", Do, w(n.value.icon) + " " + w(n.value.label), 1),
|
|
1481
|
+
(s(), a(C, null, P(o, (p) => (s(), a(C, { key: p }, [
|
|
1482
|
+
i.value[p] ? (s(), a("div", zo, [
|
|
1483
|
+
f("div", To, w(c[p]), 1),
|
|
1484
|
+
(s(!0), a(C, null, P(i.value[p], (r) => (s(), B(Io, {
|
|
1485
|
+
key: r.key,
|
|
1486
|
+
descriptor: r,
|
|
1487
|
+
node: k(t).selectedNode.value
|
|
1488
|
+
}, null, 8, ["descriptor", "node"]))), 128))
|
|
1489
|
+
])) : I("", !0)
|
|
1490
|
+
], 64))), 64)),
|
|
1491
|
+
(s(), B(Q(n.value.propertyEditorComponent), {
|
|
1492
|
+
node: k(t).selectedNode.value
|
|
1493
|
+
}, null, 8, ["node"]))
|
|
1494
|
+
])) : I("", !0);
|
|
1495
|
+
}
|
|
1496
|
+
}), Lo = /* @__PURE__ */ S(No, [["__scopeId", "data-v-4d129dac"]]), Mo = { class: "brick-toolbar" }, Bo = { class: "brick-toolbar__section" }, Oo = {
|
|
1497
|
+
key: 0,
|
|
1498
|
+
class: "brick-toolbar__section"
|
|
1499
|
+
}, Vo = /* @__PURE__ */ _({
|
|
1500
|
+
__name: "Toolbar",
|
|
1501
|
+
setup(e) {
|
|
1502
|
+
const t = U();
|
|
1503
|
+
return (n, i) => (s(), a("div", Mo, [
|
|
1504
|
+
f("div", Bo, [
|
|
1505
|
+
i[0] || (i[0] = f("h3", { class: "brick-toolbar__title" }, "Elements", -1)),
|
|
1506
|
+
O(po)
|
|
1507
|
+
]),
|
|
1508
|
+
k(t).selectedNode.value ? (s(), a("div", Oo, [
|
|
1509
|
+
i[1] || (i[1] = f("h3", { class: "brick-toolbar__title" }, "Properties", -1)),
|
|
1510
|
+
O(Lo)
|
|
1511
|
+
])) : I("", !0)
|
|
1512
|
+
]));
|
|
1513
|
+
}
|
|
1514
|
+
}), Ao = /* @__PURE__ */ S(Vo, [["__scopeId", "data-v-5bf5f6ab"]]), Ho = { class: "brick-actionbar" }, Fo = { class: "brick-actionbar__group" }, Uo = { class: "brick-actionbar__group" }, Wo = ["disabled"], Jo = ["disabled"], Yo = ["disabled"], qo = { class: "brick-actionbar__group" }, jo = /* @__PURE__ */ _({
|
|
1515
|
+
__name: "ActionBar",
|
|
1516
|
+
setup(e) {
|
|
1517
|
+
const t = bt(), n = St(), i = U(), c = Y(), o = Z(), d = E("document"), u = E(null);
|
|
1518
|
+
function p() {
|
|
1519
|
+
const m = i.selectedId.value;
|
|
1520
|
+
m && (i.deselect(), c.removeElement(m));
|
|
1521
|
+
}
|
|
1522
|
+
function r() {
|
|
1523
|
+
const m = d.value.trim() || "document", g = m.endsWith(".pdf") ? m : m + ".pdf";
|
|
1524
|
+
n.exportPdf(g);
|
|
1525
|
+
}
|
|
1526
|
+
function l() {
|
|
1527
|
+
const m = o.exportDocument(), g = JSON.stringify(m, null, 2), v = new Blob([g], { type: "application/json" }), h = URL.createObjectURL(v), x = document.createElement("a"), D = d.value.trim() || "document";
|
|
1528
|
+
x.href = h, x.download = D.endsWith(".json") ? D : D + ".json", x.click(), URL.revokeObjectURL(h);
|
|
1529
|
+
}
|
|
1530
|
+
function y() {
|
|
1531
|
+
u.value?.click();
|
|
1532
|
+
}
|
|
1533
|
+
function b(m) {
|
|
1534
|
+
const g = m.target, v = g.files?.[0];
|
|
1535
|
+
if (!v) return;
|
|
1536
|
+
const h = new FileReader();
|
|
1537
|
+
h.onload = () => {
|
|
1538
|
+
try {
|
|
1539
|
+
const x = JSON.parse(h.result);
|
|
1540
|
+
if (!x.content || !x.pageSize) {
|
|
1541
|
+
alert("Invalid brick-pdf JSON file.");
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
i.deselect(), o.loadDocument(x);
|
|
1545
|
+
} catch {
|
|
1546
|
+
alert("Failed to parse JSON file.");
|
|
1547
|
+
}
|
|
1548
|
+
}, h.readAsText(v), g.value = "";
|
|
1549
|
+
}
|
|
1550
|
+
return (m, g) => (s(), a("div", Ho, [
|
|
1551
|
+
f("div", Fo, [
|
|
1552
|
+
G(f("input", {
|
|
1553
|
+
"onUpdate:modelValue": g[0] || (g[0] = (v) => d.value = v),
|
|
1554
|
+
class: "brick-actionbar__name",
|
|
1555
|
+
type: "text",
|
|
1556
|
+
placeholder: "Document name",
|
|
1557
|
+
title: "Document name (used for export filename)"
|
|
1558
|
+
}, null, 512), [
|
|
1559
|
+
[$e, d.value]
|
|
1560
|
+
])
|
|
1561
|
+
]),
|
|
1562
|
+
f("div", Uo, [
|
|
1563
|
+
f("button", {
|
|
1564
|
+
class: "brick-actionbar__btn",
|
|
1565
|
+
disabled: !k(t).canUndo.value,
|
|
1566
|
+
title: "Undo",
|
|
1567
|
+
onClick: g[1] || (g[1] = (v) => k(t).undo())
|
|
1568
|
+
}, " Undo ", 8, Wo),
|
|
1569
|
+
f("button", {
|
|
1570
|
+
class: "brick-actionbar__btn",
|
|
1571
|
+
disabled: !k(t).canRedo.value,
|
|
1572
|
+
title: "Redo",
|
|
1573
|
+
onClick: g[2] || (g[2] = (v) => k(t).redo())
|
|
1574
|
+
}, " Redo ", 8, Jo),
|
|
1575
|
+
f("button", {
|
|
1576
|
+
class: "brick-actionbar__btn brick-actionbar__btn--danger",
|
|
1577
|
+
disabled: !k(i).selectedId.value,
|
|
1578
|
+
title: "Delete selected element",
|
|
1579
|
+
onClick: p
|
|
1580
|
+
}, " Delete ", 8, Yo)
|
|
1581
|
+
]),
|
|
1582
|
+
f("div", qo, [
|
|
1583
|
+
f("button", {
|
|
1584
|
+
class: "brick-actionbar__btn",
|
|
1585
|
+
title: "Import JSON",
|
|
1586
|
+
onClick: y
|
|
1587
|
+
}, " Import JSON "),
|
|
1588
|
+
f("button", {
|
|
1589
|
+
class: "brick-actionbar__btn",
|
|
1590
|
+
title: "Export JSON",
|
|
1591
|
+
onClick: l
|
|
1592
|
+
}, " Export JSON "),
|
|
1593
|
+
f("button", {
|
|
1594
|
+
class: "brick-actionbar__btn brick-actionbar__btn--primary",
|
|
1595
|
+
onClick: r
|
|
1596
|
+
}, " Export PDF "),
|
|
1597
|
+
f("button", {
|
|
1598
|
+
class: "brick-actionbar__btn",
|
|
1599
|
+
onClick: g[3] || (g[3] = (v) => k(n).openPdf())
|
|
1600
|
+
}, " Preview ")
|
|
1601
|
+
]),
|
|
1602
|
+
f("input", {
|
|
1603
|
+
ref_key: "fileInput",
|
|
1604
|
+
ref: u,
|
|
1605
|
+
type: "file",
|
|
1606
|
+
accept: ".json",
|
|
1607
|
+
style: { display: "none" },
|
|
1608
|
+
onChange: b
|
|
1609
|
+
}, null, 544)
|
|
1610
|
+
]));
|
|
1611
|
+
}
|
|
1612
|
+
}), Go = /* @__PURE__ */ S(jo, [["__scopeId", "data-v-be915a0f"]]), Xo = { class: "brick-pdf" }, Ko = { class: "brick-pdf__workspace" }, Qo = /* @__PURE__ */ _({
|
|
1613
|
+
__name: "BrickPdf",
|
|
1614
|
+
props: {
|
|
1615
|
+
modelValue: {}
|
|
1616
|
+
},
|
|
1617
|
+
emits: ["update:modelValue"],
|
|
1618
|
+
setup(e, { emit: t }) {
|
|
1619
|
+
const n = e, i = t;
|
|
1620
|
+
An();
|
|
1621
|
+
const c = st(n.modelValue ?? ce());
|
|
1622
|
+
at(c);
|
|
1623
|
+
const o = ct(c);
|
|
1624
|
+
dt(o);
|
|
1625
|
+
const d = yt(c);
|
|
1626
|
+
gt(d);
|
|
1627
|
+
const u = pt(c, d);
|
|
1628
|
+
ft(u);
|
|
1629
|
+
const p = vt(c, u);
|
|
1630
|
+
ht(p);
|
|
1631
|
+
const r = kt(c);
|
|
1632
|
+
xt(r);
|
|
1633
|
+
const l = Pt(c, u);
|
|
1634
|
+
Et(l);
|
|
1635
|
+
const y = $t(u);
|
|
1636
|
+
It(y);
|
|
1637
|
+
const b = Re(), m = b.Delete, g = b.Backspace;
|
|
1638
|
+
return re(m, () => {
|
|
1639
|
+
if (!o.selectedId.value) return;
|
|
1640
|
+
const v = document.activeElement;
|
|
1641
|
+
if (v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.tagName === "SELECT")) return;
|
|
1642
|
+
const h = o.selectedId.value;
|
|
1643
|
+
o.deselect(), u.removeElement(h);
|
|
1644
|
+
}), re(g, () => {
|
|
1645
|
+
if (!o.selectedId.value) return;
|
|
1646
|
+
const v = document.activeElement;
|
|
1647
|
+
if (v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.tagName === "SELECT")) return;
|
|
1648
|
+
const h = o.selectedId.value;
|
|
1649
|
+
o.deselect(), u.removeElement(h);
|
|
1650
|
+
}), Ie(
|
|
1651
|
+
() => c.document,
|
|
1652
|
+
() => {
|
|
1653
|
+
i("update:modelValue", JSON.parse(JSON.stringify(H(c.document))));
|
|
1654
|
+
},
|
|
1655
|
+
{ deep: !0 }
|
|
1656
|
+
), (v, h) => (s(), a("div", Xo, [
|
|
1657
|
+
O(Go),
|
|
1658
|
+
f("div", Ko, [
|
|
1659
|
+
O(io),
|
|
1660
|
+
O(Ao)
|
|
1661
|
+
])
|
|
1662
|
+
]));
|
|
1663
|
+
}
|
|
1664
|
+
}), Zo = /* @__PURE__ */ S(Qo, [["__scopeId", "data-v-f9b95ad8"]]), ir = {
|
|
1665
|
+
install(e) {
|
|
1666
|
+
e.component("BrickPdf", Zo);
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
export {
|
|
1670
|
+
Zo as BrickPdf,
|
|
1671
|
+
ce as createDefaultDocument,
|
|
1672
|
+
ir as default,
|
|
1673
|
+
De as getAllElementDefinitions,
|
|
1674
|
+
F as getElementDefinition,
|
|
1675
|
+
z as registerElement,
|
|
1676
|
+
or as unregisterElement,
|
|
1677
|
+
rr as useClipboard,
|
|
1678
|
+
Z as useDocumentStore,
|
|
1679
|
+
be as useDragDrop,
|
|
1680
|
+
Y as useElementActions,
|
|
1681
|
+
bt as useHistory,
|
|
1682
|
+
St as usePdfExport,
|
|
1683
|
+
lr as useResize,
|
|
1684
|
+
U as useSelection
|
|
1685
|
+
};
|