sanity-plugin-visual-editor 1.0.0 → 1.1.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.
Files changed (60) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +137 -16
  3. package/TESTING.md +133 -0
  4. package/dist/PreviewBar-D_rw0bhP.js +3503 -0
  5. package/dist/PreviewBar-D_rw0bhP.js.map +1 -0
  6. package/dist/bar.d.ts +22 -0
  7. package/dist/bar.js +67 -0
  8. package/dist/bar.js.map +1 -0
  9. package/dist/cloudflare.d.ts +76 -0
  10. package/dist/cloudflare.js +1071 -0
  11. package/dist/cloudflare.js.map +1 -0
  12. package/dist/data-D0qotTtt.d.ts +177 -0
  13. package/dist/host-DreYJEmR.js +615 -0
  14. package/dist/host-DreYJEmR.js.map +1 -0
  15. package/dist/host.d.ts +160 -0
  16. package/dist/host.js +3 -0
  17. package/dist/index-4Zm_NjhC.d.ts +221 -0
  18. package/dist/index.d.ts +18 -18
  19. package/dist/index.js +7 -8
  20. package/dist/link-search-JtZkxz4k.js +14 -0
  21. package/dist/link-search-JtZkxz4k.js.map +1 -0
  22. package/dist/link-session-Dr4YkKFy.js +52 -0
  23. package/dist/link-session-Dr4YkKFy.js.map +1 -0
  24. package/dist/next-client.d.ts +15 -0
  25. package/dist/next-client.js +78 -0
  26. package/dist/next-client.js.map +1 -0
  27. package/dist/next.d.ts +38 -0
  28. package/dist/next.js +117 -0
  29. package/dist/next.js.map +1 -0
  30. package/dist/node-labels-CDiW5rMq.js +122 -0
  31. package/dist/node-labels-CDiW5rMq.js.map +1 -0
  32. package/dist/page-documents-BFFcH8lD.d.ts +54 -0
  33. package/dist/page-documents-mGfw_flR.js +67 -0
  34. package/dist/page-documents-mGfw_flR.js.map +1 -0
  35. package/dist/perspective-BmS9TVtr.js +106 -0
  36. package/dist/perspective-BmS9TVtr.js.map +1 -0
  37. package/dist/preview-links-BZDZyIey.js +119 -0
  38. package/dist/preview-links-BZDZyIey.js.map +1 -0
  39. package/dist/preview-links-DM6BCiLV.d.ts +87 -0
  40. package/dist/protocol-BNO38gYy.js +280 -0
  41. package/dist/protocol-BNO38gYy.js.map +1 -0
  42. package/dist/protocol-BnRCy2wJ.d.ts +386 -0
  43. package/dist/server.d.ts +4 -0
  44. package/dist/server.js +495 -0
  45. package/dist/server.js.map +1 -0
  46. package/dist/shell-DZotxRXX.d.ts +37 -0
  47. package/dist/studio.d.ts +93 -0
  48. package/dist/studio.js +1263 -0
  49. package/dist/studio.js.map +1 -0
  50. package/dist/sveltekit.d.ts +281 -0
  51. package/dist/sveltekit.js +395 -0
  52. package/dist/sveltekit.js.map +1 -0
  53. package/package.json +120 -39
  54. package/dist/index.d.mts +0 -21
  55. package/dist/index.js.map +0 -1
  56. package/dist/index.mjs +0 -8
  57. package/dist/index.mjs.map +0 -1
  58. package/sanity.json +0 -8
  59. package/src/index.ts +0 -27
  60. package/v2-incompatible.js +0 -11
