@yext/visual-editor 0.0.39 → 0.0.40
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/index.d.cts +192 -61
- package/dist/index.d.ts +192 -61
- package/dist/plugin/debugger-BTQVKCwx-Bea6QVwG.js +293 -0
- package/dist/plugin/debugger-BTQVKCwx-C6TadVhk.cjs +1 -0
- package/dist/plugin/index-BBlk-mUB.cjs +1349 -0
- package/dist/plugin/index-C2zkTc1a.js +99992 -0
- package/dist/plugin/plugin.cjs +1 -296
- package/dist/plugin/plugin.js +2 -339
- package/dist/style.css +1 -1
- package/dist/visual-editor.cjs +164 -87
- package/dist/visual-editor.js +37758 -20021
- package/package.json +9 -2
package/dist/plugin/plugin.cjs
CHANGED
|
@@ -1,296 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
import "@yext/visual-editor/style.css";
|
|
3
|
-
import {
|
|
4
|
-
Template,
|
|
5
|
-
GetPath,
|
|
6
|
-
TemplateProps,
|
|
7
|
-
TemplateRenderProps,
|
|
8
|
-
GetHeadConfig,
|
|
9
|
-
HeadConfig,
|
|
10
|
-
TagType,
|
|
11
|
-
} from "@yext/pages";
|
|
12
|
-
import { Render } from "@measured/puck";
|
|
13
|
-
import { mainConfig } from "../ve.config";
|
|
14
|
-
import {
|
|
15
|
-
applyTheme,
|
|
16
|
-
VisualEditorProvider,
|
|
17
|
-
normalizeSlug,
|
|
18
|
-
getPageMetadata,
|
|
19
|
-
applyAnalytics,
|
|
20
|
-
applyHeaderScript,
|
|
21
|
-
} from "@yext/visual-editor";
|
|
22
|
-
import { themeConfig } from "../../theme.config";
|
|
23
|
-
import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
|
|
24
|
-
|
|
25
|
-
export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
|
|
26
|
-
document,
|
|
27
|
-
}): HeadConfig => {
|
|
28
|
-
const { title, description } = getPageMetadata(document);
|
|
29
|
-
const faviconUrl = document?._site?.favicon?.url;
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
title: title,
|
|
33
|
-
charset: "UTF-8",
|
|
34
|
-
viewport: "width=device-width, initial-scale=1",
|
|
35
|
-
tags: [
|
|
36
|
-
{
|
|
37
|
-
type: "link",
|
|
38
|
-
attributes: {
|
|
39
|
-
rel: "icon",
|
|
40
|
-
type: "image/x-icon",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
...(description
|
|
44
|
-
? [
|
|
45
|
-
{
|
|
46
|
-
type: "meta" as TagType,
|
|
47
|
-
attributes: {
|
|
48
|
-
name: "description",
|
|
49
|
-
content: description,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
: []),
|
|
54
|
-
...(faviconUrl
|
|
55
|
-
? [
|
|
56
|
-
{
|
|
57
|
-
type: "link" as TagType,
|
|
58
|
-
attributes: {
|
|
59
|
-
rel: "icon",
|
|
60
|
-
type: "image/x-icon",
|
|
61
|
-
href: faviconUrl,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
]
|
|
65
|
-
: []),
|
|
66
|
-
],
|
|
67
|
-
other: [
|
|
68
|
-
applyAnalytics(document),
|
|
69
|
-
applyHeaderScript(document),
|
|
70
|
-
applyTheme(document, themeConfig),
|
|
71
|
-
SchemaWrapper(document._schema),
|
|
72
|
-
].join("\\n"),
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const getPath: GetPath<TemplateProps> = ({ document }) => {
|
|
77
|
-
if (document.slug) {
|
|
78
|
-
return document.slug;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
|
|
82
|
-
const path = document.address
|
|
83
|
-
? \`\${localePath}\${document.address.region}/\${document.address.city}/\${document.address.line1}\`
|
|
84
|
-
: \`\${localePath}\${document.id}\`;
|
|
85
|
-
|
|
86
|
-
return normalizeSlug(path);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const Location: Template<TemplateRenderProps> = (props) => {
|
|
90
|
-
const { document } = props;
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<AnalyticsProvider
|
|
94
|
-
apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
|
|
95
|
-
templateData={props}
|
|
96
|
-
currency="USD"
|
|
97
|
-
>
|
|
98
|
-
<VisualEditorProvider templateProps={props}>
|
|
99
|
-
<Render config={mainConfig} data={JSON.parse(document.__.layout)} />
|
|
100
|
-
</VisualEditorProvider>
|
|
101
|
-
</AnalyticsProvider>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default Location;
|
|
106
|
-
`,p=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
|
|
107
|
-
import {
|
|
108
|
-
applyTheme,
|
|
109
|
-
Editor,
|
|
110
|
-
usePlatformBridgeDocument,
|
|
111
|
-
usePlatformBridgeEntityFields,
|
|
112
|
-
VisualEditorProvider,
|
|
113
|
-
} from "@yext/visual-editor";
|
|
114
|
-
import { componentRegistry } from "../ve.config";
|
|
115
|
-
import {
|
|
116
|
-
GetPath,
|
|
117
|
-
TemplateProps,
|
|
118
|
-
TemplateConfig,
|
|
119
|
-
HeadConfig,
|
|
120
|
-
TemplateRenderProps,
|
|
121
|
-
GetHeadConfig,
|
|
122
|
-
} from "@yext/pages";
|
|
123
|
-
import { themeConfig } from "../../theme.config";
|
|
124
|
-
import tailwindConfig from "../../tailwind.config";
|
|
125
|
-
|
|
126
|
-
// Editor is avaliable at /edit
|
|
127
|
-
export const getPath: GetPath<TemplateProps> = () => {
|
|
128
|
-
return "edit";
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const config: TemplateConfig = {
|
|
132
|
-
name: "edit",
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
|
|
136
|
-
document,
|
|
137
|
-
}): HeadConfig => {
|
|
138
|
-
return {
|
|
139
|
-
other: fullStorySnippet + applyTheme(document, themeConfig),
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// Render the editor
|
|
144
|
-
const Edit: () => JSX.Element = () => {
|
|
145
|
-
const entityDocument = usePlatformBridgeDocument();
|
|
146
|
-
const entityFields = usePlatformBridgeEntityFields();
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
<VisualEditorProvider
|
|
150
|
-
templateProps={{
|
|
151
|
-
document: entityDocument,
|
|
152
|
-
}}
|
|
153
|
-
entityFields={entityFields}
|
|
154
|
-
tailwindConfig={tailwindConfig}
|
|
155
|
-
>
|
|
156
|
-
<Editor
|
|
157
|
-
document={entityDocument}
|
|
158
|
-
componentRegistry={componentRegistry}
|
|
159
|
-
themeConfig={themeConfig}
|
|
160
|
-
/>
|
|
161
|
-
</VisualEditorProvider>
|
|
162
|
-
);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export default Edit;
|
|
166
|
-
|
|
167
|
-
const fullStorySnippet = \`<script>
|
|
168
|
-
window['_fs_run_in_iframe'] = true;
|
|
169
|
-
window['_fs_debug'] = false;
|
|
170
|
-
window['_fs_host'] = 'fullstory.com';
|
|
171
|
-
window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
|
|
172
|
-
window['_fs_org'] = 'o-1RWKDJ-na1';
|
|
173
|
-
window['_fs_namespace'] = 'FS';
|
|
174
|
-
!function(m,n,e,t,l,o,g,y){var s,f,a=function(h){
|
|
175
|
-
return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),!1)}(e)
|
|
176
|
-
;function j(b){var h,d=[];function k(){h&&(d.forEach((function(b){var d;try{d=b[h[0]]&&b[h[0]](h[1])}catch(h){return void(b[3]&&b[3](h))}
|
|
177
|
-
d&&d.then?d.then(b[2],b[3]):b[2]&&b[2](d)})),d.length=0)}function r(b){return function(d){h||(h=[b,d],k())}}return b(r(0),r(1)),{
|
|
178
|
-
then:function(b,h){return j((function(r,i){d.push([b,h,r,i]),k()}))}}}a&&(g=m[e]=function(){var b=function(b,d,k,r){function i(i,c){
|
|
179
|
-
h(b,d,k,i,c,r)}r=r||2;var c,u=/Async$/;return u.test(b)?(b=b.replace(u,""),"function"==typeof Promise?new Promise(i):j(i)):h(b,d,k,c,c,r)}
|
|
180
|
-
;function h(h,d,k,r,i,c){return b._api?b._api(h,d,k,r,i,c):(b.q&&b.q.push([h,d,k,r,i,c]),null)}return b.q=[],b}(),y=function(b){function h(h){
|
|
181
|
-
"function"==typeof h[4]&&h[4](new Error(b))}var d=g.q;if(d){for(var k=0;k<d.length;k++)h(d[k]);d.length=0,d.push=h}},function(){
|
|
182
|
-
(o=n.createElement(t)).async=!0,o.crossOrigin="anonymous",o.src="https://"+l,o.onerror=function(){y("Error loading "+l)}
|
|
183
|
-
;var b=n.getElementsByTagName(t)[0];b.parentNode.insertBefore(o,b)}(),function(){function b(){}function h(b,h,d){g(b,h,d,1)}function d(b,d,k){
|
|
184
|
-
h("setProperties",{type:b,properties:d},k)}function k(b,h){d("user",b,h)}function r(b,h,d){k({uid:b},d),h&&k(h,d)}g.identify=r,g.setUserVars=k,
|
|
185
|
-
g.identifyAccount=b,g.clearUserCookie=b,g.setVars=d,g.event=function(b,d,k){h("trackEvent",{name:b,properties:d},k)},g.anonymize=function(){r(!1)
|
|
186
|
-
},g.shutdown=function(){h("shutdown")},g.restart=function(){h("restart")},g.log=function(b,d){h("log",{level:b,msg:d})},g.consent=function(b){
|
|
187
|
-
h("setIdentity",{consent:!arguments.length||b})}}(),s="fetch",f="XMLHttpRequest",g._w={},g._w[f]=m[f],g._w[s]=m[s],m[s]&&(m[s]=function(){
|
|
188
|
-
return g._w[s].apply(this,arguments)}),g._v="2.0.0")}(window,document,window._fs_namespace,"script",window._fs_script);
|
|
189
|
-
<\/script>\`;
|
|
190
|
-
`,l=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
|
|
191
|
-
import "@yext/visual-editor/style.css";
|
|
192
|
-
import {
|
|
193
|
-
Template,
|
|
194
|
-
GetPath,
|
|
195
|
-
TemplateProps,
|
|
196
|
-
TemplateRenderProps,
|
|
197
|
-
GetHeadConfig,
|
|
198
|
-
HeadConfig,
|
|
199
|
-
TagType,
|
|
200
|
-
} from "@yext/pages";
|
|
201
|
-
import { Render } from "@measured/puck";
|
|
202
|
-
import { directoryConfig } from "../ve.config";
|
|
203
|
-
import {
|
|
204
|
-
applyTheme,
|
|
205
|
-
VisualEditorProvider,
|
|
206
|
-
normalizeSlug,
|
|
207
|
-
getPageMetadata,
|
|
208
|
-
applyAnalytics,
|
|
209
|
-
applyHeaderScript,
|
|
210
|
-
} from "@yext/visual-editor";
|
|
211
|
-
import { themeConfig } from "../../theme.config";
|
|
212
|
-
import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
|
|
213
|
-
|
|
214
|
-
export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
|
|
215
|
-
document,
|
|
216
|
-
}): HeadConfig => {
|
|
217
|
-
const { title, description } = getPageMetadata(document);
|
|
218
|
-
const faviconUrl = document?._site?.favicon?.url;
|
|
219
|
-
|
|
220
|
-
return {
|
|
221
|
-
title: title,
|
|
222
|
-
charset: "UTF-8",
|
|
223
|
-
viewport: "width=device-width, initial-scale=1",
|
|
224
|
-
tags: [
|
|
225
|
-
{
|
|
226
|
-
type: "link",
|
|
227
|
-
attributes: {
|
|
228
|
-
rel: "icon",
|
|
229
|
-
type: "image/x-icon",
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
...(description
|
|
233
|
-
? [
|
|
234
|
-
{
|
|
235
|
-
type: "meta" as TagType,
|
|
236
|
-
attributes: {
|
|
237
|
-
name: "description",
|
|
238
|
-
content: description,
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
]
|
|
242
|
-
: []),
|
|
243
|
-
...(faviconUrl
|
|
244
|
-
? [
|
|
245
|
-
{
|
|
246
|
-
type: "link" as TagType,
|
|
247
|
-
attributes: {
|
|
248
|
-
rel: "icon",
|
|
249
|
-
type: "image/x-icon",
|
|
250
|
-
href: faviconUrl,
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
]
|
|
254
|
-
: []),
|
|
255
|
-
],
|
|
256
|
-
other: [
|
|
257
|
-
applyAnalytics(document),
|
|
258
|
-
applyHeaderScript(document),
|
|
259
|
-
applyTheme(document, themeConfig),
|
|
260
|
-
SchemaWrapper(document._schema),
|
|
261
|
-
].join("\\n"),
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
export const getPath: GetPath<TemplateProps> = ({ document }) => {
|
|
266
|
-
if (document.slug) {
|
|
267
|
-
return document.slug;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
|
|
271
|
-
const path = \`\${localePath}\${document.id}\`;
|
|
272
|
-
|
|
273
|
-
return normalizeSlug(path);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const Directory: Template<TemplateRenderProps> = (props) => {
|
|
277
|
-
const { document } = props;
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<AnalyticsProvider
|
|
281
|
-
apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
|
|
282
|
-
templateData={props}
|
|
283
|
-
currency="USD"
|
|
284
|
-
>
|
|
285
|
-
<VisualEditorProvider templateProps={props}>
|
|
286
|
-
<Render
|
|
287
|
-
config={directoryConfig}
|
|
288
|
-
data={JSON.parse(document.__.layout)}
|
|
289
|
-
/>
|
|
290
|
-
</VisualEditorProvider>
|
|
291
|
-
</AnalyticsProvider>
|
|
292
|
-
);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
export default Directory;
|
|
296
|
-
`,m={"src/templates/main.tsx":d,"src/templates/edit.tsx":p,"src/templates/directory.tsx":l},u=()=>{let e=!1;const a=[],c=()=>{Object.entries(m).forEach(([n,i])=>{const o=s.join(process.cwd(),n);a.push(o),r.mkdirSync(s.dirname(o),{recursive:!0}),!r.existsSync(o)&&r.writeFileSync(o,i)})},t=()=>{a.forEach(n=>{r.rmSync(n,{force:!0})})};return process.on("SIGINT",()=>{t(),process.nextTick(()=>process.exit(0))}),process.on("SIGTERM",()=>{t(),process.nextTick(()=>process.exit(0))}),{name:"vite-plugin-yext-visual-editor",config(n,{command:i}){e=i==="build"},configureServer(n){e||(c(),n.httpServer?.on("close",()=>{t()}))},buildStart(){e&&c()},buildEnd(){e&&t()},closeBundle(){e&&t()}}};exports.yextVisualEditorPlugin=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BBlk-mUB.cjs");exports.yextVisualEditorPlugin=e.yextVisualEditorPlugin;
|
package/dist/plugin/plugin.js
CHANGED
|
@@ -1,341 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import r from "fs-extra";
|
|
3
|
-
const d = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
|
|
4
|
-
import "@yext/visual-editor/style.css";
|
|
5
|
-
import {
|
|
6
|
-
Template,
|
|
7
|
-
GetPath,
|
|
8
|
-
TemplateProps,
|
|
9
|
-
TemplateRenderProps,
|
|
10
|
-
GetHeadConfig,
|
|
11
|
-
HeadConfig,
|
|
12
|
-
TagType,
|
|
13
|
-
} from "@yext/pages";
|
|
14
|
-
import { Render } from "@measured/puck";
|
|
15
|
-
import { mainConfig } from "../ve.config";
|
|
16
|
-
import {
|
|
17
|
-
applyTheme,
|
|
18
|
-
VisualEditorProvider,
|
|
19
|
-
normalizeSlug,
|
|
20
|
-
getPageMetadata,
|
|
21
|
-
applyAnalytics,
|
|
22
|
-
applyHeaderScript,
|
|
23
|
-
} from "@yext/visual-editor";
|
|
24
|
-
import { themeConfig } from "../../theme.config";
|
|
25
|
-
import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
|
|
26
|
-
|
|
27
|
-
export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
|
|
28
|
-
document,
|
|
29
|
-
}): HeadConfig => {
|
|
30
|
-
const { title, description } = getPageMetadata(document);
|
|
31
|
-
const faviconUrl = document?._site?.favicon?.url;
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
title: title,
|
|
35
|
-
charset: "UTF-8",
|
|
36
|
-
viewport: "width=device-width, initial-scale=1",
|
|
37
|
-
tags: [
|
|
38
|
-
{
|
|
39
|
-
type: "link",
|
|
40
|
-
attributes: {
|
|
41
|
-
rel: "icon",
|
|
42
|
-
type: "image/x-icon",
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
...(description
|
|
46
|
-
? [
|
|
47
|
-
{
|
|
48
|
-
type: "meta" as TagType,
|
|
49
|
-
attributes: {
|
|
50
|
-
name: "description",
|
|
51
|
-
content: description,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
]
|
|
55
|
-
: []),
|
|
56
|
-
...(faviconUrl
|
|
57
|
-
? [
|
|
58
|
-
{
|
|
59
|
-
type: "link" as TagType,
|
|
60
|
-
attributes: {
|
|
61
|
-
rel: "icon",
|
|
62
|
-
type: "image/x-icon",
|
|
63
|
-
href: faviconUrl,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
]
|
|
67
|
-
: []),
|
|
68
|
-
],
|
|
69
|
-
other: [
|
|
70
|
-
applyAnalytics(document),
|
|
71
|
-
applyHeaderScript(document),
|
|
72
|
-
applyTheme(document, themeConfig),
|
|
73
|
-
SchemaWrapper(document._schema),
|
|
74
|
-
].join("\\n"),
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const getPath: GetPath<TemplateProps> = ({ document }) => {
|
|
79
|
-
if (document.slug) {
|
|
80
|
-
return document.slug;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
|
|
84
|
-
const path = document.address
|
|
85
|
-
? \`\${localePath}\${document.address.region}/\${document.address.city}/\${document.address.line1}\`
|
|
86
|
-
: \`\${localePath}\${document.id}\`;
|
|
87
|
-
|
|
88
|
-
return normalizeSlug(path);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const Location: Template<TemplateRenderProps> = (props) => {
|
|
92
|
-
const { document } = props;
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<AnalyticsProvider
|
|
96
|
-
apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
|
|
97
|
-
templateData={props}
|
|
98
|
-
currency="USD"
|
|
99
|
-
>
|
|
100
|
-
<VisualEditorProvider templateProps={props}>
|
|
101
|
-
<Render config={mainConfig} data={JSON.parse(document.__.layout)} />
|
|
102
|
-
</VisualEditorProvider>
|
|
103
|
-
</AnalyticsProvider>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export default Location;
|
|
108
|
-
`, p = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
|
|
109
|
-
import {
|
|
110
|
-
applyTheme,
|
|
111
|
-
Editor,
|
|
112
|
-
usePlatformBridgeDocument,
|
|
113
|
-
usePlatformBridgeEntityFields,
|
|
114
|
-
VisualEditorProvider,
|
|
115
|
-
} from "@yext/visual-editor";
|
|
116
|
-
import { componentRegistry } from "../ve.config";
|
|
117
|
-
import {
|
|
118
|
-
GetPath,
|
|
119
|
-
TemplateProps,
|
|
120
|
-
TemplateConfig,
|
|
121
|
-
HeadConfig,
|
|
122
|
-
TemplateRenderProps,
|
|
123
|
-
GetHeadConfig,
|
|
124
|
-
} from "@yext/pages";
|
|
125
|
-
import { themeConfig } from "../../theme.config";
|
|
126
|
-
import tailwindConfig from "../../tailwind.config";
|
|
127
|
-
|
|
128
|
-
// Editor is avaliable at /edit
|
|
129
|
-
export const getPath: GetPath<TemplateProps> = () => {
|
|
130
|
-
return "edit";
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const config: TemplateConfig = {
|
|
134
|
-
name: "edit",
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
|
|
138
|
-
document,
|
|
139
|
-
}): HeadConfig => {
|
|
140
|
-
return {
|
|
141
|
-
other: fullStorySnippet + applyTheme(document, themeConfig),
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// Render the editor
|
|
146
|
-
const Edit: () => JSX.Element = () => {
|
|
147
|
-
const entityDocument = usePlatformBridgeDocument();
|
|
148
|
-
const entityFields = usePlatformBridgeEntityFields();
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<VisualEditorProvider
|
|
152
|
-
templateProps={{
|
|
153
|
-
document: entityDocument,
|
|
154
|
-
}}
|
|
155
|
-
entityFields={entityFields}
|
|
156
|
-
tailwindConfig={tailwindConfig}
|
|
157
|
-
>
|
|
158
|
-
<Editor
|
|
159
|
-
document={entityDocument}
|
|
160
|
-
componentRegistry={componentRegistry}
|
|
161
|
-
themeConfig={themeConfig}
|
|
162
|
-
/>
|
|
163
|
-
</VisualEditorProvider>
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export default Edit;
|
|
168
|
-
|
|
169
|
-
const fullStorySnippet = \`<script>
|
|
170
|
-
window['_fs_run_in_iframe'] = true;
|
|
171
|
-
window['_fs_debug'] = false;
|
|
172
|
-
window['_fs_host'] = 'fullstory.com';
|
|
173
|
-
window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
|
|
174
|
-
window['_fs_org'] = 'o-1RWKDJ-na1';
|
|
175
|
-
window['_fs_namespace'] = 'FS';
|
|
176
|
-
!function(m,n,e,t,l,o,g,y){var s,f,a=function(h){
|
|
177
|
-
return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),!1)}(e)
|
|
178
|
-
;function j(b){var h,d=[];function k(){h&&(d.forEach((function(b){var d;try{d=b[h[0]]&&b[h[0]](h[1])}catch(h){return void(b[3]&&b[3](h))}
|
|
179
|
-
d&&d.then?d.then(b[2],b[3]):b[2]&&b[2](d)})),d.length=0)}function r(b){return function(d){h||(h=[b,d],k())}}return b(r(0),r(1)),{
|
|
180
|
-
then:function(b,h){return j((function(r,i){d.push([b,h,r,i]),k()}))}}}a&&(g=m[e]=function(){var b=function(b,d,k,r){function i(i,c){
|
|
181
|
-
h(b,d,k,i,c,r)}r=r||2;var c,u=/Async$/;return u.test(b)?(b=b.replace(u,""),"function"==typeof Promise?new Promise(i):j(i)):h(b,d,k,c,c,r)}
|
|
182
|
-
;function h(h,d,k,r,i,c){return b._api?b._api(h,d,k,r,i,c):(b.q&&b.q.push([h,d,k,r,i,c]),null)}return b.q=[],b}(),y=function(b){function h(h){
|
|
183
|
-
"function"==typeof h[4]&&h[4](new Error(b))}var d=g.q;if(d){for(var k=0;k<d.length;k++)h(d[k]);d.length=0,d.push=h}},function(){
|
|
184
|
-
(o=n.createElement(t)).async=!0,o.crossOrigin="anonymous",o.src="https://"+l,o.onerror=function(){y("Error loading "+l)}
|
|
185
|
-
;var b=n.getElementsByTagName(t)[0];b.parentNode.insertBefore(o,b)}(),function(){function b(){}function h(b,h,d){g(b,h,d,1)}function d(b,d,k){
|
|
186
|
-
h("setProperties",{type:b,properties:d},k)}function k(b,h){d("user",b,h)}function r(b,h,d){k({uid:b},d),h&&k(h,d)}g.identify=r,g.setUserVars=k,
|
|
187
|
-
g.identifyAccount=b,g.clearUserCookie=b,g.setVars=d,g.event=function(b,d,k){h("trackEvent",{name:b,properties:d},k)},g.anonymize=function(){r(!1)
|
|
188
|
-
},g.shutdown=function(){h("shutdown")},g.restart=function(){h("restart")},g.log=function(b,d){h("log",{level:b,msg:d})},g.consent=function(b){
|
|
189
|
-
h("setIdentity",{consent:!arguments.length||b})}}(),s="fetch",f="XMLHttpRequest",g._w={},g._w[f]=m[f],g._w[s]=m[s],m[s]&&(m[s]=function(){
|
|
190
|
-
return g._w[s].apply(this,arguments)}),g._v="2.0.0")}(window,document,window._fs_namespace,"script",window._fs_script);
|
|
191
|
-
<\/script>\`;
|
|
192
|
-
`, l = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
|
|
193
|
-
import "@yext/visual-editor/style.css";
|
|
194
|
-
import {
|
|
195
|
-
Template,
|
|
196
|
-
GetPath,
|
|
197
|
-
TemplateProps,
|
|
198
|
-
TemplateRenderProps,
|
|
199
|
-
GetHeadConfig,
|
|
200
|
-
HeadConfig,
|
|
201
|
-
TagType,
|
|
202
|
-
} from "@yext/pages";
|
|
203
|
-
import { Render } from "@measured/puck";
|
|
204
|
-
import { directoryConfig } from "../ve.config";
|
|
205
|
-
import {
|
|
206
|
-
applyTheme,
|
|
207
|
-
VisualEditorProvider,
|
|
208
|
-
normalizeSlug,
|
|
209
|
-
getPageMetadata,
|
|
210
|
-
applyAnalytics,
|
|
211
|
-
applyHeaderScript,
|
|
212
|
-
} from "@yext/visual-editor";
|
|
213
|
-
import { themeConfig } from "../../theme.config";
|
|
214
|
-
import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
|
|
215
|
-
|
|
216
|
-
export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
|
|
217
|
-
document,
|
|
218
|
-
}): HeadConfig => {
|
|
219
|
-
const { title, description } = getPageMetadata(document);
|
|
220
|
-
const faviconUrl = document?._site?.favicon?.url;
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
title: title,
|
|
224
|
-
charset: "UTF-8",
|
|
225
|
-
viewport: "width=device-width, initial-scale=1",
|
|
226
|
-
tags: [
|
|
227
|
-
{
|
|
228
|
-
type: "link",
|
|
229
|
-
attributes: {
|
|
230
|
-
rel: "icon",
|
|
231
|
-
type: "image/x-icon",
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
...(description
|
|
235
|
-
? [
|
|
236
|
-
{
|
|
237
|
-
type: "meta" as TagType,
|
|
238
|
-
attributes: {
|
|
239
|
-
name: "description",
|
|
240
|
-
content: description,
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
]
|
|
244
|
-
: []),
|
|
245
|
-
...(faviconUrl
|
|
246
|
-
? [
|
|
247
|
-
{
|
|
248
|
-
type: "link" as TagType,
|
|
249
|
-
attributes: {
|
|
250
|
-
rel: "icon",
|
|
251
|
-
type: "image/x-icon",
|
|
252
|
-
href: faviconUrl,
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
]
|
|
256
|
-
: []),
|
|
257
|
-
],
|
|
258
|
-
other: [
|
|
259
|
-
applyAnalytics(document),
|
|
260
|
-
applyHeaderScript(document),
|
|
261
|
-
applyTheme(document, themeConfig),
|
|
262
|
-
SchemaWrapper(document._schema),
|
|
263
|
-
].join("\\n"),
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
export const getPath: GetPath<TemplateProps> = ({ document }) => {
|
|
268
|
-
if (document.slug) {
|
|
269
|
-
return document.slug;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
|
|
273
|
-
const path = \`\${localePath}\${document.id}\`;
|
|
274
|
-
|
|
275
|
-
return normalizeSlug(path);
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const Directory: Template<TemplateRenderProps> = (props) => {
|
|
279
|
-
const { document } = props;
|
|
280
|
-
|
|
281
|
-
return (
|
|
282
|
-
<AnalyticsProvider
|
|
283
|
-
apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
|
|
284
|
-
templateData={props}
|
|
285
|
-
currency="USD"
|
|
286
|
-
>
|
|
287
|
-
<VisualEditorProvider templateProps={props}>
|
|
288
|
-
<Render
|
|
289
|
-
config={directoryConfig}
|
|
290
|
-
data={JSON.parse(document.__.layout)}
|
|
291
|
-
/>
|
|
292
|
-
</VisualEditorProvider>
|
|
293
|
-
</AnalyticsProvider>
|
|
294
|
-
);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
export default Directory;
|
|
298
|
-
`, m = {
|
|
299
|
-
"src/templates/main.tsx": d,
|
|
300
|
-
"src/templates/edit.tsx": p,
|
|
301
|
-
"src/templates/directory.tsx": l
|
|
302
|
-
}, g = () => {
|
|
303
|
-
let e = !1;
|
|
304
|
-
const a = [], c = () => {
|
|
305
|
-
Object.entries(m).forEach(([n, i]) => {
|
|
306
|
-
const o = s.join(process.cwd(), n);
|
|
307
|
-
a.push(o), r.mkdirSync(s.dirname(o), { recursive: !0 }), !r.existsSync(o) && r.writeFileSync(o, i);
|
|
308
|
-
});
|
|
309
|
-
}, t = () => {
|
|
310
|
-
a.forEach((n) => {
|
|
311
|
-
r.rmSync(n, { force: !0 });
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
return process.on("SIGINT", () => {
|
|
315
|
-
t(), process.nextTick(() => process.exit(0));
|
|
316
|
-
}), process.on("SIGTERM", () => {
|
|
317
|
-
t(), process.nextTick(() => process.exit(0));
|
|
318
|
-
}), {
|
|
319
|
-
name: "vite-plugin-yext-visual-editor",
|
|
320
|
-
config(n, { command: i }) {
|
|
321
|
-
e = i === "build";
|
|
322
|
-
},
|
|
323
|
-
configureServer(n) {
|
|
324
|
-
e || (c(), n.httpServer?.on("close", () => {
|
|
325
|
-
t();
|
|
326
|
-
}));
|
|
327
|
-
},
|
|
328
|
-
buildStart() {
|
|
329
|
-
e && c();
|
|
330
|
-
},
|
|
331
|
-
buildEnd() {
|
|
332
|
-
e && t();
|
|
333
|
-
},
|
|
334
|
-
closeBundle() {
|
|
335
|
-
e && t();
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
};
|
|
1
|
+
import { y as r } from "./index-C2zkTc1a.js";
|
|
339
2
|
export {
|
|
340
|
-
|
|
3
|
+
r as yextVisualEditorPlugin
|
|
341
4
|
};
|