reactjs-tiptap-editor-pro 0.2.31 → 0.2.33

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 (331) hide show
  1. package/lib/ColorPicker-MEAh4MhG.js +28181 -0
  2. package/lib/ColorPicker-ZncOwjAP.cjs +142 -0
  3. package/lib/extension-bundle.cjs +133 -0
  4. package/lib/extension-bundle.d.cts +947 -0
  5. package/lib/extension-bundle.d.ts +947 -0
  6. package/lib/extension-bundle.js +23921 -0
  7. package/lib/index.cjs +140 -0
  8. package/lib/index.d.cts +513 -0
  9. package/lib/index.d.ts +513 -0
  10. package/lib/index.js +3700 -0
  11. package/lib/locale-bundle-DiqW5jwb.cjs +1 -0
  12. package/lib/locale-bundle-DxCAtRDI.js +1487 -0
  13. package/lib/locale-bundle.cjs +1 -0
  14. package/lib/locale-bundle.d.cts +1140 -0
  15. package/lib/locale-bundle.d.ts +1140 -0
  16. package/lib/locale-bundle.js +9 -0
  17. package/lib/lucide-react-BFZtMawV.js +30462 -0
  18. package/lib/lucide-react-CMPhLW1m.cjs +7851 -0
  19. package/lib/style.css +1 -0
  20. package/package.json +58 -5
  21. package/src/components/ActionButton.tsx +0 -103
  22. package/src/components/ActionMenuButton.tsx +0 -76
  23. package/src/components/BubbleMenu.tsx +0 -93
  24. package/src/components/CharactorCount.tsx +0 -50
  25. package/src/components/ColorPicker.tsx +0 -272
  26. package/src/components/RichTextEditor.tsx +0 -212
  27. package/src/components/SizeSetter/SizeSetter.tsx +0 -102
  28. package/src/components/Toolbar.tsx +0 -108
  29. package/src/components/icons/Activity.tsx +0 -19
  30. package/src/components/icons/Animas.tsx +0 -24
  31. package/src/components/icons/AspectRatio.tsx +0 -13
  32. package/src/components/icons/Blockquote.tsx +0 -17
  33. package/src/components/icons/ColumnAddLeft.tsx +0 -7
  34. package/src/components/icons/ColumnAddRight.tsx +0 -7
  35. package/src/components/icons/DeleteColumn.tsx +0 -26
  36. package/src/components/icons/DeleteRow.tsx +0 -26
  37. package/src/components/icons/Direction.tsx +0 -7
  38. package/src/components/icons/Excalidraw.tsx +0 -7
  39. package/src/components/icons/ExportPdf.tsx +0 -8
  40. package/src/components/icons/ExportWord.tsx +0 -24
  41. package/src/components/icons/FileWordOutline.tsx +0 -13
  42. package/src/components/icons/Flag.tsx +0 -19
  43. package/src/components/icons/Food.tsx +0 -20
  44. package/src/components/icons/GIfIcon.tsx +0 -10
  45. package/src/components/icons/Icon.tsx +0 -30
  46. package/src/components/icons/ImportWord.tsx +0 -23
  47. package/src/components/icons/LeftToRight.tsx +0 -7
  48. package/src/components/icons/LineHeight.tsx +0 -13
  49. package/src/components/icons/MenuDown.tsx +0 -24
  50. package/src/components/icons/Mermaid.tsx +0 -13
  51. package/src/components/icons/NoFill.tsx +0 -7
  52. package/src/components/icons/Object.tsx +0 -24
  53. package/src/components/icons/RightToLeft.tsx +0 -7
  54. package/src/components/icons/SizeL.tsx +0 -9
  55. package/src/components/icons/SizeM.tsx +0 -13
  56. package/src/components/icons/SizeS.tsx +0 -13
  57. package/src/components/icons/Symbol.tsx +0 -19
  58. package/src/components/icons/Travel.tsx +0 -24
  59. package/src/components/icons/Twitter.tsx +0 -7
  60. package/src/components/icons/icons.ts +0 -212
  61. package/src/components/icons/index.ts +0 -12
  62. package/src/components/index.ts +0 -9
  63. package/src/components/menus/bubble.ts +0 -395
  64. package/src/components/menus/components/BubbleMenuContent.tsx +0 -15
  65. package/src/components/menus/components/BubbleMenuDrawer.tsx +0 -128
  66. package/src/components/menus/components/BubbleMenuExcalidraw.tsx +0 -91
  67. package/src/components/menus/components/BubbleMenuIframe.tsx +0 -143
  68. package/src/components/menus/components/BubbleMenuKatex.tsx +0 -136
  69. package/src/components/menus/components/BubbleMenuLink.tsx +0 -99
  70. package/src/components/menus/components/BubbleMenuMedia.tsx +0 -235
  71. package/src/components/menus/components/BubbleMenuMermaid.tsx +0 -128
  72. package/src/components/menus/components/BubbleMenuText.tsx +0 -102
  73. package/src/components/menus/components/BubbleMenuTwitter.tsx +0 -91
  74. package/src/components/menus/components/ColumnsBubbleMenu.tsx +0 -59
  75. package/src/components/menus/components/ContentMenu.tsx +0 -396
  76. package/src/components/menus/components/TableBubbleMenu.tsx +0 -362
  77. package/src/components/menus/index.ts +0 -7
  78. package/src/components/ui/button.tsx +0 -56
  79. package/src/components/ui/checkbox.tsx +0 -30
  80. package/src/components/ui/dialog.tsx +0 -128
  81. package/src/components/ui/dropdown-menu.tsx +0 -203
  82. package/src/components/ui/emoji-picker.tsx +0 -166
  83. package/src/components/ui/index.ts +0 -14
  84. package/src/components/ui/input.tsx +0 -25
  85. package/src/components/ui/label.tsx +0 -26
  86. package/src/components/ui/popover.tsx +0 -31
  87. package/src/components/ui/select.tsx +0 -162
  88. package/src/components/ui/separator.tsx +0 -31
  89. package/src/components/ui/switch.tsx +0 -29
  90. package/src/components/ui/tabs.tsx +0 -55
  91. package/src/components/ui/textarea.tsx +0 -24
  92. package/src/components/ui/toast.tsx +0 -129
  93. package/src/components/ui/toaster.tsx +0 -44
  94. package/src/components/ui/toggle.tsx +0 -45
  95. package/src/components/ui/tooltip.tsx +0 -30
  96. package/src/components/ui/use-toast.ts +0 -197
  97. package/src/constants/index.ts +0 -223
  98. package/src/constants/resetCSS.ts +0 -139
  99. package/src/extension-bundle.ts +0 -2
  100. package/src/extensions/Attachment/Attachment.ts +0 -144
  101. package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +0 -69
  102. package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +0 -28
  103. package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +0 -155
  104. package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +0 -23
  105. package/src/extensions/Attachment/index.ts +0 -1
  106. package/src/extensions/BaseKit.ts +0 -253
  107. package/src/extensions/Blockquote/Blockquote.ts +0 -31
  108. package/src/extensions/Blockquote/index.ts +0 -1
  109. package/src/extensions/Bold/Bold.ts +0 -26
  110. package/src/extensions/Bold/index.ts +0 -1
  111. package/src/extensions/BulletList/BulletList.ts +0 -28
  112. package/src/extensions/BulletList/index.ts +0 -1
  113. package/src/extensions/Clear/Clear.ts +0 -24
  114. package/src/extensions/Clear/index.ts +0 -1
  115. package/src/extensions/Code/Code.ts +0 -26
  116. package/src/extensions/Code/index.ts +0 -1
  117. package/src/extensions/CodeBlock/CodeBlock.ts +0 -54
  118. package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +0 -66
  119. package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +0 -89
  120. package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +0 -81
  121. package/src/extensions/CodeBlock/highlighter.ts +0 -132
  122. package/src/extensions/CodeBlock/index.ts +0 -1
  123. package/src/extensions/CodeBlock/shiki-plugin.ts +0 -213
  124. package/src/extensions/Color/Color.ts +0 -52
  125. package/src/extensions/Color/components/ColorActionButton.tsx +0 -104
  126. package/src/extensions/Color/index.ts +0 -1
  127. package/src/extensions/Document/Document.ts +0 -8
  128. package/src/extensions/Document/index.ts +0 -1
  129. package/src/extensions/Drawer/Drawer.ts +0 -177
  130. package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +0 -85
  131. package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +0 -598
  132. package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +0 -500
  133. package/src/extensions/Drawer/components/DrawerActiveButton.tsx +0 -239
  134. package/src/extensions/Drawer/components/EditDrawerBlock.tsx +0 -238
  135. package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +0 -260
  136. package/src/extensions/Drawer/index.ts +0 -1
  137. package/src/extensions/Emoji/Emoji.ts +0 -146
  138. package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +0 -103
  139. package/src/extensions/Emoji/components/EmojiList/emojis.ts +0 -1858
  140. package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +0 -61
  141. package/src/extensions/Emoji/index.ts +0 -1
  142. package/src/extensions/Excalidraw/Excalidraw.ts +0 -123
  143. package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +0 -138
  144. package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +0 -178
  145. package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +0 -43
  146. package/src/extensions/Excalidraw/index.ts +0 -1
  147. package/src/extensions/ExportPdf/ExportPdf.ts +0 -25
  148. package/src/extensions/ExportPdf/index.ts +0 -1
  149. package/src/extensions/ExportWord/ExportWord.ts +0 -87
  150. package/src/extensions/ExportWord/index.ts +0 -1
  151. package/src/extensions/FontFamily/FontFamily.ts +0 -64
  152. package/src/extensions/FontFamily/components/FontFamilyButton.tsx +0 -97
  153. package/src/extensions/FontFamily/index.ts +0 -1
  154. package/src/extensions/FontSize/FontSize.ts +0 -119
  155. package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +0 -84
  156. package/src/extensions/FontSize/index.ts +0 -1
  157. package/src/extensions/FormatPainter/FormatPainter.ts +0 -121
  158. package/src/extensions/FormatPainter/index.ts +0 -1
  159. package/src/extensions/Heading/Heading.ts +0 -57
  160. package/src/extensions/Heading/components/HeadingButton.tsx +0 -96
  161. package/src/extensions/Heading/index.ts +0 -1
  162. package/src/extensions/Highlight/Highlight.ts +0 -36
  163. package/src/extensions/Highlight/components/HighlightActionButton.tsx +0 -108
  164. package/src/extensions/Highlight/index.ts +0 -1
  165. package/src/extensions/History/History.ts +0 -39
  166. package/src/extensions/History/components/HistoryActionButton.tsx +0 -74
  167. package/src/extensions/History/index.ts +0 -1
  168. package/src/extensions/HorizontalRule/HorizontalRule.ts +0 -42
  169. package/src/extensions/HorizontalRule/index.ts +0 -1
  170. package/src/extensions/Iframe/Iframe.ts +0 -140
  171. package/src/extensions/Iframe/components/IframeNodeView.tsx +0 -92
  172. package/src/extensions/Iframe/components/index.module.scss +0 -40
  173. package/src/extensions/Iframe/embed.ts +0 -487
  174. package/src/extensions/Iframe/index.ts +0 -1
  175. package/src/extensions/Image/Image.ts +0 -303
  176. package/src/extensions/Image/components/ActionImageButton.tsx +0 -186
  177. package/src/extensions/Image/components/ImageCropper.tsx +0 -198
  178. package/src/extensions/Image/components/ImageView.tsx +0 -271
  179. package/src/extensions/Image/index.ts +0 -1
  180. package/src/extensions/Image/store.ts +0 -15
  181. package/src/extensions/ImageGif/ImageGif.ts +0 -176
  182. package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +0 -138
  183. package/src/extensions/ImageGif/components/ImageGifView.tsx +0 -260
  184. package/src/extensions/ImageGif/index.ts +0 -1
  185. package/src/extensions/ImportWord/ImportWord.ts +0 -52
  186. package/src/extensions/ImportWord/components/ImportWordButton.tsx +0 -151
  187. package/src/extensions/ImportWord/index.ts +0 -1
  188. package/src/extensions/Indent/Indent.ts +0 -110
  189. package/src/extensions/Indent/index.ts +0 -1
  190. package/src/extensions/Italic/Italic.ts +0 -29
  191. package/src/extensions/Italic/index.ts +0 -1
  192. package/src/extensions/Katex/Katex.ts +0 -109
  193. package/src/extensions/Katex/components/KatexActiveButton.tsx +0 -117
  194. package/src/extensions/Katex/components/KatexWrapper.tsx +0 -53
  195. package/src/extensions/Katex/index.ts +0 -1
  196. package/src/extensions/LineHeight/LineHeight.ts +0 -76
  197. package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +0 -93
  198. package/src/extensions/LineHeight/index.ts +0 -1
  199. package/src/extensions/Link/Link.ts +0 -92
  200. package/src/extensions/Link/components/LinkEditBlock.tsx +0 -110
  201. package/src/extensions/Link/components/LinkEditPopover.tsx +0 -46
  202. package/src/extensions/Link/components/LinkViewBlock.tsx +0 -54
  203. package/src/extensions/Link/index.ts +0 -1
  204. package/src/extensions/ListItem/ListItem.ts +0 -1
  205. package/src/extensions/ListItem/index.ts +0 -1
  206. package/src/extensions/Mention/Mention.ts +0 -100
  207. package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +0 -94
  208. package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +0 -38
  209. package/src/extensions/Mention/index.ts +0 -1
  210. package/src/extensions/Mermaid/Mermaid.ts +0 -177
  211. package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +0 -155
  212. package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +0 -151
  213. package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +0 -260
  214. package/src/extensions/Mermaid/index.ts +0 -1
  215. package/src/extensions/MoreMark/MoreMark.ts +0 -102
  216. package/src/extensions/MoreMark/components/ActionMoreButton.tsx +0 -97
  217. package/src/extensions/MoreMark/index.ts +0 -1
  218. package/src/extensions/MultiColumn/Column.ts +0 -36
  219. package/src/extensions/MultiColumn/MultiColumn.ts +0 -111
  220. package/src/extensions/MultiColumn/components/ColumnActionButton.ts +0 -22
  221. package/src/extensions/MultiColumn/index.ts +0 -3
  222. package/src/extensions/OrderedList/OrderedList.ts +0 -28
  223. package/src/extensions/OrderedList/index.ts +0 -1
  224. package/src/extensions/SearchAndReplace/SearchAndReplace.ts +0 -395
  225. package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +0 -190
  226. package/src/extensions/SearchAndReplace/index.ts +0 -1
  227. package/src/extensions/Selection/Selection.ts +0 -32
  228. package/src/extensions/Selection/index.ts +0 -1
  229. package/src/extensions/SlashCommand/SlashCommand.ts +0 -255
  230. package/src/extensions/SlashCommand/components/CommandsList.tsx +0 -180
  231. package/src/extensions/SlashCommand/groups.ts +0 -183
  232. package/src/extensions/SlashCommand/index.ts +0 -1
  233. package/src/extensions/SlashCommand/types.ts +0 -24
  234. package/src/extensions/Strike/Strike.ts +0 -26
  235. package/src/extensions/Strike/index.ts +0 -1
  236. package/src/extensions/Subscript/Subscript.ts +0 -88
  237. package/src/extensions/Subscript/index.ts +0 -1
  238. package/src/extensions/Table/Cell.ts +0 -131
  239. package/src/extensions/Table/Header.ts +0 -93
  240. package/src/extensions/Table/Row.ts +0 -8
  241. package/src/extensions/Table/Table.ts +0 -60
  242. package/src/extensions/Table/cell-background.ts +0 -112
  243. package/src/extensions/Table/components/CreateTablePopover.tsx +0 -132
  244. package/src/extensions/Table/components/TableActionButton.tsx +0 -42
  245. package/src/extensions/Table/index.ts +0 -6
  246. package/src/extensions/Table/utils.ts +0 -352
  247. package/src/extensions/TableOfContent/TableOfContent.ts +0 -124
  248. package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +0 -116
  249. package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +0 -27
  250. package/src/extensions/TableOfContent/components/index.module.scss +0 -40
  251. package/src/extensions/TableOfContent/index.ts +0 -1
  252. package/src/extensions/TaskList/TaskList.ts +0 -46
  253. package/src/extensions/TaskList/index.ts +0 -1
  254. package/src/extensions/TextAlign/TextAlign.ts +0 -68
  255. package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +0 -103
  256. package/src/extensions/TextAlign/index.ts +0 -1
  257. package/src/extensions/TextBubble/TextBubble.ts +0 -22
  258. package/src/extensions/TextBubble/components/TextDropdown.tsx +0 -146
  259. package/src/extensions/TextBubble/index.ts +0 -1
  260. package/src/extensions/TextDirection/TextDirection.ts +0 -97
  261. package/src/extensions/TextDirection/components/TextDirectionButton.tsx +0 -103
  262. package/src/extensions/TextDirection/index.ts +0 -1
  263. package/src/extensions/TrailingNode/TrailingNode.ts +0 -71
  264. package/src/extensions/TrailingNode/index.ts +0 -1
  265. package/src/extensions/Twitter/Twitter.ts +0 -161
  266. package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +0 -68
  267. package/src/extensions/Twitter/components/NodeViewTweet.tsx +0 -30
  268. package/src/extensions/Twitter/components/TwitterActiveButton.tsx +0 -41
  269. package/src/extensions/Twitter/index.ts +0 -1
  270. package/src/extensions/UnderLine/Underline.ts +0 -30
  271. package/src/extensions/UnderLine/index.ts +0 -1
  272. package/src/extensions/Video/Video.ts +0 -204
  273. package/src/extensions/Video/components/ActiveVideoButton.tsx +0 -191
  274. package/src/extensions/Video/index.ts +0 -1
  275. package/src/extensions/Video/store.ts +0 -15
  276. package/src/extensions/index.ts +0 -122
  277. package/src/hooks/useActive.tsx +0 -24
  278. package/src/hooks/useAttributes.tsx +0 -45
  279. package/src/hooks/useCopy.tsx +0 -20
  280. package/src/hooks/useEditorState.tsx +0 -23
  281. package/src/hooks/useExtension.tsx +0 -29
  282. package/src/index.ts +0 -8
  283. package/src/lib/utils.ts +0 -7
  284. package/src/locale-bundle.ts +0 -3
  285. package/src/locales/en.ts +0 -173
  286. package/src/locales/hu.ts +0 -173
  287. package/src/locales/index.tsx +0 -163
  288. package/src/locales/pt-br.ts +0 -173
  289. package/src/locales/vi.ts +0 -173
  290. package/src/locales/zh-cn.ts +0 -173
  291. package/src/plugins/DragHandle/index.ts +0 -375
  292. package/src/plugins/DragHandle/range.ts +0 -114
  293. package/src/plugins/DragHandle/utils.ts +0 -80
  294. package/src/plugins/image-upload.ts +0 -160
  295. package/src/store/ProviderRichText.tsx +0 -53
  296. package/src/store/editableEditor.ts +0 -15
  297. package/src/store/fast-context.tsx +0 -70
  298. package/src/store/store.ts +0 -35
  299. package/src/styles/ProseMirror.scss +0 -176
  300. package/src/styles/columns.scss +0 -23
  301. package/src/styles/editor.scss +0 -411
  302. package/src/styles/global.scss +0 -87
  303. package/src/styles/index.scss +0 -5
  304. package/src/styles/mention.scss +0 -6
  305. package/src/theme/theme.ts +0 -15
  306. package/src/types.ts +0 -271
  307. package/src/utils/_event.ts +0 -55
  308. package/src/utils/color.ts +0 -67
  309. package/src/utils/columns.ts +0 -142
  310. package/src/utils/customEvents/customEvents.ts +0 -18
  311. package/src/utils/customEvents/events.constant.ts +0 -11
  312. package/src/utils/delete-node.ts +0 -46
  313. package/src/utils/dom-dataset.ts +0 -121
  314. package/src/utils/download.ts +0 -17
  315. package/src/utils/dynamicCSS.ts +0 -192
  316. package/src/utils/editor-container-size.ts +0 -28
  317. package/src/utils/file.ts +0 -112
  318. package/src/utils/getRenderContainer.ts +0 -41
  319. package/src/utils/indent.ts +0 -99
  320. package/src/utils/is-mobile.ts +0 -57
  321. package/src/utils/json.ts +0 -18
  322. package/src/utils/line-height.ts +0 -109
  323. package/src/utils/lru-cache.ts +0 -145
  324. package/src/utils/mitt.ts +0 -114
  325. package/src/utils/node.ts +0 -92
  326. package/src/utils/pdf.ts +0 -72
  327. package/src/utils/plateform.ts +0 -49
  328. package/src/utils/shortId.ts +0 -5
  329. package/src/utils/storage.ts +0 -18
  330. package/src/utils/utils.ts +0 -71
  331. package/src/vite-env.d.ts +0 -3
