✨ feat(content-blocks): add plugin for extracting AI message content blocks#162
Merged
Conversation
…blocks Introduces a write-only ContentBlocksPlugin that converts the current Lexical editor state into a typed sequence of `text` / `image` / `file` content blocks suitable for downstream AI chat pipelines, plus an `extractMediaLists` helper that derives `imageList` / `fileList` arrays from those blocks.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
github-actions Bot
pushed a commit
that referenced
this pull request
May 27, 2026
## [Version 4.13.0](v4.12.0...v4.13.0) <sup>Released on **2026-05-27**</sup> #### ✨ Features - **content-blocks**: Add plugin for extracting AI message content blocks. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's improved * **content-blocks**: Add plugin for extracting AI message content blocks, closes [#162](#162) ([30c1b83](30c1b83)) </details> <div align="right"> [](#readme-top) </div>
Member
|
🎉 This PR is included in version 4.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
ContentBlocksPlugin(parallel to other plugins undersrc/plugins/) that turns the current Lexical state into a typedContentBlock[]—text/image/fileparts — matching the message-part format consumed by lobe-chat's context engine.MarkdownPluginwriter pipeline. Inline images inside paragraphs/headings/quotes are lifted into their own image blocks; root-level atomic nodes are always emitted as standalone blocks.extractMediaLists(blocks)— a pure helper that derives{ imageList, fileList }(with generated ids and extension-inferredfileType) from anyContentBlock[].emitPlaceholderForUnuploaded: falsedrops them silently. Adjacent text blocks are merged with\n\n.API surface
Public exports are wired through
src/index.tsand documented insrc/plugins/content-blocks/index.md.Test plan
vitest run src/plugins/content-blocks— 16 / 16 passing (11 extract + 5 media-lists)eslint src/plugins/content-blocks src/index.ts— cleantsc --noEmit— no errors in the new files (only pre-existing tsconfig deprecation warnings remain)