reactjs-tiptap-editor-pro 0.2.30 → 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 +60 -4
- 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
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.32",
|
|
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,10 +28,64 @@
|
|
|
28
28
|
"tiptap-react-rc-rich-text"
|
|
29
29
|
],
|
|
30
30
|
"sideEffects": false,
|
|
31
|
-
"main": "./
|
|
32
|
-
"module": "./
|
|
31
|
+
"main": "./lib/index.cjs",
|
|
32
|
+
"module": "./lib/index.js",
|
|
33
|
+
"types": "./lib/index.d.ts",
|
|
34
|
+
"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
|
+
}
|
|
86
|
+
},
|
|
33
87
|
"files": [
|
|
34
|
-
"
|
|
88
|
+
"lib",
|
|
35
89
|
"package.json",
|
|
36
90
|
"README.md",
|
|
37
91
|
"LICENSE"
|
|
@@ -168,6 +222,8 @@
|
|
|
168
222
|
"commit-msg": "npm run verify-commit"
|
|
169
223
|
},
|
|
170
224
|
"scripts": {
|
|
225
|
+
"build:lib": "vite build && pnpm modify-css",
|
|
226
|
+
"build:lib:dev": "vite build --mode development --watch",
|
|
171
227
|
"build:playground": "pnpm build:lib && pnpm --dir ./playground run build",
|
|
172
228
|
"docs:dev": "pnpm --parallel --filter docs... dev",
|
|
173
229
|
"docs:build": "pnpm --filter docs... build",
|
|
@@ -1,103 +0,0 @@
|
|
|
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 '@/components';
|
|
9
|
-
import { cn } from '@/lib/utils';
|
|
10
|
-
import type { ButtonViewReturnComponentProps } from '@/types';
|
|
11
|
-
import { getShortcutKeys } from '@/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
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
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 '@/components';
|
|
7
|
-
import type { ButtonViewReturnComponentProps } from '@/types';
|
|
8
|
-
import { getShortcutKeys } from '@/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 };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { Editor } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
import { BubbleMenuImage, BubbleMenuImageGif, BubbleMenuLink, BubbleMenuText, BubbleMenuVideo, ColumnsBubbleMenu, ContentMenu, TableBubbleMenu } from '@/components';
|
|
4
|
-
import { BubbleMenuDrawer } from '@/components/menus/components/BubbleMenuDrawer';
|
|
5
|
-
import { BubbleMenuExcalidraw } from '@/components/menus/components/BubbleMenuExcalidraw';
|
|
6
|
-
import { BubbleMenuIframe } from '@/components/menus/components/BubbleMenuIframe';
|
|
7
|
-
import BubbleMenuKatex from '@/components/menus/components/BubbleMenuKatex';
|
|
8
|
-
import { BubbleMenuMermaid } from '@/components/menus/components/BubbleMenuMermaid';
|
|
9
|
-
import { BubbleMenuTwitter } from '@/components/menus/components/BubbleMenuTwitter';
|
|
10
|
-
import { Image, ImageGif } from '@/extensions';
|
|
11
|
-
import type { BubbleMenuProps as BubbleMenuPropsType } from '@/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
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Editor } from '@tiptap/core';
|
|
2
|
-
import React, { useMemo } from 'react';
|
|
3
|
-
import { useLocale } from '@/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;
|
|
@@ -1,272 +0,0 @@
|
|
|
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 '@/components';
|
|
7
|
-
import { NoFill } from '@/components/icons/NoFill';
|
|
8
|
-
import { COLORS_LIST as DEFAULT_COLORS_LIST } from '@/constants';
|
|
9
|
-
import { useLocale } from '@/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 };
|