feat: extract @portabletext/html package from block-tools#2225
Draft
christianhg wants to merge 3 commits intomainfrom
Draft
feat: extract @portabletext/html package from block-tools#2225christianhg wants to merge 3 commits intomainfrom
christianhg wants to merge 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 59a42e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
0cf035b to
aba9d66
Compare
Extract HTML-to-Portable Text conversion into a new @portabletext/html
package, mirroring the @portabletext/markdown API pattern.
New package (@portabletext/html):
- htmlToPortableText(html, options?) — schema in options, not positional
- Default schema via compileSchema(defineSchema({...}))
- whitespace option (renamed from unstable_whitespaceOnPasteMode)
- Zero @sanity/* dependencies
- All source code moved from block-tools (HtmlDeserializer, rules,
preprocessors, normalizeBlock, etc.)
- All tests migrated: 134 tests across 22 test files
Legacy adapter (@portabletext/block-tools):
- Thin ~50-line adapter preserving htmlToBlocks(html, schema, options)
- Converts ArraySchemaType → Schema via sanity-bridge
- Maps unstable_whitespaceOnPasteMode → whitespace
- Re-exports everything from @portabletext/html
- 3 adapter tests (Schema, ArraySchemaType, whitespace passthrough)
Editor package:
- Converters import htmlToPortableText from @portabletext/html
- Uses snapshot.context.schema directly (no legacy schema traversal)
- Test imports updated
The HTML test fixtures moved from packages/block-tools/test/ to packages/html/test/. The prettierignore entry needs to match the new location.
The playground resolves workspace packages via Vite aliases to src/. After extracting @portabletext/html, block-tools/rules re-exports from @portabletext/html/rules. Add aliases for both the html package and the block-tools/rules subpath so Vite can resolve them correctly.
aba9d66 to
59a42e7
Compare
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.
Extract HTML-to-Portable Text conversion from
@portabletext/block-toolsinto a new@portabletext/htmlpackage, mirroring the@portabletext/markdownAPI.Block-tools has always been a thin wrapper around code that does not depend on
@sanity/*types. This makes that split explicit: the new package owns the deserializer, rules, preprocessors, and all tests. Block-tools becomes a ~50-line legacy adapter that convertsArraySchemaTypetoSchemaand delegates.Changes:
@portabletext/htmlpackage withhtmlToPortableText(html, options?). Schema moves from positional arg into options.unstable_whitespaceOnPasteModerenamed towhitespace.@portabletext/block-toolsgutted to adapter: preserveshtmlToBlockssignature, re-exports from html package.converter.text-html.ts,converter.text-plain.ts) import from@portabletext/htmldirectly.defineSchema/compileSchemafrom@portabletext/schemainstead of Sanity schema fixtures.