@yext/visual-editor 0.0.36 → 0.0.38

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 CHANGED
@@ -237,7 +237,7 @@ type EntityFieldTypesFilter = {
237
237
  directChildrenOf?: string;
238
238
  };
239
239
  type RenderEntityFieldFilter<T extends Record<string, any>> = EntityFieldTypesFilter & EitherOrNeither<AllowList<T>, DisallowList<T>>;
240
- type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | "type.coordinate" | "type.cta" | `c_${string}`;
240
+ type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | "type.coordinate" | "type.cta" | "type.rich_text_v2" | `c_${string}`;
241
241
 
242
242
  type YextEntityField<T> = {
243
243
  field: string;
@@ -793,6 +793,7 @@ interface FlexProps extends layoutProps {
793
793
  declare const Flex: ComponentConfig<FlexProps>;
794
794
 
795
795
  interface GridProps extends layoutProps {
796
+ rows: number;
796
797
  columns: number;
797
798
  liveVisibility: boolean;
798
799
  }
package/dist/index.d.ts CHANGED
@@ -237,7 +237,7 @@ type EntityFieldTypesFilter = {
237
237
  directChildrenOf?: string;
238
238
  };
239
239
  type RenderEntityFieldFilter<T extends Record<string, any>> = EntityFieldTypesFilter & EitherOrNeither<AllowList<T>, DisallowList<T>>;
240
- type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | "type.coordinate" | "type.cta" | `c_${string}`;
240
+ type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | "type.coordinate" | "type.cta" | "type.rich_text_v2" | `c_${string}`;
241
241
 
242
242
  type YextEntityField<T> = {
243
243
  field: string;
@@ -793,6 +793,7 @@ interface FlexProps extends layoutProps {
793
793
  declare const Flex: ComponentConfig<FlexProps>;
794
794
 
795
795
  interface GridProps extends layoutProps {
796
+ rows: number;
796
797
  columns: number;
797
798
  liveVisibility: boolean;
798
799
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("node:path"),i=require("fs-extra"),d=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("node:path"),i=require("fs-extra"),p=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
2
2
  import "@yext/visual-editor/style.css";
3
3
  import {
4
4
  Template,
@@ -19,8 +19,7 @@ import {
19
19
  applyAnalytics,
20
20
  } from "@yext/visual-editor";
21
21
  import { themeConfig } from "../../theme.config";
22
- import { buildSchema } from "../utils/buildSchema";
23
- import { AnalyticsProvider } from "@yext/pages-components";
22
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
24
23
 
25
24
  export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
26
25
  document,
@@ -67,7 +66,7 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
67
66
  other: [
68
67
  applyAnalytics(document),
69
68
  applyTheme(document, themeConfig),
70
- buildSchema(document),
69
+ SchemaWrapper(document._schema),
71
70
  ].join("\\n"),
72
71
  };
73
72
  };
@@ -102,7 +101,7 @@ const Location: Template<TemplateRenderProps> = (props) => {
102
101
  };
103
102
 
104
103
  export default Location;
105
- `,l=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
104
+ `,d=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
106
105
  import {
107
106
  applyTheme,
108
107
  Editor,
@@ -162,4 +161,107 @@ const Edit: () => JSX.Element = () => {
162
161
  };
163
162
 
164
163
  export default Edit;
165
- `,m={"src/templates/main.tsx":d,"src/templates/edit.tsx":l},p=()=>{let e=!1;const a=[],s=()=>{Object.entries(m).forEach(([n,r])=>{const o=c.join(process.cwd(),n);a.push(o),i.mkdirSync(c.dirname(o),{recursive:!0}),!i.existsSync(o)&&i.writeFileSync(o,r)})},t=()=>{a.forEach(n=>{i.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:r}){e=r==="build"},configureServer(n){e||(s(),n.httpServer?.on("close",()=>{t()}))},buildStart(){e&&s()},buildEnd(){e&&t()},closeBundle(){e&&t()}}};exports.yextVisualEditorPlugin=p;
164
+ `,l=`import "@yext/visual-editor/style.css";
165
+ import {
166
+ Template,
167
+ GetPath,
168
+ TemplateProps,
169
+ TemplateRenderProps,
170
+ GetHeadConfig,
171
+ HeadConfig,
172
+ TagType,
173
+ } from "@yext/pages";
174
+ import { Render } from "@measured/puck";
175
+ import { directoryConfig } from "../ve.config";
176
+ import {
177
+ applyTheme,
178
+ VisualEditorProvider,
179
+ normalizeSlug,
180
+ getPageMetadata,
181
+ applyAnalytics,
182
+ } from "@yext/visual-editor";
183
+ import { themeConfig } from "../../theme.config";
184
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
185
+
186
+ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
187
+ document,
188
+ }): HeadConfig => {
189
+ const { title, description } = getPageMetadata(document);
190
+ const faviconUrl = document?._site?.favicon?.url;
191
+
192
+ return {
193
+ title: title,
194
+ charset: "UTF-8",
195
+ viewport: "width=device-width, initial-scale=1",
196
+ tags: [
197
+ {
198
+ type: "link",
199
+ attributes: {
200
+ rel: "icon",
201
+ type: "image/x-icon",
202
+ },
203
+ },
204
+ ...(description
205
+ ? [
206
+ {
207
+ type: "meta" as TagType,
208
+ attributes: {
209
+ name: "description",
210
+ content: description,
211
+ },
212
+ },
213
+ ]
214
+ : []),
215
+ ...(faviconUrl
216
+ ? [
217
+ {
218
+ type: "link" as TagType,
219
+ attributes: {
220
+ rel: "icon",
221
+ type: "image/x-icon",
222
+ href: faviconUrl,
223
+ },
224
+ },
225
+ ]
226
+ : []),
227
+ ],
228
+ other: [
229
+ applyAnalytics(document),
230
+ applyTheme(document, themeConfig),
231
+ SchemaWrapper(document._schema),
232
+ ].join("\\n"),
233
+ };
234
+ };
235
+
236
+ export const getPath: GetPath<TemplateProps> = ({ document }) => {
237
+ if (document.slug) {
238
+ return document.slug;
239
+ }
240
+
241
+ const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
242
+ const path = \`\${localePath}\${document.id}\`;
243
+
244
+ return normalizeSlug(path);
245
+ };
246
+
247
+ const Directory: Template<TemplateRenderProps> = (props) => {
248
+ const { document } = props;
249
+
250
+ return (
251
+ <AnalyticsProvider
252
+ apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
253
+ templateData={props}
254
+ currency="USD"
255
+ >
256
+ <VisualEditorProvider templateProps={props}>
257
+ <Render
258
+ config={directoryConfig}
259
+ data={JSON.parse(document.__.layout)}
260
+ />
261
+ </VisualEditorProvider>
262
+ </AnalyticsProvider>
263
+ );
264
+ };
265
+
266
+ export default Directory;
267
+ `,m={"src/templates/main.tsx":p,"src/templates/edit.tsx":d,"src/templates/directory.tsx":l},u=()=>{let e=!1;const a=[],c=()=>{Object.entries(m).forEach(([n,r])=>{const o=s.join(process.cwd(),n);a.push(o),i.mkdirSync(s.dirname(o),{recursive:!0}),!i.existsSync(o)&&i.writeFileSync(o,r)})},t=()=>{a.forEach(n=>{i.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:r}){e=r==="build"},configureServer(n){e||(c(),n.httpServer?.on("close",()=>{t()}))},buildStart(){e&&c()},buildEnd(){e&&t()},closeBundle(){e&&t()}}};exports.yextVisualEditorPlugin=u;
@@ -1,6 +1,6 @@
1
- import c from "node:path";
1
+ import s from "node:path";
2
2
  import i from "fs-extra";
3
- const d = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
3
+ const p = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
4
4
  import "@yext/visual-editor/style.css";
5
5
  import {
6
6
  Template,
@@ -21,8 +21,7 @@ import {
21
21
  applyAnalytics,
22
22
  } from "@yext/visual-editor";
23
23
  import { themeConfig } from "../../theme.config";
24
- import { buildSchema } from "../utils/buildSchema";
25
- import { AnalyticsProvider } from "@yext/pages-components";
24
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
26
25
 
27
26
  export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
28
27
  document,
@@ -69,7 +68,7 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
69
68
  other: [
70
69
  applyAnalytics(document),
71
70
  applyTheme(document, themeConfig),
72
- buildSchema(document),
71
+ SchemaWrapper(document._schema),
73
72
  ].join("\\n"),
74
73
  };
75
74
  };
@@ -104,7 +103,7 @@ const Location: Template<TemplateRenderProps> = (props) => {
104
103
  };
105
104
 
106
105
  export default Location;
107
- `, m = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
106
+ `, d = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
108
107
  import {
109
108
  applyTheme,
110
109
  Editor,
@@ -164,15 +163,119 @@ const Edit: () => JSX.Element = () => {
164
163
  };
165
164
 
166
165
  export default Edit;
166
+ `, m = `import "@yext/visual-editor/style.css";
167
+ import {
168
+ Template,
169
+ GetPath,
170
+ TemplateProps,
171
+ TemplateRenderProps,
172
+ GetHeadConfig,
173
+ HeadConfig,
174
+ TagType,
175
+ } from "@yext/pages";
176
+ import { Render } from "@measured/puck";
177
+ import { directoryConfig } from "../ve.config";
178
+ import {
179
+ applyTheme,
180
+ VisualEditorProvider,
181
+ normalizeSlug,
182
+ getPageMetadata,
183
+ applyAnalytics,
184
+ } from "@yext/visual-editor";
185
+ import { themeConfig } from "../../theme.config";
186
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
187
+
188
+ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
189
+ document,
190
+ }): HeadConfig => {
191
+ const { title, description } = getPageMetadata(document);
192
+ const faviconUrl = document?._site?.favicon?.url;
193
+
194
+ return {
195
+ title: title,
196
+ charset: "UTF-8",
197
+ viewport: "width=device-width, initial-scale=1",
198
+ tags: [
199
+ {
200
+ type: "link",
201
+ attributes: {
202
+ rel: "icon",
203
+ type: "image/x-icon",
204
+ },
205
+ },
206
+ ...(description
207
+ ? [
208
+ {
209
+ type: "meta" as TagType,
210
+ attributes: {
211
+ name: "description",
212
+ content: description,
213
+ },
214
+ },
215
+ ]
216
+ : []),
217
+ ...(faviconUrl
218
+ ? [
219
+ {
220
+ type: "link" as TagType,
221
+ attributes: {
222
+ rel: "icon",
223
+ type: "image/x-icon",
224
+ href: faviconUrl,
225
+ },
226
+ },
227
+ ]
228
+ : []),
229
+ ],
230
+ other: [
231
+ applyAnalytics(document),
232
+ applyTheme(document, themeConfig),
233
+ SchemaWrapper(document._schema),
234
+ ].join("\\n"),
235
+ };
236
+ };
237
+
238
+ export const getPath: GetPath<TemplateProps> = ({ document }) => {
239
+ if (document.slug) {
240
+ return document.slug;
241
+ }
242
+
243
+ const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
244
+ const path = \`\${localePath}\${document.id}\`;
245
+
246
+ return normalizeSlug(path);
247
+ };
248
+
249
+ const Directory: Template<TemplateRenderProps> = (props) => {
250
+ const { document } = props;
251
+
252
+ return (
253
+ <AnalyticsProvider
254
+ apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
255
+ templateData={props}
256
+ currency="USD"
257
+ >
258
+ <VisualEditorProvider templateProps={props}>
259
+ <Render
260
+ config={directoryConfig}
261
+ data={JSON.parse(document.__.layout)}
262
+ />
263
+ </VisualEditorProvider>
264
+ </AnalyticsProvider>
265
+ );
266
+ };
267
+
268
+ export default Directory;
167
269
  `, l = {
168
- "src/templates/main.tsx": d,
169
- "src/templates/edit.tsx": m
170
- }, f = () => {
270
+ "src/templates/main.tsx": p,
271
+ "src/templates/edit.tsx": d,
272
+ "src/templates/directory.tsx": m
273
+ }, g = () => {
171
274
  let e = !1;
172
- const a = [], s = () => {
275
+ const a = [], c = () => {
173
276
  Object.entries(l).forEach(([n, r]) => {
174
- const o = c.join(process.cwd(), n);
175
- a.push(o), i.mkdirSync(c.dirname(o), { recursive: !0 }), !i.existsSync(o) && i.writeFileSync(o, r);
277
+ const o = s.join(process.cwd(), n);
278
+ a.push(o), i.mkdirSync(s.dirname(o), { recursive: !0 }), !i.existsSync(o) && i.writeFileSync(o, r);
176
279
  });
177
280
  }, t = () => {
178
281
  a.forEach((n) => {
@@ -189,12 +292,12 @@ export default Edit;
189
292
  e = r === "build";
190
293
  },
191
294
  configureServer(n) {
192
- e || (s(), n.httpServer?.on("close", () => {
295
+ e || (c(), n.httpServer?.on("close", () => {
193
296
  t();
194
297
  }));
195
298
  },
196
299
  buildStart() {
197
- e && s();
300
+ e && c();
198
301
  },
199
302
  buildEnd() {
200
303
  e && t();
@@ -205,5 +308,5 @@ export default Edit;
205
308
  };
206
309
  };
207
310
  export {
208
- f as yextVisualEditorPlugin
311
+ g as yextVisualEditorPlugin
209
312
  };