Skip to content

Conversation

@LIlGG
Copy link
Member

@LIlGG LIlGG commented Oct 27, 2025

What type of PR is this?

/kind feature
/area editor

What this PR does / why we need it:

添加 figure 功能至 editor 中。

当前会将 figure 应用至 imagevideoaudio 等。

由于 figure 的引入,image 等结构会有一定的变化,将由原先的行内元素转变为块级元素。

更新后,将兼容旧版本 image,打开编辑器后会自动将其转换为带有 figure 父节点的内容。

How to test it?

测试原有的 imagevideoaudio 等功能是否正常可用。
测试 figure-caption 是否正常可用。
测试历史数据是否正常渲染。

Which issue(s) this PR fixes:

Fixes #5388

Does this PR introduce a user-facing change?

编辑器的图片、视频、音频支持添加描述文本

Introduces a new figure extension with caption support for images, audio, and video blocks. Updates image, audio, and video extensions to use figure containers, refactors alignment logic, and improves resizing and caption editing UI. Also updates input styling and localization for figure captions and image load errors.
@f2c-ci-robot f2c-ci-robot bot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. area/editor Issues or PRs related to the Editor labels Oct 27, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

Open in StackBlitz

@halo-dev/api-client

npm i https://pkg.pr.new/@halo-dev/api-client@7875

@halo-dev/components

npm i https://pkg.pr.new/@halo-dev/components@7875

@halo-dev/richtext-editor

npm i https://pkg.pr.new/@halo-dev/richtext-editor@7875

@halo-dev/ui-shared

npm i https://pkg.pr.new/@halo-dev/ui-shared@7875

@halo-dev/ui-plugin-bundler-kit

npm i https://pkg.pr.new/@halo-dev/ui-plugin-bundler-kit@7875

commit: f70009e

Introduces a `visible` prop and logic to various editor components and bubble items, ensuring UI elements only appear when relevant (e.g., when media src is present). Refactors image, audio, and video extensions to use this visibility logic, improves media size handling, and adds ProseMirror plugins for figure auto-deletion and legacy video format migration. Updates styles and localization for enhanced media editing experience.
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.15%. Comparing base (42c374d) to head (f70009e).
⚠️ Report is 278 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7875      +/-   ##
============================================
+ Coverage     59.55%   61.15%   +1.59%     
- Complexity     3812     3933     +121     
============================================
  Files           677      689      +12     
  Lines         23248    23507     +259     
  Branches       1500     1522      +22     
============================================
+ Hits          13846    14376     +530     
+ Misses         8764     8403     -361     
- Partials        638      728      +90     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Replaces InlineBlockBox with node-view-wrapper for audio, image, and video node views, simplifying component structure. Adds keyboard shortcuts and improved placeholder handling for figure captions, and refines figure node validation logic. Updates image and video resizing logic, removes default width/height attributes, and improves resize event handling for better UX.
@f2c-ci-robot f2c-ci-robot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2025
LIlGG added 6 commits October 29, 2025 12:21
Increased priority values for code block and figure caption extensions to ensure correct shortcut handling. Updated the figure extension to use fakeSelection and revised the backspace shortcut logic to utilize RangeSelection for improved selection behavior.
Lowered the priority of the code block extension from 1100 to 900 and removed the priority from the figure caption extension to improve shortcut key handling and extension ordering.
Adjusted extension priorities for code-block, figure, gap-cursor, indent, and paragraph to improve Backspace and selection handling. Moved use-extension composable to a shared location and updated imports. Added a randomUUID utility. Refactored App.vue to use filterDuplicateExtensions for extension management.
Changed the 'content' property of the figure node from 'block+' to 'block+?' to allow the block content to be optional. This provides more flexibility in figure node usage.
Added a check using lodash-es isEmpty to avoid setting align-items style when alignItems attribute is empty. Also removed alignItems from the figure node's style attribute to prevent unintended styling.
@f2c-ci-robot f2c-ci-robot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 30, 2025
@LIlGG LIlGG changed the title WIP: feat: add figure and caption support to editor feat: add figure and caption support to editor Oct 30, 2025
@f2c-ci-robot f2c-ci-robot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 30, 2025
@ruibaby
Copy link
Member

ruibaby commented Nov 3, 2025

进入新建页面会卡死,进入编辑页面不会。

@LIlGG
Copy link
Member Author

LIlGG commented Nov 3, 2025

/hold

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 3, 2025
LIlGG added 5 commits November 4, 2025 15:01
Moved filterDuplicateExtensions from use-extension composable to a standalone utility in utils. Removed use-extension.ts and updated imports across the codebase to use the new utility. Also adjusted Figure extension content definition and cleaned up unused imports.
Updated figure node content model to allow image, video, or audio before captions. Changed figureCaption node to accept only text content. Removed unnecessary paragraph creation in image extension and improved delete/backspace handling in paragraph extension. Also added ExtensionParagraph to presetExtensions in DefaultEditor.vue and removed a debug console.log from App.vue.
Updated audio, image, and video editor components to consistently support percentage-based width and height attributes. Simplified size input logic in bubble menus, removed pixel conversion code, and unified the approach for setting and rendering media sizes. This improves flexibility and consistency for responsive layouts.
Replaced the usage of utils.id.uuid with uuidv7 from the 'uuid' package in filter-duplicate-extensions.ts. Added 'uuid' as a dependency in package.json.
@LIlGG
Copy link
Member Author

LIlGG commented Nov 5, 2025

/unhold

@f2c-ci-robot f2c-ci-robot bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 5, 2025
@f2c-ci-robot f2c-ci-robot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2025
Replaces previous 'alignItems' and 'textAlign' logic with a unified 'position' attribute for figures, images, videos, and audio. Updates Vue components and command handlers to use 'position' for alignment, simplifies related code, and improves consistency across media types. Also introduces a Vue node view for figure captions and updates related styles.
@f2c-ci-robot f2c-ci-robot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2025
@f2c-ci-robot f2c-ci-robot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2025
Adds logic to set the width attribute in newly created figure captions for both image and video extensions, ensuring the caption inherits the width from the corresponding media node. Also imports findChildren utility for node traversal.
@ruibaby ruibaby added this to the 2.22.0 milestone Nov 22, 2025
@sonarqubecloud
Copy link

Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Nov 26, 2025
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ruibaby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 26, 2025
@f2c-ci-robot f2c-ci-robot bot merged commit 558400f into halo-dev:main Nov 26, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/editor Issues or PRs related to the Editor kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

默认编辑器增加图片描述功能

2 participants