@aduptive/strapi-blockscene 1.0.0-alpha.10 → 1.0.0-alpha.11

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/README.md CHANGED
@@ -29,6 +29,9 @@ module.exports = {
29
29
  config: {
30
30
  previewBaseUrl: '/block-previews',
31
31
  previewVersion: '2026-09-22', // optional cache buster appended as ?v=
32
+ // Optional: only these Strapi component folders get cards in Settings > Block gallery.
33
+ // Dynamic Zone insertion still follows each content type's own schema.
34
+ settingsComponentCategories: ['blocks'],
32
35
  components: {
33
36
  'blocks.hero': {
34
37
  label: 'Hero banner',
@@ -37,6 +40,7 @@ module.exports = {
37
40
  tags: ['Editorial'],
38
41
  keywords: 'heading introduction',
39
42
  image: '/block-previews/hero.png',
43
+ showRowThumbnail: false, // optional per-component row thumbnail
40
44
  },
41
45
  },
42
46
  },
@@ -65,7 +69,7 @@ Right beside the native zone label ("blocks (3)") each zone gets a short bar:
65
69
  - **Undo and Redo** (Strapi 5, first zone only): icon and text, the shortcut in
66
70
  the tooltip. See [Undo and redo](#undo-and-redo).
67
71
  - **Editing mode** (first zone only, when a preview route exists): a
68
- menu with Fields, Fields + page and Visual editor. Without a preview route the
72
+ menu with Fields only, Fields + preview and Visual editor. Without a preview route the
69
73
  menu is not shown; Settings, Blockscene says why.
70
74
  - **"…" (More actions)**: Select blocks, and "Paste N blocks" while the
71
75
  clipboard holds blocks this zone allows (see [Row actions](#row-actions)).
@@ -97,7 +101,8 @@ The modal is a block browser (80vw wide):
97
101
  all"; the empty state offers a reset.
98
102
  - **Cards**, grouped by typology: facet badges (IMAGE, VIDEO, GALLERY, RICH
99
103
  TEXT, LIST, DYNAMIC, FORM), a star and an always-visible magnifying glass.
100
- Clicking the card inserts it immediately; the magnifying glass opens its preview.
104
+ Clicking the card, or focusing it and pressing Enter, inserts it immediately;
105
+ the magnifying glass opens its preview.
101
106
  - The preview **magnifies** the block: the card grows into a large panel over the
102
107
  grid (sidebar and top bar stay usable, the grid dims underneath) and shrinks
103
108
  back into its card on close (close button, Esc or a click on the dimmed
@@ -106,8 +111,7 @@ The modal is a block browser (80vw wide):
106
111
  with Fit / Mobile / Tablet / Desktop widths (scaled to fit, as in the page
107
112
  preview) and a compact strip: label, uid, description, badges, fields (on
108
113
  demand), the variant choice (see [Insert variants](#insert-variants)), star
109
- and Insert. Clicking or pressing Enter on a focused card inserts without it
110
- (the first variant, when the block has variants).
114
+ and Insert. A direct card insert uses the first variant, when the block has variants.
111
115
 
112
116
  The magnified preview shows the card's thumbnail at once and fades the live
113
117
  page in over it once it has loaded. Live source, first match wins:
@@ -190,7 +194,7 @@ components: {
190
194
  - **Choosing**: with two or more variants the magnified block shows them as a
191
195
  row of buttons; the live preview follows the choice (`{variant}` in the
192
196
  block preview URL, or the variant's block sent through the bridge) and
193
- Insert inserts it. Double click, "+" and Enter insert the first variant.
197
+ Insert inserts it. Clicking the card or pressing Enter inserts the first variant.
194
198
  The picker opened from a page preview insertion seam offers the same
195
199
  choice. A block without variants behaves as before; Settings, Blockscene
196
200
  lists each block's variants read-only.
@@ -215,6 +219,42 @@ components: {
215
219
  per variant and 256 KB for all of them. An invalid variant is left out with
216
220
  a warning naming the problem; the block keeps its valid ones.
217
221
 
222
+ ### Starter kits
223
+
224
+ New entries can start from a named set of blocks instead of an empty Dynamic
225
+ Zone. Kits live in project code, per content type. When every editable zone is
226
+ empty, Blockscene opens the kit chooser once; choosing one only changes the
227
+ unsaved form, so every placeholder remains editable and **Start blank** keeps
228
+ the current behaviour.
229
+
230
+ ```js
231
+ // config/plugins.js
232
+ blockscene: { config: {
233
+ kits: {
234
+ 'api::page.page': [{
235
+ id: 'landing',
236
+ label: { en: 'Landing page', 'pt-BR': 'Página de campanha' },
237
+ // Optional. A language code such as "pt" also matches "pt-BR".
238
+ locales: ['en', 'pt-BR'],
239
+ zones: { blocks: [
240
+ { __component: 'blocks.hero', title: 'Replace this headline' },
241
+ { __component: 'blocks.rich-text', text: 'Replace this text.' },
242
+ ] },
243
+ }],
244
+ },
245
+ } }
246
+ ```
247
+
248
+ Rows use the Content API shape and the same validated values as [insert
249
+ variants](#insert-variants). Schema defaults are merged in, nested components
250
+ work, and configured layout OPEN blocks receive their CLOSE automatically.
251
+ Media and relations are omitted because their ids are installation-specific;
252
+ required ones are called out in the server log and must be completed before
253
+ publishing. Invalid kits, missing required scalar values and kits below or
254
+ above a Dynamic Zone's bounds are ignored with a server warning. The chooser
255
+ is remembered for the current new-entry browser history item, so re-rendering
256
+ or reloading it does not apply or prompt twice.
257
+
218
258
  ## Row thumbnails
219
259
 
220
260
  Each added block shows its thumbnail at the left of the native accordion
@@ -223,8 +263,10 @@ opening or closing the row. The sources are the same as the gallery cards,
223
263
  minus the wireframe: a block with no image shows nothing, so nothing new is
224
264
  invented for blocks that were never captured. The thumbnail is inserted into
225
265
  Strapi's own header through the DOM (no Content Manager patch) and is
226
- restored when Strapi re-renders the list. Turn it off with the editor option
227
- `showRowThumbnails: false`.
266
+ restored when Strapi re-renders the list. Configured OPEN and CLOSE group
267
+ markers hide it by default. Override any component with
268
+ `components[uid].showRowThumbnail` in code or on the Settings page, or turn all
269
+ row thumbnails off with the editor option `showRowThumbnails: false`.
228
270
 
229
271
  ## Row actions
230
272
 
@@ -398,7 +440,7 @@ ignored (boot continues). `GET /blockscene/settings` returns them as
398
440
  | Copy and Paste (`clipboard`) | yes/no | yes |
399
441
  | Blocks hidden on the site (`hiddenBlocks`) | `strip` / `flag` / `off` | `strip` |
400
442
  | Friendly field labels (`friendlyLabels`, see [Field labels](#field-labels)) | yes/no | yes |
401
- | Page preview toolbar (`previewToolbar`, see [Pane toolbar](#pane-toolbar)) | ordered list of `modes`, `history`, `devices`, `status`, `actions` | all five |
443
+ | Page preview toolbar (`previewToolbar`, see [Pane toolbar](#pane-toolbar)) | ordered list of `modes`, `history`, `versions`, `devices`, `status`, `actions` | all six (`versions`: Strapi 5) |
402
444
  | Page widths (`previewDevices`) | 1 to 8 of `fit`, `mobile`, `tablet`, `desktop`, `{ label, width }` | the four built-in |
403
445
 
404
446
  Every edit view opens in its content type's mode, else the initial preview
@@ -433,7 +475,7 @@ the two supported versions only.
433
475
  ## Whole-page preview
434
476
 
435
477
  Both distributions add a page preview with three modes, chosen from the
436
- first zone's bar and from the pane toolbar: Fields (form), Fields + page (side
478
+ first zone's bar and from the pane toolbar: Fields only (form), Fields + preview (side
437
479
  by side: resizable pane, native actions moved to a bar above the form) and
438
480
  Visual editor. It posts the live values of the first Dynamic Zone to a page
439
481
  your frontend serves; the page renders them with its own components and styles
@@ -496,6 +538,11 @@ Minimal configuration:
496
538
  blocks, 0 when none or not editable); while it is positive the page may show
497
539
  a Paste button in its seams that sends `{ type: 'paste', after }` (a block
498
540
  key, or `null` for the start). Both are optional.
541
+ `update-page` also carries the complete live `entry`, including unsaved
542
+ values, plus `contentType` metadata and the projected zone name. New schema
543
+ fields therefore reach the frontend automatically; the frontend decides how
544
+ each field affects its page. The normalized `blocks` array remains alongside
545
+ it for visual editing and block-level actions.
499
546
  Keep the origin check (`admin` query parameter or your own constant).
500
547
  2. Allow the admin origin to embed it (`Content-Security-Policy: frame-ancestors`)
501
548
  and allow the page origin in the Strapi admin CSP (`frame-src`).
@@ -507,12 +554,16 @@ Minimal configuration:
507
554
  other one and the page then never hydrates, so `ready` never arrives and
508
555
  the pane reports the preview as unavailable with no error in either console.
509
556
 
510
- The bridge only exposes what the schema allows: attributes marked `private`
511
- are never projected, focused or edited; media URLs are passed through for any
512
- http(s) host (S3/CDN providers included) and same-origin paths; the zone shown
513
- is the first Dynamic Zone the user may read, and editing additionally needs the
514
- update permission on it. Pending dialogs are dropped when the document or
515
- locale changes.
557
+ The bridge only exposes what the schema and the current user's read permissions
558
+ allow. Attributes marked with Strapi's `private: true`, passwords, and
559
+ attributes with `pluginOptions.blockscene.private: true` are never projected,
560
+ focused or edited; the Blockscene option is useful for keeping a field out of
561
+ the preview without changing its public API behavior. This privacy rule also
562
+ applies inside components. Media URLs are passed through for any http(s) host
563
+ (S3/CDN providers included) and same-origin paths; the zone shown is the first
564
+ Dynamic Zone the user may read, and editing additionally needs the update
565
+ permission on it. Pending dialogs are dropped when the document or locale
566
+ changes.
516
567
 
517
568
  Editing from the page: plain-text areas the page explicitly maps
518
569
  (`data-block-field` + `contenteditable="plaintext-only"`) send `edit`. In the
@@ -551,7 +602,8 @@ blocks use the native insertion at a position. Differences:
551
602
  ### Pane toolbar
552
603
 
553
604
  Which controls the toolbar shows, and in which order, is `previewToolbar`:
554
- `modes` (Fields, Fields + page, Visual editor), `history` (Undo, Redo),
605
+ `modes` (Fields only, Fields + preview, Visual editor), `history` (Undo, Redo),
606
+ `versions` (the version history drawer, Strapi 5),
555
607
  `devices` (the width menu), `status` (Draft/Modified/Published and the unsaved
556
608
  hint) and `actions` (Save, Publish). A missing id is hidden; `status` and
557
609
  `actions` stay one group on the right, placed where the first of them is
@@ -974,11 +1026,47 @@ from what the document has now; fields the editor may not update, fields the
974
1026
  schema no longer has, blocks whose component is no longer allowed, and media or
975
1027
  related entries that no longer exist are left out and listed.
976
1028
 
1029
+ **Visual editor history (Phase 1).** The preview toolbar's `versions` control
1030
+ opens a drawer on the right. It is separate from `history` (Undo/Redo). If
1031
+ you already configured `previewToolbar`, add `versions` to that list or enable
1032
+ it in Settings. Versions are grouped by local calendar day, with local date
1033
+ and time, actor, action, and captured counts: total top-level Dynamic Zone rows
1034
+ (including group markers), added, removed and changed against the preceding
1035
+ snapshot in that locale. Older or unrecorded events show counts as unavailable;
1036
+ they are not retroactively counted as zero. The actor filter includes only
1037
+ people/tokens recorded for this document and locale. Lists use server pagination
1038
+ (25 per page) and mark events whose snapshots are no longer available.
1039
+
1040
+ Selecting an event hydrates its retained snapshot into a separate, read-only
1041
+ preview. It never calls the form's `setValues`, saves, publishes or restores
1042
+ anything. The banner identifies the version and returns to the current draft,
1043
+ including unsaved changes. Fast selections, returning while a load is pending,
1044
+ and document/locale/permission changes invalidate old responses. The pre-existing
1045
+ side-panel "Load this version" action remains available; restoration and visual
1046
+ diff enhancements are separate phases.
1047
+
1048
+ The parent rejects every mutation, selection, focus and hover message while
1049
+ viewing a version. Each version changes the iframe channel, so delayed messages
1050
+ cannot target the current draft after returning. The `update-page` message adds
1051
+ `readOnly: true`, sends no editable field/media descriptors and no clipboard.
1052
+ The reference bridge in `examples/page-preview` supports this flag, removes
1053
+ editing/insertion controls, and announces `capabilities: ['readOnly']` in `ready`.
1054
+ Custom bridges should do the same and refuse to queue or send edits when
1055
+ read-only. An older bridge can still render the snapshot, but the admin disables
1056
+ iframe interaction (including in-frame scrolling) and explains that it needs an
1057
+ update. Parent-side protection applies regardless of bridge support. The existing
1058
+ `hover` protocol highlights; it does not promise scroll-to-block behavior.
1059
+
1060
+ The drawer button also explains whether history is disabled/not configured for
1061
+ the type, the entry needs its first save, or `history.read` is missing. Permission
1062
+ changes require an administrator; this control cannot grant access.
1063
+
977
1064
  **Permission.** `Blockscene: Read version history` (`history.read`), plus read
978
1065
  access to the content type in the Content Manager. Snapshots hold removed and
979
1066
  unpublished text, so the section is hidden without it. Admin API:
980
- `GET /blockscene/history/:uid/:documentId?locale=` (the latest 100 events, no
981
- snapshots) and `GET /blockscene/history-events/:id` (one event, its snapshot and
1067
+ `GET /blockscene/history/:uid/:documentId?locale=&page=1&pageSize=25&actor=`
1068
+ (no snapshots; `results`, `pagination`, scoped `actors` and resolved `locale`)
1069
+ and `GET /blockscene/history-events/:id` (one event, its snapshot and
982
1070
  the media and relation targets that still exist).
983
1071
 
984
1072
  **Retention.** Snapshots are kept `retentionDays` (90) and at most
@@ -987,6 +1075,10 @@ kept `eventDays` (365, at least `retentionDays`). A cron job added by the plugin
987
1075
  runs nightly at 03:00 server time, in batches of 500; it only empties snapshots
988
1076
  and deletes events, never media files, and running it on several instances is
989
1077
  harmless.
1078
+ These are configurable limits, not a guarantee that a version from a week ago
1079
+ still exists: frequent changes can exceed `maxSnapshots` earlier. The snapshot
1080
+ cap is per document across locales; event metadata may outlive its snapshot.
1081
+ Naming versions and protecting them from purge are not implemented in Phase 1.
990
1082
 
991
1083
  ```js
992
1084
  // config/plugins.js
@@ -1201,6 +1293,7 @@ uploads share an origin.
1201
1293
  - `tests/`: runnable regression checks.
1202
1294
  - [Local integration tests](docs/LOCAL-TESTING.md).
1203
1295
  - [Release checklist](docs/RELEASE.md).
1296
+ - [Prioritized roadmap](docs/ROADMAP.md).
1204
1297
 
1205
1298
  This plugin does not require Image Optimization; both can be installed together.
1206
1299