@aduptive/strapi-blockscene 2.0.0-alpha.5 → 2.0.0-alpha.6
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 +143 -5
- package/dist/admin.cjs +1196 -320
- package/dist/admin.mjs +1194 -317
- package/dist/server.cjs +514 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,10 +172,14 @@ block).
|
|
|
172
172
|
|
|
173
173
|
**The hidden attribute is a database column.** At register time the plugin adds
|
|
174
174
|
a boolean attribute (like i18n adds `locale`) to every component used in a
|
|
175
|
-
Dynamic Zone: `{ type: 'boolean', default: false,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
Dynamic Zone: `{ type: 'boolean', default: false, configurable: false }`, so
|
|
176
|
+
Strapi's schema sync creates a `bs_hidden` column in each of those component
|
|
177
|
+
tables on the next start (existing rows read as not hidden). It is never shown
|
|
178
|
+
as an input: the plugin removes it from the components' edit layouts through
|
|
179
|
+
the Content Manager's layout hook (it may be listed in "Configure the view" of
|
|
180
|
+
a component; leave it out of the layout). It is not marked `visible: false`,
|
|
181
|
+
because before Strapi 5.45 the edit view crashes on a value whose attribute the
|
|
182
|
+
admin does not know. Rename it with the plugin config
|
|
179
183
|
`hiddenAttribute: 'myName'`, or set `hiddenAttribute: false` to add nothing (no
|
|
180
184
|
eye, nothing stripped). A component that already has an attribute of that name
|
|
181
185
|
with another type is skipped with a warning. Removing the plugin (or setting
|
|
@@ -218,6 +222,8 @@ needed for the gallery to pick them up. Reading requires the
|
|
|
218
222
|
typology ("Automatic" shows the guess) and tags (comma separated).
|
|
219
223
|
- Editor preferences: enhancements on/off, visibility of each collective
|
|
220
224
|
button, initial accordion state and the initial block mode.
|
|
225
|
+
- Version history (Strapi 5): module switch, covered content types, retention
|
|
226
|
+
(see "Version history").
|
|
221
227
|
- Content types: every project type with a Dynamic Zone, each with on/off
|
|
222
228
|
(off leaves its edit view fully native) and, on Strapi 5, the mode its edit
|
|
223
229
|
views open in ("Default" follows the global preview mode) and its visual
|
|
@@ -284,6 +290,7 @@ ignored (boot continues). `GET /blockscene/settings` returns them as
|
|
|
284
290
|
| Duplicate on each block (`duplicate`) | yes/no | yes |
|
|
285
291
|
| Copy and Paste (`clipboard`) | yes/no | yes |
|
|
286
292
|
| Blocks hidden on the site (`hiddenBlocks`) | `strip` / `flag` / `off` | `strip` |
|
|
293
|
+
| Friendly field labels (`friendlyLabels`, see [Field labels](#field-labels)) | yes/no | yes |
|
|
287
294
|
|
|
288
295
|
Every edit view opens in its content type's mode, else the initial preview
|
|
289
296
|
mode. Editors can switch while they edit; the switch is not remembered.
|
|
@@ -484,6 +491,137 @@ With a valid map:
|
|
|
484
491
|
Configured groups are stored exactly as before: the flat list of components in
|
|
485
492
|
the zone. Removing the config only removes the group tools and the guard.
|
|
486
493
|
|
|
494
|
+
## Field labels
|
|
495
|
+
|
|
496
|
+
The Content Manager shows each field under its "Configure the view" label, which
|
|
497
|
+
defaults to the raw attribute name (`mobileColumnsCount`). Blockscene rewrites
|
|
498
|
+
the edit view labels, hints and placeholders through the Content Manager's own
|
|
499
|
+
`Admin/CM/pages/EditView/mutate-edit-view-layout` hook (Strapi 5 and 4, the
|
|
500
|
+
same hook the i18n plugin uses), so nothing in the DOM is patched and the
|
|
501
|
+
saved view configuration is never changed. Per field, the first that applies:
|
|
502
|
+
|
|
503
|
+
1. **Project texts** from the plugin config `fields` (below);
|
|
504
|
+
2. **a label set in "Configure the view"** (anything other than the attribute name);
|
|
505
|
+
3. **the humanized name** when "Friendly field labels" is on: `mobileColumnsCount`
|
|
506
|
+
reads "Mobile columns count", `page_seo` "Page seo", acronym runs stay
|
|
507
|
+
(`pageSEO` "Page SEO", `ctaURL` "Cta URL").
|
|
508
|
+
|
|
509
|
+
Description (the hint under the field) and placeholder change only when the
|
|
510
|
+
project texts have them. Texts follow the admin user's interface language
|
|
511
|
+
(`strapi-admin-language`, else English), resolved as: exact locale, then its
|
|
512
|
+
language (`pt-BR` → `pt`), then any variant of that language, then `en`, then
|
|
513
|
+
the first value.
|
|
514
|
+
|
|
515
|
+
```js
|
|
516
|
+
// config/plugins.js
|
|
517
|
+
blockscene: { config: { fields: {
|
|
518
|
+
'api::page.page': {
|
|
519
|
+
pageSeo: { label: { en: 'Search engine settings', 'pt-BR': 'Configurações de SEO' },
|
|
520
|
+
description: { en: 'Title and description shown on Google', 'pt-BR': 'Título e descrição no Google' } },
|
|
521
|
+
},
|
|
522
|
+
'shared.seo': { metaTitle: { placeholder: 'Up to 60 characters' } },
|
|
523
|
+
} } },
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Keys are content type or component uids, then attribute names; each of
|
|
527
|
+
`label` (up to 80 characters), `description` (300) and `placeholder` (120) is a
|
|
528
|
+
string or `{ "<locale>": string }`. The map is validated at boot: an unknown
|
|
529
|
+
key, an empty or too long text, or a malformed locale code logs a warning
|
|
530
|
+
naming it and the whole `fields` config is ignored (labels fall back to the two
|
|
531
|
+
other steps). Entries for a uid or attribute the schema no longer has (a
|
|
532
|
+
renamed or removed field) are skipped with one warning listing them; the rest
|
|
533
|
+
keep working. It is code only, versioned with the
|
|
534
|
+
project; the Settings page has the on/off switch but does not edit texts.
|
|
535
|
+
|
|
536
|
+
To start the file, generate every field of a project with its humanized English
|
|
537
|
+
label from a clone of this repository, then keep what you want to change:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
node scripts/fields-skeleton.mjs ../my-project/backend > ../my-project/backend/config/blockscene-fields.json
|
|
541
|
+
# config/plugins.js: fields: require('./blockscene-fields.json')
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Limits: the hook runs synchronously and reads the last catalog the admin
|
|
545
|
+
loaded. The first edit or list view of a session starts that request and shows
|
|
546
|
+
native labels; the next layout computed (another document, list → edit, a
|
|
547
|
+
locale switch) has them. Strapi 5 gives the hook no content type uid, so the
|
|
548
|
+
layout is matched by display name and field names; two content types that
|
|
549
|
+
share both are left untouched (component fields always work: they are keyed by
|
|
550
|
+
uid). The switch "Editor enhancements enabled", `BLOCKSCENE_DISABLED` and a
|
|
551
|
+
content type turned off all leave the native labels; any error leaves the
|
|
552
|
+
layout untouched. Changing the interface language applies from the next edit
|
|
553
|
+
view.
|
|
554
|
+
|
|
555
|
+
## Version history (Strapi 5)
|
|
556
|
+
|
|
557
|
+
Off by default. Turn it on in Settings, Blockscene, "Version history" (or from
|
|
558
|
+
code, `settings.history`, see below). Strapi Community has no content history
|
|
559
|
+
(it is a Growth feature); this module records one event per content change and
|
|
560
|
+
keeps a snapshot of the content, so an editor can see what changed and load an
|
|
561
|
+
earlier version back into the form.
|
|
562
|
+
|
|
563
|
+
**What it captures.** Every create, save, publish, unpublish, discard draft and
|
|
564
|
+
delete of the covered content types (all `api::` types by default, or a list)
|
|
565
|
+
made through Strapi's document service: the admin (single and bulk actions),
|
|
566
|
+
the REST and GraphQL APIs, and any plugin or custom code that uses
|
|
567
|
+
`strapi.documents`. One event per affected locale, with who (admin user, API
|
|
568
|
+
token, Users & Permissions user, or `system`), when, the action and a summary
|
|
569
|
+
(blocks added, removed and changed per Dynamic Zone, top-level fields changed)
|
|
570
|
+
against the previous snapshot of the same locale. The snapshot is the stored
|
|
571
|
+
entry with components and Dynamic Zones in full, relations as documentIds and
|
|
572
|
+
media as file ids (a 34-block page is a few KB; the capture adds a few
|
|
573
|
+
milliseconds to a save). A snapshot identical to the previous one is not stored
|
|
574
|
+
again (the event is, with the same hash).
|
|
575
|
+
|
|
576
|
+
**What it does not see.** Writes that bypass the document service: raw
|
|
577
|
+
`strapi.db.query`, knex or SQL, imports that write the database directly. This
|
|
578
|
+
is content activity for editors, not a security audit log.
|
|
579
|
+
|
|
580
|
+
**Failure policy.** A failed capture never blocks a save or a publish: the
|
|
581
|
+
change goes through, the error is logged and the event is marked "Not
|
|
582
|
+
recorded". A failed capture fails a delete: the delete runs in one transaction
|
|
583
|
+
with its events, so nothing is deleted without its last version (a bulk delete
|
|
584
|
+
is rolled back whole). `BLOCKSCENE_DISABLED=true` or the module switch off stop
|
|
585
|
+
all capture. The plugin never records its own content types.
|
|
586
|
+
|
|
587
|
+
**In the edit view.** The Blockscene side panel gets a History section (saved
|
|
588
|
+
documents of covered types, also on types without a Dynamic Zone): the
|
|
589
|
+
versions of the document in the current locale, newest first. Selecting one
|
|
590
|
+
shows a block-level diff against the form (relations are not compared) and
|
|
591
|
+
"Load this version", which puts the version into the form the way undo does:
|
|
592
|
+
nothing is written until the editor saves, so validation, permissions and
|
|
593
|
+
lifecycles apply as for any edit, and undo reverts the load. Components and
|
|
594
|
+
blocks come back as new rows; relations become the connect/disconnect change
|
|
595
|
+
from what the document has now; fields the editor may not update, fields the
|
|
596
|
+
schema no longer has, blocks whose component is no longer allowed, and media or
|
|
597
|
+
related entries that no longer exist are left out and listed.
|
|
598
|
+
|
|
599
|
+
**Permission.** `Blockscene: Read version history` (`history.read`), plus read
|
|
600
|
+
access to the content type in the Content Manager. Snapshots hold removed and
|
|
601
|
+
unpublished text, so the section is hidden without it. Admin API:
|
|
602
|
+
`GET /blockscene/history/:uid/:documentId?locale=` (the latest 100 events, no
|
|
603
|
+
snapshots) and `GET /blockscene/history-events/:id` (one event, its snapshot and
|
|
604
|
+
the media and relation targets that still exist).
|
|
605
|
+
|
|
606
|
+
**Retention.** Snapshots are kept `retentionDays` (90) and at most
|
|
607
|
+
`maxSnapshots` (100) per document, newest first; events without a snapshot are
|
|
608
|
+
kept `eventDays` (365, at least `retentionDays`). A cron job added by the plugin
|
|
609
|
+
runs nightly at 03:00 server time, in batches of 500; it only empties snapshots
|
|
610
|
+
and deletes events, never media files, and running it on several instances is
|
|
611
|
+
harmless.
|
|
612
|
+
|
|
613
|
+
```js
|
|
614
|
+
// config/plugins.js
|
|
615
|
+
blockscene: { config: { settings: { history: { enabled: true, contentTypes: ['api::page.page', 'api::post.post'],
|
|
616
|
+
retentionDays: 90, maxSnapshots: 100, eventDays: 365 } } } }
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
Events live in the `blockscene_events` table (content type
|
|
620
|
+
`plugin::blockscene.event`, hidden from the Content Manager and the Content-Type
|
|
621
|
+
Builder). Removing the plugin, or installing a Blockscene version older than
|
|
622
|
+
the one that added history, lets Strapi drop that table and every recorded
|
|
623
|
+
version on the next start: back up `blockscene_events` first if you need it.
|
|
624
|
+
|
|
487
625
|
## Languages
|
|
488
626
|
|
|
489
627
|
All plugin chrome (gallery, settings, page preview, editor dialogs, diagnostics)
|
|
@@ -584,7 +722,7 @@ uploads share an origin.
|
|
|
584
722
|
## Development
|
|
585
723
|
|
|
586
724
|
- `admin/`: shared gallery, settings page, wireframes and version-specific adapters.
|
|
587
|
-
- `server/`: settings store, validation, permissions, the catalog endpoint and the layout-group publish guard (`groups.js` is shared with the admin).
|
|
725
|
+
- `server/`: settings store, validation, permissions, the catalog endpoint and the layout-group publish guard (`groups.js` is shared with the admin); `history.js` and `diff.js` for version history (`diff.js` is shared with the admin).
|
|
588
726
|
- `admin/translations/`: one flat catalogue per admin locale (English is the source of truth).
|
|
589
727
|
- `scripts/capture-previews.mjs`: local thumbnail capture.
|
|
590
728
|
- `packages/strapi4`, `packages/strapi5`: independently installable distributions.
|