@infonomic/payload-alternative-lexical-editor 1.0.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 (579) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapter.d.ts +11 -0
  3. package/dist/adapter.d.ts.map +1 -0
  4. package/dist/adapter.js +124 -0
  5. package/dist/adapter.js.map +1 -0
  6. package/dist/cell/rsc-entry.d.ts +20 -0
  7. package/dist/cell/rsc-entry.d.ts.map +1 -0
  8. package/dist/cell/rsc-entry.js +68 -0
  9. package/dist/cell/rsc-entry.js.map +1 -0
  10. package/dist/field/apply-value-plugin.d.ts +9 -0
  11. package/dist/field/apply-value-plugin.d.ts.map +1 -0
  12. package/dist/field/apply-value-plugin.js +66 -0
  13. package/dist/field/apply-value-plugin.js.map +1 -0
  14. package/dist/field/build-initial-state.d.ts +29 -0
  15. package/dist/field/build-initial-state.d.ts.map +1 -0
  16. package/dist/field/build-initial-state.js +14 -0
  17. package/dist/field/build-initial-state.js.map +1 -0
  18. package/dist/field/config/default.d.ts +6 -0
  19. package/dist/field/config/default.d.ts.map +1 -0
  20. package/dist/field/config/default.js +52 -0
  21. package/dist/field/config/default.js.map +1 -0
  22. package/dist/field/config/editor-config-context.d.ts +14 -0
  23. package/dist/field/config/editor-config-context.d.ts.map +1 -0
  24. package/dist/field/config/editor-config-context.js +38 -0
  25. package/dist/field/config/editor-config-context.js.map +1 -0
  26. package/dist/field/config/types.d.ts +22 -0
  27. package/dist/field/config/types.d.ts.map +1 -0
  28. package/dist/field/config/types.js +2 -0
  29. package/dist/field/config/types.js.map +1 -0
  30. package/dist/field/constants.d.ts +2 -0
  31. package/dist/field/constants.d.ts.map +1 -0
  32. package/dist/field/constants.js +2 -0
  33. package/dist/field/constants.js.map +1 -0
  34. package/dist/field/context/shared-autocomplete-context.d.ts +18 -0
  35. package/dist/field/context/shared-autocomplete-context.d.ts.map +1 -0
  36. package/dist/field/context/shared-autocomplete-context.js +40 -0
  37. package/dist/field/context/shared-autocomplete-context.js.map +1 -0
  38. package/dist/field/context/shared-history-context.d.ts +19 -0
  39. package/dist/field/context/shared-history-context.d.ts.map +1 -0
  40. package/dist/field/context/shared-history-context.js +13 -0
  41. package/dist/field/context/shared-history-context.js.map +1 -0
  42. package/dist/field/context/shared-on-change-context.d.ts +13 -0
  43. package/dist/field/context/shared-on-change-context.d.ts.map +1 -0
  44. package/dist/field/context/shared-on-change-context.js +18 -0
  45. package/dist/field/context/shared-on-change-context.js.map +1 -0
  46. package/dist/field/debug.d.ts +3 -0
  47. package/dist/field/debug.d.ts.map +1 -0
  48. package/dist/field/debug.js +17 -0
  49. package/dist/field/debug.js.map +1 -0
  50. package/dist/field/editor-context.d.ts +15 -0
  51. package/dist/field/editor-context.d.ts.map +1 -0
  52. package/dist/field/editor-context.js +37 -0
  53. package/dist/field/editor-context.js.map +1 -0
  54. package/dist/field/editor.css +1477 -0
  55. package/dist/field/editor.d.ts +4 -0
  56. package/dist/field/editor.d.ts.map +1 -0
  57. package/dist/field/editor.js +86 -0
  58. package/dist/field/editor.js.map +1 -0
  59. package/dist/field/field-component.css +44 -0
  60. package/dist/field/field-component.d.ts +16 -0
  61. package/dist/field/field-component.d.ts.map +1 -0
  62. package/dist/field/field-component.js +136 -0
  63. package/dist/field/field-component.js.map +1 -0
  64. package/dist/field/hooks/useMediaQuery.d.ts +3 -0
  65. package/dist/field/hooks/useMediaQuery.d.ts.map +1 -0
  66. package/dist/field/hooks/useMediaQuery.js +20 -0
  67. package/dist/field/hooks/useMediaQuery.js.map +1 -0
  68. package/dist/field/hooks/useModal.d.ts +13 -0
  69. package/dist/field/hooks/useModal.d.ts.map +1 -0
  70. package/dist/field/hooks/useModal.js +28 -0
  71. package/dist/field/hooks/useModal.js.map +1 -0
  72. package/dist/field/hooks/useReport.d.ts +9 -0
  73. package/dist/field/hooks/useReport.d.ts.map +1 -0
  74. package/dist/field/hooks/useReport.js +51 -0
  75. package/dist/field/hooks/useReport.js.map +1 -0
  76. package/dist/field/images/cat-typing.gif +0 -0
  77. package/dist/field/images/emoji/1F600.png +0 -0
  78. package/dist/field/images/emoji/1F641.png +0 -0
  79. package/dist/field/images/emoji/1F642.png +0 -0
  80. package/dist/field/images/emoji/2764.png +0 -0
  81. package/dist/field/images/icons/3-columns.svg +3 -0
  82. package/dist/field/images/icons/admonition.svg +1 -0
  83. package/dist/field/images/icons/arrow-clockwise.svg +1 -0
  84. package/dist/field/images/icons/arrow-counterclockwise.svg +1 -0
  85. package/dist/field/images/icons/bg-color.svg +1 -0
  86. package/dist/field/images/icons/camera.svg +1 -0
  87. package/dist/field/images/icons/card-checklist.svg +1 -0
  88. package/dist/field/images/icons/caret-right-fill.svg +1 -0
  89. package/dist/field/images/icons/chat-left-text.svg +1 -0
  90. package/dist/field/images/icons/chat-right-dots.svg +1 -0
  91. package/dist/field/images/icons/chat-right-text.svg +1 -0
  92. package/dist/field/images/icons/chat-right.svg +1 -0
  93. package/dist/field/images/icons/chat-square-quote.svg +1 -0
  94. package/dist/field/images/icons/chevron-down.svg +1 -0
  95. package/dist/field/images/icons/clipboard.svg +1 -0
  96. package/dist/field/images/icons/close.svg +1 -0
  97. package/dist/field/images/icons/code.svg +1 -0
  98. package/dist/field/images/icons/comments.svg +1 -0
  99. package/dist/field/images/icons/copy.svg +1 -0
  100. package/dist/field/images/icons/diagram-2.svg +1 -0
  101. package/dist/field/images/icons/download.svg +1 -0
  102. package/dist/field/images/icons/draggable-block-menu.svg +1 -0
  103. package/dist/field/images/icons/dropdown-more.svg +1 -0
  104. package/dist/field/images/icons/figma.svg +1 -0
  105. package/dist/field/images/icons/file-earmark-text.svg +4 -0
  106. package/dist/field/images/icons/file-image.svg +1 -0
  107. package/dist/field/images/icons/filetype-gif.svg +1 -0
  108. package/dist/field/images/icons/font-color.svg +1 -0
  109. package/dist/field/images/icons/font-family.svg +1 -0
  110. package/dist/field/images/icons/gear.svg +1 -0
  111. package/dist/field/images/icons/horizontal-rule.svg +1 -0
  112. package/dist/field/images/icons/indent.svg +1 -0
  113. package/dist/field/images/icons/journal-code.svg +1 -0
  114. package/dist/field/images/icons/journal-text.svg +1 -0
  115. package/dist/field/images/icons/justify.svg +1 -0
  116. package/dist/field/images/icons/link.svg +1 -0
  117. package/dist/field/images/icons/list-ol.svg +1 -0
  118. package/dist/field/images/icons/list-ul.svg +1 -0
  119. package/dist/field/images/icons/lock-fill.svg +1 -0
  120. package/dist/field/images/icons/lock.svg +1 -0
  121. package/dist/field/images/icons/markdown.svg +1 -0
  122. package/dist/field/images/icons/mic.svg +1 -0
  123. package/dist/field/images/icons/outdent.svg +1 -0
  124. package/dist/field/images/icons/paint-bucket.svg +1 -0
  125. package/dist/field/images/icons/palette.svg +1 -0
  126. package/dist/field/images/icons/pencil-fill.svg +1 -0
  127. package/dist/field/images/icons/plug-fill.svg +1 -0
  128. package/dist/field/images/icons/plug.svg +1 -0
  129. package/dist/field/images/icons/plus-slash-minus.svg +1 -0
  130. package/dist/field/images/icons/plus.svg +1 -0
  131. package/dist/field/images/icons/prettier-error.svg +1 -0
  132. package/dist/field/images/icons/prettier.svg +1 -0
  133. package/dist/field/images/icons/send.svg +1 -0
  134. package/dist/field/images/icons/square-check.svg +1 -0
  135. package/dist/field/images/icons/sticky.svg +1 -0
  136. package/dist/field/images/icons/success-alt.svg +1 -0
  137. package/dist/field/images/icons/success.svg +1 -0
  138. package/dist/field/images/icons/table.svg +1 -0
  139. package/dist/field/images/icons/text-center.svg +1 -0
  140. package/dist/field/images/icons/text-left.svg +1 -0
  141. package/dist/field/images/icons/text-paragraph.svg +1 -0
  142. package/dist/field/images/icons/text-right.svg +1 -0
  143. package/dist/field/images/icons/trash.svg +1 -0
  144. package/dist/field/images/icons/trash3.svg +1 -0
  145. package/dist/field/images/icons/tweet.svg +1 -0
  146. package/dist/field/images/icons/type-bold.svg +1 -0
  147. package/dist/field/images/icons/type-h1.svg +1 -0
  148. package/dist/field/images/icons/type-h2.svg +1 -0
  149. package/dist/field/images/icons/type-h3.svg +1 -0
  150. package/dist/field/images/icons/type-h4.svg +1 -0
  151. package/dist/field/images/icons/type-h5.svg +1 -0
  152. package/dist/field/images/icons/type-h6.svg +1 -0
  153. package/dist/field/images/icons/type-italic.svg +1 -0
  154. package/dist/field/images/icons/type-strikethrough.svg +1 -0
  155. package/dist/field/images/icons/type-subscript.svg +1 -0
  156. package/dist/field/images/icons/type-superscript.svg +1 -0
  157. package/dist/field/images/icons/type-underline.svg +1 -0
  158. package/dist/field/images/icons/upload.svg +1 -0
  159. package/dist/field/images/icons/user.svg +1 -0
  160. package/dist/field/images/icons/vimeo.svg +1 -0
  161. package/dist/field/images/icons/youtube.svg +1 -0
  162. package/dist/field/images/landscape.jpg +0 -0
  163. package/dist/field/images/logo.svg +1 -0
  164. package/dist/field/images/yellow-flower-small.jpg +0 -0
  165. package/dist/field/images/yellow-flower.jpg +0 -0
  166. package/dist/field/index.d.ts +12 -0
  167. package/dist/field/index.d.ts.map +1 -0
  168. package/dist/field/index.js +9 -0
  169. package/dist/field/index.js.map +1 -0
  170. package/dist/field/lexical-after-read-populate-links.d.ts +47 -0
  171. package/dist/field/lexical-after-read-populate-links.d.ts.map +1 -0
  172. package/dist/field/lexical-after-read-populate-links.js +118 -0
  173. package/dist/field/lexical-after-read-populate-links.js.map +1 -0
  174. package/dist/field/lexical-after-read-populate-media.d.ts +34 -0
  175. package/dist/field/lexical-after-read-populate-media.d.ts.map +1 -0
  176. package/dist/field/lexical-after-read-populate-media.js +40 -0
  177. package/dist/field/lexical-after-read-populate-media.js.map +1 -0
  178. package/dist/field/lexical-before-change-populate-links.d.ts +52 -0
  179. package/dist/field/lexical-before-change-populate-links.d.ts.map +1 -0
  180. package/dist/field/lexical-before-change-populate-links.js +116 -0
  181. package/dist/field/lexical-before-change-populate-links.js.map +1 -0
  182. package/dist/field/nodes/admonition-node/admonition-node-component.css +115 -0
  183. package/dist/field/nodes/admonition-node/admonition-node-component.d.ts +11 -0
  184. package/dist/field/nodes/admonition-node/admonition-node-component.d.ts.map +1 -0
  185. package/dist/field/nodes/admonition-node/admonition-node-component.js +157 -0
  186. package/dist/field/nodes/admonition-node/admonition-node-component.js.map +1 -0
  187. package/dist/field/nodes/admonition-node/admonition-node.d.ts +28 -0
  188. package/dist/field/nodes/admonition-node/admonition-node.d.ts.map +1 -0
  189. package/dist/field/nodes/admonition-node/admonition-node.js +134 -0
  190. package/dist/field/nodes/admonition-node/admonition-node.js.map +1 -0
  191. package/dist/field/nodes/admonition-node/icons/danger-icon.css +11 -0
  192. package/dist/field/nodes/admonition-node/icons/danger-icon.d.ts +8 -0
  193. package/dist/field/nodes/admonition-node/icons/danger-icon.d.ts.map +1 -0
  194. package/dist/field/nodes/admonition-node/icons/danger-icon.js +7 -0
  195. package/dist/field/nodes/admonition-node/icons/danger-icon.js.map +1 -0
  196. package/dist/field/nodes/admonition-node/icons/index.d.ts +5 -0
  197. package/dist/field/nodes/admonition-node/icons/index.d.ts.map +1 -0
  198. package/dist/field/nodes/admonition-node/icons/index.js +5 -0
  199. package/dist/field/nodes/admonition-node/icons/index.js.map +1 -0
  200. package/dist/field/nodes/admonition-node/icons/note-icon.css +11 -0
  201. package/dist/field/nodes/admonition-node/icons/note-icon.d.ts +8 -0
  202. package/dist/field/nodes/admonition-node/icons/note-icon.d.ts.map +1 -0
  203. package/dist/field/nodes/admonition-node/icons/note-icon.js +7 -0
  204. package/dist/field/nodes/admonition-node/icons/note-icon.js.map +1 -0
  205. package/dist/field/nodes/admonition-node/icons/tip-icon.css +11 -0
  206. package/dist/field/nodes/admonition-node/icons/tip-icon.d.ts +8 -0
  207. package/dist/field/nodes/admonition-node/icons/tip-icon.d.ts.map +1 -0
  208. package/dist/field/nodes/admonition-node/icons/tip-icon.js +7 -0
  209. package/dist/field/nodes/admonition-node/icons/tip-icon.js.map +1 -0
  210. package/dist/field/nodes/admonition-node/icons/warning-icon.css +11 -0
  211. package/dist/field/nodes/admonition-node/icons/warning-icon.d.ts +8 -0
  212. package/dist/field/nodes/admonition-node/icons/warning-icon.d.ts.map +1 -0
  213. package/dist/field/nodes/admonition-node/icons/warning-icon.js +7 -0
  214. package/dist/field/nodes/admonition-node/icons/warning-icon.js.map +1 -0
  215. package/dist/field/nodes/admonition-node/index.d.ts +4 -0
  216. package/dist/field/nodes/admonition-node/index.d.ts.map +1 -0
  217. package/dist/field/nodes/admonition-node/index.js +4 -0
  218. package/dist/field/nodes/admonition-node/index.js.map +1 -0
  219. package/dist/field/nodes/admonition-node/types.d.ts +14 -0
  220. package/dist/field/nodes/admonition-node/types.d.ts.map +1 -0
  221. package/dist/field/nodes/admonition-node/types.js +2 -0
  222. package/dist/field/nodes/admonition-node/types.js.map +1 -0
  223. package/dist/field/nodes/index.d.ts +10 -0
  224. package/dist/field/nodes/index.d.ts.map +1 -0
  225. package/dist/field/nodes/index.js +44 -0
  226. package/dist/field/nodes/index.js.map +1 -0
  227. package/dist/field/nodes/inline-image-node/index.d.ts +4 -0
  228. package/dist/field/nodes/inline-image-node/index.d.ts.map +1 -0
  229. package/dist/field/nodes/inline-image-node/index.js +4 -0
  230. package/dist/field/nodes/inline-image-node/index.js.map +1 -0
  231. package/dist/field/nodes/inline-image-node/inline-image-node-component.css +205 -0
  232. package/dist/field/nodes/inline-image-node/inline-image-node-component.d.ts +18 -0
  233. package/dist/field/nodes/inline-image-node/inline-image-node-component.d.ts.map +1 -0
  234. package/dist/field/nodes/inline-image-node/inline-image-node-component.js +239 -0
  235. package/dist/field/nodes/inline-image-node/inline-image-node-component.js.map +1 -0
  236. package/dist/field/nodes/inline-image-node/inline-image-node.d.ts +39 -0
  237. package/dist/field/nodes/inline-image-node/inline-image-node.d.ts.map +1 -0
  238. package/dist/field/nodes/inline-image-node/inline-image-node.js +204 -0
  239. package/dist/field/nodes/inline-image-node/inline-image-node.js.map +1 -0
  240. package/dist/field/nodes/inline-image-node/types.d.ts +33 -0
  241. package/dist/field/nodes/inline-image-node/types.d.ts.map +1 -0
  242. package/dist/field/nodes/inline-image-node/types.js +2 -0
  243. package/dist/field/nodes/inline-image-node/types.js.map +1 -0
  244. package/dist/field/nodes/layout-container-node/layout-container-node.d.ts +29 -0
  245. package/dist/field/nodes/layout-container-node/layout-container-node.d.ts.map +1 -0
  246. package/dist/field/nodes/layout-container-node/layout-container-node.js +66 -0
  247. package/dist/field/nodes/layout-container-node/layout-container-node.js.map +1 -0
  248. package/dist/field/nodes/layout-container-node/layout-item-node.d.ts +23 -0
  249. package/dist/field/nodes/layout-container-node/layout-item-node.d.ts.map +1 -0
  250. package/dist/field/nodes/layout-container-node/layout-item-node.js +50 -0
  251. package/dist/field/nodes/layout-container-node/layout-item-node.js.map +1 -0
  252. package/dist/field/nodes/link-nodes/auto-link-node.d.ts +17 -0
  253. package/dist/field/nodes/link-nodes/auto-link-node.d.ts.map +1 -0
  254. package/dist/field/nodes/link-nodes/auto-link-node.js +46 -0
  255. package/dist/field/nodes/link-nodes/auto-link-node.js.map +1 -0
  256. package/dist/field/nodes/link-nodes/index.d.ts +4 -0
  257. package/dist/field/nodes/link-nodes/index.d.ts.map +1 -0
  258. package/dist/field/nodes/link-nodes/index.js +4 -0
  259. package/dist/field/nodes/link-nodes/index.js.map +1 -0
  260. package/dist/field/nodes/link-nodes/link-node.d.ts +42 -0
  261. package/dist/field/nodes/link-nodes/link-node.d.ts.map +1 -0
  262. package/dist/field/nodes/link-nodes/link-node.js +340 -0
  263. package/dist/field/nodes/link-nodes/link-node.js.map +1 -0
  264. package/dist/field/nodes/link-nodes/types.d.ts +16 -0
  265. package/dist/field/nodes/link-nodes/types.d.ts.map +1 -0
  266. package/dist/field/nodes/link-nodes/types.js +2 -0
  267. package/dist/field/nodes/link-nodes/types.js.map +1 -0
  268. package/dist/field/nodes/vimeo-node/index.d.ts +30 -0
  269. package/dist/field/nodes/vimeo-node/index.d.ts.map +1 -0
  270. package/dist/field/nodes/vimeo-node/index.js +92 -0
  271. package/dist/field/nodes/vimeo-node/index.js.map +1 -0
  272. package/dist/field/nodes/youtube-node/index.d.ts +30 -0
  273. package/dist/field/nodes/youtube-node/index.d.ts.map +1 -0
  274. package/dist/field/nodes/youtube-node/index.js +92 -0
  275. package/dist/field/nodes/youtube-node/index.js.map +1 -0
  276. package/dist/field/plugins/admonition-plugin/admonition-drawer.css +8 -0
  277. package/dist/field/plugins/admonition-plugin/admonition-drawer.d.ts +5 -0
  278. package/dist/field/plugins/admonition-plugin/admonition-drawer.d.ts.map +1 -0
  279. package/dist/field/plugins/admonition-plugin/admonition-drawer.js +44 -0
  280. package/dist/field/plugins/admonition-plugin/admonition-drawer.js.map +1 -0
  281. package/dist/field/plugins/admonition-plugin/fields.d.ts +14 -0
  282. package/dist/field/plugins/admonition-plugin/fields.d.ts.map +1 -0
  283. package/dist/field/plugins/admonition-plugin/fields.js +72 -0
  284. package/dist/field/plugins/admonition-plugin/fields.js.map +1 -0
  285. package/dist/field/plugins/admonition-plugin/index.d.ts +8 -0
  286. package/dist/field/plugins/admonition-plugin/index.d.ts.map +1 -0
  287. package/dist/field/plugins/admonition-plugin/index.js +65 -0
  288. package/dist/field/plugins/admonition-plugin/index.js.map +1 -0
  289. package/dist/field/plugins/admonition-plugin/types.d.ts +15 -0
  290. package/dist/field/plugins/admonition-plugin/types.d.ts.map +1 -0
  291. package/dist/field/plugins/admonition-plugin/types.js +2 -0
  292. package/dist/field/plugins/admonition-plugin/types.js.map +1 -0
  293. package/dist/field/plugins/auto-embed-plugin/index.d.ts +26 -0
  294. package/dist/field/plugins/auto-embed-plugin/index.d.ts.map +1 -0
  295. package/dist/field/plugins/auto-embed-plugin/index.js +191 -0
  296. package/dist/field/plugins/auto-embed-plugin/index.js.map +1 -0
  297. package/dist/field/plugins/code-highlight-plugin/index.d.ts +10 -0
  298. package/dist/field/plugins/code-highlight-plugin/index.d.ts.map +1 -0
  299. package/dist/field/plugins/code-highlight-plugin/index.js +11 -0
  300. package/dist/field/plugins/code-highlight-plugin/index.js.map +1 -0
  301. package/dist/field/plugins/drag-drop-paste-plugin/index.d.ts +9 -0
  302. package/dist/field/plugins/drag-drop-paste-plugin/index.d.ts.map +1 -0
  303. package/dist/field/plugins/drag-drop-paste-plugin/index.js +37 -0
  304. package/dist/field/plugins/drag-drop-paste-plugin/index.js.map +1 -0
  305. package/dist/field/plugins/floating-text-format-toolbar-plugin/index.css +150 -0
  306. package/dist/field/plugins/floating-text-format-toolbar-plugin/index.d.ts +13 -0
  307. package/dist/field/plugins/floating-text-format-toolbar-plugin/index.d.ts.map +1 -0
  308. package/dist/field/plugins/floating-text-format-toolbar-plugin/index.js +236 -0
  309. package/dist/field/plugins/floating-text-format-toolbar-plugin/index.js.map +1 -0
  310. package/dist/field/plugins/inline-image-plugin/fields.d.ts +12 -0
  311. package/dist/field/plugins/inline-image-plugin/fields.d.ts.map +1 -0
  312. package/dist/field/plugins/inline-image-plugin/fields.js +160 -0
  313. package/dist/field/plugins/inline-image-plugin/fields.js.map +1 -0
  314. package/dist/field/plugins/inline-image-plugin/index.d.ts +26 -0
  315. package/dist/field/plugins/inline-image-plugin/index.d.ts.map +1 -0
  316. package/dist/field/plugins/inline-image-plugin/index.js +222 -0
  317. package/dist/field/plugins/inline-image-plugin/index.js.map +1 -0
  318. package/dist/field/plugins/inline-image-plugin/inline-image-drawer.css +29 -0
  319. package/dist/field/plugins/inline-image-plugin/inline-image-drawer.d.ts +5 -0
  320. package/dist/field/plugins/inline-image-plugin/inline-image-drawer.d.ts.map +1 -0
  321. package/dist/field/plugins/inline-image-plugin/inline-image-drawer.js +51 -0
  322. package/dist/field/plugins/inline-image-plugin/inline-image-drawer.js.map +1 -0
  323. package/dist/field/plugins/inline-image-plugin/types.d.ts +16 -0
  324. package/dist/field/plugins/inline-image-plugin/types.d.ts.map +1 -0
  325. package/dist/field/plugins/inline-image-plugin/types.js +2 -0
  326. package/dist/field/plugins/inline-image-plugin/types.js.map +1 -0
  327. package/dist/field/plugins/inline-image-plugin/utils.d.ts +9 -0
  328. package/dist/field/plugins/inline-image-plugin/utils.d.ts.map +1 -0
  329. package/dist/field/plugins/inline-image-plugin/utils.js +27 -0
  330. package/dist/field/plugins/inline-image-plugin/utils.js.map +1 -0
  331. package/dist/field/plugins/layout-plugin/insert-layout-dialog.d.ts +14 -0
  332. package/dist/field/plugins/layout-plugin/insert-layout-dialog.d.ts.map +1 -0
  333. package/dist/field/plugins/layout-plugin/insert-layout-dialog.js +26 -0
  334. package/dist/field/plugins/layout-plugin/insert-layout-dialog.js.map +1 -0
  335. package/dist/field/plugins/layout-plugin/layout-plugin.d.ts +8 -0
  336. package/dist/field/plugins/layout-plugin/layout-plugin.d.ts.map +1 -0
  337. package/dist/field/plugins/layout-plugin/layout-plugin.js +87 -0
  338. package/dist/field/plugins/layout-plugin/layout-plugin.js.map +1 -0
  339. package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.d.ts +22 -0
  340. package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.d.ts.map +1 -0
  341. package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.js +218 -0
  342. package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.js.map +1 -0
  343. package/dist/field/plugins/link-plugin/auto-link/index.d.ts +10 -0
  344. package/dist/field/plugins/link-plugin/auto-link/index.d.ts.map +1 -0
  345. package/dist/field/plugins/link-plugin/auto-link/index.js +17 -0
  346. package/dist/field/plugins/link-plugin/auto-link/index.js.map +1 -0
  347. package/dist/field/plugins/link-plugin/link/fields.d.ts +11 -0
  348. package/dist/field/plugins/link-plugin/link/fields.d.ts.map +1 -0
  349. package/dist/field/plugins/link-plugin/link/fields.js +120 -0
  350. package/dist/field/plugins/link-plugin/link/fields.js.map +1 -0
  351. package/dist/field/plugins/link-plugin/link/floating-link-editor.css +128 -0
  352. package/dist/field/plugins/link-plugin/link/floating-link-editor.d.ts +13 -0
  353. package/dist/field/plugins/link-plugin/link/floating-link-editor.d.ts.map +1 -0
  354. package/dist/field/plugins/link-plugin/link/floating-link-editor.js +239 -0
  355. package/dist/field/plugins/link-plugin/link/floating-link-editor.js.map +1 -0
  356. package/dist/field/plugins/link-plugin/link/index.d.ts +2 -0
  357. package/dist/field/plugins/link-plugin/link/index.d.ts.map +1 -0
  358. package/dist/field/plugins/link-plugin/link/index.js +65 -0
  359. package/dist/field/plugins/link-plugin/link/index.js.map +1 -0
  360. package/dist/field/plugins/link-plugin/link/link-drawer.css +21 -0
  361. package/dist/field/plugins/link-plugin/link/link-drawer.d.ts +5 -0
  362. package/dist/field/plugins/link-plugin/link/link-drawer.d.ts.map +1 -0
  363. package/dist/field/plugins/link-plugin/link/link-drawer.js +72 -0
  364. package/dist/field/plugins/link-plugin/link/link-drawer.js.map +1 -0
  365. package/dist/field/plugins/link-plugin/link/types.d.ts +20 -0
  366. package/dist/field/plugins/link-plugin/link/types.d.ts.map +1 -0
  367. package/dist/field/plugins/link-plugin/link/types.js +2 -0
  368. package/dist/field/plugins/link-plugin/link/types.js.map +1 -0
  369. package/dist/field/plugins/table-action-menu-plugin/index.d.ts +6 -0
  370. package/dist/field/plugins/table-action-menu-plugin/index.d.ts.map +1 -0
  371. package/dist/field/plugins/table-action-menu-plugin/index.js +476 -0
  372. package/dist/field/plugins/table-action-menu-plugin/index.js.map +1 -0
  373. package/dist/field/plugins/table-plugin/index.d.ts +4 -0
  374. package/dist/field/plugins/table-plugin/index.d.ts.map +1 -0
  375. package/dist/field/plugins/table-plugin/index.js +30 -0
  376. package/dist/field/plugins/table-plugin/index.js.map +1 -0
  377. package/dist/field/plugins/table-plugin/table-drawer.d.ts +12 -0
  378. package/dist/field/plugins/table-plugin/table-drawer.d.ts.map +1 -0
  379. package/dist/field/plugins/table-plugin/table-drawer.js +42 -0
  380. package/dist/field/plugins/table-plugin/table-drawer.js.map +1 -0
  381. package/dist/field/plugins/toolbar-plugin/index.d.ts +10 -0
  382. package/dist/field/plugins/toolbar-plugin/index.d.ts.map +1 -0
  383. package/dist/field/plugins/toolbar-plugin/index.js +394 -0
  384. package/dist/field/plugins/toolbar-plugin/index.js.map +1 -0
  385. package/dist/field/plugins/treeview-plugin/index.d.ts +10 -0
  386. package/dist/field/plugins/treeview-plugin/index.d.ts.map +1 -0
  387. package/dist/field/plugins/treeview-plugin/index.js +9 -0
  388. package/dist/field/plugins/treeview-plugin/index.js.map +1 -0
  389. package/dist/field/plugins/vimeo-plugin/index.d.ts +4 -0
  390. package/dist/field/plugins/vimeo-plugin/index.d.ts.map +1 -0
  391. package/dist/field/plugins/vimeo-plugin/index.js +29 -0
  392. package/dist/field/plugins/vimeo-plugin/index.js.map +1 -0
  393. package/dist/field/plugins/youtube-plugin/index.d.ts +4 -0
  394. package/dist/field/plugins/youtube-plugin/index.d.ts.map +1 -0
  395. package/dist/field/plugins/youtube-plugin/index.js +29 -0
  396. package/dist/field/plugins/youtube-plugin/index.js.map +1 -0
  397. package/dist/field/rsc-entry.d.ts +9 -0
  398. package/dist/field/rsc-entry.d.ts.map +1 -0
  399. package/dist/field/rsc-entry.js +57 -0
  400. package/dist/field/rsc-entry.js.map +1 -0
  401. package/dist/field/shared/canUseDOM.d.ts +9 -0
  402. package/dist/field/shared/canUseDOM.d.ts.map +1 -0
  403. package/dist/field/shared/canUseDOM.js +9 -0
  404. package/dist/field/shared/canUseDOM.js.map +1 -0
  405. package/dist/field/shared/environment.d.ts +23 -0
  406. package/dist/field/shared/environment.d.ts.map +1 -0
  407. package/dist/field/shared/environment.js +22 -0
  408. package/dist/field/shared/environment.js.map +1 -0
  409. package/dist/field/shared/invariant.d.ts +9 -0
  410. package/dist/field/shared/invariant.d.ts.map +1 -0
  411. package/dist/field/shared/invariant.js +18 -0
  412. package/dist/field/shared/invariant.js.map +1 -0
  413. package/dist/field/shared/simpleDiffWithCursor.d.ts +13 -0
  414. package/dist/field/shared/simpleDiffWithCursor.d.ts.map +1 -0
  415. package/dist/field/shared/simpleDiffWithCursor.js +34 -0
  416. package/dist/field/shared/simpleDiffWithCursor.js.map +1 -0
  417. package/dist/field/shared/useLayoutEffect.d.ts +11 -0
  418. package/dist/field/shared/useLayoutEffect.d.ts.map +1 -0
  419. package/dist/field/shared/useLayoutEffect.js +12 -0
  420. package/dist/field/shared/useLayoutEffect.js.map +1 -0
  421. package/dist/field/shared/warnOnlyOnce.d.ts +9 -0
  422. package/dist/field/shared/warnOnlyOnce.d.ts.map +1 -0
  423. package/dist/field/shared/warnOnlyOnce.js +21 -0
  424. package/dist/field/shared/warnOnlyOnce.js.map +1 -0
  425. package/dist/field/themes/lexical-editor-theme.css +558 -0
  426. package/dist/field/themes/lexical-editor-theme.d.ts +10 -0
  427. package/dist/field/themes/lexical-editor-theme.d.ts.map +1 -0
  428. package/dist/field/themes/lexical-editor-theme.js +105 -0
  429. package/dist/field/themes/lexical-editor-theme.js.map +1 -0
  430. package/dist/field/types.d.ts +10 -0
  431. package/dist/field/types.d.ts.map +1 -0
  432. package/dist/field/types.js +2 -0
  433. package/dist/field/types.js.map +1 -0
  434. package/dist/field/ui/button.css +45 -0
  435. package/dist/field/ui/button.d.ts +19 -0
  436. package/dist/field/ui/button.d.ts.map +1 -0
  437. package/dist/field/ui/button.js +8 -0
  438. package/dist/field/ui/button.js.map +1 -0
  439. package/dist/field/ui/checkbox.css +52 -0
  440. package/dist/field/ui/color-picker.css +88 -0
  441. package/dist/field/ui/color-picker.d.ts +21 -0
  442. package/dist/field/ui/color-picker.d.ts.map +1 -0
  443. package/dist/field/ui/color-picker.js +250 -0
  444. package/dist/field/ui/color-picker.js.map +1 -0
  445. package/dist/field/ui/content-editable-inline.d.ts +13 -0
  446. package/dist/field/ui/content-editable-inline.d.ts.map +1 -0
  447. package/dist/field/ui/content-editable-inline.js +14 -0
  448. package/dist/field/ui/content-editable-inline.js.map +1 -0
  449. package/dist/field/ui/content-editable.css +28 -0
  450. package/dist/field/ui/content-editable.d.ts +13 -0
  451. package/dist/field/ui/content-editable.d.ts.map +1 -0
  452. package/dist/field/ui/content-editable.js +15 -0
  453. package/dist/field/ui/content-editable.js.map +1 -0
  454. package/dist/field/ui/dialog.css +17 -0
  455. package/dist/field/ui/dialog.d.ts +17 -0
  456. package/dist/field/ui/dialog.d.ts.map +1 -0
  457. package/dist/field/ui/dialog.js +10 -0
  458. package/dist/field/ui/dialog.js.map +1 -0
  459. package/dist/field/ui/dropdown.d.ts +25 -0
  460. package/dist/field/ui/dropdown.d.ts.map +1 -0
  461. package/dist/field/ui/dropdown.js +118 -0
  462. package/dist/field/ui/dropdown.js.map +1 -0
  463. package/dist/field/ui/file-input.d.ts +18 -0
  464. package/dist/field/ui/file-input.d.ts.map +1 -0
  465. package/dist/field/ui/file-input.js +17 -0
  466. package/dist/field/ui/file-input.js.map +1 -0
  467. package/dist/field/ui/input.css +32 -0
  468. package/dist/field/ui/modal.css +84 -0
  469. package/dist/field/ui/modal.d.ts +17 -0
  470. package/dist/field/ui/modal.d.ts.map +1 -0
  471. package/dist/field/ui/modal.js +48 -0
  472. package/dist/field/ui/modal.js.map +1 -0
  473. package/dist/field/ui/placeholder-inline.d.ts +14 -0
  474. package/dist/field/ui/placeholder-inline.d.ts.map +1 -0
  475. package/dist/field/ui/placeholder-inline.js +12 -0
  476. package/dist/field/ui/placeholder-inline.js.map +1 -0
  477. package/dist/field/ui/placeholder.css +33 -0
  478. package/dist/field/ui/placeholder.d.ts +14 -0
  479. package/dist/field/ui/placeholder.d.ts.map +1 -0
  480. package/dist/field/ui/placeholder.js +14 -0
  481. package/dist/field/ui/placeholder.js.map +1 -0
  482. package/dist/field/ui/select.css +34 -0
  483. package/dist/field/ui/select.d.ts +16 -0
  484. package/dist/field/ui/select.d.ts.map +1 -0
  485. package/dist/field/ui/select.js +17 -0
  486. package/dist/field/ui/select.js.map +1 -0
  487. package/dist/field/ui/switch.d.ts +15 -0
  488. package/dist/field/ui/switch.d.ts.map +1 -0
  489. package/dist/field/ui/switch.js +8 -0
  490. package/dist/field/ui/switch.js.map +1 -0
  491. package/dist/field/ui/text-input.d.ts +20 -0
  492. package/dist/field/ui/text-input.d.ts.map +1 -0
  493. package/dist/field/ui/text-input.js +18 -0
  494. package/dist/field/ui/text-input.js.map +1 -0
  495. package/dist/field/utils/cloneDeep.d.ts +2 -0
  496. package/dist/field/utils/cloneDeep.d.ts.map +1 -0
  497. package/dist/field/utils/cloneDeep.js +50 -0
  498. package/dist/field/utils/cloneDeep.js.map +1 -0
  499. package/dist/field/utils/deepEqual.d.ts +2 -0
  500. package/dist/field/utils/deepEqual.d.ts.map +1 -0
  501. package/dist/field/utils/deepEqual.js +48 -0
  502. package/dist/field/utils/deepEqual.js.map +1 -0
  503. package/dist/field/utils/emoji-list.d.ts +28 -0
  504. package/dist/field/utils/emoji-list.d.ts.map +1 -0
  505. package/dist/field/utils/emoji-list.js +16613 -0
  506. package/dist/field/utils/emoji-list.js.map +1 -0
  507. package/dist/field/utils/getDOMRangeRect.d.ts +9 -0
  508. package/dist/field/utils/getDOMRangeRect.d.ts.map +1 -0
  509. package/dist/field/utils/getDOMRangeRect.js +23 -0
  510. package/dist/field/utils/getDOMRangeRect.js.map +1 -0
  511. package/dist/field/utils/getSelectedNode.d.ts +3 -0
  512. package/dist/field/utils/getSelectedNode.d.ts.map +1 -0
  513. package/dist/field/utils/getSelectedNode.js +25 -0
  514. package/dist/field/utils/getSelectedNode.js.map +1 -0
  515. package/dist/field/utils/guard.d.ts +9 -0
  516. package/dist/field/utils/guard.d.ts.map +1 -0
  517. package/dist/field/utils/guard.js +11 -0
  518. package/dist/field/utils/guard.js.map +1 -0
  519. package/dist/field/utils/hashSerializedState.d.ts +3 -0
  520. package/dist/field/utils/hashSerializedState.d.ts.map +1 -0
  521. package/dist/field/utils/hashSerializedState.js +32 -0
  522. package/dist/field/utils/hashSerializedState.js.map +1 -0
  523. package/dist/field/utils/isMobileWidth.d.ts +9 -0
  524. package/dist/field/utils/isMobileWidth.d.ts.map +1 -0
  525. package/dist/field/utils/isMobileWidth.js +9 -0
  526. package/dist/field/utils/isMobileWidth.js.map +1 -0
  527. package/dist/field/utils/joinClasses.d.ts +9 -0
  528. package/dist/field/utils/joinClasses.d.ts.map +1 -0
  529. package/dist/field/utils/joinClasses.js +11 -0
  530. package/dist/field/utils/joinClasses.js.map +1 -0
  531. package/dist/field/utils/load-related.d.ts +4 -0
  532. package/dist/field/utils/load-related.d.ts.map +1 -0
  533. package/dist/field/utils/load-related.js +45 -0
  534. package/dist/field/utils/load-related.js.map +1 -0
  535. package/dist/field/utils/point.d.ts +22 -0
  536. package/dist/field/utils/point.d.ts.map +1 -0
  537. package/dist/field/utils/point.js +43 -0
  538. package/dist/field/utils/point.js.map +1 -0
  539. package/dist/field/utils/rect.d.ts +46 -0
  540. package/dist/field/utils/rect.d.ts.map +1 -0
  541. package/dist/field/utils/rect.js +101 -0
  542. package/dist/field/utils/rect.js.map +1 -0
  543. package/dist/field/utils/setFloatingElemPosition.d.ts +2 -0
  544. package/dist/field/utils/setFloatingElemPosition.d.ts.map +1 -0
  545. package/dist/field/utils/setFloatingElemPosition.js +34 -0
  546. package/dist/field/utils/setFloatingElemPosition.js.map +1 -0
  547. package/dist/field/utils/setFloatingElemPositionForLinkEditor.d.ts +2 -0
  548. package/dist/field/utils/setFloatingElemPositionForLinkEditor.d.ts.map +1 -0
  549. package/dist/field/utils/setFloatingElemPositionForLinkEditor.js +33 -0
  550. package/dist/field/utils/setFloatingElemPositionForLinkEditor.js.map +1 -0
  551. package/dist/field/utils/swipe.d.ts +12 -0
  552. package/dist/field/utils/swipe.d.ts.map +1 -0
  553. package/dist/field/utils/swipe.js +100 -0
  554. package/dist/field/utils/swipe.js.map +1 -0
  555. package/dist/field/utils/url.d.ts +11 -0
  556. package/dist/field/utils/url.d.ts.map +1 -0
  557. package/dist/field/utils/url.js +45 -0
  558. package/dist/field/utils/url.js.map +1 -0
  559. package/dist/index.d.ts +3 -0
  560. package/dist/index.d.ts.map +1 -0
  561. package/dist/index.js +3 -0
  562. package/dist/index.js.map +1 -0
  563. package/dist/types.d.ts +33 -0
  564. package/dist/types.d.ts.map +1 -0
  565. package/dist/types.js +2 -0
  566. package/dist/types.js.map +1 -0
  567. package/dist/validate/hasText.d.ts +3 -0
  568. package/dist/validate/hasText.d.ts.map +1 -0
  569. package/dist/validate/hasText.js +29 -0
  570. package/dist/validate/hasText.js.map +1 -0
  571. package/dist/validate/validate-client.d.ts +4 -0
  572. package/dist/validate/validate-client.d.ts.map +1 -0
  573. package/dist/validate/validate-client.js +17 -0
  574. package/dist/validate/validate-client.js.map +1 -0
  575. package/dist/validate/validate-server.d.ts +4 -0
  576. package/dist/validate/validate-server.d.ts.map +1 -0
  577. package/dist/validate/validate-server.js +10 -0
  578. package/dist/validate/validate-server.js.map +1 -0
  579. package/package.json +108 -0
