neuphlo-editor 1.0.4 → 1.1.0

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 (316) hide show
  1. package/dist/react/index.cjs +404 -7
  2. package/dist/react/index.cjs.map +1 -1
  3. package/dist/react/index.css +47 -59
  4. package/dist/react/index.css.map +1 -1
  5. package/dist/react/index.d.cts +3 -1
  6. package/dist/react/index.d.ts +3 -1
  7. package/dist/react/index.js +412 -8
  8. package/dist/react/index.js.map +1 -1
  9. package/dist/styles.css +146 -122
  10. package/package.json +3 -2
  11. package/dist/chunk-3KATSGAJ.js +0 -334
  12. package/dist/chunk-3KATSGAJ.js.map +0 -1
  13. package/dist/chunk-3NZW7XQW.js +0 -199
  14. package/dist/chunk-3NZW7XQW.js.map +0 -1
  15. package/dist/chunk-3XGRNDIA.js +0 -270
  16. package/dist/chunk-3XGRNDIA.js.map +0 -1
  17. package/dist/chunk-42TQBICL.js +0 -285
  18. package/dist/chunk-42TQBICL.js.map +0 -1
  19. package/dist/chunk-4A4NLM4J.js +0 -105
  20. package/dist/chunk-4A4NLM4J.js.map +0 -1
  21. package/dist/chunk-4HTYZSZB.js +0 -283
  22. package/dist/chunk-4HTYZSZB.js.map +0 -1
  23. package/dist/chunk-52EDCGOT.js +0 -283
  24. package/dist/chunk-52EDCGOT.js.map +0 -1
  25. package/dist/chunk-5LHEWHX2.js +0 -310
  26. package/dist/chunk-5LHEWHX2.js.map +0 -1
  27. package/dist/chunk-5SICPLDM.js +0 -162
  28. package/dist/chunk-5SICPLDM.js.map +0 -1
  29. package/dist/chunk-5X66AJGZ.js +0 -286
  30. package/dist/chunk-5X66AJGZ.js.map +0 -1
  31. package/dist/chunk-66G4F3B7.js +0 -293
  32. package/dist/chunk-66G4F3B7.js.map +0 -1
  33. package/dist/chunk-6AT4Y6ZS.js +0 -287
  34. package/dist/chunk-6AT4Y6ZS.js.map +0 -1
  35. package/dist/chunk-6JV4E5XM.js +0 -253
  36. package/dist/chunk-6JV4E5XM.js.map +0 -1
  37. package/dist/chunk-7D4SUZUM.js +0 -38
  38. package/dist/chunk-7D4SUZUM.js.map +0 -1
  39. package/dist/chunk-7LA3T2ZZ.js +0 -226
  40. package/dist/chunk-7LA3T2ZZ.js.map +0 -1
  41. package/dist/chunk-7VTRP5A5.js +0 -366
  42. package/dist/chunk-7VTRP5A5.js.map +0 -1
  43. package/dist/chunk-A54YGOPF.js +0 -158
  44. package/dist/chunk-A54YGOPF.js.map +0 -1
  45. package/dist/chunk-A7P5CEXL.js +0 -307
  46. package/dist/chunk-A7P5CEXL.js.map +0 -1
  47. package/dist/chunk-AJKBB4BM.js +0 -299
  48. package/dist/chunk-AJKBB4BM.js.map +0 -1
  49. package/dist/chunk-AKTIMFVS.js +0 -62
  50. package/dist/chunk-AKTIMFVS.js.map +0 -1
  51. package/dist/chunk-BREFWGM6.js +0 -324
  52. package/dist/chunk-BREFWGM6.js.map +0 -1
  53. package/dist/chunk-BVJTDYXS.js +0 -293
  54. package/dist/chunk-BVJTDYXS.js.map +0 -1
  55. package/dist/chunk-CSNCOG2Q.js +0 -267
  56. package/dist/chunk-CSNCOG2Q.js.map +0 -1
  57. package/dist/chunk-CZP4MVGC.js +0 -33
  58. package/dist/chunk-CZP4MVGC.js.map +0 -1
  59. package/dist/chunk-DGUM43GV.js +0 -11
  60. package/dist/chunk-DGUM43GV.js.map +0 -1
  61. package/dist/chunk-DHLYGW7C.js +0 -296
  62. package/dist/chunk-DHLYGW7C.js.map +0 -1
  63. package/dist/chunk-DLV6K2L6.js +0 -300
  64. package/dist/chunk-DLV6K2L6.js.map +0 -1
  65. package/dist/chunk-E4ZOKKFZ.js +0 -104
  66. package/dist/chunk-E4ZOKKFZ.js.map +0 -1
  67. package/dist/chunk-ES6CXFKY.js +0 -253
  68. package/dist/chunk-ES6CXFKY.js.map +0 -1
  69. package/dist/chunk-G4OUF5JM.js +0 -420
  70. package/dist/chunk-G4OUF5JM.js.map +0 -1
  71. package/dist/chunk-GMGPF7KX.js +0 -286
  72. package/dist/chunk-GMGPF7KX.js.map +0 -1
  73. package/dist/chunk-GWZ7IKMP.js +0 -287
  74. package/dist/chunk-GWZ7IKMP.js.map +0 -1
  75. package/dist/chunk-H3RFWADZ.js +0 -1075
  76. package/dist/chunk-H3RFWADZ.js.map +0 -1
  77. package/dist/chunk-H7Y3GE5V.js +0 -283
  78. package/dist/chunk-H7Y3GE5V.js.map +0 -1
  79. package/dist/chunk-HGYQOOPL.js +0 -310
  80. package/dist/chunk-HGYQOOPL.js.map +0 -1
  81. package/dist/chunk-HIVO3ILW.js +0 -103
  82. package/dist/chunk-HIVO3ILW.js.map +0 -1
  83. package/dist/chunk-I6DXZZPA.js +0 -102
  84. package/dist/chunk-I6DXZZPA.js.map +0 -1
  85. package/dist/chunk-IUKIZ4GW.js +0 -310
  86. package/dist/chunk-IUKIZ4GW.js.map +0 -1
  87. package/dist/chunk-JDLH4EOS.js +0 -366
  88. package/dist/chunk-JDLH4EOS.js.map +0 -1
  89. package/dist/chunk-JIFYPDKP.js +0 -301
  90. package/dist/chunk-JIFYPDKP.js.map +0 -1
  91. package/dist/chunk-K6SSIZS6.js +0 -330
  92. package/dist/chunk-K6SSIZS6.js.map +0 -1
  93. package/dist/chunk-LIFS45CU.js +0 -253
  94. package/dist/chunk-LIFS45CU.js.map +0 -1
  95. package/dist/chunk-LNTRIOFK.js +0 -307
  96. package/dist/chunk-LNTRIOFK.js.map +0 -1
  97. package/dist/chunk-LPFVU3RN.js +0 -199
  98. package/dist/chunk-LPFVU3RN.js.map +0 -1
  99. package/dist/chunk-LRHHHMXX.js +0 -266
  100. package/dist/chunk-LRHHHMXX.js.map +0 -1
  101. package/dist/chunk-M6GRNJJ6.js +0 -366
  102. package/dist/chunk-M6GRNJJ6.js.map +0 -1
  103. package/dist/chunk-MG2IC4MX.js +0 -366
  104. package/dist/chunk-MG2IC4MX.js.map +0 -1
  105. package/dist/chunk-NEDF73LE.js +0 -417
  106. package/dist/chunk-NEDF73LE.js.map +0 -1
  107. package/dist/chunk-NRJKIW5O.js +0 -188
  108. package/dist/chunk-NRJKIW5O.js.map +0 -1
  109. package/dist/chunk-O57IX4IM.js +0 -968
  110. package/dist/chunk-O57IX4IM.js.map +0 -1
  111. package/dist/chunk-OEM5TFNL.js +0 -427
  112. package/dist/chunk-OEM5TFNL.js.map +0 -1
  113. package/dist/chunk-OIC2JM4Z.js +0 -385
  114. package/dist/chunk-OIC2JM4Z.js.map +0 -1
  115. package/dist/chunk-PQFWSZCB.js +0 -380
  116. package/dist/chunk-PQFWSZCB.js.map +0 -1
  117. package/dist/chunk-Q6CNWILK.js +0 -62
  118. package/dist/chunk-Q6CNWILK.js.map +0 -1
  119. package/dist/chunk-QF6C4OCO.js +0 -268
  120. package/dist/chunk-QF6C4OCO.js.map +0 -1
  121. package/dist/chunk-RVYZO65R.js +0 -253
  122. package/dist/chunk-RVYZO65R.js.map +0 -1
  123. package/dist/chunk-T2K3KCWJ.js +0 -105
  124. package/dist/chunk-T2K3KCWJ.js.map +0 -1
  125. package/dist/chunk-U7GHNRXL.js +0 -253
  126. package/dist/chunk-U7GHNRXL.js.map +0 -1
  127. package/dist/chunk-VADPPD5C.js +0 -373
  128. package/dist/chunk-VADPPD5C.js.map +0 -1
  129. package/dist/chunk-VFXYNXYF.js +0 -58
  130. package/dist/chunk-VFXYNXYF.js.map +0 -1
  131. package/dist/chunk-VKFDJF4D.js +0 -62
  132. package/dist/chunk-VKFDJF4D.js.map +0 -1
  133. package/dist/chunk-VLANJDHQ.js +0 -151
  134. package/dist/chunk-VLANJDHQ.js.map +0 -1
  135. package/dist/chunk-VRVNV2QN.js +0 -267
  136. package/dist/chunk-VRVNV2QN.js.map +0 -1
  137. package/dist/chunk-WCNMYOTP.js +0 -307
  138. package/dist/chunk-WCNMYOTP.js.map +0 -1
  139. package/dist/chunk-X4ZZ6IGZ.js +0 -375
  140. package/dist/chunk-X4ZZ6IGZ.js.map +0 -1
  141. package/dist/chunk-X55UNGAX.js +0 -324
  142. package/dist/chunk-X55UNGAX.js.map +0 -1
  143. package/dist/chunk-XE6OD7SD.js +0 -307
  144. package/dist/chunk-XE6OD7SD.js.map +0 -1
  145. package/dist/chunk-XMG5QIMC.js +0 -309
  146. package/dist/chunk-XMG5QIMC.js.map +0 -1
  147. package/dist/chunk-Y5TGCVN7.js +0 -22
  148. package/dist/chunk-Y5TGCVN7.js.map +0 -1
  149. package/dist/chunk-YHUGKP3V.js +0 -266
  150. package/dist/chunk-YHUGKP3V.js.map +0 -1
  151. package/dist/chunk-YVGYHTU6.js +0 -229
  152. package/dist/chunk-YVGYHTU6.js.map +0 -1
  153. package/dist/chunk-ZIUSSGJN.js +0 -268
  154. package/dist/chunk-ZIUSSGJN.js.map +0 -1
  155. package/dist/chunk-ZPN4LHFS.js +0 -1432
  156. package/dist/chunk-ZPN4LHFS.js.map +0 -1
  157. package/dist/chunk-ZZERJHJE.js +0 -319
  158. package/dist/chunk-ZZERJHJE.js.map +0 -1
  159. package/dist/editor-bubble-BuvIAV5w.d.cts +0 -38
  160. package/dist/editor-bubble-BuvIAV5w.d.ts +0 -38
  161. package/dist/editor-bubble-DHaRG3xi.d.cts +0 -38
  162. package/dist/editor-bubble-DHaRG3xi.d.ts +0 -38
  163. package/dist/example/components/editor-bubble-item.d.ts +0 -9
  164. package/dist/example/components/editor-bubble-item.js +0 -13
  165. package/dist/example/components/editor-bubble.d.ts +0 -7
  166. package/dist/example/components/editor-bubble.js +0 -51
  167. package/dist/example/components/editor-command-item.d.ts +0 -3
  168. package/dist/example/components/editor-command-item.js +0 -16
  169. package/dist/example/components/editor-command.js +0 -46
  170. package/dist/example/components/editor.d.ts +0 -21
  171. package/dist/example/components/editor.js +0 -13
  172. package/dist/example/components/index.d.ts +0 -8
  173. package/dist/example/components/index.js +0 -6
  174. package/dist/example/extensions/ai-highlight.d.ts +0 -31
  175. package/dist/example/extensions/ai-highlight.js +0 -83
  176. package/dist/example/extensions/custom-keymap.d.ts +0 -12
  177. package/dist/example/extensions/custom-keymap.js +0 -37
  178. package/dist/example/extensions/image-resizer.d.ts +0 -2
  179. package/dist/example/extensions/image-resizer.js +0 -51
  180. package/dist/example/extensions/index.d.ts +0 -25
  181. package/dist/example/extensions/index.js +0 -57
  182. package/dist/example/extensions/mathematics.d.ts +0 -40
  183. package/dist/example/extensions/mathematics.js +0 -116
  184. package/dist/example/extensions/slash-command.d.ts +0 -32
  185. package/dist/example/extensions/slash-command.js +0 -82
  186. package/dist/example/extensions/twitter.d.ts +0 -47
  187. package/dist/example/extensions/twitter.js +0 -85
  188. package/dist/example/extensions/updated-image.d.ts +0 -2
  189. package/dist/example/extensions/updated-image.js +0 -16
  190. package/dist/example/index.d.ts +0 -5
  191. package/dist/example/index.js +0 -10
  192. package/dist/example/plugins/index.d.ts +0 -1
  193. package/dist/example/plugins/index.js +0 -1
  194. package/dist/example/plugins/upload-images.d.ts +0 -13
  195. package/dist/example/plugins/upload-images.js +0 -121
  196. package/dist/example/utils/atoms.d.ts +0 -6
  197. package/dist/example/utils/atoms.js +0 -3
  198. package/dist/example/utils/index.d.ts +0 -5
  199. package/dist/example/utils/index.js +0 -41
  200. package/dist/example/utils/store.d.ts +0 -2
  201. package/dist/example/utils/store.js +0 -4
  202. package/dist/headless/components/editor-bubble-item.d.ts +0 -9
  203. package/dist/headless/components/editor-bubble-item.js +0 -29
  204. package/dist/headless/components/editor-bubble.d.ts +0 -9
  205. package/dist/headless/components/editor-bubble.js +0 -9
  206. package/dist/headless/components/editor-command-item.d.ts +0 -3
  207. package/dist/headless/components/editor-command-item.js +0 -18
  208. package/dist/headless/components/editor-command.d.ts +0 -10
  209. package/dist/headless/components/editor-command.js +0 -48
  210. package/dist/headless/components/editor.d.ts +0 -24
  211. package/dist/headless/components/editor.js +0 -13
  212. package/dist/headless/extensions/CodeBlock/CodeBlock.d.ts +0 -1
  213. package/dist/headless/extensions/CodeBlock/CodeBlock.js +0 -6
  214. package/dist/headless/extensions/CodeBlock/index.d.ts +0 -1
  215. package/dist/headless/extensions/CodeBlock/index.js +0 -1
  216. package/dist/headless/extensions/Link/Link.d.ts +0 -2
  217. package/dist/headless/extensions/Link/Link.js +0 -40
  218. package/dist/headless/extensions/Link/index.d.ts +0 -1
  219. package/dist/headless/extensions/Link/index.js +0 -1
  220. package/dist/headless/extensions/SlashCommand/CommandButton.d.ts +0 -9
  221. package/dist/headless/extensions/SlashCommand/CommandButton.js +0 -9
  222. package/dist/headless/extensions/SlashCommand/MenuList.d.ts +0 -4
  223. package/dist/headless/extensions/SlashCommand/MenuList.js +0 -91
  224. package/dist/headless/extensions/SlashCommand/SlashCommand.d.ts +0 -3
  225. package/dist/headless/extensions/SlashCommand/SlashCommand.js +0 -149
  226. package/dist/headless/extensions/SlashCommand/groups.d.ts +0 -3
  227. package/dist/headless/extensions/SlashCommand/groups.js +0 -184
  228. package/dist/headless/extensions/SlashCommand/index.d.ts +0 -1
  229. package/dist/headless/extensions/SlashCommand/index.js +0 -1
  230. package/dist/headless/extensions/SlashCommand/types.d.ts +0 -22
  231. package/dist/headless/extensions/SlashCommand/types.js +0 -1
  232. package/dist/headless/extensions/extension-kit.d.ts +0 -2
  233. package/dist/headless/extensions/extension-kit.js +0 -23
  234. package/dist/headless/extensions/index.d.ts +0 -4
  235. package/dist/headless/extensions/index.js +0 -5
  236. package/dist/headless/extensions/slash-command.d.ts +0 -36
  237. package/dist/headless/extensions/slash-command.js +0 -105
  238. package/dist/headless/src/components/editor-bubble-item.d.ts +0 -9
  239. package/dist/headless/src/components/editor-bubble-item.js +0 -13
  240. package/dist/headless/src/components/editor-bubble.d.ts +0 -7
  241. package/dist/headless/src/components/editor-bubble.js +0 -51
  242. package/dist/headless/src/components/editor-command-item.d.ts +0 -3
  243. package/dist/headless/src/components/editor-command-item.js +0 -16
  244. package/dist/headless/src/components/editor-command.js +0 -46
  245. package/dist/headless/src/components/editor.d.ts +0 -21
  246. package/dist/headless/src/components/editor.js +0 -13
  247. package/dist/headless/src/components/index.d.ts +0 -8
  248. package/dist/headless/src/components/index.js +0 -6
  249. package/dist/headless/src/extensions/ai-highlight.d.ts +0 -31
  250. package/dist/headless/src/extensions/ai-highlight.js +0 -83
  251. package/dist/headless/src/extensions/custom-keymap.d.ts +0 -12
  252. package/dist/headless/src/extensions/custom-keymap.js +0 -37
  253. package/dist/headless/src/extensions/image-resizer.d.ts +0 -2
  254. package/dist/headless/src/extensions/image-resizer.js +0 -51
  255. package/dist/headless/src/extensions/index.d.ts +0 -25
  256. package/dist/headless/src/extensions/index.js +0 -57
  257. package/dist/headless/src/extensions/mathematics.d.ts +0 -40
  258. package/dist/headless/src/extensions/mathematics.js +0 -116
  259. package/dist/headless/src/extensions/slash-command.d.ts +0 -32
  260. package/dist/headless/src/extensions/slash-command.js +0 -82
  261. package/dist/headless/src/extensions/twitter.d.ts +0 -47
  262. package/dist/headless/src/extensions/twitter.js +0 -85
  263. package/dist/headless/src/extensions/updated-image.d.ts +0 -2
  264. package/dist/headless/src/extensions/updated-image.js +0 -16
  265. package/dist/headless/src/index.d.ts +0 -5
  266. package/dist/headless/src/index.js +0 -10
  267. package/dist/headless/src/plugins/index.d.ts +0 -1
  268. package/dist/headless/src/plugins/index.js +0 -1
  269. package/dist/headless/src/plugins/upload-images.d.ts +0 -13
  270. package/dist/headless/src/plugins/upload-images.js +0 -121
  271. package/dist/headless/src/utils/atoms.d.ts +0 -6
  272. package/dist/headless/src/utils/atoms.js +0 -3
  273. package/dist/headless/src/utils/index.d.ts +0 -5
  274. package/dist/headless/src/utils/index.js +0 -41
  275. package/dist/headless/src/utils/store.d.ts +0 -2
  276. package/dist/headless/src/utils/store.js +0 -4
  277. package/dist/headless/tsup.config.d.ts +0 -3
  278. package/dist/headless/tsup.config.js +0 -13
  279. package/dist/headless/utils/atoms.d.ts +0 -7
  280. package/dist/headless/utils/atoms.js +0 -3
  281. package/dist/headless/utils/command-renderer.d.ts +0 -8
  282. package/dist/headless/utils/command-renderer.js +0 -52
  283. package/dist/headless/utils/command-store.d.ts +0 -16
  284. package/dist/headless/utils/command-store.js +0 -30
  285. package/dist/headless/utils/store.d.ts +0 -2
  286. package/dist/headless/utils/store.js +0 -4
  287. package/dist/index.cjs +0 -31
  288. package/dist/index.cjs.map +0 -1
  289. package/dist/index.d.cts +0 -3
  290. package/dist/index.d.ts +0 -1
  291. package/dist/index.js +0 -1
  292. package/dist/index.js.map +0 -1
  293. package/dist/react/Editor.d.ts +0 -18
  294. package/dist/react/Editor.js +0 -14
  295. package/dist/react/EditorContent.d.ts +0 -12
  296. package/dist/react/EditorContent.js +0 -13
  297. package/dist/react/EditorRoot.d.ts +0 -5
  298. package/dist/react/EditorRoot.js +0 -1
  299. package/dist/react/core.cjs +0 -154
  300. package/dist/react/core.cjs.map +0 -1
  301. package/dist/react/core.d.cts +0 -20
  302. package/dist/react/core.d.ts +0 -20
  303. package/dist/react/core.js +0 -10
  304. package/dist/react/core.js.map +0 -1
  305. package/dist/react/menus/LinkPopover.d.ts +0 -9
  306. package/dist/react/menus/LinkPopover.js +0 -113
  307. package/dist/react/menus/MenuList.d.ts +0 -10
  308. package/dist/react/menus/MenuList.js +0 -94
  309. package/dist/react/menus/SlashMenu.d.ts +0 -5
  310. package/dist/react/menus/SlashMenu.js +0 -71
  311. package/dist/react/menus/TextMenu.d.ts +0 -9
  312. package/dist/react/menus/TextMenu.js +0 -107
  313. package/dist/react/menus/TextMenu.withIcons.d.ts +0 -3
  314. package/dist/react/menus/TextMenu.withIcons.js +0 -7
  315. package/dist/react/menus/index.d.ts +0 -4
  316. package/dist/react/menus/index.js +0 -2
