feat: per-style schema restrictions#2458
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… during normalization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ir feature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…trictions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Gherkin feature file and browser test for per-style decorator restrictions. Also fix style-change normalization: when the `style` property changes on a text block, dirty the child span paths so the normalizer can strip marks that the new style disallows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 Bundle Stats —
|
| Metric | Value | vs main (ef6daba) |
|---|---|---|
| Internal (raw) | 749.7 KB | +2.6 KB, +0.4% |
| Internal (gzip) | 141.3 KB | +544 B, +0.4% |
| Bundled (raw) | 1.34 MB | +3.6 KB, +0.3% |
| Bundled (gzip) | 301.9 KB | +765 B, +0.2% |
| Import time | 84ms | +2ms, +2.1% |
@portabletext/editor/behaviors
| Metric | Value | vs main (ef6daba) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 2ms | -0ms, -0.9% |
@portabletext/editor/plugins
| Metric | Value | vs main (ef6daba) |
|---|---|---|
| Internal (raw) | 2.5 KB | - |
| Internal (gzip) | 910 B | - |
| Bundled (raw) | 2.3 KB | - |
| Bundled (gzip) | 839 B | - |
| Import time | 7ms | +0ms, +1.1% |
@portabletext/editor/selectors
| Metric | Value | vs main (ef6daba) |
|---|---|---|
| Internal (raw) | 60.5 KB | - |
| Internal (gzip) | 9.5 KB | - |
| Bundled (raw) | 56.9 KB | - |
| Bundled (gzip) | 8.7 KB | - |
| Import time | 6ms | -0ms, -1.1% |
@portabletext/editor/utils
| Metric | Value | vs main (ef6daba) |
|---|---|---|
| Internal (raw) | 24.2 KB | - |
| Internal (gzip) | 4.7 KB | - |
| Bundled (raw) | 22.2 KB | - |
| Bundled (gzip) | 4.4 KB | - |
| Import time | 5ms | -0ms, -0.9% |
🗺️ . · ./behaviors · ./plugins · ./selectors · ./utils · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
|
This looks interesting and relevant and aligns with some of the thoughts I'm having myself: I'm working on first-class nesting where text What I have been thinking about in that regard is how to scope and inherit decorators, annotations, lists and styles, and this PR basically mirrors my thinking:
This means that for a text block in a code block you want to set them all to One thing I've been thinking about in addition, as part of this work, is if it should be possible to define different types of text blocks to thereby scope schema definitions, even at the editor root. But even if that becomes a thing, top-level per-style schema restrictions feel valuable on their own, solve a real problem without inventing a new concept and work out-of-the box with serializers. |
This one might need a bit of discussion, but here goes:
Goal: Allow style definitions in the PTE schema to restrict which decorators, annotations, lists, and inline objects are allowed per block style, so the editor core (toolbar, paste, keyboard shortcuts, normalization) automatically respects these restrictions. This is to for instance disallow links in titles, but allow it in regular text paragraphs.
Architecture: Extend
StyleDefinitionandStyleSchemaTypewith optional decorators, annotations, lists, and inlineObjects override arrays. Add agetStyleFeatures(schema, styleName)helper that returns the effective feature set for a style (the style’s overrides if present, else the top-level schema arrays). Update all schema consumption points to use this helper when the block style is known. The toolbar already has disable/enable infrastructure - wire the availability listener to check per-style restrictions.