reactjs-tiptap-editor-pro 0.2.29 → 0.2.30
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.
- package/package.json +4 -60
- package/src/components/ActionButton.tsx +103 -0
- package/src/components/ActionMenuButton.tsx +76 -0
- package/src/components/BubbleMenu.tsx +93 -0
- package/src/components/CharactorCount.tsx +50 -0
- package/src/components/ColorPicker.tsx +272 -0
- package/src/components/RichTextEditor.tsx +212 -0
- package/src/components/SizeSetter/SizeSetter.tsx +102 -0
- package/src/components/Toolbar.tsx +108 -0
- package/src/components/icons/Activity.tsx +19 -0
- package/src/components/icons/Animas.tsx +24 -0
- package/src/components/icons/AspectRatio.tsx +13 -0
- package/src/components/icons/Blockquote.tsx +17 -0
- package/src/components/icons/ColumnAddLeft.tsx +7 -0
- package/src/components/icons/ColumnAddRight.tsx +7 -0
- package/src/components/icons/DeleteColumn.tsx +26 -0
- package/src/components/icons/DeleteRow.tsx +26 -0
- package/src/components/icons/Direction.tsx +7 -0
- package/src/components/icons/Excalidraw.tsx +7 -0
- package/src/components/icons/ExportPdf.tsx +8 -0
- package/src/components/icons/ExportWord.tsx +24 -0
- package/src/components/icons/FileWordOutline.tsx +13 -0
- package/src/components/icons/Flag.tsx +19 -0
- package/src/components/icons/Food.tsx +20 -0
- package/src/components/icons/GIfIcon.tsx +10 -0
- package/src/components/icons/Icon.tsx +30 -0
- package/src/components/icons/ImportWord.tsx +23 -0
- package/src/components/icons/LeftToRight.tsx +7 -0
- package/src/components/icons/LineHeight.tsx +13 -0
- package/src/components/icons/MenuDown.tsx +24 -0
- package/src/components/icons/Mermaid.tsx +13 -0
- package/src/components/icons/NoFill.tsx +7 -0
- package/src/components/icons/Object.tsx +24 -0
- package/src/components/icons/RightToLeft.tsx +7 -0
- package/src/components/icons/SizeL.tsx +9 -0
- package/src/components/icons/SizeM.tsx +13 -0
- package/src/components/icons/SizeS.tsx +13 -0
- package/src/components/icons/Symbol.tsx +19 -0
- package/src/components/icons/Travel.tsx +24 -0
- package/src/components/icons/Twitter.tsx +7 -0
- package/src/components/icons/icons.ts +212 -0
- package/src/components/icons/index.ts +12 -0
- package/src/components/index.ts +9 -0
- package/src/components/menus/bubble.ts +395 -0
- package/src/components/menus/components/BubbleMenuContent.tsx +15 -0
- package/src/components/menus/components/BubbleMenuDrawer.tsx +128 -0
- package/src/components/menus/components/BubbleMenuExcalidraw.tsx +91 -0
- package/src/components/menus/components/BubbleMenuIframe.tsx +143 -0
- package/src/components/menus/components/BubbleMenuKatex.tsx +136 -0
- package/src/components/menus/components/BubbleMenuLink.tsx +99 -0
- package/src/components/menus/components/BubbleMenuMedia.tsx +235 -0
- package/src/components/menus/components/BubbleMenuMermaid.tsx +128 -0
- package/src/components/menus/components/BubbleMenuText.tsx +102 -0
- package/src/components/menus/components/BubbleMenuTwitter.tsx +91 -0
- package/src/components/menus/components/ColumnsBubbleMenu.tsx +59 -0
- package/src/components/menus/components/ContentMenu.tsx +396 -0
- package/src/components/menus/components/TableBubbleMenu.tsx +362 -0
- package/src/components/menus/index.ts +7 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/dialog.tsx +128 -0
- package/src/components/ui/dropdown-menu.tsx +203 -0
- package/src/components/ui/emoji-picker.tsx +166 -0
- package/src/components/ui/index.ts +14 -0
- package/src/components/ui/input.tsx +25 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/popover.tsx +31 -0
- package/src/components/ui/select.tsx +162 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/textarea.tsx +24 -0
- package/src/components/ui/toast.tsx +129 -0
- package/src/components/ui/toaster.tsx +44 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/tooltip.tsx +30 -0
- package/src/components/ui/use-toast.ts +197 -0
- package/src/constants/index.ts +223 -0
- package/src/constants/resetCSS.ts +139 -0
- package/src/extension-bundle.ts +2 -0
- package/src/extensions/Attachment/Attachment.ts +144 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +69 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +28 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +155 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +23 -0
- package/src/extensions/Attachment/index.ts +1 -0
- package/src/extensions/BaseKit.ts +253 -0
- package/src/extensions/Blockquote/Blockquote.ts +31 -0
- package/src/extensions/Blockquote/index.ts +1 -0
- package/src/extensions/Bold/Bold.ts +26 -0
- package/src/extensions/Bold/index.ts +1 -0
- package/src/extensions/BulletList/BulletList.ts +28 -0
- package/src/extensions/BulletList/index.ts +1 -0
- package/src/extensions/Clear/Clear.ts +24 -0
- package/src/extensions/Clear/index.ts +1 -0
- package/src/extensions/Code/Code.ts +26 -0
- package/src/extensions/Code/index.ts +1 -0
- package/src/extensions/CodeBlock/CodeBlock.ts +54 -0
- package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +66 -0
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +89 -0
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +81 -0
- package/src/extensions/CodeBlock/highlighter.ts +132 -0
- package/src/extensions/CodeBlock/index.ts +1 -0
- package/src/extensions/CodeBlock/shiki-plugin.ts +213 -0
- package/src/extensions/Color/Color.ts +52 -0
- package/src/extensions/Color/components/ColorActionButton.tsx +104 -0
- package/src/extensions/Color/index.ts +1 -0
- package/src/extensions/Document/Document.ts +8 -0
- package/src/extensions/Document/index.ts +1 -0
- package/src/extensions/Drawer/Drawer.ts +177 -0
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +85 -0
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +598 -0
- package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +500 -0
- package/src/extensions/Drawer/components/DrawerActiveButton.tsx +239 -0
- package/src/extensions/Drawer/components/EditDrawerBlock.tsx +238 -0
- package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +260 -0
- package/src/extensions/Drawer/index.ts +1 -0
- package/src/extensions/Emoji/Emoji.ts +146 -0
- package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +103 -0
- package/src/extensions/Emoji/components/EmojiList/emojis.ts +1858 -0
- package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +61 -0
- package/src/extensions/Emoji/index.ts +1 -0
- package/src/extensions/Excalidraw/Excalidraw.ts +123 -0
- package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +138 -0
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +178 -0
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +43 -0
- package/src/extensions/Excalidraw/index.ts +1 -0
- package/src/extensions/ExportPdf/ExportPdf.ts +25 -0
- package/src/extensions/ExportPdf/index.ts +1 -0
- package/src/extensions/ExportWord/ExportWord.ts +87 -0
- package/src/extensions/ExportWord/index.ts +1 -0
- package/src/extensions/FontFamily/FontFamily.ts +64 -0
- package/src/extensions/FontFamily/components/FontFamilyButton.tsx +97 -0
- package/src/extensions/FontFamily/index.ts +1 -0
- package/src/extensions/FontSize/FontSize.ts +119 -0
- package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +84 -0
- package/src/extensions/FontSize/index.ts +1 -0
- package/src/extensions/FormatPainter/FormatPainter.ts +121 -0
- package/src/extensions/FormatPainter/index.ts +1 -0
- package/src/extensions/Heading/Heading.ts +57 -0
- package/src/extensions/Heading/components/HeadingButton.tsx +96 -0
- package/src/extensions/Heading/index.ts +1 -0
- package/src/extensions/Highlight/Highlight.ts +36 -0
- package/src/extensions/Highlight/components/HighlightActionButton.tsx +108 -0
- package/src/extensions/Highlight/index.ts +1 -0
- package/src/extensions/History/History.ts +39 -0
- package/src/extensions/History/components/HistoryActionButton.tsx +74 -0
- package/src/extensions/History/index.ts +1 -0
- package/src/extensions/HorizontalRule/HorizontalRule.ts +42 -0
- package/src/extensions/HorizontalRule/index.ts +1 -0
- package/src/extensions/Iframe/Iframe.ts +140 -0
- package/src/extensions/Iframe/components/IframeNodeView.tsx +92 -0
- package/src/extensions/Iframe/components/index.module.scss +40 -0
- package/src/extensions/Iframe/embed.ts +487 -0
- package/src/extensions/Iframe/index.ts +1 -0
- package/src/extensions/Image/Image.ts +303 -0
- package/src/extensions/Image/components/ActionImageButton.tsx +186 -0
- package/src/extensions/Image/components/ImageCropper.tsx +198 -0
- package/src/extensions/Image/components/ImageView.tsx +271 -0
- package/src/extensions/Image/index.ts +1 -0
- package/src/extensions/Image/store.ts +15 -0
- package/src/extensions/ImageGif/ImageGif.ts +176 -0
- package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +138 -0
- package/src/extensions/ImageGif/components/ImageGifView.tsx +260 -0
- package/src/extensions/ImageGif/index.ts +1 -0
- package/src/extensions/ImportWord/ImportWord.ts +52 -0
- package/src/extensions/ImportWord/components/ImportWordButton.tsx +151 -0
- package/src/extensions/ImportWord/index.ts +1 -0
- package/src/extensions/Indent/Indent.ts +110 -0
- package/src/extensions/Indent/index.ts +1 -0
- package/src/extensions/Italic/Italic.ts +29 -0
- package/src/extensions/Italic/index.ts +1 -0
- package/src/extensions/Katex/Katex.ts +109 -0
- package/src/extensions/Katex/components/KatexActiveButton.tsx +117 -0
- package/src/extensions/Katex/components/KatexWrapper.tsx +53 -0
- package/src/extensions/Katex/index.ts +1 -0
- package/src/extensions/LineHeight/LineHeight.ts +76 -0
- package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +93 -0
- package/src/extensions/LineHeight/index.ts +1 -0
- package/src/extensions/Link/Link.ts +92 -0
- package/src/extensions/Link/components/LinkEditBlock.tsx +110 -0
- package/src/extensions/Link/components/LinkEditPopover.tsx +46 -0
- package/src/extensions/Link/components/LinkViewBlock.tsx +54 -0
- package/src/extensions/Link/index.ts +1 -0
- package/src/extensions/ListItem/ListItem.ts +1 -0
- package/src/extensions/ListItem/index.ts +1 -0
- package/src/extensions/Mention/Mention.ts +100 -0
- package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +94 -0
- package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +38 -0
- package/src/extensions/Mention/index.ts +1 -0
- package/src/extensions/Mermaid/Mermaid.ts +177 -0
- package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +155 -0
- package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +151 -0
- package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +260 -0
- package/src/extensions/Mermaid/index.ts +1 -0
- package/src/extensions/MoreMark/MoreMark.ts +102 -0
- package/src/extensions/MoreMark/components/ActionMoreButton.tsx +97 -0
- package/src/extensions/MoreMark/index.ts +1 -0
- package/src/extensions/MultiColumn/Column.ts +36 -0
- package/src/extensions/MultiColumn/MultiColumn.ts +111 -0
- package/src/extensions/MultiColumn/components/ColumnActionButton.ts +22 -0
- package/src/extensions/MultiColumn/index.ts +3 -0
- package/src/extensions/OrderedList/OrderedList.ts +28 -0
- package/src/extensions/OrderedList/index.ts +1 -0
- package/src/extensions/SearchAndReplace/SearchAndReplace.ts +395 -0
- package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +190 -0
- package/src/extensions/SearchAndReplace/index.ts +1 -0
- package/src/extensions/Selection/Selection.ts +32 -0
- package/src/extensions/Selection/index.ts +1 -0
- package/src/extensions/SlashCommand/SlashCommand.ts +255 -0
- package/src/extensions/SlashCommand/components/CommandsList.tsx +180 -0
- package/src/extensions/SlashCommand/groups.ts +183 -0
- package/src/extensions/SlashCommand/index.ts +1 -0
- package/src/extensions/SlashCommand/types.ts +24 -0
- package/src/extensions/Strike/Strike.ts +26 -0
- package/src/extensions/Strike/index.ts +1 -0
- package/src/extensions/Subscript/Subscript.ts +88 -0
- package/src/extensions/Subscript/index.ts +1 -0
- package/src/extensions/Table/Cell.ts +131 -0
- package/src/extensions/Table/Header.ts +93 -0
- package/src/extensions/Table/Row.ts +8 -0
- package/src/extensions/Table/Table.ts +60 -0
- package/src/extensions/Table/cell-background.ts +112 -0
- package/src/extensions/Table/components/CreateTablePopover.tsx +132 -0
- package/src/extensions/Table/components/TableActionButton.tsx +42 -0
- package/src/extensions/Table/index.ts +6 -0
- package/src/extensions/Table/utils.ts +352 -0
- package/src/extensions/TableOfContent/TableOfContent.ts +124 -0
- package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +116 -0
- package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +27 -0
- package/src/extensions/TableOfContent/components/index.module.scss +40 -0
- package/src/extensions/TableOfContent/index.ts +1 -0
- package/src/extensions/TaskList/TaskList.ts +46 -0
- package/src/extensions/TaskList/index.ts +1 -0
- package/src/extensions/TextAlign/TextAlign.ts +68 -0
- package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +103 -0
- package/src/extensions/TextAlign/index.ts +1 -0
- package/src/extensions/TextBubble/TextBubble.ts +22 -0
- package/src/extensions/TextBubble/components/TextDropdown.tsx +146 -0
- package/src/extensions/TextBubble/index.ts +1 -0
- package/src/extensions/TextDirection/TextDirection.ts +97 -0
- package/src/extensions/TextDirection/components/TextDirectionButton.tsx +103 -0
- package/src/extensions/TextDirection/index.ts +1 -0
- package/src/extensions/TrailingNode/TrailingNode.ts +71 -0
- package/src/extensions/TrailingNode/index.ts +1 -0
- package/src/extensions/Twitter/Twitter.ts +161 -0
- package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +68 -0
- package/src/extensions/Twitter/components/NodeViewTweet.tsx +30 -0
- package/src/extensions/Twitter/components/TwitterActiveButton.tsx +41 -0
- package/src/extensions/Twitter/index.ts +1 -0
- package/src/extensions/UnderLine/Underline.ts +30 -0
- package/src/extensions/UnderLine/index.ts +1 -0
- package/src/extensions/Video/Video.ts +204 -0
- package/src/extensions/Video/components/ActiveVideoButton.tsx +191 -0
- package/src/extensions/Video/index.ts +1 -0
- package/src/extensions/Video/store.ts +15 -0
- package/src/extensions/index.ts +122 -0
- package/src/hooks/useActive.tsx +24 -0
- package/src/hooks/useAttributes.tsx +45 -0
- package/src/hooks/useCopy.tsx +20 -0
- package/src/hooks/useEditorState.tsx +23 -0
- package/src/hooks/useExtension.tsx +29 -0
- package/src/index.ts +8 -0
- package/src/lib/utils.ts +7 -0
- package/src/locale-bundle.ts +3 -0
- package/src/locales/en.ts +173 -0
- package/src/locales/hu.ts +173 -0
- package/src/locales/index.tsx +163 -0
- package/src/locales/pt-br.ts +173 -0
- package/src/locales/vi.ts +173 -0
- package/src/locales/zh-cn.ts +173 -0
- package/src/plugins/DragHandle/index.ts +375 -0
- package/src/plugins/DragHandle/range.ts +114 -0
- package/src/plugins/DragHandle/utils.ts +80 -0
- package/src/plugins/image-upload.ts +160 -0
- package/src/store/ProviderRichText.tsx +53 -0
- package/src/store/editableEditor.ts +15 -0
- package/src/store/fast-context.tsx +70 -0
- package/src/store/store.ts +35 -0
- package/src/styles/ProseMirror.scss +176 -0
- package/src/styles/columns.scss +23 -0
- package/src/styles/editor.scss +411 -0
- package/src/styles/global.scss +87 -0
- package/src/styles/index.scss +5 -0
- package/src/styles/mention.scss +6 -0
- package/src/theme/theme.ts +15 -0
- package/src/types.ts +271 -0
- package/src/utils/_event.ts +55 -0
- package/src/utils/color.ts +67 -0
- package/src/utils/columns.ts +142 -0
- package/src/utils/customEvents/customEvents.ts +18 -0
- package/src/utils/customEvents/events.constant.ts +11 -0
- package/src/utils/delete-node.ts +46 -0
- package/src/utils/dom-dataset.ts +121 -0
- package/src/utils/download.ts +17 -0
- package/src/utils/dynamicCSS.ts +192 -0
- package/src/utils/editor-container-size.ts +28 -0
- package/src/utils/file.ts +112 -0
- package/src/utils/getRenderContainer.ts +41 -0
- package/src/utils/indent.ts +99 -0
- package/src/utils/is-mobile.ts +57 -0
- package/src/utils/json.ts +18 -0
- package/src/utils/line-height.ts +109 -0
- package/src/utils/lru-cache.ts +145 -0
- package/src/utils/mitt.ts +114 -0
- package/src/utils/node.ts +92 -0
- package/src/utils/pdf.ts +72 -0
- package/src/utils/plateform.ts +49 -0
- package/src/utils/shortId.ts +5 -0
- package/src/utils/storage.ts +18 -0
- package/src/utils/utils.ts +71 -0
- package/src/vite-env.d.ts +3 -0
- package/lib/RichTextEditor-BwbqJLnA.cjs +0 -141
- package/lib/RichTextEditor-iGJ6-rbq.js +0 -8833
- package/lib/extension-bundle.cjs +0 -33
- package/lib/extension-bundle.d.cts +0 -947
- package/lib/extension-bundle.d.ts +0 -947
- package/lib/extension-bundle.js +0 -5755
- package/lib/index-DV-nXpU1.cjs +0 -1
- package/lib/index-M6H3FoBi.js +0 -1147
- package/lib/index.cjs +0 -1
- package/lib/index.d.cts +0 -513
- package/lib/index.d.ts +0 -513
- package/lib/index.js +0 -16
- package/lib/locale-bundle.cjs +0 -1
- package/lib/locale-bundle.d.cts +0 -1140
- package/lib/locale-bundle.d.ts +0 -1140
- package/lib/locale-bundle.js +0 -9
- package/lib/style.css +0 -1
- package/lib/tiptap-DkWHMWDt.js +0 -6061
- package/lib/tiptap-gBG-1T-V.cjs +0 -116
- package/lib/vendor-BJ0Yf78E.cjs +0 -8114
- package/lib/vendor-Cpa6z-M0.js +0 -67575
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { Extensions } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
import { Image, Video, type HeadingOptions } from '@/extensions';
|
|
4
|
+
import { actionDialogImage } from '@/extensions/Image/store';
|
|
5
|
+
import { actionDialogVideo } from '@/extensions/Video/store';
|
|
6
|
+
import { localeActions } from '@/locales';
|
|
7
|
+
|
|
8
|
+
import type { SlashCommandOptions } from './SlashCommand';
|
|
9
|
+
import type { Group } from './types';
|
|
10
|
+
|
|
11
|
+
export function renderGroups(extensions: Extensions, renderGroupItem?: SlashCommandOptions['renderGroupItem']) {
|
|
12
|
+
const groups: Group[] = [
|
|
13
|
+
{
|
|
14
|
+
name: 'format',
|
|
15
|
+
title: localeActions.t('editor.slash.format'),
|
|
16
|
+
commands: [],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'insert',
|
|
20
|
+
title: localeActions.t('editor.slash.insert'),
|
|
21
|
+
commands: [],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
extensions.forEach((extension) => {
|
|
26
|
+
/* Format */
|
|
27
|
+
if (extension.name.toLowerCase() === 'heading') {
|
|
28
|
+
extension.options.levels.forEach((level: HeadingOptions['levels'][number]) => {
|
|
29
|
+
groups[0].commands.push({
|
|
30
|
+
name: `heading${level}`,
|
|
31
|
+
label: localeActions.t(`editor.heading.h${level}.tooltip`),
|
|
32
|
+
aliases: [`h${level}`, 'bt', `bt${level}`],
|
|
33
|
+
iconName: `Heading${level}`,
|
|
34
|
+
action: ({ editor, range }) => {
|
|
35
|
+
editor.chain().focus().deleteRange(range).setHeading({ level }).run();
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (extension.name.toLowerCase() === 'bulletlist') {
|
|
42
|
+
groups[0].commands.push({
|
|
43
|
+
name: 'bulletList',
|
|
44
|
+
label: localeActions.t('editor.bulletlist.tooltip'),
|
|
45
|
+
aliases: ['ul', 'yxlb'],
|
|
46
|
+
iconName: 'List',
|
|
47
|
+
action: ({ editor, range }) => {
|
|
48
|
+
editor.chain().focus().deleteRange(range).toggleBulletList().run();
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (extension.name.toLowerCase() === 'orderedlist') {
|
|
54
|
+
groups[0].commands.push({
|
|
55
|
+
name: 'numberedList',
|
|
56
|
+
label: localeActions.t('editor.orderedlist.tooltip'),
|
|
57
|
+
aliases: ['ol', 'yxlb'],
|
|
58
|
+
iconName: 'ListOrdered',
|
|
59
|
+
action: ({ editor, range }) => {
|
|
60
|
+
editor.chain().focus().deleteRange(range).toggleOrderedList().run();
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (extension.name.toLowerCase() === 'tasklist') {
|
|
66
|
+
groups[0].commands.push({
|
|
67
|
+
name: 'taskList',
|
|
68
|
+
label: localeActions.t('editor.tasklist.tooltip'),
|
|
69
|
+
iconName: 'ListTodo',
|
|
70
|
+
description: 'Task list with todo items',
|
|
71
|
+
aliases: ['todo'],
|
|
72
|
+
action: ({ editor, range }) => {
|
|
73
|
+
editor.chain().focus().deleteRange(range).toggleTaskList().run();
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (extension.name.toLowerCase() === 'blockquote') {
|
|
79
|
+
groups[0].commands.push({
|
|
80
|
+
name: 'blockquote',
|
|
81
|
+
label: localeActions.t('editor.blockquote.tooltip'),
|
|
82
|
+
description: '插入引入格式',
|
|
83
|
+
aliases: ['yr'],
|
|
84
|
+
iconName: 'TextQuote',
|
|
85
|
+
action: ({ editor, range }) => {
|
|
86
|
+
editor.chain().focus().deleteRange(range).setBlockquote().run();
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (extension.name.toLowerCase() === 'codeblock') {
|
|
92
|
+
groups[0].commands.push({
|
|
93
|
+
name: 'codeBlock',
|
|
94
|
+
label: localeActions.t('editor.codeblock.tooltip'),
|
|
95
|
+
iconName: 'Code2',
|
|
96
|
+
description: 'Code block with syntax highlighting',
|
|
97
|
+
shouldBeHidden: editor => editor.isActive('columns'),
|
|
98
|
+
action: ({ editor, range }) => {
|
|
99
|
+
editor.chain().focus().deleteRange(range).setCodeBlock().run();
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Insert */
|
|
105
|
+
if (extension.name.toLowerCase() === Image.name) {
|
|
106
|
+
groups[1].commands.push({
|
|
107
|
+
name: 'image',
|
|
108
|
+
label: localeActions.t('editor.image.tooltip'),
|
|
109
|
+
iconName: 'ImageUp',
|
|
110
|
+
description: 'Insert a image',
|
|
111
|
+
aliases: ['image', 'tp', 'tupian'],
|
|
112
|
+
shouldBeHidden: editor => editor.isActive('columns'),
|
|
113
|
+
action: ({ editor, range }: any) => {
|
|
114
|
+
editor.chain().focus().deleteRange(range).run();
|
|
115
|
+
|
|
116
|
+
actionDialogImage.setOpen(editor.id, true);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (extension.name.toLowerCase() === Video.name) {
|
|
122
|
+
groups[1].commands.push({
|
|
123
|
+
name: 'video',
|
|
124
|
+
label: localeActions.t('editor.video.tooltip'),
|
|
125
|
+
iconName: 'Video',
|
|
126
|
+
description: 'Insert a video',
|
|
127
|
+
aliases: ['video', 'sp', 'shipin'],
|
|
128
|
+
shouldBeHidden: editor => editor.isActive('columns'),
|
|
129
|
+
action: ({ editor, range }: any) => {
|
|
130
|
+
editor.chain().focus().deleteRange(range).run();
|
|
131
|
+
actionDialogVideo.setOpen(editor.id, true);
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (extension.name.toLowerCase() === 'table') {
|
|
137
|
+
groups[1].commands.push({
|
|
138
|
+
name: 'table',
|
|
139
|
+
label: localeActions.t('editor.table.tooltip'),
|
|
140
|
+
iconName: 'Table',
|
|
141
|
+
description: 'Insert a table',
|
|
142
|
+
aliases: ['table', 'bg', 'biaoge', 'biao'],
|
|
143
|
+
shouldBeHidden: editor => editor.isActive('columns'),
|
|
144
|
+
action: ({ editor, range }) => {
|
|
145
|
+
editor
|
|
146
|
+
.chain()
|
|
147
|
+
.focus()
|
|
148
|
+
.deleteRange(range)
|
|
149
|
+
.insertTable({ rows: 3, cols: 3, withHeaderRow: false })
|
|
150
|
+
.run();
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (extension.name.toLowerCase() === 'horizontalrule') {
|
|
156
|
+
groups[1].commands.push({
|
|
157
|
+
name: 'horizontalRule',
|
|
158
|
+
label: localeActions.t('editor.horizontalrule.tooltip'),
|
|
159
|
+
iconName: 'Minus',
|
|
160
|
+
description: 'Insert a horizontal divider',
|
|
161
|
+
aliases: ['hr', 'fgx', 'fg'],
|
|
162
|
+
action: ({ editor, range }) => {
|
|
163
|
+
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (extension.name.toLowerCase() === 'columns') {
|
|
169
|
+
groups[1].commands.push({
|
|
170
|
+
name: 'columns',
|
|
171
|
+
label: localeActions.t('editor.columns.tooltip'),
|
|
172
|
+
iconName: 'Columns2',
|
|
173
|
+
description: 'Add two column content',
|
|
174
|
+
action: ({ editor }) => {
|
|
175
|
+
editor.chain().focus().insertColumns({ cols: 2 }).run();
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
renderGroupItem?.(extension, groups);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return groups;
|
|
183
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SlashCommand';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Editor, Range } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
export interface Group {
|
|
4
|
+
name: string
|
|
5
|
+
title: string
|
|
6
|
+
commands: Command[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Command {
|
|
10
|
+
name: string
|
|
11
|
+
label: string
|
|
12
|
+
description?: string
|
|
13
|
+
aliases?: string[]
|
|
14
|
+
iconName?: any
|
|
15
|
+
iconUrl?: string
|
|
16
|
+
action: ({ editor, range }: { editor: Editor, range: Range }) => void
|
|
17
|
+
shouldBeHidden?: (editor: Editor) => boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MenuListProps {
|
|
21
|
+
editor: Editor
|
|
22
|
+
items: Group[]
|
|
23
|
+
command: (command: Command) => void
|
|
24
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StrikeOptions as TiptapStrikeOptions } from '@tiptap/extension-strike';
|
|
2
|
+
import { Strike as TiptapStrike } from '@tiptap/extension-strike';
|
|
3
|
+
|
|
4
|
+
import { ActionButton } from '@/components';
|
|
5
|
+
import type { GeneralOptions } from '@/types';
|
|
6
|
+
|
|
7
|
+
export interface StrikeOptions extends TiptapStrikeOptions, GeneralOptions<StrikeOptions> {}
|
|
8
|
+
|
|
9
|
+
export const Strike = TiptapStrike.extend<StrikeOptions>({
|
|
10
|
+
addOptions() {
|
|
11
|
+
return {
|
|
12
|
+
...this.parent?.(),
|
|
13
|
+
button: ({ editor, t }: any) => ({
|
|
14
|
+
component: ActionButton,
|
|
15
|
+
componentProps: {
|
|
16
|
+
action: () => editor.commands.toggleStrike(),
|
|
17
|
+
isActive: () => editor.isActive('strike') || false,
|
|
18
|
+
disabled: !editor.can().toggleStrike(),
|
|
19
|
+
icon: 'Strikethrough',
|
|
20
|
+
shortcutKeys: ['shift', 'mod', 'S'],
|
|
21
|
+
tooltip: t('editor.strike.tooltip'),
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Strike';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Extensions } from '@tiptap/core';
|
|
2
|
+
import { Extension } from '@tiptap/core';
|
|
3
|
+
import type { SubscriptExtensionOptions as TiptapSubscriptOptions } from '@tiptap/extension-subscript';
|
|
4
|
+
import { Subscript as TiptapSubscript } from '@tiptap/extension-subscript';
|
|
5
|
+
import type { SuperscriptExtensionOptions as TiptapSuperscriptOptions } from '@tiptap/extension-superscript';
|
|
6
|
+
import { Superscript as TiptapSuperscript } from '@tiptap/extension-superscript';
|
|
7
|
+
|
|
8
|
+
import { ActionButton } from '@/components';
|
|
9
|
+
import type { ButtonViewReturn, GeneralOptions } from '@/types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents the interface for subscript and superscript options, extending GeneralOptions.
|
|
13
|
+
*/
|
|
14
|
+
export interface SubAndSuperScriptOptions extends GeneralOptions<SubAndSuperScriptOptions> {
|
|
15
|
+
/**
|
|
16
|
+
* subscript options or false, indicating whether subscript is enabled
|
|
17
|
+
*
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
subscript: Partial<TiptapSubscriptOptions> | false
|
|
21
|
+
/**
|
|
22
|
+
* superscript options or false, indicating whether superscript is enabled
|
|
23
|
+
*
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
superscript: Partial<TiptapSuperscriptOptions> | false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SubAndSuperScript = Extension.create<SubAndSuperScriptOptions>({
|
|
30
|
+
name: 'subAndSuperScript',
|
|
31
|
+
|
|
32
|
+
addOptions() {
|
|
33
|
+
return {
|
|
34
|
+
...this.parent?.(),
|
|
35
|
+
button: ({ editor, extension, t }) => {
|
|
36
|
+
const subscript = extension.options.subscript;
|
|
37
|
+
const superscript = extension.options.superscript;
|
|
38
|
+
|
|
39
|
+
const subBtn: ButtonViewReturn = {
|
|
40
|
+
component: ActionButton,
|
|
41
|
+
componentProps: {
|
|
42
|
+
action: () => editor.commands.toggleSubscript(),
|
|
43
|
+
isActive: () => editor.isActive('subscript') || false,
|
|
44
|
+
disabled: !editor.can().toggleSubscript(),
|
|
45
|
+
icon: 'Subscript',
|
|
46
|
+
tooltip: t('editor.subscript.tooltip'),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const superBtn: ButtonViewReturn = {
|
|
51
|
+
component: ActionButton,
|
|
52
|
+
componentProps: {
|
|
53
|
+
action: () => editor.commands.toggleSuperscript(),
|
|
54
|
+
isActive: () => editor.isActive('superscript') || false,
|
|
55
|
+
disabled: !editor.can().toggleSuperscript(),
|
|
56
|
+
icon: 'Superscript',
|
|
57
|
+
tooltip: t('editor.superscript.tooltip'),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const items: ButtonViewReturn[] = [];
|
|
62
|
+
|
|
63
|
+
if (subscript !== false) {
|
|
64
|
+
items.push(subBtn);
|
|
65
|
+
}
|
|
66
|
+
if (superscript !== false) {
|
|
67
|
+
items.push(superBtn);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return items;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
addExtensions() {
|
|
76
|
+
const extensions: Extensions = [];
|
|
77
|
+
|
|
78
|
+
if (this.options.subscript !== false) {
|
|
79
|
+
extensions.push(TiptapSubscript.configure(this.options.subscript));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.options.superscript !== false) {
|
|
83
|
+
extensions.push(TiptapSuperscript.configure(this.options.superscript));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return extensions;
|
|
87
|
+
},
|
|
88
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Subscript';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { mergeAttributes, Node } from '@tiptap/core';
|
|
2
|
+
import { Plugin } from '@tiptap/pm/state';
|
|
3
|
+
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
4
|
+
|
|
5
|
+
import { getCellsInColumn, isRowSelected, selectRow } from './utils';
|
|
6
|
+
|
|
7
|
+
export interface TableCellOptions {
|
|
8
|
+
HTMLAttributes: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const TableCell = Node.create<TableCellOptions>({
|
|
12
|
+
name: 'tableCell',
|
|
13
|
+
|
|
14
|
+
content: 'block+', // TODO: Do not allow table in table
|
|
15
|
+
|
|
16
|
+
tableRole: 'cell',
|
|
17
|
+
|
|
18
|
+
isolating: true,
|
|
19
|
+
|
|
20
|
+
addOptions() {
|
|
21
|
+
return {
|
|
22
|
+
HTMLAttributes: {},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
parseHTML() {
|
|
27
|
+
return [{ tag: 'td' }];
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
renderHTML({ HTMLAttributes }) {
|
|
31
|
+
return [
|
|
32
|
+
'td',
|
|
33
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
34
|
+
0,
|
|
35
|
+
];
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
addAttributes() {
|
|
39
|
+
return {
|
|
40
|
+
colspan: {
|
|
41
|
+
default: 1,
|
|
42
|
+
parseHTML: (element) => {
|
|
43
|
+
const colspan = element.getAttribute('colspan');
|
|
44
|
+
const value = colspan ? Number.parseInt(colspan, 10) : 1;
|
|
45
|
+
|
|
46
|
+
return value;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
rowspan: {
|
|
50
|
+
default: 1,
|
|
51
|
+
parseHTML: (element) => {
|
|
52
|
+
const rowspan = element.getAttribute('rowspan');
|
|
53
|
+
const value = rowspan ? Number.parseInt(rowspan, 10) : 1;
|
|
54
|
+
|
|
55
|
+
return value;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
colwidth: {
|
|
59
|
+
default: null,
|
|
60
|
+
parseHTML: (element) => {
|
|
61
|
+
const colwidth = element.getAttribute('colwidth');
|
|
62
|
+
const value = colwidth ? [Number.parseInt(colwidth, 10)] : null;
|
|
63
|
+
|
|
64
|
+
return value;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
style: {
|
|
68
|
+
default: null,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
addProseMirrorPlugins() {
|
|
74
|
+
const { isEditable } = this.editor;
|
|
75
|
+
|
|
76
|
+
return [
|
|
77
|
+
new Plugin({
|
|
78
|
+
props: {
|
|
79
|
+
decorations: (state) => {
|
|
80
|
+
if (!isEditable) {
|
|
81
|
+
return DecorationSet.empty;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const { doc, selection } = state;
|
|
85
|
+
const decorations: Decoration[] = [];
|
|
86
|
+
const cells = getCellsInColumn(0)(selection);
|
|
87
|
+
|
|
88
|
+
if (cells) {
|
|
89
|
+
cells.forEach(({ pos }: { pos: number }, index: number) => {
|
|
90
|
+
decorations.push(
|
|
91
|
+
Decoration.widget(pos + 1, () => {
|
|
92
|
+
const rowSelected = isRowSelected(index)(selection);
|
|
93
|
+
let className = 'grip-row';
|
|
94
|
+
|
|
95
|
+
if (rowSelected) {
|
|
96
|
+
className += ' selected';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (index === 0) {
|
|
100
|
+
className += ' first';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (index === cells.length - 1) {
|
|
104
|
+
className += ' last';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const grip = document.createElement('a');
|
|
108
|
+
|
|
109
|
+
grip.className = className;
|
|
110
|
+
grip.addEventListener('mousedown', (event) => {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
event.stopImmediatePropagation();
|
|
113
|
+
|
|
114
|
+
this.editor.view.dispatch(
|
|
115
|
+
selectRow(index)(this.editor.state.tr),
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return grip;
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return DecorationSet.create(doc, decorations);
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
];
|
|
130
|
+
},
|
|
131
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import TiptapTableHeader from '@tiptap/extension-table-header';
|
|
2
|
+
import { Plugin } from '@tiptap/pm/state';
|
|
3
|
+
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
4
|
+
|
|
5
|
+
import { getCellsInRow, isColumnSelected, selectColumn } from './utils';
|
|
6
|
+
|
|
7
|
+
export const TableHeader = TiptapTableHeader.extend({
|
|
8
|
+
addAttributes() {
|
|
9
|
+
return {
|
|
10
|
+
colspan: {
|
|
11
|
+
default: 1,
|
|
12
|
+
},
|
|
13
|
+
rowspan: {
|
|
14
|
+
default: 1,
|
|
15
|
+
},
|
|
16
|
+
colwidth: {
|
|
17
|
+
default: null,
|
|
18
|
+
parseHTML: (element) => {
|
|
19
|
+
const colwidth = element.getAttribute('colwidth');
|
|
20
|
+
const value = colwidth
|
|
21
|
+
? colwidth.split(',').map((item) => Number.parseInt(item, 10))
|
|
22
|
+
: null;
|
|
23
|
+
|
|
24
|
+
return value;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
style: {
|
|
28
|
+
default: null,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
addProseMirrorPlugins() {
|
|
34
|
+
const { isEditable } = this.editor;
|
|
35
|
+
|
|
36
|
+
return [
|
|
37
|
+
new Plugin({
|
|
38
|
+
props: {
|
|
39
|
+
decorations: (state) => {
|
|
40
|
+
if (!isEditable) {
|
|
41
|
+
return DecorationSet.empty;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { doc, selection } = state;
|
|
45
|
+
const decorations: Decoration[] = [];
|
|
46
|
+
const cells = getCellsInRow(0)(selection);
|
|
47
|
+
|
|
48
|
+
if (cells) {
|
|
49
|
+
cells.forEach(({ pos }: { pos: number }, index: number) => {
|
|
50
|
+
decorations.push(
|
|
51
|
+
Decoration.widget(pos + 1, () => {
|
|
52
|
+
const colSelected = isColumnSelected(index)(selection);
|
|
53
|
+
let className = 'grip-column';
|
|
54
|
+
|
|
55
|
+
if (colSelected) {
|
|
56
|
+
className += ' selected';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (index === 0) {
|
|
60
|
+
className += ' first';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (index === cells.length - 1) {
|
|
64
|
+
className += ' last';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const grip = document.createElement('a');
|
|
68
|
+
|
|
69
|
+
grip.className = className;
|
|
70
|
+
grip.addEventListener('mousedown', (event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
event.stopImmediatePropagation();
|
|
73
|
+
|
|
74
|
+
this.editor.view.dispatch(
|
|
75
|
+
selectColumn(index)(this.editor.state.tr),
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return grip;
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return DecorationSet.create(doc, decorations);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export default TableHeader;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import TiptapTable from '@tiptap/extension-table';
|
|
2
|
+
import type { TableCellOptions } from '@tiptap/extension-table-cell';
|
|
3
|
+
import type { TableHeaderOptions } from '@tiptap/extension-table-header';
|
|
4
|
+
import type { TableRowOptions } from '@tiptap/extension-table-row';
|
|
5
|
+
|
|
6
|
+
import TableActionButton from '@/extensions/Table/components/TableActionButton';
|
|
7
|
+
import type { GeneralOptions } from '@/types';
|
|
8
|
+
|
|
9
|
+
import { TableCell } from './Cell';
|
|
10
|
+
import { TableCellBackground } from './cell-background';
|
|
11
|
+
import type { TableCellBackgroundOptions } from './cell-background';
|
|
12
|
+
import { TableHeader } from './Header';
|
|
13
|
+
import { TableRow } from './Row';
|
|
14
|
+
|
|
15
|
+
export interface TableOptions extends GeneralOptions<TableOptions> {
|
|
16
|
+
HTMLAttributes: Record<string, any>
|
|
17
|
+
resizable: boolean
|
|
18
|
+
handleWidth: number
|
|
19
|
+
cellMinWidth: number
|
|
20
|
+
lastColumnResizable: boolean
|
|
21
|
+
allowTableNodeSelection: boolean
|
|
22
|
+
/** options for table rows */
|
|
23
|
+
tableRow: Partial<TableRowOptions>
|
|
24
|
+
/** options for table headers */
|
|
25
|
+
tableHeader: Partial<TableHeaderOptions>
|
|
26
|
+
/** options for table cells */
|
|
27
|
+
tableCell: Partial<TableCellOptions>
|
|
28
|
+
/** options for table cell background */
|
|
29
|
+
tableCellBackground: Partial<TableCellBackgroundOptions>
|
|
30
|
+
}
|
|
31
|
+
export const Table = TiptapTable.extend<TableOptions>({
|
|
32
|
+
addOptions() {
|
|
33
|
+
return {
|
|
34
|
+
...this.parent?.(),
|
|
35
|
+
resizable: true,
|
|
36
|
+
lastColumnResizable: false,
|
|
37
|
+
allowTableNodeSelection: false,
|
|
38
|
+
button: ({ editor, t }: any) => ({
|
|
39
|
+
component: TableActionButton,
|
|
40
|
+
componentProps: {
|
|
41
|
+
disabled: editor.isActive('table') || false,
|
|
42
|
+
icon: 'Table',
|
|
43
|
+
tooltip: t('editor.table.tooltip'),
|
|
44
|
+
editor,
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
addExtensions() {
|
|
51
|
+
return [
|
|
52
|
+
TableRow.configure(this.options.tableRow),
|
|
53
|
+
TableHeader.configure(this.options.tableHeader),
|
|
54
|
+
TableCell.configure(this.options.tableCell),
|
|
55
|
+
TableCellBackground.configure(this.options.tableCellBackground),
|
|
56
|
+
];
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export default Table;
|