@@ -324,11 +324,214 @@ var handleCommandNavigation = (event) => {
324
324
  }
325
325
  };
326
326
 
327
+ // src/headless/extensions/Image/Image.ts
328
+ var import_extension_image = require("@tiptap/extension-image");
329
+ var import_state2 = require("@tiptap/pm/state");
330
+ var Image = import_extension_image.Image.extend({
331
+ addOptions() {
332
+ return {
333
+ ...this.parent?.(),
334
+ uploadImage: void 0,
335
+ allowBase64: false
336
+ };
337
+ },
338
+ addAttributes() {
339
+ return {
340
+ ...this.parent?.(),
341
+ src: {
342
+ default: null
343
+ },
344
+ alt: {
345
+ default: null
346
+ },
347
+ title: {
348
+ default: null
349
+ },
350
+ width: {
351
+ default: null,
352
+ parseHTML: (element) => element.getAttribute("width"),
353
+ renderHTML: (attributes) => {
354
+ if (!attributes.width) {
355
+ return {};
356
+ }
357
+ return {
358
+ width: attributes.width
359
+ };
360
+ }
361
+ },
362
+ height: {
363
+ default: null,
364
+ parseHTML: (element) => element.getAttribute("height"),
365
+ renderHTML: (attributes) => {
366
+ if (!attributes.height) {
367
+ return {};
368
+ }
369
+ return {
370
+ height: attributes.height
371
+ };
372
+ }
373
+ },
374
+ align: {
375
+ default: "left",
376
+ parseHTML: (element) => element.getAttribute("data-align") || "left",
377
+ renderHTML: (attributes) => {
378
+ return {
379
+ "data-align": attributes.align
380
+ };
381
+ }
382
+ }
383
+ };
384
+ },
385
+ addCommands() {
386
+ return {
387
+ ...this.parent?.(),
388
+ setImage: (options) => ({ commands }) => {
389
+ return commands.insertContent({
390
+ type: this.name,
391
+ attrs: options
392
+ });
393
+ },
394
+ uploadImage: () => ({ editor }) => {
395
+ const input = document.createElement("input");
396
+ input.type = "file";
397
+ input.accept = "image/*";
398
+ input.onchange = async (e) => {
399
+ const file = e.target.files?.[0];
400
+ if (!file) return;
401
+ if (this.options.uploadImage) {
402
+ try {
403
+ const url = await this.options.uploadImage(file);
404
+ editor.chain().focus().setImage({ src: url }).run();
405
+ } catch (error) {
406
+ console.error("Failed to upload image:", error);
407
+ }
408
+ } else if (this.options.allowBase64) {
409
+ const reader = new FileReader();
410
+ reader.onload = () => {
411
+ const url = reader.result;
412
+ editor.chain().focus().setImage({ src: url }).run();
413
+ };
414
+ reader.readAsDataURL(file);
415
+ } else {
416
+ console.warn(
417
+ "No upload handler provided. Please provide uploadImage option or enable allowBase64."
418
+ );
419
+ }
420
+ };
421
+ input.click();
422
+ return true;
423
+ }
424
+ };
425
+ },
426
+ addProseMirrorPlugins() {
427
+ return [
428
+ new import_state2.Plugin({
429
+ key: new import_state2.PluginKey("imageDrop"),
430
+ props: {
431
+ handleDOMEvents: {
432
+ drop: (view, event) => {
433
+ const hasFiles = event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length;
434
+ if (!hasFiles) {
435
+ return false;
436
+ }
437
+ const images = Array.from(event.dataTransfer.files).filter(
438
+ (file) => /image/i.test(file.type)
439
+ );
440
+ if (images.length === 0) {
441
+ return false;
442
+ }
443
+ event.preventDefault();
444
+ const { schema } = view.state;
445
+ const coordinates = view.posAtCoords({
446
+ left: event.clientX,
447
+ top: event.clientY
448
+ });
449
+ if (!coordinates) return false;
450
+ images.forEach(async (image) => {
451
+ if (this.options.uploadImage) {
452
+ try {
453
+ const url = await this.options.uploadImage(image);
454
+ const node = schema.nodes.image.create({ src: url });
455
+ const transaction = view.state.tr.insert(
456
+ coordinates.pos,
457
+ node
458
+ );
459
+ view.dispatch(transaction);
460
+ } catch (error) {
461
+ console.error("Failed to upload image:", error);
462
+ }
463
+ } else if (this.options.allowBase64) {
464
+ const reader = new FileReader();
465
+ reader.onload = (readerEvent) => {
466
+ const node = schema.nodes.image.create({
467
+ src: readerEvent.target?.result
468
+ });
469
+ const transaction = view.state.tr.insert(
470
+ coordinates.pos,
471
+ node
472
+ );
473
+ view.dispatch(transaction);
474
+ };
475
+ reader.readAsDataURL(image);
476
+ }
477
+ });
478
+ return true;
479
+ },
480
+ paste: (view, event) => {
481
+ const hasFiles = event.clipboardData && event.clipboardData.files && event.clipboardData.files.length;
482
+ if (!hasFiles) {
483
+ return false;
484
+ }
485
+ const images = Array.from(event.clipboardData.files).filter(
486
+ (file) => /image/i.test(file.type)
487
+ );
488
+ if (images.length === 0) {
489
+ return false;
490
+ }
491
+ event.preventDefault();
492
+ images.forEach(async (image) => {
493
+ if (this.options.uploadImage) {
494
+ try {
495
+ const url = await this.options.uploadImage(image);
496
+ view.dispatch(
497
+ view.state.tr.replaceSelectionWith(
498
+ view.state.schema.nodes.image.create({ src: url })
499
+ )
500
+ );
501
+ } catch (error) {
502
+ console.error("Failed to upload image:", error);
503
+ }
504
+ } else if (this.options.allowBase64) {
505
+ const reader = new FileReader();
506
+ reader.onload = (readerEvent) => {
507
+ view.dispatch(
508
+ view.state.tr.replaceSelectionWith(
509
+ view.state.schema.nodes.image.create({
510
+ src: readerEvent.target?.result
511
+ })
512
+ )
513
+ );
514
+ };
515
+ reader.readAsDataURL(image);
516
+ }
517
+ });
518
+ return true;
519
+ }
520
+ }
521
+ }
522
+ })
523
+ ];
524
+ }
525
+ });
526
+
327
527
  // src/headless/extensions/extension-kit.ts
