reactjs-tiptap-editor-pro 0.2.30 → 0.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/lib/RichTextEditor-BwbqJLnA.cjs +141 -0
  2. package/lib/RichTextEditor-iGJ6-rbq.js +8833 -0
  3. package/lib/extension-bundle.cjs +33 -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 +5755 -0
  7. package/lib/index-DV-nXpU1.cjs +1 -0
  8. package/lib/index-M6H3FoBi.js +1147 -0
  9. package/lib/index.cjs +1 -0
  10. package/lib/index.d.cts +513 -0
  11. package/lib/index.d.ts +513 -0
  12. package/lib/index.js +16 -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/style.css +1 -0
  18. package/lib/tiptap-DkWHMWDt.js +6061 -0
  19. package/lib/tiptap-gBG-1T-V.cjs +116 -0
  20. package/lib/vendor-BJ0Yf78E.cjs +8114 -0
  21. package/lib/vendor-Cpa6z-M0.js +67575 -0
  22. package/package.json +60 -4
  23. package/src/components/ActionButton.tsx +0 -103
  24. package/src/components/ActionMenuButton.tsx +0 -76
  25. package/src/components/BubbleMenu.tsx +0 -93
  26. package/src/components/CharactorCount.tsx +0 -50
  27. package/src/components/ColorPicker.tsx +0 -272
  28. package/src/components/RichTextEditor.tsx +0 -212
  29. package/src/components/SizeSetter/SizeSetter.tsx +0 -102
  30. package/src/components/Toolbar.tsx +0 -108
  31. package/src/components/icons/Activity.tsx +0 -19
  32. package/src/components/icons/Animas.tsx +0 -24
  33. package/src/components/icons/AspectRatio.tsx +0 -13
  34. package/src/components/icons/Blockquote.tsx +0 -17
  35. package/src/components/icons/ColumnAddLeft.tsx +0 -7
  36. package/src/components/icons/ColumnAddRight.tsx +0 -7
  37. package/src/components/icons/DeleteColumn.tsx +0 -26
  38. package/src/components/icons/DeleteRow.tsx +0 -26
  39. package/src/components/icons/Direction.tsx +0 -7
  40. package/src/components/icons/Excalidraw.tsx +0 -7
  41. package/src/components/icons/ExportPdf.tsx +0 -8
  42. package/src/components/icons/ExportWord.tsx +0 -24
  43. package/src/components/icons/FileWordOutline.tsx +0 -13
  44. package/src/components/icons/Flag.tsx +0 -19
  45. package/src/components/icons/Food.tsx +0 -20
  46. package/src/components/icons/GIfIcon.tsx +0 -10
  47. package/src/components/icons/Icon.tsx +0 -30
  48. package/src/components/icons/ImportWord.tsx +0 -23
  49. package/src/components/icons/LeftToRight.tsx +0 -7
  50. package/src/components/icons/LineHeight.tsx +0 -13
  51. package/src/components/icons/MenuDown.tsx +0 -24
  52. package/src/components/icons/Mermaid.tsx +0 -13
  53. package/src/components/icons/NoFill.tsx +0 -7
  54. package/src/components/icons/Object.tsx +0 -24
  55. package/src/components/icons/RightToLeft.tsx +0 -7
  56. package/src/components/icons/SizeL.tsx +0 -9
  57. package/src/components/icons/SizeM.tsx +0 -13
  58. package/src/components/icons/SizeS.tsx +0 -13
  59. package/src/components/icons/Symbol.tsx +0 -19
  60. package/src/components/icons/Travel.tsx +0 -24
  61. package/src/components/icons/Twitter.tsx +0 -7
  62. package/src/components/icons/icons.ts +0 -212
  63. package/src/components/icons/index.ts +0 -12
  64. package/src/components/index.ts +0 -9
  65. package/src/components/menus/bubble.ts +0 -395
  66. package/src/components/menus/components/BubbleMenuContent.tsx +0 -15
  67. package/src/components/menus/components/BubbleMenuDrawer.tsx +0 -128
  68. package/src/components/menus/components/BubbleMenuExcalidraw.tsx +0 -91
  69. package/src/components/menus/components/BubbleMenuIframe.tsx +0 -143
  70. package/src/components/menus/components/BubbleMenuKatex.tsx +0 -136
  71. package/src/components/menus/components/BubbleMenuLink.tsx +0 -99
  72. package/src/components/menus/components/BubbleMenuMedia.tsx +0 -235
  73. package/src/components/menus/components/BubbleMenuMermaid.tsx +0 -128
  74. package/src/components/menus/components/BubbleMenuText.tsx +0 -102
  75. package/src/components/menus/components/BubbleMenuTwitter.tsx +0 -91
  76. package/src/components/menus/components/ColumnsBubbleMenu.tsx +0 -59
  77. package/src/components/menus/components/ContentMenu.tsx +0 -396
  78. package/src/components/menus/components/TableBubbleMenu.tsx +0 -362
  79. package/src/components/menus/index.ts +0 -7
  80. package/src/components/ui/button.tsx +0 -56
  81. package/src/components/ui/checkbox.tsx +0 -30
  82. package/src/components/ui/dialog.tsx +0 -128
  83. package/src/components/ui/dropdown-menu.tsx +0 -203
  84. package/src/components/ui/emoji-picker.tsx +0 -166
  85. package/src/components/ui/index.ts +0 -14
  86. package/src/components/ui/input.tsx +0 -25
  87. package/src/components/ui/label.tsx +0 -26
  88. package/src/components/ui/popover.tsx +0 -31
  89. package/src/components/ui/select.tsx +0 -162
  90. package/src/components/ui/separator.tsx +0 -31
  91. package/src/components/ui/switch.tsx +0 -29
  92. package/src/components/ui/tabs.tsx +0 -55
  93. package/src/components/ui/textarea.tsx +0 -24
  94. package/src/components/ui/toast.tsx +0 -129
  95. package/src/components/ui/toaster.tsx +0 -44
  96. package/src/components/ui/toggle.tsx +0 -45
  97. package/src/components/ui/tooltip.tsx +0 -30
  98. package/src/components/ui/use-toast.ts +0 -197
  99. package/src/constants/index.ts +0 -223
  100. package/src/constants/resetCSS.ts +0 -139
  101. package/src/extension-bundle.ts +0 -2
  102. package/src/extensions/Attachment/Attachment.ts +0 -144
  103. package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +0 -69
  104. package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +0 -28
  105. package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +0 -155
  106. package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +0 -23
  107. package/src/extensions/Attachment/index.ts +0 -1
  108. package/src/extensions/BaseKit.ts +0 -253
  109. package/src/extensions/Blockquote/Blockquote.ts +0 -31
  110. package/src/extensions/Blockquote/index.ts +0 -1
  111. package/src/extensions/Bold/Bold.ts +0 -26
  112. package/src/extensions/Bold/index.ts +0 -1
  113. package/src/extensions/BulletList/BulletList.ts +0 -28
  114. package/src/extensions/BulletList/index.ts +0 -1
  115. package/src/extensions/Clear/Clear.ts +0 -24
  116. package/src/extensions/Clear/index.ts +0 -1
  117. package/src/extensions/Code/Code.ts +0 -26
  118. package/src/extensions/Code/index.ts +0 -1
  119. package/src/extensions/CodeBlock/CodeBlock.ts +0 -54
  120. package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +0 -66
  121. package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +0 -89
  122. package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +0 -81
  123. package/src/extensions/CodeBlock/highlighter.ts +0 -132
  124. package/src/extensions/CodeBlock/index.ts +0 -1
  125. package/src/extensions/CodeBlock/shiki-plugin.ts +0 -213
  126. package/src/extensions/Color/Color.ts +0 -52
  127. package/src/extensions/Color/components/ColorActionButton.tsx +0 -104
  128. package/src/extensions/Color/index.ts +0 -1
  129. package/src/extensions/Document/Document.ts +0 -8
  130. package/src/extensions/Document/index.ts +0 -1
  131. package/src/extensions/Drawer/Drawer.ts +0 -177
  132. package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +0 -85
  133. package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +0 -598
  134. package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +0 -500
  135. package/src/extensions/Drawer/components/DrawerActiveButton.tsx +0 -239
  136. package/src/extensions/Drawer/components/EditDrawerBlock.tsx +0 -238
  137. package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +0 -260
  138. package/src/extensions/Drawer/index.ts +0 -1
  139. package/src/extensions/Emoji/Emoji.ts +0 -146
  140. package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +0 -103
  141. package/src/extensions/Emoji/components/EmojiList/emojis.ts +0 -1858
  142. package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +0 -61
  143. package/src/extensions/Emoji/index.ts +0 -1
  144. package/src/extensions/Excalidraw/Excalidraw.ts +0 -123
  145. package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +0 -138
  146. package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +0 -178
  147. package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +0 -43
  148. package/src/extensions/Excalidraw/index.ts +0 -1
  149. package/src/extensions/ExportPdf/ExportPdf.ts +0 -25
  150. package/src/extensions/ExportPdf/index.ts +0 -1
  151. package/src/extensions/ExportWord/ExportWord.ts +0 -87
  152. package/src/extensions/ExportWord/index.ts +0 -1
  153. package/src/extensions/FontFamily/FontFamily.ts +0 -64
  154. package/src/extensions/FontFamily/components/FontFamilyButton.tsx +0 -97
  155. package/src/extensions/FontFamily/index.ts +0 -1
  156. package/src/extensions/FontSize/FontSize.ts +0 -119
  157. package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +0 -84
  158. package/src/extensions/FontSize/index.ts +0 -1
  159. package/src/extensions/FormatPainter/FormatPainter.ts +0 -121
  160. package/src/extensions/FormatPainter/index.ts +0 -1
  161. package/src/extensions/Heading/Heading.ts +0 -57
  162. package/src/extensions/Heading/components/HeadingButton.tsx +0 -96
  163. package/src/extensions/Heading/index.ts +0 -1
  164. package/src/extensions/Highlight/Highlight.ts +0 -36
  165. package/src/extensions/Highlight/components/HighlightActionButton.tsx +0 -108
  166. package/src/extensions/Highlight/index.ts +0 -1
  167. package/src/extensions/History/History.ts +0 -39
  168. package/src/extensions/History/components/HistoryActionButton.tsx +0 -74
  169. package/src/extensions/History/index.ts +0 -1
  170. package/src/extensions/HorizontalRule/HorizontalRule.ts +0 -42
  171. package/src/extensions/HorizontalRule/index.ts +0 -1
  172. package/src/extensions/Iframe/Iframe.ts +0 -140
  173. package/src/extensions/Iframe/components/IframeNodeView.tsx +0 -92
  174. package/src/extensions/Iframe/components/index.module.scss +0 -40
  175. package/src/extensions/Iframe/embed.ts +0 -487
  176. package/src/extensions/Iframe/index.ts +0 -1
  177. package/src/extensions/Image/Image.ts +0 -303
  178. package/src/extensions/Image/components/ActionImageButton.tsx +0 -186
  179. package/src/extensions/Image/components/ImageCropper.tsx +0 -198
  180. package/src/extensions/Image/components/ImageView.tsx +0 -271
  181. package/src/extensions/Image/index.ts +0 -1
  182. package/src/extensions/Image/store.ts +0 -15
  183. package/src/extensions/ImageGif/ImageGif.ts +0 -176
  184. package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +0 -138
  185. package/src/extensions/ImageGif/components/ImageGifView.tsx +0 -260
  186. package/src/extensions/ImageGif/index.ts +0 -1
  187. package/src/extensions/ImportWord/ImportWord.ts +0 -52
  188. package/src/extensions/ImportWord/components/ImportWordButton.tsx +0 -151
  189. package/src/extensions/ImportWord/index.ts +0 -1
  190. package/src/extensions/Indent/Indent.ts +0 -110
  191. package/src/extensions/Indent/index.ts +0 -1
  192. package/src/extensions/Italic/Italic.ts +0 -29
  193. package/src/extensions/Italic/index.ts +0 -1
  194. package/src/extensions/Katex/Katex.ts +0 -109
  195. package/src/extensions/Katex/components/KatexActiveButton.tsx +0 -117
  196. package/src/extensions/Katex/components/KatexWrapper.tsx +0 -53
  197. package/src/extensions/Katex/index.ts +0 -1
  198. package/src/extensions/LineHeight/LineHeight.ts +0 -76
  199. package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +0 -93
  200. package/src/extensions/LineHeight/index.ts +0 -1
  201. package/src/extensions/Link/Link.ts +0 -92
  202. package/src/extensions/Link/components/LinkEditBlock.tsx +0 -110
  203. package/src/extensions/Link/components/LinkEditPopover.tsx +0 -46
  204. package/src/extensions/Link/components/LinkViewBlock.tsx +0 -54
  205. package/src/extensions/Link/index.ts +0 -1
  206. package/src/extensions/ListItem/ListItem.ts +0 -1
  207. package/src/extensions/ListItem/index.ts +0 -1
  208. package/src/extensions/Mention/Mention.ts +0 -100
  209. package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +0 -94
  210. package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +0 -38
  211. package/src/extensions/Mention/index.ts +0 -1
  212. package/src/extensions/Mermaid/Mermaid.ts +0 -177
  213. package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +0 -155
  214. package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +0 -151
  215. package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +0 -260
  216. package/src/extensions/Mermaid/index.ts +0 -1
  217. package/src/extensions/MoreMark/MoreMark.ts +0 -102
  218. package/src/extensions/MoreMark/components/ActionMoreButton.tsx +0 -97
  219. package/src/extensions/MoreMark/index.ts +0 -1
  220. package/src/extensions/MultiColumn/Column.ts +0 -36
  221. package/src/extensions/MultiColumn/MultiColumn.ts +0 -111
  222. package/src/extensions/MultiColumn/components/ColumnActionButton.ts +0 -22
  223. package/src/extensions/MultiColumn/index.ts +0 -3
  224. package/src/extensions/OrderedList/OrderedList.ts +0 -28
  225. package/src/extensions/OrderedList/index.ts +0 -1
  226. package/src/extensions/SearchAndReplace/SearchAndReplace.ts +0 -395
  227. package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +0 -190
  228. package/src/extensions/SearchAndReplace/index.ts +0 -1
  229. package/src/extensions/Selection/Selection.ts +0 -32
  230. package/src/extensions/Selection/index.ts +0 -1
  231. package/src/extensions/SlashCommand/SlashCommand.ts +0 -255
  232. package/src/extensions/SlashCommand/components/CommandsList.tsx +0 -180
  233. package/src/extensions/SlashCommand/groups.ts +0 -183
  234. package/src/extensions/SlashCommand/index.ts +0 -1
  235. package/src/extensions/SlashCommand/types.ts +0 -24
  236. package/src/extensions/Strike/Strike.ts +0 -26
  237. package/src/extensions/Strike/index.ts +0 -1
  238. package/src/extensions/Subscript/Subscript.ts +0 -88
  239. package/src/extensions/Subscript/index.ts +0 -1
  240. package/src/extensions/Table/Cell.ts +0 -131
  241. package/src/extensions/Table/Header.ts +0 -93
  242. package/src/extensions/Table/Row.ts +0 -8
  243. package/src/extensions/Table/Table.ts +0 -60
  244. package/src/extensions/Table/cell-background.ts +0 -112
  245. package/src/extensions/Table/components/CreateTablePopover.tsx +0 -132
  246. package/src/extensions/Table/components/TableActionButton.tsx +0 -42
  247. package/src/extensions/Table/index.ts +0 -6
  248. package/src/extensions/Table/utils.ts +0 -352
  249. package/src/extensions/TableOfContent/TableOfContent.ts +0 -124
  250. package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +0 -116
  251. package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +0 -27
  252. package/src/extensions/TableOfContent/components/index.module.scss +0 -40
  253. package/src/extensions/TableOfContent/index.ts +0 -1
  254. package/src/extensions/TaskList/TaskList.ts +0 -46
  255. package/src/extensions/TaskList/index.ts +0 -1
  256. package/src/extensions/TextAlign/TextAlign.ts +0 -68
  257. package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +0 -103
  258. package/src/extensions/TextAlign/index.ts +0 -1
  259. package/src/extensions/TextBubble/TextBubble.ts +0 -22
  260. package/src/extensions/TextBubble/components/TextDropdown.tsx +0 -146
  261. package/src/extensions/TextBubble/index.ts +0 -1
  262. package/src/extensions/TextDirection/TextDirection.ts +0 -97
  263. package/src/extensions/TextDirection/components/TextDirectionButton.tsx +0 -103
  264. package/src/extensions/TextDirection/index.ts +0 -1
  265. package/src/extensions/TrailingNode/TrailingNode.ts +0 -71
  266. package/src/extensions/TrailingNode/index.ts +0 -1
  267. package/src/extensions/Twitter/Twitter.ts +0 -161
  268. package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +0 -68
  269. package/src/extensions/Twitter/components/NodeViewTweet.tsx +0 -30
  270. package/src/extensions/Twitter/components/TwitterActiveButton.tsx +0 -41
  271. package/src/extensions/Twitter/index.ts +0 -1
  272. package/src/extensions/UnderLine/Underline.ts +0 -30
  273. package/src/extensions/UnderLine/index.ts +0 -1
  274. package/src/extensions/Video/Video.ts +0 -204
  275. package/src/extensions/Video/components/ActiveVideoButton.tsx +0 -191
  276. package/src/extensions/Video/index.ts +0 -1
  277. package/src/extensions/Video/store.ts +0 -15
  278. package/src/extensions/index.ts +0 -122
  279. package/src/hooks/useActive.tsx +0 -24
  280. package/src/hooks/useAttributes.tsx +0 -45
  281. package/src/hooks/useCopy.tsx +0 -20
  282. package/src/hooks/useEditorState.tsx +0 -23
  283. package/src/hooks/useExtension.tsx +0 -29
  284. package/src/index.ts +0 -8
  285. package/src/lib/utils.ts +0 -7
  286. package/src/locale-bundle.ts +0 -3
  287. package/src/locales/en.ts +0 -173
  288. package/src/locales/hu.ts +0 -173
  289. package/src/locales/index.tsx +0 -163
  290. package/src/locales/pt-br.ts +0 -173
  291. package/src/locales/vi.ts +0 -173
  292. package/src/locales/zh-cn.ts +0 -173
  293. package/src/plugins/DragHandle/index.ts +0 -375
  294. package/src/plugins/DragHandle/range.ts +0 -114
  295. package/src/plugins/DragHandle/utils.ts +0 -80
  296. package/src/plugins/image-upload.ts +0 -160
  297. package/src/store/ProviderRichText.tsx +0 -53
  298. package/src/store/editableEditor.ts +0 -15
  299. package/src/store/fast-context.tsx +0 -70
  300. package/src/store/store.ts +0 -35
  301. package/src/styles/ProseMirror.scss +0 -176
  302. package/src/styles/columns.scss +0 -23
  303. package/src/styles/editor.scss +0 -411
  304. package/src/styles/global.scss +0 -87
  305. package/src/styles/index.scss +0 -5
  306. package/src/styles/mention.scss +0 -6
  307. package/src/theme/theme.ts +0 -15
  308. package/src/types.ts +0 -271
  309. package/src/utils/_event.ts +0 -55
  310. package/src/utils/color.ts +0 -67
  311. package/src/utils/columns.ts +0 -142
  312. package/src/utils/customEvents/customEvents.ts +0 -18
  313. package/src/utils/customEvents/events.constant.ts +0 -11
  314. package/src/utils/delete-node.ts +0 -46
  315. package/src/utils/dom-dataset.ts +0 -121
  316. package/src/utils/download.ts +0 -17
  317. package/src/utils/dynamicCSS.ts +0 -192
  318. package/src/utils/editor-container-size.ts +0 -28
  319. package/src/utils/file.ts +0 -112
  320. package/src/utils/getRenderContainer.ts +0 -41
  321. package/src/utils/indent.ts +0 -99
  322. package/src/utils/is-mobile.ts +0 -57
  323. package/src/utils/json.ts +0 -18
  324. package/src/utils/line-height.ts +0 -109
  325. package/src/utils/lru-cache.ts +0 -145
  326. package/src/utils/mitt.ts +0 -114
  327. package/src/utils/node.ts +0 -92
  328. package/src/utils/pdf.ts +0 -72
  329. package/src/utils/plateform.ts +0 -49
  330. package/src/utils/shortId.ts +0 -5
  331. package/src/utils/storage.ts +0 -18
  332. package/src/utils/utils.ts +0 -71
  333. package/src/vite-env.d.ts +0 -3
