forked from halo-sigs/plugin-moments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
41 lines (38 loc) · 1.11 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Editor, ExtensionImage, type Range } from "@halo-dev/richtext-editor";
import type { ExtensionOptions } from "@halo-dev/richtext-editor/dist/types";
import { markRaw } from "vue";
import MdiFileImageBox from "~icons/mdi/file-image-box";
export interface ImageOptions {
inline: boolean;
allowBase64: boolean;
HTMLAttributes: Record<string, unknown>;
}
const MomentExtensionImage = ExtensionImage.extend<
ExtensionOptions & ImageOptions
>({
addOptions() {
return {
...this.parent?.(),
getCommandMenuItems() {
return {
priority: 100,
icon: markRaw(MdiFileImageBox),
title: "图片",
keywords: ["image", "tupian"],
command: ({ editor, range }: { editor: Editor; range: Range }) => {
editor
.chain()
.focus()
.deleteRange(range)
.insertContent([
{ type: "image", attrs: { src: "" } },
{ type: "paragraph", content: "" },
])
.run();
},
};
},
};
},
});
export default MomentExtensionImage;