328
- var ExtensionKit = () => [
528
+ var ExtensionKit = (options) => [
329
529
  import_starter_kit.StarterKit.configure({}),
330
530
  CodeBlock,
331
531
  Link,
532
+ Image.configure({
533
+ uploadImage: options?.uploadImage
534
+ }),
332
535
  import_extension_placeholder.Placeholder.configure({
333
536
  placeholder: ({ node }) => {
334
537
  if (node.type.name === "heading") {
@@ -1166,14 +1369,205 @@ function SlashMenu({ className }) {
1166
1369
  }
1167
1370
  )
1168
1371
  }
1372
+ ),
1373
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1374
+ EditorCommandItem,
1375
+ {
1376
+ value: "image photo picture",
1377
+ className: "nph-command__item",
1378
+ onCommand: ({
1379
+ editor: editor2,
1380
+ range
1381
+ }) => {
1382
+ ;
1383
+ editor2.chain().focus().deleteRange(range).run();
1384
+ editor2.chain().focus().uploadImage().run();
1385
+ },
1386
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1387
+ "span",
1388
+ {
1389
+ style: { display: "inline-flex", alignItems: "center", gap: 8 },
1390
+ children: [
1391
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons_react4.IconPhoto, { size: 16 }),
1392
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Image" })
1393
+ ]
1394
+ }
1395
+ )
1396
+ }
1169
1397
  )
