reactjs-tiptap-editor-pro 0.2.31 → 0.2.32
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/lib/RichTextEditor-BwbqJLnA.cjs +141 -0
- package/lib/RichTextEditor-iGJ6-rbq.js +8833 -0
- package/lib/extension-bundle.cjs +33 -0
- package/lib/extension-bundle.d.cts +947 -0
- package/lib/extension-bundle.d.ts +947 -0
- package/lib/extension-bundle.js +5755 -0
- package/lib/index-DV-nXpU1.cjs +1 -0
- package/lib/index-M6H3FoBi.js +1147 -0
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +513 -0
- package/lib/index.d.ts +513 -0
- package/lib/index.js +16 -0
- package/lib/locale-bundle.cjs +1 -0
- package/lib/locale-bundle.d.cts +1140 -0
- package/lib/locale-bundle.d.ts +1140 -0
- package/lib/locale-bundle.js +9 -0
- package/lib/style.css +1 -0
- package/lib/tiptap-DkWHMWDt.js +6061 -0
- package/lib/tiptap-gBG-1T-V.cjs +116 -0
- package/lib/vendor-BJ0Yf78E.cjs +8114 -0
- package/lib/vendor-Cpa6z-M0.js +67575 -0
- package/package.json +58 -5
- package/src/components/ActionButton.tsx +0 -103
- package/src/components/ActionMenuButton.tsx +0 -76
- package/src/components/BubbleMenu.tsx +0 -93
- package/src/components/CharactorCount.tsx +0 -50
- package/src/components/ColorPicker.tsx +0 -272
- package/src/components/RichTextEditor.tsx +0 -212
- package/src/components/SizeSetter/SizeSetter.tsx +0 -102
- package/src/components/Toolbar.tsx +0 -108
- package/src/components/icons/Activity.tsx +0 -19
- package/src/components/icons/Animas.tsx +0 -24
- package/src/components/icons/AspectRatio.tsx +0 -13
- package/src/components/icons/Blockquote.tsx +0 -17
- package/src/components/icons/ColumnAddLeft.tsx +0 -7
- package/src/components/icons/ColumnAddRight.tsx +0 -7
- package/src/components/icons/DeleteColumn.tsx +0 -26
- package/src/components/icons/DeleteRow.tsx +0 -26
- package/src/components/icons/Direction.tsx +0 -7
- package/src/components/icons/Excalidraw.tsx +0 -7
- package/src/components/icons/ExportPdf.tsx +0 -8
- package/src/components/icons/ExportWord.tsx +0 -24
- package/src/components/icons/FileWordOutline.tsx +0 -13
- package/src/components/icons/Flag.tsx +0 -19
- package/src/components/icons/Food.tsx +0 -20
- package/src/components/icons/GIfIcon.tsx +0 -10
- package/src/components/icons/Icon.tsx +0 -30
- package/src/components/icons/ImportWord.tsx +0 -23
- package/src/components/icons/LeftToRight.tsx +0 -7
- package/src/components/icons/LineHeight.tsx +0 -13
- package/src/components/icons/MenuDown.tsx +0 -24
- package/src/components/icons/Mermaid.tsx +0 -13
- package/src/components/icons/NoFill.tsx +0 -7
- package/src/components/icons/Object.tsx +0 -24
- package/src/components/icons/RightToLeft.tsx +0 -7
- package/src/components/icons/SizeL.tsx +0 -9
- package/src/components/icons/SizeM.tsx +0 -13
- package/src/components/icons/SizeS.tsx +0 -13
- package/src/components/icons/Symbol.tsx +0 -19
- package/src/components/icons/Travel.tsx +0 -24
- package/src/components/icons/Twitter.tsx +0 -7
- package/src/components/icons/icons.ts +0 -212
- package/src/components/icons/index.ts +0 -12
- package/src/components/index.ts +0 -9
- package/src/components/menus/bubble.ts +0 -395
- package/src/components/menus/components/BubbleMenuContent.tsx +0 -15
- package/src/components/menus/components/BubbleMenuDrawer.tsx +0 -128
- package/src/components/menus/components/BubbleMenuExcalidraw.tsx +0 -91
- package/src/components/menus/components/BubbleMenuIframe.tsx +0 -143
- package/src/components/menus/components/BubbleMenuKatex.tsx +0 -136
- package/src/components/menus/components/BubbleMenuLink.tsx +0 -99
- package/src/components/menus/components/BubbleMenuMedia.tsx +0 -235
- package/src/components/menus/components/BubbleMenuMermaid.tsx +0 -128
- package/src/components/menus/components/BubbleMenuText.tsx +0 -102
- package/src/components/menus/components/BubbleMenuTwitter.tsx +0 -91
- package/src/components/menus/components/ColumnsBubbleMenu.tsx +0 -59
- package/src/components/menus/components/ContentMenu.tsx +0 -396
- package/src/components/menus/components/TableBubbleMenu.tsx +0 -362
- package/src/components/menus/index.ts +0 -7
- package/src/components/ui/button.tsx +0 -56
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/dialog.tsx +0 -128
- package/src/components/ui/dropdown-menu.tsx +0 -203
- package/src/components/ui/emoji-picker.tsx +0 -166
- package/src/components/ui/index.ts +0 -14
- package/src/components/ui/input.tsx +0 -25
- package/src/components/ui/label.tsx +0 -26
- package/src/components/ui/popover.tsx +0 -31
- package/src/components/ui/select.tsx +0 -162
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/switch.tsx +0 -29
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/textarea.tsx +0 -24
- package/src/components/ui/toast.tsx +0 -129
- package/src/components/ui/toaster.tsx +0 -44
- package/src/components/ui/toggle.tsx +0 -45
- package/src/components/ui/tooltip.tsx +0 -30
- package/src/components/ui/use-toast.ts +0 -197
- package/src/constants/index.ts +0 -223
- package/src/constants/resetCSS.ts +0 -139
- package/src/extension-bundle.ts +0 -2
- package/src/extensions/Attachment/Attachment.ts +0 -144
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +0 -69
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +0 -28
- package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +0 -155
- package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +0 -23
- package/src/extensions/Attachment/index.ts +0 -1
- package/src/extensions/BaseKit.ts +0 -253
- package/src/extensions/Blockquote/Blockquote.ts +0 -31
- package/src/extensions/Blockquote/index.ts +0 -1
- package/src/extensions/Bold/Bold.ts +0 -26
- package/src/extensions/Bold/index.ts +0 -1
- package/src/extensions/BulletList/BulletList.ts +0 -28
- package/src/extensions/BulletList/index.ts +0 -1
- package/src/extensions/Clear/Clear.ts +0 -24
- package/src/extensions/Clear/index.ts +0 -1
- package/src/extensions/Code/Code.ts +0 -26
- package/src/extensions/Code/index.ts +0 -1
- package/src/extensions/CodeBlock/CodeBlock.ts +0 -54
- package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +0 -66
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +0 -89
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +0 -81
- package/src/extensions/CodeBlock/highlighter.ts +0 -132
- package/src/extensions/CodeBlock/index.ts +0 -1
- package/src/extensions/CodeBlock/shiki-plugin.ts +0 -213
- package/src/extensions/Color/Color.ts +0 -52
- package/src/extensions/Color/components/ColorActionButton.tsx +0 -104
- package/src/extensions/Color/index.ts +0 -1
- package/src/extensions/Document/Document.ts +0 -8
- package/src/extensions/Document/index.ts +0 -1
- package/src/extensions/Drawer/Drawer.ts +0 -177
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +0 -85
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +0 -598
- package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +0 -500
- package/src/extensions/Drawer/components/DrawerActiveButton.tsx +0 -239
- package/src/extensions/Drawer/components/EditDrawerBlock.tsx +0 -238
- package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +0 -260
- package/src/extensions/Drawer/index.ts +0 -1
- package/src/extensions/Emoji/Emoji.ts +0 -146
- package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +0 -103
- package/src/extensions/Emoji/components/EmojiList/emojis.ts +0 -1858
- package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +0 -61
- package/src/extensions/Emoji/index.ts +0 -1
- package/src/extensions/Excalidraw/Excalidraw.ts +0 -123
- package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +0 -138
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +0 -178
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +0 -43
- package/src/extensions/Excalidraw/index.ts +0 -1
- package/src/extensions/ExportPdf/ExportPdf.ts +0 -25
- package/src/extensions/ExportPdf/index.ts +0 -1
- package/src/extensions/ExportWord/ExportWord.ts +0 -87
- package/src/extensions/ExportWord/index.ts +0 -1
- package/src/extensions/FontFamily/FontFamily.ts +0 -64
- package/src/extensions/FontFamily/components/FontFamilyButton.tsx +0 -97
- package/src/extensions/FontFamily/index.ts +0 -1
- package/src/extensions/FontSize/FontSize.ts +0 -119
- package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +0 -84
- package/src/extensions/FontSize/index.ts +0 -1
- package/src/extensions/FormatPainter/FormatPainter.ts +0 -121
- package/src/extensions/FormatPainter/index.ts +0 -1
- package/src/extensions/Heading/Heading.ts +0 -57
- package/src/extensions/Heading/components/HeadingButton.tsx +0 -96
- package/src/extensions/Heading/index.ts +0 -1
- package/src/extensions/Highlight/Highlight.ts +0 -36
- package/src/extensions/Highlight/components/HighlightActionButton.tsx +0 -108
- package/src/extensions/Highlight/index.ts +0 -1
- package/src/extensions/History/History.ts +0 -39
- package/src/extensions/History/components/HistoryActionButton.tsx +0 -74
- package/src/extensions/History/index.ts +0 -1
- package/src/extensions/HorizontalRule/HorizontalRule.ts +0 -42
- package/src/extensions/HorizontalRule/index.ts +0 -1
- package/src/extensions/Iframe/Iframe.ts +0 -140
- package/src/extensions/Iframe/components/IframeNodeView.tsx +0 -92
- package/src/extensions/Iframe/components/index.module.scss +0 -40
- package/src/extensions/Iframe/embed.ts +0 -487
- package/src/extensions/Iframe/index.ts +0 -1
- package/src/extensions/Image/Image.ts +0 -303
- package/src/extensions/Image/components/ActionImageButton.tsx +0 -186
- package/src/extensions/Image/components/ImageCropper.tsx +0 -198
- package/src/extensions/Image/components/ImageView.tsx +0 -271
- package/src/extensions/Image/index.ts +0 -1
- package/src/extensions/Image/store.ts +0 -15
- package/src/extensions/ImageGif/ImageGif.ts +0 -176
- package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +0 -138
- package/src/extensions/ImageGif/components/ImageGifView.tsx +0 -260
- package/src/extensions/ImageGif/index.ts +0 -1
- package/src/extensions/ImportWord/ImportWord.ts +0 -52
- package/src/extensions/ImportWord/components/ImportWordButton.tsx +0 -151
- package/src/extensions/ImportWord/index.ts +0 -1
- package/src/extensions/Indent/Indent.ts +0 -110
- package/src/extensions/Indent/index.ts +0 -1
- package/src/extensions/Italic/Italic.ts +0 -29
- package/src/extensions/Italic/index.ts +0 -1
- package/src/extensions/Katex/Katex.ts +0 -109
- package/src/extensions/Katex/components/KatexActiveButton.tsx +0 -117
- package/src/extensions/Katex/components/KatexWrapper.tsx +0 -53
- package/src/extensions/Katex/index.ts +0 -1
- package/src/extensions/LineHeight/LineHeight.ts +0 -76
- package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +0 -93
- package/src/extensions/LineHeight/index.ts +0 -1
- package/src/extensions/Link/Link.ts +0 -92
- package/src/extensions/Link/components/LinkEditBlock.tsx +0 -110
- package/src/extensions/Link/components/LinkEditPopover.tsx +0 -46
- package/src/extensions/Link/components/LinkViewBlock.tsx +0 -54
- package/src/extensions/Link/index.ts +0 -1
- package/src/extensions/ListItem/ListItem.ts +0 -1
- package/src/extensions/ListItem/index.ts +0 -1
- package/src/extensions/Mention/Mention.ts +0 -100
- package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +0 -94
- package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +0 -38
- package/src/extensions/Mention/index.ts +0 -1
- package/src/extensions/Mermaid/Mermaid.ts +0 -177
- package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +0 -155
- package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +0 -151
- package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +0 -260
- package/src/extensions/Mermaid/index.ts +0 -1
- package/src/extensions/MoreMark/MoreMark.ts +0 -102
- package/src/extensions/MoreMark/components/ActionMoreButton.tsx +0 -97
- package/src/extensions/MoreMark/index.ts +0 -1
- package/src/extensions/MultiColumn/Column.ts +0 -36
- package/src/extensions/MultiColumn/MultiColumn.ts +0 -111
- package/src/extensions/MultiColumn/components/ColumnActionButton.ts +0 -22
- package/src/extensions/MultiColumn/index.ts +0 -3
- package/src/extensions/OrderedList/OrderedList.ts +0 -28
- package/src/extensions/OrderedList/index.ts +0 -1
- package/src/extensions/SearchAndReplace/SearchAndReplace.ts +0 -395
- package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +0 -190
- package/src/extensions/SearchAndReplace/index.ts +0 -1
- package/src/extensions/Selection/Selection.ts +0 -32
- package/src/extensions/Selection/index.ts +0 -1
- package/src/extensions/SlashCommand/SlashCommand.ts +0 -255
- package/src/extensions/SlashCommand/components/CommandsList.tsx +0 -180
- package/src/extensions/SlashCommand/groups.ts +0 -183
- package/src/extensions/SlashCommand/index.ts +0 -1
- package/src/extensions/SlashCommand/types.ts +0 -24
- package/src/extensions/Strike/Strike.ts +0 -26
- package/src/extensions/Strike/index.ts +0 -1
- package/src/extensions/Subscript/Subscript.ts +0 -88
- package/src/extensions/Subscript/index.ts +0 -1
- package/src/extensions/Table/Cell.ts +0 -131
- package/src/extensions/Table/Header.ts +0 -93
- package/src/extensions/Table/Row.ts +0 -8
- package/src/extensions/Table/Table.ts +0 -60
- package/src/extensions/Table/cell-background.ts +0 -112
- package/src/extensions/Table/components/CreateTablePopover.tsx +0 -132
- package/src/extensions/Table/components/TableActionButton.tsx +0 -42
- package/src/extensions/Table/index.ts +0 -6
- package/src/extensions/Table/utils.ts +0 -352
- package/src/extensions/TableOfContent/TableOfContent.ts +0 -124
- package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +0 -116
- package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +0 -27
- package/src/extensions/TableOfContent/components/index.module.scss +0 -40
- package/src/extensions/TableOfContent/index.ts +0 -1
- package/src/extensions/TaskList/TaskList.ts +0 -46
- package/src/extensions/TaskList/index.ts +0 -1
- package/src/extensions/TextAlign/TextAlign.ts +0 -68
- package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +0 -103
- package/src/extensions/TextAlign/index.ts +0 -1
- package/src/extensions/TextBubble/TextBubble.ts +0 -22
- package/src/extensions/TextBubble/components/TextDropdown.tsx +0 -146
- package/src/extensions/TextBubble/index.ts +0 -1
- package/src/extensions/TextDirection/TextDirection.ts +0 -97
- package/src/extensions/TextDirection/components/TextDirectionButton.tsx +0 -103
- package/src/extensions/TextDirection/index.ts +0 -1
- package/src/extensions/TrailingNode/TrailingNode.ts +0 -71
- package/src/extensions/TrailingNode/index.ts +0 -1
- package/src/extensions/Twitter/Twitter.ts +0 -161
- package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +0 -68
- package/src/extensions/Twitter/components/NodeViewTweet.tsx +0 -30
- package/src/extensions/Twitter/components/TwitterActiveButton.tsx +0 -41
- package/src/extensions/Twitter/index.ts +0 -1
- package/src/extensions/UnderLine/Underline.ts +0 -30
- package/src/extensions/UnderLine/index.ts +0 -1
- package/src/extensions/Video/Video.ts +0 -204
- package/src/extensions/Video/components/ActiveVideoButton.tsx +0 -191
- package/src/extensions/Video/index.ts +0 -1
- package/src/extensions/Video/store.ts +0 -15
- package/src/extensions/index.ts +0 -122
- package/src/hooks/useActive.tsx +0 -24
- package/src/hooks/useAttributes.tsx +0 -45
- package/src/hooks/useCopy.tsx +0 -20
- package/src/hooks/useEditorState.tsx +0 -23
- package/src/hooks/useExtension.tsx +0 -29
- package/src/index.ts +0 -8
- package/src/lib/utils.ts +0 -7
- package/src/locale-bundle.ts +0 -3
- package/src/locales/en.ts +0 -173
- package/src/locales/hu.ts +0 -173
- package/src/locales/index.tsx +0 -163
- package/src/locales/pt-br.ts +0 -173
- package/src/locales/vi.ts +0 -173
- package/src/locales/zh-cn.ts +0 -173
- package/src/plugins/DragHandle/index.ts +0 -375
- package/src/plugins/DragHandle/range.ts +0 -114
- package/src/plugins/DragHandle/utils.ts +0 -80
- package/src/plugins/image-upload.ts +0 -160
- package/src/store/ProviderRichText.tsx +0 -53
- package/src/store/editableEditor.ts +0 -15
- package/src/store/fast-context.tsx +0 -70
- package/src/store/store.ts +0 -35
- package/src/styles/ProseMirror.scss +0 -176
- package/src/styles/columns.scss +0 -23
- package/src/styles/editor.scss +0 -411
- package/src/styles/global.scss +0 -87
- package/src/styles/index.scss +0 -5
- package/src/styles/mention.scss +0 -6
- package/src/theme/theme.ts +0 -15
- package/src/types.ts +0 -271
- package/src/utils/_event.ts +0 -55
- package/src/utils/color.ts +0 -67
- package/src/utils/columns.ts +0 -142
- package/src/utils/customEvents/customEvents.ts +0 -18
- package/src/utils/customEvents/events.constant.ts +0 -11
- package/src/utils/delete-node.ts +0 -46
- package/src/utils/dom-dataset.ts +0 -121
- package/src/utils/download.ts +0 -17
- package/src/utils/dynamicCSS.ts +0 -192
- package/src/utils/editor-container-size.ts +0 -28
- package/src/utils/file.ts +0 -112
- package/src/utils/getRenderContainer.ts +0 -41
- package/src/utils/indent.ts +0 -99
- package/src/utils/is-mobile.ts +0 -57
- package/src/utils/json.ts +0 -18
- package/src/utils/line-height.ts +0 -109
- package/src/utils/lru-cache.ts +0 -145
- package/src/utils/mitt.ts +0 -114
- package/src/utils/node.ts +0 -92
- package/src/utils/pdf.ts +0 -72
- package/src/utils/plateform.ts +0 -49
- package/src/utils/shortId.ts +0 -5
- package/src/utils/storage.ts +0 -18
- package/src/utils/utils.ts +0 -71
- package/src/vite-env.d.ts +0 -3
|
@@ -1,239 +0,0 @@
|
|
|
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 {
|
|
6
|
-
makeDropdownToolbar,
|
|
7
|
-
Editor as Editor4,
|
|
8
|
-
} from 'easydrawer';
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
import svg64 from 'svg64';
|
|
11
|
-
|
|
12
|
-
import { ActionButton } from 'reactjs-tiptap-editor-pro/components/ActionButton';
|
|
13
|
-
import { Button } from 'reactjs-tiptap-editor-pro/components/ui';
|
|
14
|
-
import { Dialog, DialogContent, DialogFooter, DialogTitle, DialogTrigger } from 'reactjs-tiptap-editor-pro/components/ui/dialog';
|
|
15
|
-
import ControlDrawer from 'reactjs-tiptap-editor-pro/extensions/Drawer/components/ControlDrawer/ControlDrawer';
|
|
16
|
-
import { dataURLtoFile } from 'reactjs-tiptap-editor-pro/utils/file';
|
|
17
|
-
import { shortId } from 'reactjs-tiptap-editor-pro/utils/shortId';
|
|
18
|
-
|
|
19
|
-
interface IProps {
|
|
20
|
-
editor: Editor, upload?: any
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let clear = false;
|
|
24
|
-
|
|
25
|
-
export const DrawerActiveButton: React.FC<IProps> = ({ editor, upload }) => {
|
|
26
|
-
const [visible, toggleVisible] = useState(false);
|
|
27
|
-
const refEditor = useRef<Editor4 | null>(null);
|
|
28
|
-
const refWidget = useRef<any>(null);
|
|
29
|
-
|
|
30
|
-
const mermaidInit = () => {
|
|
31
|
-
const init = async () => {
|
|
32
|
-
const parentElement = document.querySelector('#easydrawer');
|
|
33
|
-
|
|
34
|
-
if (!parentElement) return;
|
|
35
|
-
|
|
36
|
-
refEditor.current = new Editor4(parentElement as any, {
|
|
37
|
-
wheelEventsEnabled: false,
|
|
38
|
-
disableZoom: true,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
refWidget.current = makeDropdownToolbar(refEditor.current);
|
|
42
|
-
refWidget.current.addDefaultToolWidgets();
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
init();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (visible) {
|
|
50
|
-
setTimeout(() => {
|
|
51
|
-
mermaidInit();
|
|
52
|
-
}, 200);
|
|
53
|
-
}
|
|
54
|
-
}, [visible]);
|
|
55
|
-
|
|
56
|
-
const setSvg = async () => {
|
|
57
|
-
if (refEditor.current) {
|
|
58
|
-
const svg = refEditor.current.toSVG() as unknown as HTMLElement;
|
|
59
|
-
const contentHtml = svg.outerHTML;
|
|
60
|
-
// const { width, height } = svg.getBoundingClientRect();
|
|
61
|
-
const name = `drawer-${shortId()}.svg`;
|
|
62
|
-
|
|
63
|
-
let src = svg64(svg.outerHTML);
|
|
64
|
-
|
|
65
|
-
if (upload) {
|
|
66
|
-
const file = dataURLtoFile(src, name);
|
|
67
|
-
src = await upload(file);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
editor
|
|
71
|
-
?.chain()
|
|
72
|
-
.focus()
|
|
73
|
-
.setDrawer(
|
|
74
|
-
{
|
|
75
|
-
type: 'drawer',
|
|
76
|
-
src,
|
|
77
|
-
alt: encodeURIComponent(contentHtml),
|
|
78
|
-
width: 426,
|
|
79
|
-
height: 212
|
|
80
|
-
},
|
|
81
|
-
!!contentHtml,
|
|
82
|
-
)
|
|
83
|
-
.run();
|
|
84
|
-
}
|
|
85
|
-
toggleVisible(false);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const setColorPen = (color: string) => {
|
|
89
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[2] as any;
|
|
90
|
-
const shapeWidget = refWidget.current.getWidgetById('pen-1');
|
|
91
|
-
|
|
92
|
-
if (penTool && shapeWidget) {
|
|
93
|
-
penTool.setColor(color);
|
|
94
|
-
shapeWidget.serializeState();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const setThicknessPen = (thickness: number) => {
|
|
99
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[2] as any;
|
|
100
|
-
const shapeWidget = refWidget.current.getWidgetById('pen-1');
|
|
101
|
-
|
|
102
|
-
if (penTool && shapeWidget) {
|
|
103
|
-
penTool.setThickness(thickness);
|
|
104
|
-
shapeWidget.serializeState();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const setColorHighlight = (color: string) => {
|
|
109
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[3] as any;
|
|
110
|
-
|
|
111
|
-
const shapeWidget = refWidget.current.getWidgetById('pen-2');
|
|
112
|
-
|
|
113
|
-
if (penTool && shapeWidget) {
|
|
114
|
-
penTool.setColor(color);
|
|
115
|
-
shapeWidget.serializeState();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const changeShape = (type: any) => {
|
|
120
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
121
|
-
|
|
122
|
-
if (shapeWidget) {
|
|
123
|
-
shapeWidget.setShapeType(type);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const changeColorShape = (color: string) => {
|
|
128
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[5] as any;
|
|
129
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
130
|
-
|
|
131
|
-
if (penTool && shapeWidget) {
|
|
132
|
-
penTool.setColor(color);
|
|
133
|
-
shapeWidget.serializeState();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const onThicknessChange = (v: any) => {
|
|
138
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[5] as any;
|
|
139
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
140
|
-
|
|
141
|
-
if (penTool && shapeWidget) {
|
|
142
|
-
penTool.setThickness(v);
|
|
143
|
-
shapeWidget.serializeState();
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const changeBorderColorShape = (color: string) => {
|
|
148
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[5] as any;
|
|
149
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
150
|
-
|
|
151
|
-
if (penTool && shapeWidget) {
|
|
152
|
-
penTool.setBorderColor(color);
|
|
153
|
-
shapeWidget.serializeState();
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const onUndo =() => {
|
|
158
|
-
if (clear) {
|
|
159
|
-
while (refEditor.current!.history.redoStackSize > 0) {
|
|
160
|
-
refEditor.current!.history.redo();
|
|
161
|
-
}
|
|
162
|
-
clear = false;
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
refEditor.current!.history.undo();
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const onRedo =() => {
|
|
170
|
-
if (clear) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
refEditor.current!.history.redo();
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const onClear =() => {
|
|
178
|
-
if (clear) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
while (refEditor.current!.history.undoStackSize > 0) {
|
|
183
|
-
onUndo();
|
|
184
|
-
}
|
|
185
|
-
clear = true;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
return (
|
|
189
|
-
<Dialog
|
|
190
|
-
onOpenChange={toggleVisible}
|
|
191
|
-
open={visible}
|
|
192
|
-
>
|
|
193
|
-
<DialogTrigger asChild>
|
|
194
|
-
<ActionButton
|
|
195
|
-
action={() => toggleVisible(true)}
|
|
196
|
-
icon="PencilRuler"
|
|
197
|
-
tooltip="Drawer"
|
|
198
|
-
/>
|
|
199
|
-
</DialogTrigger>
|
|
200
|
-
|
|
201
|
-
<DialogContent className="z-[99999] !max-w-[1300px]">
|
|
202
|
-
<DialogTitle>
|
|
203
|
-
Drawer
|
|
204
|
-
</DialogTitle>
|
|
205
|
-
|
|
206
|
-
<div style={{ height: '600px', width: '100%', borderWidth: 1, background: 'white', position: 'relative' }}>
|
|
207
|
-
<div
|
|
208
|
-
className='size-full'
|
|
209
|
-
id='easydrawer'
|
|
210
|
-
>
|
|
211
|
-
</div>
|
|
212
|
-
|
|
213
|
-
<ControlDrawer
|
|
214
|
-
changeBorderColorShape={changeBorderColorShape}
|
|
215
|
-
changeColorShape={changeColorShape}
|
|
216
|
-
changeShape={changeShape}
|
|
217
|
-
onClear={onClear}
|
|
218
|
-
onRedo={onRedo}
|
|
219
|
-
onThicknessChange={onThicknessChange}
|
|
220
|
-
onUndo={onUndo}
|
|
221
|
-
refEditor={refEditor}
|
|
222
|
-
setColorHighlight={setColorHighlight}
|
|
223
|
-
setColorPen={setColorPen}
|
|
224
|
-
setThicknessPen={setThicknessPen}
|
|
225
|
-
/>
|
|
226
|
-
</div>
|
|
227
|
-
|
|
228
|
-
<DialogFooter>
|
|
229
|
-
<Button
|
|
230
|
-
onClick={setSvg}
|
|
231
|
-
type="button"
|
|
232
|
-
>
|
|
233
|
-
Save changes
|
|
234
|
-
</Button>
|
|
235
|
-
</DialogFooter>
|
|
236
|
-
</DialogContent>
|
|
237
|
-
</Dialog>
|
|
238
|
-
);
|
|
239
|
-
};
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
makeDropdownToolbar,
|
|
6
|
-
Editor as Editor4,
|
|
7
|
-
} from 'easydrawer';
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
import svg64 from 'svg64';
|
|
10
|
-
|
|
11
|
-
import { ActionButton } from 'reactjs-tiptap-editor-pro/components/ActionButton';
|
|
12
|
-
import { Button } from 'reactjs-tiptap-editor-pro/components/ui';
|
|
13
|
-
import { Dialog, DialogContent, DialogFooter, DialogTitle, DialogTrigger } from 'reactjs-tiptap-editor-pro/components/ui/dialog';
|
|
14
|
-
import ControlDrawer from 'reactjs-tiptap-editor-pro/extensions/Drawer/components/ControlDrawer/ControlDrawer';
|
|
15
|
-
import { dataURLtoFile } from 'reactjs-tiptap-editor-pro/utils/file';
|
|
16
|
-
import { shortId } from 'reactjs-tiptap-editor-pro/utils/shortId';
|
|
17
|
-
|
|
18
|
-
let clear = false;
|
|
19
|
-
|
|
20
|
-
export function EditDrawerBlock ({ editor, attrs, extension }: any) {
|
|
21
|
-
const [visible, toggleVisible] = useState(false);
|
|
22
|
-
const refEditor = useRef<Editor4 | null>(null);
|
|
23
|
-
const refWidget = useRef<any>(null);
|
|
24
|
-
const { alt, align } = attrs;
|
|
25
|
-
const upload = extension?.options.upload;
|
|
26
|
-
|
|
27
|
-
const mermaidInit = () => {
|
|
28
|
-
const init = async () => {
|
|
29
|
-
const parentElement = document.querySelector('#easydrawer');
|
|
30
|
-
|
|
31
|
-
if (!parentElement) return;
|
|
32
|
-
|
|
33
|
-
refEditor.current = new Editor4(parentElement as any, {
|
|
34
|
-
wheelEventsEnabled: false,
|
|
35
|
-
disableZoom: true,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
refWidget.current = makeDropdownToolbar(refEditor.current);
|
|
39
|
-
refWidget.current.addDefaultToolWidgets();
|
|
40
|
-
|
|
41
|
-
refEditor.current.loadFromSVG(decodeURIComponent(alt));
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
init();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (visible) {
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
mermaidInit();
|
|
51
|
-
}, 200);
|
|
52
|
-
}
|
|
53
|
-
}, [visible]);
|
|
54
|
-
|
|
55
|
-
const setSvg = async () => {
|
|
56
|
-
if (refEditor.current) {
|
|
57
|
-
const svg = refEditor.current.toSVG() as unknown as HTMLElement;
|
|
58
|
-
const contentHtml = svg.outerHTML;
|
|
59
|
-
const name = `drawer-${shortId()}.svg`;
|
|
60
|
-
|
|
61
|
-
let src = svg64(svg.outerHTML);
|
|
62
|
-
|
|
63
|
-
if (upload) {
|
|
64
|
-
const file = dataURLtoFile(src, name);
|
|
65
|
-
src = await upload(file);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
editor
|
|
69
|
-
?.chain()
|
|
70
|
-
.focus()
|
|
71
|
-
.setDrawer(
|
|
72
|
-
{
|
|
73
|
-
type: 'drawer',
|
|
74
|
-
src,
|
|
75
|
-
alt: encodeURIComponent(contentHtml),
|
|
76
|
-
width: 426,
|
|
77
|
-
height: 212
|
|
78
|
-
},
|
|
79
|
-
!!contentHtml,
|
|
80
|
-
)
|
|
81
|
-
.run();
|
|
82
|
-
editor?.commands.setAlignImageDrawer(align);
|
|
83
|
-
}
|
|
84
|
-
toggleVisible(false);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const setColorPen = (color: string) => {
|
|
88
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[2] as any;
|
|
89
|
-
const shapeWidget = refWidget.current.getWidgetById('pen-1');
|
|
90
|
-
|
|
91
|
-
if (penTool && shapeWidget) {
|
|
92
|
-
penTool.setColor(color);
|
|
93
|
-
shapeWidget.serializeState();
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const setThicknessPen = (thickness: number) => {
|
|
98
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[2] as any;
|
|
99
|
-
const shapeWidget = refWidget.current.getWidgetById('pen-1');
|
|
100
|
-
|
|
101
|
-
if (penTool && shapeWidget) {
|
|
102
|
-
penTool.setThickness(thickness);
|
|
103
|
-
shapeWidget.serializeState();
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const setColorHighlight = (color: string) => {
|
|
108
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[3] as any;
|
|
109
|
-
|
|
110
|
-
const shapeWidget = refWidget.current.getWidgetById('pen-2');
|
|
111
|
-
|
|
112
|
-
if (penTool && shapeWidget) {
|
|
113
|
-
penTool.setColor(color);
|
|
114
|
-
shapeWidget.serializeState();
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const changeShape = (type: any) => {
|
|
119
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
120
|
-
|
|
121
|
-
if (shapeWidget) {
|
|
122
|
-
shapeWidget.setShapeType(type);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const changeColorShape = (color: string) => {
|
|
127
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[5] as any;
|
|
128
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
129
|
-
|
|
130
|
-
if (penTool && shapeWidget) {
|
|
131
|
-
penTool.setColor(color);
|
|
132
|
-
shapeWidget.serializeState();
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const onThicknessChange = (v: any) => {
|
|
137
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[5] as any;
|
|
138
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
139
|
-
|
|
140
|
-
if (penTool && shapeWidget) {
|
|
141
|
-
penTool.setThickness(v);
|
|
142
|
-
shapeWidget.serializeState();
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const changeBorderColorShape = (color: string) => {
|
|
147
|
-
const penTool = refEditor.current!.toolController.getPrimaryTools()[5] as any;
|
|
148
|
-
const shapeWidget = refWidget.current.getWidgetById('shape');
|
|
149
|
-
|
|
150
|
-
if (penTool && shapeWidget) {
|
|
151
|
-
penTool.setBorderColor(color);
|
|
152
|
-
shapeWidget.serializeState();
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const onUndo =() => {
|
|
157
|
-
if (clear) {
|
|
158
|
-
while (refEditor.current!.history.redoStackSize > 0) {
|
|
159
|
-
refEditor.current!.history.redo();
|
|
160
|
-
}
|
|
161
|
-
clear = false;
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
refEditor.current!.history.undo();
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const onRedo =() => {
|
|
169
|
-
if (clear) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
refEditor.current!.history.redo();
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const onClear =() => {
|
|
177
|
-
if (clear) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
while (refEditor.current!.history.undoStackSize > 0) {
|
|
182
|
-
onUndo();
|
|
183
|
-
}
|
|
184
|
-
clear = true;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<Dialog
|
|
189
|
-
onOpenChange={toggleVisible}
|
|
190
|
-
open={visible}
|
|
191
|
-
>
|
|
192
|
-
<DialogTrigger asChild>
|
|
193
|
-
<ActionButton
|
|
194
|
-
action={() => toggleVisible(true)}
|
|
195
|
-
icon="Pencil"
|
|
196
|
-
tooltip="Edit Drawer"
|
|
197
|
-
/>
|
|
198
|
-
</DialogTrigger>
|
|
199
|
-
|
|
200
|
-
<DialogContent className="z-[99999] !max-w-[1300px]">
|
|
201
|
-
<DialogTitle>
|
|
202
|
-
Edit Drawer
|
|
203
|
-
</DialogTitle>
|
|
204
|
-
|
|
205
|
-
<div style={{ height: '100%', borderWidth: 1, background: 'white', position: 'relative' }}>
|
|
206
|
-
<div
|
|
207
|
-
className='size-full'
|
|
208
|
-
id='easydrawer'
|
|
209
|
-
>
|
|
210
|
-
</div>
|
|
211
|
-
|
|
212
|
-
<ControlDrawer
|
|
213
|
-
changeBorderColorShape={changeBorderColorShape}
|
|
214
|
-
changeColorShape={changeColorShape}
|
|
215
|
-
changeShape={changeShape}
|
|
216
|
-
onClear={onClear}
|
|
217
|
-
onRedo={onRedo}
|
|
218
|
-
onThicknessChange={onThicknessChange}
|
|
219
|
-
onUndo={onUndo}
|
|
220
|
-
refEditor={refEditor}
|
|
221
|
-
setColorHighlight={setColorHighlight}
|
|
222
|
-
setColorPen={setColorPen}
|
|
223
|
-
setThicknessPen={setThicknessPen}
|
|
224
|
-
/>
|
|
225
|
-
</div>
|
|
226
|
-
|
|
227
|
-
<DialogFooter>
|
|
228
|
-
<Button
|
|
229
|
-
onClick={setSvg}
|
|
230
|
-
type="button"
|
|
231
|
-
>
|
|
232
|
-
Save changes
|
|
233
|
-
</Button>
|
|
234
|
-
</DialogFooter>
|
|
235
|
-
</DialogContent>
|
|
236
|
-
</Dialog>
|
|
237
|
-
);
|
|
238
|
-
}
|