Move legacy Slate normalization to a paste boundary#155
Open
sneridagh wants to merge 2 commits into
Open
Conversation
Replace the always-on legacy Slate → Plate `normalizeNode` plugins with a
single `insertFragment` boundary normalizer (`LegacyPastePlugin`), and remove
the per-concern runtime plugins from the editor and renderer kits. Server-
delivered content is already migrated by the Aurora middleware, so the only
client-side normalization still needed is for legacy fragments pasted straight
out of a legacy volto-slate editor.
- Add LegacyPastePlugin + normalizeLegacyFragment (editor kits only)
- Remove Legacy{Bold,Italic,Strikethrough,List,Link}Plugin from the kits
(the plugin objects stay exported for potential host reuse)
- Dedupe LegacyLinkPlugin double-registration in the full preset
- Pre-migrate the LegacyLink story via normalizeLegacyValue
- Add unit + acceptance tests and refresh slateToPlate.md
pnicolli
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
At some point, we moved all the normalization and block migration logic to run in the server exclusively. There was some leftovers in the form of PlatePlugins that run in runtime. This is a PR for cleanup. The only use case where they are required are in the "paste" from a slate block (in edit mode) since it's application-slate and it catches it and should be able to run the legacy migrations in this case too.
Legacy Slate → Plate normalization is now a server concern: the Aurora request middleware (
middleware.server.ts→migrateContent) assembles the unified Somersault value and runs every legacy migration before the content reaches the client. That made the per-concern runtime plugins (LegacyBoldPlugin,LegacyItalicPlugin,LegacyStrikethroughPlugin,LegacyListPlugin,LegacyLinkPlugin) redundant — they re-ran migrations on already-normalized data on every edit.This PR removes those always-on
normalizeNode/normalizeInitialValueplugins from the kits and replaces them with a single paste-boundary normalizer.The one case the server cannot cover is a legacy Slate fragment pasted straight out of a legacy
volto-slateeditor (the clipboard carries raw legacy nodes underapplication/x-slate-fragment, which Slate inserts verbatim). This was verified empirically: with the runtime plugins gone, a plain Plate editor left pasted legacy nodes unnormalized, while Aurora (which had the plugins) did not. The newLegacyPastePluginhandles exactly this — once, at the boundary — instead of running five normalizers on every keystroke.What changed
New —
LegacyPastePlugin(legacy-paste-plugin.ts)insertFragment(same pattern assuggestion-core.ts) and runs the static migrations once on the incoming fragment vianormalizeLegacyFragment(editor, fragment).normalizeLegacyValue: bold → italic → strikethrough → links → lists. The link step is editor-aware, so it resolves the configured link type.insertFragment).EditorKit,BlockEditorKit); renderers never paste.Removed the runtime legacy plugins from the kits
basic-marks-kit/basic-marks-base-kit,list-kit/list-base-kit,link-kit/link-base-kit, and cmsui'slink-kit.config/presets/full.ts, which registeredLegacyLinkPlugintwice (explicitly and viaEditorKit→LinkKit).Legacy*Pluginobjects are still exported from their modules (not deleted), so a host such as@kitconcept/volto-platecan opt back into runtime normalization if needed. The staticmigrate*InValuehelpers and the server pipeline are untouched.Story fix — the
LegacyLinkStorybook story fed legacy data straight to the editor/renderer, which no longer self-normalize; it now pre-migrates withnormalizeLegacyValue, mirroring what the server hands over.Docs —
slateToPlate.mdupdated to document the paste boundary and the exported-but-unregistered plugins.Tests
legacy-paste-plugin.test.ts:normalizeLegacyFragment(marks + links + lists, idempotency, no input mutation) and theinsertFragmentoverride.legacy-paste.test.ts: pastes a real legacyvolto-slatefragment (application/x-slate-fragmentcarryingstrong,link.data.url,ul/li) via the editor's owninsertData(the genuine clipboard-decode →insertFragmentpath), and asserts it renders as<a href>, bold, and list content — and that no legacy types survive in the editor value.Results
@plone/plateunit tests@plone/plate+@plone/cmsuitypecheckNotes
normalizeLegacyValue.insertFragmentoverride is typed withanyto match Plate's generic transform signature, consistent withsuggestion-core.ts.