1170
1398
  ]
1171
1399
  }
1172
1400
  ) });
1173
1401
  }
1174
1402
 
1175
- // src/react/Editor.tsx
1403
+ // src/react/menus/ImageMenu.tsx
1404
+ var import_react12 = require("@tiptap/react");
1405
+ var import_menus2 = require("@tiptap/react/menus");
1406
+ var import_icons_react5 = require("@tabler/icons-react");
1407
+ var import_react13 = require("react");
1176
1408
  var import_jsx_runtime8 = require("react/jsx-runtime");
1409
+ function ImageMenu({ className }) {
1410
+ const { editor } = (0, import_react12.useCurrentEditor)();
1411
+ const [size, setSize] = (0, import_react13.useState)(100);
1412
+ const [align, setAlign] = (0, import_react13.useState)("left");
1413
+ (0, import_react13.useEffect)(() => {
1414
+ if (!editor) return;
1415
+ const update = () => {
1416
+ if (!editor.isActive("image")) return;
1417
+ const attrs = editor.getAttributes("image") ?? {
1418
+ width: "",
1419
+ align: "left"
1420
+ };
1421
+ const width = attrs.width ?? "";
1422
+ if (width.includes("%")) {
1423
+ setSize(parseInt(width) || 100);
1424
+ } else {
1425
+ setSize(100);
1426
+ }
1427
+ setAlign(attrs.align ?? "left");
1428
+ };
1429
+ update();
1430
+ editor.on("selectionUpdate", update);
1431
+ editor.on("transaction", update);
1432
+ editor.on("update", update);
1433
+ return () => {
1434
+ editor.off("selectionUpdate", update);
1435
+ editor.off("transaction", update);
1436
+ editor.off("update", update);
1437
+ };
1438
+ }, [editor]);
1439
+ if (!editor) return null;
1440
+ const updateImageSize = (newSize) => {
1441
+ setSize(newSize);
1442
+ editor.commands.updateAttributes("image", {
1443
+ width: `${newSize}%`
1444
+ });
1445
+ };
1446
+ const updateImageAlign = (newAlign) => {
1447
+ setAlign(newAlign);
1448
+ editor.commands.updateAttributes("image", { align: newAlign });
1449
+ };
1450
+ const removeImage = () => {
1451
+ editor.chain().focus().deleteSelection().run();
1452
+ };
1453
+ const triggerUpload = () => {
1454
+ ;
1455
+ editor.chain().focus().uploadImage().run();
1456
+ };
1457
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1458
+ import_menus2.BubbleMenu,
1459
+ {
1460
+ editor,
1461
+ shouldShow: ({ editor: e }) => {
1462
+ return e.isActive("image");
1463
+ },
1464
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: className ? `bubble-menu ${className}` : "bubble-menu", children: [
1465
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1466
+ "div",
1467
+ {
1468
+ style: {
1469
+ display: "flex",
1470
+ alignItems: "center",
1471
+ gap: 8,
1472
+ minWidth: 140
1473
+ },
1474
+ children: [
1475
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { style: { fontSize: "12px", whiteSpace: "nowrap" }, children: [
1476
+ size,
1477
+ "%"
1478
+ ] }),
1479
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1480
+ "input",
1481
+ {
1482
+ type: "range",
1483
+ min: "25",
1484
+ max: "100",
1485
+ step: "5",
1486
+ value: size,
1487
+ onChange: (e) => updateImageSize(parseInt(e.target.value)),
1488
+ onMouseDown: (e) => e.stopPropagation(),
1489
+ style: { flex: 1 }
1490
+ }
1491
+ )
1492
+ ]
1493
+ }
1494
+ ),
1495
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1496
+ "div",
1497
+ {
1498
+ className: "nph-link-popover__divider",
1499
+ style: { margin: "0 4px" }
1500
+ }
1501
+ ),
1502
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1503
+ "button",
1504
+ {
1505
+ type: "button",
1506
+ className: `nph-btn nph-btn-ghost nph-btn-xs nph-btn-icon${align === "left" ? " is-active" : ""}`,
1507
+ title: "Align left",
1508
+ onMouseDown: (e) => e.preventDefault(),
1509
+ onClick: () => updateImageAlign("left"),
1510
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_react5.IconAlignLeft, { size: 16 })
1511
+ }
1512
+ ),
1513
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1514
+ "button",
1515
+ {
1516
+ type: "button",
1517
+ className: `nph-btn nph-btn-ghost nph-btn-xs nph-btn-icon${align === "center" ? " is-active" : ""}`,
1518
+ title: "Align center",
1519
+ onMouseDown: (e) => e.preventDefault(),
1520
+ onClick: () => updateImageAlign("center"),
1521
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_react5.IconAlignCenter, { size: 16 })
1522
+ }
1523
+ ),
1524
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1525
+ "button",
1526
+ {
1527
+ type: "button",
1528
+ className: `nph-btn nph-btn-ghost nph-btn-xs nph-btn-icon${align === "right" ? " is-active" : ""}`,
1529
+ title: "Align right",
1530
+ onMouseDown: (e) => e.preventDefault(),
1531
+ onClick: () => updateImageAlign("right"),
1532
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_react5.IconAlignRight, { size: 16 })
1533
+ }
1534
+ ),
1535
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1536
+ "div",
1537
+ {
1538
+ className: "nph-link-popover__divider",
1539
+ style: { margin: "0 4px" }
1540
+ }
1541
+ ),
1542
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1543
+ "button",
1544
+ {
1545
+ type: "button",
1546
+ className: "nph-btn nph-btn-ghost nph-btn-xs nph-btn-icon",
1547
+ title: "Upload new image",
1548
+ onMouseDown: (e) => e.preventDefault(),
1549
+ onClick: triggerUpload,
1550
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_react5.IconUpload, { size: 16 })
1551
+ }
1552
+ ),
1553
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1554
+ "button",
1555
+ {
1556
+ type: "button",
1557
+ className: "nph-btn nph-btn-ghost nph-btn-xs nph-btn-icon",
1558
+ title: "Remove image",
1559
+ onMouseDown: (e) => e.preventDefault(),
1560
+ onClick: removeImage,
1561
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_react5.IconTrash, { size: 16 })
1562
+ }
1563
+ )
1564
+ ] })
1565
+ }
1566
+ );
1567
+ }
1568
+
1569
+ // src/react/Editor.tsx
1570
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1177
1571
  function Editor({
1178
1572
  content,
1179
1573
  className,
@@ -1181,11 +1575,13 @@ function Editor({
1181
1575
  immediatelyRender = false,
1182
1576
  showTextMenu = true,
1183
1577
  showSlashMenu = true,
1578
+ showImageMenu = true,
1184
1579
  extensions,
1185
1580
  onUpdate,
1186
- onCreate
1581
+ onCreate,
1582
+ uploadImage
1187
1583
  }) {
1188
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EditorRoot, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1584
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EditorRoot, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1189
1585
  EditorContent,
1190
1586
  {
1191
1587
  onUpdate,
@@ -1193,7 +1589,7 @@ function Editor({
1193
1589
  immediatelyRender,
1194
1590
  editable,
1195
1591
  content,
1196
- extensions: [...extension_kit_default(), ...extensions ?? []],
1592
+ extensions: [...extension_kit_default({ uploadImage }), ...extensions ?? []],
1197
1593
  editorProps: {
1198
1594
  attributes: {
1199
1595
  class: "nph-editor max-w-none outline-none"
@@ -1203,8 +1599,9 @@ function Editor({
1203
1599
  }
1204
1600
  },
1205
1601
  children: [
1206
- showTextMenu ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TextMenu, {}) : null,
1207
- showSlashMenu ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SlashMenu, {}) : null
1602
+ showTextMenu ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TextMenu, {}) : null,
1603
+ showImageMenu ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ImageMenu, {}) : null,
1604
+ showSlashMenu ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SlashMenu, {}) : null
1208
1605
  ]
1209
1606
  }
1210
1607
  ) }) });