@meta-1/editor 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +458 -0
  2. package/package.json +100 -0
  3. package/src/editor/constants.tsx +66 -0
  4. package/src/editor/container.css +46 -0
  5. package/src/editor/control/character-count/index.tsx +39 -0
  6. package/src/editor/control/drag-handle/index.tsx +85 -0
  7. package/src/editor/control/drag-handle/use.content.actions.ts +71 -0
  8. package/src/editor/control/drag-handle/use.data.ts +29 -0
  9. package/src/editor/control/drag-handle/use.handle.id.ts +6 -0
  10. package/src/editor/control/index.tsx +35 -0
  11. package/src/editor/editor.css +626 -0
  12. package/src/editor/extension/block-quote-figure/BlockquoteFigure.ts +73 -0
  13. package/src/editor/extension/block-quote-figure/Quote/Quote.ts +31 -0
  14. package/src/editor/extension/block-quote-figure/Quote/index.ts +1 -0
  15. package/src/editor/extension/block-quote-figure/QuoteCaption/QuoteCaption.ts +54 -0
  16. package/src/editor/extension/block-quote-figure/QuoteCaption/index.ts +1 -0
  17. package/src/editor/extension/block-quote-figure/index.ts +1 -0
  18. package/src/editor/extension/document/index.ts +5 -0
  19. package/src/editor/extension/figcaption/Figcaption.ts +90 -0
  20. package/src/editor/extension/figcaption/index.ts +1 -0
  21. package/src/editor/extension/figure/Figure.ts +62 -0
  22. package/src/editor/extension/figure/index.ts +1 -0
  23. package/src/editor/extension/font-size/FontSize.ts +64 -0
  24. package/src/editor/extension/font-size/index.ts +1 -0
  25. package/src/editor/extension/global-drag-handle/clipboard-serializer.ts +28 -0
  26. package/src/editor/extension/global-drag-handle/index.ts +377 -0
  27. package/src/editor/extension/heading/index.ts +13 -0
  28. package/src/editor/extension/horizontal-rule/HorizontalRule.ts +10 -0
  29. package/src/editor/extension/horizontal-rule/index.ts +1 -0
  30. package/src/editor/extension/image/index.ts +5 -0
  31. package/src/editor/extension/image-block/ImageBlock.ts +103 -0
  32. package/src/editor/extension/image-block/components/ImageBlockMenu.tsx +100 -0
  33. package/src/editor/extension/image-block/components/ImageBlockView.tsx +47 -0
  34. package/src/editor/extension/image-block/components/ImageBlockWidth.tsx +40 -0
  35. package/src/editor/extension/image-block/index.ts +1 -0
  36. package/src/editor/extension/image-upload/ImageUpload.ts +58 -0
  37. package/src/editor/extension/image-upload/index.ts +1 -0
  38. package/src/editor/extension/image-upload/view/ImageUpload.tsx +27 -0
  39. package/src/editor/extension/image-upload/view/ImageUploader.tsx +64 -0
  40. package/src/editor/extension/image-upload/view/hooks.ts +109 -0
  41. package/src/editor/extension/image-upload/view/index.tsx +1 -0
  42. package/src/editor/extension/index.ts +30 -0
  43. package/src/editor/extension/link/Link.ts +39 -0
  44. package/src/editor/extension/link/index.ts +1 -0
  45. package/src/editor/extension/multi-column/Column.ts +33 -0
  46. package/src/editor/extension/multi-column/Columns.ts +65 -0
  47. package/src/editor/extension/multi-column/index.ts +2 -0
  48. package/src/editor/extension/multi-column/menus/ColumnsMenu.tsx +82 -0
  49. package/src/editor/extension/multi-column/menus/index.ts +1 -0
  50. package/src/editor/extension/selection/Selection.ts +36 -0
  51. package/src/editor/extension/selection/index.ts +1 -0
  52. package/src/editor/extension/slash-command/MenuList.tsx +145 -0
  53. package/src/editor/extension/slash-command/groups.ts +153 -0
  54. package/src/editor/extension/slash-command/index.ts +277 -0
  55. package/src/editor/extension/slash-command/types.ts +25 -0
  56. package/src/editor/extension/table/Cell.ts +126 -0
  57. package/src/editor/extension/table/Header.ts +89 -0
  58. package/src/editor/extension/table/Row.ts +8 -0
  59. package/src/editor/extension/table/Table.ts +9 -0
  60. package/src/editor/extension/table/index.ts +4 -0
  61. package/src/editor/extension/table/menus/TableColumn/index.tsx +73 -0
  62. package/src/editor/extension/table/menus/TableColumn/utils.ts +38 -0
  63. package/src/editor/extension/table/menus/TableRow/index.tsx +74 -0
  64. package/src/editor/extension/table/menus/TableRow/utils.ts +38 -0
  65. package/src/editor/extension/table/menus/index.tsx +2 -0
  66. package/src/editor/extension/table/utils.ts +258 -0
  67. package/src/editor/extension/task-item/index.ts +1 -0
  68. package/src/editor/extension/task-item/task-item.ts +225 -0
  69. package/src/editor/extension/task-list/index.ts +1 -0
  70. package/src/editor/extension/task-list/task-list.ts +81 -0
  71. package/src/editor/extension/trailing-node/index.ts +1 -0
  72. package/src/editor/extension/trailing-node/trailing-node.ts +70 -0
  73. package/src/editor/extension/unique-id/index.ts +1 -0
  74. package/src/editor/extension/unique-id/uniqueId.ts +123 -0
  75. package/src/editor/hooks.ts +264 -0
  76. package/src/editor/index.tsx +53 -0
  77. package/src/editor/menus/LinkMenu/LinkMenu.tsx +75 -0
  78. package/src/editor/menus/LinkMenu/index.tsx +1 -0
  79. package/src/editor/menus/TextMenu/TextMenu.tsx +193 -0
  80. package/src/editor/menus/TextMenu/components/AIDropdown.tsx +140 -0
  81. package/src/editor/menus/TextMenu/components/ContentTypePicker.tsx +76 -0
  82. package/src/editor/menus/TextMenu/components/EditLinkPopover.tsx +25 -0
  83. package/src/editor/menus/TextMenu/components/FontFamilyPicker.tsx +84 -0
  84. package/src/editor/menus/TextMenu/components/FontSizePicker.tsx +56 -0
  85. package/src/editor/menus/TextMenu/hooks/useTextmenuCommands.ts +96 -0
  86. package/src/editor/menus/TextMenu/hooks/useTextmenuContentTypes.ts +86 -0
  87. package/src/editor/menus/TextMenu/hooks/useTextmenuStates.ts +50 -0
  88. package/src/editor/menus/TextMenu/index.tsx +2 -0
  89. package/src/editor/menus/types.ts +21 -0
  90. package/src/editor/panels/Colorpicker/ColorButton.tsx +35 -0
  91. package/src/editor/panels/Colorpicker/Colorpicker.tsx +67 -0
  92. package/src/editor/panels/Colorpicker/index.tsx +2 -0
  93. package/src/editor/panels/LinkEditorPanel/LinkEditorPanel.tsx +76 -0
  94. package/src/editor/panels/LinkEditorPanel/index.tsx +1 -0
  95. package/src/editor/panels/LinkPreviewPanel/LinkPreviewPanel.tsx +32 -0
  96. package/src/editor/panels/LinkPreviewPanel/index.tsx +1 -0
  97. package/src/editor/panels/index.tsx +3 -0
  98. package/src/editor/types.tsx +38 -0
  99. package/src/editor/ui/Button/Button.tsx +70 -0
  100. package/src/editor/ui/Button/index.tsx +2 -0
  101. package/src/editor/ui/Dropdown/Dropdown.tsx +39 -0
  102. package/src/editor/ui/Dropdown/index.tsx +1 -0
  103. package/src/editor/ui/Icon.tsx +21 -0
  104. package/src/editor/ui/Loader/Loader.tsx +39 -0
  105. package/src/editor/ui/Loader/index.ts +1 -0
  106. package/src/editor/ui/Loader/types.ts +7 -0
  107. package/src/editor/ui/Panel/index.tsx +109 -0
  108. package/src/editor/ui/PopoverMenu.tsx +127 -0
  109. package/src/editor/ui/Spinner/Spinner.tsx +10 -0
  110. package/src/editor/ui/Spinner/index.tsx +1 -0
  111. package/src/editor/ui/Surface.tsx +27 -0
  112. package/src/editor/ui/Textarea/Textarea.tsx +20 -0
  113. package/src/editor/ui/Textarea/index.tsx +1 -0
  114. package/src/editor/ui/Toggle/Toggle.tsx +39 -0
  115. package/src/editor/ui/Toggle/index.tsx +1 -0
  116. package/src/editor/ui/Toolbar.tsx +107 -0
  117. package/src/editor/ui/Tooltip/index.tsx +77 -0
  118. package/src/editor/ui/Tooltip/types.ts +17 -0
  119. package/src/editor/utils/cssVar.ts +14 -0
  120. package/src/editor/utils/getRenderContainer.ts +39 -0
  121. package/src/editor/utils/index.ts +16 -0
  122. package/src/editor/utils/isCustomNodeSelected.ts +47 -0
  123. package/src/editor/utils/isTextSelected.ts +25 -0
  124. package/src/editor/utils/locale.ts +5 -0
  125. package/src/editor/viewer/index.tsx +26 -0
  126. package/src/globals.css +1 -0
  127. package/src/index.ts +7 -0
  128. package/src/locales/en-us.ts +133 -0
  129. package/src/locales/zh-cn.ts +133 -0
  130. package/src/locales/zh-tw.ts +133 -0