@@ -0,0 +1,236 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ */
10
+ import './index.css';
11
+ import { useCallback, useEffect, useRef, useState } from 'react';
12
+ import { $isCodeHighlightNode } from '@lexical/code';
13
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
14
+ import { mergeRegister } from '@lexical/utils';
15
+ import { formatDrawerSlug, useEditDepth, useModal } from '@payloadcms/ui';
16
+ import { $getSelection, $isParagraphNode, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, } from 'lexical';
17
+ import { createPortal } from 'react-dom';
18
+ import { useEditorConfig } from '../../config/editor-config-context';
19
+ import { $isLinkNode, TOGGLE_LINK_COMMAND } from '../../nodes/link-nodes';
20
+ import { getDOMRangeRect } from '../../utils/getDOMRangeRect';
21
+ import { getSelectedNode } from '../../utils/getSelectedNode';
22
+ import { setFloatingElemPosition } from '../../utils/setFloatingElemPosition';
23
+ function TextFormatFloatingToolbar({ editor, anchorElem, isLink, isBold, isItalic, isUnderline, isCode, isStrikethrough, isSubscript, isSuperscript, }) {
24
+ const popupCharStylesEditorRef = useRef(null);
25
+ const { uuid } = useEditorConfig();
26
+ const editDepth = useEditDepth();
27
+ const { openModal } = useModal();
28
+ const linkDrawerSlug = formatDrawerSlug({
29
+ slug: `rich-text-link-lexical-${uuid}`,
30
+ depth: editDepth,
31
+ });
32
+ const handleOnInsertLink = useCallback(() => {
33
+ if (!isLink) {
34
+ // Only call TOGGLE_LINK_COMMAND and openModal if there is
35
+ // text selected (at least one character).
36
+ const editorState = editor.getEditorState();
37
+ editorState.read(() => {
38
+ const selection = $getSelection();
39
+ if ($isRangeSelection(selection)) {
40
+ if (selection.focus.offset !== selection.anchor.offset) {
41
+ const linkAttributes = {
42
+ linkType: 'custom',
43
+ url: 'https://',
44
+ };
45
+ editor.dispatchCommand(TOGGLE_LINK_COMMAND, linkAttributes);
46
+ // TODO: WARNING: See: link-plugin-payload/floating-link-editor.
47
+ // The Drawer modal is currently wrapped in the floating editor and
48
+ // will only open if $toggleLink in the link node successfully
49
+ // modifies a link now - which will trigger an update in the
50
+ // floating link editor. Not a good way to couple the two.
51
+ openModal(linkDrawerSlug);
52
+ }
53
+ }
54
+ });
55
+ }
56
+ else {
57
+ editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
58
+ }
59
+ }, [editor, isLink, linkDrawerSlug, openModal]);
60
+ const mouseMoveListener = useCallback((e) => {
61
+ if (popupCharStylesEditorRef?.current != null && (e.buttons === 1 || e.buttons === 3)) {
62
+ if (popupCharStylesEditorRef.current.style.pointerEvents !== 'none') {
63
+ const x = e.clientX;
64
+ const y = e.clientY;
65
+ const elementUnderMouse = document.elementFromPoint(x, y);
66
+ if (!popupCharStylesEditorRef.current.contains(elementUnderMouse)) {
67
+ // Mouse is not over the target element => not a normal click, but probably a drag
68
+ popupCharStylesEditorRef.current.style.pointerEvents = 'none';
69
+ }
70
+ }
71
+ }
72
+ }, []);
73
+ const mouseUpListener = useCallback((_e) => {
74
+ if (popupCharStylesEditorRef?.current != null) {
75
+ if (popupCharStylesEditorRef.current.style.pointerEvents !== 'auto') {
76
+ popupCharStylesEditorRef.current.style.pointerEvents = 'auto';
77
+ }
78
+ }
79
+ }, []);
80
+ useEffect(() => {
81
+ if (popupCharStylesEditorRef?.current != null) {
82
+ document.addEventListener('mousemove', mouseMoveListener);
83
+ document.addEventListener('mouseup', mouseUpListener);
84
+ return () => {
85
+ document.removeEventListener('mousemove', mouseMoveListener);
86
+ document.removeEventListener('mouseup', mouseUpListener);
87
+ };
88
+ }
89
+ }, [mouseMoveListener, mouseUpListener]);
90
+ const updateTextFormatFloatingToolbar = useCallback(() => {
91
+ const selection = $getSelection();
92
+ const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
93
+ const nativeSelection = window.getSelection();
94
+ if (popupCharStylesEditorElem === null) {
95
+ return;
96
+ }
97
+ const rootElement = editor.getRootElement();
98
+ if (selection !== null &&
99
+ nativeSelection !== null &&
100
+ !nativeSelection.isCollapsed &&
101
+ rootElement !== null &&
102
+ rootElement.contains(nativeSelection.anchorNode)) {
103
+ const rangeRect = getDOMRangeRect(nativeSelection, rootElement);
104
+ setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem, isLink);
105
+ }
106
+ }, [editor, anchorElem, isLink]);
107
+ useEffect(() => {
108
+ const scrollerElem = anchorElem.parentElement;
109
+ const update = () => {
110
+ editor.getEditorState().read(() => {
111
+ updateTextFormatFloatingToolbar();
112
+ });
113
+ };
114
+ window.addEventListener('resize', update);
115
+ if (scrollerElem != null) {
116
+ scrollerElem.addEventListener('scroll', update);
117
+ }
118
+ return () => {
119
+ window.removeEventListener('resize', update);
120
+ if (scrollerElem != null) {
121
+ scrollerElem.removeEventListener('scroll', update);
122
+ }
123
+ };
124
+ }, [editor, updateTextFormatFloatingToolbar, anchorElem]);
125
+ useEffect(() => {
126
+ editor.getEditorState().read(() => {
127
+ updateTextFormatFloatingToolbar();
128
+ });
129
+ return mergeRegister(editor.registerUpdateListener(({ editorState }) => {
130
+ editorState.read(() => {
131
+ updateTextFormatFloatingToolbar();
132
+ });
133
+ }), editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
134
+ updateTextFormatFloatingToolbar();
135
+ return false;
136
+ }, COMMAND_PRIORITY_LOW));
137
+ }, [editor, updateTextFormatFloatingToolbar]);
138
+ return (_jsx("div", { ref: popupCharStylesEditorRef, className: "floating-text-format-popup", children: editor.isEditable() && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => {
139
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
140
+ }, className: `popup-item spaced ${isBold ? 'active' : ''}`, "aria-label": "Format text as bold", children: _jsx("i", { className: "format bold" }) }), _jsx("button", { type: "button", onClick: () => {
141
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
142
+ }, className: `popup-item spaced ${isItalic ? 'active' : ''}`, "aria-label": "Format text as italics", children: _jsx("i", { className: "format italic" }) }), _jsx("button", { type: "button", onClick: () => {
143
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');
144
+ }, className: `popup-item spaced ${isUnderline ? 'active' : ''}`, "aria-label": "Format text to underlined", children: _jsx("i", { className: "format underline" }) }), _jsx("button", { type: "button", onClick: () => {
145
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
146
+ }, className: `popup-item spaced ${isStrikethrough ? 'active' : ''}`, "aria-label": "Format text with a strikethrough", children: _jsx("i", { className: "format strikethrough" }) }), _jsx("button", { type: "button", onClick: () => {
147
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'subscript');
148
+ }, className: `popup-item spaced ${isSubscript ? 'active' : ''}`, title: "Subscript", "aria-label": "Format Subscript", children: _jsx("i", { className: "format subscript" }) }), _jsx("button", { type: "button", onClick: () => {
149
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'superscript');
150
+ }, className: `popup-item spaced ${isSuperscript ? 'active' : ''}`, title: "Superscript", "aria-label": "Format Superscript", children: _jsx("i", { className: "format superscript" }) }), _jsx("button", { type: "button", onClick: () => {
151
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code');
152
+ }, className: `popup-item spaced ${isCode ? 'active' : ''}`, "aria-label": "Insert code block", children: _jsx("i", { className: "format code" }) }), _jsx("button", { type: "button", onClick: handleOnInsertLink, className: `popup-item spaced ${isLink ? 'active' : ''}`, "aria-label": "Insert link", children: _jsx("i", { className: "format link" }) })] })) }));
153
+ }
154
+ function useFloatingTextFormatToolbar(editor, anchorElem) {
155
+ const [isText, setIsText] = useState(false);
156
+ const [isLink, setIsLink] = useState(false);
157
+ const [isBold, setIsBold] = useState(false);
158
+ const [isItalic, setIsItalic] = useState(false);
159
+ const [isUnderline, setIsUnderline] = useState(false);
160
+ const [isStrikethrough, setIsStrikethrough] = useState(false);
161
+ const [isSubscript, setIsSubscript] = useState(false);
162
+ const [isSuperscript, setIsSuperscript] = useState(false);
163
+ const [isCode, setIsCode] = useState(false);
164
+ const updatePopup = useCallback(() => {
165
+ editor.getEditorState().read(() => {
166
+ // Should not to pop up the floating toolbar when using IME input
167
+ if (editor.isComposing()) {
168
+ return;
169
+ }
170
+ const selection = $getSelection();
171
+ const nativeSelection = window.getSelection();
172
+ const rootElement = editor.getRootElement();
173
+ if (nativeSelection !== null &&
174
+ (!$isRangeSelection(selection) ||
175
+ rootElement === null ||
176
+ !rootElement.contains(nativeSelection.anchorNode))) {
177
+ setIsText(false);
178
+ return;
179
+ }
180
+ if (!$isRangeSelection(selection)) {
181
+ return;
182
+ }
183
+ const node = getSelectedNode(selection);
184
+ // Update text format
185
+ setIsBold(selection.hasFormat('bold'));
186
+ setIsItalic(selection.hasFormat('italic'));
187
+ setIsUnderline(selection.hasFormat('underline'));
188
+ setIsStrikethrough(selection.hasFormat('strikethrough'));
189
+ setIsSubscript(selection.hasFormat('subscript'));
190
+ setIsSuperscript(selection.hasFormat('superscript'));
191
+ setIsCode(selection.hasFormat('code'));
192
+ // Update links
193
+ const parent = node.getParent();
194
+ if ($isLinkNode(parent) || $isLinkNode(node)) {
195
+ setIsLink(true);
196
+ }
197
+ else {
198
+ setIsLink(false);
199
+ }
200
+ if (!$isCodeHighlightNode(selection.anchor.getNode()) && selection.getTextContent() !== '') {
201
+ setIsText($isTextNode(node) || $isParagraphNode(node));
202
+ }
203
+ else {
204
+ setIsText(false);
205
+ }
206
+ const rawTextContent = selection.getTextContent().replace(/\n/g, '');
207
+ if (!selection.isCollapsed() && rawTextContent === '') {
208
+ setIsText(false);
209
+ }
210
+ });
211
+ }, [editor]);
212
+ useEffect(() => {
213
+ document.addEventListener('selectionchange', updatePopup);
214
+ return () => {
215
+ document.removeEventListener('selectionchange', updatePopup);
216
+ };
217
+ }, [updatePopup]);
218
+ useEffect(() => {
219
+ return mergeRegister(editor.registerUpdateListener(() => {
220
+ updatePopup();
221
+ }), editor.registerRootListener(() => {
222
+ if (editor.getRootElement() === null) {
223
+ setIsText(false);
224
+ }
225
+ }));
226
+ }, [editor, updatePopup]);
227
+ if (!isText) {
228
+ return null;
229
+ }
230
+ return createPortal(_jsx(TextFormatFloatingToolbar, { editor: editor, anchorElem: anchorElem, isLink: isLink, isBold: isBold, isItalic: isItalic, isStrikethrough: isStrikethrough, isSubscript: isSubscript, isSuperscript: isSuperscript, isUnderline: isUnderline, isCode: isCode }), anchorElem);
231
+ }
232
+ export function FloatingTextFormatToolbarPlugin({ anchorElem = document.body, }) {
233
+ const [editor] = useLexicalComposerContext();
234
+ return useFloatingTextFormatToolbar(editor, anchorElem);
235
+ }
236
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/field/plugins/floating-text-format-toolbar-plugin/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ;;;;;;GAMG;AAEH,OAAO,aAAa,CAAA;AAGpB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;A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AAW,EAAE,CAAA;QACf,CAAC,CAAC,EACF,MAAM,CAAC,oBAAoB,CAAC,GAAG,EAAE;YAC/B,IAAI,MAAM,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC;gBACrC,SAAS,CAAC,KAAK,CAAC,CAAA;YAClB,CAAC;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;IAEzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,YAAY,CACjB,KAAC,yBAAyB,IACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,GACd,EACF,UAAU,CACX,CAAA;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,EAC9C,UAAU,GAAG,QAAQ,CAAC,IAAI,GAG3B;IACC,MAAM,CAAC,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAA;IAC5C,OAAO,4BAA4B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AACzD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ClientField, CollectionSlug, FormState, OptionObject } from 'payload';
2
+ import type { InlineImageData } from './types';
3
+ export declare const positionOptions: OptionObject[];
4
+ export declare const sizeOptions: OptionObject[];
5
+ export declare const getFields: (imageCollection: CollectionSlug) => ClientField[];
6
+ export declare function getInitialState(data: InlineImageData | undefined): FormState;
7
+ export declare function isAltTextValid(value: string | undefined): boolean;
8
+ export declare function validateFields(fields: FormState): {
9
+ valid: boolean;
10
+ fields: FormState;
11
+ };
12
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/field/plugins/inline-image-plugin/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,eAAO,MAAM,eAAe,EAAE,YAAY,EAiBzC,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,YAAY,EAarC,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,iBAAiB,cAAc,KAAG,WAAW,EAiDtE,CAAA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,SAAS,CAoC5E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEjE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CA0CvF"}
@@ -0,0 +1,160 @@
1
+ export const positionOptions = [
2
+ {
3
+ label: 'Left',
4
+ value: 'left',
5
+ },
6
+ {
7
+ label: 'Right',
8
+ value: 'right',
9
+ },
10
+ {
11
+ label: 'Full',
12
+ value: 'full',
13
+ },
14
+ {
15
+ label: 'Wide',
16
+ value: 'wide',
17
+ },
18
+ ];
19
+ export const sizeOptions = [
20
+ {
21
+ label: 'Small',
22
+ value: 'small',
23
+ },
24
+ {
25
+ label: 'Medium',
26
+ value: 'medium',
27
+ },
28
+ {
29
+ label: 'Auto',
30
+ value: 'auto',
31
+ },
32
+ ];
33
+ export const getFields = (imageCollection) => [
34
+ {
35
+ name: 'image',
36
+ localized: false,
37
+ type: 'upload',
38
+ required: true,
39
+ label: 'Image',
40
+ relationTo: imageCollection,
41
+ },
42
+ {
43
+ name: 'version',
44
+ localized: false,
45
+ type: 'text',
46
+ hidden: true,
47
+ },
48
+ {
49
+ name: 'altText',
50
+ required: true,
51
+ label: 'Alt Text',
52
+ localized: false,
53
+ type: 'text',
54
+ },
55
+ {
56
+ name: 'position',
57
+ localized: false,
58
+ label: 'Position',
59
+ required: true,
60
+ options: positionOptions,
61
+ type: 'select',
62
+ },
63
+ // @ts-expect-error
64
+ {
65
+ name: 'size',
66
+ localized: false,
67
+ label: 'Size',
68
+ required: true,
69
+ options: sizeOptions,
70
+ type: 'select',
71
+ admin: {
72
+ description: "If an inline image is placed in an editor column layout, its position should be set to 'full' and size should be set to 'medium' for 75% columns, and 'small' for equal width and 25% columns. Otherwise set size to 'auto'.",
73
+ },
74
+ },
75
+ {
76
+ name: 'showCaption',
77
+ label: 'Show Caption',
78
+ localized: false,
79
+ type: 'checkbox',
80
+ },
81
+ ];
82
+ export function getInitialState(data) {
83
+ return {
84
+ // TODO: Investigate - would love to have used formState and RenderFields / MappedFields
85
+ // for the Image upload field, but for some reason I could not get a return value
86
+ // for the selected image via handleFormOnChange or handleFormOnSubmit :-(
87
+ // image: {
88
+ // value: '',
89
+ // initialValue: null,
90
+ // valid: true,
91
+ // },
92
+ image: {
93
+ value: data?.id,
94
+ initialValue: data?.id,
95
+ valid: true,
96
+ },
97
+ altText: {
98
+ value: data?.altText,
99
+ initialValue: data?.altText,
100
+ valid: true,
101
+ },
102
+ position: {
103
+ value: data?.position ?? 'full',
104
+ initialValue: data?.position ?? 'full',
105
+ valid: true,
106
+ },
107
+ size: {
108
+ value: data?.size ?? 'auto',
109
+ initialValue: data?.size ?? 'auto',
110
+ valid: true,
111
+ },
112
+ showCaption: {
113
+ value: data?.showCaption ?? false,
114
+ initialValue: data?.showCaption ?? false,
115
+ valid: true,
116
+ },
117
+ };
118
+ }
119
+ export function isAltTextValid(value) {
120
+ return value != null && value.length > 0;
121
+ }
122
+ export function validateFields(fields) {
123
+ let valid = true;
124
+ if (fields.altText != null) {
125
+ if (isAltTextValid(fields.altText.value) === false) {
126
+ fields.altText.valid = false;
127
+ valid = false;
128
+ }
129
+ else {
130
+ fields.altText.valid = true;
131
+ }
132
+ }
133
+ if (fields.position != null) {
134
+ if (fields.position.value !== 'left' &&
135
+ fields.position.value !== 'right' &&
136
+ fields.position.value !== 'full' &&
137
+ fields.position.value !== 'wide') {
138
+ fields.position.valid = false;
139
+ }
140
+ else {
141
+ fields.position.valid = true;
142
+ }
143
+ }
144
+ if (fields.size != null) {
145
+ if (fields.size.value !== 'small' &&
146
+ fields.size.value !== 'medium' &&
147
+ fields.size.value !== 'auto') {
148
+ fields.size.valid = false;
149
+ }
150
+ else {
151
+ fields.size.valid = true;
152
+ }
153
+ }
154
+ // Return
155
+ return {
156
+ valid,
157
+ fields,
158
+ };
159
+ }
160
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../src/field/plugins/inline-image-plugin/fields.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C;QACE,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;KACd;IACD;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD;QACE,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;KACd;IACD;QACE,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;KACd;CACF,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;KACd;CACF,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,eAA+B,EAAiB,EAAE,CAAC;IAC3E;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,I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;QAC/B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;QAC9B,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IACE,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO;YAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ;YAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,EAC5B,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAC3B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,SAAS;IACT,OAAO;QACL,KAAK;QACL,MAAM;KACP,CAAA;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Portions copyright (c) Meta Platforms, Inc.
3
+ * and affiliates and is based on examples found here
4
+ * https://github.com/facebook/lexical/tree/main/packages/lexical-playground
5
+ * - in particular the ImagesPlugin
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+ import type React from 'react';
12
+ import { type LexicalCommand } from 'lexical';
13
+ import type { InlineImageAttributes } from '../../nodes/inline-image-node/types';
14
+ export type InsertInlineImagePayload = Readonly<InlineImageAttributes>;
15
+ export declare const OPEN_INLINE_IMAGE_MODAL_COMMAND: LexicalCommand<null>;
16
+ export declare const INSERT_INLINE_IMAGE_COMMAND: LexicalCommand<InlineImageAttributes>;
17
+ export declare function InlineImagePlugin({ collection }: {
18
+ collection: string;
19
+ }): React.JSX.Element;
20
+ declare global {
21
+ interface DragEvent {
22
+ rangeOffset?: number;
23
+ rangeParent?: Node;
24
+ }
25
+ }
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/field/plugins/inline-image-plugin/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,EAgBL,KAAK,cAAc,EAEpB,MAAM,SAAS,CAAA;AAWhB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAGhF,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAA;AAKtE,eAAO,MAAM,+BAA+B,EAAE,cAAc,CAAC,IAAI,CAEhE,CAAA;AAED,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,qBAAqB,CAE7E,CAAA;AAED,wBAAgB,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA+I3F;AAiGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,SAAS;QACjB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,WAAW,CAAC,EAAE,IAAI,CAAA;KACnB;CACF"}