@@ -0,0 +1,93 @@
1
+ import { n as MoreMenuOptions } from "./shell-DZotxRXX.js";
2
+ import { r as PageDocumentRule } from "./page-documents-BFFcH8lD.js";
3
+ import "sanity";
4
+ import { DocumentLocation, DocumentLocationResolver, DocumentLocationResolver as DocumentLocationResolver$1, DocumentLocationResolverObject, DocumentLocationResolverObject as DocumentLocationResolverObject$1, DocumentLocationResolvers, DocumentLocationResolvers as DocumentLocationResolvers$1, DocumentLocationsState, DocumentLocationsState as DocumentLocationsState$1, DocumentResolver, DocumentResolver as DocumentResolver$1, DocumentResolverContext } from "sanity/presentation";
5
+ /**
6
+ * Streams the open document's unsaved form value to the storefront's realtime preview hub, so
7
+ * preview tabs update as the editor types instead of after the Studio's autosave (at most one save
8
+ * per second while typing).
9
+ *
10
+ * The Studio is served on the storefront's origin (e.g. `/studio`), so requests go to the same
11
+ * origin. Edits go over a WebSocket to the hub (`<endpoint>/socket`, opened when a document
12
+ * opens), or as POSTs where one cannot open. Without a session, the plugin creates a Sanity
13
+ * preview secret with the editor's own login and trades it for a signed cookie limited to the
14
+ * live-edit routes (`<endpoint>/session`).
15
+ *
16
+ * Rich text: the Portable Text editor hands its changes to the form in batches (250 ms after
17
+ * typing pauses, every second while it continues), but emits each keystroke at once as a `patch`
18
+ * event. A Portable Text plugin (inside every rich-text editor) reports the editor's value on each
19
+ * patch, with the field's path from its input, and the document is sent with that value in place.
20
+ */
21
+ type LiveEditOptions = {
22
+ /** Storefront live-edit base endpoint. Default `/api/preview/live-edit`. */
23
+ endpoint?: string;
24
+ /** Studio base path used when creating the preview secret. Default `/studio`. */
25
+ studioPath?: string;
26
+ /** Source label passed to `createPreviewSecret`. Default `'visual-editor-live-edit'`. */
27
+ source?: string;
28
+ };
29
+ /** Streams unsaved edits of the open document to the realtime preview hub. */
30
+ export declare const liveEditPlugin: import("sanity").Plugin<void | LiveEditOptions>;
31
+ type VisualEditorLocations = DocumentLocationResolvers$1 | DocumentLocationResolver$1;
32
+ type VisualEditorToolOptions = {
33
+ /** The tool's name, in its URL. Default `visual-editor`. */
34
+ name?: string;
35
+ /** Default `Visual Editor`. */
36
+ title?: string;
37
+ previewUrl?: {
38
+ /** The page opened without `?preview=`. Default `/`. */
39
+ initial?: string;
40
+ /**
41
+ * The site's preview-mode route, as in Presentation's `previewUrl.previewMode.enable`. The tool
42
+ * creates a preview secret and opens the page through it. Default `/preview/enable`.
43
+ */
44
+ previewMode?: {
45
+ enable: string;
46
+ };
47
+ };
48
+ /** The bar's route on the site. Default `/__visual-editor`. */
49
+ barPath?: string;
50
+ /**
51
+ * Presentation's document resolvers, with its API (`defineDocuments`, `defineLocations`):
52
+ * - `mainDocuments`: which document each page shows; the pane opens it as you browse. Resolved
53
+ * with the editor's client; without it, the site's `/__visual-editor/document` route is asked.
54
+ * - `locations`: where each document appears; every document form shows "Used on N pages", each
55
+ * page opening here.
56
+ */
57
+ resolve?: {
58
+ mainDocuments?: PageDocumentRule[];
59
+ locations?: VisualEditorLocations;
60
+ };
61
+ /** @deprecated Use `resolve.mainDocuments`. */
62
+ mainDocuments?: PageDocumentRule[];
63
+ /** The site serves short preview links (`links` in `createPreviewBar`). Default `true`. */
64
+ links?: boolean;
65
+ /** Document types the bar's Studio search opens filtered to. Default: all types. */
66
+ searchTypes?: string[];
67
+ /** The document pane's width. Default 420. */
68
+ paneWidth?: number;
69
+ /**
70
+ * Hide the Studio's navbar while the tool is open, so the preview bar is the only toolbar (its
71
+ * logo goes back to the Studio). Default `true`.
72
+ */
73
+ hideStudioNavbar?: boolean;
74
+ /**
75
+ * Stream unsaved edits (and Portable Text keystrokes) to the storefront's realtime preview hub.
76
+ * Enabled by default (`true`); pass `false` to disable, or an options object to customize.
77
+ */
78
+ liveEdit?: boolean | LiveEditOptions;
79
+ /** The bar's "…" menu: a code link (e.g. the repository) and a document for site preferences. */
80
+ menu?: MoreMenuOptions;
81
+ };
82
+ export type VisualEditorOptions = VisualEditorToolOptions;
83
+ /**
84
+ * Presentation's `defineLocations`, for `resolve.locations`: types a resolver, does nothing else.
85
+ * The same resolvers work in both tools.
86
+ */
87
+ export declare function defineLocations<K extends string>(resolver: DocumentLocationResolverObject$1<K> | DocumentLocationsState$1): typeof resolver;
88
+ /** Presentation's `defineDocuments`, for `resolve.mainDocuments`: types the list, nothing else. */
89
+ export declare function defineDocuments(resolvers: DocumentResolver$1[]): typeof resolvers;
90
+ export declare const visualEditor: import("sanity").Plugin<void | VisualEditorToolOptions>;
91
+ /** @deprecated Use `visualEditor`. */
92
+ export declare const visualEditorTool: import("sanity").Plugin<void | VisualEditorToolOptions>;
93
+ export type { DocumentLocation, DocumentLocationResolver, DocumentLocationResolverObject, DocumentLocationResolvers, DocumentLocationsState, DocumentResolver, DocumentResolverContext, LiveEditOptions, VisualEditorLocations, VisualEditorToolOptions };