@micelio/strapi-plugin-core 0.1.0 → 0.2.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 (54) hide show
  1. package/README.md +5 -3
  2. package/dist/admin/MicelioLayout-Bmu5xCw9.js +1023 -0
  3. package/dist/admin/MicelioLayout-DMMsKnMo.mjs +1021 -0
  4. package/dist/admin/PreviewHeaderAction-BaduMvYy.mjs +61 -0
  5. package/dist/admin/PreviewHeaderAction-CGHycv4I.js +61 -0
  6. package/dist/admin/{en-D-T8z3qh.js → en-BDVuq0fN.js} +37 -1
  7. package/dist/admin/{en-C2O-S2ym.mjs → en-Bahc6y6N.mjs} +37 -1
  8. package/dist/admin/{es-RV0vkOHh.js → es-DStBGkm7.js} +37 -1
  9. package/dist/admin/{es-CQ2tv9N8.mjs → es-nUHBIoZG.mjs} +37 -1
  10. package/dist/admin/{index-D3TGbaQ7.js → index-D_Dbvo2F.js} +8 -2
  11. package/dist/admin/{index-CiSujTES.mjs → index-Dwr15ZsB.mjs} +8 -2
  12. package/dist/admin/index.js +1 -1
  13. package/dist/admin/index.mjs +1 -1
  14. package/dist/admin/permissions-BAI0qDr9.js +24 -0
  15. package/dist/admin/permissions-CYirM30e.mjs +25 -0
  16. package/dist/admin/src/components/EyeIcon.d.ts +8 -0
  17. package/dist/admin/src/components/PreviewFrame.d.ts +47 -0
  18. package/dist/admin/src/components/PreviewHeaderAction.d.ts +28 -0
  19. package/dist/admin/src/hooks/useEntry.d.ts +31 -0
  20. package/dist/admin/src/hooks/usePreviewSource.d.ts +31 -0
  21. package/dist/admin/src/pages/MicelioLayout.d.ts +2 -1
  22. package/dist/admin/src/pages/PreviewPage.d.ts +2 -0
  23. package/dist/admin/src/permissions.d.ts +5 -0
  24. package/dist/admin/src/translations/en.json.d.ts +37 -1
  25. package/dist/admin/src/utils/fetchError.d.ts +2 -0
  26. package/dist/admin/src/utils/previewAction.d.ts +22 -0
  27. package/dist/admin/src/utils/previewPane.d.ts +59 -0
  28. package/dist/server/index.js +796 -105
  29. package/dist/server/index.mjs +796 -105
  30. package/dist/server/src/constants/preview.d.ts +2 -0
  31. package/dist/server/src/constants/taxonomy.d.ts +13 -0
  32. package/dist/server/src/content-types/category/schema.json.d.ts +78 -0
  33. package/dist/server/src/content-types/index.d.ts +125 -2
  34. package/dist/server/src/content-types/preview-credential/schema.json.d.ts +7 -6
  35. package/dist/server/src/content-types/tag/schema.json.d.ts +46 -0
  36. package/dist/server/src/controllers/index.d.ts +6 -0
  37. package/dist/server/src/editorial/transitions.d.ts +5 -2
  38. package/dist/server/src/index.d.ts +140 -2
  39. package/dist/server/src/migrations/rename-legacy-uids.d.ts +26 -0
  40. package/dist/server/src/migrations/site-backfill.d.ts +13 -0
  41. package/dist/server/src/preview/credentials.d.ts +7 -5
  42. package/dist/server/src/preview/draft-query.d.ts +62 -0
  43. package/dist/server/src/preview/revocation.d.ts +9 -1
  44. package/dist/server/src/preview/shortcut.d.ts +24 -0
  45. package/dist/server/src/routes/index.d.ts +2 -0
  46. package/dist/server/src/routes/taxonomy.d.ts +12 -0
  47. package/dist/server/src/services/index.d.ts +6 -0
  48. package/dist/server/src/services/preview.d.ts +25 -6
  49. package/dist/server/src/site-scope/documents.d.ts +13 -3
  50. package/dist/server/src/types/hooks.d.ts +5 -4
  51. package/dist/server/src/types/preview.d.ts +35 -10
  52. package/package.json +4 -3
  53. package/dist/admin/MicelioLayout-3sKGPS_0.mjs +0 -443
  54. package/dist/admin/MicelioLayout-DXzRS4l3.js +0 -443
