Skip to content

Commit

Permalink
Add text diagram option in toolbox (#11)
Browse files Browse the repository at this point in the history
<img width="949" alt="image" src="https://github.com/halo-sigs/plugin-text-diagram/assets/21301288/1b755f39-6831-4461-b17d-c163c3df9960">

/kind feature

```release-note
Add text diagram option in toolbox
```
  • Loading branch information
ruibaby authored Jan 26, 2024
1 parent b1ea8f9 commit 48537b0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions console/src/editor/text-diagram/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Node,
type Range,
VueNodeViewRenderer,
ToolboxItem,
} from "@halo-dev/richtext-editor";
import TextDiagramView from "./TextDiagramView.vue";
import { markRaw } from "vue";
Expand Down Expand Up @@ -100,6 +101,29 @@ export const ExtensionTextDiagram = Node.create<TextDiagramOptions>({
addOptions() {
return {
...this.parent?.(),
getToolboxItems({ editor }: { editor: Editor }) {
return [
{
priority: 100,
component: markRaw(ToolboxItem),
props: {
editor,
icon: markRaw(icon),
title: "文本绘图",
action: () => {
editor
.chain()
.focus()
.insertContent([
{ type: "text-diagram", attrs: {} },
{ type: "paragraph", content: "" },
])
.run();
},
},
},
];
},
// 扩展指令项
getCommandMenuItems() {
return {
Expand Down

0 comments on commit 48537b0

Please sign in to comment.