From f5797d5bd41cde7d15856667334870ece133567f Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 25 Jan 2024 21:54:27 +0800 Subject: [PATCH] Add text diagram option in toolbox Signed-off-by: Ryan Wang --- console/src/editor/text-diagram/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/console/src/editor/text-diagram/index.ts b/console/src/editor/text-diagram/index.ts index 7c3c9d4..2c4aa75 100644 --- a/console/src/editor/text-diagram/index.ts +++ b/console/src/editor/text-diagram/index.ts @@ -4,6 +4,7 @@ import { Node, type Range, VueNodeViewRenderer, + ToolboxItem, } from "@halo-dev/richtext-editor"; import TextDiagramView from "./TextDiagramView.vue"; import { markRaw } from "vue"; @@ -100,6 +101,29 @@ export const ExtensionTextDiagram = Node.create({ 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 {