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,151 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { Editor } from '@tiptap/core';
|
|
5
|
+
import mermaid from 'mermaid';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import svg64 from 'svg64';
|
|
8
|
+
|
|
9
|
+
import { ActionButton } from '@/components/ActionButton';
|
|
10
|
+
import { Button } from '@/components/ui';
|
|
11
|
+
import { Dialog, DialogContent, DialogFooter, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
|
12
|
+
import { Textarea } from '@/components/ui/textarea';
|
|
13
|
+
import { dataURLtoFile } from '@/utils/file';
|
|
14
|
+
import { shortId } from '@/utils/shortId';
|
|
15
|
+
|
|
16
|
+
interface IProps {
|
|
17
|
+
editor: Editor, upload?: any
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultCode = 'graph TB\na-->b';
|
|
21
|
+
|
|
22
|
+
export const MermaidActiveButton: React.FC<IProps> = ({ editor, upload }) => {
|
|
23
|
+
const [mermaidCode, setMermaidCode] = useState(defaultCode);
|
|
24
|
+
const [svgCode, setSvgCode] = useState('');
|
|
25
|
+
const [visible, toggleVisible] = useState(false);
|
|
26
|
+
const mermaidRef = useRef<HTMLElement | null>(null);
|
|
27
|
+
|
|
28
|
+
const renderMermaid = async (value: any) => {
|
|
29
|
+
try {
|
|
30
|
+
const { svg } = await mermaid.render('mermaid-svg', value);
|
|
31
|
+
setSvgCode(svg);
|
|
32
|
+
} catch {
|
|
33
|
+
setSvgCode('');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const mermaidInit = () => {
|
|
38
|
+
mermaid.initialize({
|
|
39
|
+
darkMode: false,
|
|
40
|
+
startOnLoad: false,
|
|
41
|
+
// fontFamily:'',
|
|
42
|
+
fontSize: 12,
|
|
43
|
+
theme: 'base',
|
|
44
|
+
});
|
|
45
|
+
renderMermaid(mermaidCode);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (visible) {
|
|
50
|
+
mermaidInit();
|
|
51
|
+
}
|
|
52
|
+
}, [visible]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (visible) {
|
|
56
|
+
renderMermaid(mermaidCode);
|
|
57
|
+
}
|
|
58
|
+
}, [mermaidCode]);
|
|
59
|
+
|
|
60
|
+
const setMermaid = async () => {
|
|
61
|
+
if (mermaidCode === '') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (mermaidCode) {
|
|
65
|
+
const svg = mermaidRef.current!.querySelector('svg') as unknown as HTMLElement;
|
|
66
|
+
const { width, height } = svg.getBoundingClientRect();
|
|
67
|
+
const name = `mermaid-${shortId()}.svg`;
|
|
68
|
+
// const { size } = new Blob([svg.outerHTML], {
|
|
69
|
+
// type: 'image/svg+xml',
|
|
70
|
+
// })
|
|
71
|
+
|
|
72
|
+
let src = svg64(svg.outerHTML);
|
|
73
|
+
|
|
74
|
+
if (upload) {
|
|
75
|
+
const file = dataURLtoFile(src, name);
|
|
76
|
+
src = await upload(file);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
editor
|
|
80
|
+
?.chain()
|
|
81
|
+
.focus()
|
|
82
|
+
.setMermaid(
|
|
83
|
+
{
|
|
84
|
+
type: 'mermaid',
|
|
85
|
+
src,
|
|
86
|
+
alt: encodeURIComponent(mermaidCode),
|
|
87
|
+
width,
|
|
88
|
+
height,
|
|
89
|
+
},
|
|
90
|
+
!!mermaidCode,
|
|
91
|
+
)
|
|
92
|
+
.run();
|
|
93
|
+
}
|
|
94
|
+
toggleVisible(false);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Dialog
|
|
99
|
+
onOpenChange={toggleVisible}
|
|
100
|
+
open={visible}
|
|
101
|
+
>
|
|
102
|
+
<DialogTrigger asChild>
|
|
103
|
+
<ActionButton
|
|
104
|
+
action={() => toggleVisible(true)}
|
|
105
|
+
icon="Mermaid"
|
|
106
|
+
tooltip="Mermaid"
|
|
107
|
+
/>
|
|
108
|
+
</DialogTrigger>
|
|
109
|
+
|
|
110
|
+
<DialogContent className="z-[99999] !max-w-[1300px]">
|
|
111
|
+
<DialogTitle>
|
|
112
|
+
Mermaid
|
|
113
|
+
</DialogTitle>
|
|
114
|
+
|
|
115
|
+
<div style={{ height: '100%', borderWidth: 1 }}>
|
|
116
|
+
<div className="flex gap-[10px] rounded-[10px] p-[10px]">
|
|
117
|
+
<Textarea
|
|
118
|
+
autoFocus
|
|
119
|
+
className="flex-1"
|
|
120
|
+
defaultValue={defaultCode}
|
|
121
|
+
onChange={e => setMermaidCode(e.target.value)}
|
|
122
|
+
placeholder="Text"
|
|
123
|
+
required
|
|
124
|
+
rows={10}
|
|
125
|
+
value={mermaidCode}
|
|
126
|
+
style={{
|
|
127
|
+
color: 'hsl(var(--foreground))',
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
<div
|
|
132
|
+
className="flex flex-1 items-center justify-center rounded-[10px] p-[10px]"
|
|
133
|
+
dangerouslySetInnerHTML={{ __html: svgCode }}
|
|
134
|
+
ref={mermaidRef as any}
|
|
135
|
+
style={{ height: '100%', borderWidth: 1, minHeight: 500, background: '#fff' }}
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<DialogFooter>
|
|
141
|
+
<Button
|
|
142
|
+
onClick={setMermaid}
|
|
143
|
+
type="button"
|
|
144
|
+
>
|
|
145
|
+
Save changes
|
|
146
|
+
</Button>
|
|
147
|
+
</DialogFooter>
|
|
148
|
+
</DialogContent>
|
|
149
|
+
</Dialog>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/* eslint-disable no-unsafe-optional-chaining */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { NodeViewWrapper, isNumber } from '@tiptap/react';
|
|
7
|
+
import { throttle } from 'lodash-es';
|
|
8
|
+
|
|
9
|
+
import { IMAGE_MAX_SIZE, IMAGE_MIN_SIZE, IMAGE_THROTTLE_WAIT_TIME } from '@/constants';
|
|
10
|
+
import { clamp } from '@/utils/utils';
|
|
11
|
+
|
|
12
|
+
interface Size {
|
|
13
|
+
width: number
|
|
14
|
+
height: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ResizeDirection = {
|
|
18
|
+
TOP_LEFT: 'tl',
|
|
19
|
+
TOP_RIGHT: 'tr',
|
|
20
|
+
BOTTOM_LEFT: 'bl',
|
|
21
|
+
BOTTOM_RIGHT: 'br',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function NodeViewMermaid({ editor, node, updateAttributes, getPos, selected }: any) {
|
|
25
|
+
const [maxSize, setMaxSize] = useState<Size>({
|
|
26
|
+
width: IMAGE_MAX_SIZE,
|
|
27
|
+
height: IMAGE_MAX_SIZE,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const [originalSize, setOriginalSize] = useState({
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const [resizeDirections] = useState<string[]>([
|
|
36
|
+
ResizeDirection.TOP_LEFT,
|
|
37
|
+
ResizeDirection.TOP_RIGHT,
|
|
38
|
+
ResizeDirection.BOTTOM_LEFT,
|
|
39
|
+
ResizeDirection.BOTTOM_RIGHT,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const [resizing, setResizing] = useState<boolean>(false);
|
|
43
|
+
|
|
44
|
+
const [resizerState, setResizerState] = useState({
|
|
45
|
+
x: 0,
|
|
46
|
+
y: 0,
|
|
47
|
+
w: 0,
|
|
48
|
+
h: 0,
|
|
49
|
+
dir: '',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const { align } = node?.attrs;
|
|
53
|
+
|
|
54
|
+
const imgAttrs = useMemo(() => {
|
|
55
|
+
const { src, alt, width: w, height: h } = node?.attrs;
|
|
56
|
+
|
|
57
|
+
const width = isNumber(w) ? `${w}px` : w;
|
|
58
|
+
const height = isNumber(h) ? `${h}px` : h;
|
|
59
|
+
return {
|
|
60
|
+
src: src || undefined,
|
|
61
|
+
alt: alt || undefined,
|
|
62
|
+
style: {
|
|
63
|
+
width: width || undefined,
|
|
64
|
+
height: height || undefined,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}, [node?.attrs]);
|
|
68
|
+
|
|
69
|
+
const imageMaxStyle = useMemo(() => {
|
|
70
|
+
const {
|
|
71
|
+
style: { width },
|
|
72
|
+
} = imgAttrs;
|
|
73
|
+
|
|
74
|
+
return { width: width === '100%' ? width : undefined };
|
|
75
|
+
}, [imgAttrs]);
|
|
76
|
+
|
|
77
|
+
function onImageLoad(e: Record<string, any>) {
|
|
78
|
+
setOriginalSize({
|
|
79
|
+
width: e.target.width,
|
|
80
|
+
height: e.target.height,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// https://github.com/scrumpy/tiptap/issues/361#issuecomment-540299541
|
|
85
|
+
function selectImage() {
|
|
86
|
+
editor.commands.setNodeSelection(getPos());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const getMaxSize = useCallback(
|
|
90
|
+
throttle(() => {
|
|
91
|
+
const { width } = getComputedStyle(editor.view.dom);
|
|
92
|
+
setMaxSize((prev) => {
|
|
93
|
+
return {
|
|
94
|
+
...prev,
|
|
95
|
+
width: Number.parseInt(width, 10),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}, IMAGE_THROTTLE_WAIT_TIME),
|
|
99
|
+
[editor],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
function onMouseDown(e: MouseEvent, dir: string) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
|
|
106
|
+
const originalWidth = originalSize.width;
|
|
107
|
+
const originalHeight = originalSize.height;
|
|
108
|
+
const aspectRatio = originalWidth / originalHeight;
|
|
109
|
+
|
|
110
|
+
let width = Number(node.attrs.width);
|
|
111
|
+
let height = Number(node.attrs.height);
|
|
112
|
+
const maxWidth = maxSize.width;
|
|
113
|
+
|
|
114
|
+
if (width && !height) {
|
|
115
|
+
width = width > maxWidth ? maxWidth : width;
|
|
116
|
+
height = Math.round(width / aspectRatio);
|
|
117
|
+
} else if (height && !width) {
|
|
118
|
+
width = Math.round(height * aspectRatio);
|
|
119
|
+
width = width > maxWidth ? maxWidth : width;
|
|
120
|
+
} else if (!width && !height) {
|
|
121
|
+
width = originalWidth > maxWidth ? maxWidth : originalWidth;
|
|
122
|
+
height = Math.round(width / aspectRatio);
|
|
123
|
+
} else {
|
|
124
|
+
width = width > maxWidth ? maxWidth : width;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setResizing(true);
|
|
128
|
+
|
|
129
|
+
setResizerState({
|
|
130
|
+
x: e.clientX,
|
|
131
|
+
y: e.clientY,
|
|
132
|
+
w: width,
|
|
133
|
+
h: height,
|
|
134
|
+
dir,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const onMouseMove = useCallback(
|
|
139
|
+
throttle((e: MouseEvent) => {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
|
|
143
|
+
if (!resizing) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const { x, w, dir } = resizerState;
|
|
148
|
+
|
|
149
|
+
const dx = (e.clientX - x) * (/l/.test(dir) ? -1 : 1);
|
|
150
|
+
// const dy = (e.clientY - y) * (/t/.test(dir) ? -1 : 1)
|
|
151
|
+
const { width: wI, height: hI } = node?.attrs;
|
|
152
|
+
const ratio = wI / hI;
|
|
153
|
+
|
|
154
|
+
const width = clamp(w + dx, IMAGE_MIN_SIZE, maxSize.width);
|
|
155
|
+
const height = Math.round(width / ratio);
|
|
156
|
+
|
|
157
|
+
updateAttributes({
|
|
158
|
+
width,
|
|
159
|
+
height,
|
|
160
|
+
});
|
|
161
|
+
}, IMAGE_THROTTLE_WAIT_TIME),
|
|
162
|
+
[resizing, resizerState, maxSize, updateAttributes, node?.attrs],
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const onMouseUp = useCallback(
|
|
166
|
+
(e: MouseEvent) => {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
e.stopPropagation();
|
|
169
|
+
if (!resizing) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
setResizerState({
|
|
174
|
+
x: 0,
|
|
175
|
+
y: 0,
|
|
176
|
+
w: 0,
|
|
177
|
+
h: 0,
|
|
178
|
+
dir: '',
|
|
179
|
+
});
|
|
180
|
+
setResizing(false);
|
|
181
|
+
|
|
182
|
+
selectImage();
|
|
183
|
+
},
|
|
184
|
+
[resizing, selectImage],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const onEvents = useCallback(() => {
|
|
188
|
+
document?.addEventListener('mousemove', onMouseMove, true);
|
|
189
|
+
document?.addEventListener('mouseup', onMouseUp, true);
|
|
190
|
+
}, [onMouseMove, onMouseUp]);
|
|
191
|
+
|
|
192
|
+
const offEvents = useCallback(() => {
|
|
193
|
+
document?.removeEventListener('mousemove', onMouseMove, true);
|
|
194
|
+
document?.removeEventListener('mouseup', onMouseUp, true);
|
|
195
|
+
}, [onMouseMove, onMouseUp]);
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
if (resizing) {
|
|
199
|
+
onEvents();
|
|
200
|
+
} else {
|
|
201
|
+
offEvents();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return () => {
|
|
205
|
+
offEvents();
|
|
206
|
+
};
|
|
207
|
+
}, [resizing, onEvents, offEvents]);
|
|
208
|
+
|
|
209
|
+
const resizeOb: ResizeObserver = useMemo(() => {
|
|
210
|
+
return new ResizeObserver(() => getMaxSize());
|
|
211
|
+
}, [getMaxSize]);
|
|
212
|
+
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
resizeOb.observe(editor.view.dom);
|
|
215
|
+
|
|
216
|
+
return () => {
|
|
217
|
+
resizeOb.disconnect();
|
|
218
|
+
};
|
|
219
|
+
}, [editor.view.dom, resizeOb]);
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<NodeViewWrapper className="image-view"
|
|
223
|
+
style={{ ...imageMaxStyle, width: '100%', textAlign: align }}
|
|
224
|
+
>
|
|
225
|
+
<div
|
|
226
|
+
data-drag-handle
|
|
227
|
+
draggable="true"
|
|
228
|
+
style={{ ...imageMaxStyle, background: '#fff' }}
|
|
229
|
+
className={`image-view__body ${selected ? 'image-view__body--focused' : ''} ${
|
|
230
|
+
resizing ? 'image-view__body--resizing' : ''
|
|
231
|
+
}`}
|
|
232
|
+
>
|
|
233
|
+
<img
|
|
234
|
+
alt={imgAttrs.alt}
|
|
235
|
+
className="image-view__body__image block"
|
|
236
|
+
height="auto"
|
|
237
|
+
onClick={selectImage}
|
|
238
|
+
onLoad={onImageLoad}
|
|
239
|
+
src={imgAttrs.src}
|
|
240
|
+
style={imgAttrs.style}
|
|
241
|
+
/>
|
|
242
|
+
|
|
243
|
+
{editor.view.editable && (selected || resizing) && (
|
|
244
|
+
<div className="image-resizer">
|
|
245
|
+
{resizeDirections?.map((direction) => {
|
|
246
|
+
return (
|
|
247
|
+
<span
|
|
248
|
+
className={`image-resizer__handler image-resizer__handler--${direction}`}
|
|
249
|
+
key={`image-dir-${direction}`}
|
|
250
|
+
onMouseDown={(e: any) => onMouseDown(e, direction)}
|
|
251
|
+
>
|
|
252
|
+
</span>
|
|
253
|
+
);
|
|
254
|
+
})}
|
|
255
|
+
</div>
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
</NodeViewWrapper>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Mermaid';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import type { Extensions } 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 type { Item } from '@/extensions/MoreMark/components/ActionMoreButton';
|
|
9
|
+
import ActionMoreButton from '@/extensions/MoreMark/components/ActionMoreButton';
|
|
10
|
+
import type { GeneralOptions } from '@/types';
|
|
11
|
+
|
|
12
|
+
export interface MoreMarkOptions extends GeneralOptions<MoreMarkOptions> {
|
|
13
|
+
/**
|
|
14
|
+
* // 下标
|
|
15
|
+
*
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
subscript: Partial<TiptapSubscriptOptions> | false
|
|
19
|
+
/**
|
|
20
|
+
* // 上标
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
superscript: Partial<TiptapSuperscriptOptions> | false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const MoreMark = Extension.create<MoreMarkOptions>({
|
|
28
|
+
name: 'moreMark',
|
|
29
|
+
addOptions() {
|
|
30
|
+
return {
|
|
31
|
+
...this.parent?.(),
|
|
32
|
+
button({ editor, extension, t }) {
|
|
33
|
+
const subscript = extension.options.subscript;
|
|
34
|
+
const superscript = extension.options.superscript;
|
|
35
|
+
const subBtn: Item = {
|
|
36
|
+
action: () => editor.commands.toggleSubscript(),
|
|
37
|
+
isActive: () => editor.isActive('subscript') || false,
|
|
38
|
+
disabled: !editor.can().toggleSubscript(),
|
|
39
|
+
icon: 'Subscript',
|
|
40
|
+
title: t('editor.subscript.tooltip'),
|
|
41
|
+
shortcutKeys: ['mod', '.'],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const superBtn: Item = {
|
|
45
|
+
action: () => editor.commands.toggleSuperscript(),
|
|
46
|
+
isActive: () => editor.isActive('superscript') || false,
|
|
47
|
+
disabled: !editor.can().toggleSuperscript(),
|
|
48
|
+
icon: 'Superscript',
|
|
49
|
+
title: t('editor.superscript.tooltip'),
|
|
50
|
+
shortcutKeys: ['mod', ','],
|
|
51
|
+
};
|
|
52
|
+
// const hasCode = hasExtension(editor, 'code');
|
|
53
|
+
|
|
54
|
+
const items: Item[] = [];
|
|
55
|
+
|
|
56
|
+
if (subscript !== false) {
|
|
57
|
+
items.push(subBtn);
|
|
58
|
+
}
|
|
59
|
+
if (superscript !== false) {
|
|
60
|
+
items.push(superBtn);
|
|
61
|
+
}
|
|
62
|
+
// if (hasCode) {
|
|
63
|
+
// const codeBtn: Item = {
|
|
64
|
+
// action: () => editor.commands.toggleCode(),
|
|
65
|
+
// isActive: () => editor.isActive('code') || false,
|
|
66
|
+
// disabled: !editor.can().toggleCode(),
|
|
67
|
+
// icon: 'Code',
|
|
68
|
+
// title: t('editor.code.tooltip'),
|
|
69
|
+
// shortcutKeys: ['mod', 'E'],
|
|
70
|
+
// };
|
|
71
|
+
// if (hasCode) {
|
|
72
|
+
// items.push(codeBtn);
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
component: ActionMoreButton,
|
|
78
|
+
componentProps: {
|
|
79
|
+
icon: 'Type',
|
|
80
|
+
tooltip: t('editor.moremark'),
|
|
81
|
+
disabled: !editor.isEditable,
|
|
82
|
+
items,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
addExtensions() {
|
|
90
|
+
const extensions: Extensions = [];
|
|
91
|
+
|
|
92
|
+
if (this.options.subscript !== false) {
|
|
93
|
+
extensions.push(TiptapSubscript.configure(this.options.subscript));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.options.superscript !== false) {
|
|
97
|
+
extensions.push(TiptapSuperscript.configure(this.options.superscript));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return extensions;
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ActionButton,
|
|
5
|
+
DropdownMenu,
|
|
6
|
+
DropdownMenuCheckboxItem,
|
|
7
|
+
DropdownMenuContent,
|
|
8
|
+
DropdownMenuTrigger,
|
|
9
|
+
IconComponent,
|
|
10
|
+
MenuDown,
|
|
11
|
+
} from '@/components';
|
|
12
|
+
import type { ButtonViewReturnComponentProps } from '@/types';
|
|
13
|
+
import { getShortcutKeys } from '@/utils/plateform';
|
|
14
|
+
|
|
15
|
+
export interface Item {
|
|
16
|
+
title: string
|
|
17
|
+
icon?: any
|
|
18
|
+
isActive: NonNullable<ButtonViewReturnComponentProps['isActive']>
|
|
19
|
+
action?: ButtonViewReturnComponentProps['action']
|
|
20
|
+
style?: React.CSSProperties
|
|
21
|
+
shortcutKeys?: string[]
|
|
22
|
+
disabled?: boolean
|
|
23
|
+
divider?: boolean
|
|
24
|
+
default?: boolean
|
|
25
|
+
}
|
|
26
|
+
interface IPropsActionMoreButton {
|
|
27
|
+
editor: any
|
|
28
|
+
disabled?: boolean
|
|
29
|
+
color?: string
|
|
30
|
+
maxHeight?: string | number
|
|
31
|
+
icon?: any
|
|
32
|
+
tooltip?: string
|
|
33
|
+
items?: Item[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ActionMoreButton(props: IPropsActionMoreButton) {
|
|
37
|
+
const active = useMemo(() => {
|
|
38
|
+
const find: any = props?.items?.find((k: any) => k.isActive());
|
|
39
|
+
if (find && !find.default) {
|
|
40
|
+
return {
|
|
41
|
+
...find,
|
|
42
|
+
icon: find?.icon ? find?.icon : props?.icon,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const item: Item = {
|
|
46
|
+
title: props.tooltip as any,
|
|
47
|
+
icon: props.icon,
|
|
48
|
+
isActive: () => false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return item;
|
|
52
|
+
}, [props]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<DropdownMenu>
|
|
56
|
+
<DropdownMenuTrigger asChild
|
|
57
|
+
disabled={props?.disabled}
|
|
58
|
+
>
|
|
59
|
+
<ActionButton
|
|
60
|
+
customClass="!w-12 h-12"
|
|
61
|
+
disabled={props?.disabled}
|
|
62
|
+
icon={props?.icon}
|
|
63
|
+
tooltip={props?.tooltip}
|
|
64
|
+
>
|
|
65
|
+
<MenuDown className="size-3 text-gray-500" />
|
|
66
|
+
</ActionButton>
|
|
67
|
+
</DropdownMenuTrigger>
|
|
68
|
+
|
|
69
|
+
<DropdownMenuContent className="w-full">
|
|
70
|
+
{props?.items?.map((item: any, index) => {
|
|
71
|
+
return (
|
|
72
|
+
<DropdownMenuCheckboxItem
|
|
73
|
+
checked={active.title === item.title}
|
|
74
|
+
className="flex items-center gap-3"
|
|
75
|
+
key={`more-mark-${index}`}
|
|
76
|
+
onClick={item.action}
|
|
77
|
+
>
|
|
78
|
+
<IconComponent name={item?.icon} />
|
|
79
|
+
|
|
80
|
+
<span className="ml-1">
|
|
81
|
+
{item.title}
|
|
82
|
+
</span>
|
|
83
|
+
|
|
84
|
+
{!!item?.shortcutKeys && (
|
|
85
|
+
<span className="ml-auto text-xs tracking-widest opacity-60">
|
|
86
|
+
{getShortcutKeys(item.shortcutKeys)}
|
|
87
|
+
</span>
|
|
88
|
+
)}
|
|
89
|
+
</DropdownMenuCheckboxItem>
|
|
90
|
+
);
|
|
91
|
+
})}
|
|
92
|
+
</DropdownMenuContent>
|
|
93
|
+
</DropdownMenu>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default ActionMoreButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MoreMark';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
export const Column = Node.create({
|
|
4
|
+
name: 'column',
|
|
5
|
+
content: 'block+',
|
|
6
|
+
isolating: true,
|
|
7
|
+
|
|
8
|
+
addOptions() {
|
|
9
|
+
return {
|
|
10
|
+
HTMLAttributes: {
|
|
11
|
+
class: 'column',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
addAttributes() {
|
|
17
|
+
return {
|
|
18
|
+
index: {
|
|
19
|
+
default: 0,
|
|
20
|
+
parseHTML: element => element.getAttribute('index'),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
parseHTML() {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
tag: 'div[class=column]',
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
renderHTML({ HTMLAttributes }) {
|
|
34
|
+
return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
35
|
+
},
|
|
36
|
+
});
|