@@ -0,0 +1,33 @@
1
+ import { mergeAttributes, Node } from "@tiptap/core";
2
+
3
+ export const Column = Node.create({
4
+ name: "column",
5
+
6
+ content: "block+",
7
+
8
+ isolating: true,
9
+
10
+ addAttributes() {
11
+ return {
12
+ position: {
13
+ default: "",
14
+ parseHTML: (element) => element.getAttribute("data-position"),
15
+ renderHTML: (attributes) => ({ "data-position": attributes.position }),
16
+ },
17
+ };
18
+ },
19
+
20
+ renderHTML({ HTMLAttributes }) {
21
+ return ["div", mergeAttributes(HTMLAttributes, { "data-type": "column" }), 0];
22
+ },
23
+
24
+ parseHTML() {
25
+ return [
26
+ {
27
+ tag: 'div[data-type="column"]',
28
+ },
29
+ ];
30
+ },
31
+ });
32
+
33
+ export default Column;
@@ -0,0 +1,65 @@
1
+ import { Node } from "@tiptap/core";
2
+
3
+ export enum ColumnLayout {
4
+ SidebarLeft = "sidebar-left",
5
+ SidebarRight = "sidebar-right",
6
+ TwoColumn = "two-column",
7
+ }
8
+
9
+ declare module "@tiptap/core" {
10
+ interface Commands<ReturnType> {
11
+ columns: {
12
+ setColumns: () => ReturnType;
13
+ setLayout: (layout: ColumnLayout) => ReturnType;
14
+ };
15
+ }
16
+ }
17
+
18
+ export const Columns = Node.create({
19
+ name: "columns",
20
+
21
+ group: "columns",
22
+
23
+ content: "column column",
24
+
25
+ defining: true,
26
+
27
+ isolating: true,
28
+
29
+ addAttributes() {
30
+ return {
31
+ layout: {
32
+ default: ColumnLayout.TwoColumn,
33
+ },
34
+ };
35
+ },
36
+
37
+ addCommands() {
38
+ return {
39
+ setColumns:
40
+ () =>
41
+ ({ commands }) =>
42
+ commands.insertContent(
43
+ `<div data-type="columns"><div data-type="column" data-position="left"><p></p></div><div data-type="column" data-position="right"><p></p></div></div>`,
44
+ ),
45
+ setLayout:
46
+ (layout: ColumnLayout) =>
47
+ ({ commands }) =>
48
+ commands.updateAttributes("columns", { layout }),
49
+ };
50
+ },
51
+
52
+ renderHTML({ HTMLAttributes }) {
53
+ return ["div", { "data-type": "columns", class: `layout-${HTMLAttributes.layout}` }, 0];
54
+ },
55
+
56
+ parseHTML() {
57
+ return [
58
+ {
59
+ tag: 'div[data-type="columns"]',
60
+ },
61
+ ];
62
+ },
63
+ });
64
+
65
+ export default Columns;
@@ -0,0 +1,2 @@
1
+ export { Column } from "./Column";
2
+ export { Columns } from "./Columns";
@@ -0,0 +1,82 @@
1
+ import { useCallback } from "react";
2
+ import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react";
3
+ import { sticky } from "tippy.js";
4
+ import { v4 as uuid } from "uuid";
5
+
6
+ import type { MenuProps } from "../../../menus/types";
7
+ import { Icon } from "../../../ui/Icon";
8
+ import { Toolbar } from "../../../ui/Toolbar";
9
+ import { getRenderContainer } from "../../../utils";
10
+ import { ColumnLayout } from "../Columns";
11
+
12
+ export const ColumnsMenu = ({ editor, appendTo }: MenuProps) => {
13
+ const getReferenceClientRect = useCallback(() => {
14
+ const renderContainer = getRenderContainer(editor, "columns");
15
+ const rect = renderContainer?.getBoundingClientRect() || new DOMRect(-1000, -1000, 0, 0);
16
+
17
+ return rect;
18
+ }, [editor]);
19
+
20
+ const shouldShow = useCallback(() => {
21
+ const isColumns = editor.isActive("columns");
22
+ return isColumns;
23
+ }, [editor]);
24
+
25
+ const onColumnLeft = useCallback(() => {
26
+ editor.chain().focus().setLayout(ColumnLayout.SidebarLeft).run();
27
+ }, [editor]);
28
+
29
+ const onColumnRight = useCallback(() => {
30
+ editor.chain().focus().setLayout(ColumnLayout.SidebarRight).run();
31
+ }, [editor]);
32
+
33
+ const onColumnTwo = useCallback(() => {
34
+ editor.chain().focus().setLayout(ColumnLayout.TwoColumn).run();
35
+ }, [editor]);
36
+
37
+ return (
38
+ <BaseBubbleMenu
39
+ editor={editor}
40
+ pluginKey={`columnsMenu-${uuid()}`}
41
+ shouldShow={shouldShow}
42
+ tippyOptions={{
43
+ zIndex: 40,
44
+ offset: [0, 8],
45
+ popperOptions: {
46
+ modifiers: [{ name: "flip", enabled: false }],
47
+ },
48
+ getReferenceClientRect,
49
+ appendTo: () => appendTo?.current,
50
+ plugins: [sticky],
51
+ sticky: "popper",
52
+ }}
53
+ updateDelay={0}
54
+ >
55
+ <Toolbar.Wrapper>
56
+ <Toolbar.Button
57
+ active={editor.isActive("columns", { layout: ColumnLayout.SidebarLeft })}
58
+ onClick={onColumnLeft}
59
+ tooltip="Sidebar left"
60
+ >
61
+ <Icon name="PanelLeft" />
62
+ </Toolbar.Button>
63
+ <Toolbar.Button
64
+ active={editor.isActive("columns", { layout: ColumnLayout.TwoColumn })}
65
+ onClick={onColumnTwo}
66
+ tooltip="Two columns"
67
+ >
68
+ <Icon name="Columns2" />
69
+ </Toolbar.Button>
70
+ <Toolbar.Button
71
+ active={editor.isActive("columns", { layout: ColumnLayout.SidebarRight })}
72
+ onClick={onColumnRight}
73
+ tooltip="Sidebar right"
74
+ >
75
+ <Icon name="PanelRight" />
76
+ </Toolbar.Button>
77
+ </Toolbar.Wrapper>
78
+ </BaseBubbleMenu>
79
+ );
80
+ };
81
+
82
+ export default ColumnsMenu;
@@ -0,0 +1 @@
1
+ export { ColumnsMenu } from "./ColumnsMenu";
@@ -0,0 +1,36 @@
1
+ import { Extension } from "@tiptap/core";
2
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
3
+ import { Decoration, DecorationSet } from "@tiptap/pm/view";
4
+
5
+ export const Selection = Extension.create({
6
+ name: "selection",
7
+
8
+ addProseMirrorPlugins() {
9
+ const { editor } = this;
10
+
11
+ return [
12
+ new Plugin({
13
+ key: new PluginKey("selection"),
14
+ props: {
15
+ decorations(state) {
16
+ if (state.selection.empty) {
17
+ return null;
18
+ }
19
+
20
+ if (editor.isFocused) {
21
+ return null;
22
+ }
23
+
24
+ return DecorationSet.create(state.doc, [
25
+ Decoration.inline(state.selection.from, state.selection.to, {
26
+ class: "selection",
27
+ }),
28
+ ]);
29
+ },
30
+ },
31
+ }),
32
+ ];
33
+ },
34
+ });
35
+
36
+ export default Selection;
@@ -0,0 +1 @@
1
+ export { Selection } from "./Selection";
@@ -0,0 +1,145 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
+
3
+ import { DropdownButton } from "../../ui/Dropdown";
4
+ import { Icon } from "../../ui/Icon";
5
+ import { Surface } from "../../ui/Surface";
6
+ import type { Command, MenuListProps } from "./types";
7
+
8
+ export const MenuList = React.forwardRef((props: MenuListProps, ref) => {
9
+ const scrollContainer = useRef<HTMLDivElement>(null);
10
+ const activeItem = useRef<HTMLButtonElement>(null);
11
+ const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);
12
+ const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);
13
+
14
+ // Anytime the groups change, i.e. the user types to narrow it down, we want to
15
+ // reset the current selection to the first menu item
16
+ useEffect(() => {
17
+ setSelectedGroupIndex(0);
18
+ setSelectedCommandIndex(0);
19
+ }, [props.items]);
20
+
21
+ const selectItem = useCallback(
22
+ (groupIndex: number, commandIndex: number) => {
23
+ const command = props.items[groupIndex].commands[commandIndex];
24
+ props.command(command);
25
+ },
26
+ [props],
27
+ );
28
+
29
+ React.useImperativeHandle(ref, () => ({
30
+ onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {
31
+ if (event.key === "ArrowDown") {
32
+ if (!props.items.length) {
33
+ return false;
34
+ }
35
+
36
+ const commands = props.items[selectedGroupIndex].commands;
37
+
38
+ let newCommandIndex = selectedCommandIndex + 1;
39
+ let newGroupIndex = selectedGroupIndex;
40
+
41
+ if (commands.length - 1 < newCommandIndex) {
42
+ newCommandIndex = 0;
43
+ newGroupIndex = selectedGroupIndex + 1;
44
+ }
45
+
46
+ if (props.items.length - 1 < newGroupIndex) {
47
+ newGroupIndex = 0;
48
+ }
49
+
50
+ setSelectedCommandIndex(newCommandIndex);
51
+ setSelectedGroupIndex(newGroupIndex);
52
+
53
+ return true;
54
+ }
55
+
56
+ if (event.key === "ArrowUp") {
57
+ if (!props.items.length) {
58
+ return false;
59
+ }
60
+
61
+ let newCommandIndex = selectedCommandIndex - 1;
62
+ let newGroupIndex = selectedGroupIndex;
63
+
64
+ if (newCommandIndex < 0) {
65
+ newGroupIndex = selectedGroupIndex - 1;
66
+ newCommandIndex = props.items[newGroupIndex]?.commands.length - 1 || 0;
67
+ }
68
+
69
+ if (newGroupIndex < 0) {
70
+ newGroupIndex = props.items.length - 1;
71
+ newCommandIndex = props.items[newGroupIndex].commands.length - 1;
72
+ }
73
+
74
+ setSelectedCommandIndex(newCommandIndex);
75
+ setSelectedGroupIndex(newGroupIndex);
76
+
77
+ return true;
78
+ }
79
+
80
+ if (event.key === "Enter") {
81
+ if (!props.items.length || selectedGroupIndex === -1 || selectedCommandIndex === -1) {
82
+ return false;
83
+ }
84
+
85
+ selectItem(selectedGroupIndex, selectedCommandIndex);
86
+
87
+ return true;
88
+ }
89
+
90
+ return false;
91
+ },
92
+ }));
93
+
94
+ useEffect(() => {
95
+ if (activeItem.current && scrollContainer.current) {
96
+ const offsetTop = activeItem.current.offsetTop;
97
+ const offsetHeight = activeItem.current.offsetHeight;
98
+ scrollContainer.current.scrollTop = offsetTop - offsetHeight;
99
+ }
100
+ }, []);
101
+
102
+ const createCommandClickHandler = useCallback(
103
+ (groupIndex: number, commandIndex: number) => {
104
+ return () => {
105
+ selectItem(groupIndex, commandIndex);
106
+ };
107
+ },
108
+ [selectItem],
109
+ );
110
+
111
+ if (!props.items.length) {
112
+ return null;
113
+ }
114
+
115
+ return (
116
+ <Surface className="mb-8 max-h-[min(80vh,24rem)] flex-wrap overflow-auto p-2 text-black" ref={scrollContainer}>
117
+ <div className="grid grid-cols-1 gap-0.5">
118
+ {props.items.map((group, groupIndex: number) => (
119
+ <React.Fragment key={`${group.title}-wrapper`}>
120
+ <div
121
+ className="col-[1/-1] mx-2 mt-4 select-none font-semibold text-[0.65rem] text-neutral-500 uppercase tracking-wider first:mt-0.5"
122
+ key={`${group.title}`}
123
+ >
124
+ {group.title}
125
+ </div>
126
+ {group.commands.map((command: Command, commandIndex: number) => (
127
+ <DropdownButton
128
+ isActive={selectedGroupIndex === groupIndex && selectedCommandIndex === commandIndex}
129
+ key={`${command.label}`}
130
+ onClick={createCommandClickHandler(groupIndex, commandIndex)}
131
+ >
132
+ <Icon className="mr-1" name={command.iconName} />
133
+ {command.label}
134
+ </DropdownButton>
135
+ ))}
136
+ </React.Fragment>
137
+ ))}
138
+ </div>
139
+ </Surface>
140
+ );
141
+ });
142
+
143
+ MenuList.displayName = "MenuList";
144
+
145
+ export default MenuList;
@@ -0,0 +1,153 @@
1
+ import { i18n } from "../../utils/locale";
2
+ import type { Group } from "./types";
3
+
4
+ export const getGroups = (): Group[] => [
5
+ {
6
+ name: "format",
7
+ title: i18n("slashCommand.group.format"),
8
+ commands: [
9
+ {
10
+ name: "heading1",
11
+ label: i18n("slashCommand.heading1.title"),
12
+ iconName: "Heading1",
13
+ description: i18n("slashCommand.heading1.description"),
14
+ aliases: ["h1"],
15
+ action: (editor) => {
16
+ editor.chain().focus().setHeading({ level: 1 }).run();
17
+ },
18
+ },
19
+ {
20
+ name: "heading2",
21
+ label: i18n("slashCommand.heading2.title"),
22
+ iconName: "Heading2",
23
+ description: i18n("slashCommand.heading2.description"),
24
+ aliases: ["h2"],
25
+ action: (editor) => {
26
+ editor.chain().focus().setHeading({ level: 2 }).run();
27
+ },
28
+ },
29
+ {
30
+ name: "heading3",
31
+ label: i18n("slashCommand.heading3.title"),
32
+ iconName: "Heading3",
33
+ description: i18n("slashCommand.heading3.description"),
34
+ aliases: ["h3"],
35
+ action: (editor) => {
36
+ editor.chain().focus().setHeading({ level: 3 }).run();
37
+ },
38
+ },
39
+ {
40
+ name: "bulletList",
41
+ label: i18n("slashCommand.bulletList.title"),
42
+ iconName: "List",
43
+ description: i18n("slashCommand.bulletList.description"),
44
+ aliases: ["ul"],
45
+ action: (editor) => {
46
+ editor.chain().focus().toggleBulletList().run();
47
+ },
48
+ },
49
+ {
50
+ name: "numberedList",
51
+ label: i18n("slashCommand.numberedList.title"),
52
+ iconName: "ListOrdered",
53
+ description: i18n("slashCommand.numberedList.description"),
54
+ aliases: ["ol"],
55
+ action: (editor) => {
56
+ editor.chain().focus().toggleOrderedList().run();
57
+ },
58
+ },
59
+ {
60
+ name: "taskList",
61
+ label: i18n("slashCommand.taskList.title"),
62
+ iconName: "ListTodo",
63
+ description: i18n("slashCommand.taskList.description"),
64
+ aliases: ["todo"],
65
+ action: (editor) => {
66
+ editor.chain().focus().toggleTaskList().run();
67
+ },
68
+ },
69
+ {
70
+ name: "blockquote",
71
+ label: i18n("slashCommand.blockquote.title"),
72
+ iconName: "Quote",
73
+ description: i18n("slashCommand.blockquote.description"),
74
+ action: (editor) => {
75
+ editor.chain().focus().setBlockquote().run();
76
+ },
77
+ },
78
+ {
79
+ name: "codeBlock",
80
+ label: i18n("slashCommand.codeBlock.title"),
81
+ iconName: "SquareCode",
82
+ description: i18n("slashCommand.codeBlock.description"),
83
+ shouldBeHidden: (editor) => editor.isActive("columns"),
84
+ action: (editor) => {
85
+ editor.chain().focus().setCodeBlock().run();
86
+ },
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ name: "insert",
92
+ title: i18n("slashCommand.group.insert"),
93
+ commands: [
94
+ {
95
+ name: "table",
96
+ label: i18n("slashCommand.table.title"),
97
+ iconName: "Table",
98
+ description: i18n("slashCommand.table.description"),
99
+ shouldBeHidden: (editor) => editor.isActive("columns"),
100
+ action: (editor) => {
101
+ editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: false }).run();
102
+ },
103
+ },
104
+ {
105
+ name: "image",
106
+ label: i18n("slashCommand.image.title"),
107
+ iconName: "Image",
108
+ description: i18n("slashCommand.image.description"),
109
+ aliases: ["img"],
110
+ action: (editor) => {
111
+ editor.chain().focus().setImageUpload().run();
112
+ },
113
+ },
114
+ // {
115
+ // name: 'columns',
116
+ // label: t("列"),
117
+ // iconName: 'Columns2',
118
+ // description: t("添加两列内容"),
119
+ // aliases: ['cols'],
120
+ // shouldBeHidden: editor => editor.isActive('columns'),
121
+ // action: editor => {
122
+ // editor
123
+ // .chain()
124
+ // .focus()
125
+ // //.setColumns()
126
+ // .focus(editor.state.selection.head - 1)
127
+ // .run()
128
+ // },
129
+ // },
130
+ {
131
+ name: "horizontalRule",
132
+ label: i18n("slashCommand.horizontalRule.title"),
133
+ iconName: "Minus",
134
+ description: i18n("slashCommand.horizontalRule.description"),
135
+ aliases: ["hr"],
136
+ action: (editor) => {
137
+ editor.chain().focus().setHorizontalRule().run();
138
+ },
139
+ },
140
+ // {
141
+ // name: 'toc',
142
+ // label: t("表格内容"),
143
+ // iconName: 'Book',
144
+ // aliases: ['outline'],
145
+ // description: t("插入表格内容"),
146
+ // shouldBeHidden: editor => editor.isActive('columns'),
147
+ // action: editor => {
148
+ // editor.chain().focus()//.insertTableOfContents().run()
149
+ // },
150
+ // },
151
+ ],
152
+ },
153
+ ];