@grapesjs/studio-sdk-plugins 1.0.22 → 1.0.23
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/dataSourceEjs/EjsImporter.d.ts +2 -1
- package/dist/dataSourceEjs/index.cjs.js +23 -17
- package/dist/dataSourceEjs/index.es.js +339 -290
- package/dist/dataSourceEjs/index.umd.js +23 -17
- package/dist/dataSourceEjs/tests/EjsExporter.test.d.ts +1 -0
- package/dist/dataSourceEjs/tests/EjsImporter.test.d.ts +1 -0
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
- package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +9 -0
- package/dist/dataSourceHandlebars/constants.d.ts +16 -0
- package/dist/dataSourceHandlebars/index.cjs.js +13 -13
- package/dist/dataSourceHandlebars/index.es.js +272 -217
- package/dist/dataSourceHandlebars/index.umd.js +13 -13
- package/dist/dataSourceHandlebars/tests/HandlebarsExporter.test.d.ts +1 -0
- package/dist/dataSourceHandlebars/tests/HandlebarsImporter.test.d.ts +1 -0
- package/dist/index.cjs.js +70 -63
- package/dist/index.es.js +3297 -3187
- package/dist/index.umd.js +70 -63
- package/dist/presetPrintable/index.cjs.js +7 -6
- package/dist/presetPrintable/index.es.js +204 -197
- package/dist/presetPrintable/index.umd.js +7 -6
- package/dist/presetPrintable/shared.d.ts +3 -0
- package/dist/presetPrintable/types.d.ts +4 -1
- package/dist/presetPrintable/typesSchema.d.ts +18 -0
- package/dist/presetPrintable/utils.d.ts +11 -0
- package/jest.config.js +9 -0
- package/package.json +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const N = "app.grapesjs.com", W = "app-stage.grapesjs.com", G = [
|
|
2
|
+
N,
|
|
3
|
+
W,
|
|
4
4
|
"localhost",
|
|
5
5
|
"127.0.0.1",
|
|
6
6
|
".local-credentialless.webcontainer.io",
|
|
@@ -9,21 +9,21 @@ const U = "app.grapesjs.com", G = "app-stage.grapesjs.com", x = [
|
|
|
9
9
|
// For stackblitz.com demos
|
|
10
10
|
"-sandpack.codesandbox.io"
|
|
11
11
|
// For Sandpack demos
|
|
12
|
-
],
|
|
13
|
-
const t =
|
|
12
|
+
], V = "license:check:start", Y = "license:check:end", J = () => typeof window < "u", M = (e, n = {}) => {
|
|
13
|
+
const t = Q(e) ? { id: e, src: e } : e;
|
|
14
14
|
return new Promise((s, a) => {
|
|
15
|
-
var
|
|
16
|
-
const o = document.querySelector(`script[src="${t.src}"]`), { id:
|
|
15
|
+
var l, p;
|
|
16
|
+
const o = document.querySelector(`script[src="${t.src}"]`), { id: r } = t;
|
|
17
17
|
if (o)
|
|
18
|
-
return (
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
return (l = n.onScript) == null || l.call(n, o), s(r);
|
|
19
|
+
const i = document.createElement("script");
|
|
20
|
+
i.src = t.src, i.onload = () => s(r), i.onerror = () => a(r), document.head.appendChild(i), (p = n.onScript) == null || p.call(n, i);
|
|
21
21
|
});
|
|
22
|
-
},
|
|
23
|
-
const e =
|
|
24
|
-
return !!e && (
|
|
25
|
-
},
|
|
26
|
-
async function
|
|
22
|
+
}, X = ({ isDev: e, isStage: n }) => `${e ? "" : `https://${n ? W : N}`}/api`, Z = () => {
|
|
23
|
+
const e = J() && window.location.hostname;
|
|
24
|
+
return !!e && (G.includes(e) || G.some((n) => e.endsWith(n)));
|
|
25
|
+
}, Q = (e) => typeof e == "string";
|
|
26
|
+
async function ee({
|
|
27
27
|
path: e,
|
|
28
28
|
baseApiUrl: n,
|
|
29
29
|
method: t = "GET",
|
|
@@ -31,70 +31,70 @@ async function Y({
|
|
|
31
31
|
params: a,
|
|
32
32
|
body: o
|
|
33
33
|
}) {
|
|
34
|
-
const
|
|
34
|
+
const i = `${n || X({ isDev: !1, isStage: !1 })}${e}`, l = {
|
|
35
35
|
method: t,
|
|
36
36
|
headers: {
|
|
37
37
|
"Content-Type": "application/json",
|
|
38
38
|
...s
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
o && (
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
throw new Error(`HTTP error! status: ${
|
|
45
|
-
return
|
|
41
|
+
o && (l.body = JSON.stringify(o));
|
|
42
|
+
const p = a ? new URLSearchParams(a).toString() : "", d = p ? `?${p}` : "", g = await fetch(`${i}${d}`, l);
|
|
43
|
+
if (!g.ok)
|
|
44
|
+
throw new Error(`HTTP error! status: ${g.status}`);
|
|
45
|
+
return g.json();
|
|
46
46
|
}
|
|
47
|
-
var
|
|
48
|
-
const
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
47
|
+
var B = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(B || {}), z = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(z || {});
|
|
48
|
+
const O = {
|
|
49
|
+
[B.free]: 0,
|
|
50
|
+
[B.startup]: 10,
|
|
51
|
+
[B.business]: 20,
|
|
52
|
+
[B.enterprise]: 30
|
|
53
53
|
};
|
|
54
|
-
function
|
|
54
|
+
function te(e) {
|
|
55
55
|
const n = e;
|
|
56
56
|
return n.init = (t) => (s) => e(s, t), n;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
async function
|
|
58
|
+
const se = (e) => /* @__PURE__ */ te(e);
|
|
59
|
+
async function ne({
|
|
60
60
|
editor: e,
|
|
61
61
|
plan: n,
|
|
62
62
|
pluginName: t,
|
|
63
63
|
licenseKey: s,
|
|
64
64
|
cleanup: a
|
|
65
65
|
}) {
|
|
66
|
-
let o = "",
|
|
67
|
-
const
|
|
68
|
-
console.warn("Cleanup plugin:", t, "Reason:",
|
|
69
|
-
},
|
|
70
|
-
var
|
|
71
|
-
const { error:
|
|
72
|
-
if (!(
|
|
73
|
-
|
|
66
|
+
let o = "", r = !1;
|
|
67
|
+
const i = Z(), l = (d) => {
|
|
68
|
+
console.warn("Cleanup plugin:", t, "Reason:", d), a();
|
|
69
|
+
}, p = (d = {}) => {
|
|
70
|
+
var w;
|
|
71
|
+
const { error: g, sdkLicense: u } = d, f = (w = d.plan) == null ? void 0 : w.category;
|
|
72
|
+
if (!(u || d.license) || g)
|
|
73
|
+
l(g || "Invalid license");
|
|
74
74
|
else if (f) {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const c = O[n], h = O[f];
|
|
76
|
+
c > h && l({ pluginRequiredPlan: n, licensePlan: f });
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
e.on(
|
|
80
|
-
o =
|
|
81
|
-
}), e.on(
|
|
82
|
-
|
|
79
|
+
e.on(V, (d) => {
|
|
80
|
+
o = d == null ? void 0 : d.baseApiUrl, r = !0;
|
|
81
|
+
}), e.on(Y, (d) => {
|
|
82
|
+
p(d);
|
|
83
83
|
}), setTimeout(async () => {
|
|
84
|
-
if (!
|
|
85
|
-
if (
|
|
84
|
+
if (!r) {
|
|
85
|
+
if (i) return;
|
|
86
86
|
if (s) {
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const d = await oe({ licenseKey: s, pluginName: t, baseApiUrl: o });
|
|
88
|
+
d && p(d);
|
|
89
89
|
} else
|
|
90
|
-
|
|
90
|
+
l("The `licenseKey` option not provided");
|
|
91
91
|
}
|
|
92
92
|
}, 2e3);
|
|
93
93
|
}
|
|
94
|
-
async function
|
|
94
|
+
async function oe(e) {
|
|
95
95
|
const { licenseKey: n, pluginName: t, baseApiUrl: s } = e;
|
|
96
96
|
try {
|
|
97
|
-
return (await
|
|
97
|
+
return (await ee({
|
|
98
98
|
baseApiUrl: s,
|
|
99
99
|
path: `/sdk/${n || "na"}`,
|
|
100
100
|
method: "POST",
|
|
@@ -107,31 +107,32 @@ async function Q(e) {
|
|
|
107
107
|
return console.error("Error during SDK license check:", a), !1;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const ae = (e) => (n) => {
|
|
111
111
|
var t;
|
|
112
|
-
return ((t = n.getAttribute) == null ? void 0 : t.call(n,
|
|
113
|
-
},
|
|
112
|
+
return ((t = n.getAttribute) == null ? void 0 : t.call(n, q)) === e;
|
|
113
|
+
}, re = (...e) => (n, t) => e.some((s) => t.is(s)), K = (e, n, t) => {
|
|
114
114
|
const { doc: s = document } = t, a = t.target || s.head, o = a.querySelector(`style[${e}]`) || s.createElement("style");
|
|
115
115
|
o.setAttribute(e, "true"), o.innerHTML = n, !a.contains(o) && a.appendChild(o);
|
|
116
|
-
},
|
|
117
|
-
function
|
|
118
|
-
let s, a, o,
|
|
119
|
-
const
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
|
|
116
|
+
}, ie = "gjs-plg-", C = "data-gs-plg-", q = "data-type-role";
|
|
117
|
+
function I(e, n, t) {
|
|
118
|
+
let s, a, o, r, i;
|
|
119
|
+
const l = n === void 0 ? 100 : n;
|
|
120
|
+
function p() {
|
|
121
|
+
const g = Date.now() - r;
|
|
122
|
+
g < l && g >= 0 ? s = setTimeout(p, l - g) : (s = null, i = e.apply(o, a), o = a = null);
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
return o = this, a = arguments,
|
|
124
|
+
const d = function() {
|
|
125
|
+
return o = this, a = arguments, r = Date.now(), s || (s = setTimeout(p, l)), i;
|
|
126
126
|
};
|
|
127
|
-
return
|
|
127
|
+
return d.clear = function() {
|
|
128
128
|
s && (clearTimeout(s), s = null);
|
|
129
|
-
},
|
|
130
|
-
s && (
|
|
131
|
-
},
|
|
129
|
+
}, d.flush = function() {
|
|
130
|
+
s && (i = e.apply(o, a), o = a = null, clearTimeout(s), s = null);
|
|
131
|
+
}, d;
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
|
|
133
|
+
const A = "page-break";
|
|
134
|
+
var m = /* @__PURE__ */ ((e) => (e.A5 = "a5", e.A5Portrait = "a5-portrait", e.A4 = "a4", e.A3 = "a3", e.B5 = "b5", e.B4 = "b4", e.letter = "letter", e.legal = "legal", e.ledger = "ledger", e))(m || {});
|
|
135
|
+
function D(e, n) {
|
|
135
136
|
const s = {
|
|
136
137
|
mm: 3.7795275590551185,
|
|
137
138
|
// 1mm ≈ 3.78px
|
|
@@ -146,45 +147,46 @@ function L(e, n) {
|
|
|
146
147
|
};
|
|
147
148
|
return s[n] ? e * s[n] : null;
|
|
148
149
|
}
|
|
149
|
-
const
|
|
150
|
-
const { name: t, id: s, width: a, height: o, unit:
|
|
150
|
+
const ce = (e, n) => {
|
|
151
|
+
const { name: t, id: s, width: a, height: o, unit: r } = e, { fixedHeight: i } = n, l = `${a}${r}`, p = `${o}${r}`;
|
|
151
152
|
return {
|
|
152
153
|
id: s || t.toLowerCase().replace(/\s/g, "-"),
|
|
153
|
-
name: `${t} (${
|
|
154
|
+
name: `${t} (${l} x ${p})`,
|
|
154
155
|
sizeH: o,
|
|
155
156
|
sizeW: a,
|
|
156
|
-
sizeUnit:
|
|
157
|
+
sizeUnit: r,
|
|
157
158
|
widthMedia: "",
|
|
158
|
-
width:
|
|
159
|
-
minHeight:
|
|
160
|
-
height:
|
|
159
|
+
width: l,
|
|
160
|
+
minHeight: i ? "0" : `${D(o, r)}px`,
|
|
161
|
+
height: i ? p : void 0
|
|
161
162
|
};
|
|
162
|
-
},
|
|
163
|
-
function
|
|
164
|
-
const { Devices: n } = e, { height: t, minHeight: s } = n.getSelected().attributes, o = parseFloat(`${t && t !== "auto" ? t : s}`),
|
|
165
|
-
if (!
|
|
166
|
-
return
|
|
167
|
-
const
|
|
168
|
-
let
|
|
169
|
-
for (;
|
|
170
|
-
const f =
|
|
171
|
-
f ? (
|
|
163
|
+
}, H = "page-breaks", $ = "gjs-page-breaks-spot", j = (e) => e.type === H;
|
|
164
|
+
function le(e) {
|
|
165
|
+
const { Devices: n } = e, { height: t, minHeight: s } = n.getSelected().attributes, o = parseFloat(`${t && t !== "auto" ? t : s}`), r = e.getWrapper(), i = r == null ? void 0 : r.getEl(), l = [];
|
|
166
|
+
if (!r || !i)
|
|
167
|
+
return l;
|
|
168
|
+
const p = i.getBoundingClientRect().height, g = r.findType(A).map((f) => f.getEl()).filter(Boolean).map((f) => ({ top: f.offsetTop, height: f.offsetHeight }));
|
|
169
|
+
let u = 0;
|
|
170
|
+
for (; u < p; ) {
|
|
171
|
+
const f = g.find((y) => y.top > u && y.top < u + o);
|
|
172
|
+
f ? (u = f.top + f.height, l.push(f.top)) : (u += o, u < p && l.push(u));
|
|
172
173
|
}
|
|
173
|
-
return
|
|
174
|
+
return l;
|
|
174
175
|
}
|
|
175
|
-
function
|
|
176
|
+
function pe(e, n) {
|
|
176
177
|
const { Canvas: t } = e, s = t.events, a = e.events;
|
|
177
178
|
let o;
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
`${
|
|
181
|
-
`.${
|
|
179
|
+
const r = () => {
|
|
180
|
+
K(
|
|
181
|
+
`${C}preset-printable-spots`,
|
|
182
|
+
`.${$} {
|
|
182
183
|
position: absolute;
|
|
183
184
|
left: 0;
|
|
184
185
|
width: 100%;
|
|
185
186
|
border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
|
|
187
|
+
color: var(--gs-theme-cl-prm-txt, var(--gjs-font-color));
|
|
186
188
|
}
|
|
187
|
-
.${
|
|
189
|
+
.${$}::after {
|
|
188
190
|
background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
|
|
189
191
|
content: attr(data-page-number);
|
|
190
192
|
display: block;
|
|
@@ -198,83 +200,87 @@ function ae(e, n) {
|
|
|
198
200
|
`,
|
|
199
201
|
{ target: window.document.head }
|
|
200
202
|
);
|
|
201
|
-
},
|
|
203
|
+
}, i = () => {
|
|
202
204
|
if (n.enablePageBreaksSpot === !1) return;
|
|
203
|
-
const
|
|
204
|
-
return t.getSpots(
|
|
205
|
-
},
|
|
206
|
-
const { spotEl:
|
|
207
|
-
!
|
|
208
|
-
},
|
|
209
|
-
if (!
|
|
210
|
-
let { spotEl:
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
const { spotEl:
|
|
214
|
-
!
|
|
215
|
-
const
|
|
216
|
-
|
|
205
|
+
const c = { id: H, type: H, component: e.getWrapper() };
|
|
206
|
+
return t.getSpots(c).pop() || t.addSpot(c);
|
|
207
|
+
}, l = ({ spot: c }) => {
|
|
208
|
+
const { spotEl: h } = c.attributes;
|
|
209
|
+
!j(c) || !h || !o || o.removeChild(h);
|
|
210
|
+
}, p = ({ spot: c }) => {
|
|
211
|
+
if (!j(c) || !o) return;
|
|
212
|
+
let { spotEl: h } = c.attributes;
|
|
213
|
+
h || (h = document.createElement("div"), h.className = `${$}__items`, c.set({ spotEl: h })), o.appendChild(h);
|
|
214
|
+
}, d = ({ spot: c }) => {
|
|
215
|
+
const { spotEl: h, pageBreaks: x = [] } = c.attributes;
|
|
216
|
+
!j(c) || !h || !o || (Object.entries(c.getStyle()).forEach(([k, R]) => h.style.setProperty(k, R)), h.innerHTML = "", x.forEach((k, R) => {
|
|
217
|
+
const T = document.createElement("div");
|
|
218
|
+
T.setAttribute("data-page-number", `${R + 2}`), T.className = $, T.style.top = `${k}px`, h.appendChild(T);
|
|
217
219
|
}));
|
|
218
|
-
},
|
|
220
|
+
}, g = I(() => {
|
|
219
221
|
if (e.em.destroyed) return;
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
}, 150),
|
|
223
|
-
o = t.getSpotsEl(),
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
[
|
|
229
|
-
[
|
|
222
|
+
const c = i();
|
|
223
|
+
c && c.set({ pageBreaks: le(e), up: (c.attributes.up || 0) + 1 });
|
|
224
|
+
}, 150), u = I(g, 200), f = () => {
|
|
225
|
+
o = t.getSpotsEl(), i();
|
|
226
|
+
}, y = () => {
|
|
227
|
+
const c = i();
|
|
228
|
+
c && c.set({ up: (c.attributes.up || 0) + 1 });
|
|
229
|
+
}, w = [
|
|
230
|
+
["component:input", g],
|
|
231
|
+
["frame:scroll", y],
|
|
232
|
+
[a.update, g],
|
|
233
|
+
[s.spotAdd, p],
|
|
234
|
+
[s.spotUpdate, d],
|
|
235
|
+
[s.spotRemove, l],
|
|
230
236
|
[s.frameLoadBody, f]
|
|
231
237
|
];
|
|
232
|
-
return
|
|
233
|
-
|
|
238
|
+
return w.forEach(([c, h]) => e.on(c, h)), e.onReady(() => {
|
|
239
|
+
r(), new ResizeObserver(y).observe(t.getElement().parentElement);
|
|
234
240
|
}), () => {
|
|
235
|
-
|
|
241
|
+
w.forEach(([c, h]) => e.off(c, h)), g.clear(), u.clear();
|
|
236
242
|
};
|
|
237
243
|
}
|
|
238
|
-
var
|
|
239
|
-
const
|
|
244
|
+
var _ = /* @__PURE__ */ ((e) => (e.print = "presetPrintable:print", e))(_ || {});
|
|
245
|
+
const F = (e) => new Promise((n) => {
|
|
240
246
|
const t = document.createElement("iframe");
|
|
241
247
|
t.style.cssText = "position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;", t.srcdoc = e.content, t.onload = () => n(t), document.body.appendChild(t);
|
|
242
248
|
});
|
|
243
|
-
function
|
|
249
|
+
function de(e, n) {
|
|
244
250
|
const { Commands: t, Pages: s } = e;
|
|
245
251
|
return t.add(
|
|
246
|
-
|
|
247
|
-
async (a, o,
|
|
248
|
-
const
|
|
249
|
-
page:
|
|
252
|
+
_.print,
|
|
253
|
+
async (a, o, r = {}) => {
|
|
254
|
+
const i = {
|
|
255
|
+
page: r.allPages ? void 0 : s.getSelected(),
|
|
250
256
|
styles: "inline",
|
|
251
257
|
optionsHtml: {
|
|
252
258
|
// Avoid DataSource exporter
|
|
253
259
|
exporter: null
|
|
254
260
|
}
|
|
255
|
-
},
|
|
256
|
-
if (
|
|
257
|
-
for (const
|
|
258
|
-
|
|
261
|
+
}, p = (await t.run(z.projectFiles, i)).filter((u) => u.filename.endsWith(".html")), d = p.map((u) => u.content).join('<div style="break-before: page;"></div>'), g = [];
|
|
262
|
+
if (r.separatePrints)
|
|
263
|
+
for (const u of p)
|
|
264
|
+
g.push(await F(u));
|
|
259
265
|
else
|
|
260
|
-
|
|
261
|
-
for (const
|
|
262
|
-
const f =
|
|
266
|
+
g.push(await F({ content: d, filename: "", mimeType: "" }));
|
|
267
|
+
for (const u of g) {
|
|
268
|
+
const f = u.contentWindow;
|
|
263
269
|
f.focus(), f.print();
|
|
264
270
|
}
|
|
265
|
-
setTimeout(() =>
|
|
271
|
+
setTimeout(() => g.forEach((u) => u.remove()), 1e3);
|
|
266
272
|
}
|
|
267
273
|
), t.add("presetPrintable:exp", async (a) => {
|
|
268
|
-
await
|
|
269
|
-
const { Devices: o, Canvas:
|
|
270
|
-
f.html(
|
|
274
|
+
await M("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"), await M("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");
|
|
275
|
+
const { Devices: o, Canvas: r } = a, { sizeW: i, sizeH: l, sizeUnit: p } = o.getSelected().attributes, d = r.getFrameEl().contentDocument, g = "px", u = [D(i, p), D(l, p)], f = new window.jspdf.jsPDF({ unit: g, format: u }), y = d.body;
|
|
276
|
+
f.html(y, { callback: (w) => w.save() });
|
|
271
277
|
}), () => {
|
|
272
|
-
delete e.Commands.commands[
|
|
278
|
+
delete e.Commands.commands[_.print];
|
|
273
279
|
};
|
|
274
280
|
}
|
|
275
|
-
function
|
|
276
|
-
const { blockPageBreak: t = {} } = n, { Components: s, Blocks: a } = e, o = "Page Break",
|
|
277
|
-
return s.addType(
|
|
281
|
+
function ge(e, n) {
|
|
282
|
+
const { blockPageBreak: t = {} } = n, { Components: s, Blocks: a } = e, o = "Page Break", r = `${ie}${A}`;
|
|
283
|
+
return s.addType(A, {
|
|
278
284
|
block: t && {
|
|
279
285
|
label: o,
|
|
280
286
|
media: '<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',
|
|
@@ -282,59 +288,60 @@ function re(e, n) {
|
|
|
282
288
|
select: !0,
|
|
283
289
|
...t
|
|
284
290
|
},
|
|
285
|
-
isComponent:
|
|
291
|
+
isComponent: ae(A),
|
|
286
292
|
model: {
|
|
287
293
|
defaults: {
|
|
288
294
|
name: o,
|
|
289
|
-
classes:
|
|
290
|
-
attributes: { [
|
|
295
|
+
classes: r,
|
|
296
|
+
attributes: { [q]: A },
|
|
291
297
|
emptyState: !0,
|
|
292
298
|
stylable: !1,
|
|
293
299
|
droppable: !1,
|
|
294
|
-
draggable:
|
|
295
|
-
styles: `.${
|
|
300
|
+
draggable: re("wrapper"),
|
|
301
|
+
styles: `.${r} { break-before: page; }`,
|
|
296
302
|
traits: []
|
|
297
303
|
}
|
|
298
304
|
}
|
|
299
305
|
}), () => {
|
|
300
|
-
s.removeType(
|
|
306
|
+
s.removeType(A), a.remove(A);
|
|
301
307
|
};
|
|
302
308
|
}
|
|
303
|
-
const
|
|
309
|
+
const ue = "presetPrintable", he = B.free, fe = function(e, n = {}) {
|
|
310
|
+
var U;
|
|
304
311
|
const t = {
|
|
305
|
-
selectedDevice:
|
|
312
|
+
selectedDevice: m.A4,
|
|
306
313
|
...n
|
|
307
|
-
}, { Canvas: s, Devices: a } = e,
|
|
308
|
-
{ name: "A5", width: 148, height: 210, unit: "mm" },
|
|
309
|
-
{ name: "A5 Portrait", width: 210, height: 148, unit: "mm" },
|
|
310
|
-
{ name: "A4", width: 210, height: 297, unit: "mm" },
|
|
311
|
-
{ name: "A3", width: 297, height: 420, unit: "mm" },
|
|
312
|
-
{ name: "B5", width: 176, height: 250, unit: "mm" },
|
|
313
|
-
{ name: "B4", width: 250, height: 353, unit: "mm" },
|
|
314
|
-
{ name: "Letter", width: 8.5, height: 11, unit: "in" },
|
|
315
|
-
{ name: "Legal", width: 8.5, height: 14, unit: "in" },
|
|
316
|
-
{ name: "Ledger", width: 11, height: 17, unit: "in" }
|
|
317
|
-
].map((
|
|
314
|
+
}, { Canvas: s, Devices: a, Blocks: o } = e, r = s.events, i = e.events, l = t.selectedDevice || a.getConfig().default, p = [
|
|
315
|
+
{ id: m.A5, name: "A5", width: 148, height: 210, unit: "mm" },
|
|
316
|
+
{ id: m.A5Portrait, name: "A5 Portrait", width: 210, height: 148, unit: "mm" },
|
|
317
|
+
{ id: m.A4, name: "A4", width: 210, height: 297, unit: "mm" },
|
|
318
|
+
{ id: m.A3, name: "A3", width: 297, height: 420, unit: "mm" },
|
|
319
|
+
{ id: m.B5, name: "B5", width: 176, height: 250, unit: "mm" },
|
|
320
|
+
{ id: m.B4, name: "B4", width: 250, height: 353, unit: "mm" },
|
|
321
|
+
{ id: m.letter, name: "Letter", width: 8.5, height: 11, unit: "in" },
|
|
322
|
+
{ id: m.legal, name: "Legal", width: 8.5, height: 14, unit: "in" },
|
|
323
|
+
{ id: m.ledger, name: "Ledger", width: 11, height: 17, unit: "in" }
|
|
324
|
+
], g = (((U = t.devices) == null ? void 0 : U.call(t, { items: p })) || p).map((v) => ce(v, t));
|
|
318
325
|
a.devices.reset(g);
|
|
319
|
-
const
|
|
320
|
-
a.select(
|
|
321
|
-
const
|
|
322
|
-
const
|
|
323
|
-
(
|
|
326
|
+
const u = l && a.get(l) || a.getAll().at(0);
|
|
327
|
+
a.select(u), ["map", "video"].forEach((v) => o.remove(v));
|
|
328
|
+
const y = () => {
|
|
329
|
+
const v = "page-rule", { rules: b } = e.Css, { width: E, height: P, minHeight: L } = a.getSelected().attributes, S = P && P !== "auto" ? P : L;
|
|
330
|
+
(b.where({ id: v }).pop() || b.add(
|
|
324
331
|
{
|
|
325
|
-
id:
|
|
332
|
+
id: v,
|
|
326
333
|
selectors: [],
|
|
327
334
|
selectorsAdd: "@page"
|
|
328
335
|
},
|
|
329
336
|
{ at: 0 }
|
|
330
337
|
)).setStyle({
|
|
331
|
-
size: `${
|
|
338
|
+
size: `${E} ${S}`,
|
|
332
339
|
margin: "0"
|
|
333
340
|
});
|
|
334
|
-
},
|
|
335
|
-
const
|
|
336
|
-
${!!parseFloat(`${
|
|
337
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
341
|
+
}, w = (v) => {
|
|
342
|
+
const b = v.document, { minHeight: E } = a.getSelected().attributes, L = `
|
|
343
|
+
${!!parseFloat(`${E}`) ? `
|
|
344
|
+
[data-gjs-type="wrapper"] { min-height: ${E}; }
|
|
338
345
|
` : `
|
|
339
346
|
body {
|
|
340
347
|
overflow: hidden;
|
|
@@ -346,48 +353,48 @@ const ce = "presetPrintable", le = function(e, n = {}) {
|
|
|
346
353
|
}
|
|
347
354
|
`}
|
|
348
355
|
`;
|
|
349
|
-
|
|
356
|
+
K(`${C}preset-printable`, L, { doc: b, target: b.head }), y();
|
|
350
357
|
};
|
|
351
|
-
e.on(
|
|
352
|
-
const
|
|
353
|
-
if (
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
+
e.on(r.frameLoadBody, (v) => {
|
|
359
|
+
const b = v.window;
|
|
360
|
+
if (w(b), t.fixedHeight) {
|
|
361
|
+
const P = v.model.getComponent().getEl();
|
|
362
|
+
P == null || P.addEventListener("scroll", (L) => {
|
|
363
|
+
const S = L.target;
|
|
364
|
+
S.scrollTop > 0 && S.scrollTo(0, 0);
|
|
358
365
|
});
|
|
359
366
|
}
|
|
360
367
|
}), e.on(a.events.select, () => {
|
|
361
|
-
var
|
|
362
|
-
const
|
|
363
|
-
|
|
368
|
+
var b;
|
|
369
|
+
const v = (b = s.getFrameEl().contentDocument) == null ? void 0 : b.defaultView;
|
|
370
|
+
v && w(v);
|
|
364
371
|
});
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
|
|
372
|
+
const c = () => {
|
|
373
|
+
const b = e.Css.getRules().filter((E) => E.selectorsToString() === "body").pop();
|
|
374
|
+
b == null || b.addStyle({
|
|
368
375
|
"margin-top": "",
|
|
369
376
|
"margin-right": "",
|
|
370
377
|
"margin-bottom": "",
|
|
371
378
|
"margin-left": "",
|
|
372
379
|
margin: "0"
|
|
373
380
|
});
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
const
|
|
381
|
+
}, h = [[i.projectLoad, c]];
|
|
382
|
+
h.forEach(([v, b]) => e.on(v, b));
|
|
383
|
+
const x = pe(e, t), k = de(e), R = ge(e, t);
|
|
377
384
|
e.onReady(() => {
|
|
378
385
|
e.UndoManager.clear();
|
|
379
386
|
});
|
|
380
387
|
const T = () => {
|
|
381
|
-
|
|
388
|
+
h.forEach(([v, b]) => e.off(v, b)), x(), k(), R();
|
|
382
389
|
};
|
|
383
|
-
e.on(i.destroy, T),
|
|
390
|
+
e.on(i.destroy, T), ne({
|
|
384
391
|
editor: e,
|
|
385
392
|
licenseKey: t.licenseKey,
|
|
386
|
-
plan:
|
|
387
|
-
pluginName:
|
|
393
|
+
plan: he,
|
|
394
|
+
pluginName: ue,
|
|
388
395
|
cleanup: T
|
|
389
396
|
});
|
|
390
|
-
},
|
|
397
|
+
}, be = se(fe);
|
|
391
398
|
export {
|
|
392
|
-
|
|
399
|
+
be as default
|
|
393
400
|
};
|