reactjs-tiptap-editor-pro 0.2.29 → 0.2.31
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 +5 -58
- 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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactjs-tiptap-editor-pro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.31",
|
|
5
5
|
"packageManager": "pnpm@8.15.9",
|
|
6
6
|
"description": "A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,64 +28,13 @@
|
|
|
28
28
|
"tiptap-react-rc-rich-text"
|
|
29
29
|
],
|
|
30
30
|
"sideEffects": false,
|
|
31
|
-
"main": "./
|
|
32
|
-
"module": "./
|
|
33
|
-
"types": "./lib/index.d.ts",
|
|
31
|
+
"main": "./src/index.ts",
|
|
32
|
+
"module": "./src/index.ts",
|
|
34
33
|
"exports": {
|
|
35
|
-
"
|
|
36
|
-
"require": {
|
|
37
|
-
"types": "./lib/index.d.cts",
|
|
38
|
-
"default": "./lib/index.cjs"
|
|
39
|
-
},
|
|
40
|
-
"import": {
|
|
41
|
-
"types": "./lib/index.d.ts",
|
|
42
|
-
"default": "./lib/index.js"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"./extension-bundle": {
|
|
46
|
-
"require": {
|
|
47
|
-
"types": "./lib/extension-bundle.d.cts",
|
|
48
|
-
"default": "./lib/extension-bundle.cjs"
|
|
49
|
-
},
|
|
50
|
-
"import": {
|
|
51
|
-
"types": "./lib/extension-bundle.d.ts",
|
|
52
|
-
"default": "./lib/extension-bundle.js"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"./locale-bundle": {
|
|
56
|
-
"require": {
|
|
57
|
-
"types": "./lib/locale-bundle.d.cts",
|
|
58
|
-
"default": "./lib/locale-bundle.cjs"
|
|
59
|
-
},
|
|
60
|
-
"import": {
|
|
61
|
-
"types": "./lib/locale-bundle.d.ts",
|
|
62
|
-
"default": "./lib/locale-bundle.js"
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"./style.css": {
|
|
66
|
-
"require": "./lib/style.css",
|
|
67
|
-
"import": "./lib/style.css"
|
|
68
|
-
},
|
|
69
|
-
"./lib/*": "./lib/*",
|
|
70
|
-
"./package.json": "./package.json",
|
|
71
|
-
"./*": "./lib/*"
|
|
72
|
-
},
|
|
73
|
-
"typesVersions": {
|
|
74
|
-
"*": {
|
|
75
|
-
"extension-bundle": [
|
|
76
|
-
"./lib/extension-bundle.d.ts"
|
|
77
|
-
],
|
|
78
|
-
"locale-bundle": [
|
|
79
|
-
"./lib/locale-bundle.d.ts"
|
|
80
|
-
],
|
|
81
|
-
"*": [
|
|
82
|
-
"./lib/*",
|
|
83
|
-
"./*"
|
|
84
|
-
]
|
|
85
|
-
}
|
|
34
|
+
"./*": "./src/*"
|
|
86
35
|
},
|
|
87
36
|
"files": [
|
|
88
|
-
"
|
|
37
|
+
"src",
|
|
89
38
|
"package.json",
|
|
90
39
|
"README.md",
|
|
91
40
|
"LICENSE"
|
|
@@ -222,8 +171,6 @@
|
|
|
222
171
|
"commit-msg": "npm run verify-commit"
|
|
223
172
|
},
|
|
224
173
|
"scripts": {
|
|
225
|
-
"build:lib": "vite build && pnpm modify-css",
|
|
226
|
-
"build:lib:dev": "vite build --mode development --watch",
|
|
227
174
|
"build:playground": "pnpm build:lib && pnpm --dir ./playground run build",
|
|
228
175
|
"docs:dev": "pnpm --parallel --filter docs... dev",
|
|
229
176
|
"docs:build": "pnpm --filter docs... build",
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable react/display-name */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
6
|
+
import type { TooltipContentProps } from '@radix-ui/react-tooltip';
|
|
7
|
+
|
|
8
|
+
import { Toggle, Tooltip, TooltipContent, TooltipTrigger, IconComponent as Icon } from 'reactjs-tiptap-editor-pro/components';
|
|
9
|
+
import { cn } from 'reactjs-tiptap-editor-pro/lib/utils';
|
|
10
|
+
import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
|
|
11
|
+
import { getShortcutKeys } from 'reactjs-tiptap-editor-pro/utils/plateform';
|
|
12
|
+
|
|
13
|
+
export interface ActionButtonProps {
|
|
14
|
+
/* Icon name to display */
|
|
15
|
+
icon?: string
|
|
16
|
+
/* Button title */
|
|
17
|
+
title?: string
|
|
18
|
+
/* Tooltip text */
|
|
19
|
+
tooltip?: string
|
|
20
|
+
/* Whether the button is disabled */
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
/* Keyboard shortcut keys */
|
|
23
|
+
shortcutKeys?: string[]
|
|
24
|
+
/* Custom CSS class */
|
|
25
|
+
customClass?: string
|
|
26
|
+
/* Loading state */
|
|
27
|
+
loading?: boolean
|
|
28
|
+
/* Tooltip options */
|
|
29
|
+
tooltipOptions?: TooltipContentProps
|
|
30
|
+
/* Button color */
|
|
31
|
+
color?: string
|
|
32
|
+
/* Click action handler */
|
|
33
|
+
action?: ButtonViewReturnComponentProps['action']
|
|
34
|
+
/* Active state checker */
|
|
35
|
+
isActive?: ButtonViewReturnComponentProps['isActive']
|
|
36
|
+
/* Child components */
|
|
37
|
+
children?: React.ReactNode
|
|
38
|
+
/* Whether to render as child */
|
|
39
|
+
asChild?: boolean
|
|
40
|
+
/* Whether it's an upload button */
|
|
41
|
+
upload?: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ActionButton = React.forwardRef<HTMLButtonElement, Partial<ActionButtonProps>>(
|
|
45
|
+
(props, ref) => {
|
|
46
|
+
const {
|
|
47
|
+
icon = undefined,
|
|
48
|
+
// title = undefined,
|
|
49
|
+
tooltip = undefined,
|
|
50
|
+
disabled = false,
|
|
51
|
+
customClass = '',
|
|
52
|
+
// color = undefined,
|
|
53
|
+
loading = undefined,
|
|
54
|
+
shortcutKeys = undefined,
|
|
55
|
+
tooltipOptions = {},
|
|
56
|
+
action = undefined,
|
|
57
|
+
isActive = undefined,
|
|
58
|
+
children,
|
|
59
|
+
asChild = false,
|
|
60
|
+
upload = false,
|
|
61
|
+
...rest
|
|
62
|
+
} = props;
|
|
63
|
+
const Comp = asChild ? Slot : Toggle;
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Tooltip>
|
|
67
|
+
<TooltipTrigger asChild>
|
|
68
|
+
<Comp
|
|
69
|
+
data-state={isActive?.() ? 'on' : 'off'}
|
|
70
|
+
onClick={action}
|
|
71
|
+
ref={ref}
|
|
72
|
+
size="sm"
|
|
73
|
+
className={cn('w-[32px] h-[32px]', customClass)}
|
|
74
|
+
// pressed={isActive?.() || false}
|
|
75
|
+
disabled={disabled}
|
|
76
|
+
{...(rest as Omit<typeof rest, 'loading'>)}
|
|
77
|
+
>
|
|
78
|
+
{icon && <Icon name={icon} className="size-4" />}
|
|
79
|
+
{children}
|
|
80
|
+
</Comp>
|
|
81
|
+
</TooltipTrigger>
|
|
82
|
+
|
|
83
|
+
{tooltip && (
|
|
84
|
+
<TooltipContent {...tooltipOptions}>
|
|
85
|
+
<div className="flex max-w-24 flex-col items-center text-center">
|
|
86
|
+
<div>
|
|
87
|
+
{tooltip}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
{!!shortcutKeys?.length && <span>
|
|
91
|
+
{getShortcutKeys(shortcutKeys)}
|
|
92
|
+
</span>}
|
|
93
|
+
</div>
|
|
94
|
+
</TooltipContent>
|
|
95
|
+
)}
|
|
96
|
+
</Tooltip>
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
ActionButton,
|
|
103
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
+
|
|
6
|
+
import { Button, Tooltip, TooltipContent, TooltipTrigger, icons } from 'reactjs-tiptap-editor-pro/components';
|
|
7
|
+
import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
|
|
8
|
+
import { getShortcutKeys } from 'reactjs-tiptap-editor-pro/utils/plateform';
|
|
9
|
+
|
|
10
|
+
export interface ActionMenuButtonProps {
|
|
11
|
+
/** Icon name to display */
|
|
12
|
+
icon?: any
|
|
13
|
+
/** Button title text */
|
|
14
|
+
title?: string
|
|
15
|
+
/** Tooltip text */
|
|
16
|
+
tooltip?: string
|
|
17
|
+
/** Whether the button is disabled */
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
/** Keyboard shortcut keys */
|
|
20
|
+
shortcutKeys?: string[]
|
|
21
|
+
/** Button color */
|
|
22
|
+
color?: string
|
|
23
|
+
/** Click action handler */
|
|
24
|
+
action?: ButtonViewReturnComponentProps['action']
|
|
25
|
+
/** Active state checker */
|
|
26
|
+
isActive?: ButtonViewReturnComponentProps['isActive']
|
|
27
|
+
/** Whether to render as child */
|
|
28
|
+
asChild?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ActionMenuButton = React.forwardRef<HTMLButtonElement, ActionMenuButtonProps>(
|
|
32
|
+
({ asChild, ...props }, ref) => {
|
|
33
|
+
const Icon = icons[props.icon];
|
|
34
|
+
const Comp = asChild ? Slot : Button;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Tooltip>
|
|
38
|
+
<TooltipTrigger asChild>
|
|
39
|
+
<Comp
|
|
40
|
+
className="h-[32px] min-w-24 overflow-hidden px-[5px] py-0"
|
|
41
|
+
disabled={props?.disabled}
|
|
42
|
+
ref={ref}
|
|
43
|
+
variant="ghost"
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
<div className="flex h-full items-center font-normal">
|
|
47
|
+
{props?.title && (
|
|
48
|
+
<div className="grow truncate text-left text-sm">
|
|
49
|
+
{props?.title}
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{Icon && <Icon className="ml-1 size-3 shrink-0 text-zinc-500" />}
|
|
54
|
+
</div>
|
|
55
|
+
</Comp>
|
|
56
|
+
</TooltipTrigger>
|
|
57
|
+
|
|
58
|
+
<TooltipContent>
|
|
59
|
+
<div className="flex max-w-24 flex-col items-center text-center">
|
|
60
|
+
{props?.tooltip && <div>
|
|
61
|
+
{props?.tooltip}
|
|
62
|
+
</div>}
|
|
63
|
+
|
|
64
|
+
<div className="flex">
|
|
65
|
+
{!!props?.shortcutKeys?.length && <span>
|
|
66
|
+
{getShortcutKeys(props?.shortcutKeys)}
|
|
67
|
+
</span>}
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</TooltipContent>
|
|
71
|
+
</Tooltip>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export { ActionMenuButton };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
import { BubbleMenuImage, BubbleMenuImageGif, BubbleMenuLink, BubbleMenuText, BubbleMenuVideo, ColumnsBubbleMenu, ContentMenu, TableBubbleMenu } from 'reactjs-tiptap-editor-pro/components';
|
|
4
|
+
import { BubbleMenuDrawer } from 'reactjs-tiptap-editor-pro/components/menus/components/BubbleMenuDrawer';
|
|
5
|
+
import { BubbleMenuExcalidraw } from 'reactjs-tiptap-editor-pro/components/menus/components/BubbleMenuExcalidraw';
|
|
6
|
+
import { BubbleMenuIframe } from 'reactjs-tiptap-editor-pro/components/menus/components/BubbleMenuIframe';
|
|
7
|
+
import BubbleMenuKatex from 'reactjs-tiptap-editor-pro/components/menus/components/BubbleMenuKatex';
|
|
8
|
+
import { BubbleMenuMermaid } from 'reactjs-tiptap-editor-pro/components/menus/components/BubbleMenuMermaid';
|
|
9
|
+
import { BubbleMenuTwitter } from 'reactjs-tiptap-editor-pro/components/menus/components/BubbleMenuTwitter';
|
|
10
|
+
import { Image, ImageGif } from 'reactjs-tiptap-editor-pro/extensions';
|
|
11
|
+
import type { BubbleMenuProps as BubbleMenuPropsType } from 'reactjs-tiptap-editor-pro/types';
|
|
12
|
+
|
|
13
|
+
export interface BubbleMenuComponentProps {
|
|
14
|
+
editor: Editor
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
bubbleMenu?: BubbleMenuPropsType
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Bubble Menu Component
|
|
21
|
+
*
|
|
22
|
+
* @param editor Editor instance
|
|
23
|
+
* @param disabled Whether the menu is disabled
|
|
24
|
+
* @param bubbleMenu Bubble menu configuration
|
|
25
|
+
* @returns Bubble menu component
|
|
26
|
+
*/
|
|
27
|
+
export function BubbleMenu({ editor, disabled, bubbleMenu }: BubbleMenuComponentProps) {
|
|
28
|
+
const extensionsNames = editor.extensionManager.extensions.map(ext => ext.name);
|
|
29
|
+
|
|
30
|
+
const renderMenuItems = () => [
|
|
31
|
+
extensionsNames.includes('columns') && !bubbleMenu?.columnConfig?.hidden ? <ColumnsBubbleMenu editor={editor}
|
|
32
|
+
key="columns"
|
|
33
|
+
/> : null,
|
|
34
|
+
extensionsNames.includes('table') && !bubbleMenu?.tableConfig?.hidden ? <TableBubbleMenu editor={editor} items={bubbleMenu?.tableConfig?.items} actions={bubbleMenu?.tableConfig?.actions}
|
|
35
|
+
key="table"
|
|
36
|
+
/> : null,
|
|
37
|
+
extensionsNames.includes('link') && !bubbleMenu?.linkConfig?.hidden ? <BubbleMenuLink disabled={disabled}
|
|
38
|
+
editor={editor}
|
|
39
|
+
key="link"
|
|
40
|
+
/> : null,
|
|
41
|
+
extensionsNames.includes(Image.name) && !bubbleMenu?.imageConfig?.hidden ? <BubbleMenuImage disabled={disabled}
|
|
42
|
+
editor={editor}
|
|
43
|
+
key="image"
|
|
44
|
+
/> : null,
|
|
45
|
+
extensionsNames.includes(ImageGif.name) && !bubbleMenu?.imageGifConfig?.hidden ? <BubbleMenuImageGif disabled={disabled}
|
|
46
|
+
editor={editor}
|
|
47
|
+
key="imageGif"
|
|
48
|
+
/> : null,
|
|
49
|
+
extensionsNames.includes('video') && !bubbleMenu?.videoConfig?.hidden ? <BubbleMenuVideo disabled={disabled}
|
|
50
|
+
editor={editor}
|
|
51
|
+
key="video"
|
|
52
|
+
/> : null,
|
|
53
|
+
extensionsNames.includes('katex') && !bubbleMenu?.katexConfig?.hidden ? <BubbleMenuKatex disabled={disabled}
|
|
54
|
+
editor={editor}
|
|
55
|
+
key="katex"
|
|
56
|
+
/> : null,
|
|
57
|
+
extensionsNames.includes('excalidraw') && !bubbleMenu?.excalidrawConfig?.hidden ? <BubbleMenuExcalidraw disabled={disabled}
|
|
58
|
+
editor={editor}
|
|
59
|
+
key="excalidraw"
|
|
60
|
+
/> : null,
|
|
61
|
+
extensionsNames.includes('mermaid') && !bubbleMenu?.mermaidConfig?.hidden ? <BubbleMenuMermaid disabled={disabled}
|
|
62
|
+
editor={editor}
|
|
63
|
+
key="mermaid"
|
|
64
|
+
/> : null,
|
|
65
|
+
extensionsNames.includes('iframe') && !bubbleMenu?.iframeConfig?.hidden ? <BubbleMenuIframe disabled={disabled}
|
|
66
|
+
editor={editor}
|
|
67
|
+
key="iframe"
|
|
68
|
+
/> : null,
|
|
69
|
+
extensionsNames.includes('twitter') && !bubbleMenu?.twitterConfig?.hidden ? <BubbleMenuTwitter disabled={disabled}
|
|
70
|
+
editor={editor}
|
|
71
|
+
key="twitter"
|
|
72
|
+
/> : null,
|
|
73
|
+
!bubbleMenu?.floatingMenuConfig?.hidden ? <ContentMenu disabled={disabled}
|
|
74
|
+
editor={editor}
|
|
75
|
+
key="content"
|
|
76
|
+
/> : null,
|
|
77
|
+
!bubbleMenu?.textConfig?.hidden ? <BubbleMenuText disabled={disabled}
|
|
78
|
+
editor={editor}
|
|
79
|
+
items={bubbleMenu?.textConfig?.items}
|
|
80
|
+
key="text"
|
|
81
|
+
/> : null,
|
|
82
|
+
extensionsNames.includes('drawer') && !bubbleMenu?.drawerConfig?.hidden ? <BubbleMenuDrawer disabled={disabled}
|
|
83
|
+
editor={editor}
|
|
84
|
+
key="drawer"
|
|
85
|
+
/> : null,
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
if (bubbleMenu?.render) {
|
|
89
|
+
return bubbleMenu.render({ editor, disabled: disabled || false, bubbleMenu }, renderMenuItems());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return renderMenuItems().filter(Boolean);
|
|
93
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
|
|
4
|
+
|
|
5
|
+
interface IPropsCharactorCount {
|
|
6
|
+
editor: Editor
|
|
7
|
+
extensions: any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function CharactorCount({ editor, extensions }: IPropsCharactorCount) {
|
|
11
|
+
const { t } = useLocale();
|
|
12
|
+
|
|
13
|
+
const limit = useMemo(() => {
|
|
14
|
+
return extensions?.find((extension: any) => extension.name === 'base-kit')?.options?.characterCount?.limit;
|
|
15
|
+
}, [extensions]);
|
|
16
|
+
|
|
17
|
+
if (!limit) {
|
|
18
|
+
return (
|
|
19
|
+
<div className="flex items-center justify-between p-3 border-t">
|
|
20
|
+
<div className="flex flex-col">
|
|
21
|
+
<div className="flex justify-end gap-3 text-sm">
|
|
22
|
+
<span>
|
|
23
|
+
{(editor as any).storage.characterCount.characters()}
|
|
24
|
+
{' '}
|
|
25
|
+
{t('editor.characters')}
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="flex items-center justify-between p-3 border-t">
|
|
35
|
+
<div className="flex flex-col">
|
|
36
|
+
<div className="flex justify-end gap-3 text-sm">
|
|
37
|
+
<span>
|
|
38
|
+
{editor.storage.characterCount.characters()}
|
|
39
|
+
/
|
|
40
|
+
{limit}
|
|
41
|
+
{' '}
|
|
42
|
+
{t('editor.characters')}
|
|
43
|
+
</span>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default CharactorCount;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Plus } from 'lucide-react';
|
|
4
|
+
import { HexColorPicker } from 'react-colorful';
|
|
5
|
+
|
|
6
|
+
import { Button, Input, Popover, PopoverContent, PopoverTrigger, Separator } from 'reactjs-tiptap-editor-pro/components';
|
|
7
|
+
import { NoFill } from 'reactjs-tiptap-editor-pro/components/icons/NoFill';
|
|
8
|
+
import { COLORS_LIST as DEFAULT_COLORS_LIST } from 'reactjs-tiptap-editor-pro/constants';
|
|
9
|
+
import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
|
|
10
|
+
|
|
11
|
+
export interface ColorPickerProps {
|
|
12
|
+
highlight?: boolean
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
colors?: string[]
|
|
15
|
+
defaultColor?: string
|
|
16
|
+
children: React.ReactNode
|
|
17
|
+
onChange?: (color: string | undefined) => void
|
|
18
|
+
setSelectedColor?: (color: string | undefined) => void
|
|
19
|
+
selectedColor?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ColorPicker(props: ColorPickerProps) {
|
|
23
|
+
const { t } = useLocale();
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
highlight = false,
|
|
27
|
+
disabled = false,
|
|
28
|
+
selectedColor,
|
|
29
|
+
setSelectedColor,
|
|
30
|
+
onChange,
|
|
31
|
+
colors = DEFAULT_COLORS_LIST,
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
const chunkedColors = useMemo(() => {
|
|
35
|
+
const colorsArray = colors;
|
|
36
|
+
const chunked: string[][] = [];
|
|
37
|
+
for (let i = 0; i < colorsArray.length; i += 10) {
|
|
38
|
+
chunked.push(colorsArray.slice(i, i + 10));
|
|
39
|
+
}
|
|
40
|
+
return chunked;
|
|
41
|
+
}, [colors]);
|
|
42
|
+
|
|
43
|
+
const [recentColorsStore, setRecentColorsStore] = useState<string[]>([]);
|
|
44
|
+
|
|
45
|
+
const setRecentColor = (color: string) => {
|
|
46
|
+
const newRecentColors = [...recentColorsStore];
|
|
47
|
+
const index = newRecentColors.indexOf(color);
|
|
48
|
+
if (index !== -1) {
|
|
49
|
+
newRecentColors.splice(index, 1);
|
|
50
|
+
}
|
|
51
|
+
newRecentColors.unshift(color);
|
|
52
|
+
if (newRecentColors.length > 10) {
|
|
53
|
+
newRecentColors.pop();
|
|
54
|
+
}
|
|
55
|
+
setRecentColorsStore(newRecentColors);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function setColor(color: string | undefined) {
|
|
59
|
+
if (color === undefined) {
|
|
60
|
+
// clear color
|
|
61
|
+
setSelectedColor?.(color);
|
|
62
|
+
onChange?.(color);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// check if color is correct
|
|
66
|
+
const isCorrectColor = /^#([\da-f]{3}){1,2}$/i.test(color);
|
|
67
|
+
if (isCorrectColor) {
|
|
68
|
+
setSelectedColor?.(color);
|
|
69
|
+
onChange?.(color);
|
|
70
|
+
setRecentColor(color);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Popover modal>
|
|
76
|
+
<PopoverTrigger asChild
|
|
77
|
+
className="!p-0"
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
>
|
|
80
|
+
{props?.children}
|
|
81
|
+
</PopoverTrigger>
|
|
82
|
+
|
|
83
|
+
<PopoverContent align="start"
|
|
84
|
+
className="size-full p-2"
|
|
85
|
+
hideWhenDetached
|
|
86
|
+
side="bottom"
|
|
87
|
+
>
|
|
88
|
+
<div className="flex flex-col">
|
|
89
|
+
{highlight
|
|
90
|
+
? (
|
|
91
|
+
<div
|
|
92
|
+
className="rd-1 flex cursor-pointer items-center gap-[4px] p-1 hover:bg-accent"
|
|
93
|
+
onClick={() => setColor(undefined)}
|
|
94
|
+
>
|
|
95
|
+
<NoFill />
|
|
96
|
+
|
|
97
|
+
<span className="ml-1 text-sm">
|
|
98
|
+
{t('editor.nofill')}
|
|
99
|
+
</span>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
: (
|
|
103
|
+
<div
|
|
104
|
+
className="rd-1 flex cursor-pointer items-center gap-[4px] p-1 hover:bg-accent"
|
|
105
|
+
onClick={() => {
|
|
106
|
+
setColor(undefined);
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<NoFill />
|
|
110
|
+
|
|
111
|
+
<span className="ml-1 text-sm">
|
|
112
|
+
{t('editor.default')}
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{chunkedColors.map((items: string[], index: number) => {
|
|
118
|
+
return (
|
|
119
|
+
<span className="relative flex h-auto w-full p-0 last:pb-2"
|
|
120
|
+
key={index}
|
|
121
|
+
>
|
|
122
|
+
{items.map((item: string, idx) => {
|
|
123
|
+
return (
|
|
124
|
+
<span
|
|
125
|
+
className="inline-block size-6 flex-[0_0_auto] cursor-pointer rounded-sm !border border-transparent p-0.5 hover:border-border hover:shadow-sm"
|
|
126
|
+
key={`sub-color-${idx}`}
|
|
127
|
+
onClick={() => setColor(item)}
|
|
128
|
+
>
|
|
129
|
+
<span
|
|
130
|
+
className="relative block size-[18px] rounded-[2px] border-transparent"
|
|
131
|
+
style={{
|
|
132
|
+
backgroundColor: item,
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{item === selectedColor
|
|
136
|
+
? (
|
|
137
|
+
<svg
|
|
138
|
+
className="absolute -top-px left-px block size-3"
|
|
139
|
+
viewBox="0 0 18 18"
|
|
140
|
+
style={{
|
|
141
|
+
fill: 'rgb(255, 255, 255)',
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path>
|
|
145
|
+
</svg>
|
|
146
|
+
)
|
|
147
|
+
: (
|
|
148
|
+
<svg
|
|
149
|
+
viewBox="0 0 18 18"
|
|
150
|
+
style={{
|
|
151
|
+
fill: 'rgb(255, 255, 255)',
|
|
152
|
+
display: 'none',
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path>
|
|
156
|
+
</svg>
|
|
157
|
+
)}
|
|
158
|
+
</span>
|
|
159
|
+
</span>
|
|
160
|
+
);
|
|
161
|
+
})}
|
|
162
|
+
</span>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
|
|
166
|
+
<div>
|
|
167
|
+
<div className="my-1 text-sm">
|
|
168
|
+
{t('editor.recent')}
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<span className="relative flex h-auto w-full p-0 last:pb-2">
|
|
172
|
+
{recentColorsStore?.map((item, index) => {
|
|
173
|
+
return (
|
|
174
|
+
<span
|
|
175
|
+
className="inline-block size-6 flex-[0_0_auto] cursor-pointer rounded-sm !border border-transparent p-0.5 hover:border-border hover:shadow-sm"
|
|
176
|
+
key={`sub-color-recent-${index}`}
|
|
177
|
+
onClick={() => setColor(item)}
|
|
178
|
+
>
|
|
179
|
+
<span
|
|
180
|
+
className="relative block size-[18px] rounded-[2px] border-transparent"
|
|
181
|
+
style={{
|
|
182
|
+
backgroundColor: item,
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<svg
|
|
186
|
+
viewBox="0 0 18 18"
|
|
187
|
+
style={{
|
|
188
|
+
fill: 'rgb(255, 255, 255)',
|
|
189
|
+
display: 'none',
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path>
|
|
193
|
+
</svg>
|
|
194
|
+
</span>
|
|
195
|
+
</span>
|
|
196
|
+
);
|
|
197
|
+
})}
|
|
198
|
+
</span>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<AddMoreColor setColor={setColor} />
|
|
202
|
+
</div>
|
|
203
|
+
</PopoverContent>
|
|
204
|
+
</Popover>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface AddMoreColorProps {
|
|
209
|
+
setColor: (color: string) => void
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function AddMoreColor({ setColor }: AddMoreColorProps) {
|
|
213
|
+
const [colorMore, setColorMore] = useState('#000000');
|
|
214
|
+
const [openColorMore, setOpenColorMore] = useState(false);
|
|
215
|
+
const { t } = useLocale();
|
|
216
|
+
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
return () => {
|
|
219
|
+
setOpenColorMore(false);
|
|
220
|
+
};
|
|
221
|
+
}, []);
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<Popover open={openColorMore}>
|
|
225
|
+
<PopoverTrigger asChild>
|
|
226
|
+
<div
|
|
227
|
+
className="p-1.5 text-sm hover:cursor-pointer hover:bg-accent"
|
|
228
|
+
onClick={(e) => {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
setOpenColorMore(true);
|
|
231
|
+
}}
|
|
232
|
+
>
|
|
233
|
+
{t('editor.color.more')}
|
|
234
|
+
...
|
|
235
|
+
</div>
|
|
236
|
+
</PopoverTrigger>
|
|
237
|
+
|
|
238
|
+
<PopoverContent>
|
|
239
|
+
<div className="flex flex-col items-center justify-center">
|
|
240
|
+
<HexColorPicker color={colorMore}
|
|
241
|
+
onChange={setColorMore}
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
<Input
|
|
245
|
+
className="mt-[8px] w-full"
|
|
246
|
+
type="text"
|
|
247
|
+
value={colorMore.slice(1)}
|
|
248
|
+
onChange={(e) => {
|
|
249
|
+
e.preventDefault();
|
|
250
|
+
setColorMore(`#${e.target.value}`);
|
|
251
|
+
}}
|
|
252
|
+
/>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<Separator className="my-[10px]" />
|
|
256
|
+
|
|
257
|
+
<Button
|
|
258
|
+
className="w-full"
|
|
259
|
+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
setColor(colorMore);
|
|
262
|
+
setOpenColorMore(false);
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
<Plus size={16} />
|
|
266
|
+
</Button>
|
|
267
|
+
</PopoverContent>
|
|
268
|
+
</Popover>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export { ColorPicker };
|