@@ -90,7 +90,43 @@ declare const _default: {
90
90
  "status.plugins.fix": "Fix",
91
91
  "status.diagnostics.copy": "Copy diagnostics",
92
92
  "status.diagnostics.copied": "The diagnostics were copied.",
93
- "status.diagnostics.failed": "The diagnostics could not be copied."
93
+ "status.diagnostics.failed": "The diagnostics could not be copied.",
94
+ "preview.title": "Preview",
95
+ "preview.page": "Preview of {title}",
96
+ "preview.subtitle": "The saved draft, as the site renders it.",
97
+ "preview.back": "Back to the entry",
98
+ "preview.pane": "Preview",
99
+ "preview.entry.title": "Entry",
100
+ "preview.entry.readOnly": "Read-only",
101
+ "preview.entry.body": "The form is in the Content Manager: open it in another tab, edit and save the entry there. This page shows the saved draft and loads it again after each save.",
102
+ "preview.entry.bodyReadOnly": "You may read this entry but not edit it. The preview shows its saved draft.",
103
+ "preview.entry.locale": "Locale: {locale}",
104
+ "preview.entry.saved": "Draft saved {date}",
105
+ "preview.entry.open": "Open in the Content Manager, in a new tab",
106
+ "preview.entry.view": "View in the Content Manager, in a new tab",
107
+ "preview.device.group": "Preview width",
108
+ "preview.device.phone": "Phone",
109
+ "preview.device.tablet": "Tablet",
110
+ "preview.device.desktop": "Desktop",
111
+ "preview.static": "As static site",
112
+ "preview.locale": "Locale",
113
+ "preview.reload": "Reload",
114
+ "preview.updating": "Updating the preview",
115
+ "preview.shortcuts": "Shortcuts: Ctrl+Shift+1, 2 and 3 for phone, tablet and desktop; Ctrl+Shift+S for the static site; Ctrl+Shift+Left Arrow back to the entry. On a Mac use Command instead of Ctrl. They do not work while you type in a field.",
116
+ "preview.frame.title": "Preview of {title}",
117
+ "preview.blocked.title": "The admin does not allow this site in a frame",
118
+ "preview.blocked.body": "The Content Security Policy of the admin does not list {origin} in frame-src, so the browser refuses to show it. Add it to frame-src in the strapi::security config of the Strapi project and restart it. The host check on the Micelio status page reports it too.",
119
+ "preview.upgrade.title": "Upgrade the frontend",
120
+ "preview.upgrade.body": "The site's frontend speaks the preview protocol versions {versions}, and this plugin speaks none of them. The preview stays plain: it shows the draft and loads it again as a whole after each save.",
121
+ "preview.error.entry": "The entry could not be loaded.",
122
+ "preview.error.missing": "This entry does not exist.",
123
+ "preview.error.unavailable": "This site has no preview: set its url in the Content Manager (Site), and make sure the frontend runs there.",
124
+ "preview.error.forbidden": "You may not preview this entry. It needs the permission to preview drafts and the permission to read the entry.",
125
+ "preview.error.unsupported": "This type has no preview: its entries do not belong to a site.",
126
+ "preview.error.busy": "Too many preview requests. Wait a minute, then reload.",
127
+ "preview.error.failed": "The preview could not load. Reload to try again.",
128
+ "action.preview": "Preview",
129
+ "action.preview.unsaved": "Preview: save your changes first"
94
130
  }
95
131
  ;
96
132
 
