@grapesjs/studio-sdk-plugins 1.0.29 → 1.0.30
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/canvasScreenshot/index.cjs.d.ts +3 -0
- package/dist/canvasScreenshot/index.cjs.js +1 -0
- package/dist/canvasScreenshot/index.d.ts +3 -0
- package/dist/canvasScreenshot/index.es.d.ts +3 -0
- package/dist/canvasScreenshot/index.es.js +212 -0
- package/dist/canvasScreenshot/index.umd.js +1 -0
- package/dist/canvasScreenshot/shared.d.ts +3 -0
- package/dist/canvasScreenshot/types.d.ts +61 -0
- package/dist/canvasScreenshot/typesSchema.d.ts +17 -0
- package/dist/canvasScreenshot/utils.d.ts +3 -0
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +48 -48
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +2400 -2302
- package/dist/index.umd.js +50 -50
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +173 -171
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/types.d.ts +29 -6
- package/dist/layoutSidebarButtons/typesSchema.d.ts +16 -0
- package/dist/prosemirror/index.cjs.js +9 -9
- package/dist/prosemirror/index.es.js +894 -885
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/prosemirror/utils.d.ts +4 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +96 -96
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/swiperComponent/index.cjs.js +5 -5
- package/dist/swiperComponent/index.es.js +103 -101
- package/dist/swiperComponent/index.umd.js +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const I="app.grapesjs.com",L="app-stage.grapesjs.com",C="app2.grapesjs.com",P="app-stage2.grapesjs.com",E=[I,C,L,P,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],N="license:check:start",A="license:check:end",D=()=>typeof window<"u",_=(e,n={})=>{const s=O(e)?{id:e,src:e}:e;return new Promise((c,d)=>{var m,h;const{loadedScripts:r}=n,{id:i,src:a}=s,l=document.querySelector(`script[src="${a}"]`);if(l){if((m=n.onScript)==null||m.call(n,l),r&&!r.get(a)){l.addEventListener("load",()=>c(i)),l.addEventListener("error",()=>d(i));return}return c(i)}const u=window.define;window.define=void 0;const t=()=>{r==null||r.set(a,!0),window.define=u},o=document.createElement("script");o.src=a,o.onload=()=>{c(i),t()},o.onerror=()=>{d(i),t()},document.head.appendChild(o),(h=n.onScript)==null||h.call(n,o)})},U=e=>{const n=e.map(s=>_(s));return Promise.allSettled(n)},W=async e=>{const n=window.define;window.define=void 0;const s=await U(e);return window.define=n,s},$=({isDev:e,isStage:n})=>`${e?"":`https://${n?L:I}`}/api`,k=()=>{const e=D()&&window.location.hostname;return!!e&&(E.includes(e)||E.some(n=>e.endsWith(n)))},O=e=>typeof e=="string";async function j({path:e,baseApiUrl:n,method:s="GET",headers:c={},params:d,body:r}){const a=`${n||$({isDev:!1,isStage:!1})}${e}`,l={method:s,headers:{"Content-Type":"application/json",...c}};r&&(l.body=JSON.stringify(r));const u=d?new URLSearchParams(d).toString():"",t=u?`?${u}`:"",o=await fetch(`${a}${t}`,l);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{});const b={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function R(e){const n=e;return n.init=s=>c=>e(c,s),n}const H=e=>R(e);async function K({editor:e,plan:n,pluginName:s,licenseKey:c,cleanup:d}){let r="",i=!1;const a=k(),l=t=>{console.warn("Cleanup plugin:",s,"Reason:",t),d()},u=(t={})=>{var f;const{error:o,sdkLicense:m}=t,h=(f=t.plan)==null?void 0:f.category;if(!(m||t.license)||o)l(o||"Invalid license");else if(h){const v=b[n],w=b[h];v>w&&l({pluginRequiredPlan:n,licensePlan:h})}};e.on(N,t=>{r=t==null?void 0:t.baseApiUrl,i=!0}),e.on(A,t=>{u(t)}),setTimeout(async()=>{if(!i){if(a)return;if(c){const t=await x({licenseKey:c,pluginName:s,baseApiUrl:r});t&&u(t)}else l("The `licenseKey` option not provided")}},2e3)}async function x(e){const{licenseKey:n,pluginName:s,baseApiUrl:c}=e;try{return(await j({baseApiUrl:c,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const G="canvasScreenshot",M=p.startup;var T=(e=>(e.screenshot="studioPlugin:screenshot",e))(T||{});const q=async e=>await W([{id:"html-to-image",src:e}]),B=async(e,n={},s={})=>{const{cdnScript:c}=s;if(!window.htmlToImage){if(!c)return;await q(c)}return new Promise((d,r)=>{(async()=>{try{const{canvasWidth:a,canvasHeight:l,width:u,height:t,type:o,quality:m,addOptions:h}=n,g={pixelRatio:1,width:u,height:t,canvasWidth:a,canvasHeight:l},f=(h==null?void 0:h(g))||g,w=await window.htmlToImage.toCanvas(e,f);w.toBlob(y=>{y?d({file:y,canvas:w}):r(new Error("Failed to create file from canvas"))},o,m)}catch(a){r(a)}})()})},S=T.screenshot,F=function(e,n={}){const{Commands:s,Canvas:c,Storage:d}=e,r=d.events.afterStore,i={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...n};s.add(S,async(u,t,o)=>{const{el:m,...h}=o;return await B(m,h,i)});const a=async()=>{var t;const u=c.getBody();if(!u)return e.log("Canvas element not found");try{const o=await e.runCommand(S,{el:u,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(t=i.screenshotOnSave)==null||t.call(i,{...o,editor:e})}catch(o){console.error("Screenshot error",o)}};i.screenshotOnSave&&e.on(r,a);const l=()=>{delete s.commands[S],e.off(r,a)};K({editor:e,licenseKey:n.licenseKey,plan:M,pluginName:G,cleanup:l})},J=H(F);module.exports=J;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const I = "app.grapesjs.com", L = "app-stage.grapesjs.com", C = "app2.grapesjs.com", P = "app-stage2.grapesjs.com", E = [
|
|
2
|
+
I,
|
|
3
|
+
C,
|
|
4
|
+
L,
|
|
5
|
+
P,
|
|
6
|
+
"localhost",
|
|
7
|
+
"127.0.0.1",
|
|
8
|
+
".local-credentialless.webcontainer.io",
|
|
9
|
+
// For stackblitz.com demos
|
|
10
|
+
".local.webcontainer.io",
|
|
11
|
+
// For stackblitz.com demos
|
|
12
|
+
"-sandpack.codesandbox.io"
|
|
13
|
+
// For Sandpack demos
|
|
14
|
+
], N = "license:check:start", A = "license:check:end", D = () => typeof window < "u", _ = (e, n = {}) => {
|
|
15
|
+
const s = O(e) ? { id: e, src: e } : e;
|
|
16
|
+
return new Promise((c, d) => {
|
|
17
|
+
var m, h;
|
|
18
|
+
const { loadedScripts: r } = n, { id: i, src: a } = s, l = document.querySelector(`script[src="${a}"]`);
|
|
19
|
+
if (l) {
|
|
20
|
+
if ((m = n.onScript) == null || m.call(n, l), r && !r.get(a)) {
|
|
21
|
+
l.addEventListener("load", () => c(i)), l.addEventListener("error", () => d(i));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return c(i);
|
|
25
|
+
}
|
|
26
|
+
const u = window.define;
|
|
27
|
+
window.define = void 0;
|
|
28
|
+
const t = () => {
|
|
29
|
+
r == null || r.set(a, !0), window.define = u;
|
|
30
|
+
}, o = document.createElement("script");
|
|
31
|
+
o.src = a, o.onload = () => {
|
|
32
|
+
c(i), t();
|
|
33
|
+
}, o.onerror = () => {
|
|
34
|
+
d(i), t();
|
|
35
|
+
}, document.head.appendChild(o), (h = n.onScript) == null || h.call(n, o);
|
|
36
|
+
});
|
|
37
|
+
}, U = (e) => {
|
|
38
|
+
const n = e.map((s) => _(s));
|
|
39
|
+
return Promise.allSettled(n);
|
|
40
|
+
}, W = async (e) => {
|
|
41
|
+
const n = window.define;
|
|
42
|
+
window.define = void 0;
|
|
43
|
+
const s = await U(e);
|
|
44
|
+
return window.define = n, s;
|
|
45
|
+
}, $ = ({ isDev: e, isStage: n }) => `${e ? "" : `https://${n ? L : I}`}/api`, k = () => {
|
|
46
|
+
const e = D() && window.location.hostname;
|
|
47
|
+
return !!e && (E.includes(e) || E.some((n) => e.endsWith(n)));
|
|
48
|
+
}, O = (e) => typeof e == "string";
|
|
49
|
+
async function j({
|
|
50
|
+
path: e,
|
|
51
|
+
baseApiUrl: n,
|
|
52
|
+
method: s = "GET",
|
|
53
|
+
headers: c = {},
|
|
54
|
+
params: d,
|
|
55
|
+
body: r
|
|
56
|
+
}) {
|
|
57
|
+
const a = `${n || $({ isDev: !1, isStage: !1 })}${e}`, l = {
|
|
58
|
+
method: s,
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
...c
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
r && (l.body = JSON.stringify(r));
|
|
65
|
+
const u = d ? new URLSearchParams(d).toString() : "", t = u ? `?${u}` : "", o = await fetch(`${a}${t}`, l);
|
|
66
|
+
if (!o.ok)
|
|
67
|
+
throw new Error(`HTTP error! status: ${o.status}`);
|
|
68
|
+
return o.json();
|
|
69
|
+
}
|
|
70
|
+
var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {});
|
|
71
|
+
const b = {
|
|
72
|
+
[p.free]: 0,
|
|
73
|
+
[p.startup]: 10,
|
|
74
|
+
[p.business]: 20,
|
|
75
|
+
[p.enterprise]: 30
|
|
76
|
+
};
|
|
77
|
+
function R(e) {
|
|
78
|
+
const n = e;
|
|
79
|
+
return n.init = (s) => (c) => e(c, s), n;
|
|
80
|
+
}
|
|
81
|
+
const H = (e) => /* @__PURE__ */ R(e);
|
|
82
|
+
async function K({
|
|
83
|
+
editor: e,
|
|
84
|
+
plan: n,
|
|
85
|
+
pluginName: s,
|
|
86
|
+
licenseKey: c,
|
|
87
|
+
cleanup: d
|
|
88
|
+
}) {
|
|
89
|
+
let r = "", i = !1;
|
|
90
|
+
const a = k(), l = (t) => {
|
|
91
|
+
console.warn("Cleanup plugin:", s, "Reason:", t), d();
|
|
92
|
+
}, u = (t = {}) => {
|
|
93
|
+
var f;
|
|
94
|
+
const { error: o, sdkLicense: m } = t, h = (f = t.plan) == null ? void 0 : f.category;
|
|
95
|
+
if (!(m || t.license) || o)
|
|
96
|
+
l(o || "Invalid license");
|
|
97
|
+
else if (h) {
|
|
98
|
+
const v = b[n], w = b[h];
|
|
99
|
+
v > w && l({ pluginRequiredPlan: n, licensePlan: h });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
e.on(N, (t) => {
|
|
103
|
+
r = t == null ? void 0 : t.baseApiUrl, i = !0;
|
|
104
|
+
}), e.on(A, (t) => {
|
|
105
|
+
u(t);
|
|
106
|
+
}), setTimeout(async () => {
|
|
107
|
+
if (!i) {
|
|
108
|
+
if (a) return;
|
|
109
|
+
if (c) {
|
|
110
|
+
const t = await x({ licenseKey: c, pluginName: s, baseApiUrl: r });
|
|
111
|
+
t && u(t);
|
|
112
|
+
} else
|
|
113
|
+
l("The `licenseKey` option not provided");
|
|
114
|
+
}
|
|
115
|
+
}, 2e3);
|
|
116
|
+
}
|
|
117
|
+
async function x(e) {
|
|
118
|
+
const { licenseKey: n, pluginName: s, baseApiUrl: c } = e;
|
|
119
|
+
try {
|
|
120
|
+
return (await j({
|
|
121
|
+
baseApiUrl: c,
|
|
122
|
+
path: `/sdk/${n || "na"}`,
|
|
123
|
+
method: "POST",
|
|
124
|
+
params: {
|
|
125
|
+
d: window.location.hostname,
|
|
126
|
+
pn: s
|
|
127
|
+
}
|
|
128
|
+
})).result || {};
|
|
129
|
+
} catch (d) {
|
|
130
|
+
return console.error("Error during SDK license check:", d), !1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const G = "canvasScreenshot", M = p.startup;
|
|
134
|
+
var T = /* @__PURE__ */ ((e) => (e.screenshot = "studioPlugin:screenshot", e))(T || {});
|
|
135
|
+
const q = async (e) => await W([{ id: "html-to-image", src: e }]), B = async (e, n = {}, s = {}) => {
|
|
136
|
+
const { cdnScript: c } = s;
|
|
137
|
+
if (!window.htmlToImage) {
|
|
138
|
+
if (!c) return;
|
|
139
|
+
await q(c);
|
|
140
|
+
}
|
|
141
|
+
return new Promise((d, r) => {
|
|
142
|
+
(async () => {
|
|
143
|
+
try {
|
|
144
|
+
const { canvasWidth: a, canvasHeight: l, width: u, height: t, type: o, quality: m, addOptions: h } = n, g = {
|
|
145
|
+
pixelRatio: 1,
|
|
146
|
+
width: u,
|
|
147
|
+
height: t,
|
|
148
|
+
canvasWidth: a,
|
|
149
|
+
canvasHeight: l
|
|
150
|
+
}, f = (h == null ? void 0 : h(g)) || g, w = await window.htmlToImage.toCanvas(e, f);
|
|
151
|
+
w.toBlob(
|
|
152
|
+
(y) => {
|
|
153
|
+
y ? d({
|
|
154
|
+
file: y,
|
|
155
|
+
canvas: w
|
|
156
|
+
}) : r(new Error("Failed to create file from canvas"));
|
|
157
|
+
},
|
|
158
|
+
o,
|
|
159
|
+
m
|
|
160
|
+
);
|
|
161
|
+
} catch (a) {
|
|
162
|
+
r(a);
|
|
163
|
+
}
|
|
164
|
+
})();
|
|
165
|
+
});
|
|
166
|
+
}, S = T.screenshot, F = function(e, n = {}) {
|
|
167
|
+
const { Commands: s, Canvas: c, Storage: d } = e, r = d.events.afterStore, i = {
|
|
168
|
+
cdnScript: "https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",
|
|
169
|
+
...n
|
|
170
|
+
};
|
|
171
|
+
s.add(S, async (u, t, o) => {
|
|
172
|
+
const { el: m, ...h } = o;
|
|
173
|
+
return await B(m, h, i);
|
|
174
|
+
});
|
|
175
|
+
const a = async () => {
|
|
176
|
+
var t;
|
|
177
|
+
const u = c.getBody();
|
|
178
|
+
if (!u)
|
|
179
|
+
return e.log("Canvas element not found");
|
|
180
|
+
try {
|
|
181
|
+
const o = await e.runCommand(S, {
|
|
182
|
+
el: u,
|
|
183
|
+
canvasWidth: 400,
|
|
184
|
+
// max element width for the screenshot
|
|
185
|
+
canvasHeight: 225,
|
|
186
|
+
// 675 * (400 / 1200)
|
|
187
|
+
width: 1200,
|
|
188
|
+
// Desktop size for the screenshot
|
|
189
|
+
height: 675,
|
|
190
|
+
// 1200 / (16/9) - 16:9 aspect ratio
|
|
191
|
+
type: "image/jpeg"
|
|
192
|
+
});
|
|
193
|
+
(t = i.screenshotOnSave) == null || t.call(i, { ...o, editor: e });
|
|
194
|
+
} catch (o) {
|
|
195
|
+
console.error("Screenshot error", o);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
i.screenshotOnSave && e.on(r, a);
|
|
199
|
+
const l = () => {
|
|
200
|
+
delete s.commands[S], e.off(r, a);
|
|
201
|
+
};
|
|
202
|
+
K({
|
|
203
|
+
editor: e,
|
|
204
|
+
licenseKey: n.licenseKey,
|
|
205
|
+
plan: M,
|
|
206
|
+
pluginName: G,
|
|
207
|
+
cleanup: l
|
|
208
|
+
});
|
|
209
|
+
}, J = H(F);
|
|
210
|
+
export {
|
|
211
|
+
J as default
|
|
212
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(m,f){typeof exports=="object"&&typeof module<"u"?module.exports=f():typeof define=="function"&&define.amd?define(f):(m=typeof globalThis<"u"?globalThis:m||self,m.StudioSdkPlugins_canvasScreenshot=f())})(this,function(){"use strict";const m="app.grapesjs.com",f="app-stage.grapesjs.com",T=[m,"app2.grapesjs.com",f,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],P="license:check:start",A="license:check:end",N=()=>typeof window<"u",C=(e,n={})=>{const s=k(e)?{id:e,src:e}:e;return new Promise((c,d)=>{var p,h;const{loadedScripts:i}=n,{id:r,src:a}=s,l=document.querySelector(`script[src="${a}"]`);if(l){if((p=n.onScript)==null||p.call(n,l),i&&!i.get(a)){l.addEventListener("load",()=>c(r)),l.addEventListener("error",()=>d(r));return}return c(r)}const u=window.define;window.define=void 0;const t=()=>{i==null||i.set(a,!0),window.define=u},o=document.createElement("script");o.src=a,o.onload=()=>{c(r),t()},o.onerror=()=>{d(r),t()},document.head.appendChild(o),(h=n.onScript)==null||h.call(n,o)})},D=e=>{const n=e.map(s=>C(s));return Promise.allSettled(n)},_=async e=>{const n=window.define;window.define=void 0;const s=await D(e);return window.define=n,s},O=({isDev:e,isStage:n})=>`${e?"":`https://${n?f:m}`}/api`,U=()=>{const e=N()&&window.location.hostname;return!!e&&(T.includes(e)||T.some(n=>e.endsWith(n)))},k=e=>typeof e=="string";async function W({path:e,baseApiUrl:n,method:s="GET",headers:c={},params:d,body:i}){const a=`${n||O({isDev:!1,isStage:!1})}${e}`,l={method:s,headers:{"Content-Type":"application/json",...c}};i&&(l.body=JSON.stringify(i));const u=d?new URLSearchParams(d).toString():"",t=u?`?${u}`:"",o=await fetch(`${a}${t}`,l);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var w=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(w||{});const E={[w.free]:0,[w.startup]:10,[w.business]:20,[w.enterprise]:30};function $(e){const n=e;return n.init=s=>c=>e(c,s),n}const j=e=>$(e);async function R({editor:e,plan:n,pluginName:s,licenseKey:c,cleanup:d}){let i="",r=!1;const a=U(),l=t=>{console.warn("Cleanup plugin:",s,"Reason:",t),d()},u=(t={})=>{var g;const{error:o,sdkLicense:p}=t,h=(g=t.plan)==null?void 0:g.category;if(!(p||t.license)||o)l(o||"Invalid license");else if(h){const b=E[n],S=E[h];b>S&&l({pluginRequiredPlan:n,licensePlan:h})}};e.on(P,t=>{i=t==null?void 0:t.baseApiUrl,r=!0}),e.on(A,t=>{u(t)}),setTimeout(async()=>{if(!r){if(a)return;if(c){const t=await x({licenseKey:c,pluginName:s,baseApiUrl:i});t&&u(t)}else l("The `licenseKey` option not provided")}},2e3)}async function x(e){const{licenseKey:n,pluginName:s,baseApiUrl:c}=e;try{return(await W({baseApiUrl:c,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const M="canvasScreenshot",G=w.startup;var I=(e=>(e.screenshot="studioPlugin:screenshot",e))(I||{});const H=async e=>await _([{id:"html-to-image",src:e}]),K=async(e,n={},s={})=>{const{cdnScript:c}=s;if(!window.htmlToImage){if(!c)return;await H(c)}return new Promise((d,i)=>{(async()=>{try{const{canvasWidth:a,canvasHeight:l,width:u,height:t,type:o,quality:p,addOptions:h}=n,y={pixelRatio:1,width:u,height:t,canvasWidth:a,canvasHeight:l},g=(h==null?void 0:h(y))||y,S=await window.htmlToImage.toCanvas(e,g);S.toBlob(L=>{L?d({file:L,canvas:S}):i(new Error("Failed to create file from canvas"))},o,p)}catch(a){i(a)}})()})},v=I.screenshot;return j(function(e,n={}){const{Commands:s,Canvas:c,Storage:d}=e,i=d.events.afterStore,r={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...n};s.add(v,async(u,t,o)=>{const{el:p,...h}=o;return await K(p,h,r)});const a=async()=>{var t;const u=c.getBody();if(!u)return e.log("Canvas element not found");try{const o=await e.runCommand(v,{el:u,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(t=r.screenshotOnSave)==null||t.call(r,{...o,editor:e})}catch(o){console.error("Screenshot error",o)}};r.screenshotOnSave&&e.on(i,a);const l=()=>{delete s.commands[v],e.off(i,a)};R({editor:e,licenseKey:n.licenseKey,plan:G,pluginName:M,cleanup:l})})});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Editor } from 'grapesjs';
|
|
2
|
+
import { CanvasScreenshotOptions as CanvasScreenshotOptionsSchema } from './typesSchema';
|
|
3
|
+
export interface CanvasScreenshotOptions extends Omit<CanvasScreenshotOptionsSchema, 'screenshotOnSave'> {
|
|
4
|
+
/**
|
|
5
|
+
* If this callback is provided, the screenshot will be taken automatically on each project save.
|
|
6
|
+
* @example
|
|
7
|
+
* screenshotOnSave: result => {
|
|
8
|
+
* console.log('screenshotOnSave', result);
|
|
9
|
+
* myUploadScreenshotFile(result.file);
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
screenshotOnSave?: (props: ScreenshotResult) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface ScreenshotElOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Width in pixels to be applied to node before rendering.
|
|
17
|
+
*/
|
|
18
|
+
width?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Height in pixels to be applied to node before rendering.
|
|
21
|
+
*/
|
|
22
|
+
height?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Width of the canvas to be used for rendering.
|
|
25
|
+
*/
|
|
26
|
+
canvasWidth?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Height of the canvas to be used for rendering.
|
|
29
|
+
*/
|
|
30
|
+
canvasHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* A string indicating the image format.
|
|
33
|
+
* @default 'image/png'
|
|
34
|
+
*/
|
|
35
|
+
type?: string;
|
|
36
|
+
/**
|
|
37
|
+
* A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp).
|
|
38
|
+
* A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
39
|
+
*/
|
|
40
|
+
quality?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Additional screenshot library options.
|
|
43
|
+
* @example
|
|
44
|
+
* addOptions: (defaultOptions) => ({
|
|
45
|
+
* ...defaultOptions,
|
|
46
|
+
* backgroundColor: '#fff',
|
|
47
|
+
* })
|
|
48
|
+
*/
|
|
49
|
+
addOptions?: (defaultOptions: Record<string, any>) => Record<string, any>;
|
|
50
|
+
}
|
|
51
|
+
export interface ScreenshotResult {
|
|
52
|
+
editor: Editor;
|
|
53
|
+
file: Blob;
|
|
54
|
+
canvas: HTMLCanvasElement;
|
|
55
|
+
}
|
|
56
|
+
export interface CommandScreenshotOptions extends ScreenshotElOptions {
|
|
57
|
+
el: HTMLElement;
|
|
58
|
+
}
|
|
59
|
+
export declare enum StudioScreenshotCommands {
|
|
60
|
+
screenshot = "studioPlugin:screenshot"
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SDKPluginOptions } from '../utils';
|
|
2
|
+
export interface CanvasScreenshotOptions extends SDKPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* CDN URL of the screenshot library.
|
|
5
|
+
* @default 'https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js'
|
|
6
|
+
*/
|
|
7
|
+
cdnScript?: string;
|
|
8
|
+
/**
|
|
9
|
+
* If this callback is provided, the screenshot will be taken automatically on each project save.
|
|
10
|
+
* @examples
|
|
11
|
+
* screenshotOnSave: result => {
|
|
12
|
+
* console.log('screenshotOnSave', result);
|
|
13
|
+
* myUploadScreenshotFile(result.file);
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
screenshotOnSave?: '__fn__';
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CanvasScreenshotOptions, ScreenshotElOptions, ScreenshotResult } from './types';
|
|
2
|
+
export declare const loadHtml2Image: (src: string) => Promise<PromiseSettledResult<string>[]>;
|
|
3
|
+
export declare const screenshotEl: (el: HTMLElement, opt?: ScreenshotElOptions, pluginOptions?: CanvasScreenshotOptions) => Promise<Omit<ScreenshotResult, "editor"> | undefined>;
|
package/dist/index.cjs.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { default as rteProseMirror } from './prosemirror';
|
|
|
14
14
|
export { default as canvasEmptyState } from './canvasEmptyState';
|
|
15
15
|
export { default as canvasFullSize } from './canvasFullSize';
|
|
16
16
|
export { default as canvasGridMode } from './canvasGridMode';
|
|
17
|
+
export { default as canvasScreenshot } from './canvasScreenshot';
|
|
17
18
|
export { default as layoutSidebarButtons } from './layoutSidebarButtons';
|
|
18
19
|
export { default as presetPrintable } from './presetPrintable';
|
|
19
20
|
export { default as dataSourceEjs } from './dataSourceEjs';
|