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