@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
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/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
y,
|
|
4
|
-
C,
|
|
1
|
+
import T from "handlebars/dist/cjs/handlebars";
|
|
2
|
+
const $ = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = "app2.grapesjs.com", A = "app-stage2.grapesjs.com", b = [
|
|
5
3
|
$,
|
|
6
|
-
|
|
4
|
+
k,
|
|
5
|
+
x,
|
|
6
|
+
A,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
@@ -12,113 +12,126 @@ const y = "app.grapesjs.com", $ = "app-stage.grapesjs.com", C = "app2.grapesjs.c
|
|
|
12
12
|
// For stackblitz.com demos
|
|
13
13
|
"-sandpack.codesandbox.io"
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
],
|
|
16
|
-
isDev:
|
|
15
|
+
], L = "license:check:end", N = () => typeof window < "u", R = ({
|
|
16
|
+
isDev: e,
|
|
17
17
|
isStage: t,
|
|
18
|
-
isPlatform:
|
|
19
|
-
}) => `${
|
|
20
|
-
const
|
|
21
|
-
return !!
|
|
18
|
+
isPlatform: s
|
|
19
|
+
}) => `${e ? "" : `https://${t ? x : $}`}/${s ? "platform-api" : "api"}`, O = () => {
|
|
20
|
+
const e = N() && window.location.hostname;
|
|
21
|
+
return !!e && (b.includes(e) || b.some((t) => e.endsWith(t)));
|
|
22
22
|
};
|
|
23
|
-
async function
|
|
24
|
-
path:
|
|
23
|
+
async function _({
|
|
24
|
+
path: e,
|
|
25
25
|
baseApiUrl: t,
|
|
26
|
-
method:
|
|
26
|
+
method: s = "GET",
|
|
27
27
|
headers: n = {},
|
|
28
|
-
params:
|
|
29
|
-
body:
|
|
28
|
+
params: a,
|
|
29
|
+
body: r
|
|
30
30
|
}) {
|
|
31
|
-
const
|
|
32
|
-
method:
|
|
31
|
+
const i = `${t || R({ isDev: !1, isStage: !1 })}${e}`, c = {
|
|
32
|
+
method: s,
|
|
33
33
|
headers: {
|
|
34
34
|
"Content-Type": "application/json",
|
|
35
35
|
...n
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
throw new Error(`HTTP error! status: ${
|
|
42
|
-
return
|
|
38
|
+
r && (c.body = JSON.stringify(r));
|
|
39
|
+
const u = a ? new URLSearchParams(a).toString() : "", h = u ? `?${u}` : "", l = await fetch(`${i}${h}`, c);
|
|
40
|
+
if (!l.ok)
|
|
41
|
+
throw new Error(`HTTP error! status: ${l.status}`);
|
|
42
|
+
return l.json();
|
|
43
43
|
}
|
|
44
|
-
var p = /* @__PURE__ */ ((
|
|
45
|
-
const
|
|
44
|
+
var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), d = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", 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.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", 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.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", 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))(d || {});
|
|
45
|
+
const m = {
|
|
46
46
|
[p.free]: 0,
|
|
47
47
|
[p.startup]: 10,
|
|
48
48
|
[p.business]: 20,
|
|
49
49
|
[p.enterprise]: 30
|
|
50
50
|
};
|
|
51
|
-
function
|
|
52
|
-
const t =
|
|
53
|
-
return t.init = (
|
|
51
|
+
function w(e) {
|
|
52
|
+
const t = e;
|
|
53
|
+
return t.init = (s) => (n) => e(n, s), t;
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
async function
|
|
57
|
-
editor:
|
|
55
|
+
const D = (e) => /* @__PURE__ */ w(e);
|
|
56
|
+
async function G({
|
|
57
|
+
editor: e,
|
|
58
58
|
plan: t,
|
|
59
|
-
pluginName:
|
|
59
|
+
pluginName: s,
|
|
60
60
|
licenseKey: n,
|
|
61
|
-
onLicenseCheckResponse:
|
|
62
|
-
cleanup:
|
|
61
|
+
onLicenseCheckResponse: a,
|
|
62
|
+
cleanup: r
|
|
63
63
|
}) {
|
|
64
|
-
let
|
|
65
|
-
const
|
|
66
|
-
console.warn("Cleanup plugin:",
|
|
67
|
-
},
|
|
68
|
-
var
|
|
69
|
-
const { error:
|
|
70
|
-
if (!(
|
|
71
|
-
c(
|
|
72
|
-
else if (
|
|
73
|
-
const
|
|
74
|
-
|
|
64
|
+
let o = "", i;
|
|
65
|
+
const c = (l) => {
|
|
66
|
+
console.warn("Cleanup plugin:", s, "Reason:", l), r();
|
|
67
|
+
}, u = (l = {}) => {
|
|
68
|
+
var P;
|
|
69
|
+
const { error: y, sdkLicense: E } = l, g = (P = l.plan) == null ? void 0 : P.category;
|
|
70
|
+
if (!(E || l.license) || y)
|
|
71
|
+
c(y || "Invalid license");
|
|
72
|
+
else if (g) {
|
|
73
|
+
const I = m[t], S = m[g];
|
|
74
|
+
I > S && c({ pluginRequiredPlan: t, licensePlan: g });
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
77
|
+
e.Commands.has(d.settings) && (i = e.runCommand(d.settings), o = (i == null ? void 0 : i.baseUrl) || "");
|
|
78
|
+
const h = (l) => {
|
|
79
|
+
a == null || a(l), l && u(l);
|
|
80
|
+
};
|
|
81
|
+
if (!i) {
|
|
82
|
+
e.onReady(async () => {
|
|
83
|
+
if (!O())
|
|
84
|
+
if (n) {
|
|
85
|
+
const l = await B({ licenseKey: n, pluginName: s, baseApiUrl: o });
|
|
86
|
+
h(l);
|
|
87
|
+
} else
|
|
88
|
+
c("The `licenseKey` option not provided");
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (i.licensePlan || i.licenseError) {
|
|
93
|
+
const l = M(i);
|
|
94
|
+
h(l);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
e.on(L, (l) => h(l));
|
|
91
98
|
}
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
const M = (e) => ({
|
|
100
|
+
sdkLicense: e.license,
|
|
101
|
+
license: e.license,
|
|
102
|
+
error: e.licenseError,
|
|
103
|
+
plan: e.licensePlan
|
|
104
|
+
});
|
|
105
|
+
async function B(e) {
|
|
106
|
+
const { licenseKey: t, pluginName: s, baseApiUrl: n } = e;
|
|
94
107
|
try {
|
|
95
|
-
return (await
|
|
108
|
+
return (await _({
|
|
96
109
|
baseApiUrl: n,
|
|
97
110
|
path: `/sdk/${t || "na"}`,
|
|
98
111
|
method: "POST",
|
|
99
112
|
params: {
|
|
100
113
|
d: window.location.hostname,
|
|
101
|
-
pn:
|
|
114
|
+
pn: s
|
|
102
115
|
}
|
|
103
116
|
})).result || {};
|
|
104
|
-
} catch (
|
|
105
|
-
return console.error("Error during SDK license check:",
|
|
117
|
+
} catch (a) {
|
|
118
|
+
return console.error("Error during SDK license check:", a), !1;
|
|
106
119
|
}
|
|
107
120
|
}
|
|
108
|
-
const
|
|
109
|
-
...
|
|
121
|
+
const j = (e, t) => (e.config.optsHtml = {
|
|
122
|
+
...e.config.optsHtml,
|
|
110
123
|
exporter: t
|
|
111
124
|
}, () => {
|
|
112
|
-
|
|
113
|
-
}), U = (
|
|
114
|
-
const
|
|
115
|
-
const { input:
|
|
116
|
-
(!
|
|
117
|
-
}, n =
|
|
118
|
-
return
|
|
119
|
-
|
|
125
|
+
e.config.optsHtml.exporter = void 0;
|
|
126
|
+
}), U = (e, t) => {
|
|
127
|
+
const s = (a) => {
|
|
128
|
+
const { input: r } = a, { contains: o } = t;
|
|
129
|
+
(!o || r.includes(o)) && (a.input = t.importer.import(r));
|
|
130
|
+
}, n = e.Parser.events.htmlBefore;
|
|
131
|
+
return e.on(n, s), () => {
|
|
132
|
+
e.off(n, s);
|
|
120
133
|
};
|
|
121
|
-
},
|
|
134
|
+
}, v = {
|
|
122
135
|
equals: "equals",
|
|
123
136
|
isTruthy: "isTruthy",
|
|
124
137
|
isFalsy: "isFalsy",
|
|
@@ -131,7 +144,7 @@ const H = (a, t) => (a.config.optsHtml = {
|
|
|
131
144
|
isNumber: "isNumber",
|
|
132
145
|
isBoolean: "isBoolean",
|
|
133
146
|
isDefaultValue: "isDefaultValue"
|
|
134
|
-
},
|
|
147
|
+
}, H = {
|
|
135
148
|
">": "numGt",
|
|
136
149
|
"<": "numLt",
|
|
137
150
|
">=": "numGte",
|
|
@@ -145,58 +158,58 @@ const H = (a, t) => (a.config.optsHtml = {
|
|
|
145
158
|
equalsIgnoreCase: "strEqualsIgnoreCase",
|
|
146
159
|
trimEquals: "strTrimEquals"
|
|
147
160
|
}, V = {
|
|
148
|
-
...
|
|
149
|
-
...
|
|
161
|
+
...v,
|
|
162
|
+
...H,
|
|
150
163
|
...W
|
|
151
164
|
};
|
|
152
|
-
class
|
|
165
|
+
class F {
|
|
153
166
|
getHelperId(t) {
|
|
154
167
|
return V[t] || t;
|
|
155
168
|
}
|
|
156
|
-
getFullPath({ collectionId: t, path:
|
|
157
|
-
let n =
|
|
158
|
-
return t && (n = [this._sanitizeVariableName(t),
|
|
169
|
+
getFullPath({ collectionId: t, path: s }) {
|
|
170
|
+
let n = s;
|
|
171
|
+
return t && (n = [this._sanitizeVariableName(t), s].filter(Boolean).join(".")), n || "";
|
|
159
172
|
}
|
|
160
173
|
getVariableSyntax({ dataResolver: t }) {
|
|
161
|
-
const { defaultValue:
|
|
162
|
-
return
|
|
174
|
+
const { defaultValue: s } = t, n = this.getFullPath(t);
|
|
175
|
+
return s ? `{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}` : `{{{${n}}}}`;
|
|
163
176
|
}
|
|
164
177
|
getCollectionStartSyntax({ dataResolver: t }) {
|
|
165
|
-
const { collectionId:
|
|
166
|
-
let
|
|
178
|
+
const { collectionId: s, dataSource: n } = t, a = n == null ? void 0 : n.path;
|
|
179
|
+
let r = "";
|
|
167
180
|
if (t.startIndex !== void 0 || t.endIndex !== void 0) {
|
|
168
|
-
const
|
|
169
|
-
h !== "" ?
|
|
181
|
+
const u = t.startIndex ?? 0, h = t.endIndex !== void 0 ? t.endIndex : "";
|
|
182
|
+
h !== "" ? r = ` (slice ${a} ${u} ${h})` : r = ` (slice ${a} ${u})`;
|
|
170
183
|
}
|
|
171
|
-
const
|
|
172
|
-
return `{{#each ${
|
|
184
|
+
const i = ` as |${this._sanitizeVariableName(s)}|`;
|
|
185
|
+
return `{{#each ${r || a}${i}}}`;
|
|
173
186
|
}
|
|
174
187
|
getCollectionEndSyntax() {
|
|
175
188
|
return "{{/each}}";
|
|
176
189
|
}
|
|
177
190
|
getConditionalStartSyntax({ dataResolver: t }) {
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
const n =
|
|
181
|
-
if (
|
|
182
|
-
const { statements:
|
|
183
|
-
return `{{#if ${
|
|
191
|
+
const s = t.condition;
|
|
192
|
+
if (!s) return "";
|
|
193
|
+
const n = s, a = s;
|
|
194
|
+
if (a.statements && a.logicalOperator === "and" || a.logicalOperator === "or") {
|
|
195
|
+
const { statements: r } = a, o = a.logicalOperator, i = r.map((u) => this._parseCondition(u)).join(" ");
|
|
196
|
+
return `{{#if ${r.length > 1 ? `(${o} ${i})` : i}}}`;
|
|
184
197
|
} else
|
|
185
198
|
return `{{#if ${this._parseCondition(n)}}}`;
|
|
186
199
|
}
|
|
187
200
|
_parseCondition(t) {
|
|
188
201
|
if (!t) return "";
|
|
189
|
-
const
|
|
202
|
+
const s = t, n = t;
|
|
190
203
|
if (n.statements && n.logicalOperator === "and" || n.logicalOperator === "or") {
|
|
191
|
-
const { statements:
|
|
192
|
-
return
|
|
204
|
+
const { statements: a } = n, r = n.logicalOperator, o = n.statements.map((i) => this._parseCondition(i)).join(" ");
|
|
205
|
+
return a.length > 1 ? `(${r} ${o})` : o;
|
|
193
206
|
} else {
|
|
194
|
-
const
|
|
195
|
-
return this.getExpressionStr(
|
|
207
|
+
const a = s.operator, r = this.getHelperId(a), o = this._parseValue(s.left), i = this._parseValue(s.right);
|
|
208
|
+
return this.getExpressionStr(r, o, i);
|
|
196
209
|
}
|
|
197
210
|
}
|
|
198
|
-
getExpressionStr(t,
|
|
199
|
-
return
|
|
211
|
+
getExpressionStr(t, s, n) {
|
|
212
|
+
return v[t] ? t === "isTruthy" ? s : t === "isFalsy" ? `!${s}` : `${t} ${s}` : `(${t} ${s} ${n})`;
|
|
200
213
|
}
|
|
201
214
|
_parseValue(t) {
|
|
202
215
|
return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
|
|
@@ -211,24 +224,24 @@ class G {
|
|
|
211
224
|
return "{{/if}}";
|
|
212
225
|
}
|
|
213
226
|
}
|
|
214
|
-
class
|
|
227
|
+
class C {
|
|
215
228
|
constructor() {
|
|
216
229
|
this.messages = [], this.collectionStack = [];
|
|
217
230
|
}
|
|
218
231
|
import(t) {
|
|
219
232
|
this.messages = [], this.collectionStack = [];
|
|
220
|
-
const
|
|
221
|
-
return this.astToGrapesJS(
|
|
233
|
+
const s = this.parse(t);
|
|
234
|
+
return this.astToGrapesJS(s);
|
|
222
235
|
}
|
|
223
236
|
parse(t) {
|
|
224
237
|
try {
|
|
225
|
-
return
|
|
226
|
-
} catch (
|
|
227
|
-
if (
|
|
228
|
-
const n =
|
|
229
|
-
throw new Error(`Handlebars syntax error at line ${
|
|
238
|
+
return T.parse(t);
|
|
239
|
+
} catch (s) {
|
|
240
|
+
if (s instanceof Error && s.message.includes("Parse error")) {
|
|
241
|
+
const n = s.message.match(/line (\d+)/), a = n ? parseInt(n[1]) : 0, r = s.message.match(/column (\d+)/), o = r ? parseInt(r[1]) : 0;
|
|
242
|
+
throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`);
|
|
230
243
|
}
|
|
231
|
-
throw
|
|
244
|
+
throw s;
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
247
|
astToGrapesJS(t) {
|
|
@@ -254,109 +267,109 @@ class q {
|
|
|
254
267
|
}
|
|
255
268
|
}
|
|
256
269
|
handleProgram(t) {
|
|
257
|
-
let
|
|
270
|
+
let s = "";
|
|
258
271
|
if (t.body)
|
|
259
272
|
for (const n of t.body)
|
|
260
|
-
|
|
261
|
-
return
|
|
273
|
+
s += this.astToGrapesJS(n);
|
|
274
|
+
return s;
|
|
262
275
|
}
|
|
263
276
|
handleContentStatement(t) {
|
|
264
277
|
return t.value || "";
|
|
265
278
|
}
|
|
266
|
-
handleMustacheStatement(t,
|
|
267
|
-
const n = this.getExpressionString(t.path),
|
|
268
|
-
return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n,
|
|
279
|
+
handleMustacheStatement(t, s = {}) {
|
|
280
|
+
const n = this.getExpressionString(t.path), a = { ...s };
|
|
281
|
+
return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, a) : a.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`;
|
|
269
282
|
}
|
|
270
|
-
processPathWithCollectionContext(t,
|
|
271
|
-
t.startsWith("@") ? this.handleDirectCollectionReference(t,
|
|
283
|
+
processPathWithCollectionContext(t, s) {
|
|
284
|
+
t.startsWith("@") ? this.handleDirectCollectionReference(t, s) : this.handleRelativePathReference(t, s);
|
|
272
285
|
}
|
|
273
|
-
handleDirectCollectionReference(t,
|
|
286
|
+
handleDirectCollectionReference(t, s) {
|
|
274
287
|
if (this.isSpecialIterationVariable(t)) {
|
|
275
|
-
this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t,
|
|
288
|
+
this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, s);
|
|
276
289
|
return;
|
|
277
290
|
}
|
|
278
|
-
const [n, ...
|
|
279
|
-
this.collectionStack.includes(n) ? this.setCurrentItemResolver(n,
|
|
291
|
+
const [n, ...a] = t.substring(1).split("/"), r = a.join(".");
|
|
292
|
+
this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, r, s) : this.handleParentReferenceFallback(t, s);
|
|
280
293
|
}
|
|
281
294
|
isSpecialIterationVariable(t) {
|
|
282
295
|
return ["index", "@index", "key", "@key"].includes(t);
|
|
283
296
|
}
|
|
284
|
-
setSpecialVariableResolver(t,
|
|
297
|
+
setSpecialVariableResolver(t, s, n) {
|
|
285
298
|
n.collectionId = t;
|
|
286
|
-
const
|
|
299
|
+
const a = {
|
|
287
300
|
index: "currentIndex",
|
|
288
301
|
"@index": "currentIndex",
|
|
289
302
|
key: "currentKey",
|
|
290
303
|
"@key": "currentKey"
|
|
291
304
|
};
|
|
292
|
-
n.variableType = s
|
|
305
|
+
n.variableType = a[s];
|
|
293
306
|
}
|
|
294
|
-
setCurrentItemResolver(t,
|
|
295
|
-
n.collectionId = t, n.variableType = "currentItem",
|
|
307
|
+
setCurrentItemResolver(t, s, n) {
|
|
308
|
+
n.collectionId = t, n.variableType = "currentItem", s && (n.path = s);
|
|
296
309
|
}
|
|
297
|
-
handleRelativePathReference(t,
|
|
298
|
-
const n =
|
|
299
|
-
|
|
310
|
+
handleRelativePathReference(t, s) {
|
|
311
|
+
const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
|
|
312
|
+
i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
|
|
300
313
|
}
|
|
301
314
|
calculateParentLevel(t) {
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
304
|
-
return { parentLevel: this.collectionStack.length - 1 -
|
|
315
|
+
const s = this.collectionStack.findLastIndex((r) => r === t[0]);
|
|
316
|
+
if (s !== -1)
|
|
317
|
+
return { parentLevel: this.collectionStack.length - 1 - s, remainingPathParts: t.slice(1) };
|
|
305
318
|
let n = 0;
|
|
306
|
-
const
|
|
307
|
-
for (;
|
|
308
|
-
n++,
|
|
309
|
-
return { parentLevel: n, remainingPathParts:
|
|
319
|
+
const a = [...t];
|
|
320
|
+
for (; a[0] === ".."; )
|
|
321
|
+
n++, a.shift();
|
|
322
|
+
return { parentLevel: n, remainingPathParts: a };
|
|
310
323
|
}
|
|
311
|
-
resolveRelativePath(t,
|
|
312
|
-
const
|
|
313
|
-
n.collectionId =
|
|
324
|
+
resolveRelativePath(t, s, n) {
|
|
325
|
+
const a = this.collectionStack[s];
|
|
326
|
+
n.collectionId = a, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
|
|
314
327
|
}
|
|
315
|
-
handleParentReferenceFallback(t,
|
|
316
|
-
const n =
|
|
317
|
-
|
|
328
|
+
handleParentReferenceFallback(t, s) {
|
|
329
|
+
const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
|
|
330
|
+
i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
|
|
318
331
|
}
|
|
319
332
|
handleBlockStatement(t) {
|
|
320
|
-
const
|
|
321
|
-
switch (
|
|
333
|
+
const s = t.path.original;
|
|
334
|
+
switch (s) {
|
|
322
335
|
case "if":
|
|
323
336
|
case "unless":
|
|
324
|
-
return this.handleConditionalBlock(t,
|
|
337
|
+
return this.handleConditionalBlock(t, s);
|
|
325
338
|
case "each":
|
|
326
339
|
return this.handleEachBlock(t);
|
|
327
340
|
default:
|
|
328
|
-
return this.addMessage("warning", `Unsupported block helper: ${
|
|
341
|
+
return this.addMessage("warning", `Unsupported block helper: ${s}`, t.loc), this.handleGenericBlock(t);
|
|
329
342
|
}
|
|
330
343
|
}
|
|
331
|
-
handleConditionalBlock(t,
|
|
332
|
-
const
|
|
344
|
+
handleConditionalBlock(t, s) {
|
|
345
|
+
const r = {
|
|
333
346
|
logicalOperator: "and",
|
|
334
347
|
statements: [
|
|
335
348
|
{
|
|
336
349
|
left: { type: "data-variable", path: this.getExpressionString(t.params[0]) },
|
|
337
|
-
operator:
|
|
350
|
+
operator: s === "unless" ? "isFalsy" : "isTruthy"
|
|
338
351
|
}
|
|
339
352
|
]
|
|
340
|
-
},
|
|
353
|
+
}, o = this.handleProgram(t.program), i = t.inverse ? this.handleProgram(t.inverse) : "";
|
|
341
354
|
return `
|
|
342
|
-
<data-condition data-gjs-data-resolver='${JSON.stringify({ condition:
|
|
343
|
-
<data-condition-true-content>${
|
|
344
|
-
<data-condition-false-content>${
|
|
355
|
+
<data-condition data-gjs-data-resolver='${JSON.stringify({ condition: r })}'>
|
|
356
|
+
<data-condition-true-content>${o}</data-condition-true-content>
|
|
357
|
+
<data-condition-false-content>${i}</data-condition-false-content>
|
|
345
358
|
</data-condition>
|
|
346
359
|
`;
|
|
347
360
|
}
|
|
348
361
|
handleEachBlock(t) {
|
|
349
|
-
var
|
|
350
|
-
const
|
|
362
|
+
var r, o, i;
|
|
363
|
+
const s = this.getExpressionString(t.params[0]);
|
|
351
364
|
let n;
|
|
352
|
-
t.params.length >= 3 && t.params[1] === "as" && ((
|
|
353
|
-
const
|
|
365
|
+
t.params.length >= 3 && t.params[1] === "as" && ((r = t.params[2]) == null ? void 0 : r.type) === "PathExpression" ? n = t.params[2].original : (i = (o = t.program) == null ? void 0 : o.blockParams) != null && i.length ? n = t.program.blockParams[0] : n = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(n);
|
|
366
|
+
const a = this.handleProgram(t.program);
|
|
354
367
|
return this.collectionStack.pop(), `
|
|
355
368
|
<data-collection data-gjs-data-resolver='${JSON.stringify({
|
|
356
|
-
dataSource: { type: "data-variable", path:
|
|
369
|
+
dataSource: { type: "data-variable", path: s },
|
|
357
370
|
collectionId: n
|
|
358
371
|
})}'>
|
|
359
|
-
<data-collection-item>${
|
|
372
|
+
<data-collection-item>${a}</data-collection-item>
|
|
360
373
|
</data-collection>
|
|
361
374
|
`;
|
|
362
375
|
}
|
|
@@ -364,15 +377,15 @@ class q {
|
|
|
364
377
|
return `<!--${t.value}-->`;
|
|
365
378
|
}
|
|
366
379
|
handleElementNode(t) {
|
|
367
|
-
let
|
|
380
|
+
let s = "";
|
|
368
381
|
if (t.attributes)
|
|
369
|
-
for (const
|
|
370
|
-
|
|
382
|
+
for (const a of t.attributes)
|
|
383
|
+
a.value.type === "TextNode" ? s += ` ${a.name}="${a.value.chars}"` : (this.addMessage("warning", `Complex attribute values not fully supported: ${a.name}`, t.loc), s += ` ${a.name}="${this.getExpressionString(a.value)}"`);
|
|
371
384
|
let n = "";
|
|
372
385
|
if (t.children)
|
|
373
|
-
for (const
|
|
374
|
-
n += this.astToGrapesJS(
|
|
375
|
-
return `<${t.tag}${
|
|
386
|
+
for (const a of t.children)
|
|
387
|
+
n += this.astToGrapesJS(a);
|
|
388
|
+
return `<${t.tag}${s}>${n}</${t.tag}>`;
|
|
376
389
|
}
|
|
377
390
|
handleTextNode(t) {
|
|
378
391
|
return t.chars || "";
|
|
@@ -381,64 +394,64 @@ class q {
|
|
|
381
394
|
return this.addMessage("warning", `Partials are not fully supported: ${t.name.original}`, t.loc), `{{> ${t.name.original}}}`;
|
|
382
395
|
}
|
|
383
396
|
handleGenericBlock(t) {
|
|
384
|
-
const
|
|
385
|
-
return `<!-- Unsupported block: ${t.path.original} -->${
|
|
397
|
+
const s = this.handleProgram(t.program);
|
|
398
|
+
return `<!-- Unsupported block: ${t.path.original} -->${s}`;
|
|
386
399
|
}
|
|
387
400
|
getExpressionString(t) {
|
|
388
401
|
return t.type === "PathExpression" ? t.original : t.type === "StringLiteral" ? t.value : t.type === "NumberLiteral" ? t.value.toString() : t.type === "BooleanLiteral" ? t.value ? "true" : "false" : t.type === "SubExpression" ? this.getExpressionString(t.params[0]) : t.type === "Hash" ? `{${t.pairs.map((n) => `${n.key}=${this.getExpressionString(n.value)}`).join(", ")}}` : (this.addMessage("warning", `Complex expression type not fully supported: ${t.type}`, t.loc), "");
|
|
389
402
|
}
|
|
390
|
-
addMessage(t,
|
|
403
|
+
addMessage(t, s, n) {
|
|
391
404
|
this.messages.push({
|
|
392
405
|
type: t,
|
|
393
|
-
message:
|
|
406
|
+
message: s,
|
|
394
407
|
location: n ? { line: n.start.line, column: n.start.column } : void 0
|
|
395
408
|
});
|
|
396
409
|
}
|
|
397
410
|
}
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
411
|
+
const f = (e) => {
|
|
412
|
+
if (e == null || e === "")
|
|
400
413
|
return [];
|
|
401
|
-
if (
|
|
414
|
+
if (e === ".")
|
|
402
415
|
return ["this"];
|
|
403
|
-
if (
|
|
416
|
+
if (e === ".." || e === "../")
|
|
404
417
|
return [".."];
|
|
405
|
-
if (
|
|
406
|
-
const
|
|
407
|
-
return ["..", ...
|
|
418
|
+
if (e.startsWith("../")) {
|
|
419
|
+
const o = e.substring(3);
|
|
420
|
+
return ["..", ...f(o)];
|
|
408
421
|
}
|
|
409
422
|
const t = [];
|
|
410
|
-
let
|
|
423
|
+
let s = 0, n = e.replace(
|
|
411
424
|
/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,
|
|
412
|
-
(
|
|
413
|
-
const h =
|
|
414
|
-
return t[
|
|
425
|
+
(o, i, c, u) => {
|
|
426
|
+
const h = c !== void 0 ? c : u || "";
|
|
427
|
+
return t[s] = h, `__HANDLEBARS_PLACEHOLDER_${s++}__`;
|
|
415
428
|
}
|
|
416
429
|
);
|
|
417
430
|
n = n.replace(/\//g, ".");
|
|
418
|
-
const
|
|
419
|
-
for (const
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
} else
|
|
425
|
-
}
|
|
426
|
-
return
|
|
427
|
-
},
|
|
428
|
-
const
|
|
431
|
+
const a = n.split("."), r = [];
|
|
432
|
+
for (const o of a) {
|
|
433
|
+
const i = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);
|
|
434
|
+
if (i) {
|
|
435
|
+
const c = parseInt(i[1], 10);
|
|
436
|
+
r.push(t[c]);
|
|
437
|
+
} else o !== "" && r.push(o);
|
|
438
|
+
}
|
|
439
|
+
return r;
|
|
440
|
+
}, q = "dataSourceHandlebars", J = p.startup, z = function(e, t = {}) {
|
|
441
|
+
const s = j(e, new F()), n = U(e, {
|
|
429
442
|
contains: "{{",
|
|
430
|
-
importer: new
|
|
443
|
+
importer: new C()
|
|
431
444
|
});
|
|
432
|
-
|
|
433
|
-
editor:
|
|
445
|
+
G({
|
|
446
|
+
editor: e,
|
|
434
447
|
licenseKey: t.licenseKey,
|
|
435
|
-
plan:
|
|
436
|
-
pluginName:
|
|
448
|
+
plan: J,
|
|
449
|
+
pluginName: q,
|
|
437
450
|
cleanup: () => {
|
|
438
|
-
|
|
451
|
+
s(), n();
|
|
439
452
|
}
|
|
440
453
|
});
|
|
441
|
-
},
|
|
454
|
+
}, Z = D(z);
|
|
442
455
|
export {
|
|
443
|
-
|
|
456
|
+
Z as default
|
|
444
457
|
};
|