@@ -0,0 +1,2 @@
1
+ /** The HTTP status of an error the admin's fetch client threw, if it carries one. */
2
+ export declare function statusOf(error: unknown): number | undefined;
@@ -0,0 +1,22 @@
1
+ /** The part of a content type's schema the edit view's action reads. */
2
+ export interface ActionSchema {
3
+ attributes?: Record<string, {
4
+ type?: string;
5
+ } | undefined>;
6
+ pluginOptions?: {
7
+ micelio?: {
8
+ siteScoped?: unknown;
9
+ };
10
+ };
11
+ }
12
+ /**
13
+ * Whether an entry of this type has a preview: the type belongs to a site (`withSiteScope`) and has
14
+ * a dynamic zone, which is where the blocks of a page live.
15
+ *
16
+ * @remarks
17
+ * The server's handler for Strapi's own "Open preview" button (`server/src/preview/shortcut.ts`)
18
+ * applies the same rule; the two stay apart because the admin imports nothing at runtime from the server.
19
+ */
20
+ export declare function hasPreview(schema: ActionSchema | undefined): boolean;
21
+ /** The admin path of the preview page for an entry, which `PreviewPage` reads (`preview/:uid/:documentId`). */
22
+ export declare function previewPagePath(uid: string, documentId: string, locale: string | null): string;
@@ -0,0 +1,59 @@
1
+ /** The widths of the preview, as the design's toolbar offers them (phone, tablet and desktop). */
2
+ export declare const DEVICES: readonly [{
3
+ readonly id: "phone";
4
+ readonly width: 320;
5
+ }, {
6
+ readonly id: "tablet";
7
+ readonly width: 768;
8
+ }, {
9
+ readonly id: "desktop";
10
+ readonly width: 1280;
11
+ }];
12
+ /** A device of the toolbar. */
13
+ export type DeviceId = (typeof DEVICES)[number]['id'];
14
+ /** What the toolbar shows: the draft with its islands, or with each island on its static alternative. */
15
+ export type PreviewMode = 'live' | 'static';
16
+ /** An action a shortcut of the Shortcuts sheet (Preview and Page groups) runs. */
17
+ export type PreviewShortcut = {
18
+ action: 'device';
19
+ device: DeviceId;
20
+ } | {
21
+ action: 'static' | 'back';
22
+ };
23
+ /** The minutes the page waits after it asked for a token before it asks for a new one: the grant lasts 15 minutes. */
24
+ export declare const GRANT_REFRESH_MINUTES = 14;
25
+ /** How often the page reads the document to notice a save made elsewhere, in milliseconds. */
26
+ export declare const SAVE_POLL_MS = 4000;
27
+ /** The envelope versions the admin speaks: its own release's (ADR-0019, section 4). */
28
+ export declare const SPOKEN_VERSIONS: readonly number[];
29
+ /** The keys of a keyboard event the shortcuts read. */
30
+ export interface ShortcutEvent {
31
+ code: string;
32
+ key: string;
33
+ ctrlKey: boolean;
34
+ metaKey: boolean;
35
+ shiftKey: boolean;
36
+ altKey: boolean;
37
+ target: unknown;
38
+ }
39
+ /**
40
+ * The URL the iframe loads: the one the token route answered, asking for the static alternatives in
41
+ * static mode.
42
+ *
43
+ * @returns The URL, and the origin of the site, the only origin the page talks to; `undefined` when `url`
44
+ * is not an `http` or `https` URL.
45
+ */
46
+ export declare function frameTarget(url: string, mode: PreviewMode): {
47
+ src: string;
48
+ origin: string;
49
+ } | undefined;
50
+ /** Whether a shortcut would land in a field the editor types in or chooses from with the keys. */
51
+ export declare function isTypingTarget(target: unknown): boolean;
52
+ /**
53
+ * The preview shortcut a key press is, from the Shortcuts sheet: ⌘⇧1, ⌘⇧2 and ⌘⇧3 for the widths,
54
+ * ⌘⇧S for "as static site" and ⌘⇧← back to the entry (⌘ is Ctrl on Windows and Linux).
55
+ *
56
+ * @remarks
57
+ * Never inside a field. A press with Alt, or with ⌘ and Ctrl together, is not one.
58
+ */
59
+ export declare function previewShortcut(event: ShortcutEvent): PreviewShortcut | undefined;