reactjs-tiptap-editor-pro 0.2.28 → 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-BC85Dn21.js +0 -8826
- package/lib/RichTextEditor-Cxm0yJdr.cjs +0 -141
- 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 -511
- package/lib/index.d.ts +0 -511
- 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,104 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Editor } from '@tiptap/react';
|
|
4
|
+
import { debounce } from 'lodash-es';
|
|
5
|
+
|
|
6
|
+
import { ActionButton, Button, ColorPicker } from '@/components';
|
|
7
|
+
import { IconComponent } from '@/components/icons';
|
|
8
|
+
import type { ButtonViewReturnComponentProps } from '@/types';
|
|
9
|
+
|
|
10
|
+
interface ColorActionButtonProps {
|
|
11
|
+
editor: Editor
|
|
12
|
+
colors?: string[]
|
|
13
|
+
defaultColor?: string
|
|
14
|
+
icon?: React.ReactNode
|
|
15
|
+
tooltip?: string
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
action?: ButtonViewReturnComponentProps['action']
|
|
18
|
+
isActive?: ButtonViewReturnComponentProps['isActive']
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface IconCProps {
|
|
22
|
+
fill?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function IconC({ fill }: IconCProps) {
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
width="18px"
|
|
29
|
+
height="18px"
|
|
30
|
+
viewBox="0 0 240 240"
|
|
31
|
+
version="1.1"
|
|
32
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
33
|
+
>
|
|
34
|
+
<g stroke="none" strokeWidth={1} fill="none" fillRule="evenodd">
|
|
35
|
+
<g transform="translate(0.000000, 0.500000)">
|
|
36
|
+
<g transform="translate(39.000000, 17.353553)">
|
|
37
|
+
<path
|
|
38
|
+
d="M11,201.146447 L167,201.146447 C173.075132,201.146447 178,206.071314 178,212.146447 C178,218.221579 173.075132,223.146447 167,223.146447 L11,223.146447 C4.92486775,223.146447 7.43989126e-16,218.221579 0,212.146447 C-7.43989126e-16,206.071314 4.92486775,201.146447 11,201.146447 Z"
|
|
39
|
+
id="矩形"
|
|
40
|
+
fill={fill || '#DF2A3F'}
|
|
41
|
+
fillRule="evenodd"
|
|
42
|
+
/>
|
|
43
|
+
<path
|
|
44
|
+
d="M72.3425855,16.8295583 C75.799482,7.50883712 86.1577877,2.75526801 95.4785089,6.21216449 C100.284516,7.99463061 104.096358,11.7387855 105.968745,16.4968188 L106.112518,16.8745422 L159.385152,161.694068 C161.291848,166.877345 158.635655,172.624903 153.452378,174.531599 C148.358469,176.405421 142.719567,173.872338 140.716873,168.864661 L140.614848,168.598825 L89.211,28.86 L37.3759214,168.623816 C35.4885354,173.712715 29.8981043,176.351047 24.7909589,174.617647 L24.5226307,174.522368 C19.4337312,172.634982 16.7953993,167.044551 18.5287999,161.937406 L18.6240786,161.669077 L72.3425855,16.8295583 Z"
|
|
45
|
+
id="路径-21"
|
|
46
|
+
fill="currentColor"
|
|
47
|
+
fillRule="nonzero"
|
|
48
|
+
/>
|
|
49
|
+
<path
|
|
50
|
+
d="M121,103.146447 C126.522847,103.146447 131,107.623599 131,113.146447 C131,118.575687 126.673329,122.994378 121.279905,123.142605 L121,123.146447 L55,123.146447 C49.4771525,123.146447 45,118.669294 45,113.146447 C45,107.717207 49.3266708,103.298515 54.7200952,103.150288 L55,103.146447 L121,103.146447 Z"
|
|
51
|
+
id="路径-22"
|
|
52
|
+
fill="currentColor"
|
|
53
|
+
fillRule="nonzero"
|
|
54
|
+
/>
|
|
55
|
+
</g>
|
|
56
|
+
</g>
|
|
57
|
+
</g>
|
|
58
|
+
</svg>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function ColorActionButton(props: ColorActionButtonProps) {
|
|
63
|
+
const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);
|
|
64
|
+
|
|
65
|
+
function onChange(color: string | undefined) {
|
|
66
|
+
props.action?.(color);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function toggleColor() {
|
|
70
|
+
props.action?.(selectedColor);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const setSelectedColorDebounce = useCallback(
|
|
74
|
+
debounce((color: string | undefined) => {
|
|
75
|
+
setSelectedColor(color);
|
|
76
|
+
}, 350),
|
|
77
|
+
[],
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="flex items-center h-[32px]">
|
|
82
|
+
<ActionButton tooltip={props?.tooltip} disabled={props?.disabled} action={toggleColor}>
|
|
83
|
+
<span className="flex items-center justify-center text-sm">
|
|
84
|
+
<IconC fill={selectedColor} />
|
|
85
|
+
</span>
|
|
86
|
+
</ActionButton>
|
|
87
|
+
|
|
88
|
+
<ColorPicker
|
|
89
|
+
selectedColor={selectedColor}
|
|
90
|
+
setSelectedColor={setSelectedColorDebounce}
|
|
91
|
+
onChange={onChange}
|
|
92
|
+
disabled={props?.disabled}
|
|
93
|
+
colors={props?.colors}
|
|
94
|
+
defaultColor={props?.defaultColor}
|
|
95
|
+
>
|
|
96
|
+
<Button variant="ghost" size="icon" className="r!ichtext-h-[32px] !w-3" disabled={props?.disabled}>
|
|
97
|
+
<IconComponent className="!w-3 !h-3 text-zinc-500" name="MenuDown" />
|
|
98
|
+
</Button>
|
|
99
|
+
</ColorPicker>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default ColorActionButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Color';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Document';
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
import type { CommandProps } from '@tiptap/core';
|
|
3
|
+
import { mergeAttributes } from '@tiptap/core';
|
|
4
|
+
import TiptapImage from '@tiptap/extension-image';
|
|
5
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
6
|
+
|
|
7
|
+
import { DrawerActiveButton } from '@/extensions/Drawer/components/DrawerActiveButton';
|
|
8
|
+
import { NodeViewDrawer } from '@/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer';
|
|
9
|
+
import type { GeneralOptions } from '@/types';
|
|
10
|
+
|
|
11
|
+
declare module '@tiptap/core' {
|
|
12
|
+
interface Commands<ReturnType> {
|
|
13
|
+
drawer: {
|
|
14
|
+
setDrawer: (options: any, replace?: any) => ReturnType
|
|
15
|
+
setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DrawerOptions extends GeneralOptions<DrawerOptions> {
|
|
21
|
+
/** Function for uploading files */
|
|
22
|
+
upload?: (file: File) => Promise<string>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Drawer = TiptapImage.extend<DrawerOptions>({
|
|
26
|
+
name: 'drawer',
|
|
27
|
+
|
|
28
|
+
addOptions() {
|
|
29
|
+
return {
|
|
30
|
+
...this.parent?.(),
|
|
31
|
+
inline: false,
|
|
32
|
+
content: '',
|
|
33
|
+
marks: '',
|
|
34
|
+
group: 'block',
|
|
35
|
+
draggable: false,
|
|
36
|
+
selectable: true,
|
|
37
|
+
atom: true,
|
|
38
|
+
HTMLAttributes: {
|
|
39
|
+
class: 'drawer',
|
|
40
|
+
},
|
|
41
|
+
button: ({ editor, t, extension }: any) => ({
|
|
42
|
+
component: DrawerActiveButton,
|
|
43
|
+
componentProps: {
|
|
44
|
+
action: () => {
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
47
|
+
isActive: () => false,
|
|
48
|
+
disabled: false,
|
|
49
|
+
editor,
|
|
50
|
+
icon: 'PencilRuler',
|
|
51
|
+
tooltip: t('editor.drawer.tooltip'),
|
|
52
|
+
upload: extension?.options?.upload,
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
addAttributes() {
|
|
59
|
+
return {
|
|
60
|
+
...this.parent?.(),
|
|
61
|
+
width: {
|
|
62
|
+
default: null,
|
|
63
|
+
parseHTML: (element) => {
|
|
64
|
+
const img = element.querySelector('img') as any;
|
|
65
|
+
|
|
66
|
+
const width = img?.getAttribute('width');
|
|
67
|
+
|
|
68
|
+
return width ? Number.parseInt(width, 10) : 320;
|
|
69
|
+
},
|
|
70
|
+
renderHTML: (attributes) => {
|
|
71
|
+
return {
|
|
72
|
+
width: attributes.width,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
height: {
|
|
77
|
+
default: null,
|
|
78
|
+
parseHTML: (element) => {
|
|
79
|
+
const img = element.querySelector('img') as any;
|
|
80
|
+
|
|
81
|
+
const height = img?.getAttribute('height');
|
|
82
|
+
|
|
83
|
+
return height ? Number.parseInt(height, 10) : 212;
|
|
84
|
+
},
|
|
85
|
+
renderHTML: (attributes) => {
|
|
86
|
+
return {
|
|
87
|
+
height: attributes.height,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
align: {
|
|
92
|
+
default: 'center',
|
|
93
|
+
parseHTML: element => element.getAttribute('align'),
|
|
94
|
+
renderHTML: (attributes) => {
|
|
95
|
+
return {
|
|
96
|
+
align: attributes.align,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
addNodeView() {
|
|
104
|
+
return ReactNodeViewRenderer(NodeViewDrawer);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
addCommands() {
|
|
109
|
+
return {
|
|
110
|
+
setDrawer:
|
|
111
|
+
(
|
|
112
|
+
options: { src: string, alt?: string },
|
|
113
|
+
replace?: boolean,
|
|
114
|
+
) =>
|
|
115
|
+
({ commands, editor }: CommandProps) => {
|
|
116
|
+
if (replace) {
|
|
117
|
+
return commands.insertContent({
|
|
118
|
+
type: this.name,
|
|
119
|
+
attrs: options,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return commands.insertContentAt(editor.state.selection.anchor, {
|
|
123
|
+
type: this.name,
|
|
124
|
+
attrs: options,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
setAlignImageDrawer:
|
|
129
|
+
(align: any) =>
|
|
130
|
+
({ commands }: any) => {
|
|
131
|
+
return commands.updateAttributes(this.name, { align });
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
renderHTML({ HTMLAttributes }) {
|
|
137
|
+
const { align } = HTMLAttributes;
|
|
138
|
+
const style = align ? `text-align: ${align};` : '';
|
|
139
|
+
|
|
140
|
+
return [
|
|
141
|
+
'div', // Parent element
|
|
142
|
+
{
|
|
143
|
+
style,
|
|
144
|
+
class: 'imageDrawer',
|
|
145
|
+
},
|
|
146
|
+
[
|
|
147
|
+
'img',
|
|
148
|
+
mergeAttributes(
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
this.options.HTMLAttributes,
|
|
151
|
+
HTMLAttributes,
|
|
152
|
+
),
|
|
153
|
+
],
|
|
154
|
+
];
|
|
155
|
+
},
|
|
156
|
+
parseHTML() {
|
|
157
|
+
return [
|
|
158
|
+
{
|
|
159
|
+
tag: 'div[class=imageDrawer]',
|
|
160
|
+
getAttrs: (element) => {
|
|
161
|
+
const img = element.querySelector('img');
|
|
162
|
+
|
|
163
|
+
const width = img?.getAttribute('width');
|
|
164
|
+
const height = img?.getAttribute('height');
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
src: img?.getAttribute('src'),
|
|
168
|
+
alt: img?.getAttribute('alt'),
|
|
169
|
+
width: width ? Number.parseInt(width, 10) : null,
|
|
170
|
+
height: height ? Number.parseInt(height, 10) : null,
|
|
171
|
+
align: img?.getAttribute('align') || element.style.textAlign || null,
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
},
|
|
177
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
background-color: white;
|
|
3
|
+
border-radius: 10px;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
position: absolute;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
z-index: 1000;
|
|
9
|
+
padding: 10px;
|
|
10
|
+
gap: 10px;
|
|
11
|
+
z-index: 100;
|
|
12
|
+
border: 1px solid #eeeeee;
|
|
13
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
14
|
+
border-radius: 10px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tool {
|
|
18
|
+
outline: none;
|
|
19
|
+
border: none;
|
|
20
|
+
background-color: white;
|
|
21
|
+
border-radius: 5px;
|
|
22
|
+
padding: 5px;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
transition: all 0.3s;
|
|
25
|
+
color: rgb(89, 83, 83) !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
.tool svg {
|
|
30
|
+
width: 20px;
|
|
31
|
+
height: 20px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tool:hover {
|
|
35
|
+
background-color: #f5f5f5;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.active {
|
|
39
|
+
background-color: #eeeeee !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.pen {
|
|
43
|
+
display: flex;
|
|
44
|
+
gap: 4px;
|
|
45
|
+
align-items: center;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.line {
|
|
50
|
+
height: 20px;
|
|
51
|
+
width: 1px;
|
|
52
|
+
background-color: rgb(188, 185, 185);
|
|
53
|
+
margin: 0 6px;
|
|
54
|
+
transform: rotate(18deg);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.options {
|
|
58
|
+
margin-top: 10px;
|
|
59
|
+
padding: 10px 0 0;
|
|
60
|
+
border-top: 1px dashed #eeeeee;
|
|
61
|
+
display: flex;
|
|
62
|
+
gap: 4px;
|
|
63
|
+
align-items: center;
|
|
64
|
+
flex-wrap: wrap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.colorWrap {
|
|
68
|
+
display: flex;
|
|
69
|
+
gap: 8px;
|
|
70
|
+
align-items: center;
|
|
71
|
+
margin: 4px 0;
|
|
72
|
+
}
|
|
73
|
+
.color {
|
|
74
|
+
outline: none !important;
|
|
75
|
+
border: none !important;
|
|
76
|
+
border-radius: 4px;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
width: 20px;
|
|
79
|
+
height: 20px;
|
|
80
|
+
border: 1px solid #eeeeee;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.colorActive {
|
|
84
|
+
outline: 2px solid #2576B9 !important;
|
|
85
|
+
}
|