Go to file
Ryan Wang a396aad87f
feat: add editor extension point (#781)
#### What type of PR is this?

/kind feature

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

添加编辑器的扩展点,用于扩展集成其他编辑器。

定义一个扩展点的方式:

```ts
export default definePlugin({
  extensionPoints: {
    "editor:create": () => {
      return [
        {
          name: "stackedit",
          displayName: "StackEdit",
          component: markRaw(StackEdit),
          rawType: "markdown",
        },
      ];
    },
  },
});
```

其中 `component` 字段即编辑器组件对象,需要包含 `raw`、`content` 的 prop。

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2881

#### Screenshots:

<img width="1664" alt="image" src="https://user-images.githubusercontent.com/21301288/208406097-60258cba-cff6-436f-bd50-6d8c27ea9a53.png">
<img width="1662" alt="image" src="https://user-images.githubusercontent.com/21301288/208406174-d4649365-3448-4581-a452-f9781502eac6.png">
<img width="1920" alt="image" src="https://user-images.githubusercontent.com/21301288/208407570-db10e956-cd6a-4e0d-801e-b794ad0261bc.png">
<img width="1920" alt="image" src="https://user-images.githubusercontent.com/21301288/208407607-fd595957-5278-40c2-a3b5-fb73c1de429c.png">

#### Special notes for your reviewer:

目前可用于测试的插件:

1. [plugin-stackedit-1.0.0-SNAPSHOT.jar.zip](https://github.com/halo-dev/console/files/10258488/plugin-stackedit-1.0.0-SNAPSHOT.jar.zip)
2. [plugin-bytemd-1.0.0-SNAPSHOT.jar.zip](https://github.com/halo-dev/console/files/10258490/plugin-bytemd-1.0.0-SNAPSHOT.jar.zip)

测试方式:

1. Console 需要 `pnpm build:packages`。
2. 在 Console 的插件管理上传以上插件。
3. 新建若干文章,使用不同的编辑器。
4. 检查是否能够正常发布和编辑。
5. 检查编辑的时候,是否正确使用了之前的编辑器。
6. 检查主题端是否渲染正常。

一些实现细节:

1. 为了支持更新文章时能够选择发布时的编辑器,会在 post 的 `metadata.annotations` 添加一条 `content.halo.run/preferred-editor` 用于标记使用的什么编辑器。如果编辑器不存在,会使用 content 的 `rawType` 来匹配。
2. 目前没有全局默认编辑器设置,只能在新建文章的时候选择。

#### Does this PR introduce a user-facing change?

```release-note
Console 端支持扩展集成其他编辑器
```
2022-12-22 04:14:29 +00:00
.changeset refactor: rename admin to console (#634) 2022-10-09 06:56:33 +00:00
.github chore: remove build jobs of github action (#759) 2022-12-07 18:04:33 +08:00
.husky chore: use lint-staged to improve dx (#768) 2022-12-13 15:38:48 +00:00
.vscode chore: update vscode extension recommendations 2022-08-31 23:35:46 +08:00
cypress chore: next major version base project (#478) 2022-03-03 18:26:15 +08:00
docs feat: add editor extension point (#781) 2022-12-22 04:14:29 +00:00
packages feat: add editor extension point (#781) 2022-12-22 04:14:29 +00:00
public feat: change favicon to halo logo 2022-09-27 17:30:14 +08:00
src feat: add editor extension point (#781) 2022-12-22 04:14:29 +00:00
.dockerignore Add dockerignore file to ignore node_modules folder while building docker image (#588) 2022-07-19 07:50:05 +00:00
.editorconfig refactor: upgrade codemirror version. (#354) 2021-09-15 21:44:00 +08:00
.env.development refactor: set the root path of the development environment to /console (#638) 2022-10-11 15:32:14 +00:00
.env.production refactor: improve login-related logic (#617) 2022-09-22 12:46:12 +00:00
.eslintrc.cjs chore: use vue/vue3-recommended eslint plugin 2022-08-30 17:30:43 +08:00
.gitignore chore: use pnpm's workspace feature to manage base components (#579) 2022-06-14 15:56:55 +08:00
.gitpod.yml chore: update gitpod config 2022-09-09 19:17:22 +08:00
.npmignore refactor: refactor post preview and private post view. 2019-12-19 17:50:23 +08:00
.npmrc chore: bump dependencies 2022-08-23 11:10:29 +08:00
.prettierignore chore: use lint-staged to improve dx (#768) 2022-12-13 15:38:48 +00:00
Dockerfile Refactor GitHub workflow configuration (#589) 2022-07-19 19:31:11 +08:00
LICENSE release: 1.2.0. 2020-01-05 22:39:18 +08:00
Makefile Add Makefile for convenient operations (#641) 2022-10-13 10:00:16 +00:00
OWNERS chore: add @wzrove to reviewer list (#714) (#771) 2022-12-14 02:08:48 +00:00
README.md docs: update github workflow badge (#775) 2022-12-16 02:54:11 +00:00
cypress.json chore: next major version base project (#478) 2022-03-03 18:26:15 +08:00
env.d.ts feat: api client requests support configuring the mute parameter to hide exception toast (#744) 2022-12-05 09:40:12 +00:00
index.html refactor: rename admin to console (#634) 2022-10-09 06:56:33 +00:00
package.json feat: add support for resetting configmap of plugin and theme (#777) 2022-12-19 08:25:47 +00:00
pnpm-lock.yaml feat: add support for resetting configmap of plugin and theme (#777) 2022-12-19 08:25:47 +00:00
pnpm-workspace.yaml chore: use pnpm's workspace feature to manage base components (#579) 2022-06-14 15:56:55 +08:00
postcss.config.js chore: configure tailwind css (#504) 2022-03-11 11:51:40 +08:00
prettier.config.js chore: add tailwindcss prettier plugin and reformat code 2022-05-29 23:55:06 +08:00
tailwind.config.js refactor: widgets of dashboard page (#736) 2022-11-30 14:51:49 +00:00
tsconfig.app.json feat: add attachment management support (#600) 2022-09-04 17:06:11 +00:00
tsconfig.json chore: next major version base project (#478) 2022-03-03 18:26:15 +08:00
tsconfig.vite-config.json refactor: external static libraries 2022-09-26 13:16:40 +08:00
tsconfig.vitest.json chore: next major version base project (#478) 2022-03-03 18:26:15 +08:00
vite.config.ts refactor: widgets of dashboard page (#736) 2022-11-30 14:51:49 +00:00
vitest.config.ts refactor: load the logo as an inline svg (#664) 2022-10-26 03:10:14 +00:00

README.md

README

Halo logo

Halo 2.0 的管理端项目(原 halo-admin

GitHub release GitHub GitHub last commit GitHub Workflow Status Gitpod ready-to-code


当前仓库已经将 halo-admin 改为了 console。但对于 Halo 1.x 版本,依旧保持 halo-admin 的概念。

开发环境运行

# pnpm@7.0.0+
npm install -g pnpm
pnpm install 
pnpm build:packages
pnpm dev

生产构建

pnpm build

状态

Repobeats analytics