@aduptive/strapi-blockscene 2.0.0-alpha.7 → 2.0.0-alpha.8
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 +146 -21
- package/dist/admin.cjs +1803 -1155
- package/dist/admin.mjs +1766 -1118
- package/dist/server.cjs +145 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Blockscene for Strapi
|
|
2
2
|
|
|
3
3
|
A visual gallery for the components already allowed in a native Dynamic Zone,
|
|
4
|
-
with configurable thumbnails, SVG wireframes, editor preferences and
|
|
5
|
-
|
|
4
|
+
with configurable thumbnails, SVG wireframes, editor preferences and a
|
|
5
|
+
whole-page preview that edits the form through your own frontend.
|
|
6
6
|
No renderer, framework or content migration is required.
|
|
7
7
|
|
|
8
8
|
**Alpha.** Published as pre-releases; APIs, settings and the preview bridge may
|
|
@@ -64,7 +64,7 @@ Right beside the native zone label ("blocks (3)") each zone gets a short bar:
|
|
|
64
64
|
both off there is no button.
|
|
65
65
|
- **Undo and Redo** (Strapi 5, first zone only): icon and text, the shortcut in
|
|
66
66
|
the tooltip. See [Undo and redo](#undo-and-redo).
|
|
67
|
-
- **Editing mode** (
|
|
67
|
+
- **Editing mode** (first zone only, when a preview route exists): a
|
|
68
68
|
menu with Fields, Fields + page and Visual editor. Without a preview route the
|
|
69
69
|
menu is not shown; Settings, Blockscene says why.
|
|
70
70
|
- **"…" (More actions)**: Select blocks, and "Paste N blocks" while the
|
|
@@ -104,8 +104,9 @@ The modal is a block browser (80vw wide):
|
|
|
104
104
|
under `prefers-reduced-motion: reduce`. The panel shows a large live preview
|
|
105
105
|
with Fit / Mobile / Tablet / Desktop widths (scaled to fit, as in the page
|
|
106
106
|
preview) and a compact strip: label, uid, description, badges, fields (on
|
|
107
|
-
demand),
|
|
108
|
-
inserts without it
|
|
107
|
+
demand), the variant choice (see [Insert variants](#insert-variants)), star
|
|
108
|
+
and Insert. Double click, "+" or Enter on a focused card inserts without it
|
|
109
|
+
(the first variant, when the block has variants).
|
|
109
110
|
|
|
110
111
|
The magnified preview shows the card's thumbnail at once and fades the live
|
|
111
112
|
page in over it once it has loaded. Live source, first match wins:
|
|
@@ -113,14 +114,16 @@ page in over it once it has loaded. Live source, first match wins:
|
|
|
113
114
|
1. **Block preview URL** (`editor.blockPreviewUrl`, Settings, both versions):
|
|
114
115
|
a plain page per block in a plain iframe, no bridge. Placeholders, URL
|
|
115
116
|
encoded: `{uid}`, `{name}` (after the dot), `{category}` (before the dot),
|
|
116
|
-
`{variant}` (
|
|
117
|
-
type is not
|
|
117
|
+
`{variant}` (the chosen [insert variant](#insert-variants)'s id, else
|
|
118
|
+
`default`) and `{locale}` (the entry's locale, empty when the type is not
|
|
119
|
+
localized). Example:
|
|
118
120
|
`http://localhost:3026/{locale}/block-preview/{name}/{variant}`. Such a
|
|
119
121
|
fixtures route is usually dev-only: leave the option empty on production.
|
|
120
|
-
2. **Page preview route** (
|
|
122
|
+
2. **Page preview route** (the preview route base URL, else on Strapi 5 the
|
|
121
123
|
native Preview origin + `/block-preview/page`): the same bridge as the
|
|
122
|
-
whole-page preview, sent one block made from the
|
|
123
|
-
`preview`. Read-only: every message except `ready`
|
|
124
|
+
whole-page preview, sent one block made from the chosen variant over the
|
|
125
|
+
schema defaults, mode `preview`. Read-only: every message except `ready`
|
|
126
|
+
is ignored.
|
|
124
127
|
3. Otherwise the image only.
|
|
125
128
|
|
|
126
129
|
If the live page neither loads nor says `ready` within 8 s, the image stays
|
|
@@ -157,6 +160,59 @@ label ending with the raw zone name, which Strapi's message carries in every
|
|
|
157
160
|
locale; a zone whose name ends another zone's name (`blocks` and `sub blocks`)
|
|
158
161
|
is the documented limit.
|
|
159
162
|
|
|
163
|
+
### Insert variants
|
|
164
|
+
|
|
165
|
+
A block can offer named presets of its field values, so the editor inserts
|
|
166
|
+
"Hero, dark" instead of the bare schema defaults. Variants come from the
|
|
167
|
+
project's code, never from the Settings page: the plugin config
|
|
168
|
+
`components[uid].variants`, a list of `{ id, label, values }`.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
// config/plugins.js
|
|
172
|
+
components: {
|
|
173
|
+
'blocks.hero': {
|
|
174
|
+
variants: [
|
|
175
|
+
{ id: 'default', label: 'Default', values: {} },
|
|
176
|
+
{ id: 'dark', label: { en: 'Dark', 'pt-BR': 'Escuro' }, values: {
|
|
177
|
+
title: 'Big launch', theme: 'dark',
|
|
178
|
+
link: { text: 'Read more', url: '/news' },
|
|
179
|
+
items: [{ label: 'One' }, { label: 'Two' }],
|
|
180
|
+
} },
|
|
181
|
+
// A frontend fixture works as is: ids, __component, media and relations are dropped.
|
|
182
|
+
{ id: 'cases', label: 'Cases', values: require('../fixtures/hero/cases.json').data },
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- **Choosing**: with two or more variants the magnified block shows them as a
|
|
189
|
+
row of buttons; the live preview follows the choice (`{variant}` in the
|
|
190
|
+
block preview URL, or the variant's block sent through the bridge) and
|
|
191
|
+
Insert inserts it. Double click, "+" and Enter insert the first variant.
|
|
192
|
+
The picker opened from a page preview insertion seam offers the same
|
|
193
|
+
choice. A block without variants behaves as before; Settings, Blockscene
|
|
194
|
+
lists each block's variants read-only.
|
|
195
|
+
- **Merge**: `values` is a partial field map over the schema defaults. A
|
|
196
|
+
nested component merges over its own defaults; a repeatable list replaces
|
|
197
|
+
the default list, each item over the item's defaults. The row goes through
|
|
198
|
+
the same form path as any gallery insert (Strapi 5 `addFieldRow`, Strapi 4
|
|
199
|
+
`addComponentToDynamicZone` then the fields' `onChange`), so nothing is
|
|
200
|
+
saved until Save and undo/redo covers it.
|
|
201
|
+
- **Supported values**, checked against the schema once at boot: text-like
|
|
202
|
+
fields (strings, rich text, email, uid, dates as strings), numbers
|
|
203
|
+
(integers, big integers, floats, decimals), booleans, enumerations (one of
|
|
204
|
+
their values), JSON, blocks (an array) and `null`; nested components,
|
|
205
|
+
single or repeatable (up to the attribute's `max`, and 100), each validated
|
|
206
|
+
against its own schema. Media and relation values are dropped with a boot
|
|
207
|
+
warning: their ids belong to one install and are not checked here. `id` and
|
|
208
|
+
`__component` keys are ignored, so a content-API shaped block works.
|
|
209
|
+
Unknown attributes, passwords and Dynamic Zones reject the variant.
|
|
210
|
+
- **Bounds**: `id` is 1 to 40 of `a-z 0-9 - _`, unique per block (it is the
|
|
211
|
+
`{variant}` URL segment); `label` a string of 1 to 60 characters or
|
|
212
|
+
`{ "<locale>": string }`; at most 12 variants per block, 16 KB of values
|
|
213
|
+
per variant and 256 KB for all of them. An invalid variant is left out with
|
|
214
|
+
a warning naming the problem; the block keeps its valid ones.
|
|
215
|
+
|
|
160
216
|
## Row thumbnails
|
|
161
217
|
|
|
162
218
|
Each added block shows its thumbnail at the left of the native accordion
|
|
@@ -253,13 +309,14 @@ needed for the gallery to pick them up. Reading requires the
|
|
|
253
309
|
and "Restore default colors". Colors must be `#RRGGBB`.
|
|
254
310
|
- Component list with the effective source, choose/replace image from the
|
|
255
311
|
Media Library, "Use automatic image", the wireframe template, the gallery
|
|
256
|
-
typology ("Automatic" shows the guess) and tags (comma separated)
|
|
312
|
+
typology ("Automatic" shows the guess) and tags (comma separated); a group
|
|
313
|
+
OPEN also has its layout grid fields (see [Layout grid](#layout-grid)).
|
|
257
314
|
- Editor preferences: enhancements on/off, visibility of each collective
|
|
258
315
|
button, initial accordion state and the initial block mode.
|
|
259
316
|
- Version history (Strapi 5): module switch, covered content types, retention
|
|
260
317
|
(see "Version history").
|
|
261
318
|
- Content types: every project type with a Dynamic Zone, each with on/off
|
|
262
|
-
(off leaves its edit view fully native)
|
|
319
|
+
(off leaves its edit view fully native), the mode its edit
|
|
263
320
|
views open in ("Default" follows the global preview mode), its visual
|
|
264
321
|
editor sidebar and optionally its own page preview toolbar (see below).
|
|
265
322
|
- "Restore project defaults" (or "Reset to defaults" when the project has no
|
|
@@ -322,16 +379,16 @@ ignored (boot continues). `GET /blockscene/settings` returns them as
|
|
|
322
379
|
| Initial accordion state | all closed / all open / remember | all closed |
|
|
323
380
|
| Load rich-text editors on demand (`lazyEditors`, Strapi 5) | yes/no | yes |
|
|
324
381
|
| Custom fields loaded on demand (`lazyFields`, Strapi 5) | up to 20 uids `plugin::x.y` / `global::x` | `["plugin::ckeditor5.CKEditor"]` |
|
|
325
|
-
| Preview route base URL
|
|
382
|
+
| Preview route base URL | full URL or empty | empty: native Preview origin (Strapi 5; none on Strapi 4) |
|
|
326
383
|
| Block preview URL | http(s) URL with placeholders, up to 500 characters, or empty | empty: page preview route, else image |
|
|
327
|
-
| Initial preview mode
|
|
384
|
+
| Initial preview mode | form / side by side / preview | form |
|
|
328
385
|
| Confirm before deleting a block (`confirmDelete`) | yes/no | yes |
|
|
329
386
|
| Duplicate on each block (`duplicate`) | yes/no | yes |
|
|
330
387
|
| Copy and Paste (`clipboard`) | yes/no | yes |
|
|
331
388
|
| Blocks hidden on the site (`hiddenBlocks`) | `strip` / `flag` / `off` | `strip` |
|
|
332
389
|
| Friendly field labels (`friendlyLabels`, see [Field labels](#field-labels)) | yes/no | yes |
|
|
333
|
-
| Page preview toolbar (`previewToolbar`,
|
|
334
|
-
| Page widths (`previewDevices
|
|
390
|
+
| Page preview toolbar (`previewToolbar`, see [Pane toolbar](#pane-toolbar)) | ordered list of `modes`, `history`, `devices`, `status`, `actions` | all five |
|
|
391
|
+
| Page widths (`previewDevices`) | 1 to 8 of `fit`, `mobile`, `tablet`, `desktop`, `{ label, width }` | the four built-in |
|
|
335
392
|
|
|
336
393
|
Every edit view opens in its content type's mode, else the initial preview
|
|
337
394
|
mode. Editors can switch while they edit; the switch is not remembered.
|
|
@@ -362,9 +419,9 @@ The accordion controls drive the native Dynamic Zone accordions through their
|
|
|
362
419
|
`aria-expanded` headers, so no Strapi source is patched. They are validated on
|
|
363
420
|
the two supported versions only.
|
|
364
421
|
|
|
365
|
-
## Whole-page preview
|
|
422
|
+
## Whole-page preview
|
|
366
423
|
|
|
367
|
-
|
|
424
|
+
Both distributions add a page preview with three modes, chosen from the
|
|
368
425
|
first zone's bar and from the pane toolbar: Fields (form), Fields + page (side
|
|
369
426
|
by side: resizable pane, native actions moved to a bar above the form) and
|
|
370
427
|
Visual editor. It posts the live values of the first Dynamic Zone to a page
|
|
@@ -455,7 +512,30 @@ page updates while you type; Done, Esc or the backdrop put the block back. Side
|
|
|
455
512
|
by side focuses the field in the form on the left instead. Media
|
|
456
513
|
fields open the native Media Library. Everything is validated against the schema
|
|
457
514
|
and the zone's edit permission; a published page never receives unsaved values
|
|
458
|
-
by itself.
|
|
515
|
+
by itself.
|
|
516
|
+
|
|
517
|
+
On Strapi 4 (run on 4.26.1; the edit view APIs it uses are the same in 4.11.0)
|
|
518
|
+
the page preview is the same: the three modes, the same bridge
|
|
519
|
+
(`blockscene:page-preview:v1`, so one frontend route serves both), widths,
|
|
520
|
+
hover sync, the block dialog, the visual editor sidebar, custom panels,
|
|
521
|
+
insertion, groups and paste from the page, and the per content type settings.
|
|
522
|
+
It reads and writes the edit view's own data (`useCMEditViewDataManager`); new
|
|
523
|
+
blocks use the native insertion at a position. Differences:
|
|
524
|
+
|
|
525
|
+
- No undo and redo (no History buttons, no shortcuts). Strapi 4's form has no
|
|
526
|
+
way to set all values at once, and restoring each field would also undo the
|
|
527
|
+
relations it loads lazily, which Save would then disconnect.
|
|
528
|
+
- No native Preview to fall back on: set the preview route base URL.
|
|
529
|
+
- The toolbar's status shows Draft or Published (Strapi 4 has no Modified
|
|
530
|
+
state) and the unsaved hint; its Save and Publish (or Unpublish) click the
|
|
531
|
+
edit view header's own buttons, so their checks and dialogs are Strapi's.
|
|
532
|
+
- The browser smoke covers split mode, select, inline and live edits, widths,
|
|
533
|
+
hover, the block dialog, a sidebar item, media, insertion and toolbar Save
|
|
534
|
+
on 4.26.1; group tools, paste and custom panels from the page share the
|
|
535
|
+
Strapi 5 code and are checked there only.
|
|
536
|
+
- With Strapi 4's two navigation columns the content area is narrower: the
|
|
537
|
+
form keeps at least 520 px, so side by side the page gets less than half on
|
|
538
|
+
a 1440 px screen.
|
|
459
539
|
|
|
460
540
|
### Pane toolbar
|
|
461
541
|
|
|
@@ -528,8 +608,9 @@ every plugin's `register` before any `bootstrap`, then the host's `bootstrap`:
|
|
|
528
608
|
calling `registerPanel` from either bootstrap works. An invalid panel is logged
|
|
529
609
|
(`[blockscene] registerPanel: ...`) and ignored; `registerPanel` returns `true`
|
|
530
610
|
or `false`. A panel that throws while rendering shows the plugin's error notice
|
|
531
|
-
in its drawer; the editor keeps working. Strapi
|
|
532
|
-
|
|
611
|
+
in its drawer; the editor keeps working. On Strapi 4 the same call works (its
|
|
612
|
+
`values` and `onChange` are the edit view data manager's); the lab smoke covers
|
|
613
|
+
panels on Strapi 5 only.
|
|
533
614
|
|
|
534
615
|
### Undo and redo
|
|
535
616
|
|
|
@@ -642,6 +723,50 @@ The edit view draws the same structure over Strapi's native rows (Strapi 5 and
|
|
|
642
723
|
Unclosed groups and stray markers are indented as the page preview shows them
|
|
643
724
|
but have no chevron and are never moved (the diagnostics list them).
|
|
644
725
|
|
|
726
|
+
### Layout grid
|
|
727
|
+
|
|
728
|
+
An OPEN whose component lays its children out in columns (a "grid columns"
|
|
729
|
+
wrapper) can show them that way in the form. Name the OPEN attribute that holds
|
|
730
|
+
its desktop column count, per component, in Settings (the OPEN's card, "Layout
|
|
731
|
+
grid") or in the code `settings`:
|
|
732
|
+
|
|
733
|
+
```json
|
|
734
|
+
{ "components": { "wrappers.grid-columns": { "layout": { "columnsField": "columnsMd", "mobileColumnsField": "columns", "maxColumns": 3 } } } }
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
- `columnsField` (required) and `mobileColumnsField` (optional) must be
|
|
738
|
+
attributes of that component that can hold a count: `integer`, `biginteger`,
|
|
739
|
+
`float`, `decimal`, `string`, or an `enumeration` whose every value is a whole
|
|
740
|
+
number (`["1", "2", "3"]`). `maxColumns` is 1 to 12 (default 12). Checked on
|
|
741
|
+
`PUT` and on the code settings at boot; a saved layout whose attribute was
|
|
742
|
+
removed is dropped on read. A layout on a component that is not a configured
|
|
743
|
+
OPEN does nothing.
|
|
744
|
+
- The count is read live from the OPEN's form: its value, else the attribute's
|
|
745
|
+
default, else 1, capped at `maxColumns` (a value that is not a whole number
|
|
746
|
+
from 1 counts as missing). The grid shows the desktop count; the mobile one is
|
|
747
|
+
named in its caption.
|
|
748
|
+
- Each child is a cell under the OPEN's header (its name and the first text of
|
|
749
|
+
its fields); a nested group is one cell ("N blocks"); the CLOSE stays a row
|
|
750
|
+
below. The children's own rows are hidden but stay mounted, so the form,
|
|
751
|
+
validation, Save and the row tools keep working on them; Expand all skips
|
|
752
|
+
them as it skips a folded group.
|
|
753
|
+
- A cell opens its block's native form in the block dialog (the one of the
|
|
754
|
+
visual editor), in any mode, with every field type. A validation error inside
|
|
755
|
+
a child gives its cell a red border; the dialog shows the field.
|
|
756
|
+
- Reorder by dragging a cell onto another, or with Alt+Arrow keys on a focused
|
|
757
|
+
cell (left/right one cell, up/down one row of the grid); nested groups move
|
|
758
|
+
whole. "Remove from group" in a cell's "…" menu moves the block right after
|
|
759
|
+
the CLOSE. "Add a block" opens the gallery (the zone's allowed components) and
|
|
760
|
+
inserts at the end of the group; an OPEN brings its CLOSE. Each of these is
|
|
761
|
+
one form change: one undo step on Strapi 5, nothing saved before Save.
|
|
762
|
+
- The icon on the OPEN's header switches that group between grid and list (the
|
|
763
|
+
native rows) for the session, per document and group. A folded group shows no
|
|
764
|
+
grid.
|
|
765
|
+
- Dragging a cell out of the grid onto the list is not supported (it would need
|
|
766
|
+
Strapi's own drag and drop): use "Remove from group", or the list view.
|
|
767
|
+
|
|
768
|
+
Strapi 5 and 4 (the block dialog is shared by both since the page preview core).
|
|
769
|
+
|
|
645
770
|
## Field labels
|
|
646
771
|
|
|
647
772
|
The Content Manager shows each field under its "Configure the view" label, which
|