Go to file
Takagi 21db06a507
refactor: editor code block to be extensible by plugins (#6428)
#### What type of PR is this?

/kind improvement
/area editor
/area ui

#### What this PR does / why we need it:

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

具体做了以下几处重构:

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

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

<img width="1067" alt="image" src="https://github.com/user-attachments/assets/f9e2c5eb-a48a-4d2c-9fee-442e9d16ef19">

#### How to test it?

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

#### Does this PR introduce a user-facing change?
```release-note
重构默认编辑器代码块使其能够被插件扩展。
```
2024-08-26 02:55:13 +00:00
.devcontainer Add devcontainer support (#6252) 2024-07-10 10:21:25 +00:00
.github chore: update github issue templates (#6457) 2024-08-12 08:22:53 +00:00
api Fix the problem that roles could not be granted sometimes (#6471) 2024-08-21 03:22:50 +00:00
api-docs/openapi/v3_0 Add support for restoring from backup root 2024-08-21 11:45:49 +08:00
application Respond not found if no theme template found (#6511) 2024-08-26 02:47:12 +00:00
buildSrc Support publishing to maven central repository (#3767) 2023-04-18 14:28:23 +08:00
config/checkstyle chore: add checkstyle rule (#2091) 2022-05-17 06:46:11 +00:00
docs Add before and after security web filters (#6297) 2024-07-09 14:05:24 +00:00
e2e chore: upgrade api-testing to v0.0.17 (#6253) 2024-07-02 15:21:24 +00:00
gradle/wrapper Upgrade to Gradle 8.8 (#6033) 2024-06-03 15:05:45 +00:00
hack chore: add cherry_pick_pull.sh for cherry-picking pull request (#1554) 2021-12-03 10:21:24 +08:00
platform feat: add file size and type restriction for local file uploads (#6390) 2024-08-01 01:58:12 +00:00
ui refactor: editor code block to be extensible by plugins (#6428) 2024-08-26 02:55:13 +00:00
.dockerignore chore: rename console to ui in some files (#5347) 2024-02-07 14:40:08 +00:00
.editorconfig Support backup and restore (#4206) 2023-07-24 08:26:16 +00:00
.gitattributes Refactor .gitignore 2019-04-03 11:37:59 +08:00
.gitignore test: add e2e test cases of user, role, and plugin (#4920) 2023-11-28 21:52:44 +08:00
.gitpod.yml test: add e2e test cases of user, role, and plugin (#4920) 2023-11-28 21:52:44 +08:00
CODE_OF_CONDUCT.md docs: add CODE_OF_CONDUCT.md (#2150) 2022-06-12 08:10:12 +00:00
CONTRIBUTING.md docs: update the branch name from `master` to `main` in contribution.md (#5359) 2024-02-17 08:00:15 +00:00
Dockerfile chore: specify expose port in dockerfile (#5820) 2024-04-29 10:37:26 +00:00
LICENSE Create LICENSE 2018-03-21 21:39:46 +08:00
OWNERS chore: update reviewers for OWNERS file (#5672) 2024-04-09 15:22:09 +00:00
README.md chore: update afdian url (#6441) 2024-08-05 03:24:24 +00:00
SECURITY.md Mark the security policy for version 1.x as unsupported (#5450) 2024-03-06 06:06:07 +00:00
build.gradle Upgrade Spring Boot to 3.3.3 (#6512) 2024-08-26 02:51:13 +00:00
gradle.properties Prepare for developing 2.19.0 (#6429) 2024-08-02 04:56:14 +00:00
gradlew Upgrade Gradle to 8.6 (#5533) 2024-03-20 12:32:07 +00:00
gradlew.bat Upgrade to Gradle 8.8 (#6033) 2024-06-03 15:05:45 +00:00
settings.gradle Add build script for ui project 2024-02-03 22:51:50 +08:00

README.md

Halo logo

Halo [ˈheɪloʊ],强大易用的开源建站工具。

GitHub release Docker pulls GitHub last commit GitHub Workflow Status Codecov percentage Halo - Powerful and easy-to-use Open-Source website building tool | Product Hunt
官网 文档 社区 Gitee Telegram 频道

Watch the video


快速开始

docker run -d --name halo -p 8090:8090 -v ~/.halo2:/root/.halo2 halohub/halo:2.18

以上仅作为体验使用,详细部署文档请查阅:https://docs.halo.run/getting-started/install/docker-compose

在线体验

生态

可访问 官方应用市场awesome-halo 仓库 查看适用于 Halo 2.x 的主题和插件。

许可证

license

Halo 使用 GPL-v3.0 协议开源,请遵守开源协议。

赞助

如果 Halo 对你有帮助,欢迎赞助我们,感谢以下赞助者对 Halo 项目的支持:

sponsors

贡献

参考 CONTRIBUTING

状态

Repobeats analytics