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,41 @@
1
+ import { ActionButton, IconComponent, Popover, PopoverContent, PopoverTrigger } from 'reactjs-tiptap-editor-pro/components';
2
+ import FormEditLinkTwitter from 'reactjs-tiptap-editor-pro/extensions/Twitter/components/FormEditLinkTwitter';
3
+ import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
4
+
5
+ interface IPropsTwitterActiveButton {
6
+ editor: any
7
+ icon?: any
8
+ title?: string
9
+ tooltip?: string
10
+ disabled?: boolean
11
+ shortcutKeys?: string[]
12
+ isActive?: ButtonViewReturnComponentProps['isActive']
13
+ action?: ButtonViewReturnComponentProps['action']
14
+ }
15
+
16
+ function TwitterActiveButton(props: IPropsTwitterActiveButton) {
17
+ function onSetLink(src: string) {
18
+ if (props.action) {
19
+ props.action(src);
20
+ }
21
+ }
22
+
23
+ return (
24
+ <Popover modal>
25
+ <PopoverTrigger disabled={props?.disabled} asChild>
26
+ <ActionButton
27
+ tooltip={props?.tooltip}
28
+ isActive={props?.isActive}
29
+ disabled={props?.disabled}
30
+ >
31
+ <IconComponent name={props?.icon} />
32
+ </ActionButton>
33
+ </PopoverTrigger>
34
+ <PopoverContent hideWhenDetached className="w-full" align="start" side="bottom">
35
+ <FormEditLinkTwitter editor={props.editor} onSetLink={onSetLink} />
36
+ </PopoverContent>
37
+ </Popover>
38
+ );
39
+ }
40
+
41
+ export default TwitterActiveButton;
@@ -0,0 +1 @@
1
+ export * from './Twitter';
@@ -0,0 +1,30 @@
1
+ import type { UnderlineOptions as TiptapUnderlineOptions } from '@tiptap/extension-underline';
2
+ import TiptapUnderline from '@tiptap/extension-underline';
3
+
4
+ import { ActionButton } from 'reactjs-tiptap-editor-pro/components';
5
+ import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
6
+
7
+ export interface UnderlineOptions
8
+ extends TiptapUnderlineOptions,
9
+ GeneralOptions<UnderlineOptions> {}
10
+
11
+ export const Underline = TiptapUnderline.extend<UnderlineOptions>({
12
+ addOptions() {
13
+ return {
14
+ ...this.parent?.(),
15
+ button({ editor, t }: any) {
16
+ return {
17
+ component: ActionButton,
18
+ componentProps: {
19
+ action: () => editor.commands.toggleUnderline(),
20
+ isActive: () => editor.isActive('underline') || false,
21
+ disabled: !editor.can().toggleUnderline(),
22
+ icon: 'Underline',
23
+ shortcutKeys: ['mod', 'U'],
24
+ tooltip: t('editor.underline.tooltip'),
25
+ },
26
+ };
27
+ },
28
+ };
29
+ },
30
+ });
@@ -0,0 +1 @@
1
+ export * from './Underline';
@@ -0,0 +1,204 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ import { VIDEO_SIZE } from 'reactjs-tiptap-editor-pro/constants';
4
+ import ActionVideoButton from 'reactjs-tiptap-editor-pro/extensions/Video/components/ActiveVideoButton';
5
+ import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
6
+ import { getCssUnitWithDefault } from 'reactjs-tiptap-editor-pro/utils/utils';
7
+
8
+ /**
9
+ * Represents the interface for video options, extending GeneralOptions.
10
+ */
11
+ export interface VideoOptions extends GeneralOptions<VideoOptions> {
12
+ /**
13
+ * Indicates whether fullscreen play is allowed
14
+ *
15
+ * @default true
16
+ */
17
+ allowFullscreen: boolean
18
+ /**
19
+ * Indicates whether to display the frameborder
20
+ *
21
+ * @default false
22
+ */
23
+ frameborder: boolean
24
+ /**
25
+ * Width of the video, can be a number or string
26
+ *
27
+ * @default VIDEO_SIZE['size-medium']
28
+ */
29
+ width: number | string
30
+ /** HTML attributes object for passing additional attributes */
31
+ HTMLAttributes: {
32
+ [key: string]: any
33
+ }
34
+ /** Function for uploading files */
35
+ upload?: (file: File) => Promise<string>
36
+
37
+ /** The source URL of the video */
38
+ resourceVideo: 'upload' | 'link' | 'both'
39
+ }
40
+
41
+ /**
42
+ * Represents the type for setting video options
43
+ */
44
+ interface SetVideoOptions {
45
+ /** The source URL of the video */
46
+ src: string
47
+ /** The width of the video */
48
+ width: string | number
49
+ }
50
+
51
+ declare module '@tiptap/core' {
52
+ interface Commands<ReturnType> {
53
+ video: {
54
+ /**
55
+ * Add an video
56
+ */
57
+ setVideo: (options: Partial<SetVideoOptions>) => ReturnType
58
+ /**
59
+ * Update an video
60
+ */
61
+ updateVideo: (options: Partial<SetVideoOptions>) => ReturnType
62
+ }
63
+ }
64
+ }
65
+
66
+ function linkConvert(src: string) {
67
+ // Convert youtube links
68
+ src = src
69
+ .replace('https://youtu.be/', 'https://www.youtube.com/watch?v=')
70
+ .replace('watch?v=', 'embed/');
71
+
72
+ // Convert vimeo links
73
+ src = src.replace('https://vimeo.com/', 'https://player.vimeo.com/video/');
74
+
75
+ // Convert bilibili links
76
+ const isBilibiliLink = /^https?:\/\/www.bilibili.com\/video\/.*/i.test(src);
77
+ if (isBilibiliLink) {
78
+ src = src
79
+ .replace(/\?.*$/, '')
80
+ .replace('https://www.bilibili.com/video/', 'https://player.bilibili.com/player.html?bvid=');
81
+ }
82
+
83
+ // Convert google drive links
84
+ if (src.includes('drive.google.com')) {
85
+ src = src.replace('/view', '/preview');
86
+ }
87
+
88
+ return src;
89
+ }
90
+
91
+ export const Video = Node.create<VideoOptions>({
92
+ name: 'video',
93
+ group: 'block',
94
+ atom: true,
95
+ draggable: true,
96
+
97
+ addOptions() {
98
+ return {
99
+ divider: false,
100
+ spacer: false,
101
+ allowFullscreen: true,
102
+ upload: undefined,
103
+ frameborder: false,
104
+ resourceVideo: 'both',
105
+ width: VIDEO_SIZE['size-medium'],
106
+ HTMLAttributes: {
107
+ class: 'iframe-wrapper',
108
+ style: 'display: flex;justify-content: center;',
109
+ },
110
+ button: ({ editor, t }: any) => {
111
+ return {
112
+ component: ActionVideoButton,
113
+ componentProps: {
114
+ action: () => {
115
+ return;
116
+ },
117
+ isActive: () => editor.isActive('video') || false,
118
+ /* If setVideo is not available(when Video Component is not imported), the button is disabled */
119
+ disabled: !editor.can().setVideo?.({}),
120
+ icon: 'Video',
121
+ tooltip: t('editor.video.tooltip'),
122
+ editor,
123
+ },
124
+ };
125
+ },
126
+ };
127
+ },
128
+
129
+ addAttributes() {
130
+ return {
131
+ src: {
132
+ default: null,
133
+ renderHTML: ({ src }) => ({
134
+ src: src ? linkConvert(src) : null,
135
+ }),
136
+ },
137
+ width: {
138
+ default: this.options.width,
139
+ renderHTML: ({ width }) => ({
140
+ width: getCssUnitWithDefault(width),
141
+ }),
142
+ },
143
+ frameborder: {
144
+ default: this.options.frameborder ? 1 : 0,
145
+ parseHTML: () => (this.options.frameborder ? 1 : 0),
146
+ },
147
+ allowfullscreen: {
148
+ default: this.options.allowFullscreen,
149
+ parseHTML: () => this.options.allowFullscreen,
150
+ },
151
+ };
152
+ },
153
+
154
+ parseHTML() {
155
+ return [
156
+ {
157
+ tag: 'div[data-video] iframe',
158
+ },
159
+ ];
160
+ },
161
+
162
+ renderHTML({ HTMLAttributes }) {
163
+ const { width = '100%' } = HTMLAttributes ?? {};
164
+
165
+ const iframeHTMLAttributes = {
166
+ ...HTMLAttributes,
167
+ width: '100%',
168
+ height: '100%',
169
+ };
170
+
171
+ const responsiveStyle = `position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${width};`;
172
+ const responsiveSizesStyle = `flex: 1;padding-bottom: ${(9 / 16) * 100}%;`;
173
+
174
+ const iframeDOM = ['iframe', iframeHTMLAttributes];
175
+ const sizesDOM = ['div', { style: responsiveSizesStyle }];
176
+ const responsiveDOM = ['div', { style: responsiveStyle }, sizesDOM, iframeDOM];
177
+
178
+ const divAttrs = {
179
+ ...this.options.HTMLAttributes,
180
+ 'data-video': '',
181
+ };
182
+
183
+ return ['div', divAttrs, responsiveDOM];
184
+ },
185
+
186
+ addCommands() {
187
+ return {
188
+ setVideo:
189
+ options =>
190
+ ({ commands }) => {
191
+ return commands.insertContent({
192
+ type: this.name,
193
+ attrs: options,
194
+ });
195
+ },
196
+ updateVideo:
197
+ options =>
198
+ ({ commands }) => {
199
+ return commands.updateAttributes(this.name, options);
200
+ },
201
+ };
202
+ },
203
+
204
+ });
@@ -0,0 +1,191 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+
3
+ import { ActionButton, Button, Input, Tabs, TabsContent, TabsList, TabsTrigger } from 'reactjs-tiptap-editor-pro/components';
4
+ import { Dialog, DialogContent, DialogTitle, DialogTrigger } from 'reactjs-tiptap-editor-pro/components/ui/dialog';
5
+ import { Video } from 'reactjs-tiptap-editor-pro/extensions/Video/Video';
6
+ import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
7
+ import { listenEvent } from 'reactjs-tiptap-editor-pro/utils/customEvents/customEvents';
8
+ import { EVENTS } from 'reactjs-tiptap-editor-pro/utils/customEvents/events.constant';
9
+
10
+ function checkIsVideo(url: string) {
11
+ return /\.(?:mp4|webm|ogg|mov)$/i.test(url);
12
+ }
13
+
14
+ function ActionVideoButton(props: any) {
15
+ const { t } = useLocale();
16
+
17
+ const [link, setLink] = useState<string>('');
18
+ const fileInput = useRef<HTMLInputElement>(null);
19
+
20
+ const [error, setError] = useState<string>('');
21
+
22
+ const [open, setOpen] = useState(false);
23
+
24
+ const handleUploadVideo = (evt: any) => {
25
+ setOpen(evt.detail);
26
+ };
27
+
28
+ useEffect(() => {
29
+ const rm1 = listenEvent(EVENTS.UPLOAD_VIDEO(props.editor.id), handleUploadVideo);
30
+
31
+ return () => {
32
+ rm1();
33
+ };
34
+ }, []);
35
+
36
+ const uploadOptions = useMemo(() => {
37
+ const uploadOptions = props.editor.extensionManager.extensions.find(
38
+ (extension: any) => extension.name === Video.name,
39
+ )?.options;
40
+
41
+ return uploadOptions;
42
+ }, [props.editor]);
43
+
44
+ async function handleFile(event: any) {
45
+ const files = event?.target?.files;
46
+ if (!props.editor || props.editor.isDestroyed || files.length === 0) {
47
+ return;
48
+ }
49
+ const file = files[0];
50
+
51
+ let src = '';
52
+ if (uploadOptions.upload) {
53
+ src = await uploadOptions.upload(file);
54
+ } else {
55
+ src = URL.createObjectURL(file);
56
+ }
57
+
58
+ props.editor
59
+ .chain()
60
+ .focus()
61
+ .setVideo({
62
+ src,
63
+ width: '100%',
64
+ })
65
+ .run();
66
+ setOpen(false);
67
+ }
68
+ function handleLink(e: any) {
69
+ e.preventDefault();
70
+ e.stopPropagation();
71
+
72
+ if (!link) {
73
+ return;
74
+ }
75
+
76
+ props.editor
77
+ .chain()
78
+ .focus()
79
+ .setVideo({
80
+ src: link,
81
+ width: '100%',
82
+ })
83
+ .run();
84
+ setOpen(false);
85
+ }
86
+
87
+ function handleClick(e: any) {
88
+ e.preventDefault();
89
+ fileInput.current?.click();
90
+ }
91
+
92
+ return (
93
+ <Dialog onOpenChange={setOpen}
94
+ open={open}
95
+ >
96
+ <DialogTrigger asChild>
97
+ <ActionButton
98
+ action={() => setOpen(true)}
99
+ icon={props.icon}
100
+ tooltip={props.tooltip}
101
+ />
102
+ </DialogTrigger>
103
+
104
+ <DialogContent>
105
+ <DialogTitle>
106
+ {t('editor.video.dialog.title')}
107
+ </DialogTitle>
108
+
109
+ <Tabs
110
+ activationMode="manual"
111
+ defaultValue={
112
+ (uploadOptions?.resourceVideo === 'both' || uploadOptions?.resourceVideo === 'upload') ? 'upload' : 'link'
113
+ }
114
+ >
115
+ <TabsList className="grid w-full grid-cols-2">
116
+ {(uploadOptions?.resourceVideo === 'both' || uploadOptions?.resourceVideo === 'upload') && (
117
+ <TabsTrigger value="upload">
118
+ {t('editor.video.dialog.tab.upload')}
119
+ </TabsTrigger>
120
+ )}
121
+
122
+ {(uploadOptions?.resourceVideo === 'both' || uploadOptions?.resourceVideo === 'link') && (
123
+ <TabsTrigger value="link">
124
+ {t('editor.video.dialog.link')}
125
+ </TabsTrigger>
126
+ )}
127
+ </TabsList>
128
+
129
+ <TabsContent value="upload">
130
+ <div className="flex items-center gap-[10px]">
131
+ <Button className="mt-1 w-full"
132
+ onClick={handleClick}
133
+ size="sm"
134
+ >
135
+ {t('editor.video.dialog.tab.upload')}
136
+ </Button>
137
+ </div>
138
+
139
+ <input
140
+ accept="video/*"
141
+ multiple
142
+ onChange={handleFile}
143
+ ref={fileInput}
144
+ type="file"
145
+ style={{
146
+ display: 'none',
147
+ }}
148
+ />
149
+ </TabsContent>
150
+
151
+ <TabsContent value="link">
152
+ <form onSubmit={handleLink}>
153
+ <div className="flex items-center gap-2">
154
+ <Input
155
+ autoFocus
156
+ placeholder={t('editor.video.dialog.placeholder')}
157
+ required
158
+ type="url"
159
+ value={link}
160
+ onChange={(e) => {
161
+ const url = e.target.value;
162
+
163
+ const isVideoUrl = checkIsVideo(url);
164
+
165
+ if (!isVideoUrl) {
166
+ setError('Invalid video URL');
167
+ setLink('');
168
+ return;
169
+ }
170
+ setError('');
171
+ setLink(url);
172
+ }}
173
+ />
174
+
175
+ <Button type="submit">
176
+ {t('editor.video.dialog.button.apply')}
177
+ </Button>
178
+ </div>
179
+ </form>
180
+
181
+ {error && <div className="my-[5px] text-red-500">
182
+ {error}
183
+ </div>}
184
+ </TabsContent>
185
+ </Tabs>
186
+ </DialogContent>
187
+ </Dialog>
188
+ );
189
+ }
190
+
191
+ export default ActionVideoButton;
@@ -0,0 +1 @@
1
+ export * from './Video';
@@ -0,0 +1,15 @@
1
+ import { useStoreUploadVideo } from 'reactjs-tiptap-editor-pro/store/store';
2
+ import { dispatchEvent } from 'reactjs-tiptap-editor-pro/utils/customEvents/customEvents';
3
+ import { EVENTS } from 'reactjs-tiptap-editor-pro/utils/customEvents/events.constant';
4
+
5
+ export function useDialogVideo() {
6
+ const [v] = useStoreUploadVideo(store => store.value);
7
+
8
+ return v;
9
+ }
10
+
11
+ export const actionDialogVideo = {
12
+ setOpen: (id: any, value: boolean) => {
13
+ dispatchEvent(EVENTS.UPLOAD_VIDEO(id), value);
14
+ },
15
+ };
@@ -0,0 +1,122 @@
1
+ export { Bold } from './Bold';
2
+ export type { BoldOptions } from './Bold';
3
+
4
+ export { Italic } from './Italic';
5
+ export type { ItalicOptions } from './Italic';
6
+
7
+ export { Underline } from './UnderLine';
8
+ export type { UnderlineOptions } from './UnderLine';
9
+
10
+ export { Strike } from './Strike';
11
+ export type { StrikeOptions } from './Strike';
12
+
13
+ export { Code } from './Code';
14
+ export type { CodeOptions } from './Code';
15
+
16
+ export { CodeBlock } from './CodeBlock';
17
+ export type { CodeBlockOptions } from './CodeBlock';
18
+
19
+ export { FontFamily } from './FontFamily';
20
+
21
+ export { Heading } from './Heading';
22
+ export type { HeadingOptions } from './Heading';
23
+
24
+ export { TextAlign } from './TextAlign';
25
+ export type { TextAlignOptions } from './TextAlign';
26
+
27
+ export { FontSize } from './FontSize';
28
+ export type { FontSizeOptions } from './FontSize';
29
+
30
+ export { Color } from './Color';
31
+ export type { ColorOptions } from './Color';
32
+
33
+ export { Highlight } from './Highlight';
34
+ export type { HighlightOptions } from './Highlight';
35
+
36
+ export { BulletList } from './BulletList';
37
+ export type { BulletListOptions } from './BulletList';
38
+
39
+ export { Clear } from './Clear';
40
+ export type { ClearOptions } from './Clear';
41
+
42
+ export { OrderedList } from './OrderedList';
43
+ export type { OrderedListOptions } from './OrderedList';
44
+
45
+ export { TaskList } from './TaskList';
46
+ export type { TaskListOptions } from './TaskList';
47
+
48
+ export { Blockquote } from './Blockquote';
49
+ export type { BlockquoteOptions } from './Blockquote';
50
+
51
+ export { Link } from './Link';
52
+ export type { LinkOptions } from './Link';
53
+
54
+ export { HorizontalRule } from './HorizontalRule';
55
+ export type { HorizontalRuleOptions } from './HorizontalRule';
56
+
57
+ export { History } from './History';
58
+ export type { HistoryOptions } from './History';
59
+
60
+ export { BaseKit } from './BaseKit';
61
+ export type { BaseKitOptions } from './BaseKit';
62
+
63
+ export { SubAndSuperScript } from './Subscript';
64
+
65
+ export type { SubAndSuperScriptOptions } from './Subscript';
66
+ export type { MoreMarkOptions } from './MoreMark';
67
+ export { MoreMark } from './MoreMark';
68
+
69
+ export { Indent } from './Indent';
70
+ export type { IndentOptions } from './Indent';
71
+
72
+ export { LineHeight } from './LineHeight';
73
+ export type { LineHeightOptions } from './LineHeight';
74
+
75
+ export { SlashCommand } from './SlashCommand';
76
+
77
+ export { Image } from './Image';
78
+ export type { SetImageAttrsOptions } from './Image';
79
+
80
+ export { Video } from './Video/Video';
81
+ export type { VideoOptions } from './Video';
82
+
83
+ export { Table } from './Table';
84
+
85
+ export type { TableOptions } from './Table';
86
+
87
+ export { FormatPainter } from './FormatPainter';
88
+ export type { FormatPainterOptions } from './FormatPainter';
89
+
90
+ export { Column, MultiColumn, ColumnActionButton } from './MultiColumn';
91
+
92
+ export { Iframe } from './Iframe';
93
+
94
+ export { SearchAndReplace } from './SearchAndReplace';
95
+
96
+ export { Emoji } from './Emoji';
97
+
98
+ export { Katex } from './Katex';
99
+
100
+ export { ExportPdf } from './ExportPdf';
101
+
102
+ export { ImportWord } from './ImportWord';
103
+
104
+ export { ExportWord } from './ExportWord';
105
+
106
+ export { TableOfContents } from './TableOfContent';
107
+
108
+ export { Excalidraw } from './Excalidraw';
109
+
110
+ export { TextDirection } from './TextDirection';
111
+
112
+ export { Mention } from './Mention';
113
+
114
+ export { Attachment } from './Attachment';
115
+
116
+ export { ImageGif } from './ImageGif';
117
+
118
+ export { Mermaid } from './Mermaid';
119
+
120
+ export { Twitter } from './Twitter';
121
+
122
+ export { Drawer } from './Drawer';
@@ -0,0 +1,24 @@
1
+ /* eslint-disable prefer-spread */
2
+ import { useEffect, useState } from 'react';
3
+
4
+ import type { Editor } from '@tiptap/core';
5
+
6
+ export function useActive(editor: Editor, ...args: any[]) {
7
+ const [active, toggleActive] = useState(false);
8
+
9
+ useEffect(() => {
10
+ const listener = () => {
11
+ toggleActive(editor.isActive.apply(editor, args as any));
12
+ };
13
+
14
+ editor.on('selectionUpdate', listener);
15
+ editor.on('transaction', listener);
16
+
17
+ return () => {
18
+ editor.off('selectionUpdate', listener);
19
+ editor.off('transaction', listener);
20
+ };
21
+ }, [editor, args, toggleActive]);
22
+
23
+ return active;
24
+ }
@@ -0,0 +1,45 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import { useEffect, useRef, useState } from 'react';
3
+
4
+ import type { Editor } from '@tiptap/core';
5
+ import deepEqual from 'deep-equal';
6
+
7
+ type MapFn<T, R> = (arg: T) => R;
8
+
9
+ function mapSelf<T>(d: T): T {
10
+ return d;
11
+ }
12
+
13
+ export function useAttributes<T, R = T>(editor: Editor, attrbute: string, defaultValue?: T, map?: (arg: T) => R) {
14
+ const mapFn = (map || mapSelf) as MapFn<T, R>;
15
+ const [value, setValue] = useState<R>(mapFn(defaultValue as any));
16
+ const prevValueCache = useRef<R>(value);
17
+
18
+ useEffect(() => {
19
+ const listener = () => {
20
+ const attrs = { ...defaultValue, ...editor.getAttributes(attrbute) } as any;
21
+ Object.keys(attrs).forEach((key) => {
22
+ if (attrs[key] === null || attrs[key] === undefined) {
23
+ // @ts-ignore
24
+ attrs[key] = defaultValue ? defaultValue[key] : null;
25
+ }
26
+ });
27
+ const nextAttrs = mapFn(attrs);
28
+ if (deepEqual(prevValueCache.current, nextAttrs)) {
29
+ return;
30
+ }
31
+ setValue(nextAttrs);
32
+ prevValueCache.current = nextAttrs;
33
+ };
34
+
35
+ editor.on('selectionUpdate', listener);
36
+ editor.on('transaction', listener);
37
+
38
+ return () => {
39
+ editor.off('selectionUpdate', listener);
40
+ editor.off('transaction', listener);
41
+ };
42
+ }, [editor, defaultValue, attrbute, mapFn]);
43
+
44
+ return value;
45
+ }