@prenta/plugin-blocks 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.
- package/CHANGELOG.md +226 -0
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/__tests__/BlockSelector.test.d.ts +2 -0
- package/dist/__tests__/BlockSelector.test.d.ts.map +1 -0
- package/dist/__tests__/BlockSelector.test.js +79 -0
- package/dist/__tests__/BlockSelector.test.js.map +1 -0
- package/dist/__tests__/catalog.test.d.ts +2 -0
- package/dist/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/__tests__/catalog.test.js +54 -0
- package/dist/__tests__/catalog.test.js.map +1 -0
- package/dist/__tests__/index.test.d.ts +2 -0
- package/dist/__tests__/index.test.d.ts.map +1 -0
- package/dist/__tests__/index.test.js +37 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/admin/BlockSelector.d.ts +8 -0
- package/dist/admin/BlockSelector.d.ts.map +1 -0
- package/dist/admin/BlockSelector.js +52 -0
- package/dist/admin/BlockSelector.js.map +1 -0
- package/dist/block-types/index.d.ts +9 -0
- package/dist/block-types/index.d.ts.map +1 -0
- package/dist/block-types/index.js +169 -0
- package/dist/block-types/index.js.map +1 -0
- package/dist/collections.d.ts +3 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +2 -0
- package/dist/collections.js.map +1 -0
- package/dist/fields.d.ts +3 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +2 -0
- package/dist/fields.js.map +1 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# @actuate-media/plugin-blocks
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5eea995: Product rename: ActuateCMS is now **Prenta**. Every package moves from the
|
|
8
|
+
`@actuate-media/*` scope to `@prenta/*` with simplified names (`@prenta/core`,
|
|
9
|
+
`@prenta/admin`, `create-prenta`), and version numbers continue from where the
|
|
10
|
+
old scope left off.
|
|
11
|
+
|
|
12
|
+
This is a clean break — no backwards-compat aliases:
|
|
13
|
+
- **npm packages**: `@actuate-media/cms-core` → `@prenta/core`,
|
|
14
|
+
`@actuate-media/cms-admin` → `@prenta/admin`, all other packages keep their
|
|
15
|
+
suffix under `@prenta/*`. `create-actuate-cms` → `create-prenta`
|
|
16
|
+
(`npm create prenta`), `create-actuate-astro` → `create-prenta-astro`.
|
|
17
|
+
CLI bins: `actuate`/`actuate-cms` → `prenta`/`prenta-cms`; `actuate-mcp` →
|
|
18
|
+
`prenta-mcp`.
|
|
19
|
+
- **Database**: migration `0012_rename_to_prenta` renames all 36 `actuate_*`
|
|
20
|
+
tables to `prenta_*` in place (plus prefixed constraints, indexes, and
|
|
21
|
+
sequences). Run `prisma migrate deploy` when upgrading.
|
|
22
|
+
- **Runtime identifiers**: `getActuateConfig` → `getPrentaConfig`,
|
|
23
|
+
`handleActuateAPI` → `handlePrentaAPI`, `ActuateClient` → `PrentaClient`,
|
|
24
|
+
`ActuateDB` → `PrentaDB`, config file `actuate.config.ts` →
|
|
25
|
+
`prenta.config.ts`, CSS scopes `.actuate-admin`/`.actuate-canvas` →
|
|
26
|
+
`.prenta-admin`/`.prenta-canvas`, preview protocol `actuate-preview:*` →
|
|
27
|
+
`prenta-preview:*`, webhook headers `X-Actuate-*` → `X-Prenta-*`, session
|
|
28
|
+
cookie `actuate_session` → `prenta_session`, env vars `ACTUATE_*` →
|
|
29
|
+
`PRENTA_*`, purge route `/api/actuate/purge` → `/api/prenta/purge`.
|
|
30
|
+
- **Sessions and webhooks**: all sessions reset on upgrade (cookie + JWT issuer
|
|
31
|
+
changed); webhook consumers must re-verify signatures against the new
|
|
32
|
+
`X-Prenta-*` headers.
|
|
33
|
+
|
|
34
|
+
The old `@actuate-media/*` packages are deprecated on npm and will receive no
|
|
35
|
+
further releases.
|
|
36
|
+
|
|
37
|
+
## 0.1.0
|
|
38
|
+
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- 98a5149: Remove the inert `enabledBlocks` plugin-config option.
|
|
42
|
+
|
|
43
|
+
`blocksPlugin({ enabledBlocks })` computed a filtered block list and then threw it
|
|
44
|
+
away — `PluginDefinition` has no block-catalog slot, so the option did nothing.
|
|
45
|
+
Block filtering is a `BlockSelector` component prop (unchanged and covered by
|
|
46
|
+
tests). `blocksPlugin()` now takes no arguments; the `BlocksPluginConfig` type is
|
|
47
|
+
removed. (Breaking only for code that passed the no-op option.)
|
|
48
|
+
|
|
49
|
+
## 0.0.16
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- e25cd48: Standardize React peer ranges to `^18.0.0 || ^19.0.0`.
|
|
54
|
+
|
|
55
|
+
Plugin React peer ranges were inconsistent: `plugin-ai`, `plugin-commerce`, and
|
|
56
|
+
`plugin-seo` pinned `react: ^19.2.0` (excluding React 18, which `cms-core`
|
|
57
|
+
supports via `react >=18.0.0`), while the others used `^18.0.0 || ^19.2.0`
|
|
58
|
+
(excluding React 19.0/19.1). Either produced an `ERESOLVE` install failure for
|
|
59
|
+
consumers on the excluded versions. All bundled plugins now declare `react`
|
|
60
|
+
(and `react-dom` where already peered) as `^18.0.0 || ^19.0.0`.
|
|
61
|
+
|
|
62
|
+
## 0.0.15
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- cd8a061: Remove dead sidebar nav from bundled plugins and guard the whole class.
|
|
67
|
+
|
|
68
|
+
`plugin-ai`, `plugin-commerce`, and `plugin-blocks` each advertised
|
|
69
|
+
`adminNavItems` paths (`/ai/*`, `/commerce/*`, `/blocks`) that the admin router
|
|
70
|
+
has no view for — plugins cannot register views, and these plugins register no
|
|
71
|
+
collection backing those paths — so every one of those sidebar links landed on
|
|
72
|
+
the 404 page. The commerce items were also duplicates of the working collection
|
|
73
|
+
nav (its collections already appear under the "Commerce" group at their real
|
|
74
|
+
`/<slug>` routes).
|
|
75
|
+
- Dropped the dead `adminNavItems` from all three plugins. Commerce collections
|
|
76
|
+
remain reachable at `/products`, `/orders`, `/discounts`, …; plugin-ai and
|
|
77
|
+
plugin-blocks are backend/page-builder plugins with no standalone admin route.
|
|
78
|
+
- Added `cms-admin`'s `router/admin-routes` resolver (`adminPathResolves`) plus
|
|
79
|
+
a table-driven test asserting **every** bundled plugin's nav paths resolve to a
|
|
80
|
+
real view, and a drift test that keeps the known-route list in sync with
|
|
81
|
+
`AdminRoot`. This is the systemic guard for a bug class that has now shipped in
|
|
82
|
+
published packages three times.
|
|
83
|
+
|
|
84
|
+
## 0.0.14
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- c231dd0: Add `definePlugin` and migrate all 10 plugins onto the canonical `PluginDefinition` contract.
|
|
89
|
+
|
|
90
|
+
cms-core already exported `PluginDefinition`, but every plugin hand-rolled a
|
|
91
|
+
local `ActuatePlugin` interface — a lossy subset that dropped `version`/`init`
|
|
92
|
+
and, in blocks/email/ai, widened hook payloads to `unknown[]`/`event: string`.
|
|
93
|
+
That's copy-paste drift with no shared source of truth.
|
|
94
|
+
|
|
95
|
+
`cms-core` now exports `definePlugin(plugin: PluginDefinition)` (an identity
|
|
96
|
+
helper like `defineConfig`), and each plugin imports the canonical type instead
|
|
97
|
+
of its own: the local `ActuatePlugin` interfaces are deleted, factory return
|
|
98
|
+
types are `PluginDefinition`, and the widened `hooks.ts` types are retyped as
|
|
99
|
+
`PluginHook[]`. Type-only change — no runtime behavior, plugin `name`, or config
|
|
100
|
+
options changed. Net −69 lines.
|
|
101
|
+
|
|
102
|
+
- 325694f: Import `definePlugin` from the lightweight `@actuate-media/cms-core/config`
|
|
103
|
+
entry instead of the barrel.
|
|
104
|
+
|
|
105
|
+
The plugin-definition migration imported the `definePlugin` **value** from
|
|
106
|
+
`@actuate-media/cms-core`, which pulls the entire cms-core barrel (graphql,
|
|
107
|
+
sharp, sentry, codegen) into every plugin's runtime — bundle bloat for
|
|
108
|
+
consumers and, under parallel test load, a timeout. The `/config` subpath exists
|
|
109
|
+
precisely to avoid the barrel. Types stay as erased `import type`, so nothing
|
|
110
|
+
heavy is loaded. No API or behavior change.
|
|
111
|
+
|
|
112
|
+
## 0.0.13
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- 041a228: Add the MIT `license` field to every published package (previously missing) and correct `repository.url` to `github.com/actuate-media/actuatecms` (13 packages carried the wrong org).
|
|
117
|
+
|
|
118
|
+
## 0.0.12
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- 854152d: Developer experience improvements from external-consumer feedback:
|
|
123
|
+
- Every published package now ships its `CHANGELOG.md` in the npm tarball, and packages that were missing a `README.md` (cli, cms-admin, cms-core, import, platform-vercel, all plugins, sections-react) now have one — so release notes and usage docs are visible on npmjs.com and in `node_modules`.
|
|
124
|
+
- New client-safe form validation entry point: `@actuate-media/cms-core/forms/client` exports `validateFormFieldClient()`, `validateFormValuesClient()`, visibility/conditional helpers, and the exact `FORM_EMAIL_RE` / `FORM_PHONE_RE` regexes the server enforces — zero Node dependencies, so public-site forms can mirror server rules without reimplementing them. The server validator now imports the same primitives, so client and server can never drift.
|
|
125
|
+
|
|
126
|
+
## 0.0.11
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- b5de8dd: Fix ESM module resolution and dependency duplication issues reported during consumer integration.
|
|
131
|
+
- Add "default" export condition to all platform and plugin packages so they resolve correctly from require() contexts (fixes ERR_PACKAGE_PATH_NOT_EXPORTED in next.config.ts and serverless functions).
|
|
132
|
+
- Move @actuate-media/cms-core from direct dependencies to peerDependencies across all packages to prevent duplicate installations when consumer version ranges don't exactly match the pinned version.
|
|
133
|
+
- Add "prepack" lifecycle script to create-actuate-cms to guarantee dist/ is built before npm publishes the package (fixes empty dist/ in v0.4.0).
|
|
134
|
+
|
|
135
|
+
## 0.0.10
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [54c7a3b]
|
|
140
|
+
- @actuate-media/cms-core@0.6.0
|
|
141
|
+
|
|
142
|
+
## 0.0.9
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- Updated dependencies [c08cf8b]
|
|
147
|
+
- Updated dependencies [80aa939]
|
|
148
|
+
- @actuate-media/cms-core@0.5.0
|
|
149
|
+
|
|
150
|
+
## 0.0.8
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- Updated dependencies [f2cf7d7]
|
|
155
|
+
- @actuate-media/cms-core@0.4.0
|
|
156
|
+
|
|
157
|
+
## 0.0.7
|
|
158
|
+
|
|
159
|
+
### Patch Changes
|
|
160
|
+
|
|
161
|
+
- Updated dependencies [0621037]
|
|
162
|
+
- @actuate-media/cms-core@0.3.1
|
|
163
|
+
|
|
164
|
+
## 0.0.6
|
|
165
|
+
|
|
166
|
+
### Patch Changes
|
|
167
|
+
|
|
168
|
+
- Updated dependencies [4e3a5eb]
|
|
169
|
+
- @actuate-media/cms-core@0.3.0
|
|
170
|
+
|
|
171
|
+
## 0.0.5
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- Updated dependencies
|
|
176
|
+
- @actuate-media/cms-core@0.2.3
|
|
177
|
+
|
|
178
|
+
## 0.0.4
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Updated dependencies
|
|
183
|
+
- @actuate-media/cms-core@0.2.2
|
|
184
|
+
|
|
185
|
+
## 0.0.3
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies
|
|
190
|
+
- @actuate-media/cms-core@0.2.1
|
|
191
|
+
|
|
192
|
+
## 0.0.2
|
|
193
|
+
|
|
194
|
+
### Patch Changes
|
|
195
|
+
|
|
196
|
+
- 3fd38a2: Fix all 13 integration issues discovered during MaidPro.co deployment
|
|
197
|
+
|
|
198
|
+
**cms-core:**
|
|
199
|
+
- Add .js extensions to all ESM relative imports (58 files)
|
|
200
|
+
- Replace workspace:\* with versioned deps in all packages
|
|
201
|
+
- Add sideEffects:false for proper tree-shaking
|
|
202
|
+
- Subpath exports (/config, /api, /middleware, /next) avoid barrel side effects
|
|
203
|
+
- Stats/search routes use safeCount/safeFindMany for missing Prisma models
|
|
204
|
+
- Ship prisma/cms-schema.prisma with all required CMS models
|
|
205
|
+
- Accept both CMS_SECRET and CMS_SESSION_SECRET with clear error messages
|
|
206
|
+
- Fix hardcoded /admin paths in OAuth flow (now uses getAdminPath())
|
|
207
|
+
- Loosen withActuateCMS and createCMSMiddleware parameter types
|
|
208
|
+
- Auto-inject transpilePackages and serverExternalPackages in withActuateCMS
|
|
209
|
+
- Unify PluginDefinition with ActuatePlugin interface
|
|
210
|
+
|
|
211
|
+
**cms-admin:**
|
|
212
|
+
- Scope all 40+ CSS theme variables to .actuate-admin instead of :root
|
|
213
|
+
- ThemeProvider applies dark class to .actuate-admin, not document.documentElement
|
|
214
|
+
- Scaffold uses (admin)/(site) route groups for full CSS/script isolation
|
|
215
|
+
- Sidebar branding supports custom logo via config.admin.branding
|
|
216
|
+
|
|
217
|
+
**platform-vercel:**
|
|
218
|
+
- Email adapter accepts both `from` and `defaultFrom`
|
|
219
|
+
|
|
220
|
+
**All plugin/platform packages:**
|
|
221
|
+
- Fix ESM .js extensions in compiled output
|
|
222
|
+
- Replace workspace:\* with ^0.1.0 for publishable deps
|
|
223
|
+
|
|
224
|
+
- Updated dependencies [682dac7]
|
|
225
|
+
- Updated dependencies [3fd38a2]
|
|
226
|
+
- @actuate-media/cms-core@0.2.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Actuate Media
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @prenta/plugin-blocks
|
|
2
|
+
|
|
3
|
+
Reusable content blocks for [Prenta CMS](https://github.com/actuate-media/prenta)
|
|
4
|
+
— define once, reference across documents.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @prenta/plugin-blocks
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { blocksPlugin } from '@prenta/plugin-blocks'
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
plugins: [blocksPlugin()],
|
|
17
|
+
// ...
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Release notes
|
|
22
|
+
|
|
23
|
+
See [CHANGELOG.md](./CHANGELOG.md) (shipped with the package) or the
|
|
24
|
+
[GitHub releases](https://github.com/actuate-media/prenta/releases).
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockSelector.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/BlockSelector.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// @vitest-environment happy-dom
|
|
3
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
4
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
|
+
import { BlockSelector } from '../admin/BlockSelector.js';
|
|
6
|
+
import { builtInBlocks } from '../block-types/index.js';
|
|
7
|
+
// The only interactive controls besides card buttons are the search box (a
|
|
8
|
+
// textbox, not a button), so every button is a block card.
|
|
9
|
+
const cards = () => screen.queryAllByRole('button');
|
|
10
|
+
const searchBox = () => screen.getByPlaceholderText('Search blocks…');
|
|
11
|
+
describe('BlockSelector', () => {
|
|
12
|
+
describe('enabledBlocks prop', () => {
|
|
13
|
+
it('renders exactly the enabled blocks, by name', () => {
|
|
14
|
+
render(_jsx(BlockSelector, { onSelect: vi.fn(), enabledBlocks: ['hero', 'cta'] }));
|
|
15
|
+
expect(screen.getByText('Hero')).toBeTruthy();
|
|
16
|
+
expect(screen.getByText('CTA')).toBeTruthy();
|
|
17
|
+
// A block outside the subset must not render.
|
|
18
|
+
expect(screen.queryByText('Gallery')).toBeNull();
|
|
19
|
+
expect(cards()).toHaveLength(2);
|
|
20
|
+
});
|
|
21
|
+
it('renders the whole built-in catalog when enabledBlocks is omitted', () => {
|
|
22
|
+
render(_jsx(BlockSelector, { onSelect: vi.fn() }));
|
|
23
|
+
// Every built-in label appears at least once (some icons reuse a label
|
|
24
|
+
// string, e.g. the Image block, so match with getAllByText).
|
|
25
|
+
for (const block of builtInBlocks) {
|
|
26
|
+
expect(screen.getAllByText(block.label).length, block.label).toBeGreaterThan(0);
|
|
27
|
+
}
|
|
28
|
+
expect(cards()).toHaveLength(builtInBlocks.length);
|
|
29
|
+
});
|
|
30
|
+
it('distinguishes enabledBlocks={[]} (zero cards) from undefined (all cards)', () => {
|
|
31
|
+
// Truthy-but-empty array filters to nothing and shows the empty state...
|
|
32
|
+
const { unmount } = render(_jsx(BlockSelector, { onSelect: vi.fn(), enabledBlocks: [] }));
|
|
33
|
+
expect(cards()).toHaveLength(0);
|
|
34
|
+
expect(screen.getByText('No blocks match your search.')).toBeTruthy();
|
|
35
|
+
unmount();
|
|
36
|
+
// ...whereas undefined shows the full catalog and no empty state.
|
|
37
|
+
render(_jsx(BlockSelector, { onSelect: vi.fn() }));
|
|
38
|
+
expect(cards()).toHaveLength(builtInBlocks.length);
|
|
39
|
+
expect(screen.queryByText('No blocks match your search.')).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('search filter', () => {
|
|
43
|
+
it('matches block name or label as a case-insensitive substring', () => {
|
|
44
|
+
render(_jsx(BlockSelector, { onSelect: vi.fn() }));
|
|
45
|
+
// 'video' matches name "videoEmbed" / label "Video Embed" and nothing else.
|
|
46
|
+
fireEvent.change(searchBox(), { target: { value: 'video' } });
|
|
47
|
+
expect(cards()).toHaveLength(1);
|
|
48
|
+
expect(screen.getByText('Video Embed')).toBeTruthy();
|
|
49
|
+
// Uppercase term still matches (search is lowercased before comparing).
|
|
50
|
+
fireEvent.change(searchBox(), { target: { value: 'HERO' } });
|
|
51
|
+
expect(cards()).toHaveLength(1);
|
|
52
|
+
expect(screen.getByText('Hero')).toBeTruthy();
|
|
53
|
+
});
|
|
54
|
+
it('applies the search to the enabledBlocks subset, not the full catalog', () => {
|
|
55
|
+
render(_jsx(BlockSelector, { onSelect: vi.fn(), enabledBlocks: ['hero', 'cta'] }));
|
|
56
|
+
// "image" matches Image / Image & Text in the full catalog, but neither is
|
|
57
|
+
// in the {hero, cta} subset, so the composed result is empty.
|
|
58
|
+
fireEvent.change(searchBox(), { target: { value: 'image' } });
|
|
59
|
+
expect(cards()).toHaveLength(0);
|
|
60
|
+
expect(screen.getByText('No blocks match your search.')).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
it('renders the empty state (and no cards) for a non-matching term', () => {
|
|
63
|
+
render(_jsx(BlockSelector, { onSelect: vi.fn() }));
|
|
64
|
+
fireEvent.change(searchBox(), { target: { value: 'zzz' } });
|
|
65
|
+
expect(screen.getByText('No blocks match your search.')).toBeTruthy();
|
|
66
|
+
expect(cards()).toHaveLength(0);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('selection', () => {
|
|
70
|
+
it('invokes onSelect with the block name (not the label) when a card is clicked', () => {
|
|
71
|
+
const onSelect = vi.fn();
|
|
72
|
+
render(_jsx(BlockSelector, { onSelect: onSelect, enabledBlocks: ['hero'] }));
|
|
73
|
+
fireEvent.click(screen.getByText('Hero'));
|
|
74
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
75
|
+
expect(onSelect).toHaveBeenCalledWith('hero');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=BlockSelector.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockSelector.test.js","sourceRoot":"","sources":["../../src/__tests__/BlockSelector.test.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA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AAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;YAC3D,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC,CAAC,UAAU,EAAE,CAAA;YACrE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;YACrF,MAAM,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,CAAA;YACxB,MAAM,CAAC,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,MAAM,CAAC,GAAI,CAAC,CAAA;YACtE,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;YACzC,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;YACzC,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/catalog.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { builtInBlocks } from '../block-types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Data-integrity invariants for the static built-in block catalog. These guard
|
|
5
|
+
* against silent editor breakage — a duplicate block name, a select field whose
|
|
6
|
+
* defaultValue is not one of its options (which would break the editor's default
|
|
7
|
+
* selection), or an array block with no subfields / minRows < 1.
|
|
8
|
+
*/
|
|
9
|
+
describe('builtInBlocks catalog integrity', () => {
|
|
10
|
+
it('has unique block names', () => {
|
|
11
|
+
const names = builtInBlocks.map((b) => b.name);
|
|
12
|
+
expect(new Set(names).size).toBe(names.length);
|
|
13
|
+
});
|
|
14
|
+
it('gives every block a non-empty name, label, icon, and at least one field', () => {
|
|
15
|
+
expect(builtInBlocks.length).toBeGreaterThan(0);
|
|
16
|
+
for (const block of builtInBlocks) {
|
|
17
|
+
expect(block.name.length, `${block.name} name`).toBeGreaterThan(0);
|
|
18
|
+
expect(block.label.length, `${block.name} label`).toBeGreaterThan(0);
|
|
19
|
+
expect(block.icon.length, `${block.name} icon`).toBeGreaterThan(0);
|
|
20
|
+
expect(Object.keys(block.fields).length, `${block.name} fields`).toBeGreaterThan(0);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
it('every select field default is one of its declared option values', () => {
|
|
24
|
+
let checked = 0;
|
|
25
|
+
for (const block of builtInBlocks) {
|
|
26
|
+
for (const [fieldName, field] of Object.entries(block.fields)) {
|
|
27
|
+
if (field.type !== 'select')
|
|
28
|
+
continue;
|
|
29
|
+
if (field.defaultValue === undefined)
|
|
30
|
+
continue;
|
|
31
|
+
checked++;
|
|
32
|
+
const values = field.options.map((o) => o.value);
|
|
33
|
+
expect(values, `${block.name}.${fieldName} default "${String(field.defaultValue)}" absent from options`).toContain(field.defaultValue);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Confirms the invariant was actually exercised (cta.variant, imageText.layout).
|
|
37
|
+
expect(checked).toBeGreaterThanOrEqual(2);
|
|
38
|
+
});
|
|
39
|
+
it('every array field declares minRows>=1 and a non-empty subfield set', () => {
|
|
40
|
+
let checked = 0;
|
|
41
|
+
for (const block of builtInBlocks) {
|
|
42
|
+
for (const [fieldName, field] of Object.entries(block.fields)) {
|
|
43
|
+
if (field.type !== 'array')
|
|
44
|
+
continue;
|
|
45
|
+
checked++;
|
|
46
|
+
expect(field.minRows ?? 0, `${block.name}.${fieldName} minRows`).toBeGreaterThanOrEqual(1);
|
|
47
|
+
expect(Object.keys(field.fields).length, `${block.name}.${fieldName} subfields`).toBeGreaterThan(0);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// testimonials/faq/gallery/stats/cards all use array fields.
|
|
51
|
+
expect(checked).toBeGreaterThanOrEqual(1);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=catalog.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.test.js","sourceRoot":"","sources":["../../src/__tests__/catalog.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEvD;;;;;GAKG;AACH,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC9C,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QAC/C,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;YAClE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE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GAAG,EAAE;QAC5E,IAAI,OAAO,GAAG,CAAC,CAAA;QACf,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9D,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;oBAAE,SAAQ;gBACpC,OAAO,EAAE,CAAA;gBACT,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,SAAS,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;gBAC1F,MAAM,CACJ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAChC,GAAG,KAAK,CAAC,IAAI,IAAI,SAAS,YAAY,CACvC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;YACtB,CAAC;QACH,CAAC;QACD,6DAA6D;QAC7D,MAAM,CAAC,OAAO,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { blocksPlugin } from '../index.js';
|
|
3
|
+
import { builtInBlocks } from '../block-types/index.js';
|
|
4
|
+
import { blocksHooks } from '../hooks.js';
|
|
5
|
+
describe('plugin-blocks', () => {
|
|
6
|
+
describe('structure', () => {
|
|
7
|
+
it('returns name plugin-blocks', () => {
|
|
8
|
+
expect(blocksPlugin().name).toBe('plugin-blocks');
|
|
9
|
+
});
|
|
10
|
+
it('exposes fields, collections, and admin nav', () => {
|
|
11
|
+
const plugin = blocksPlugin();
|
|
12
|
+
expect(plugin.fields).toBeDefined();
|
|
13
|
+
expect(typeof plugin.fields).toBe('object');
|
|
14
|
+
expect(plugin.collections).toBeDefined();
|
|
15
|
+
expect(typeof plugin.collections).toBe('object');
|
|
16
|
+
// No admin nav: the old /blocks link had no backing view (404). The block
|
|
17
|
+
// editor UI is wired into the page builder, not a standalone route.
|
|
18
|
+
// Guarded centrally by cms-admin's plugin-nav-resolves test.
|
|
19
|
+
expect(plugin.adminNavItems).toBeUndefined();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('configuration', () => {
|
|
23
|
+
it('default config keeps the full built-in block catalog available', () => {
|
|
24
|
+
expect(builtInBlocks.length).toBeGreaterThan(0);
|
|
25
|
+
const plugin = blocksPlugin();
|
|
26
|
+
expect(plugin.name).toBe('plugin-blocks');
|
|
27
|
+
expect(plugin.hooks?.length).toBe(blocksHooks.length);
|
|
28
|
+
});
|
|
29
|
+
// Block filtering is a BlockSelector component prop (covered by
|
|
30
|
+
// BlockSelector.test.tsx), not plugin config — PluginDefinition has no
|
|
31
|
+
// block-catalog slot — so the factory intentionally takes no arguments.
|
|
32
|
+
it('takes no config options', () => {
|
|
33
|
+
expect(blocksPlugin).toHaveLength(0);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE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AAyB,EAAE,GAAG,EAAE;YACjC,MAAM,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface BlockSelectorProps {
|
|
2
|
+
onSelect: (blockType: string) => void;
|
|
3
|
+
enabledBlocks?: string[];
|
|
4
|
+
}
|
|
5
|
+
/** Grid-based selector for choosing a block type to insert. */
|
|
6
|
+
export declare function BlockSelector({ onSelect, enabledBlocks }: BlockSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=BlockSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockSelector.d.ts","sourceRoot":"","sources":["../../src/admin/BlockSelector.tsx"],"names":[],"mappings":"AAKA,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,kBAAkB,2CAsD5E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
|
+
import { builtInBlocks } from '../block-types/index.js';
|
|
5
|
+
/** Grid-based selector for choosing a block type to insert. */
|
|
6
|
+
export function BlockSelector({ onSelect, enabledBlocks }) {
|
|
7
|
+
const [search, setSearch] = useState('');
|
|
8
|
+
const availableBlocks = useMemo(() => {
|
|
9
|
+
let blocks = enabledBlocks
|
|
10
|
+
? builtInBlocks.filter((b) => enabledBlocks.includes(b.name))
|
|
11
|
+
: builtInBlocks;
|
|
12
|
+
if (search) {
|
|
13
|
+
const term = search.toLowerCase();
|
|
14
|
+
blocks = blocks.filter((b) => b.name.toLowerCase().includes(term) || b.label.toLowerCase().includes(term));
|
|
15
|
+
}
|
|
16
|
+
return blocks;
|
|
17
|
+
}, [enabledBlocks, search]);
|
|
18
|
+
return (_jsxs("div", { style: { padding: '1rem' }, children: [_jsx("input", { type: "text", placeholder: "Search blocks\u2026", value: search, onChange: (e) => setSearch(e.target.value), style: {
|
|
19
|
+
width: '100%',
|
|
20
|
+
padding: '0.5rem 0.75rem',
|
|
21
|
+
marginBottom: '1rem',
|
|
22
|
+
border: '1px solid #d1d5db',
|
|
23
|
+
borderRadius: '0.375rem',
|
|
24
|
+
fontSize: '0.875rem',
|
|
25
|
+
} }), _jsx("div", { style: {
|
|
26
|
+
display: 'grid',
|
|
27
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))',
|
|
28
|
+
gap: '0.75rem',
|
|
29
|
+
}, children: availableBlocks.map((block) => (_jsx(BlockCard, { block: block, onSelect: onSelect }, block.name))) }), availableBlocks.length === 0 && (_jsx("p", { style: { textAlign: 'center', color: '#6b7280', padding: '2rem 0' }, children: "No blocks match your search." }))] }));
|
|
30
|
+
}
|
|
31
|
+
function BlockCard({ block, onSelect, }) {
|
|
32
|
+
return (_jsxs("button", { type: "button", onClick: () => onSelect(block.name), style: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
justifyContent: 'center',
|
|
37
|
+
gap: '0.5rem',
|
|
38
|
+
padding: '1rem',
|
|
39
|
+
border: '1px solid #e5e7eb',
|
|
40
|
+
borderRadius: '0.5rem',
|
|
41
|
+
background: '#fff',
|
|
42
|
+
cursor: 'pointer',
|
|
43
|
+
transition: 'border-color 0.15s, box-shadow 0.15s',
|
|
44
|
+
}, onMouseEnter: (e) => {
|
|
45
|
+
e.currentTarget.style.borderColor = '#3b82f6';
|
|
46
|
+
e.currentTarget.style.boxShadow = '0 0 0 2px rgba(59,130,246,0.15)';
|
|
47
|
+
}, onMouseLeave: (e) => {
|
|
48
|
+
e.currentTarget.style.borderColor = '#e5e7eb';
|
|
49
|
+
e.currentTarget.style.boxShadow = 'none';
|
|
50
|
+
}, children: [_jsx("span", { style: { fontSize: '1.5rem' }, "aria-hidden": "true", children: block.icon }), _jsx("span", { style: { fontSize: '0.8125rem', fontWeight: 500, color: '#374151' }, children: block.label })] }));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=BlockSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockSelector.js","sourceRoot":"","sources":["../../src/admin/BlockSelector.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,aAAa,EAA4B,MAAM,yBAAyB,CAAA;AAOjF,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAsB;IAC3E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAExC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE;QACnC,IAAI,MAAM,GAAG,aAAa;YACxB,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC7D,CAAC,CAAC,aAAa,CAAA;QAEjB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;YACjC,MAAM,GAAG,MAAM,CAAC,MAAM,CACpB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,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,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAQ;YACvB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,GAAG,EAAE,QAAQ;YACb,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,mBAAmB;YAC3B,YAAY,EAAE,QAAQ;YACtB,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,sCAAsC;SACnD,EACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE;YAClB,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAA;YAC7C,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,GAAG,iCAAiC,CAAA;QACrE,CAAC,EACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE;YAClB,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAA;YAC7C,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAA;QAC1C,CAAC,aAED,eAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAc,MAAM,YACpD,KAAK,CAAC,IAAI,GACN,EACP,eAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,YACtE,KAAK,CAAC,KAAK,GACP,IACA,CACV,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldDefinition } from '@prenta/core';
|
|
2
|
+
export interface BlockTypeDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
fields: Record<string, FieldDefinition>;
|
|
7
|
+
}
|
|
8
|
+
export declare const builtInBlocks: BlockTypeDefinition[];
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block-types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CACxC;AAED,eAAO,MAAM,aAAa,EAAE,mBAAmB,EAuK9C,CAAA"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export const builtInBlocks = [
|
|
2
|
+
{
|
|
3
|
+
name: 'hero',
|
|
4
|
+
label: 'Hero',
|
|
5
|
+
icon: 'Star',
|
|
6
|
+
fields: {
|
|
7
|
+
heading: { type: 'text', label: 'Heading', required: true },
|
|
8
|
+
subheading: { type: 'text', label: 'Subheading' },
|
|
9
|
+
backgroundImage: { type: 'media', label: 'Background Image', accept: ['image/*'] },
|
|
10
|
+
ctaText: { type: 'text', label: 'CTA Text' },
|
|
11
|
+
ctaUrl: { type: 'url', label: 'CTA URL' },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'cta',
|
|
16
|
+
label: 'CTA',
|
|
17
|
+
icon: 'MousePointer',
|
|
18
|
+
fields: {
|
|
19
|
+
heading: { type: 'text', label: 'Heading', required: true },
|
|
20
|
+
description: { type: 'text', label: 'Description' },
|
|
21
|
+
buttonText: { type: 'text', label: 'Button Text', required: true },
|
|
22
|
+
buttonUrl: { type: 'url', label: 'Button URL', required: true },
|
|
23
|
+
variant: {
|
|
24
|
+
type: 'select',
|
|
25
|
+
label: 'Variant',
|
|
26
|
+
options: [
|
|
27
|
+
{ label: 'Primary', value: 'primary' },
|
|
28
|
+
{ label: 'Secondary', value: 'secondary' },
|
|
29
|
+
{ label: 'Outline', value: 'outline' },
|
|
30
|
+
],
|
|
31
|
+
defaultValue: 'primary',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'text',
|
|
37
|
+
label: 'Text',
|
|
38
|
+
icon: 'Type',
|
|
39
|
+
fields: {
|
|
40
|
+
content: { type: 'richText', label: 'Content', required: true },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'image',
|
|
45
|
+
label: 'Image',
|
|
46
|
+
icon: 'Image',
|
|
47
|
+
fields: {
|
|
48
|
+
image: { type: 'media', label: 'Image', accept: ['image/*'], required: true },
|
|
49
|
+
alt: { type: 'text', label: 'Alt Text', required: true },
|
|
50
|
+
caption: { type: 'text', label: 'Caption' },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'imageText',
|
|
55
|
+
label: 'Image & Text',
|
|
56
|
+
icon: 'Columns',
|
|
57
|
+
fields: {
|
|
58
|
+
image: { type: 'media', label: 'Image', accept: ['image/*'], required: true },
|
|
59
|
+
content: { type: 'richText', label: 'Content', required: true },
|
|
60
|
+
layout: {
|
|
61
|
+
type: 'select',
|
|
62
|
+
label: 'Layout',
|
|
63
|
+
options: [
|
|
64
|
+
{ label: 'Image Left', value: 'imageLeft' },
|
|
65
|
+
{ label: 'Image Right', value: 'imageRight' },
|
|
66
|
+
],
|
|
67
|
+
defaultValue: 'imageLeft',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'testimonials',
|
|
73
|
+
label: 'Testimonials',
|
|
74
|
+
icon: 'Quote',
|
|
75
|
+
fields: {
|
|
76
|
+
items: {
|
|
77
|
+
type: 'array',
|
|
78
|
+
label: 'Testimonials',
|
|
79
|
+
minRows: 1,
|
|
80
|
+
fields: {
|
|
81
|
+
quote: { type: 'text', label: 'Quote', required: true },
|
|
82
|
+
author: { type: 'text', label: 'Author', required: true },
|
|
83
|
+
role: { type: 'text', label: 'Role' },
|
|
84
|
+
avatar: { type: 'media', label: 'Avatar', accept: ['image/*'] },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'faq',
|
|
91
|
+
label: 'FAQ',
|
|
92
|
+
icon: 'HelpCircle',
|
|
93
|
+
fields: {
|
|
94
|
+
items: {
|
|
95
|
+
type: 'array',
|
|
96
|
+
label: 'FAQ Items',
|
|
97
|
+
minRows: 1,
|
|
98
|
+
fields: {
|
|
99
|
+
question: { type: 'text', label: 'Question', required: true },
|
|
100
|
+
answer: { type: 'richText', label: 'Answer', required: true },
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'gallery',
|
|
107
|
+
label: 'Gallery',
|
|
108
|
+
icon: 'Grid',
|
|
109
|
+
fields: {
|
|
110
|
+
images: {
|
|
111
|
+
type: 'array',
|
|
112
|
+
label: 'Images',
|
|
113
|
+
minRows: 1,
|
|
114
|
+
fields: {
|
|
115
|
+
image: { type: 'media', label: 'Image', accept: ['image/*'], required: true },
|
|
116
|
+
alt: { type: 'text', label: 'Alt Text', required: true },
|
|
117
|
+
caption: { type: 'text', label: 'Caption' },
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'videoEmbed',
|
|
124
|
+
label: 'Video Embed',
|
|
125
|
+
icon: 'Play',
|
|
126
|
+
fields: {
|
|
127
|
+
url: { type: 'url', label: 'Video URL', required: true },
|
|
128
|
+
title: { type: 'text', label: 'Title' },
|
|
129
|
+
thumbnail: { type: 'media', label: 'Thumbnail', accept: ['image/*'] },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'stats',
|
|
134
|
+
label: 'Stats',
|
|
135
|
+
icon: 'BarChart',
|
|
136
|
+
fields: {
|
|
137
|
+
items: {
|
|
138
|
+
type: 'array',
|
|
139
|
+
label: 'Stats',
|
|
140
|
+
minRows: 1,
|
|
141
|
+
fields: {
|
|
142
|
+
value: { type: 'text', label: 'Value', required: true },
|
|
143
|
+
label: { type: 'text', label: 'Label', required: true },
|
|
144
|
+
prefix: { type: 'text', label: 'Prefix' },
|
|
145
|
+
suffix: { type: 'text', label: 'Suffix' },
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'cards',
|
|
152
|
+
label: 'Cards',
|
|
153
|
+
icon: 'LayoutGrid',
|
|
154
|
+
fields: {
|
|
155
|
+
items: {
|
|
156
|
+
type: 'array',
|
|
157
|
+
label: 'Cards',
|
|
158
|
+
minRows: 1,
|
|
159
|
+
fields: {
|
|
160
|
+
title: { type: 'text', label: 'Title', required: true },
|
|
161
|
+
description: { type: 'text', label: 'Description' },
|
|
162
|
+
image: { type: 'media', label: 'Image', accept: ['image/*'] },
|
|
163
|
+
linkUrl: { type: 'url', label: 'Link URL' },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/block-types/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD;QACE,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE;YACN,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC3D,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;YACjD,eAAe,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,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,EAAE,QAAQ,EAAE,IAAI,EAAE;oBACvD,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE;oBACnD,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE;oBAC7D,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE;iBAC5C;aACF;SACF;KACF;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAyC,EAAE,CAAA"}
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAM,CAAA"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAoC,EAAE,CAAA"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,eAAO,MAAM,WAAW,EAAE,UAAU,EAAO,CAAA"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAiB,EAAE,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PluginDefinition } from '@prenta/core/config';
|
|
2
|
+
/**
|
|
3
|
+
* Factory that creates the blocks plugin.
|
|
4
|
+
*
|
|
5
|
+
* To restrict which block types are offered, pass an `enabledBlocks` prop to the
|
|
6
|
+
* `BlockSelector` admin component — `PluginDefinition` has no block-catalog slot,
|
|
7
|
+
* so filtering can't be threaded through plugin config. This factory takes no
|
|
8
|
+
* options rather than accepting one that silently does nothing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function blocksPlugin(): PluginDefinition;
|
|
11
|
+
export { builtInBlocks } from './block-types/index.js';
|
|
12
|
+
export type { BlockTypeDefinition } from './block-types/index.js';
|
|
13
|
+
export { BlockSelector } from './admin/BlockSelector.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAKzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,gBAAgB,CAW/C;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { definePlugin } from '@prenta/core/config';
|
|
2
|
+
import { blocksFields } from './fields.js';
|
|
3
|
+
import { blocksCollections } from './collections.js';
|
|
4
|
+
import { blocksHooks } from './hooks.js';
|
|
5
|
+
/**
|
|
6
|
+
* Factory that creates the blocks plugin.
|
|
7
|
+
*
|
|
8
|
+
* To restrict which block types are offered, pass an `enabledBlocks` prop to the
|
|
9
|
+
* `BlockSelector` admin component — `PluginDefinition` has no block-catalog slot,
|
|
10
|
+
* so filtering can't be threaded through plugin config. This factory takes no
|
|
11
|
+
* options rather than accepting one that silently does nothing.
|
|
12
|
+
*/
|
|
13
|
+
export function blocksPlugin() {
|
|
14
|
+
return definePlugin({
|
|
15
|
+
name: 'plugin-blocks',
|
|
16
|
+
fields: blocksFields,
|
|
17
|
+
collections: blocksCollections,
|
|
18
|
+
// No adminNavItems: plugin-blocks registers no collections and the admin
|
|
19
|
+
// router has no /blocks view, so the "Block Library" link was a dead 404.
|
|
20
|
+
// The block-editor UI in ./admin is wired into the page builder, not a
|
|
21
|
+
// standalone route. Guarded by cms-admin's plugin-nav-resolves test.
|
|
22
|
+
hooks: blocksHooks,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { builtInBlocks } from './block-types/index.js';
|
|
26
|
+
export { BlockSelector } from './admin/BlockSelector.js';
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyB,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,YAAY;QACpB,WAAW,EAAE,iBAAiB;QAC9B,yEAAyE;QACzE,0EAA0E;QAC1E,uEAAuE;QACvE,qEAAqE;QACrE,KAAK,EAAE,WAAW;KACnB,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prenta/plugin-blocks",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/actuate-media/prenta.git",
|
|
8
|
+
"directory": "packages/plugin-blocks"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"CHANGELOG.md"
|
|
26
|
+
],
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@prenta/core": ">=0.1.0",
|
|
29
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
30
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@testing-library/react": "^16.1.0",
|
|
34
|
+
"@types/react": "^19.0.0",
|
|
35
|
+
"@types/react-dom": "^19.0.0",
|
|
36
|
+
"happy-dom": "^20.9.0",
|
|
37
|
+
"react": "^19.2.0",
|
|
38
|
+
"react-dom": "^19.2.0",
|
|
39
|
+
"typescript": "^5.7.0",
|
|
40
|
+
"vitest": "^4.1.0",
|
|
41
|
+
"@prenta/core": "0.118.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc --project tsconfig.json",
|
|
45
|
+
"type-check": "tsc --noEmit",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"clean": "rm -rf dist .turbo"
|
|
48
|
+
}
|
|
49
|
+
}
|