Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: editor code block to be extensible by plugins #6428

Merged
merged 16 commits into from
Aug 26, 2024

Conversation

LIlGG
Copy link
Member

@LIlGG LIlGG commented Aug 1, 2024

What type of PR is this?

/kind improvement
/area editor
/area ui

What this PR does / why we need it:

此 PR 重构了默认编辑器中代码块的相关代码,使编辑器能够被插件扩展。这样做的优点是当用户使用例如 highlightjs 这类的高亮插件时,可以保证在 Console 端选择的语言及主题可以在主题端完美适配。

具体做了以下几处重构:

  1. 在默认编辑器的代码块中,不再提供高亮样式,代码块高亮将完全交由插件来适配。(但可以在默认的代码块中自定义输入语言,主题端自行处理)。
  2. 为了防止出现重复的插件功能,将会根据插件优先级及加载顺序(后加载优先级高于先加载),对同类型且同名的插件进行过滤,只保留一个。
  3. 重构代码块 Select 组件,使得选择语言或主题更加方便。
  4. 为代码块提供主题的扩展设置项。

建议在此 PR 合并之后,由 Halo 默认提供一个高亮插件作为预设插件,这样可以用于解决原有功能升级之后丢失的问题。

image

How to test it?

测试是否会改变已有代码块的语言等。
测试使用第三方插件之后,是否具有高亮。
设置高亮语言后,保存并刷新,查看高亮语言是否存在。主题同理。
查看主题端是否能够正常渲染。

Does this PR introduce a user-facing change?

重构默认编辑器代码块使其能够被插件扩展。

@f2c-ci-robot f2c-ci-robot bot added kind/improvement Categorizes issue or PR as related to a improvement. 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 area/ui Issues or PRs related to the Halo UI labels Aug 1, 2024
@f2c-ci-robot f2c-ci-robot bot requested review from guqing and lan-yonghui August 1, 2024 08:32
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.22%. Comparing base (6cd8dc8) to head (8a48cd6).
Report is 14 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6428      +/-   ##
============================================
+ Coverage     58.18%   58.22%   +0.04%     
- Complexity     3774     3775       +1     
============================================
  Files           651      651              
  Lines         22125    22128       +3     
  Branches       1538     1538              
============================================
+ Hits          12873    12885      +12     
+ Misses         8641     8634       -7     
+ Partials        611      609       -2     

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

Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

/ping @halo-dev/sig-halo-console

Copy link
Member

@guqing guqing 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 Aug 5, 2024
ui/packages/editor/src/extensions/code-block/Select.vue Outdated Show resolved Hide resolved
ui/packages/editor/src/extensions/code-block/Select.vue Outdated Show resolved Hide resolved
ui/packages/editor/src/extensions/code-block/Select.vue Outdated Show resolved Hide resolved
ui/src/components/editor/DefaultEditor.vue Outdated Show resolved Hide resolved
ui/src/components/editor/DefaultEditor.vue Outdated Show resolved Hide resolved
ui/src/components/editor/DefaultEditor.vue Outdated Show resolved Hide resolved
ui/src/components/editor/DefaultEditor.vue Outdated Show resolved Hide resolved
@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 lgtm Indicates that a PR is ready to be merged. labels Aug 5, 2024
@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 Aug 5, 2024
@LIlGG LIlGG requested a review from ruibaby August 5, 2024 06:54
@ruibaby ruibaby added this to the 2.19.x milestone Aug 5, 2024
@guqing
Copy link
Member

guqing commented Aug 23, 2024

有冲突需要解决一下

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 Aug 26, 2024
Copy link
Member

@guqing guqing left a comment

Choose a reason for hiding this comment

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

/lgtm

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.

/approve

Copy link

f2c-ci-robot bot commented Aug 26, 2024

[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 Aug 26, 2024
@f2c-ci-robot f2c-ci-robot bot merged commit 21db06a into halo-dev:main Aug 26, 2024
8 checks passed
@ruibaby ruibaby modified the milestones: 2.19.x, 2.19.0 Aug 26, 2024
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.

4 participants