@@ -1,64 +0,0 @@
1
- import type { Extension } from '@tiptap/core';
2
- import type { FontFamilyOptions as TiptapFontFamilyOptions } from '@tiptap/extension-font-family';
3
- import FontFamilyTiptap from '@tiptap/extension-font-family';
4
-
5
- import type { BaseKitOptions } from '../BaseKit';
6
- import { ensureNameValueOptions } from '@/utils/utils';
7
- import { DEFAULT_FONT_FAMILY_LIST } from '@/constants';
8
- import FontFamilyButton from '@/extensions/FontFamily/components/FontFamilyButton';
9
- import type { GeneralOptions, NameValueOption } from '@/types';
10
-
11
- export interface FontFamilyOptions extends TiptapFontFamilyOptions, GeneralOptions<FontFamilyOptions> {
12
- /**
13
- * Font family list.
14
- */
15
- fontFamilyList: (string | NameValueOption)[]
16
- }
17
-
18
- export const FontFamily = FontFamilyTiptap.extend<FontFamilyOptions>({
19
- addOptions() {
20
- return {
21
- ...this.parent?.(),
22
- fontFamilyList: DEFAULT_FONT_FAMILY_LIST,
23
- button({ editor, extension, t }: any) {
24
- const { extensions = [] } = editor.extensionManager ?? [];
25
- const fontFamilyList = ensureNameValueOptions(extension?.options?.fontFamilyList || []);
26
- const baseKitExt = extensions.find(
27
- (k: any) => k.name === 'base-kit',
28
- ) as Extension<BaseKitOptions>;
29
-
30
- const items = fontFamilyList.map(font => ({
31
- action: () => {
32
- editor.chain().focus().setFontFamily(font.value).run();
33
- },
34
- isActive: () => editor.isActive('textStyle', { fontFamily: font.value }) || false,
35
- disabled: !editor.can().setFontFamily(font.value),
36
- title: font.name,
37
- font: font.value,
38
- }));
39
-
40
- if (baseKitExt && baseKitExt.options.textStyle !== false) {
41
- items.unshift({
42
- action: () => editor.chain().focus().unsetFontFamily().run(),
43
- isActive: () => false,
44
- disabled: false,
45
- font: t('editor.fontFamily.default.tooltip'),
46
- title: t('editor.fontFamily.tooltip'),
47
- });
48
- }
49
-
50
- const disabled = items.filter((k: any) => k.disabled).length === items.length;
51
-
52
- return {
53
- component: FontFamilyButton,
54
- componentProps: {
55
- tooltip: t('editor.fontFamily.tooltip'),
56
- disabled,
57
- items,
58
- editor,
59
- },
60
- };
61
- },
62
- };
63
- },
64
- });
@@ -1,97 +0,0 @@
1
- import React, { Fragment, useMemo } from 'react';
2
-
3
- import {
4
- ActionMenuButton,
5
- DropdownMenu,
6
- DropdownMenuCheckboxItem,
7
- DropdownMenuContent,
8
- DropdownMenuSeparator,
9
- DropdownMenuTrigger,
10
- } from '@/components';
11
- import { useLocale } from '@/locales';
12
- import type { ButtonViewReturnComponentProps } from '@/types';
13
-
14
- export interface Item {
15
- title: string
16
- icon?: any
17
- font?: string
18
- isActive: NonNullable<ButtonViewReturnComponentProps['isActive']>
19
- action?: ButtonViewReturnComponentProps['action']
20
- style?: React.CSSProperties
21
- shortcutKeys?: string[]
22
- disabled?: boolean
23
- divider?: boolean
24
- default?: boolean
25
- }
26
-
27
- interface Props {
28
- editor: any
29
- disabled?: boolean
30
- color?: string
31
- shortcutKeys?: string[]
32
- maxHeight?: string | number
33
- tooltip?: string
34
- items?: Item[]
35
- }
36
-
37
- function FontFamilyButton(props: Props) {
38
- const { t, lang } = useLocale();
39
-
40
- const active = useMemo(() => {
41
- const find: any = props?.items?.find((k: any) => k.isActive());
42
-
43
- if (find && !find.default) {
44
- return {
45
- ...find,
46
- };
47
- }
48
- const item: Item = {
49
- title: props.tooltip as any,
50
- font: t('editor.fontFamily.default.tooltip'),
51
- isActive: () => false,
52
- disabled: false,
53
- action: () => props.editor.chain().focus().unsetFontFamily().run(),
54
- };
55
- return item;
56
- }, [t, lang, props]);
57
-
58
- return (
59
- <DropdownMenu>
60
- <DropdownMenuTrigger asChild
61
- disabled={props?.disabled}
62
- >
63
- <ActionMenuButton
64
- disabled={props?.disabled}
65
- icon="MenuDown"
66
- title={active?.font?.length > 7 ? `${active?.font?.slice(0, 6)}...` : active?.font}
67
- tooltip={props?.tooltip}
68
- />
69
- </DropdownMenuTrigger>
70
-
71
- <DropdownMenuContent className="w-full">
72
- {props?.items?.map((item: any, index) => {
73
- const style
74
- = item.font === t('editor.fontFamily.default.tooltip') ? {} : { fontFamily: item.font };
75
-
76
- return (
77
- <Fragment key={`font-family-${index}`}>
78
- <DropdownMenuCheckboxItem checked={active?.font === item.font}
79
- onClick={item.action}
80
- >
81
- <div className="ml-1 h-full"
82
- style={style}
83
- >
84
- {item.font}
85
- </div>
86
- </DropdownMenuCheckboxItem>
87
-
88
- {item.font === t('editor.fontFamily.default.tooltip') && <DropdownMenuSeparator />}
89
- </Fragment>
90
- );
91
- })}
92
- </DropdownMenuContent>
93
- </DropdownMenu>
94
- );
95
- }
96
-
97
- export default FontFamilyButton;
@@ -1 +0,0 @@
1
- export * from './FontFamily';
@@ -1,119 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
-
3
- import FontSizeMenuButton from './components/FontSizeMenuButton';
4
- import { ensureNameValueOptions } from '@/utils/utils';
5
- import { DEFAULT_FONT_SIZE_LIST, DEFAULT_FONT_SIZE_VALUE } from '@/constants';
6
- import type { GeneralOptions, NameValueOption } from '@/types';
7
-
8
- /**
9
- * Represents the interface for font size options, extending GeneralOptions.
10
- */
11
- export interface FontSizeOptions extends GeneralOptions<FontSizeOptions> {
12
- types: string[]
13
- /**
14
- * List of available font size values
15
- *
16
- * @default DEFAULT_FONT_SIZE_LIST
17
- */
18
- fontSizes: (string | NameValueOption)[]
19
- }
20
-
21
- declare module '@tiptap/core' {
22
- interface Commands<ReturnType> {
23
- fontSize: {
24
- /**
25
- * Set the text font size. ex: "12px", "2em", or "small". Must be a valid
26
- * CSS font-size
27
- * (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size).
28
- */
29
- setFontSize: (fontSize: string) => ReturnType
30
- /**
31
- * Unset the font size
32
- */
33
- unsetFontSize: () => ReturnType
34
- }
35
- }
36
- }
37
-
38
- export const FontSize = Extension.create<FontSizeOptions>({
39
- name: 'fontSize',
40
- addOptions() {
41
- return {
42
- ...this.parent?.(),
43
- types: ['textStyle'],
44
- fontSizes: [...DEFAULT_FONT_SIZE_LIST],
45
- button({ editor, extension, t }) {
46
- const fontSizes = ensureNameValueOptions(extension.options?.fontSizes || DEFAULT_FONT_SIZE_VALUE);
47
- const defaultFontSize = ensureNameValueOptions([DEFAULT_FONT_SIZE_VALUE])[0];
48
- const items = fontSizes.map(k => ({
49
- title: k.value === defaultFontSize.value ? t('editor.fontSize.default.tooltip') : String(k.name),
50
- isActive: () => {
51
- const { fontSize } = editor.getAttributes('textStyle');
52
- const isDefault = k.value === defaultFontSize.value;
53
- const notFontSize = fontSize === undefined;
54
- if (isDefault && notFontSize) {
55
- return true;
56
- }
57
- return editor.isActive({ fontSize: String(k.value) }) || false;
58
- },
59
- action: () => {
60
- if (k.value === defaultFontSize.value) {
61
- editor.commands.unsetFontSize();
62
- return;
63
- }
64
- editor.commands.setFontSize(String(k.value));
65
- },
66
- disabled: !editor.can().setFontSize(String(k.value)),
67
- divider: k.value === defaultFontSize.value || false,
68
- default: k.value === defaultFontSize.value || false,
69
- }));
70
- const disabled = items.filter(k => k.disabled).length === items.length;
71
- return {
72
- component: FontSizeMenuButton,
73
- componentProps: {
74
- editor,
75
- tooltip: t('editor.fontSize.tooltip'),
76
- disabled,
77
- items,
78
- maxHeight: 280,
79
- },
80
- };
81
- },
82
- };
83
- },
84
- addGlobalAttributes() {
85
- return [
86
- {
87
- types: this.options.types,
88
- attributes: {
89
- fontSize: {
90
- default: null,
91
- parseHTML: element => element.style.fontSize.replaceAll(/["']+/g, ''),
92
- renderHTML: (attributes) => {
93
- if (!attributes.fontSize) {
94
- return {};
95
- }
96
- return {
97
- style: `font-size: ${attributes.fontSize}`,
98
- };
99
- },
100
- },
101
- },
102
- },
103
- ];
104
- },
105
- addCommands() {
106
- return {
107
- setFontSize:
108
- fontSize =>
109
- ({ chain }) => {
110
- return chain().setMark('textStyle', { fontSize }).run();
111
- },
112
- unsetFontSize:
113
- () =>
114
- ({ chain }) => {
115
- return chain().setMark('textStyle', { fontSize: null }).removeEmptyTextStyle().run();
116
- },
117
- };
118
- },
119
- });
@@ -1,84 +0,0 @@
1
- import React, { useMemo, useRef } from 'react';
2
-
3
- import {
4
- ActionMenuButton,
5
- DropdownMenu,
6
- DropdownMenuCheckboxItem,
7
- DropdownMenuContent,
8
- DropdownMenuTrigger,
9
- } from '@/components';
10
- import { useLocale } from '@/locales';
11
- import type { ButtonViewReturnComponentProps } from '@/types';
12
-
13
- export interface Item {
14
- title: string
15
- isActive: NonNullable<ButtonViewReturnComponentProps['isActive']>
16
- action?: ButtonViewReturnComponentProps['action']
17
- style?: React.CSSProperties
18
- disabled?: boolean
19
- divider?: boolean
20
- default?: boolean
21
- }
22
-
23
- interface IPropsFontSizeMenuButton {
24
- editor: any
25
- disabled?: boolean
26
- color?: string
27
- shortcutKeys?: string[]
28
- maxHeight?: string | number
29
- tooltip?: string
30
- items?: Item[]
31
- }
32
-
33
- function FontSizeMenuButton(props: IPropsFontSizeMenuButton) {
34
- const { t } = useLocale();
35
- const divRef = useRef<HTMLDivElement>(null);
36
-
37
- const active = useMemo(() => {
38
- const find: any = (props.items || []).find((k: any) => k.isActive());
39
- if (find) {
40
- return find;
41
- }
42
- const item: Item = {
43
- title: t('editor.fontSize.default.tooltip'),
44
- isActive: () => false,
45
- };
46
- return item;
47
- }, [props]);
48
-
49
- return (
50
- <DropdownMenu>
51
- <DropdownMenuTrigger asChild disabled={props?.disabled}>
52
- <div ref={divRef}>
53
- <ActionMenuButton
54
- disabled={props?.disabled}
55
- icon="MenuDown"
56
- title={active?.title}
57
- tooltip={`${props?.tooltip}`}
58
- />
59
- </div>
60
- </DropdownMenuTrigger>
61
-
62
- <DropdownMenuContent
63
- container={divRef.current as any}
64
- className="max-h-[40vh] w-32 overflow-y-auto"
65
- >
66
- {props?.items?.map((item: any, index) => {
67
- return (
68
- <DropdownMenuCheckboxItem
69
- checked={active.title === item.title}
70
- key={`font-size-${index}`}
71
- onClick={item.action}
72
- >
73
- <div className="ml-1 h-full">
74
- {item.title}
75
- </div>
76
- </DropdownMenuCheckboxItem>
77
- );
78
- })}
79
- </DropdownMenuContent>
80
- </DropdownMenu>
81
- );
82
- }
83
-
84
- export default FontSizeMenuButton;
@@ -1 +0,0 @@
1
- export * from './FontSize';
@@ -1,121 +0,0 @@
1
- /* eslint-disable prefer-const */
2
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
- import { Extension } from '@tiptap/core';
4
- import type { Mark } from '@tiptap/pm/model';
5
- import { Plugin, PluginKey } from '@tiptap/pm/state';
6
-
7
- import { ActionButton } from '@/components';
8
- import type { GeneralOptions } from '@/types';
9
-
10
- /**
11
- * Represents the interface for font size options, extending GeneralOptions.
12
- */
13
- export interface FormatPainterOptions extends GeneralOptions<FormatPainterOptions> {}
14
-
15
- declare module '@tiptap/core' {
16
- interface Commands<ReturnType> {
17
- painter: {
18
- setPainter: (marks: Mark[]) => ReturnType
19
- }
20
- }
21
- }
22
-
23
- export interface PainterAction {
24
- type: 'start' | 'end'
25
- marks: Mark[]
26
- }
27
- /**
28
- * 格式刷
29
- */
30
- export const FormatPainter = Extension.create<FormatPainterOptions>({
31
- name: 'painter',
32
- addOptions() {
33
- return {
34
- ...this.parent?.(),
35
- button: ({ editor, t }) => ({
36
- component: ActionButton,
37
- componentProps: {
38
- action: () => {
39
- editor.commands.setPainter(editor?.state.selection.$head.marks() as Mark[]);
40
- },
41
- icon: 'PaintRoller',
42
- tooltip: t('editor.format'),
43
- },
44
- }),
45
- };
46
- },
47
- addCommands() {
48
- return {
49
- setPainter:
50
- (marks: Mark[]) =>
51
- ({
52
- view: {
53
- dispatch,
54
- state: { tr },
55
- dom,
56
- },
57
- }) => {
58
- const svgCursor
59
- = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#000" d="M9 22v-6H4V7q0-1.65 1.175-2.825T8 3h12v13h-5v6zM6 10h12V5h-1v4h-2V5h-1v2h-2V5H8q-.825 0-1.412.588T6 7zm0 4h12v-2H6zm0 0v-2z"/></svg>';
60
- const encodedSvg = encodeURIComponent(svgCursor);
61
- const cursorUrl = `url("data:image/svg+xml;utf8,${encodedSvg}"), auto`;
62
-
63
- dom.style.cursor = cursorUrl;
64
- dispatch(tr.setMeta('painterAction', { type: 'start', marks }));
65
- return true;
66
- },
67
- };
68
- },
69
-
70
- addProseMirrorPlugins() {
71
- return [
72
- new Plugin({
73
- key: new PluginKey('format-painter'),
74
- state: {
75
- init: () => [] as Mark[],
76
- apply: (tr, set) => {
77
- const action = tr.getMeta('painterAction') as PainterAction;
78
- if (action && action.type === 'start') {
79
- set = action.marks;
80
- } else if (action && action.type === 'end') {
81
- set = [];
82
- }
83
- return set;
84
- },
85
- },
86
- props: {
87
- handleDOMEvents: {
88
- mousedown(view) {
89
- const marks = this.getState(view.state) as Mark[];
90
- if (!marks || marks.length === 0) {
91
- view.dom.style.cursor = '';
92
- return false; // 如果没有标记,则不执行任何操作
93
- }
94
- const mouseup = () => {
95
- document.removeEventListener('mouseup', mouseup);
96
-
97
- let {
98
- dispatch,
99
- state: { tr, selection },
100
- dom,
101
- } = view as any;
102
- dom.style.cursor = '';
103
-
104
- tr = tr.removeMark(selection.from, selection.to);
105
- for (const mark of marks) {
106
- if (mark.type.name !== 'link') {
107
- tr = tr.addMark(selection.from, selection.to, mark);
108
- }
109
- }
110
-
111
- dispatch(tr.setMeta('painterAction', { type: 'end' }));
112
- };
113
- document.addEventListener('mouseup', mouseup);
114
- return true;
115
- },
116
- },
117
- },
118
- }),
119
- ];
120
- },
121
- });
@@ -1 +0,0 @@
1
- export * from './FormatPainter';
@@ -1,57 +0,0 @@
1
- import type { Extension } from '@tiptap/core';
2
- import type { HeadingOptions as TiptapHeadingOptions } from '@tiptap/extension-heading';
3
- import { Heading as TiptapHeading } from '@tiptap/extension-heading';
4
-
5
- import type { BaseKitOptions } from '../BaseKit';
6
- import HeadingButton from '@/extensions/Heading/components/HeadingButton';
7
- import type { GeneralOptions } from '@/types';
8
-
9
- export interface HeadingOptions extends TiptapHeadingOptions, GeneralOptions<HeadingOptions> {}
10
-
11
- export const Heading = TiptapHeading.extend<HeadingOptions>({
12
- addOptions() {
13
- return {
14
- ...this.parent?.(),
15
- levels: [1, 2, 3, 4, 5, 6],
16
- button({ editor, extension, t }) {
17
- const { extensions = [] } = editor.extensionManager ?? [];
18
- const levels = extension.options?.levels || [];
19
- const baseKitExt = extensions.find(
20
- k => k.name === 'base-kit',
21
- ) as Extension<BaseKitOptions>;
22
-
23
- const items: any[] = levels.map(level => ({
24
- action: () => editor.commands.toggleHeading({ level }),
25
- isActive: () => editor.isActive('heading', { level }) || false,
26
- disabled: !editor.can().toggleHeading({ level }),
27
- title: t(`editor.heading.h${level}.tooltip`),
28
- level,
29
- shortcutKeys: ['alt', 'mod', `${level}`],
30
- }));
31
-
32
- if (baseKitExt && baseKitExt.options.paragraph !== false) {
33
- items.unshift({
34
- action: () => editor.commands.setParagraph(),
35
- isActive: () => editor.isActive('paragraph') || false,
36
- disabled: !editor.can().setParagraph(),
37
- level: 0,
38
- title: t('editor.paragraph.tooltip'),
39
- shortcutKeys: ['alt', 'mod', '0'],
40
- });
41
- }
42
-
43
- const disabled = items.filter((k: any) => k.disabled).length === items.length;
44
-
45
- return {
46
- component: HeadingButton,
47
- componentProps: {
48
- tooltip: t('editor.heading.tooltip'),
49
- disabled,
50
- items,
51
- editor,
52
- },
53
- };
54
- },
55
- };
56
- },
57
- });
@@ -1,96 +0,0 @@
1
- import React, { Fragment, useMemo } from 'react';
2
-
3
- import {
4
- ActionMenuButton,
5
- DropdownMenu,
6
- DropdownMenuCheckboxItem,
7
- DropdownMenuContent,
8
- DropdownMenuSeparator,
9
- DropdownMenuShortcut,
10
- DropdownMenuTrigger,
11
- } from '@/components';
12
- import type { ButtonViewReturnComponentProps } from '@/types';
13
- import { getShortcutKey } from '@/utils/plateform';
14
-
15
- export interface Item {
16
- title: string
17
- icon?: any
18
- level?: number
19
- isActive: NonNullable<ButtonViewReturnComponentProps['isActive']>
20
- action?: ButtonViewReturnComponentProps['action']
21
- style?: React.CSSProperties
22
- shortcutKeys?: string[]
23
- disabled?: boolean
24
- divider?: boolean
25
- default?: boolean
26
- }
27
-
28
- interface Props {
29
- editor: any
30
- disabled?: boolean
31
- color?: string
32
- shortcutKeys?: string[]
33
- maxHeight?: string | number
34
- tooltip?: string
35
- items?: Item[]
36
- }
37
-
38
- function HeadingButton(props: Props) {
39
- const active = useMemo(() => {
40
- const find: any = props?.items?.find((k: any) => k.isActive());
41
-
42
- if (find && !find.default) {
43
- return {
44
- ...find,
45
- };
46
- }
47
- const item: Item = {
48
- title: props.tooltip as any,
49
- level: 0,
50
- isActive: () => false,
51
- };
52
- return item;
53
- }, [props]);
54
-
55
- return (
56
- <DropdownMenu>
57
- <DropdownMenuTrigger asChild
58
- disabled={props?.disabled}
59
- >
60
- <ActionMenuButton
61
- disabled={props?.disabled}
62
- icon="MenuDown"
63
- title={active?.title}
64
- tooltip={props?.tooltip}
65
- />
66
- </DropdownMenuTrigger>
67
-
68
- <DropdownMenuContent className="w-full">
69
- {props?.items?.map((item: any, index) => {
70
- return (
71
- <Fragment key={`heading-k-${index}`}>
72
- <DropdownMenuCheckboxItem
73
- checked={active?.title === item.title}
74
- onClick={item.action}
75
- >
76
- <div className={`heading- ml-1 h-full${item.level}`}>
77
- {item.title}
78
- </div>
79
-
80
- {!!item?.shortcutKeys?.length && (
81
- <DropdownMenuShortcut className="pl-4">
82
- {item?.shortcutKeys?.map((item: any) => getShortcutKey(item)).join(' ')}
83
- </DropdownMenuShortcut>
84
- )}
85
- </DropdownMenuCheckboxItem>
86
-
87
- {item.level === 0 && <DropdownMenuSeparator />}
88
- </Fragment>
89
- );
90
- })}
91
- </DropdownMenuContent>
92
- </DropdownMenu>
93
- );
94
- }
95
-
96
- export default HeadingButton;
@@ -1 +0,0 @@
1
- export * from './Heading';
@@ -1,36 +0,0 @@
1
- import type { HighlightOptions as TiptapHighlightOptions } from '@tiptap/extension-highlight';
2
- import { Highlight as TiptapHighlight } from '@tiptap/extension-highlight';
3
-
4
- import HighlightActionButton from './components/HighlightActionButton';
5
- import type { GeneralOptions } from '@/types';
6
-
7
- export interface HighlightOptions
8
- extends TiptapHighlightOptions,
9
- GeneralOptions<HighlightOptions> {}
10
-
11
- export const Highlight = TiptapHighlight.extend<HighlightOptions>({
12
- addOptions() {
13
- return {
14
- ...this.parent?.(),
15
- multicolor: true,
16
- button: ({ editor, t }) => ({
17
- component: HighlightActionButton,
18
- componentProps: {
19
- action: (color?: unknown) => {
20
- if (typeof color === 'string') {
21
- editor.chain().focus().setHighlight({ color }).run();
22
- }
23
- if (color === undefined) {
24
- editor.chain().focus().unsetHighlight().run();
25
- }
26
- },
27
- editor,
28
- isActive: () => editor.isActive('highlight') || false,
29
- disabled: !editor.can().setHighlight(),
30
- shortcutKeys: ['⇧', 'mod', 'H'],
31
- tooltip: t('editor.highlight.tooltip'),
32
- },
33
- }),
34
- };
35
- },
36
- });