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.
Files changed (333) hide show
  1. package/package.json +5 -58
  2. package/src/components/ActionButton.tsx +103 -0
  3. package/src/components/ActionMenuButton.tsx +76 -0
  4. package/src/components/BubbleMenu.tsx +93 -0
  5. package/src/components/CharactorCount.tsx +50 -0
  6. package/src/components/ColorPicker.tsx +272 -0
  7. package/src/components/RichTextEditor.tsx +212 -0
  8. package/src/components/SizeSetter/SizeSetter.tsx +102 -0
  9. package/src/components/Toolbar.tsx +108 -0
  10. package/src/components/icons/Activity.tsx +19 -0
  11. package/src/components/icons/Animas.tsx +24 -0
  12. package/src/components/icons/AspectRatio.tsx +13 -0
  13. package/src/components/icons/Blockquote.tsx +17 -0
  14. package/src/components/icons/ColumnAddLeft.tsx +7 -0
  15. package/src/components/icons/ColumnAddRight.tsx +7 -0
  16. package/src/components/icons/DeleteColumn.tsx +26 -0
  17. package/src/components/icons/DeleteRow.tsx +26 -0
  18. package/src/components/icons/Direction.tsx +7 -0
  19. package/src/components/icons/Excalidraw.tsx +7 -0
  20. package/src/components/icons/ExportPdf.tsx +8 -0
  21. package/src/components/icons/ExportWord.tsx +24 -0
  22. package/src/components/icons/FileWordOutline.tsx +13 -0
  23. package/src/components/icons/Flag.tsx +19 -0
  24. package/src/components/icons/Food.tsx +20 -0
  25. package/src/components/icons/GIfIcon.tsx +10 -0
  26. package/src/components/icons/Icon.tsx +30 -0
  27. package/src/components/icons/ImportWord.tsx +23 -0
  28. package/src/components/icons/LeftToRight.tsx +7 -0
  29. package/src/components/icons/LineHeight.tsx +13 -0
  30. package/src/components/icons/MenuDown.tsx +24 -0
  31. package/src/components/icons/Mermaid.tsx +13 -0
  32. package/src/components/icons/NoFill.tsx +7 -0
  33. package/src/components/icons/Object.tsx +24 -0
  34. package/src/components/icons/RightToLeft.tsx +7 -0
  35. package/src/components/icons/SizeL.tsx +9 -0
  36. package/src/components/icons/SizeM.tsx +13 -0
  37. package/src/components/icons/SizeS.tsx +13 -0
  38. package/src/components/icons/Symbol.tsx +19 -0
  39. package/src/components/icons/Travel.tsx +24 -0
  40. package/src/components/icons/Twitter.tsx +7 -0
  41. package/src/components/icons/icons.ts +212 -0
  42. package/src/components/icons/index.ts +12 -0
  43. package/src/components/index.ts +9 -0
  44. package/src/components/menus/bubble.ts +395 -0
  45. package/src/components/menus/components/BubbleMenuContent.tsx +15 -0
  46. package/src/components/menus/components/BubbleMenuDrawer.tsx +128 -0
  47. package/src/components/menus/components/BubbleMenuExcalidraw.tsx +91 -0
  48. package/src/components/menus/components/BubbleMenuIframe.tsx +143 -0
  49. package/src/components/menus/components/BubbleMenuKatex.tsx +136 -0
  50. package/src/components/menus/components/BubbleMenuLink.tsx +99 -0
  51. package/src/components/menus/components/BubbleMenuMedia.tsx +235 -0
  52. package/src/components/menus/components/BubbleMenuMermaid.tsx +128 -0
  53. package/src/components/menus/components/BubbleMenuText.tsx +102 -0
  54. package/src/components/menus/components/BubbleMenuTwitter.tsx +91 -0
  55. package/src/components/menus/components/ColumnsBubbleMenu.tsx +59 -0
  56. package/src/components/menus/components/ContentMenu.tsx +396 -0
  57. package/src/components/menus/components/TableBubbleMenu.tsx +362 -0
  58. package/src/components/menus/index.ts +7 -0
  59. package/src/components/ui/button.tsx +56 -0
  60. package/src/components/ui/checkbox.tsx +30 -0
  61. package/src/components/ui/dialog.tsx +128 -0
  62. package/src/components/ui/dropdown-menu.tsx +203 -0
  63. package/src/components/ui/emoji-picker.tsx +166 -0
  64. package/src/components/ui/index.ts +14 -0
  65. package/src/components/ui/input.tsx +25 -0
  66. package/src/components/ui/label.tsx +26 -0
  67. package/src/components/ui/popover.tsx +31 -0
  68. package/src/components/ui/select.tsx +162 -0
  69. package/src/components/ui/separator.tsx +31 -0
  70. package/src/components/ui/switch.tsx +29 -0
  71. package/src/components/ui/tabs.tsx +55 -0
  72. package/src/components/ui/textarea.tsx +24 -0
  73. package/src/components/ui/toast.tsx +129 -0
  74. package/src/components/ui/toaster.tsx +44 -0
  75. package/src/components/ui/toggle.tsx +45 -0
  76. package/src/components/ui/tooltip.tsx +30 -0
  77. package/src/components/ui/use-toast.ts +197 -0
  78. package/src/constants/index.ts +223 -0
  79. package/src/constants/resetCSS.ts +139 -0
  80. package/src/extension-bundle.ts +2 -0
  81. package/src/extensions/Attachment/Attachment.ts +144 -0
  82. package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +69 -0
  83. package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +28 -0
  84. package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +155 -0
  85. package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +23 -0
  86. package/src/extensions/Attachment/index.ts +1 -0
  87. package/src/extensions/BaseKit.ts +253 -0
  88. package/src/extensions/Blockquote/Blockquote.ts +31 -0
  89. package/src/extensions/Blockquote/index.ts +1 -0
  90. package/src/extensions/Bold/Bold.ts +26 -0
  91. package/src/extensions/Bold/index.ts +1 -0
  92. package/src/extensions/BulletList/BulletList.ts +28 -0
  93. package/src/extensions/BulletList/index.ts +1 -0
  94. package/src/extensions/Clear/Clear.ts +24 -0
  95. package/src/extensions/Clear/index.ts +1 -0
  96. package/src/extensions/Code/Code.ts +26 -0
  97. package/src/extensions/Code/index.ts +1 -0
  98. package/src/extensions/CodeBlock/CodeBlock.ts +54 -0
  99. package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +66 -0
  100. package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +89 -0
  101. package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +81 -0
  102. package/src/extensions/CodeBlock/highlighter.ts +132 -0
  103. package/src/extensions/CodeBlock/index.ts +1 -0
  104. package/src/extensions/CodeBlock/shiki-plugin.ts +213 -0
  105. package/src/extensions/Color/Color.ts +52 -0
  106. package/src/extensions/Color/components/ColorActionButton.tsx +104 -0
  107. package/src/extensions/Color/index.ts +1 -0
  108. package/src/extensions/Document/Document.ts +8 -0
  109. package/src/extensions/Document/index.ts +1 -0
  110. package/src/extensions/Drawer/Drawer.ts +177 -0
  111. package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +85 -0
  112. package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +598 -0
  113. package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +500 -0
  114. package/src/extensions/Drawer/components/DrawerActiveButton.tsx +239 -0
  115. package/src/extensions/Drawer/components/EditDrawerBlock.tsx +238 -0
  116. package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +260 -0
  117. package/src/extensions/Drawer/index.ts +1 -0
  118. package/src/extensions/Emoji/Emoji.ts +146 -0
  119. package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +103 -0
  120. package/src/extensions/Emoji/components/EmojiList/emojis.ts +1858 -0
  121. package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +61 -0
  122. package/src/extensions/Emoji/index.ts +1 -0
  123. package/src/extensions/Excalidraw/Excalidraw.ts +123 -0
  124. package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +138 -0
  125. package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +178 -0
  126. package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +43 -0
  127. package/src/extensions/Excalidraw/index.ts +1 -0
  128. package/src/extensions/ExportPdf/ExportPdf.ts +25 -0
  129. package/src/extensions/ExportPdf/index.ts +1 -0
  130. package/src/extensions/ExportWord/ExportWord.ts +87 -0
  131. package/src/extensions/ExportWord/index.ts +1 -0
  132. package/src/extensions/FontFamily/FontFamily.ts +64 -0
  133. package/src/extensions/FontFamily/components/FontFamilyButton.tsx +97 -0
  134. package/src/extensions/FontFamily/index.ts +1 -0
  135. package/src/extensions/FontSize/FontSize.ts +119 -0
  136. package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +84 -0
  137. package/src/extensions/FontSize/index.ts +1 -0
  138. package/src/extensions/FormatPainter/FormatPainter.ts +121 -0
  139. package/src/extensions/FormatPainter/index.ts +1 -0
  140. package/src/extensions/Heading/Heading.ts +57 -0
  141. package/src/extensions/Heading/components/HeadingButton.tsx +96 -0
  142. package/src/extensions/Heading/index.ts +1 -0
  143. package/src/extensions/Highlight/Highlight.ts +36 -0
  144. package/src/extensions/Highlight/components/HighlightActionButton.tsx +108 -0
  145. package/src/extensions/Highlight/index.ts +1 -0
  146. package/src/extensions/History/History.ts +39 -0
  147. package/src/extensions/History/components/HistoryActionButton.tsx +74 -0
  148. package/src/extensions/History/index.ts +1 -0
  149. package/src/extensions/HorizontalRule/HorizontalRule.ts +42 -0
  150. package/src/extensions/HorizontalRule/index.ts +1 -0
  151. package/src/extensions/Iframe/Iframe.ts +140 -0
  152. package/src/extensions/Iframe/components/IframeNodeView.tsx +92 -0
  153. package/src/extensions/Iframe/components/index.module.scss +40 -0
  154. package/src/extensions/Iframe/embed.ts +487 -0
  155. package/src/extensions/Iframe/index.ts +1 -0
  156. package/src/extensions/Image/Image.ts +303 -0
  157. package/src/extensions/Image/components/ActionImageButton.tsx +186 -0
  158. package/src/extensions/Image/components/ImageCropper.tsx +198 -0
  159. package/src/extensions/Image/components/ImageView.tsx +271 -0
  160. package/src/extensions/Image/index.ts +1 -0
  161. package/src/extensions/Image/store.ts +15 -0
  162. package/src/extensions/ImageGif/ImageGif.ts +176 -0
  163. package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +138 -0
  164. package/src/extensions/ImageGif/components/ImageGifView.tsx +260 -0
  165. package/src/extensions/ImageGif/index.ts +1 -0
  166. package/src/extensions/ImportWord/ImportWord.ts +52 -0
  167. package/src/extensions/ImportWord/components/ImportWordButton.tsx +151 -0
  168. package/src/extensions/ImportWord/index.ts +1 -0
  169. package/src/extensions/Indent/Indent.ts +110 -0
  170. package/src/extensions/Indent/index.ts +1 -0
  171. package/src/extensions/Italic/Italic.ts +29 -0
  172. package/src/extensions/Italic/index.ts +1 -0
  173. package/src/extensions/Katex/Katex.ts +109 -0
  174. package/src/extensions/Katex/components/KatexActiveButton.tsx +117 -0
  175. package/src/extensions/Katex/components/KatexWrapper.tsx +53 -0
  176. package/src/extensions/Katex/index.ts +1 -0
  177. package/src/extensions/LineHeight/LineHeight.ts +76 -0
  178. package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +93 -0
  179. package/src/extensions/LineHeight/index.ts +1 -0
  180. package/src/extensions/Link/Link.ts +92 -0
  181. package/src/extensions/Link/components/LinkEditBlock.tsx +110 -0
  182. package/src/extensions/Link/components/LinkEditPopover.tsx +46 -0
  183. package/src/extensions/Link/components/LinkViewBlock.tsx +54 -0
  184. package/src/extensions/Link/index.ts +1 -0
  185. package/src/extensions/ListItem/ListItem.ts +1 -0
  186. package/src/extensions/ListItem/index.ts +1 -0
  187. package/src/extensions/Mention/Mention.ts +100 -0
  188. package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +94 -0
  189. package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +38 -0
  190. package/src/extensions/Mention/index.ts +1 -0
  191. package/src/extensions/Mermaid/Mermaid.ts +177 -0
  192. package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +155 -0
  193. package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +151 -0
  194. package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +260 -0
  195. package/src/extensions/Mermaid/index.ts +1 -0
  196. package/src/extensions/MoreMark/MoreMark.ts +102 -0
  197. package/src/extensions/MoreMark/components/ActionMoreButton.tsx +97 -0
  198. package/src/extensions/MoreMark/index.ts +1 -0
  199. package/src/extensions/MultiColumn/Column.ts +36 -0
  200. package/src/extensions/MultiColumn/MultiColumn.ts +111 -0
  201. package/src/extensions/MultiColumn/components/ColumnActionButton.ts +22 -0
  202. package/src/extensions/MultiColumn/index.ts +3 -0
  203. package/src/extensions/OrderedList/OrderedList.ts +28 -0
  204. package/src/extensions/OrderedList/index.ts +1 -0
  205. package/src/extensions/SearchAndReplace/SearchAndReplace.ts +395 -0
  206. package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +190 -0
  207. package/src/extensions/SearchAndReplace/index.ts +1 -0
  208. package/src/extensions/Selection/Selection.ts +32 -0
  209. package/src/extensions/Selection/index.ts +1 -0
  210. package/src/extensions/SlashCommand/SlashCommand.ts +255 -0
  211. package/src/extensions/SlashCommand/components/CommandsList.tsx +180 -0
  212. package/src/extensions/SlashCommand/groups.ts +183 -0
  213. package/src/extensions/SlashCommand/index.ts +1 -0
  214. package/src/extensions/SlashCommand/types.ts +24 -0
  215. package/src/extensions/Strike/Strike.ts +26 -0
  216. package/src/extensions/Strike/index.ts +1 -0
  217. package/src/extensions/Subscript/Subscript.ts +88 -0
  218. package/src/extensions/Subscript/index.ts +1 -0
  219. package/src/extensions/Table/Cell.ts +131 -0
  220. package/src/extensions/Table/Header.ts +93 -0
  221. package/src/extensions/Table/Row.ts +8 -0
  222. package/src/extensions/Table/Table.ts +60 -0
  223. package/src/extensions/Table/cell-background.ts +112 -0
  224. package/src/extensions/Table/components/CreateTablePopover.tsx +132 -0
  225. package/src/extensions/Table/components/TableActionButton.tsx +42 -0
  226. package/src/extensions/Table/index.ts +6 -0
  227. package/src/extensions/Table/utils.ts +352 -0
  228. package/src/extensions/TableOfContent/TableOfContent.ts +124 -0
  229. package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +116 -0
  230. package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +27 -0
  231. package/src/extensions/TableOfContent/components/index.module.scss +40 -0
  232. package/src/extensions/TableOfContent/index.ts +1 -0
  233. package/src/extensions/TaskList/TaskList.ts +46 -0
  234. package/src/extensions/TaskList/index.ts +1 -0
  235. package/src/extensions/TextAlign/TextAlign.ts +68 -0
  236. package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +103 -0
  237. package/src/extensions/TextAlign/index.ts +1 -0
  238. package/src/extensions/TextBubble/TextBubble.ts +22 -0
  239. package/src/extensions/TextBubble/components/TextDropdown.tsx +146 -0
  240. package/src/extensions/TextBubble/index.ts +1 -0
  241. package/src/extensions/TextDirection/TextDirection.ts +97 -0
  242. package/src/extensions/TextDirection/components/TextDirectionButton.tsx +103 -0
  243. package/src/extensions/TextDirection/index.ts +1 -0
  244. package/src/extensions/TrailingNode/TrailingNode.ts +71 -0
  245. package/src/extensions/TrailingNode/index.ts +1 -0
  246. package/src/extensions/Twitter/Twitter.ts +161 -0
  247. package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +68 -0
  248. package/src/extensions/Twitter/components/NodeViewTweet.tsx +30 -0
  249. package/src/extensions/Twitter/components/TwitterActiveButton.tsx +41 -0
  250. package/src/extensions/Twitter/index.ts +1 -0
  251. package/src/extensions/UnderLine/Underline.ts +30 -0
  252. package/src/extensions/UnderLine/index.ts +1 -0
  253. package/src/extensions/Video/Video.ts +204 -0
  254. package/src/extensions/Video/components/ActiveVideoButton.tsx +191 -0
  255. package/src/extensions/Video/index.ts +1 -0
  256. package/src/extensions/Video/store.ts +15 -0
  257. package/src/extensions/index.ts +122 -0
  258. package/src/hooks/useActive.tsx +24 -0
  259. package/src/hooks/useAttributes.tsx +45 -0
  260. package/src/hooks/useCopy.tsx +20 -0
  261. package/src/hooks/useEditorState.tsx +23 -0
  262. package/src/hooks/useExtension.tsx +29 -0
  263. package/src/index.ts +8 -0
  264. package/src/lib/utils.ts +7 -0
  265. package/src/locale-bundle.ts +3 -0
  266. package/src/locales/en.ts +173 -0
  267. package/src/locales/hu.ts +173 -0
  268. package/src/locales/index.tsx +163 -0
  269. package/src/locales/pt-br.ts +173 -0
  270. package/src/locales/vi.ts +173 -0
  271. package/src/locales/zh-cn.ts +173 -0
  272. package/src/plugins/DragHandle/index.ts +375 -0
  273. package/src/plugins/DragHandle/range.ts +114 -0
  274. package/src/plugins/DragHandle/utils.ts +80 -0
  275. package/src/plugins/image-upload.ts +160 -0
  276. package/src/store/ProviderRichText.tsx +53 -0
  277. package/src/store/editableEditor.ts +15 -0
  278. package/src/store/fast-context.tsx +70 -0
  279. package/src/store/store.ts +35 -0
  280. package/src/styles/ProseMirror.scss +176 -0
  281. package/src/styles/columns.scss +23 -0
  282. package/src/styles/editor.scss +411 -0
  283. package/src/styles/global.scss +87 -0
  284. package/src/styles/index.scss +5 -0
  285. package/src/styles/mention.scss +6 -0
  286. package/src/theme/theme.ts +15 -0
  287. package/src/types.ts +271 -0
  288. package/src/utils/_event.ts +55 -0
  289. package/src/utils/color.ts +67 -0
  290. package/src/utils/columns.ts +142 -0
  291. package/src/utils/customEvents/customEvents.ts +18 -0
  292. package/src/utils/customEvents/events.constant.ts +11 -0
  293. package/src/utils/delete-node.ts +46 -0
  294. package/src/utils/dom-dataset.ts +121 -0
  295. package/src/utils/download.ts +17 -0
  296. package/src/utils/dynamicCSS.ts +192 -0
  297. package/src/utils/editor-container-size.ts +28 -0
  298. package/src/utils/file.ts +112 -0
  299. package/src/utils/getRenderContainer.ts +41 -0
  300. package/src/utils/indent.ts +99 -0
  301. package/src/utils/is-mobile.ts +57 -0
  302. package/src/utils/json.ts +18 -0
  303. package/src/utils/line-height.ts +109 -0
  304. package/src/utils/lru-cache.ts +145 -0
  305. package/src/utils/mitt.ts +114 -0
  306. package/src/utils/node.ts +92 -0
  307. package/src/utils/pdf.ts +72 -0
  308. package/src/utils/plateform.ts +49 -0
  309. package/src/utils/shortId.ts +5 -0
  310. package/src/utils/storage.ts +18 -0
  311. package/src/utils/utils.ts +71 -0
  312. package/src/vite-env.d.ts +3 -0
  313. package/lib/RichTextEditor-BwbqJLnA.cjs +0 -141
  314. package/lib/RichTextEditor-iGJ6-rbq.js +0 -8833
  315. package/lib/extension-bundle.cjs +0 -33
  316. package/lib/extension-bundle.d.cts +0 -947
  317. package/lib/extension-bundle.d.ts +0 -947
  318. package/lib/extension-bundle.js +0 -5755
  319. package/lib/index-DV-nXpU1.cjs +0 -1
  320. package/lib/index-M6H3FoBi.js +0 -1147
  321. package/lib/index.cjs +0 -1
  322. package/lib/index.d.cts +0 -513
  323. package/lib/index.d.ts +0 -513
  324. package/lib/index.js +0 -16
  325. package/lib/locale-bundle.cjs +0 -1
  326. package/lib/locale-bundle.d.cts +0 -1140
  327. package/lib/locale-bundle.d.ts +0 -1140
  328. package/lib/locale-bundle.js +0 -9
  329. package/lib/style.css +0 -1
  330. package/lib/tiptap-DkWHMWDt.js +0 -6061
  331. package/lib/tiptap-gBG-1T-V.cjs +0 -116
  332. package/lib/vendor-BJ0Yf78E.cjs +0 -8114
  333. package/lib/vendor-Cpa6z-M0.js +0 -67575