@@ -1,109 +0,0 @@
1
- import type { Command } from '@tiptap/core';
2
- import type { NodeType, Node as ProsemirrorNode } from '@tiptap/pm/model';
3
- import type { EditorState, Transaction } from '@tiptap/pm/state';
4
- import { AllSelection, TextSelection } from '@tiptap/pm/state';
5
-
6
- import { DEFAULT_LINE_HEIGHT } from 'reactjs-tiptap-editor-pro/constants';
7
-
8
- export const ALLOWED_NODE_TYPES = ['paragraph', 'heading', 'list_item', 'todo_item'];
9
-
10
- export function isLineHeightActive(state: EditorState, lineHeight: string): boolean {
11
- const { selection, doc } = state;
12
- const { from, to } = selection;
13
-
14
- let keepLooking = true;
15
- let active = false;
16
-
17
- doc.nodesBetween(from, to, (node) => {
18
- const nodeType = node.type;
19
- const lineHeightValue = node.attrs.lineHeight || DEFAULT_LINE_HEIGHT;
20
-
21
- if (ALLOWED_NODE_TYPES.includes(nodeType.name)) {
22
- if (keepLooking && lineHeight === lineHeightValue) {
23
- keepLooking = false;
24
- active = true;
25
-
26
- return false;
27
- }
28
- return nodeType.name !== 'list_item' && nodeType.name !== 'todo_item';
29
- }
30
- return keepLooking;
31
- });
32
-
33
- return active;
34
- }
35
-
36
- interface SetLineHeightTask {
37
- node: ProsemirrorNode
38
- nodeType: NodeType
39
- pos: number
40
- }
41
-
42
- export function setTextLineHeight(tr: Transaction, lineHeight: string | null): Transaction {
43
- const { selection, doc } = tr;
44
-
45
- if (!selection || !doc) {
46
- return tr;
47
- }
48
-
49
- if (!(selection instanceof TextSelection || selection instanceof AllSelection)) {
50
- return tr;
51
- }
52
-
53
- const { from, to } = selection;
54
-
55
- const tasks: Array<SetLineHeightTask> = [];
56
- const lineHeightValue = lineHeight && lineHeight !== DEFAULT_LINE_HEIGHT ? lineHeight : null;
57
-
58
- doc.nodesBetween(from, to, (node, pos) => {
59
- const nodeType = node.type;
60
- if (ALLOWED_NODE_TYPES.includes(nodeType.name)) {
61
- const lineHeight = node.attrs.lineHeight || null;
62
- if (lineHeight !== lineHeightValue) {
63
- tasks.push({
64
- node,
65
- pos,
66
- nodeType,
67
- });
68
- }
69
- return nodeType.name !== 'list_item' && nodeType.name !== 'todo_item';
70
- }
71
- return true;
72
- });
73
-
74
- if (tasks.length === 0) {
75
- return tr;
76
- }
77
-
78
- for (const task of tasks) {
79
- const { node, pos, nodeType } = task;
80
- let { attrs } = node;
81
-
82
- attrs = {
83
- ...attrs,
84
- lineHeight: lineHeightValue,
85
- };
86
-
87
- tr = tr.setNodeMarkup(pos, nodeType, attrs, node.marks);
88
- }
89
-
90
- return tr;
91
- }
92
-
93
- export function createLineHeightCommand(lineHeight: string): Command {
94
- return ({ state, dispatch }) => {
95
- const { selection } = state;
96
- let { tr } = state;
97
- tr = tr.setSelection(selection);
98
-
99
- tr = setTextLineHeight(tr, lineHeight);
100
-
101
- if (tr.docChanged) {
102
- if (dispatch)
103
- dispatch(tr);
104
- return true;
105
- }
106
-
107
- return false;
108
- };
109
- }
@@ -1,145 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
- import { safeJSONStringify } from './json';
3
- import { getStorage, setStorage } from './storage';
4
-
5
- class Node {
6
- public key: string;
7
- public value: string | number;
8
- public prev: Node | null;
9
- public next: Node | null;
10
-
11
- constructor(key: any, value: any) {
12
- this.key = key;
13
- this.value = value;
14
- this.prev = null;
15
- this.next = null;
16
- }
17
- }
18
-
19
- export class LRUCache {
20
- private capacity: number;
21
- private usedCapacity: number;
22
- private head: Node;
23
- private tail: Node;
24
- private store: Record<string, Node>;
25
-
26
- constructor(capacity: any) {
27
- this.capacity = capacity || 20;
28
- this.usedCapacity = 0;
29
- this.store = {};
30
- this.head = new Node('fakeHeadNode', 'fakeHeadNode');
31
- this.tail = new Node('fakeTailNode', 'fakeTailNode');
32
-
33
- this.head.next = this.tail;
34
- this.tail.prev = this.head;
35
- }
36
-
37
- private removeNode(node: any) {
38
- node.prev.next = node.next;
39
- node.next.prev = node.prev;
40
- }
41
-
42
- private addToHead(node: any) {
43
- node.prev = this.head;
44
- node.next = this.head.next;
45
- // @ts-expect-error
46
- this.head.next.prev = node;
47
- this.head.next = node;
48
- }
49
-
50
- private moveToHead(node: any) {
51
- this.removeNode(node);
52
- this.addToHead(node);
53
- }
54
-
55
- private removeTail() {
56
- const node = this.tail.prev;
57
- this.removeNode(node);
58
- return node;
59
- }
60
-
61
- get(key: any) {
62
- if (key in this.store) {
63
- const node = this.store[key];
64
- this.moveToHead(node);
65
- return node.value;
66
- }
67
-
68
- return -1;
69
- }
70
-
71
- put(key: any, value: any) {
72
- if (key in this.store) {
73
- const node = this.store[key];
74
- node.value = value;
75
- this.moveToHead(node);
76
- } else {
77
- const node = new Node(key, value);
78
- this.addToHead(node);
79
- this.store[key] = node;
80
- this.usedCapacity += 1;
81
-
82
- if (this.usedCapacity > this.capacity) {
83
- const tailNode = this.removeTail() as any;
84
- delete this.store[tailNode.key];
85
- this.usedCapacity -= 1;
86
- }
87
- }
88
- }
89
-
90
- keys() {
91
- const res = [];
92
- let node = this.head as any;
93
-
94
- while (node) {
95
- res.push(node.key);
96
- node = node.next;
97
- }
98
-
99
- return res.slice(1, -1);
100
- }
101
-
102
- values() {
103
- const res = [];
104
- let node = this.head as any;
105
-
106
- while (node) {
107
- res.push(node.value);
108
- node = node.next;
109
- }
110
-
111
- return res.slice(1, -1);
112
- }
113
-
114
- toJSON() {
115
- return this.store;
116
- }
117
- }
118
-
119
- export function createKeysLocalStorageLRUCache(storageKey: any, capacity: any) {
120
- const lruCache = new LRUCache(capacity);
121
-
122
- const manager = {
123
- syncFromStorage() {
124
- const data = getStorage(storageKey) || [];
125
- data
126
- .slice()
127
- .reverse()
128
- .forEach((key: any) => {
129
- lruCache.put(key, key);
130
- });
131
- },
132
- syncToStorage() {
133
- setStorage(storageKey, safeJSONStringify(lruCache.keys()));
134
- },
135
- put(key: any) {
136
- lruCache.put(key, key);
137
- this.syncToStorage();
138
- },
139
- get(key?: string) {
140
- return key ? lruCache.get(key) : lruCache.keys();
141
- },
142
- };
143
-
144
- return manager;
145
- }
package/src/utils/mitt.ts DELETED
@@ -1,114 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
- /**
3
- * copy to https://github.com/developit/mitt
4
- */
5
-
6
- export type EventType = string | symbol;
7
-
8
- // An event handler can take an optional event argument
9
- // and should not return a value
10
- export type Handler<T = unknown> = (event: T) => void;
11
- export type WildcardHandler<T = Record<string, unknown>> = (
12
- type: keyof T,
13
- event: T[keyof T],
14
- ) => void;
15
-
16
- // An array of all currently registered event handlers for a type
17
- export type EventHandlerList<T = unknown> = Array<Handler<T>>;
18
- export type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
19
-
20
- // A map of event types and their corresponding event handlers.
21
- export type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<
22
- keyof Events | '*',
23
- EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>
24
- >;
25
-
26
- export interface Emitter<Events extends Record<EventType, unknown>> {
27
- all: EventHandlerMap<Events>
28
-
29
- on: (<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>) => void) & ((type: '*', handler: WildcardHandler<Events>) => void)
30
-
31
- off: (<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>) => void) & ((type: '*', handler: WildcardHandler<Events>) => void)
32
-
33
- emit: (<Key extends keyof Events>(type: Key, event: Events[Key]) => void) & (<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never) => void)
34
- }
35
-
36
- /**
37
- * Mitt: Tiny (~200b) functional event emitter / pubsub.
38
- * @name mitt
39
- * @returns {Mitt}
40
- */
41
- export default function mitt<Events extends Record<EventType, unknown>>(
42
- all?: EventHandlerMap<Events>,
43
- ): Emitter<Events> {
44
- type GenericEventHandler = Handler<Events[keyof Events]> | WildcardHandler<Events>;
45
- all = all || new Map();
46
-
47
- return {
48
- /**
49
- * A Map of event names to registered handler functions.
50
- */
51
- all,
52
-
53
- /**
54
- * Register an event handler for the given type.
55
- * @param {string|symbol} type Type of event to listen for, or `'*'` for all events
56
- * @param {Function} handler Function to call in response to given event
57
- * @memberOf mitt
58
- */
59
- //@ts-expect-error
60
- on<Key extends keyof Events>(type: Key, handler: GenericEventHandler) {
61
- const handlers: Array<GenericEventHandler> | undefined = all.get(type);
62
- if (handlers) {
63
- handlers.push(handler);
64
- } else {
65
- all.set(type, [handler] as EventHandlerList<Events[keyof Events]>);
66
- }
67
- },
68
-
69
- /**
70
- * Remove an event handler for the given type.
71
- * If `handler` is omitted, all handlers of the given type are removed.
72
- * @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
73
- * @param {Function} [handler] Handler function to remove
74
- * @memberOf mitt
75
- */
76
- //@ts-expect-error
77
- off<Key extends keyof Events>(type: Key, handler?: GenericEventHandler) {
78
- const handlers: Array<GenericEventHandler> | undefined = all.get(type);
79
- if (handlers) {
80
- if (handler) {
81
- handlers.splice(handlers.indexOf(handler) >>> 0, 1);
82
- } else {
83
- all.set(type, []);
84
- }
85
- }
86
- },
87
-
88
- /**
89
- * Invoke all handlers for the given type.
90
- * If present, `'*'` handlers are invoked after type-matched handlers.
91
- *
92
- * Note: Manually firing '*' handlers is not supported.
93
- *
94
- * @param {string|symbol} type The event type to invoke
95
- * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
96
- * @memberOf mitt
97
- */
98
- emit<Key extends keyof Events>(type: Key, evt?: Events[Key]) {
99
- let handlers = all.get(type);
100
- if (handlers) {
101
- [...(handlers as EventHandlerList<Events[keyof Events]>)].map((handler) => {
102
- handler(evt!);
103
- });
104
- }
105
-
106
- handlers = all.get('*');
107
- if (handlers) {
108
- [...(handlers as WildCardEventHandlerList<Events>)].map((handler) => {
109
- handler(type, evt!);
110
- });
111
- }
112
- },
113
- };
114
- }
package/src/utils/node.ts DELETED
@@ -1,92 +0,0 @@
1
- import type { Editor } from '@tiptap/core';
2
- import type { Node } from '@tiptap/pm/model';
3
- import type { EditorState } from '@tiptap/pm/state';
4
-
5
- export function isTitleNode(node: Node): boolean {
6
- return node && node.type.name === 'title';
7
- }
8
-
9
- export function isBulletListNode(node: Node): boolean {
10
- return node && node.type.name === 'bulletList';
11
- }
12
-
13
- export function isOrderedListNode(node: Node): boolean {
14
- return node && node.type.name === 'orderedList';
15
- }
16
-
17
- export function isTodoListNode(node: Node): boolean {
18
- return node && node.type.name === 'taskList';
19
- }
20
-
21
- export function isListNode(node: Node): boolean {
22
- return isBulletListNode(node) || isOrderedListNode(node) || isTodoListNode(node);
23
- }
24
-
25
- export function getCurrentNode(state: EditorState): any {
26
- const $head = state.selection.$head;
27
- let node = null;
28
-
29
- for (let d = $head.depth; d > 0; d--) {
30
- node = $head.node(d);
31
- }
32
-
33
- return node;
34
- }
35
-
36
- export function getNodeAtPos(state: EditorState, pos: number): any {
37
- const $head = state.doc.resolve(pos);
38
- let node = null;
39
-
40
- for (let d = $head.depth; d > 0; d--) {
41
- node = $head.node(d);
42
- }
43
-
44
- return node;
45
- }
46
-
47
- export function isInCustomNode(state: EditorState, nodeName: string): boolean {
48
- if (!state.schema.nodes[nodeName])
49
- return false;
50
-
51
- const $head = state.selection.$head;
52
- for (let d = $head.depth; d > 0; d--) {
53
- if ($head.node(d).type === state.schema.nodes[nodeName]) {
54
- return true;
55
- }
56
- }
57
- return false;
58
- }
59
-
60
- export function isInCodeBlock(state: EditorState): boolean {
61
- return isInCustomNode(state, 'codeBlock');
62
- }
63
-
64
- export function isInTitle(state: EditorState): boolean {
65
- if (state?.selection?.$head?.pos === 0)
66
- return true;
67
- return isInCustomNode(state, 'title');
68
- }
69
-
70
- export function isInCallout(state: EditorState): boolean {
71
- return isInCustomNode(state, 'callout');
72
- }
73
-
74
- export function findNode(editor: Editor, name: string) {
75
- const content = editor.getJSON();
76
- const queue = [content];
77
- const res = [];
78
-
79
- while (queue.length > 0) {
80
- const node = queue.shift() as any;
81
-
82
- if (node.type === name) {
83
- res.push(node);
84
- }
85
-
86
- if (node.content && node.content.length > 0) {
87
- queue.push(...node.content);
88
- }
89
- }
90
-
91
- return res;
92
- }
package/src/utils/pdf.ts DELETED
@@ -1,72 +0,0 @@
1
- import type { Editor } from '@tiptap/core';
2
-
3
- function printHtml(content: string) {
4
- const iframe: HTMLIFrameElement = document.createElement('iframe');
5
- iframe.setAttribute('style', 'position: absolute; width: 0; height: 0; top: 0; left: 0;');
6
- document.body.appendChild(iframe);
7
-
8
- iframe.textContent = `
9
- <!DOCTYPE html>
10
- <html lang="en">
11
- <head>
12
- <title>Echo Editor</title>
13
- <meta charset="UTF-8">
14
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
15
- </head>
16
- <body class="is-print">
17
- <div class="tiptap ProseMirror" translate="no" aria-expanded="false">
18
- ${content}
19
- </div>
20
- </body>
21
- </html>
22
- `;
23
-
24
- const frameWindow = iframe.contentWindow;
25
- const doc: any = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document);
26
-
27
- // load style from CDN to iframe
28
- const link = document.createElement('link');
29
- link.rel = 'stylesheet';
30
- link.href = 'https://cdn.jsdelivr.net/npm/reactjs-tiptap-editor@latest/lib/style.css';
31
- doc.head.appendChild(link);
32
-
33
- if (doc) {
34
- doc.open();
35
- doc.write(content);
36
- doc.close();
37
- }
38
-
39
- if (frameWindow) {
40
- iframe.addEventListener('load', function () {
41
- try {
42
- setTimeout(() => {
43
- frameWindow.focus();
44
- try {
45
- if (!frameWindow.document.execCommand('print', false)) {
46
- frameWindow.print();
47
- }
48
- } catch {
49
- frameWindow.print();
50
- }
51
- frameWindow.close();
52
- }, 10);
53
- } catch (err) {
54
- console.error(err);
55
- }
56
-
57
- setTimeout(() => {
58
- document.body.removeChild(iframe);
59
- }, 100);
60
- });
61
- }
62
- }
63
-
64
- export function printEditorContent(editor: Editor) {
65
- const content = editor.getHTML();
66
-
67
- if (content) {
68
- printHtml(content);
69
- return true;
70
- }
71
- return false;
72
- }
@@ -1,49 +0,0 @@
1
- // We'll cache the result of isMac() and isTouchDevice(), since they shouldn't
2
- // change during a session. That way repeated calls don't require any logic and
3
- // are rapid.
4
- let isMacResult: boolean | undefined;
5
- let isTouchDeviceResult: boolean | undefined;
6
-
7
- /**
8
- * Return true if the user is using a Mac (as opposed to Windows, etc.) device.
9
- */
10
- export function isMac(): boolean {
11
- if (isMacResult === undefined) {
12
- isMacResult = navigator.platform.includes('Mac');
13
- }
14
- return isMacResult;
15
- }
16
-
17
- /**
18
- * 根据 Mac 和非 Mac 平台,返回应该用于键盘快捷键的修饰键的可读版本。用于直观地指示应该按哪个键。
19
- */
20
- export function getShortcutKey(key: string): string {
21
- if (`${key}`.toLowerCase() === 'mod') {
22
- return isMac() ? '⌘' : 'Ctrl';
23
- } else if (`${key}`.toLowerCase() === 'alt') {
24
- return isMac() ? '⌥' : 'Alt';
25
- } else if (`${key}`.toLowerCase() === 'shift') {
26
- return isMac() ? '⇧' : 'Shift';
27
- } else {
28
- return key;
29
- }
30
- }
31
- export function getShortcutKeys(keys: string[]): string {
32
- return keys.map(getShortcutKey).join(' ');
33
- }
34
-
35
- /** Return true if the user is using a touch-based device. */
36
- export function isTouchDevice(): boolean {
37
- if (isTouchDeviceResult === undefined) {
38
- // This technique is taken from
39
- // https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/
40
- // (and https://stackoverflow.com/a/4819886/4543977)
41
- isTouchDeviceResult
42
- = (window && 'ontouchstart' in window)
43
- || navigator.maxTouchPoints > 0
44
- // @ts-expect-error: msMaxTouchPoints is IE-specific, so needs to be ignored
45
- || navigator.msMaxTouchPoints > 0;
46
- }
47
-
48
- return isTouchDeviceResult;
49
- }
@@ -1,5 +0,0 @@
1
- export function shortId(length = 8) {
2
- return Math.random()
3
- .toString(36)
4
- .substring(2, length + 2);
5
- }
@@ -1,18 +0,0 @@
1
- export function getStorage(key: any, defaultValue = null) {
2
- if (typeof window === 'undefined')
3
- // eslint-disable-next-line unicorn/error-message
4
- throw new Error();
5
-
6
- const value = localStorage.getItem(key);
7
- if (!value)
8
- return defaultValue;
9
- try {
10
- return JSON.parse(value);
11
- } catch {
12
- return value;
13
- }
14
- }
15
-
16
- export function setStorage(key: any, value: any) {
17
- window.localStorage.setItem(key, `${value}`);
18
- }
@@ -1,71 +0,0 @@
1
- import type { Editor } from '@tiptap/core';
2
-
3
- import type { NameValueOption } from 'reactjs-tiptap-editor-pro/types';
4
-
5
- export function clamp(val: number, min: number, max: number) {
6
- if (val < min) {
7
- return min;
8
- }
9
- if (val > max) {
10
- return max;
11
- }
12
- return val;
13
- }
14
-
15
- export const isNumber = (value: unknown): value is number => typeof value === 'number';
16
-
17
- export const isString = (value: unknown): value is string => typeof value === 'string';
18
-
19
- export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';
20
-
21
- export const isFunction = (value: unknown): boolean => typeof value === 'function';
22
-
23
- export function getCssUnitWithDefault(value?: string | number, defaultUnit = 'px') {
24
- if (!value)
25
- return value;
26
-
27
- const stringValue = isNumber(value) ? String(value) : value;
28
-
29
- const num = Number.parseFloat(stringValue);
30
- const unitMatch = stringValue.match(/[%a-z]+$/i);
31
- const unit = unitMatch ? unitMatch[0] : defaultUnit;
32
-
33
- return Number.isNaN(num) ? value : num + unit;
34
- }
35
-
36
- /**
37
- * Checks if the editor has a specific extension method with the given name.
38
- *
39
- * @param {Editor} editor - An instance of the editor.
40
- * @param {string} name - The name of the extension method.
41
- * @returns {boolean} - Returns true if the specified extension method is present, otherwise returns false.
42
- */
43
- export function hasExtension(editor: Editor, name: string): boolean {
44
- if (!editor) {
45
- return false;
46
- }
47
-
48
- // Retrieve the extension manager of the editor, defaulting to an empty array if it doesn't exist
49
- const { extensions = [] } = editor?.extensionManager ?? {};
50
-
51
- // Check if the extension method with the specified name is present in the extension manager
52
- const find = extensions.find(i => i.name === name);
53
-
54
- // Return false if the extension method with the specified name is not found, otherwise return true
55
- if (!find) {
56
- return false;
57
- }
58
- return true;
59
- }
60
-
61
- /**
62
- * Normalizes an array of strings or objects to an array of objects with 'value' and 'name' properties.
63
- */
64
- export function ensureNameValueOptions(arr: (string | NameValueOption)[]) {
65
- return arr.map((item) => {
66
- if (isString(item)) {
67
- return { value: item, name: item };
68
- }
69
- return item;
70
- });
71
- }
package/src/vite-env.d.ts DELETED
@@ -1,3 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- declare const process;