Skip to content

Conversation

@LIlGG
Copy link
Member

@LIlGG LIlGG commented Oct 17, 2025

What type of PR is this?

/kind improvement
/area editor
/area ui

What this PR does / why we need it:

升级 Tiptap 版本至 3.7.2。

⚠️ 由于 Tiptap 在 3.x 做了一些破坏性更新,并且 Halo 也遵循其更新,对 BubbleMenu 进行了更新,因此当前插件如果扩展了编辑器,并使用了 BubbleMenu,则需要根据以下方式进行更新升级。

  1. 使用 options 代替 tippyOptions
- tippyOptions: {
-  fixed: false,
- },
+ options: {
+  strategy:"absolute",
+ },
  1. 使用 getReferencedVirtualElement 代替 getRenderContainer
- getRenderContainer: (node: HTMLElement) => {
-   let container = node;
-   if (container.nodeName === "#text") {
-     container = node.parentElement as HTMLElement;
-   }
-   while (
-     container &&
-     container.classList &&
-    !container.classList.contains("column")
-   ) {
-     container = container.parentElement as HTMLElement;
-   }
-   return container;
- },
+ getReferencedVirtualElement() {
+  const editor = this.editor;
+   if (!editor) {
+     return null;
+   }
+  const parentNode = findParentNode(
+     (node) => node.type.name === Column.name
+   )(editor.state.selection);
+   if (parentNode) {
+     const domRect = posToDOMRect(
+       editor.view,
+       parentNode.pos,
+       parentNode.pos + parentNode.node.nodeSize
+     );
+     return {
+       getBoundingClientRect: () => domRect,
+       getClientRects: () => [domRect],
+     };
+   }
+   return null;
+ },
  1. 移除 defaultAnimation
- defaultAnimation: false,

此外,更新后,原有插件中扩展已有 Node 的 BubbleMenu 方式将会失效,例如 编辑器超链接卡片 扩展了 Text Node 的 BubbleMenu,因为此前并未支持扩展已实现的 BubbleMenu
在当前 PR 中,为了解决升级版本后失效的问题,引入了 extendsKey 字段,用于扩展已有的 BubbleMenu。(需要已有的 BubbleMenu 设置了 PluginKey。
用法如下:

Extension.create({
    name: "expandTextBubbleMenu",
    addOptions() {
      return {
        getBubbleMenu() {
          return {
            // 目标 BubbleMenu 的 PluginKey。当前版本会导出 Halo UI Editor 中的所有 PluginKey。
            extendsKey: TEXT_BUBBLE_MENU_KEY,
            items: [
              {
                priority: 10,
                // 具有同一个 key 的 items 将会被覆盖
                key: "textItem1",
                props: { title: "ExpandText" },
              },
            ],
          };
        },
      };
    },
  }),

这样当 text 中具有 textItem1 的 item 时,将会被覆盖,没有时将会追加合并。

How to test it?

Does this PR introduce a user-facing change?

升级 Tiptap 至 3.x

@f2c-ci-robot f2c-ci-robot bot added kind/improvement Categorizes issue or PR as related to a improvement. release-note-none Denotes a PR that doesn't merit a release note. area/editor Issues or PRs related to the Editor labels Oct 17, 2025
@f2c-ci-robot f2c-ci-robot bot requested review from JohnNiang and guqing October 17, 2025 04:34
@f2c-ci-robot f2c-ci-robot bot added the area/ui Issues or PRs related to the Halo UI label Oct 17, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 17, 2025

Open in StackBlitz

@halo-dev/api-client

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

@halo-dev/components

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

@halo-dev/richtext-editor

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

@halo-dev/console-shared

npm i https://pkg.pr.new/@halo-dev/console-shared@7811

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

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

commit: 8acc2af

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7811      +/-   ##
============================================
+ Coverage     59.55%   60.36%   +0.80%     
- Complexity     3812     3822      +10     
============================================
  Files           677      677              
  Lines         23248    23080     -168     
  Branches       1500     1496       -4     
============================================
+ Hits          13846    13932      +86     
+ Misses         8764     8483     -281     
- Partials        638      665      +27     

☔ 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.

@ruibaby ruibaby added this to the 2.22.x milestone Oct 17, 2025
@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 17, 2025
@ruibaby
Copy link
Member

ruibaby commented Oct 17, 2025

/hold

需要完整测试一遍

@f2c-ci-robot f2c-ci-robot bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 17, 2025
@LIlGG LIlGG force-pushed the chore/upgrade-tiptap-3 branch from fc35413 to 262de31 Compare October 21, 2025 03:48
@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 21, 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 Oct 22, 2025
@ruibaby
Copy link
Member

ruibaby commented Oct 22, 2025

从 2.22 开始,对于此 PR 这种改动,推荐在 docs.halo.run 的插件开发部分添加版本的 API 变更日志:halo-dev/docs#513

所以建议将 PR 描述中的内容添加到这个文档。

@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 Oct 22, 2025
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 22, 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 Oct 22, 2025
@ruibaby
Copy link
Member

ruibaby commented Oct 22, 2025

/unhold

@f2c-ci-robot f2c-ci-robot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 22, 2025
@f2c-ci-robot f2c-ci-robot bot merged commit da84c6c into halo-dev:main Oct 22, 2025
12 checks passed
@ruibaby ruibaby modified the milestones: 2.22.x, 2.22.0 Oct 22, 2025
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 area/ui Issues or PRs related to the Halo UI kind/improvement Categorizes issue or PR as related to a improvement. 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