@@ -0,0 +1,108 @@
1
+ import React, { useCallback, useState } from 'react';
2
+
3
+ import type { TooltipContentProps } from '@radix-ui/react-tooltip';
4
+ import { debounce } from 'lodash-es';
5
+
6
+ import { ActionButton, Button, ColorPicker } from 'reactjs-tiptap-editor-pro/components';
7
+ import { IconComponent } from 'reactjs-tiptap-editor-pro/components/icons';
8
+ import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
9
+
10
+ interface IPropsHighlightActionButton {
11
+ editor: any
12
+ tooltip?: string
13
+ disabled?: boolean
14
+ action?: ButtonViewReturnComponentProps['action']
15
+ isActive?: ButtonViewReturnComponentProps['isActive']
16
+ tooltipOptions?: TooltipContentProps
17
+ shortcutKeys?: string[]
18
+ }
19
+
20
+ function IconC({ fill }: any) {
21
+ return (
22
+ <svg
23
+ width="18px"
24
+ height="18px"
25
+ viewBox="0 0 256 256"
26
+ version="1.1"
27
+ xmlns="http://www.w3.org/2000/svg"
28
+ >
29
+ <g id="icon/填充色" stroke="none" strokeWidth={1} fill="none" fillRule="evenodd">
30
+ <g id="icon/背景颜色">
31
+ <g id="编组" fill="currentColor">
32
+ <g
33
+ transform="translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)"
34
+ id="矩形"
35
+ >
36
+ <path
37
+ d="M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z"
38
+ fillRule="nonzero"
39
+ />
40
+ <path
41
+ d="M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z"
42
+ fillRule="evenodd"
43
+ />
44
+ <path
45
+ d="M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z"
46
+ fillRule="nonzero"
47
+ />
48
+ </g>
49
+ </g>
50
+ <path
51
+ d="M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z"
52
+ id="矩形"
53
+ fill={fill || '#FBDE28'}
54
+ />
55
+ </g>
56
+ </g>
57
+ </svg>
58
+ );
59
+ }
60
+
61
+ function HighlightActionButton(props: IPropsHighlightActionButton) {
62
+ // const { action, isActive, disabled, icon, tooltip } = props as any;
63
+ const [selectedColor, setSelectedColor] = useState<any>(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: any) => {
75
+ setSelectedColor(color);
76
+ }, 350),
77
+ [],
78
+ );
79
+
80
+ return (
81
+ <div className="flex items-center h-[32px]">
82
+ <ActionButton
83
+ tooltip={props?.tooltip}
84
+ disabled={props?.disabled}
85
+ action={toggleColor}
86
+ tooltipOptions={props?.tooltipOptions}
87
+ shortcutKeys={props?.shortcutKeys}
88
+ >
89
+ <span className="flex items-center justify-center text-sm">
90
+ <IconC fill={selectedColor} />
91
+ </span>
92
+ </ActionButton>
93
+ <ColorPicker
94
+ selectedColor={selectedColor}
95
+ setSelectedColor={setSelectedColorDebounce}
96
+ onChange={onChange}
97
+ highlight
98
+ disabled={props?.disabled}
99
+ >
100
+ <Button variant="ghost" size="icon" className="!w-3 !h-[32px]" disabled={props?.disabled}>
101
+ <IconComponent className="!w-3 !h-3 text-zinc-500" name="MenuDown" />
102
+ </Button>
103
+ </ColorPicker>
104
+ </div>
105
+ );
106
+ }
107
+
108
+ export default HighlightActionButton;
@@ -0,0 +1 @@
1
+ export * from './Highlight';
@@ -0,0 +1,39 @@
1
+ import type { HistoryOptions as TiptapHistoryOptions } from '@tiptap/extension-history';
2
+ import { History as TiptapHistory } from '@tiptap/extension-history';
3
+
4
+ import HistoryActionButton from 'reactjs-tiptap-editor-pro/extensions/History/components/HistoryActionButton';
5
+ import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
6
+
7
+ export interface HistoryOptions extends TiptapHistoryOptions, GeneralOptions<HistoryOptions> {}
8
+
9
+ const historys: ['undo', 'redo'] = ['undo', 'redo'];
10
+
11
+ export const History = TiptapHistory.extend<HistoryOptions>({
12
+ addOptions() {
13
+ return {
14
+ ...this.parent?.(),
15
+ depth: 100,
16
+ newGroupDelay: 500,
17
+ button: ({ editor, t }: any) => {
18
+ return historys.map(item => ({
19
+ component: HistoryActionButton,
20
+ componentProps: {
21
+ action: () => {
22
+ if (item === 'undo') {
23
+ editor.chain().focus().undo().run();
24
+ }
25
+ if (item === 'redo') {
26
+ editor.chain().focus().redo().run();
27
+ }
28
+ },
29
+ shortcutKeys: item === 'undo' ? ['mod', 'Z'] : ['shift', 'mod', 'Z'],
30
+ disabled: item === 'undo' ? !editor.can().undo() : !editor.can().redo(),
31
+ isActive: () => (item === 'undo' ? !editor.can().undo() : !editor.can().redo()),
32
+ icon: item === 'undo' ? 'Undo2' : 'Redo2',
33
+ tooltip: t(`editor.${item}.tooltip`),
34
+ },
35
+ }));
36
+ },
37
+ };
38
+ },
39
+ });
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+
3
+ import type { TooltipContentProps } from '@radix-ui/react-tooltip';
4
+
5
+ import { Toggle, Tooltip, TooltipContent, TooltipTrigger, icons } from 'reactjs-tiptap-editor-pro/components';
6
+ import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
7
+ import { getShortcutKeys } from 'reactjs-tiptap-editor-pro/utils/plateform';
8
+
9
+ interface IPropsHistoryActionButton {
10
+ icon?: string
11
+ title?: string
12
+ tooltip?: string
13
+ disabled?: boolean
14
+ shortcutKeys?: string[]
15
+ customClass?: string
16
+ loading?: boolean
17
+ tooltipOptions?: TooltipContentProps
18
+ color?: string
19
+ action?: ButtonViewReturnComponentProps['action']
20
+ isActive?: ButtonViewReturnComponentProps['isActive']
21
+ children?: React.ReactNode
22
+ }
23
+
24
+ function HistoryActionButton(props?: Partial<IPropsHistoryActionButton>) {
25
+ const {
26
+ icon = undefined,
27
+ // title = undefined,
28
+ tooltip = undefined,
29
+ // disabled = false,
30
+ customClass = '',
31
+ // color = undefined,
32
+ // loading = false,
33
+ // shortcutKeys = undefined,
34
+ tooltipOptions = {},
35
+ action = undefined,
36
+ isActive = undefined,
37
+ children,
38
+ } = props as any;
39
+
40
+ const Icon = icons[icon as string];
41
+
42
+ return (
43
+ <Tooltip>
44
+ <TooltipTrigger asChild>
45
+ <Toggle
46
+ size="sm"
47
+ className={`w-[32px] h-[32px] ${customClass}`}
48
+ disabled={isActive?.()}
49
+ onClick={action}
50
+ // data-state={isActive?.() ? 'on' : 'off'}
51
+ >
52
+ {Icon && <Icon className="w-4 h-4" />}
53
+ {children && <>
54
+ {children}
55
+ </>}
56
+ </Toggle>
57
+ </TooltipTrigger>
58
+ {tooltip && (
59
+ <TooltipContent {...tooltipOptions}>
60
+ <div className="flex flex-col items-center text-center max-w-24">
61
+ <div>
62
+ {tooltip}
63
+ </div>
64
+ {!!props?.shortcutKeys?.length && <span>
65
+ {getShortcutKeys(props?.shortcutKeys)}
66
+ </span>}
67
+ </div>
68
+ </TooltipContent>
69
+ )}
70
+ </Tooltip>
71
+ );
72
+ }
73
+
74
+ export default HistoryActionButton;
@@ -0,0 +1 @@
1
+ export * from './History';
@@ -0,0 +1,42 @@
1
+ import { mergeAttributes } from '@tiptap/core';
2
+ import type { HorizontalRuleOptions as TiptapHorizontalRuleOptions } from '@tiptap/extension-horizontal-rule';
3
+ import { HorizontalRule as TiptapHorizontalRule } from '@tiptap/extension-horizontal-rule';
4
+
5
+ import { ActionButton } from 'reactjs-tiptap-editor-pro/components';
6
+ import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
7
+
8
+ export interface HorizontalRuleOptions
9
+ extends TiptapHorizontalRuleOptions,
10
+ GeneralOptions<HorizontalRuleOptions> {}
11
+
12
+ export const HorizontalRule = TiptapHorizontalRule.extend<HorizontalRuleOptions>({
13
+ renderHTML() {
14
+ return [
15
+ 'div',
16
+ mergeAttributes(this.options.HTMLAttributes, {
17
+ 'data-type': this.name,
18
+ }),
19
+ ['hr'],
20
+ ];
21
+ },
22
+ addOptions() {
23
+ return {
24
+ ...this.parent?.(),
25
+ button: ({ editor, t }) => ({
26
+ component: ActionButton,
27
+ componentProps: {
28
+ action: () => editor.commands.setHorizontalRule(),
29
+ disabled: !editor.can().setHorizontalRule(),
30
+ icon: 'Minus',
31
+ shortcutKeys: ['mod', 'alt', 'S'],
32
+ tooltip: t('editor.horizontalrule.tooltip'),
33
+ },
34
+ }),
35
+ };
36
+ },
37
+ addKeyboardShortcuts() {
38
+ return {
39
+ 'Mod-Alt-s': () => this.editor.commands.setHorizontalRule(),
40
+ };
41
+ },
42
+ });
@@ -0,0 +1 @@
1
+ export * from './HorizontalRule';
@@ -0,0 +1,140 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
3
+ import { ReactNodeViewRenderer } from '@tiptap/react';
4
+
5
+ import { ActionButton } from 'reactjs-tiptap-editor-pro/components';
6
+ import IframeNodeView from 'reactjs-tiptap-editor-pro/extensions/Iframe/components/IframeNodeView';
7
+ import { getDatasetAttribute } from 'reactjs-tiptap-editor-pro/utils/dom-dataset';
8
+
9
+ export interface IIframeAttrs {
10
+ width?: number | string
11
+ height?: number
12
+ url?: string
13
+ defaultShowPicker?: boolean
14
+ }
15
+
16
+ declare module '@tiptap/core' {
17
+ interface Commands<ReturnType> {
18
+ iframe: {
19
+ /**
20
+ * Add an iframe
21
+ */
22
+ setIframe: (options: { src: string, service: string }) => ReturnType
23
+ }
24
+ }
25
+ }
26
+
27
+ export const Iframe = Node.create({
28
+ name: 'iframe',
29
+ content: '',
30
+ marks: '',
31
+ group: 'block',
32
+ selectable: true,
33
+ atom: true,
34
+ draggable: true,
35
+
36
+ addOptions() {
37
+ return {
38
+ ...this.parent?.(),
39
+ HTMLAttributes: {
40
+ class: 'iframe',
41
+ },
42
+ button: ({
43
+ editor,
44
+ extension,
45
+ t,
46
+ }: {
47
+ editor: any
48
+ extension: any
49
+ t: (key: string) => string
50
+ }) => ({
51
+ component: ActionButton,
52
+ componentProps: {
53
+ action: (options: { src: string, service: string }) => editor.commands.setIframe(options),
54
+ upload: extension.options.upload,
55
+ disabled: !editor.can().setIframe({}),
56
+ icon: 'Iframe',
57
+ tooltip: t('editor.iframe.tooltip'),
58
+ },
59
+ }),
60
+ };
61
+ },
62
+
63
+ addAttributes() {
64
+ return {
65
+ width: {
66
+ default: 600,
67
+ parseHTML: getDatasetAttribute('width'),
68
+ },
69
+ height: {
70
+ default: 300,
71
+ parseHTML: getDatasetAttribute('height'),
72
+ },
73
+ url: {
74
+ default: null,
75
+ parseHTML: getDatasetAttribute('url'),
76
+ },
77
+ defaultShowPicker: {
78
+ default: false,
79
+ },
80
+ frameborder: {
81
+ default: 0,
82
+ },
83
+ allowfullscreen: {
84
+ default: this.options.allowFullscreen,
85
+ parseHTML: () => this.options.allowFullscreen,
86
+ },
87
+ };
88
+ },
89
+
90
+ parseHTML() {
91
+ return [
92
+ {
93
+ tag: 'iframe',
94
+ },
95
+ ];
96
+ },
97
+
98
+ renderHTML({ HTMLAttributes }) {
99
+ return ['iframe', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
100
+ },
101
+
102
+ addCommands() {
103
+ return {
104
+ setIframe:
105
+ options =>
106
+ ({ tr, commands, chain }) => {
107
+ // @ts-ignore
108
+ if (tr.selection?.node?.type?.name == this.name) {
109
+ return commands.updateAttributes(this.name, options);
110
+ }
111
+
112
+ const attrs = options || { url: '' };
113
+ // const { selection } = editor.state
114
+
115
+ return chain()
116
+ .insertContent({
117
+ type: this.name,
118
+ attrs,
119
+ })
120
+ .run();
121
+ },
122
+ };
123
+ },
124
+
125
+ addInputRules() {
126
+ return [
127
+ nodeInputRule({
128
+ find: /^\$iframe\$$/,
129
+ type: this.type,
130
+ getAttributes: () => {
131
+ return { width: '100%' };
132
+ },
133
+ }),
134
+ ];
135
+ },
136
+
137
+ addNodeView() {
138
+ return ReactNodeViewRenderer(IframeNodeView);
139
+ },
140
+ });
@@ -0,0 +1,92 @@
1
+ import { useCallback, useState } from 'react';
2
+
3
+ import { NodeViewWrapper } from '@tiptap/react';
4
+ import clsx from 'clsx';
5
+ import { Resizable } from 're-resizable';
6
+
7
+ // import { getEditorContainerDOMSize } from 'reactjs-tiptap-editor-pro/utils'
8
+ import { Button, Input } from 'reactjs-tiptap-editor-pro/components/ui';
9
+ import { Iframe } from 'reactjs-tiptap-editor-pro/extensions/Iframe/Iframe';
10
+ import { useEditableEditor } from 'reactjs-tiptap-editor-pro/store/editableEditor';
11
+
12
+ import styles from './index.module.scss';
13
+
14
+ function IframeNodeView({ editor, node, updateAttributes }: any) {
15
+ const isEditable = useEditableEditor();
16
+
17
+ const { url, width, height } = node.attrs;
18
+ // const { width: maxWidth } = getEditorContainerDOMSize(editor)
19
+
20
+ const [originalLink, setOriginalLink] = useState<string>('');
21
+
22
+ function handleConfirm() {
23
+ if (!originalLink) {
24
+ return;
25
+ }
26
+
27
+ editor
28
+ .chain()
29
+ .updateAttributes(Iframe.name, {
30
+ url: originalLink,
31
+ })
32
+ .setNodeSelection(editor.state.selection.from)
33
+ .focus()
34
+ .run();
35
+ }
36
+
37
+ const onResize = useCallback(
38
+ (size: any) => {
39
+ updateAttributes({ width: size.width, height: size.height });
40
+ },
41
+ [updateAttributes],
42
+ );
43
+
44
+ return (
45
+ <NodeViewWrapper>
46
+ {!url && (
47
+ <div className="mx-auto my-[12px] flex max-w-[600px] items-center justify-center gap-[10px] rounded-[12px] border border-solid border-[#ccc] p-[10px]">
48
+ <Input
49
+ autoFocus
50
+ className="flex-1"
51
+ onInput={(e: any) => setOriginalLink(e.target.value)}
52
+ placeholder="Enter link"
53
+ type="url"
54
+ value={originalLink}
55
+ />
56
+
57
+ <Button className="w-[60px]"
58
+ onClick={handleConfirm}
59
+ >
60
+ OK
61
+ </Button>
62
+ </div>
63
+ )}
64
+
65
+ {url && (
66
+ <Resizable
67
+ size={{ width: Number.parseInt(width), height: Number.parseInt(height) }}
68
+ onResizeStop={(e, direction, ref, d) => {
69
+ onResize({
70
+ width: Number.parseInt(width) + d.width,
71
+ height: Number.parseInt(height) + d.height,
72
+ });
73
+ }}
74
+ >
75
+ <div className={clsx(styles.wrap, 'render-wrapper')}>
76
+ <div className={styles.innerWrap}
77
+ style={{ pointerEvents: !isEditable ? 'auto' : 'none' }}
78
+ >
79
+ <iframe
80
+ className="my-[12px] "
81
+ src={url}
82
+ >
83
+ </iframe>
84
+ </div>
85
+ </div>
86
+ </Resizable>
87
+ )}
88
+ </NodeViewWrapper>
89
+ );
90
+ }
91
+
92
+ export default IframeNodeView;
@@ -0,0 +1,40 @@
1
+ .wrap {
2
+ display: flex;
3
+ height: 100%;
4
+ max-width: 100%;
5
+ overflow: hidden;
6
+ line-height: 0;
7
+ flex-direction: column;
8
+ border: 1px dashed hsl(var(--border)) !important;
9
+ border-radius: 6px;
10
+
11
+ .handlerWrap {
12
+ display: flex;
13
+ padding: 10px;
14
+ }
15
+
16
+ .innerWrap {
17
+ position: relative;
18
+ width: 100%;
19
+ height: 100%;
20
+ overflow: hidden;
21
+ border-radius: var(--border-radius);
22
+ flex: 1;
23
+ }
24
+
25
+ .emptyWrap {
26
+ display: flex;
27
+ height: 100%;
28
+ justify-content: center;
29
+ align-items: center;
30
+ }
31
+
32
+ :global {
33
+ iframe {
34
+ width: 100%;
35
+ height: 100%;
36
+ border: 0;
37
+ border: none !important;
38
+ }
39
+ }
40
+ }