@soul-refiner/design-system 2.0.0-alpha.18 → 2.0.0-alpha.19

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 (341) hide show
  1. package/dist/_virtual/_cloneBuffer.js +5 -0
  2. package/dist/_virtual/_commonjsHelpers.js +10 -0
  3. package/dist/_virtual/_nodeUtil.js +5 -0
  4. package/dist/_virtual/index.js +5 -0
  5. package/dist/_virtual/index2.js +5 -0
  6. package/dist/_virtual/index3.js +5 -0
  7. package/dist/_virtual/isBuffer.js +5 -0
  8. package/dist/_virtual/use-sync-external-store-shim.development.js +5 -0
  9. package/dist/_virtual/use-sync-external-store-shim.production.min.js +5 -0
  10. package/dist/_virtual/util.js +5 -0
  11. package/dist/_virtual/with-selector.development.js +5 -0
  12. package/dist/_virtual/with-selector.js +5 -0
  13. package/dist/_virtual/with-selector.production.min.js +5 -0
  14. package/dist/node_modules/@udecode/plate-alignment/dist/index.js +98 -0
  15. package/dist/node_modules/@udecode/plate-core/dist/index.js +2656 -0
  16. package/dist/node_modules/@udecode/plate-link/dist/index.js +585 -0
  17. package/dist/node_modules/@udecode/plate-media/dist/index.js +211 -0
  18. package/dist/node_modules/@udecode/plate-normalizers/dist/index.js +20 -0
  19. package/dist/node_modules/@udecode/plate-resizable/dist/index.js +334 -0
  20. package/dist/node_modules/@udecode/plate-table/dist/index.js +1371 -0
  21. package/dist/node_modules/@udecode/plate-utils/dist/index.js +127 -0
  22. package/dist/node_modules/@udecode/slate/dist/index.js +316 -0
  23. package/dist/node_modules/@udecode/slate-react/dist/index.js +35 -0
  24. package/dist/node_modules/@udecode/slate-utils/dist/index.js +230 -0
  25. package/dist/node_modules/@udecode/utils/dist/index.js +61 -0
  26. package/dist/node_modules/clsx/dist/clsx.m.js +8 -0
  27. package/dist/node_modules/dequal/dist/index.js +88 -0
  28. package/dist/node_modules/immer/dist/immer.js +968 -0
  29. package/dist/node_modules/is-hotkey/lib/index.js +253 -0
  30. package/dist/node_modules/jotai/esm/react/utils.js +29 -0
  31. package/dist/node_modules/jotai/esm/react.js +116 -0
  32. package/dist/node_modules/jotai/esm/vanilla/utils.js +44 -0
  33. package/dist/node_modules/jotai/esm/vanilla.js +602 -0
  34. package/dist/node_modules/jotai-optics/dist/index.modern.js +8 -0
  35. package/dist/node_modules/jotai-x/dist/index.js +259 -0
  36. package/dist/node_modules/js-video-url-parser/lib/base.js +9 -0
  37. package/dist/node_modules/js-video-url-parser/lib/provider/allocine.js +38 -0
  38. package/dist/node_modules/js-video-url-parser/lib/provider/canalplus.js +50 -0
  39. package/dist/node_modules/js-video-url-parser/lib/provider/coub.js +58 -0
  40. package/dist/node_modules/js-video-url-parser/lib/provider/dailymotion.js +74 -0
  41. package/dist/node_modules/js-video-url-parser/lib/provider/facebook.js +82 -0
  42. package/dist/node_modules/js-video-url-parser/lib/provider/loom.js +55 -0
  43. package/dist/node_modules/js-video-url-parser/lib/provider/soundcloud.js +129 -0
  44. package/dist/node_modules/js-video-url-parser/lib/provider/teachertube.js +114 -0
  45. package/dist/node_modules/js-video-url-parser/lib/provider/ted.js +100 -0
  46. package/dist/node_modules/js-video-url-parser/lib/provider/tiktok.js +54 -0
  47. package/dist/node_modules/js-video-url-parser/lib/provider/twitch.js +154 -0
  48. package/dist/node_modules/js-video-url-parser/lib/provider/vimeo.js +93 -0
  49. package/dist/node_modules/js-video-url-parser/lib/provider/wistia.js +116 -0
  50. package/dist/node_modules/js-video-url-parser/lib/provider/youku.js +87 -0
  51. package/dist/node_modules/js-video-url-parser/lib/provider/youtube.js +209 -0
  52. package/dist/node_modules/js-video-url-parser/lib/urlParser.js +88 -0
  53. package/dist/node_modules/js-video-url-parser/lib/util.js +112 -0
  54. package/dist/node_modules/lodash/_DataView.js +14 -0
  55. package/dist/node_modules/lodash/_Hash.js +42 -0
  56. package/dist/node_modules/lodash/_ListCache.js +42 -0
  57. package/dist/node_modules/lodash/_Map.js +14 -0
  58. package/dist/node_modules/lodash/_MapCache.js +42 -0
  59. package/dist/node_modules/lodash/_Promise.js +14 -0
  60. package/dist/node_modules/lodash/_Set.js +14 -0
  61. package/dist/node_modules/lodash/_SetCache.js +35 -0
  62. package/dist/node_modules/lodash/_Stack.js +38 -0
  63. package/dist/node_modules/lodash/_Symbol.js +12 -0
  64. package/dist/node_modules/lodash/_Uint8Array.js +12 -0
  65. package/dist/node_modules/lodash/_WeakMap.js +14 -0
  66. package/dist/node_modules/lodash/_apply.js +26 -0
  67. package/dist/node_modules/lodash/_arrayAggregator.js +27 -0
  68. package/dist/node_modules/lodash/_arrayEach.js +27 -0
  69. package/dist/node_modules/lodash/_arrayFilter.js +30 -0
  70. package/dist/node_modules/lodash/_arrayLikeKeys.js +60 -0
  71. package/dist/node_modules/lodash/_arrayMap.js +26 -0
  72. package/dist/node_modules/lodash/_arrayPush.js +25 -0
  73. package/dist/node_modules/lodash/_arraySome.js +28 -0
  74. package/dist/node_modules/lodash/_assignMergeValue.js +27 -0
  75. package/dist/node_modules/lodash/_assignValue.js +35 -0
  76. package/dist/node_modules/lodash/_assocIndexOf.js +27 -0
  77. package/dist/node_modules/lodash/_baseAggregator.js +27 -0
  78. package/dist/node_modules/lodash/_baseAssign.js +24 -0
  79. package/dist/node_modules/lodash/_baseAssignIn.js +24 -0
  80. package/dist/node_modules/lodash/_baseAssignValue.js +31 -0
  81. package/dist/node_modules/lodash/_baseClone.js +193 -0
  82. package/dist/node_modules/lodash/_baseCreate.js +36 -0
  83. package/dist/node_modules/lodash/_baseEach.js +21 -0
  84. package/dist/node_modules/lodash/_baseFlatten.js +45 -0
  85. package/dist/node_modules/lodash/_baseFor.js +22 -0
  86. package/dist/node_modules/lodash/_baseForOwn.js +23 -0
  87. package/dist/node_modules/lodash/_baseGet.js +31 -0
  88. package/dist/node_modules/lodash/_baseGetAllKeys.js +27 -0
  89. package/dist/node_modules/lodash/_baseGetTag.js +36 -0
  90. package/dist/node_modules/lodash/_baseHasIn.js +18 -0
  91. package/dist/node_modules/lodash/_baseIsArguments.js +25 -0
  92. package/dist/node_modules/lodash/_baseIsEqual.js +35 -0
  93. package/dist/node_modules/lodash/_baseIsEqualDeep.js +96 -0
  94. package/dist/node_modules/lodash/_baseIsMap.js +25 -0
  95. package/dist/node_modules/lodash/_baseIsMatch.js +69 -0
  96. package/dist/node_modules/lodash/_baseIsNative.js +56 -0
  97. package/dist/node_modules/lodash/_baseIsSet.js +25 -0
  98. package/dist/node_modules/lodash/_baseIsTypedArray.js +68 -0
  99. package/dist/node_modules/lodash/_baseIteratee.js +41 -0
  100. package/dist/node_modules/lodash/_baseKeys.js +37 -0
  101. package/dist/node_modules/lodash/_baseKeysIn.js +41 -0
  102. package/dist/node_modules/lodash/_baseMap.js +29 -0
  103. package/dist/node_modules/lodash/_baseMatches.js +30 -0
  104. package/dist/node_modules/lodash/_baseMatchesProperty.js +45 -0
  105. package/dist/node_modules/lodash/_baseMerge.js +54 -0
  106. package/dist/node_modules/lodash/_baseMergeDeep.js +114 -0
  107. package/dist/node_modules/lodash/_baseProperty.js +19 -0
  108. package/dist/node_modules/lodash/_basePropertyDeep.js +22 -0
  109. package/dist/node_modules/lodash/_baseRest.js +25 -0
  110. package/dist/node_modules/lodash/_baseSetToString.js +30 -0
  111. package/dist/node_modules/lodash/_baseSlice.js +36 -0
  112. package/dist/node_modules/lodash/_baseTimes.js +25 -0
  113. package/dist/node_modules/lodash/_baseToString.js +46 -0
  114. package/dist/node_modules/lodash/_baseUnary.js +19 -0
  115. package/dist/node_modules/lodash/_baseUnset.js +29 -0
  116. package/dist/node_modules/lodash/_baseValues.js +25 -0
  117. package/dist/node_modules/lodash/_cacheHas.js +18 -0
  118. package/dist/node_modules/lodash/_castPath.js +30 -0
  119. package/dist/node_modules/lodash/_cloneArrayBuffer.js +22 -0
  120. package/dist/node_modules/lodash/_cloneBuffer.js +48 -0
  121. package/dist/node_modules/lodash/_cloneDataView.js +22 -0
  122. package/dist/node_modules/lodash/_cloneRegExp.js +22 -0
  123. package/dist/node_modules/lodash/_cloneSymbol.js +24 -0
  124. package/dist/node_modules/lodash/_cloneTypedArray.js +22 -0
  125. package/dist/node_modules/lodash/_copyArray.js +25 -0
  126. package/dist/node_modules/lodash/_copyObject.js +47 -0
  127. package/dist/node_modules/lodash/_copySymbols.js +23 -0
  128. package/dist/node_modules/lodash/_copySymbolsIn.js +23 -0
  129. package/dist/node_modules/lodash/_coreJsData.js +12 -0
  130. package/dist/node_modules/lodash/_createAggregator.js +32 -0
  131. package/dist/node_modules/lodash/_createAssigner.js +44 -0
  132. package/dist/node_modules/lodash/_createBaseEach.js +38 -0
  133. package/dist/node_modules/lodash/_createBaseFor.js +30 -0
  134. package/dist/node_modules/lodash/_customDefaultsMerge.js +35 -0
  135. package/dist/node_modules/lodash/_customOmitClone.js +22 -0
  136. package/dist/node_modules/lodash/_defineProperty.js +17 -0
  137. package/dist/node_modules/lodash/_equalArrays.js +92 -0
  138. package/dist/node_modules/lodash/_equalByTag.js +123 -0
  139. package/dist/node_modules/lodash/_equalObjects.js +96 -0
  140. package/dist/node_modules/lodash/_flatRest.js +24 -0
  141. package/dist/node_modules/lodash/_freeGlobal.js +11 -0
  142. package/dist/node_modules/lodash/_getAllKeys.js +24 -0
  143. package/dist/node_modules/lodash/_getAllKeysIn.js +25 -0
  144. package/dist/node_modules/lodash/_getMapData.js +24 -0
  145. package/dist/node_modules/lodash/_getMatchData.js +31 -0
  146. package/dist/node_modules/lodash/_getNative.js +24 -0
  147. package/dist/node_modules/lodash/_getPrototype.js +12 -0
  148. package/dist/node_modules/lodash/_getRawTag.js +52 -0
  149. package/dist/node_modules/lodash/_getSymbols.js +37 -0
  150. package/dist/node_modules/lodash/_getSymbolsIn.js +34 -0
  151. package/dist/node_modules/lodash/_getTag.js +70 -0
  152. package/dist/node_modules/lodash/_getValue.js +18 -0
  153. package/dist/node_modules/lodash/_hasPath.js +50 -0
  154. package/dist/node_modules/lodash/_hashClear.js +21 -0
  155. package/dist/node_modules/lodash/_hashDelete.js +22 -0
  156. package/dist/node_modules/lodash/_hashGet.js +36 -0
  157. package/dist/node_modules/lodash/_hashHas.js +29 -0
  158. package/dist/node_modules/lodash/_hashSet.js +29 -0
  159. package/dist/node_modules/lodash/_initCloneArray.js +31 -0
  160. package/dist/node_modules/lodash/_initCloneByTag.js +87 -0
  161. package/dist/node_modules/lodash/_initCloneObject.js +26 -0
  162. package/dist/node_modules/lodash/_isFlattenable.js +28 -0
  163. package/dist/node_modules/lodash/_isIndex.js +30 -0
  164. package/dist/node_modules/lodash/_isIterateeCall.js +39 -0
  165. package/dist/node_modules/lodash/_isKey.js +36 -0
  166. package/dist/node_modules/lodash/_isKeyable.js +20 -0
  167. package/dist/node_modules/lodash/_isMasked.js +26 -0
  168. package/dist/node_modules/lodash/_isPrototype.js +23 -0
  169. package/dist/node_modules/lodash/_isStrictComparable.js +21 -0
  170. package/dist/node_modules/lodash/_listCacheClear.js +18 -0
  171. package/dist/node_modules/lodash/_listCacheDelete.js +41 -0
  172. package/dist/node_modules/lodash/_listCacheGet.js +25 -0
  173. package/dist/node_modules/lodash/_listCacheHas.js +22 -0
  174. package/dist/node_modules/lodash/_listCacheSet.js +32 -0
  175. package/dist/node_modules/lodash/_mapCacheClear.js +29 -0
  176. package/dist/node_modules/lodash/_mapCacheDelete.js +24 -0
  177. package/dist/node_modules/lodash/_mapCacheGet.js +22 -0
  178. package/dist/node_modules/lodash/_mapCacheHas.js +22 -0
  179. package/dist/node_modules/lodash/_mapCacheSet.js +28 -0
  180. package/dist/node_modules/lodash/_mapToArray.js +23 -0
  181. package/dist/node_modules/lodash/_matchesStrictComparable.js +25 -0
  182. package/dist/node_modules/lodash/_memoizeCapped.js +32 -0
  183. package/dist/node_modules/lodash/_nativeCreate.js +12 -0
  184. package/dist/node_modules/lodash/_nativeKeys.js +12 -0
  185. package/dist/node_modules/lodash/_nativeKeysIn.js +25 -0
  186. package/dist/node_modules/lodash/_nodeUtil.js +43 -0
  187. package/dist/node_modules/lodash/_objectToString.js +27 -0
  188. package/dist/node_modules/lodash/_overArg.js +20 -0
  189. package/dist/node_modules/lodash/_overRest.js +42 -0
  190. package/dist/node_modules/lodash/_parent.js +23 -0
  191. package/dist/node_modules/lodash/_root.js +15 -0
  192. package/dist/node_modules/lodash/_safeGet.js +26 -0
  193. package/dist/node_modules/lodash/_setCacheAdd.js +24 -0
  194. package/dist/node_modules/lodash/_setCacheHas.js +19 -0
  195. package/dist/node_modules/lodash/_setToArray.js +23 -0
  196. package/dist/node_modules/lodash/_setToString.js +21 -0
  197. package/dist/node_modules/lodash/_shortOut.js +42 -0
  198. package/dist/node_modules/lodash/_stackClear.js +21 -0
  199. package/dist/node_modules/lodash/_stackDelete.js +23 -0
  200. package/dist/node_modules/lodash/_stackGet.js +19 -0
  201. package/dist/node_modules/lodash/_stackHas.js +19 -0
  202. package/dist/node_modules/lodash/_stackSet.js +42 -0
  203. package/dist/node_modules/lodash/_stringToPath.js +33 -0
  204. package/dist/node_modules/lodash/_toKey.js +27 -0
  205. package/dist/node_modules/lodash/_toSource.js +31 -0
  206. package/dist/node_modules/lodash/castArray.js +55 -0
  207. package/dist/node_modules/lodash/cloneDeep.js +40 -0
  208. package/dist/node_modules/lodash/constant.js +31 -0
  209. package/dist/node_modules/lodash/defaults.js +69 -0
  210. package/dist/node_modules/lodash/defaultsDeep.js +44 -0
  211. package/dist/node_modules/lodash/eq.js +42 -0
  212. package/dist/node_modules/lodash/flatten.js +28 -0
  213. package/dist/node_modules/lodash/get.js +39 -0
  214. package/dist/node_modules/lodash/hasIn.js +41 -0
  215. package/dist/node_modules/lodash/identity.js +26 -0
  216. package/dist/node_modules/lodash/isArguments.js +43 -0
  217. package/dist/node_modules/lodash/isArray.js +31 -0
  218. package/dist/node_modules/lodash/isArrayLike.js +40 -0
  219. package/dist/node_modules/lodash/isArrayLikeObject.js +40 -0
  220. package/dist/node_modules/lodash/isBuffer.js +52 -0
  221. package/dist/node_modules/lodash/isFunction.js +44 -0
  222. package/dist/node_modules/lodash/isLength.js +40 -0
  223. package/dist/node_modules/lodash/isMap.js +35 -0
  224. package/dist/node_modules/lodash/isObject.js +36 -0
  225. package/dist/node_modules/lodash/isObjectLike.js +34 -0
  226. package/dist/node_modules/lodash/isPlainObject.js +70 -0
  227. package/dist/node_modules/lodash/isSet.js +35 -0
  228. package/dist/node_modules/lodash/isSymbol.js +36 -0
  229. package/dist/node_modules/lodash/isTypedArray.js +35 -0
  230. package/dist/node_modules/lodash/keyBy.js +48 -0
  231. package/dist/node_modules/lodash/keys.js +45 -0
  232. package/dist/node_modules/lodash/keysIn.js +40 -0
  233. package/dist/node_modules/lodash/last.js +25 -0
  234. package/dist/node_modules/lodash/map.js +67 -0
  235. package/dist/node_modules/lodash/memoize.js +79 -0
  236. package/dist/node_modules/lodash/merge.js +51 -0
  237. package/dist/node_modules/lodash/mergeWith.js +46 -0
  238. package/dist/node_modules/lodash/omit.js +75 -0
  239. package/dist/node_modules/lodash/property.js +41 -0
  240. package/dist/node_modules/lodash/stubArray.js +28 -0
  241. package/dist/node_modules/lodash/stubFalse.js +23 -0
  242. package/dist/node_modules/lodash/toPlainObject.js +39 -0
  243. package/dist/node_modules/lodash/toString.js +34 -0
  244. package/dist/node_modules/lodash/values.js +46 -0
  245. package/dist/node_modules/lodash.mapvalues/index.js +2290 -0
  246. package/dist/node_modules/optics-ts/dist/mjs/index.js +31 -0
  247. package/dist/node_modules/optics-ts/dist/mjs/internals.js +460 -0
  248. package/dist/node_modules/proxy-compare/dist/index.modern.js +7 -0
  249. package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js +395 -0
  250. package/dist/node_modules/react-tracked/dist/index.modern.js +48 -0
  251. package/dist/node_modules/use-deep-compare/dist-web/index.js +35 -0
  252. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +181 -0
  253. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +32 -0
  254. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +254 -0
  255. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +30 -0
  256. package/dist/node_modules/use-sync-external-store/shim/index.js +21 -0
  257. package/dist/node_modules/use-sync-external-store/shim/with-selector.js +19 -0
  258. package/dist/node_modules/zustand/esm/middleware.js +551 -0
  259. package/dist/node_modules/zustand/esm/traditional.js +25 -0
  260. package/dist/node_modules/zustand/esm/vanilla.js +34 -0
  261. package/dist/node_modules/zustand-x/dist/index.js +217 -0
  262. package/dist/src/common/styles.js +12 -12
  263. package/dist/src/components/actions/button/button.js +11 -10
  264. package/dist/src/components/actions/dropdown/dropdown.js +5 -5
  265. package/dist/src/components/actions/rate/rate.js +2 -2
  266. package/dist/src/components/actions/switch/switch.js +3 -3
  267. package/dist/src/components/actions/toggle/toggle.js +4 -4
  268. package/dist/src/components/actions/upload/upload.js +3 -3
  269. package/dist/src/components/atoms/box/box.js +2 -2
  270. package/dist/src/components/atoms/typography/display.js +2 -2
  271. package/dist/src/components/atoms/typography/heading.js +2 -2
  272. package/dist/src/components/atoms/typography/paragraph.js +2 -2
  273. package/dist/src/components/atoms/typography/typography.js +2 -2
  274. package/dist/src/components/card/action/action.js +6 -6
  275. package/dist/src/components/card/audio/audio.js +5 -5
  276. package/dist/src/components/card/feature/feature.js +7 -7
  277. package/dist/src/components/card/meeting/meeting.js +6 -6
  278. package/dist/src/components/card/person/person.js +5 -5
  279. package/dist/src/components/card/price/price.js +4 -4
  280. package/dist/src/components/card/regular/regular.js +2 -2
  281. package/dist/src/components/card/styles.js +2 -2
  282. package/dist/src/components/card/video/video.js +5 -5
  283. package/dist/src/components/card/written/written.js +5 -5
  284. package/dist/src/components/custom/courses_selection/courses_selection.js +5 -5
  285. package/dist/src/components/custom/users_selection/users_selection.js +6 -6
  286. package/dist/src/components/editor/editor.js +2 -2
  287. package/dist/src/components/editor/navbar/alignment_dropdown.js +3 -3
  288. package/dist/src/components/editor/navbar/button_modal.js +2 -2
  289. package/dist/src/components/editor/navbar/navbar.js +6 -6
  290. package/dist/src/components/editor/plugins/blocks/buttons.js +3 -3
  291. package/dist/src/components/editor/plugins/blocks/image.js +12 -11
  292. package/dist/src/components/editor/plugins/blocks/list.js +2 -2
  293. package/dist/src/components/editor/plugins/blocks/media-popover.js +9 -7
  294. package/dist/src/components/editor/plugins/blocks/qa.js +2 -2
  295. package/dist/src/components/editor/plugins/blocks/resizable.js +3 -3
  296. package/dist/src/components/editor/plugins/blocks/table-cell.js +7 -7
  297. package/dist/src/components/editor/plugins/blocks/table-row.js +2 -2
  298. package/dist/src/components/editor/plugins/blocks/table.js +16 -14
  299. package/dist/src/components/editor/plugins/leafs/leafs.js +2 -2
  300. package/dist/src/components/editor/plugins/leafs/link.js +2 -2
  301. package/dist/src/components/editor/plugins/plate.js +3 -3
  302. package/dist/src/components/editor/simple_editor/navbar.js +4 -4
  303. package/dist/src/components/editor/simple_editor/simple_editor.js +3 -3
  304. package/dist/src/components/editor/styles/menu_button.js +2 -2
  305. package/dist/src/components/feedback/animated_toast/animated_toast.js +3 -3
  306. package/dist/src/components/feedback/badge/badge.js +3 -3
  307. package/dist/src/components/feedback/banner/banner.js +2 -2
  308. package/dist/src/components/feedback/chip/chip.js +3 -3
  309. package/dist/src/components/feedback/loader/loader.js +4 -3
  310. package/dist/src/components/feedback/notification/notification.js +2 -2
  311. package/dist/src/components/feedback/progress/progress.js +5 -5
  312. package/dist/src/components/feedback/toast/toast.js +3 -3
  313. package/dist/src/components/iconography/avatar/avatar.js +6 -6
  314. package/dist/src/components/iconography/icon/icon.js +2 -2
  315. package/dist/src/components/input/calendar/calendar.js +13 -13
  316. package/dist/src/components/input/checkbox/checkbox.js +2 -2
  317. package/dist/src/components/input/date/date.js +13 -13
  318. package/dist/src/components/input/filter/filter.js +11 -10
  319. package/dist/src/components/input/filter/filter_option.js +3 -3
  320. package/dist/src/components/input/radio/radio.js +3 -3
  321. package/dist/src/components/input/search/search.js +4 -4
  322. package/dist/src/components/input/select/select.js +3 -3
  323. package/dist/src/components/input/text_area/text_area.js +6 -6
  324. package/dist/src/components/input/text_input/text_input.js +7 -7
  325. package/dist/src/components/input/time/time.js +3 -3
  326. package/dist/src/components/media/video-player/playlist-item.js +3 -3
  327. package/dist/src/components/media/video-player/video.js +6 -6
  328. package/dist/src/components/navigation/breadcrumb/breadcrumb.js +3 -3
  329. package/dist/src/components/navigation/inner/inner.js +8 -8
  330. package/dist/src/components/navigation/tabs/tabs.js +4 -4
  331. package/dist/src/components/surfaces/accordion/accordion.js +3 -3
  332. package/dist/src/components/surfaces/calendar_date/calendar_date.js +6 -6
  333. package/dist/src/components/surfaces/carousel/card/card.js +4 -4
  334. package/dist/src/components/surfaces/comment/comment.js +10 -10
  335. package/dist/src/components/surfaces/drawer/drawer.js +6 -6
  336. package/dist/src/components/surfaces/message/message.js +2 -2
  337. package/dist/src/components/surfaces/modal/modal.js +3 -3
  338. package/dist/src/components/surfaces/post/post.js +9 -9
  339. package/dist/src/components/table/table/table.js +7 -7
  340. package/dist/src/index.js +0 -1
  341. package/package.json +2 -1
@@ -0,0 +1,2656 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var index = require('../../../jotai-x/dist/index.js');
5
+ var reactHotkeysHook_esm = require('../../../react-hotkeys-hook/dist/react-hotkeys-hook.esm.js');
6
+ var index$1 = require('../../../zustand-x/dist/index.js');
7
+ var index$6 = require('../../slate/dist/index.js');
8
+ var index$4 = require('../../slate-react/dist/index.js');
9
+ var index$7 = require('../../slate-utils/dist/index.js');
10
+ var index$3 = require('../../utils/dist/index.js');
11
+ var defaultsDeep = require('../../../lodash/defaultsDeep.js');
12
+ var slateHistory = require('slate-history');
13
+ var slateReact = require('slate-react');
14
+ var slateHyperscript = require('slate-hyperscript');
15
+ var castArray = require('../../../lodash/castArray.js');
16
+ var keyBy = require('../../../lodash/keyBy.js');
17
+ var merge = require('../../../lodash/merge.js');
18
+ var values = require('../../../lodash/values.js');
19
+ var cloneDeep = require('../../../lodash/cloneDeep.js');
20
+ var clsx_m = require('../../../clsx/dist/clsx.m.js');
21
+ var index$2 = require('../../../is-hotkey/lib/index.js');
22
+ require('../../../lodash/_Stack.js');
23
+ require('../../../lodash/_SetCache.js');
24
+ require('../../../lodash/_equalByTag.js');
25
+ require('../../../lodash/isArguments.js');
26
+ require('../../../lodash/isBuffer.js');
27
+ require('../../../lodash/isTypedArray.js');
28
+ require('../../../lodash/_baseGetTag.js');
29
+ require('../../../lodash/_getTag.js');
30
+ var slate = require('slate');
31
+ var omit = require('../../../lodash/omit.js');
32
+ var index$5 = require('../../../use-deep-compare/dist-web/index.js');
33
+ var index_modern = require('../../../jotai-optics/dist/index.modern.js');
34
+ var utils = require('../../../jotai/esm/vanilla/utils.js');
35
+ var vanilla = require('../../../jotai/esm/vanilla.js');
36
+
37
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
38
+
39
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
40
+
41
+ var __defProp = Object.defineProperty;
42
+ var __defProps = Object.defineProperties;
43
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
44
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
45
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
46
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
47
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
48
+ var __spreadValues = (a, b) => {
49
+ for (var prop in b || (b = {}))
50
+ if (__hasOwnProp.call(b, prop))
51
+ __defNormalProp(a, prop, b[prop]);
52
+ if (__getOwnPropSymbols)
53
+ for (var prop of __getOwnPropSymbols(b)) {
54
+ if (__propIsEnum.call(b, prop))
55
+ __defNormalProp(a, prop, b[prop]);
56
+ }
57
+ return a;
58
+ };
59
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
60
+ var __objRest = (source, exclude) => {
61
+ var target = {};
62
+ for (var prop in source)
63
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
64
+ target[prop] = source[prop];
65
+ if (source != null && __getOwnPropSymbols)
66
+ for (var prop of __getOwnPropSymbols(source)) {
67
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
68
+ target[prop] = source[prop];
69
+ }
70
+ return target;
71
+ };
72
+ function DefaultLeaf(_a) {
73
+ var _b = _a, {
74
+ attributes,
75
+ children,
76
+ text,
77
+ leaf,
78
+ editor,
79
+ nodeProps
80
+ } = _b, props = __objRest(_b, [
81
+ "attributes",
82
+ "children",
83
+ "text",
84
+ "leaf",
85
+ "editor",
86
+ "nodeProps"
87
+ ]);
88
+ return /* @__PURE__ */ React__default.default.createElement("span", __spreadValues(__spreadValues({}, attributes), props), children);
89
+ }
90
+
91
+ // src/stores/element/useElementStore.ts
92
+ var SCOPE_ELEMENT = "element";
93
+ var initialState = {
94
+ element: null
95
+ };
96
+ var { useElementStore, ElementProvider } = index.createAtomStore(
97
+ initialState,
98
+ { name: "element" }
99
+ );
100
+
101
+ // src/stores/element/useElement.ts
102
+ var useElement = (pluginKey = SCOPE_ELEMENT) => {
103
+ const value = useElementStore(pluginKey).get.element();
104
+ if (!value) {
105
+ console.warn(
106
+ `The \`useElement(pluginKey)\` hook must be used inside the node component's context`
107
+ );
108
+ return {};
109
+ }
110
+ return value;
111
+ };
112
+
113
+ // src/stores/event-editor/eventEditorStore.ts
114
+ var eventEditorStore = index$1.createZustandStore("event-editor")({
115
+ blur: null,
116
+ focus: null,
117
+ last: null
118
+ });
119
+ var eventEditorActions = eventEditorStore.set;
120
+ var eventEditorSelectors = eventEditorStore.get;
121
+ eventEditorStore.use;
122
+ var applyDeepToNodes = ({
123
+ node,
124
+ path = [],
125
+ source,
126
+ apply,
127
+ query
128
+ }) => {
129
+ const entry = [node, path];
130
+ if (index$6.queryNode(entry, query)) {
131
+ if (source instanceof Function) {
132
+ apply(node, source());
133
+ } else {
134
+ apply(node, source);
135
+ }
136
+ }
137
+ if (!index$6.isAncestor(node))
138
+ return;
139
+ node.children.forEach((child, index) => {
140
+ applyDeepToNodes({
141
+ node: child,
142
+ path: path.concat([index]),
143
+ source,
144
+ apply,
145
+ query
146
+ });
147
+ });
148
+ };
149
+ var resetEditorChildren = (editor, options) => {
150
+ index$7.replaceNodeChildren(editor, __spreadValues({
151
+ at: [],
152
+ nodes: editor.childrenFactory()
153
+ }, options));
154
+ };
155
+
156
+ // src/transforms/resetEditor.ts
157
+ var resetEditor = (editor) => {
158
+ const isFocused = index$4.isEditorFocused(editor);
159
+ resetEditorChildren(editor);
160
+ editor.history.undos = [];
161
+ editor.history.redos = [];
162
+ editor.operations = [];
163
+ if (isFocused) {
164
+ index$4.focusEditorEdge(editor, { edge: "start" });
165
+ }
166
+ };
167
+
168
+ // src/constants/ELEMENT_DEFAULT.ts
169
+ var ELEMENT_DEFAULT = "p";
170
+
171
+ // src/utils/getPluginsByKey.ts
172
+ var getPluginsByKey = (editor) => {
173
+ var _a;
174
+ return (_a = editor == null ? void 0 : editor.pluginsByKey) != null ? _a : {};
175
+ };
176
+
177
+ // src/utils/getPlugin.ts
178
+ var getPlugin = (editor, key) => {
179
+ var _a;
180
+ return (_a = getPluginsByKey(editor)[key]) != null ? _a : { key };
181
+ };
182
+
183
+ // src/utils/getPluginType.ts
184
+ var getPluginType = (editor, key) => {
185
+ var _a, _b;
186
+ return (_b = (_a = getPlugin(editor, key).type) != null ? _a : key) != null ? _b : "";
187
+ };
188
+ var overridePluginsByKey = (plugin, overrideByKey = {}, nested = false) => {
189
+ var _b;
190
+ if (overrideByKey[plugin.key]) {
191
+ const _a = overrideByKey[plugin.key], {
192
+ plugins: pluginOverridesPlugins,
193
+ then: pluginOverridesThen
194
+ } = _a, pluginOverrides = __objRest(_a, [
195
+ "plugins",
196
+ "then"
197
+ ]);
198
+ plugin = defaultsDeep.default(pluginOverrides, plugin);
199
+ if (!nested) {
200
+ pluginOverridesPlugins == null ? void 0 : pluginOverridesPlugins.forEach((pOverrides) => {
201
+ if (!plugin.plugins)
202
+ plugin.plugins = [];
203
+ const found = plugin.plugins.find((p) => p.key === pOverrides.key);
204
+ if (!found)
205
+ plugin.plugins.push(pOverrides);
206
+ });
207
+ }
208
+ }
209
+ if (plugin.plugins) {
210
+ plugin.plugins = plugin.plugins.map(
211
+ (p) => overridePluginsByKey(p, overrideByKey, true)
212
+ );
213
+ }
214
+ const { then } = plugin;
215
+ if (then) {
216
+ if (plugin._thenReplaced === void 0) {
217
+ plugin._thenReplaced = 0;
218
+ }
219
+ if (plugin._thenReplaced < 3) {
220
+ plugin.then = (editor, p) => {
221
+ const pluginThen = __spreadValues({ key: plugin.key }, then(editor, p));
222
+ return defaultsDeep.default(
223
+ overridePluginsByKey(pluginThen, overrideByKey),
224
+ pluginThen
225
+ );
226
+ };
227
+ plugin._thenReplaced++;
228
+ }
229
+ } else if ((_b = overrideByKey[plugin.key]) == null ? void 0 : _b.then) {
230
+ plugin.then = overrideByKey[plugin.key].then;
231
+ }
232
+ return plugin;
233
+ };
234
+
235
+ // src/utils/createPluginFactory.ts
236
+ var createPluginFactory = (defaultPlugin) => (override, overrideByKey = {}) => {
237
+ overrideByKey[defaultPlugin.key] = override;
238
+ return overridePluginsByKey(
239
+ __spreadValues({}, defaultPlugin),
240
+ overrideByKey
241
+ );
242
+ };
243
+
244
+ // src/plugins/createDeserializeAstPlugin.ts
245
+ var KEY_DESERIALIZE_AST = "deserializeAst";
246
+ var createDeserializeAstPlugin = createPluginFactory({
247
+ key: KEY_DESERIALIZE_AST,
248
+ editor: {
249
+ insertData: {
250
+ format: "application/x-slate-fragment",
251
+ getFragment: ({ data }) => {
252
+ const decoded = decodeURIComponent(window.atob(data));
253
+ let parsed;
254
+ try {
255
+ parsed = JSON.parse(decoded);
256
+ } catch (error) {
257
+ }
258
+ return parsed;
259
+ }
260
+ }
261
+ }
262
+ });
263
+ var getBlockAbove = (editor, options = {}) => index$6.getAboveNode(editor, __spreadProps(__spreadValues({}, options), {
264
+ block: true
265
+ }));
266
+ var isSelectionAtBlockStart = (editor, options) => {
267
+ var _a;
268
+ const { selection } = editor;
269
+ if (!selection)
270
+ return false;
271
+ const path = (_a = getBlockAbove(editor, options)) == null ? void 0 : _a[1];
272
+ if (!path)
273
+ return false;
274
+ return index$6.isStartPoint(editor, selection.focus, path) || index$6.isExpanded(editor.selection) && index$6.isStartPoint(editor, selection.anchor, path);
275
+ };
276
+ var removeSelectionMark = (editor) => {
277
+ const marks = index$6.getMarks(editor);
278
+ if (!marks)
279
+ return;
280
+ Object.keys(marks).forEach((key) => {
281
+ index$6.removeEditorMark(editor, key);
282
+ });
283
+ };
284
+ var KEY_EDITOR_PROTOCOL = "editorProtocol";
285
+ var withEditorProtocol = (editor) => {
286
+ const { deleteBackward, deleteForward, deleteFragment } = editor;
287
+ const resetMarks = () => {
288
+ if (isSelectionAtBlockStart(editor)) {
289
+ removeSelectionMark(editor);
290
+ }
291
+ };
292
+ editor.deleteBackward = (unit) => {
293
+ deleteBackward(unit);
294
+ resetMarks();
295
+ };
296
+ editor.deleteForward = (unit) => {
297
+ deleteForward(unit);
298
+ resetMarks();
299
+ };
300
+ editor.deleteFragment = (direction) => {
301
+ deleteFragment(direction);
302
+ resetMarks();
303
+ };
304
+ return editor;
305
+ };
306
+ var createEditorProtocolPlugin = createPluginFactory({
307
+ key: KEY_EDITOR_PROTOCOL,
308
+ withOverrides: withEditorProtocol
309
+ });
310
+
311
+ // src/plugins/createEventEditorPlugin.ts
312
+ var KEY_EVENT_EDITOR = "event-editor";
313
+ var createEventEditorPlugin = createPluginFactory({
314
+ key: KEY_EVENT_EDITOR,
315
+ handlers: {
316
+ onFocus: (editor) => () => {
317
+ eventEditorActions.focus(editor.id);
318
+ },
319
+ onBlur: (editor) => () => {
320
+ const focus = eventEditorSelectors.focus();
321
+ if (focus === editor.id) {
322
+ eventEditorActions.focus(null);
323
+ }
324
+ eventEditorActions.blur(editor.id);
325
+ }
326
+ }
327
+ });
328
+ var withTHistory = (editor) => slateHistory.withHistory(editor);
329
+ var createHistoryPlugin = createPluginFactory({
330
+ key: "history",
331
+ withOverrides: withTHistory
332
+ });
333
+
334
+ // src/plugins/createInlineVoidPlugin.ts
335
+ var KEY_INLINE_VOID = "inline-void";
336
+ var withInlineVoid = (editor) => {
337
+ const { isInline, isVoid, markableVoid } = editor;
338
+ const voidTypes = [];
339
+ const inlineTypes = [];
340
+ const markableVoidTypes = [];
341
+ editor.plugins.forEach((plugin) => {
342
+ if (plugin.isInline) {
343
+ inlineTypes.push(plugin.type);
344
+ }
345
+ if (plugin.isVoid) {
346
+ voidTypes.push(plugin.type);
347
+ }
348
+ if (plugin.isMarkableVoid) {
349
+ markableVoidTypes.push(plugin.type);
350
+ }
351
+ });
352
+ editor.isInline = (element) => {
353
+ return inlineTypes.includes(element.type) ? true : isInline(element);
354
+ };
355
+ editor.isVoid = (element) => {
356
+ return voidTypes.includes(element.type) ? true : isVoid(element);
357
+ };
358
+ editor.markableVoid = (element) => {
359
+ return markableVoidTypes.includes(element.type) ? true : markableVoid(element);
360
+ };
361
+ return editor;
362
+ };
363
+ var createInlineVoidPlugin = createPluginFactory({
364
+ key: KEY_INLINE_VOID,
365
+ withOverrides: withInlineVoid
366
+ });
367
+
368
+ // src/utils/getInjectedPlugins.ts
369
+ var getInjectedPlugins = (editor, plugin) => {
370
+ const injectedPlugins = [];
371
+ [...editor.plugins].reverse().forEach((p) => {
372
+ var _a;
373
+ const injectedPlugin = (_a = p.inject.pluginsByKey) == null ? void 0 : _a[plugin.key];
374
+ if (injectedPlugin)
375
+ injectedPlugins.push(injectedPlugin);
376
+ });
377
+ return [plugin, ...injectedPlugins];
378
+ };
379
+
380
+ // src/utils/pipeInsertDataQuery.ts
381
+ var pipeInsertDataQuery = (plugins, { data, dataTransfer }) => plugins.every((p) => {
382
+ var _a, _b;
383
+ const query = (_b = (_a = p.editor) == null ? void 0 : _a.insertData) == null ? void 0 : _b.query;
384
+ return !query || query({
385
+ data,
386
+ dataTransfer
387
+ });
388
+ });
389
+ var pipeInsertFragment = (editor, injectedPlugins, _a) => {
390
+ var _b = _a, {
391
+ fragment
392
+ } = _b, options = __objRest(_b, [
393
+ "fragment"
394
+ ]);
395
+ index$6.withoutNormalizing(editor, () => {
396
+ injectedPlugins.some((p) => {
397
+ var _a2, _b2, _c;
398
+ return ((_c = (_b2 = (_a2 = p.editor) == null ? void 0 : _a2.insertData) == null ? void 0 : _b2.preInsert) == null ? void 0 : _c.call(_b2, fragment, options)) === true;
399
+ });
400
+ editor.insertFragment(fragment);
401
+ });
402
+ };
403
+
404
+ // src/utils/pipeTransformData.ts
405
+ var pipeTransformData = (plugins, { data, dataTransfer }) => {
406
+ plugins.forEach((p) => {
407
+ var _a, _b;
408
+ const transformData = (_b = (_a = p.editor) == null ? void 0 : _a.insertData) == null ? void 0 : _b.transformData;
409
+ if (!transformData)
410
+ return;
411
+ data = transformData(data, { dataTransfer });
412
+ });
413
+ return data;
414
+ };
415
+
416
+ // src/utils/pipeTransformFragment.ts
417
+ var pipeTransformFragment = (plugins, _a) => {
418
+ var _b = _a, {
419
+ fragment
420
+ } = _b, options = __objRest(_b, [
421
+ "fragment"
422
+ ]);
423
+ plugins.forEach((p) => {
424
+ var _a2, _b2;
425
+ const transformFragment = (_b2 = (_a2 = p.editor) == null ? void 0 : _a2.insertData) == null ? void 0 : _b2.transformFragment;
426
+ if (!transformFragment)
427
+ return;
428
+ fragment = transformFragment(fragment, options);
429
+ });
430
+ return fragment;
431
+ };
432
+
433
+ // src/plugins/createInsertDataPlugin.ts
434
+ var withInsertData = (editor) => {
435
+ const { insertData } = editor;
436
+ editor.insertData = (dataTransfer) => {
437
+ const inserted = [...editor.plugins].reverse().some((plugin) => {
438
+ const insertDataOptions = plugin.editor.insertData;
439
+ if (!insertDataOptions)
440
+ return false;
441
+ const injectedPlugins = getInjectedPlugins(editor, plugin);
442
+ const { format, getFragment } = insertDataOptions;
443
+ if (!format)
444
+ return false;
445
+ let data = dataTransfer.getData(format);
446
+ if (!data)
447
+ return;
448
+ if (!pipeInsertDataQuery(injectedPlugins, {
449
+ data,
450
+ dataTransfer
451
+ })) {
452
+ return false;
453
+ }
454
+ data = pipeTransformData(injectedPlugins, {
455
+ data,
456
+ dataTransfer
457
+ });
458
+ let fragment = getFragment == null ? void 0 : getFragment({
459
+ data,
460
+ dataTransfer
461
+ });
462
+ if (!(fragment == null ? void 0 : fragment.length))
463
+ return false;
464
+ fragment = pipeTransformFragment(injectedPlugins, {
465
+ fragment,
466
+ data,
467
+ dataTransfer
468
+ });
469
+ if (fragment.length === 0)
470
+ return false;
471
+ pipeInsertFragment(editor, injectedPlugins, {
472
+ fragment,
473
+ data,
474
+ dataTransfer
475
+ });
476
+ return true;
477
+ });
478
+ if (inserted)
479
+ return;
480
+ insertData(dataTransfer);
481
+ };
482
+ return editor;
483
+ };
484
+ var KEY_INSERT_DATA = "insertData";
485
+ var createInsertDataPlugin = createPluginFactory({
486
+ key: KEY_INSERT_DATA,
487
+ withOverrides: withInsertData
488
+ });
489
+ var KEY_LENGTH = "length";
490
+ var withLength = (editor, { options }) => {
491
+ const { apply } = editor;
492
+ editor.apply = (operation) => {
493
+ index$6.withoutNormalizing(editor, () => {
494
+ apply(operation);
495
+ if (options.maxLength) {
496
+ const length = index$6.getEditorString(editor, []).length;
497
+ if (length > options.maxLength) {
498
+ const overflowLength = length - options.maxLength;
499
+ editor.delete({
500
+ unit: "character",
501
+ distance: overflowLength,
502
+ reverse: true
503
+ });
504
+ }
505
+ }
506
+ });
507
+ };
508
+ return editor;
509
+ };
510
+ var createLengthPlugin = createPluginFactory({
511
+ key: KEY_LENGTH,
512
+ withOverrides: withLength
513
+ });
514
+
515
+ // src/plugins/createNodeFactoryPlugin.ts
516
+ var KEY_NODE_FACTORY = "nodeFactory";
517
+ var createNodeFactoryPlugin = createPluginFactory({
518
+ key: KEY_NODE_FACTORY,
519
+ withOverrides: (editor) => {
520
+ editor.blockFactory = (node) => __spreadValues({
521
+ type: getPluginType(editor, ELEMENT_DEFAULT),
522
+ children: [{ text: "" }]
523
+ }, node);
524
+ editor.childrenFactory = () => [editor.blockFactory()];
525
+ return editor;
526
+ }
527
+ });
528
+
529
+ // src/plugins/createPrevSelectionPlugin.ts
530
+ var KEY_PREV_SELECTION = "prevSelection";
531
+ var createPrevSelectionPlugin = createPluginFactory({
532
+ key: KEY_PREV_SELECTION,
533
+ handlers: {
534
+ onKeyDown: (editor) => (e) => {
535
+ e.persist();
536
+ editor.currentKeyboardEvent = e;
537
+ }
538
+ },
539
+ withOverrides: (editor) => {
540
+ const { apply } = editor;
541
+ editor.apply = (operation) => {
542
+ if (operation.type === "set_selection") {
543
+ const { properties } = operation;
544
+ editor.prevSelection = properties;
545
+ apply(operation);
546
+ editor.currentKeyboardEvent = null;
547
+ return;
548
+ }
549
+ apply(operation);
550
+ };
551
+ return editor;
552
+ }
553
+ });
554
+ var withTReact = (editor) => slateReact.withReact(editor);
555
+
556
+ // src/plugins/createReactPlugin.ts
557
+ var createReactPlugin = createPluginFactory({
558
+ key: "react",
559
+ withOverrides: withTReact
560
+ });
561
+ var isInlineNode = (editor) => (node) => index$6.isText(node) || index$6.isElement(node) && editor.isInline(node);
562
+ var makeBlockLazy = (type) => () => ({
563
+ type,
564
+ children: []
565
+ });
566
+ var hasDifferentChildNodes = (descendants, isInline) => {
567
+ return descendants.some((descendant, index, arr) => {
568
+ const prevDescendant = arr[index - 1];
569
+ if (index !== 0) {
570
+ return isInline(descendant) !== isInline(prevDescendant);
571
+ }
572
+ return false;
573
+ });
574
+ };
575
+ var normalizeDifferentNodeTypes = (descendants, isInline, makeDefaultBlock) => {
576
+ const hasDifferentNodes = hasDifferentChildNodes(descendants, isInline);
577
+ const { fragment } = descendants.reduce(
578
+ (memo, node) => {
579
+ if (hasDifferentNodes && isInline(node)) {
580
+ let block = memo.precedingBlock;
581
+ if (!block) {
582
+ block = makeDefaultBlock();
583
+ memo.precedingBlock = block;
584
+ memo.fragment.push(block);
585
+ }
586
+ block.children.push(node);
587
+ } else {
588
+ memo.fragment.push(node);
589
+ memo.precedingBlock = null;
590
+ }
591
+ return memo;
592
+ },
593
+ {
594
+ fragment: [],
595
+ precedingBlock: null
596
+ }
597
+ );
598
+ return fragment;
599
+ };
600
+ var normalizeEmptyChildren = (descendants) => {
601
+ if (descendants.length === 0) {
602
+ return [{ text: "" }];
603
+ }
604
+ return descendants;
605
+ };
606
+ var normalize = (descendants, isInline, makeDefaultBlock) => {
607
+ descendants = normalizeEmptyChildren(descendants);
608
+ descendants = normalizeDifferentNodeTypes(
609
+ descendants,
610
+ isInline,
611
+ makeDefaultBlock
612
+ );
613
+ descendants = descendants.map((node) => {
614
+ if (index$6.isElement(node)) {
615
+ return __spreadProps(__spreadValues({}, node), {
616
+ children: normalize(node.children, isInline, makeDefaultBlock)
617
+ });
618
+ }
619
+ return node;
620
+ });
621
+ return descendants;
622
+ };
623
+ var normalizeDescendantsToDocumentFragment = (editor, { descendants }) => {
624
+ const isInline = isInlineNode(editor);
625
+ const defaultType = getPluginType(editor, ELEMENT_DEFAULT);
626
+ const makeDefaultBlock = makeBlockLazy(defaultType);
627
+ return normalize(descendants, isInline, makeDefaultBlock);
628
+ };
629
+
630
+ // src/plugins/html-deserializer/utils/collapse-white-space/collapseString.ts
631
+ var collapseString = (text, {
632
+ trimStart = "collapse",
633
+ trimEnd = "collapse",
634
+ shouldCollapseWhiteSpace = true,
635
+ whiteSpaceIncludesNewlines = true
636
+ } = {}) => {
637
+ if (trimStart === "all") {
638
+ text = text.replace(/^\s+/, "");
639
+ }
640
+ if (trimEnd === "single-newline") {
641
+ text = text.replace(/\n$/, "");
642
+ }
643
+ if (shouldCollapseWhiteSpace) {
644
+ if (whiteSpaceIncludesNewlines) {
645
+ text = text.replaceAll(/\s+/g, " ");
646
+ } else {
647
+ text = text.replaceAll(/[^\S\n\r]+/g, " ");
648
+ text = text.replaceAll(/^[^\S\n\r]+/gm, "");
649
+ text = text.replaceAll(/[^\S\n\r]+$/gm, "");
650
+ }
651
+ }
652
+ return text;
653
+ };
654
+
655
+ // src/plugins/html-deserializer/utils/inlineTagNames.ts
656
+ var inlineTagNames = /* @__PURE__ */ new Set([
657
+ "A",
658
+ "ABBR",
659
+ "B",
660
+ "BDI",
661
+ "BDO",
662
+ "BR",
663
+ "CITE",
664
+ "CODE",
665
+ "DATA",
666
+ "DFN",
667
+ "EM",
668
+ "I",
669
+ "KBD",
670
+ "MARK",
671
+ "Q",
672
+ "S",
673
+ "SAMP",
674
+ "SMALL",
675
+ "SPAN",
676
+ "STRONG",
677
+ "SUB",
678
+ "SUP",
679
+ "TIME",
680
+ "U",
681
+ "VAR",
682
+ "WBR",
683
+ "IMG",
684
+ "MAP",
685
+ "TRACK",
686
+ "VIDEO",
687
+ "EMBED",
688
+ "IFRAME",
689
+ "OBJECT",
690
+ "PICTURE",
691
+ "PORTAL",
692
+ "SOURCE",
693
+ "svg",
694
+ "math",
695
+ "CANVAS",
696
+ "DEL",
697
+ "INS",
698
+ "BUTTON",
699
+ "INPUT",
700
+ "LABEL",
701
+ "METER",
702
+ "OUTPUT",
703
+ "PROGRESS",
704
+ "SELECT",
705
+ "TEXTAREA",
706
+ "ACRONYM",
707
+ "BIG",
708
+ "CONTENT",
709
+ "FONT",
710
+ "IMG",
711
+ "MARQUEE",
712
+ "MENUITEM",
713
+ "NOBR",
714
+ "SHADOW",
715
+ "STRIKE",
716
+ "TT"
717
+ ]);
718
+
719
+ // src/plugins/html-deserializer/utils/isHtmlElement.ts
720
+ var isHtmlElement = (node) => node.nodeType === Node.ELEMENT_NODE;
721
+
722
+ // src/plugins/html-deserializer/utils/isHtmlInlineElement.ts
723
+ var isHtmlInlineElement = (node) => {
724
+ if (!isHtmlElement(node))
725
+ return false;
726
+ const element = node;
727
+ const tagNameIsInline = inlineTagNames.has(element.tagName);
728
+ const displayProperty = element.style.display.split(" ")[0];
729
+ if (displayProperty === "") {
730
+ return tagNameIsInline;
731
+ }
732
+ if (displayProperty.startsWith("inline")) {
733
+ return true;
734
+ }
735
+ if (displayProperty === "inherit" && element.parentElement) {
736
+ return isHtmlInlineElement(element.parentElement);
737
+ }
738
+ if (["initial", "unset", "revert", "revert-layer", "contents", "none"].includes(
739
+ displayProperty
740
+ )) {
741
+ return tagNameIsInline;
742
+ }
743
+ return false;
744
+ };
745
+
746
+ // src/plugins/html-deserializer/utils/isHtmlText.ts
747
+ var isHtmlText = (node) => node.nodeType === Node.TEXT_NODE;
748
+
749
+ // src/plugins/html-deserializer/utils/isHtmlBlockElement.ts
750
+ var isHtmlBlockElement = (node) => {
751
+ if (!isHtmlElement(node))
752
+ return false;
753
+ const element = node;
754
+ return !isHtmlInlineElement(element);
755
+ };
756
+
757
+ // src/plugins/html-deserializer/utils/collapse-white-space/isLastNonEmptyTextOfInlineFormattingContext.ts
758
+ var isLastNonEmptyTextOfInlineFormattingContext = (initialText) => {
759
+ let currentNode = initialText;
760
+ while (true) {
761
+ if (currentNode.nextSibling) {
762
+ currentNode = currentNode.nextSibling;
763
+ } else {
764
+ currentNode = currentNode.parentElement;
765
+ if (currentNode && isHtmlBlockElement(currentNode)) {
766
+ return true;
767
+ }
768
+ currentNode = (currentNode == null ? void 0 : currentNode.nextSibling) || null;
769
+ }
770
+ if (!currentNode) {
771
+ return true;
772
+ }
773
+ if (isHtmlBlockElement(currentNode)) {
774
+ return true;
775
+ }
776
+ if ((currentNode.textContent || "").length > 0) {
777
+ return false;
778
+ }
779
+ }
780
+ };
781
+
782
+ // src/plugins/html-deserializer/utils/collapse-white-space/stateTransforms.ts
783
+ var upsertInlineFormattingContext = (state) => {
784
+ if (state.inlineFormattingContext) {
785
+ state.inlineFormattingContext.atStart = false;
786
+ } else {
787
+ state.inlineFormattingContext = {
788
+ atStart: true,
789
+ lastHasTrailingWhiteSpace: false
790
+ };
791
+ }
792
+ };
793
+ var endInlineFormattingContext = (state) => {
794
+ state.inlineFormattingContext = null;
795
+ };
796
+
797
+ // src/plugins/html-deserializer/utils/collapse-white-space/collapseWhiteSpaceText.ts
798
+ var collapseWhiteSpaceText = (text, state) => {
799
+ const textContent = text.textContent || "";
800
+ const isWhiteSpaceOnly = textContent.trim() === "";
801
+ if (state.inlineFormattingContext || !isWhiteSpaceOnly) {
802
+ upsertInlineFormattingContext(state);
803
+ }
804
+ const { whiteSpaceRule } = state;
805
+ const trimStart = (() => {
806
+ if (whiteSpaceRule !== "normal")
807
+ return "collapse";
808
+ if (!state.inlineFormattingContext || state.inlineFormattingContext.atStart || state.inlineFormattingContext.lastHasTrailingWhiteSpace)
809
+ return "all";
810
+ return "collapse";
811
+ })();
812
+ const trimEnd = (() => {
813
+ if (whiteSpaceRule === "normal")
814
+ return "collapse";
815
+ if (isLastNonEmptyTextOfInlineFormattingContext(text))
816
+ return "single-newline";
817
+ return "collapse";
818
+ })();
819
+ const shouldCollapseWhiteSpace = {
820
+ normal: true,
821
+ pre: false,
822
+ "pre-line": true
823
+ }[whiteSpaceRule];
824
+ const whiteSpaceIncludesNewlines = whiteSpaceRule !== "pre-line";
825
+ const collapsedTextContent = collapseString(textContent || "", {
826
+ trimStart,
827
+ trimEnd,
828
+ shouldCollapseWhiteSpace,
829
+ whiteSpaceIncludesNewlines
830
+ });
831
+ if (state.inlineFormattingContext && shouldCollapseWhiteSpace) {
832
+ state.inlineFormattingContext.lastHasTrailingWhiteSpace = collapsedTextContent.endsWith(" ");
833
+ }
834
+ text.textContent = collapsedTextContent;
835
+ };
836
+
837
+ // src/plugins/html-deserializer/utils/collapse-white-space/collapseWhiteSpaceNode.ts
838
+ var collapseWhiteSpaceNode = (node, state) => {
839
+ if (isHtmlElement(node)) {
840
+ collapseWhiteSpaceElement(node, state);
841
+ return;
842
+ }
843
+ if (isHtmlText(node)) {
844
+ collapseWhiteSpaceText(node, state);
845
+ return;
846
+ }
847
+ collapseWhiteSpaceChildren(node, state);
848
+ };
849
+
850
+ // src/plugins/html-deserializer/utils/collapse-white-space/collapseWhiteSpaceChildren.ts
851
+ var collapseWhiteSpaceChildren = (node, state) => {
852
+ const childNodes = Array.from(node.childNodes);
853
+ for (const childNode of childNodes) {
854
+ collapseWhiteSpaceNode(childNode, state);
855
+ }
856
+ };
857
+
858
+ // src/plugins/html-deserializer/utils/collapse-white-space/inferWhiteSpaceRule.ts
859
+ var inferWhiteSpaceRule = (element) => {
860
+ const whiteSpaceProperty = element.style.whiteSpace;
861
+ switch (whiteSpaceProperty) {
862
+ case "normal":
863
+ case "nowrap": {
864
+ return "normal";
865
+ }
866
+ case "pre":
867
+ case "pre-wrap":
868
+ case "break-spaces": {
869
+ return "pre";
870
+ }
871
+ case "pre-line": {
872
+ return "pre-line";
873
+ }
874
+ }
875
+ if (element.tagName === "PRE") {
876
+ return "pre";
877
+ }
878
+ if (whiteSpaceProperty === "initial") {
879
+ return "normal";
880
+ }
881
+ return null;
882
+ };
883
+
884
+ // src/plugins/html-deserializer/utils/collapse-white-space/collapseWhiteSpaceElement.ts
885
+ var collapseWhiteSpaceElement = (element, state) => {
886
+ const isInlineElement = isHtmlInlineElement(element);
887
+ const previousWhiteSpaceRule = state.whiteSpaceRule;
888
+ const inferredWhiteSpaceRule = inferWhiteSpaceRule(element);
889
+ if (inferredWhiteSpaceRule) {
890
+ state.whiteSpaceRule = inferredWhiteSpaceRule;
891
+ }
892
+ if (!isInlineElement) {
893
+ endInlineFormattingContext(state);
894
+ }
895
+ collapseWhiteSpaceChildren(element, state);
896
+ if (!isInlineElement) {
897
+ endInlineFormattingContext(state);
898
+ }
899
+ state.whiteSpaceRule = previousWhiteSpaceRule;
900
+ };
901
+
902
+ // src/plugins/html-deserializer/utils/collapse-white-space/collapseWhiteSpace.ts
903
+ var collapseWhiteSpace = (element) => {
904
+ const clonedElement = element.cloneNode(true);
905
+ const state = {
906
+ inlineFormattingContext: null,
907
+ whiteSpaceRule: "normal"
908
+ };
909
+ collapseWhiteSpaceElement(clonedElement, state);
910
+ return clonedElement;
911
+ };
912
+
913
+ // src/plugins/html-deserializer/utils/deserializeHtmlNodeChildren.ts
914
+ var deserializeHtmlNodeChildren = (editor, node) => Array.from(node.childNodes).flatMap(
915
+ deserializeHtmlNode(editor)
916
+ );
917
+
918
+ // src/plugins/html-deserializer/utils/htmlBodyToFragment.ts
919
+ var htmlBodyToFragment = (editor, element) => {
920
+ if (element.nodeName === "BODY") {
921
+ return slateHyperscript.jsx(
922
+ "fragment",
923
+ {},
924
+ deserializeHtmlNodeChildren(editor, element)
925
+ );
926
+ }
927
+ };
928
+
929
+ // src/plugins/html-deserializer/utils/htmlBrToNewLine.ts
930
+ var htmlBrToNewLine = (node) => {
931
+ if (node.nodeName === "BR") {
932
+ return "\n";
933
+ }
934
+ };
935
+ var pluginDeserializeHtml = (editor, plugin, {
936
+ element: el,
937
+ deserializeLeaf
938
+ }) => {
939
+ var _a;
940
+ const {
941
+ deserializeHtml: deserializeHtml2,
942
+ isElement: isElementRoot,
943
+ isLeaf: isLeafRoot,
944
+ type
945
+ } = plugin;
946
+ if (!deserializeHtml2)
947
+ return;
948
+ const {
949
+ attributeNames,
950
+ query,
951
+ isLeaf: isLeafRule,
952
+ isElement: isElementRule,
953
+ rules
954
+ } = deserializeHtml2;
955
+ let { getNode } = deserializeHtml2;
956
+ const isElement4 = isElementRule || isElementRoot;
957
+ const isLeaf = isLeafRule || isLeafRoot;
958
+ if (!deserializeLeaf && !isElement4) {
959
+ return;
960
+ }
961
+ if (deserializeLeaf && !isLeaf) {
962
+ return;
963
+ }
964
+ if (rules) {
965
+ const isValid = rules.some(
966
+ ({ validNodeName = "*", validStyle, validClassName, validAttribute }) => {
967
+ var _a2;
968
+ if (validNodeName) {
969
+ const validNodeNames = castArray.default(validNodeName);
970
+ if (validNodeNames.length > 0 && !validNodeNames.includes(el.nodeName) && validNodeName !== "*")
971
+ return false;
972
+ }
973
+ if (validClassName && !el.classList.contains(validClassName))
974
+ return false;
975
+ if (validStyle) {
976
+ for (const [key, value] of Object.entries(validStyle)) {
977
+ const values2 = castArray.default(value);
978
+ if (!values2.includes(el.style[key]) && value !== "*")
979
+ return;
980
+ if (value === "*" && !el.style[key])
981
+ return;
982
+ const defaultNodeValue = (_a2 = plugin.inject.props) == null ? void 0 : _a2.defaultNodeValue;
983
+ if (defaultNodeValue && defaultNodeValue === el.style[key]) {
984
+ return false;
985
+ }
986
+ }
987
+ }
988
+ if (validAttribute) {
989
+ if (typeof validAttribute === "string") {
990
+ if (!el.getAttributeNames().includes(validAttribute))
991
+ return false;
992
+ } else {
993
+ for (const [attributeName, attributeValue] of Object.entries(
994
+ validAttribute
995
+ )) {
996
+ const attributeValues = castArray.default(attributeValue);
997
+ const elAttribute = el.getAttribute(attributeName);
998
+ if (!index$3.isDefined(elAttribute) || !attributeValues.includes(elAttribute))
999
+ return false;
1000
+ }
1001
+ }
1002
+ }
1003
+ return true;
1004
+ }
1005
+ );
1006
+ if (!isValid)
1007
+ return;
1008
+ }
1009
+ if (query && !query(el)) {
1010
+ return;
1011
+ }
1012
+ if (!getNode) {
1013
+ if (isElement4) {
1014
+ getNode = () => ({ type });
1015
+ } else if (isLeaf) {
1016
+ getNode = () => ({ [type]: true });
1017
+ } else {
1018
+ return;
1019
+ }
1020
+ }
1021
+ let node = (_a = getNode(el, {})) != null ? _a : {};
1022
+ if (Object.keys(node).length === 0)
1023
+ return;
1024
+ const injectedPlugins = getInjectedPlugins(editor, plugin);
1025
+ injectedPlugins.forEach((injectedPlugin) => {
1026
+ var _a2, _b;
1027
+ const res = (_b = (_a2 = injectedPlugin.deserializeHtml) == null ? void 0 : _a2.getNode) == null ? void 0 : _b.call(_a2, el, node);
1028
+ if (res) {
1029
+ node = __spreadValues(__spreadValues({}, node), res);
1030
+ }
1031
+ });
1032
+ if (attributeNames) {
1033
+ const elementAttributes = {};
1034
+ const elementAttributeNames = el.getAttributeNames();
1035
+ for (const elementAttributeName of elementAttributeNames) {
1036
+ if (attributeNames.includes(elementAttributeName)) {
1037
+ elementAttributes[elementAttributeName] = el.getAttribute(elementAttributeName);
1038
+ }
1039
+ }
1040
+ if (Object.keys(elementAttributes).length > 0) {
1041
+ node.attributes = elementAttributes;
1042
+ }
1043
+ }
1044
+ return __spreadProps(__spreadValues({}, deserializeHtml2), { node });
1045
+ };
1046
+
1047
+ // src/plugins/html-deserializer/utils/pipeDeserializeHtmlElement.ts
1048
+ var pipeDeserializeHtmlElement = (editor, element) => {
1049
+ let result;
1050
+ [...editor.plugins].reverse().some((plugin) => {
1051
+ result = pluginDeserializeHtml(editor, plugin, { element });
1052
+ return !!result;
1053
+ });
1054
+ return result;
1055
+ };
1056
+
1057
+ // src/plugins/html-deserializer/utils/htmlElementToElement.ts
1058
+ var htmlElementToElement = (editor, element) => {
1059
+ var _a;
1060
+ const deserialized = pipeDeserializeHtmlElement(editor, element);
1061
+ if (deserialized) {
1062
+ const { node, withoutChildren } = deserialized;
1063
+ let descendants = (_a = node.children) != null ? _a : deserializeHtmlNodeChildren(editor, element);
1064
+ if (descendants.length === 0 || withoutChildren) {
1065
+ descendants = [{ text: "" }];
1066
+ }
1067
+ return slateHyperscript.jsx("element", node, descendants);
1068
+ }
1069
+ };
1070
+
1071
+ // src/plugins/html-deserializer/utils/pipeDeserializeHtmlLeaf.ts
1072
+ var pipeDeserializeHtmlLeaf = (editor, element) => {
1073
+ let node = {};
1074
+ [...editor.plugins].reverse().forEach((plugin) => {
1075
+ const deserialized = pluginDeserializeHtml(editor, plugin, {
1076
+ element,
1077
+ deserializeLeaf: true
1078
+ });
1079
+ if (!deserialized)
1080
+ return;
1081
+ node = __spreadValues(__spreadValues({}, node), deserialized.node);
1082
+ });
1083
+ return node;
1084
+ };
1085
+
1086
+ // src/plugins/html-deserializer/utils/htmlElementToLeaf.ts
1087
+ var htmlElementToLeaf = (editor, element) => {
1088
+ const node = pipeDeserializeHtmlLeaf(editor, element);
1089
+ return deserializeHtmlNodeChildren(editor, element).reduce(
1090
+ (arr, child) => {
1091
+ if (!child)
1092
+ return arr;
1093
+ if (index$6.isElement(child)) {
1094
+ if (Object.keys(node).length > 0) {
1095
+ mergeDeepToNodes({
1096
+ node: child,
1097
+ source: node,
1098
+ query: {
1099
+ filter: ([n]) => index$6.isText(n)
1100
+ }
1101
+ });
1102
+ }
1103
+ arr.push(child);
1104
+ } else {
1105
+ const attributes = __spreadValues({}, node);
1106
+ if (index$6.isText(child) && child.text) {
1107
+ Object.keys(attributes).forEach((key) => {
1108
+ if (attributes[key] && child[key]) {
1109
+ attributes[key] = child[key];
1110
+ }
1111
+ });
1112
+ }
1113
+ arr.push(slateHyperscript.jsx("text", attributes, child));
1114
+ }
1115
+ return arr;
1116
+ },
1117
+ []
1118
+ );
1119
+ };
1120
+
1121
+ // src/plugins/html-deserializer/utils/htmlTextNodeToString.ts
1122
+ var htmlTextNodeToString = (node) => {
1123
+ if (isHtmlText(node)) {
1124
+ return node.textContent || "";
1125
+ }
1126
+ };
1127
+
1128
+ // src/plugins/html-deserializer/utils/deserializeHtmlNode.ts
1129
+ var deserializeHtmlNode = (editor) => (node) => {
1130
+ const textNode = htmlTextNodeToString(node);
1131
+ if (textNode)
1132
+ return textNode;
1133
+ if (!isHtmlElement(node))
1134
+ return null;
1135
+ const breakLine = htmlBrToNewLine(node);
1136
+ if (breakLine)
1137
+ return breakLine;
1138
+ const fragment = htmlBodyToFragment(editor, node);
1139
+ if (fragment)
1140
+ return fragment;
1141
+ const element = htmlElementToElement(editor, node);
1142
+ if (element)
1143
+ return element;
1144
+ return htmlElementToLeaf(editor, node);
1145
+ };
1146
+
1147
+ // src/plugins/html-deserializer/utils/deserializeHtmlElement.ts
1148
+ var deserializeHtmlElement = (editor, element) => {
1149
+ return deserializeHtmlNode(editor)(element);
1150
+ };
1151
+
1152
+ // src/plugins/html-deserializer/utils/htmlStringToDOMNode.ts
1153
+ var htmlStringToDOMNode = (rawHtml) => {
1154
+ const node = document.createElement("body");
1155
+ node.innerHTML = rawHtml;
1156
+ return node;
1157
+ };
1158
+
1159
+ // src/plugins/html-deserializer/utils/deserializeHtml.ts
1160
+ var deserializeHtml = (editor, {
1161
+ element,
1162
+ collapseWhiteSpace: shouldCollapseWhiteSpace = true
1163
+ }) => {
1164
+ if (typeof element === "string") {
1165
+ element = htmlStringToDOMNode(element);
1166
+ }
1167
+ if (shouldCollapseWhiteSpace) {
1168
+ element = collapseWhiteSpace(element);
1169
+ }
1170
+ const fragment = deserializeHtmlElement(editor, element);
1171
+ return normalizeDescendantsToDocumentFragment(editor, {
1172
+ descendants: fragment
1173
+ });
1174
+ };
1175
+
1176
+ // src/plugins/html-deserializer/utils/parseHtmlDocument.ts
1177
+ var parseHtmlDocument = (html) => {
1178
+ return new DOMParser().parseFromString(html, "text/html");
1179
+ };
1180
+
1181
+ // src/plugins/html-deserializer/createDeserializeHtmlPlugin.ts
1182
+ var KEY_DESERIALIZE_HTML = "deserializeHtml";
1183
+ var createDeserializeHtmlPlugin = createPluginFactory({
1184
+ key: KEY_DESERIALIZE_HTML,
1185
+ then: (editor) => ({
1186
+ editor: {
1187
+ insertData: {
1188
+ format: "text/html",
1189
+ getFragment: ({ data }) => {
1190
+ const document2 = parseHtmlDocument(data);
1191
+ return deserializeHtml(editor, {
1192
+ element: document2.body
1193
+ });
1194
+ }
1195
+ }
1196
+ }
1197
+ })
1198
+ });
1199
+ var mergeDeepPlugins = (editor, _plugin) => {
1200
+ const plugin = __spreadValues({}, _plugin);
1201
+ const { then } = plugin;
1202
+ if (then) {
1203
+ delete plugin.then;
1204
+ const { plugins: pluginPlugins } = plugin;
1205
+ const pluginThen = mergeDeepPlugins(
1206
+ editor,
1207
+ defaultsDeep.default(then(editor, plugin), plugin)
1208
+ );
1209
+ if (pluginPlugins && pluginThen.plugins) {
1210
+ const merged = merge.default(
1211
+ keyBy.default(pluginPlugins, "key"),
1212
+ keyBy.default(pluginThen.plugins, "key")
1213
+ );
1214
+ pluginThen.plugins = values.default(merged);
1215
+ }
1216
+ return pluginThen;
1217
+ }
1218
+ return plugin;
1219
+ };
1220
+
1221
+ // src/utils/setDefaultPlugin.ts
1222
+ var setDefaultPlugin = (plugin) => {
1223
+ if (plugin.type === void 0)
1224
+ plugin.type = plugin.key;
1225
+ if (!plugin.options)
1226
+ plugin.options = {};
1227
+ if (!plugin.inject)
1228
+ plugin.inject = {};
1229
+ if (!plugin.editor)
1230
+ plugin.editor = {};
1231
+ return plugin;
1232
+ };
1233
+
1234
+ // src/utils/flattenDeepPlugins.ts
1235
+ var flattenDeepPlugins = (editor, plugins) => {
1236
+ if (!plugins)
1237
+ return;
1238
+ plugins.forEach((plugin) => {
1239
+ let p = setDefaultPlugin(plugin);
1240
+ p = mergeDeepPlugins(editor, p);
1241
+ if (p.enabled === false)
1242
+ return;
1243
+ if (editor.pluginsByKey[p.key]) {
1244
+ const index = editor.plugins.indexOf(editor.pluginsByKey[p.key]);
1245
+ const mergedPlugin = defaultsDeep.default(p, editor.pluginsByKey[p.key]);
1246
+ if (index >= 0) {
1247
+ editor.plugins[index] = mergedPlugin;
1248
+ }
1249
+ editor.pluginsByKey[p.key] = mergedPlugin;
1250
+ } else {
1251
+ editor.plugins.push(p);
1252
+ editor.pluginsByKey[p.key] = p;
1253
+ }
1254
+ flattenDeepPlugins(editor, p.plugins);
1255
+ });
1256
+ };
1257
+
1258
+ // src/utils/setPlatePlugins.ts
1259
+ var setPlatePlugins = (editor, {
1260
+ disableCorePlugins,
1261
+ plugins: _plugins = [],
1262
+ maxLength
1263
+ }) => {
1264
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
1265
+ let plugins = [];
1266
+ if (disableCorePlugins !== true) {
1267
+ const dcp = disableCorePlugins;
1268
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.react)) {
1269
+ plugins.push((_b = (_a = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _a.react) != null ? _b : createReactPlugin());
1270
+ }
1271
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.history)) {
1272
+ plugins.push(
1273
+ (_d = (_c = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _c.history) != null ? _d : createHistoryPlugin()
1274
+ );
1275
+ }
1276
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.nodeFactory)) {
1277
+ plugins.push(
1278
+ (_f = (_e = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _e[KEY_NODE_FACTORY]) != null ? _f : createNodeFactoryPlugin()
1279
+ );
1280
+ }
1281
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.eventEditor)) {
1282
+ plugins.push(
1283
+ (_h = (_g = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _g[KEY_EVENT_EDITOR]) != null ? _h : createEventEditorPlugin()
1284
+ );
1285
+ }
1286
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.inlineVoid)) {
1287
+ plugins.push(
1288
+ (_j = (_i = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _i[KEY_INLINE_VOID]) != null ? _j : createInlineVoidPlugin()
1289
+ );
1290
+ }
1291
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.insertData)) {
1292
+ plugins.push(
1293
+ (_l = (_k = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _k[KEY_INSERT_DATA]) != null ? _l : createInsertDataPlugin()
1294
+ );
1295
+ }
1296
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.selection)) {
1297
+ plugins.push(
1298
+ (_n = (_m = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _m[KEY_PREV_SELECTION]) != null ? _n : createPrevSelectionPlugin()
1299
+ );
1300
+ }
1301
+ if ((typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.length)) && index$3.isDefined(maxLength)) {
1302
+ plugins.push(
1303
+ (_p = (_o = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _o[KEY_LENGTH]) != null ? _p : createLengthPlugin({
1304
+ options: {
1305
+ maxLength
1306
+ }
1307
+ })
1308
+ );
1309
+ }
1310
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.deserializeHtml)) {
1311
+ plugins.push(
1312
+ (_r = (_q = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _q[KEY_DESERIALIZE_HTML]) != null ? _r : createDeserializeHtmlPlugin()
1313
+ );
1314
+ }
1315
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.deserializeAst)) {
1316
+ plugins.push(
1317
+ (_t = (_s = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _s[KEY_DESERIALIZE_AST]) != null ? _t : createDeserializeAstPlugin()
1318
+ );
1319
+ }
1320
+ if (typeof dcp !== "object" || !(dcp == null ? void 0 : dcp.editorProtocol)) {
1321
+ plugins.push(
1322
+ (_v = (_u = editor == null ? void 0 : editor.pluginsByKey) == null ? void 0 : _u[KEY_EDITOR_PROTOCOL]) != null ? _v : createEditorProtocolPlugin()
1323
+ );
1324
+ }
1325
+ }
1326
+ plugins = [...plugins, ..._plugins];
1327
+ editor.plugins = [];
1328
+ editor.pluginsByKey = {};
1329
+ flattenDeepPlugins(editor, plugins);
1330
+ editor.plugins.forEach((plugin) => {
1331
+ if (plugin.overrideByKey) {
1332
+ const newPlugins = editor.plugins.map((p) => {
1333
+ return overridePluginsByKey(p, plugin.overrideByKey);
1334
+ });
1335
+ editor.plugins = [];
1336
+ editor.pluginsByKey = {};
1337
+ flattenDeepPlugins(editor, newPlugins);
1338
+ }
1339
+ });
1340
+ };
1341
+
1342
+ // src/plugins/withPlate.ts
1343
+ var shouldHaveBeenOverridden = (fnName) => () => {
1344
+ console.warn(
1345
+ `editor.${fnName} should have been overriden but was not. Please report this issue here: https://github.com/udecode/plate/issues`
1346
+ );
1347
+ };
1348
+ var withPlate = (e, {
1349
+ id,
1350
+ plugins = [],
1351
+ disableCorePlugins,
1352
+ maxLength
1353
+ } = {}) => {
1354
+ let editor = e;
1355
+ editor.id = id != null ? id : editor.id;
1356
+ editor.prevSelection = null;
1357
+ editor.isFallback = false;
1358
+ editor.currentKeyboardEvent = null;
1359
+ editor.reset = () => resetEditor(editor);
1360
+ editor.redecorate = () => shouldHaveBeenOverridden("redecorate");
1361
+ editor.plate = {
1362
+ get set() {
1363
+ return null;
1364
+ }
1365
+ };
1366
+ if (!editor.key) {
1367
+ editor.key = Math.random();
1368
+ }
1369
+ setPlatePlugins(editor, {
1370
+ plugins,
1371
+ maxLength,
1372
+ disableCorePlugins
1373
+ });
1374
+ editor.plugins.forEach((plugin) => {
1375
+ if (plugin.withOverrides) {
1376
+ editor = plugin.withOverrides(editor, plugin);
1377
+ }
1378
+ });
1379
+ return editor;
1380
+ };
1381
+ var createPlugins = (plugins, {
1382
+ components,
1383
+ overrideByKey
1384
+ } = {}) => {
1385
+ let allOverrideByKey = {};
1386
+ if (overrideByKey) {
1387
+ allOverrideByKey = cloneDeep.default(overrideByKey);
1388
+ }
1389
+ if (components) {
1390
+ Object.keys(components).forEach((key) => {
1391
+ if (!allOverrideByKey[key])
1392
+ allOverrideByKey[key] = {};
1393
+ allOverrideByKey[key].component = components[key];
1394
+ });
1395
+ }
1396
+ if (Object.keys(allOverrideByKey).length > 0) {
1397
+ return plugins.map((plugin) => {
1398
+ return overridePluginsByKey(plugin, allOverrideByKey);
1399
+ });
1400
+ }
1401
+ return plugins;
1402
+ };
1403
+
1404
+ // src/utils/createPlateEditor.ts
1405
+ var createPlateEditor = (_a = {}) => {
1406
+ var _b = _a, {
1407
+ editor = index$6.createTEditor(),
1408
+ plugins = [],
1409
+ components,
1410
+ overrideByKey,
1411
+ normalizeInitialValue: shouldNormalizeInitialValue
1412
+ } = _b, withPlateOptions = __objRest(_b, [
1413
+ "editor",
1414
+ "plugins",
1415
+ "components",
1416
+ "overrideByKey",
1417
+ "normalizeInitialValue"
1418
+ ]);
1419
+ plugins = createPlugins(plugins, {
1420
+ components,
1421
+ overrideByKey
1422
+ });
1423
+ const e = withPlate(editor, __spreadValues({
1424
+ plugins
1425
+ }, withPlateOptions));
1426
+ if (shouldNormalizeInitialValue) {
1427
+ index$6.normalizeEditor(e, { force: true });
1428
+ }
1429
+ return e;
1430
+ };
1431
+
1432
+ // src/utils/createPlateFallbackEditor.ts
1433
+ var createPlateFallbackEditor = (options = {}) => {
1434
+ const editor = createPlateEditor(options);
1435
+ editor.isFallback = true;
1436
+ editor.apply = () => {
1437
+ throw new Error(
1438
+ "Cannot apply operations on the fallback editor. The fallback editor is used when a hook that depends on the Plate store was unable to locate a valid store. If you are using PlateController, use `useEditorMounted(id?: PlateId)` or `!editor.isFallback` to ensure that a valid Plate store is available before attempting to call operations on the editor."
1439
+ );
1440
+ };
1441
+ return editor;
1442
+ };
1443
+
1444
+ // src/utils/getPluginInjectProps.ts
1445
+ var getPluginInjectProps = (editor, key) => {
1446
+ var _a, _b;
1447
+ return (_b = (_a = getPlugin(editor, key).inject) == null ? void 0 : _a.props) != null ? _b : {};
1448
+ };
1449
+
1450
+ // src/utils/getPluginOptions.ts
1451
+ var getPluginOptions = (editor, key) => {
1452
+ var _a;
1453
+ return (_a = getPlugin(editor, key).options) != null ? _a : {};
1454
+ };
1455
+
1456
+ // src/utils/getPluginTypes.ts
1457
+ var getPluginTypes = (editor, keys) => keys.map((key) => getPluginType(editor, key));
1458
+
1459
+ // src/utils/misc/getSlateClass.ts
1460
+ var getSlateClass = (type) => `slate-${type}`;
1461
+
1462
+ // src/utils/getRenderNodeProps.ts
1463
+ var getRenderNodeProps = ({
1464
+ attributes,
1465
+ nodeProps,
1466
+ props,
1467
+ type
1468
+ }) => {
1469
+ var _a;
1470
+ let newProps = {};
1471
+ if (props) {
1472
+ newProps = (_a = typeof props === "function" ? props(nodeProps) : props) != null ? _a : {};
1473
+ }
1474
+ if (!newProps.nodeProps && attributes) {
1475
+ newProps.nodeProps = attributes;
1476
+ }
1477
+ nodeProps = __spreadValues(__spreadValues({}, nodeProps), newProps);
1478
+ if (nodeProps.nodeProps) {
1479
+ Object.keys(nodeProps.nodeProps).forEach((key) => {
1480
+ var _a2, _b;
1481
+ if (((_a2 = nodeProps.nodeProps) == null ? void 0 : _a2[key]) === void 0) {
1482
+ (_b = nodeProps.nodeProps) == null ? true : delete _b[key];
1483
+ }
1484
+ });
1485
+ }
1486
+ const { className } = nodeProps;
1487
+ return __spreadProps(__spreadValues({}, nodeProps), { className: clsx_m.clsx(getSlateClass(type), className) });
1488
+ };
1489
+ var HOTKEYS = {
1490
+ bold: "mod+b",
1491
+ compose: ["down", "left", "right", "up", "backspace", "enter"],
1492
+ deleteBackward: "shift?+backspace",
1493
+ deleteForward: "shift?+delete",
1494
+ extendBackward: "shift+left",
1495
+ extendForward: "shift+right",
1496
+ insertSoftBreak: "shift+enter",
1497
+ italic: "mod+i",
1498
+ moveBackward: "left",
1499
+ moveForward: "right",
1500
+ moveWordBackward: "ctrl+left",
1501
+ moveWordForward: "ctrl+right",
1502
+ splitBlock: "enter",
1503
+ tab: "tab",
1504
+ untab: "shift+tab",
1505
+ undo: "mod+z"
1506
+ };
1507
+ var APPLE_HOTKEYS = {
1508
+ deleteBackward: ["ctrl+backspace", "ctrl+h"],
1509
+ deleteForward: ["ctrl+delete", "ctrl+d"],
1510
+ deleteLineBackward: "cmd+shift?+backspace",
1511
+ deleteLineForward: ["cmd+shift?+delete", "ctrl+k"],
1512
+ deleteWordBackward: "opt+shift?+backspace",
1513
+ deleteWordForward: "opt+shift?+delete",
1514
+ extendLineBackward: "opt+shift+up",
1515
+ extendLineForward: "opt+shift+down",
1516
+ moveLineBackward: "opt+up",
1517
+ moveLineForward: "opt+down",
1518
+ moveWordBackward: "opt+left",
1519
+ moveWordForward: "opt+right",
1520
+ redo: "cmd+shift+z",
1521
+ transposeCharacter: "ctrl+t"
1522
+ };
1523
+ var WINDOWS_HOTKEYS = {
1524
+ deleteWordBackward: "ctrl+shift?+backspace",
1525
+ deleteWordForward: "ctrl+shift?+delete",
1526
+ redo: ["ctrl+y", "ctrl+shift+z"]
1527
+ };
1528
+ var create = (key) => {
1529
+ const generic = HOTKEYS[key];
1530
+ const apple = APPLE_HOTKEYS[key];
1531
+ const windows = WINDOWS_HOTKEYS[key];
1532
+ const isGeneric = generic && index$2.isKeyHotkey(generic);
1533
+ const isApple = apple && index$2.isKeyHotkey(apple);
1534
+ const isWindows = windows && index$2.isKeyHotkey(windows);
1535
+ return (event) => {
1536
+ if (isGeneric && isGeneric(event))
1537
+ return true;
1538
+ if (index$3.IS_APPLE && isApple && isApple(event))
1539
+ return true;
1540
+ if (!index$3.IS_APPLE && isWindows && isWindows(event))
1541
+ return true;
1542
+ return false;
1543
+ };
1544
+ };
1545
+ var createComposing = (key) => (editor, event, {
1546
+ composing
1547
+ } = {}) => {
1548
+ if (!create(key)(event))
1549
+ return false;
1550
+ if (!!composing !== index$4.isComposing(editor))
1551
+ return false;
1552
+ return true;
1553
+ };
1554
+ ({
1555
+ isBold: create("bold"),
1556
+ isCompose: create("compose"),
1557
+ isMoveBackward: create("moveBackward"),
1558
+ isMoveForward: create("moveForward"),
1559
+ isDeleteBackward: create("deleteBackward"),
1560
+ isDeleteForward: create("deleteForward"),
1561
+ isDeleteLineBackward: create("deleteLineBackward"),
1562
+ isDeleteLineForward: create("deleteLineForward"),
1563
+ isDeleteWordBackward: create("deleteWordBackward"),
1564
+ isDeleteWordForward: create("deleteWordForward"),
1565
+ isExtendBackward: create("extendBackward"),
1566
+ isExtendForward: create("extendForward"),
1567
+ isExtendLineBackward: create("extendLineBackward"),
1568
+ isExtendLineForward: create("extendLineForward"),
1569
+ isItalic: create("italic"),
1570
+ isMoveLineBackward: create("moveLineBackward"),
1571
+ isMoveLineForward: create("moveLineForward"),
1572
+ isMoveWordBackward: create("moveWordBackward"),
1573
+ isMoveWordForward: create("moveWordForward"),
1574
+ isRedo: create("redo"),
1575
+ isSoftBreak: create("insertSoftBreak"),
1576
+ isSplitBlock: create("splitBlock"),
1577
+ isTab: createComposing("tab"),
1578
+ isTransposeCharacter: create("transposeCharacter"),
1579
+ isUndo: create("undo"),
1580
+ isUntab: createComposing("untab")
1581
+ });
1582
+ var mergeDeepToNodes = (options) => {
1583
+ applyDeepToNodes(__spreadProps(__spreadValues({}, options), { apply: merge.default }));
1584
+ };
1585
+
1586
+ // src/utils/mockPlugin.ts
1587
+ var mockPlugin = (plugin) => __spreadValues({
1588
+ key: "",
1589
+ type: "",
1590
+ editor: {},
1591
+ inject: {},
1592
+ options: {}
1593
+ }, plugin);
1594
+
1595
+ // src/utils/pipeDecorate.ts
1596
+ var pipeDecorate = (editor, decorateProp) => {
1597
+ const decorates = editor.plugins.flatMap(
1598
+ (plugin) => {
1599
+ var _a, _b;
1600
+ return (_b = (_a = plugin.decorate) == null ? void 0 : _a.call(plugin, editor, plugin)) != null ? _b : [];
1601
+ }
1602
+ );
1603
+ if (decorateProp) {
1604
+ decorates.push(decorateProp);
1605
+ }
1606
+ if (decorates.length === 0)
1607
+ return;
1608
+ return (entry) => {
1609
+ let ranges = [];
1610
+ const addRanges = (newRanges) => {
1611
+ if (newRanges == null ? void 0 : newRanges.length)
1612
+ ranges = [...ranges, ...newRanges];
1613
+ };
1614
+ decorates.forEach((decorate) => {
1615
+ addRanges(decorate(entry));
1616
+ });
1617
+ return ranges;
1618
+ };
1619
+ };
1620
+
1621
+ // src/utils/pipeHandler.ts
1622
+ var convertDomEventToSyntheticEvent = (domEvent) => {
1623
+ let propagationStopped = false;
1624
+ return __spreadProps(__spreadValues({}, domEvent), {
1625
+ nativeEvent: domEvent,
1626
+ currentTarget: domEvent.currentTarget,
1627
+ target: domEvent.target,
1628
+ bubbles: domEvent.bubbles,
1629
+ cancelable: domEvent.cancelable,
1630
+ defaultPrevented: domEvent.defaultPrevented,
1631
+ eventPhase: domEvent.eventPhase,
1632
+ isTrusted: domEvent.isTrusted,
1633
+ timeStamp: domEvent.timeStamp,
1634
+ type: domEvent.type,
1635
+ isDefaultPrevented: () => domEvent.defaultPrevented,
1636
+ isPropagationStopped: () => propagationStopped,
1637
+ persist: () => {
1638
+ throw new Error(
1639
+ "persist is not implemented for synthetic events created using convertDomEventToSyntheticEvent"
1640
+ );
1641
+ },
1642
+ preventDefault: () => domEvent.preventDefault(),
1643
+ stopPropagation: () => {
1644
+ propagationStopped = true;
1645
+ domEvent.stopPropagation();
1646
+ }
1647
+ });
1648
+ };
1649
+ var isEventHandled = (event, handler) => {
1650
+ if (!handler) {
1651
+ return false;
1652
+ }
1653
+ const shouldTreatEventAsHandled = handler(event);
1654
+ if (shouldTreatEventAsHandled != null) {
1655
+ return shouldTreatEventAsHandled;
1656
+ }
1657
+ return event.isPropagationStopped();
1658
+ };
1659
+ var pipeHandler = (editor, {
1660
+ editableProps,
1661
+ handlerKey
1662
+ }) => {
1663
+ let pluginsHandlers = [];
1664
+ pluginsHandlers = editor.plugins.flatMap(
1665
+ (plugin) => {
1666
+ var _a, _b, _c;
1667
+ return (_c = (_b = (_a = plugin.handlers) == null ? void 0 : _a[handlerKey]) == null ? void 0 : _b.call(_a, editor, plugin)) != null ? _c : [];
1668
+ }
1669
+ );
1670
+ const propsHandler = editableProps == null ? void 0 : editableProps[handlerKey];
1671
+ if (pluginsHandlers.length === 0 && !propsHandler)
1672
+ return;
1673
+ return (event) => {
1674
+ const isDomEvent = event instanceof Event;
1675
+ const handledEvent = isDomEvent ? convertDomEventToSyntheticEvent(event) : event;
1676
+ const eventIsHandled = pluginsHandlers.some(
1677
+ (handler) => isEventHandled(handledEvent, handler)
1678
+ );
1679
+ if (eventIsHandled)
1680
+ return true;
1681
+ return isEventHandled(handledEvent, propsHandler);
1682
+ };
1683
+ };
1684
+ var pluginInjectProps = (editor, { key, inject: { props } }, nodeProps) => {
1685
+ var _a, _b, _c, _d;
1686
+ const { element, text, className, style } = nodeProps;
1687
+ const node = element != null ? element : text;
1688
+ if (!node)
1689
+ return;
1690
+ if (!props)
1691
+ return;
1692
+ const {
1693
+ nodeKey = key,
1694
+ styleKey = nodeKey,
1695
+ validTypes,
1696
+ classNames,
1697
+ transformClassName,
1698
+ transformNodeValue,
1699
+ transformProps,
1700
+ transformStyle,
1701
+ validNodeValues,
1702
+ defaultNodeValue,
1703
+ query
1704
+ } = props;
1705
+ const queryResult = query == null ? void 0 : query(props, nodeProps);
1706
+ if (!queryResult && validTypes && index$6.isElement(node) && node.type && !validTypes.includes(node.type)) {
1707
+ return;
1708
+ }
1709
+ const nodeValue = node[nodeKey];
1710
+ if (!queryResult && (!index$3.isDefined(nodeValue) || validNodeValues && !validNodeValues.includes(nodeValue) || nodeValue === defaultNodeValue)) {
1711
+ return;
1712
+ }
1713
+ const transformOptions = __spreadProps(__spreadValues({}, nodeProps), { nodeValue });
1714
+ const value = (_a = transformNodeValue == null ? void 0 : transformNodeValue(transformOptions)) != null ? _a : nodeValue;
1715
+ transformOptions.value = value;
1716
+ let res = {};
1717
+ if (element) {
1718
+ res.className = clsx_m.clsx(className, `slate-${nodeKey}-${nodeValue}`);
1719
+ }
1720
+ if ((classNames == null ? void 0 : classNames[nodeValue]) || transformClassName) {
1721
+ res.className = (_b = transformClassName == null ? void 0 : transformClassName(transformOptions)) != null ? _b : clsx_m.clsx(className, classNames == null ? void 0 : classNames[value]);
1722
+ }
1723
+ if (styleKey) {
1724
+ res.style = (_c = transformStyle == null ? void 0 : transformStyle(transformOptions)) != null ? _c : __spreadProps(__spreadValues({}, style), {
1725
+ [styleKey]: value
1726
+ });
1727
+ }
1728
+ if (transformProps) {
1729
+ res = (_d = transformProps(transformOptions, res)) != null ? _d : res;
1730
+ }
1731
+ return res;
1732
+ };
1733
+
1734
+ // src/utils/pipeInjectProps.tsx
1735
+ var pipeInjectProps = (editor, nodeProps) => {
1736
+ editor.plugins.forEach((plugin) => {
1737
+ if (plugin.inject.props) {
1738
+ const props = pluginInjectProps(editor, plugin, nodeProps);
1739
+ if (props) {
1740
+ nodeProps = __spreadValues(__spreadValues({}, nodeProps), props);
1741
+ }
1742
+ }
1743
+ });
1744
+ return __spreadProps(__spreadValues({}, nodeProps), { editor });
1745
+ };
1746
+
1747
+ // src/utils/pipeOnChange.ts
1748
+ var pipeOnChange = (editor) => {
1749
+ const onChanges = editor.plugins.flatMap(
1750
+ (plugin) => {
1751
+ var _a, _b, _c;
1752
+ return (_c = (_b = (_a = plugin.handlers) == null ? void 0 : _a.onChange) == null ? void 0 : _b.call(_a, editor, plugin)) != null ? _c : [];
1753
+ }
1754
+ );
1755
+ return (nodes) => {
1756
+ return onChanges.some((handler) => {
1757
+ if (!handler) {
1758
+ return false;
1759
+ }
1760
+ const shouldTreatEventAsHandled = handler(nodes);
1761
+ if (shouldTreatEventAsHandled != null) {
1762
+ return shouldTreatEventAsHandled;
1763
+ }
1764
+ return false;
1765
+ });
1766
+ };
1767
+ };
1768
+ var pluginRenderElement = (editor, { key, type, component: _component, props }) => function render(nodeProps) {
1769
+ const { element, children: _children } = nodeProps;
1770
+ if (element.type === type) {
1771
+ const Element = _component != null ? _component : slateReact.DefaultElement;
1772
+ const injectAboveComponents = editor.plugins.flatMap(
1773
+ (o) => {
1774
+ var _a, _b;
1775
+ return (_b = (_a = o.inject) == null ? void 0 : _a.aboveComponent) != null ? _b : [];
1776
+ }
1777
+ );
1778
+ const injectBelowComponents = editor.plugins.flatMap(
1779
+ (o) => {
1780
+ var _a, _b;
1781
+ return (_b = (_a = o.inject) == null ? void 0 : _a.belowComponent) != null ? _b : [];
1782
+ }
1783
+ );
1784
+ nodeProps = getRenderNodeProps({
1785
+ attributes: element.attributes,
1786
+ nodeProps,
1787
+ props,
1788
+ type
1789
+ });
1790
+ let children = _children;
1791
+ injectBelowComponents.forEach((withHOC2) => {
1792
+ const hoc = withHOC2(__spreadProps(__spreadValues({}, nodeProps), { key }));
1793
+ if (hoc) {
1794
+ children = hoc(__spreadProps(__spreadValues({}, nodeProps), { children }));
1795
+ }
1796
+ });
1797
+ let component = /* @__PURE__ */ React__default.default.createElement(Element, __spreadValues({}, nodeProps), children);
1798
+ injectAboveComponents.forEach((withHOC2) => {
1799
+ const hoc = withHOC2(__spreadProps(__spreadValues({}, nodeProps), { key }));
1800
+ if (hoc) {
1801
+ component = hoc(__spreadProps(__spreadValues({}, nodeProps), { children: component }));
1802
+ }
1803
+ });
1804
+ return /* @__PURE__ */ React__default.default.createElement(ElementProvider, { element, scope: key }, component);
1805
+ }
1806
+ };
1807
+
1808
+ // src/utils/pipeRenderElement.tsx
1809
+ var pipeRenderElement = (editor, renderElementProp) => {
1810
+ const renderElements = [];
1811
+ editor.plugins.forEach((plugin) => {
1812
+ if (plugin.isElement) {
1813
+ renderElements.push(pluginRenderElement(editor, plugin));
1814
+ }
1815
+ });
1816
+ return function render(nodeProps) {
1817
+ const props = pipeInjectProps(editor, nodeProps);
1818
+ let element;
1819
+ renderElements.some((renderElement) => {
1820
+ element = renderElement(props);
1821
+ return !!element;
1822
+ });
1823
+ if (element)
1824
+ return element;
1825
+ if (renderElementProp) {
1826
+ return renderElementProp(props);
1827
+ }
1828
+ return /* @__PURE__ */ React__default.default.createElement(slateReact.DefaultElement, __spreadValues({}, props));
1829
+ };
1830
+ };
1831
+ var pluginRenderLeaf = (editor, { key, type = key, component, props }) => function render(nodeProps) {
1832
+ const { leaf, children } = nodeProps;
1833
+ if (leaf[type]) {
1834
+ const Leaf = component != null ? component : DefaultLeaf;
1835
+ nodeProps = getRenderNodeProps({
1836
+ attributes: leaf.attributes,
1837
+ props,
1838
+ nodeProps,
1839
+ type
1840
+ });
1841
+ return /* @__PURE__ */ React__default.default.createElement(Leaf, __spreadValues({}, nodeProps), children);
1842
+ }
1843
+ return children;
1844
+ };
1845
+
1846
+ // src/utils/pipeRenderLeaf.tsx
1847
+ var pipeRenderLeaf = (editor, renderLeafProp) => {
1848
+ const renderLeafs = [];
1849
+ editor.plugins.forEach((plugin) => {
1850
+ if (plugin.isLeaf && plugin.key) {
1851
+ renderLeafs.push(pluginRenderLeaf(editor, plugin));
1852
+ }
1853
+ });
1854
+ return function render(nodeProps) {
1855
+ const props = pipeInjectProps(editor, nodeProps);
1856
+ renderLeafs.forEach((renderLeaf) => {
1857
+ const newChildren = renderLeaf(props);
1858
+ if (newChildren !== void 0) {
1859
+ props.children = newChildren;
1860
+ }
1861
+ });
1862
+ if (renderLeafProp) {
1863
+ return renderLeafProp(props);
1864
+ }
1865
+ return /* @__PURE__ */ React__default.default.createElement(DefaultLeaf, __spreadValues({}, props));
1866
+ };
1867
+ };
1868
+ var withHOC = (HOC, Component, hocProps, hocRef) => React__default.default.forwardRef((props, componentRef) => /* @__PURE__ */ React__default.default.createElement(HOC, __spreadProps(__spreadValues({}, hocProps), { ref: hocRef }), /* @__PURE__ */ React__default.default.createElement(Component, __spreadProps(__spreadValues({}, props), { ref: componentRef }))));
1869
+ var {
1870
+ plateControllerStore,
1871
+ usePlateControllerStore,
1872
+ PlateControllerProvider: PlateController
1873
+ } = index.createAtomStore(
1874
+ {
1875
+ activeId: vanilla.atom(null),
1876
+ primaryEditorIds: vanilla.atom([]),
1877
+ editorStores: vanilla.atom({})
1878
+ },
1879
+ {
1880
+ name: "plateController"
1881
+ }
1882
+ );
1883
+ var usePlateControllerSelectors = () => usePlateControllerStore().get;
1884
+ var usePlateControllerActions = () => usePlateControllerStore().set;
1885
+ var usePlateControllerExists = () => !!usePlateControllerStore().store({ warnIfNoStore: false });
1886
+ var usePlateControllerEditorStore = (idProp) => {
1887
+ const storeAtom = React__default.default.useMemo(
1888
+ () => vanilla.atom((get) => {
1889
+ const editorStores = get(plateControllerStore.atom.editorStores);
1890
+ const forId = (id) => {
1891
+ var _a;
1892
+ if (!id)
1893
+ return null;
1894
+ return (_a = editorStores[id]) != null ? _a : null;
1895
+ };
1896
+ if (idProp)
1897
+ return forId(idProp);
1898
+ const lookupOrder = [
1899
+ get(plateControllerStore.atom.activeId),
1900
+ ...get(plateControllerStore.atom.primaryEditorIds)
1901
+ ];
1902
+ for (const id of lookupOrder) {
1903
+ const store = forId(id);
1904
+ if (store)
1905
+ return store;
1906
+ }
1907
+ return null;
1908
+ }),
1909
+ [idProp]
1910
+ );
1911
+ return usePlateControllerSelectors().atom(storeAtom);
1912
+ };
1913
+ var createPlateStore = (_a = {}) => {
1914
+ var _b = _a, {
1915
+ decorate = null,
1916
+ editor = createPlateFallbackEditor(),
1917
+ id,
1918
+ isMounted = false,
1919
+ versionDecorate = 1,
1920
+ versionEditor = 1,
1921
+ versionSelection = 1,
1922
+ onChange = null,
1923
+ editorRef = null,
1924
+ plugins = [],
1925
+ rawPlugins = [],
1926
+ readOnly = null,
1927
+ primary = true,
1928
+ renderElement = null,
1929
+ renderLeaf = null,
1930
+ value = null
1931
+ } = _b, state = __objRest(_b, [
1932
+ "decorate",
1933
+ "editor",
1934
+ "id",
1935
+ "isMounted",
1936
+ "versionDecorate",
1937
+ "versionEditor",
1938
+ "versionSelection",
1939
+ "onChange",
1940
+ "editorRef",
1941
+ "plugins",
1942
+ "rawPlugins",
1943
+ "readOnly",
1944
+ "primary",
1945
+ "renderElement",
1946
+ "renderLeaf",
1947
+ "value"
1948
+ ]);
1949
+ return index.createAtomStore(
1950
+ __spreadValues({
1951
+ decorate,
1952
+ editor,
1953
+ id,
1954
+ isMounted,
1955
+ versionDecorate,
1956
+ versionEditor,
1957
+ versionSelection,
1958
+ onChange,
1959
+ editorRef,
1960
+ plugins,
1961
+ rawPlugins,
1962
+ readOnly,
1963
+ primary,
1964
+ renderElement,
1965
+ renderLeaf,
1966
+ value
1967
+ }, state),
1968
+ {
1969
+ name: "plate",
1970
+ extend: (atoms) => ({
1971
+ trackedEditor: vanilla.atom((get) => ({
1972
+ editor: get(atoms.editor),
1973
+ version: get(atoms.versionEditor)
1974
+ })),
1975
+ trackedSelection: vanilla.atom((get) => ({
1976
+ selection: get(atoms.editor).selection,
1977
+ version: get(atoms.versionSelection)
1978
+ }))
1979
+ })
1980
+ }
1981
+ );
1982
+ };
1983
+ var {
1984
+ plateStore,
1985
+ usePlateStore,
1986
+ PlateProvider: PlateStoreProvider
1987
+ } = createPlateStore();
1988
+ var usePlateEditorStore = (id, { debugHookName = "usePlateEditorStore" } = {}) => {
1989
+ var _a;
1990
+ const localStore = (_a = usePlateStore(id).store({ warnIfNoStore: false })) != null ? _a : null;
1991
+ const [localStoreExists] = React__default.default.useState(!!localStore);
1992
+ const store = localStoreExists ? localStore : (
1993
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1994
+ usePlateControllerEditorStore(id)
1995
+ );
1996
+ const plateControllerExists = usePlateControllerExists();
1997
+ const fallbackStore = React__default.default.useMemo(() => vanilla.createStore(), []);
1998
+ if (!store) {
1999
+ if (plateControllerExists) {
2000
+ return fallbackStore;
2001
+ }
2002
+ throw new Error(
2003
+ `${debugHookName} must be used inside a Plate or PlateController`
2004
+ );
2005
+ }
2006
+ return store;
2007
+ };
2008
+ var usePlateSelectors = (id, options) => {
2009
+ const store = usePlateEditorStore(id, __spreadValues({
2010
+ debugHookName: "usePlateSelectors"
2011
+ }, options));
2012
+ return usePlateStore({ store }).get;
2013
+ };
2014
+ var usePlateActions = (id, options) => {
2015
+ const store = usePlateEditorStore(id, __spreadValues({
2016
+ debugHookName: "usePlateActions"
2017
+ }, options));
2018
+ return usePlateStore({ store }).set;
2019
+ };
2020
+ var usePlateId = () => usePlateSelectors(void 0, { debugHookName: "usePlateId" }).id();
2021
+ var useIncrementVersion = (key, id, options = {}) => {
2022
+ const previousVersionRef = React__default.default.useRef(1);
2023
+ const set = usePlateActions(id, __spreadValues({
2024
+ debugHookName: "useIncrementVersion"
2025
+ }, options))[key]();
2026
+ return React__default.default.useCallback(() => {
2027
+ const nextVersion = previousVersionRef.current + 1;
2028
+ set(nextVersion);
2029
+ previousVersionRef.current = nextVersion;
2030
+ }, [set]);
2031
+ };
2032
+ var useRedecorate = (id, options = {}) => {
2033
+ const updateDecorate = useIncrementVersion("versionDecorate", id, __spreadValues({
2034
+ debugHookName: "useRedecorate"
2035
+ }, options));
2036
+ return React__default.default.useCallback(() => {
2037
+ updateDecorate();
2038
+ }, [updateDecorate]);
2039
+ };
2040
+
2041
+ // src/stores/plate/selectors/useEditorRef.ts
2042
+ var useEditorRef = (id, options = {}) => usePlateSelectors(id, __spreadValues({
2043
+ debugHookName: "useEditorRef"
2044
+ }, options)).editor();
2045
+
2046
+ // src/stores/plate/selectors/useEditorSelection.ts
2047
+ var useEditorSelection = (id, options = {}) => usePlateSelectors(id, __spreadValues({
2048
+ debugHookName: "useEditorSelection"
2049
+ }, options)).trackedSelection().selection;
2050
+ var useEditorSelector = (selector, deps, _a = {}) => {
2051
+ var _b = _a, {
2052
+ id,
2053
+ equalityFn = (a, b) => a === b
2054
+ } = _b, storeOptions = __objRest(_b, [
2055
+ "id",
2056
+ "equalityFn"
2057
+ ]);
2058
+ const selectorAtom = React__default.default.useMemo(
2059
+ () => utils.selectAtom(
2060
+ plateStore.atom.trackedEditor,
2061
+ ({ editor }, prev) => selector(editor, prev),
2062
+ equalityFn
2063
+ ),
2064
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2065
+ deps
2066
+ );
2067
+ return usePlateSelectors(id, __spreadValues({
2068
+ debugHookName: "useEditorSelector"
2069
+ }, storeOptions)).atom(selectorAtom);
2070
+ };
2071
+
2072
+ // src/types/PlateStore.ts
2073
+ var EXPOSED_STORE_KEYS = [
2074
+ "readOnly",
2075
+ "plugins",
2076
+ "onChange",
2077
+ "decorate",
2078
+ "renderElement",
2079
+ "renderLeaf"
2080
+ ];
2081
+
2082
+ // src/components/EditorMethodsEffect.ts
2083
+ var EditorMethodsEffect = ({ id }) => {
2084
+ const editor = useEditorRef(id);
2085
+ const redecorate = useRedecorate(id);
2086
+ const plateStore2 = usePlateStore(id);
2087
+ const storeSetters = Object.fromEntries(
2088
+ EXPOSED_STORE_KEYS.map((key) => [key, plateStore2.set[key]()])
2089
+ );
2090
+ const memorizedStoreSetters = React__default.default.useMemo(() => storeSetters, []);
2091
+ React__default.default.useEffect(() => {
2092
+ editor.redecorate = redecorate;
2093
+ editor.plate = {
2094
+ set: memorizedStoreSetters
2095
+ };
2096
+ }, [editor, redecorate, memorizedStoreSetters]);
2097
+ return null;
2098
+ };
2099
+ function EditorRefPluginEffect({
2100
+ id,
2101
+ plugin
2102
+ }) {
2103
+ var _a;
2104
+ const editor = useEditorRef(id);
2105
+ (_a = plugin.useHooks) == null ? void 0 : _a.call(plugin, editor, plugin);
2106
+ return null;
2107
+ }
2108
+ function EditorRefEffect({ id }) {
2109
+ const setIsMounted = usePlateActions(id).isMounted();
2110
+ const plugins = usePlateSelectors(id).plugins();
2111
+ const editorState = useEditorRef(id);
2112
+ const editorRef = usePlateSelectors(id).editorRef();
2113
+ React__default.default.useEffect(() => {
2114
+ setIsMounted(true);
2115
+ return () => {
2116
+ setIsMounted(false);
2117
+ };
2118
+ }, [setIsMounted]);
2119
+ React__default.default.useEffect(() => {
2120
+ if (typeof editorRef === "function") {
2121
+ editorRef(editorState);
2122
+ return () => editorRef(null);
2123
+ }
2124
+ if (editorRef) {
2125
+ editorRef.current = editorState;
2126
+ return () => {
2127
+ editorRef.current = null;
2128
+ };
2129
+ }
2130
+ }, [editorRef, editorState]);
2131
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, plugins.map((plugin) => /* @__PURE__ */ React__default.default.createElement(EditorRefPluginEffect, { key: plugin.key, id, plugin })));
2132
+ }
2133
+ var EditorStateEffect = React__default.default.memo(({ id }) => {
2134
+ const editorState = slateReact.useSlate();
2135
+ const updateVersionEditor = useIncrementVersion("versionEditor", id);
2136
+ React__default.default.useEffect(() => {
2137
+ updateVersionEditor();
2138
+ });
2139
+ const updateVersionSelection = useIncrementVersion("versionSelection", id);
2140
+ const prevSelectionRef = React__default.default.useRef(editorState.selection);
2141
+ const sameSelection = isSelectionEqual(
2142
+ prevSelectionRef.current,
2143
+ editorState.selection
2144
+ );
2145
+ React__default.default.useEffect(() => {
2146
+ if (!sameSelection) {
2147
+ updateVersionSelection();
2148
+ }
2149
+ prevSelectionRef.current = editorState.selection;
2150
+ }, [editorState.selection, sameSelection, updateVersionSelection]);
2151
+ return null;
2152
+ });
2153
+ var isSelectionEqual = (a, b) => {
2154
+ if (!a && !b)
2155
+ return true;
2156
+ if (!a || !b)
2157
+ return false;
2158
+ return slate.Range.equals(a, b);
2159
+ };
2160
+
2161
+ // src/types/misc/dom-attributes.ts
2162
+ var DOM_HANDLERS = [
2163
+ // Clipboard Events
2164
+ "onCopy",
2165
+ "onCopyCapture",
2166
+ "onCut",
2167
+ "onCutCapture",
2168
+ "onPaste",
2169
+ "onPasteCapture",
2170
+ // Composition Events
2171
+ "onCompositionEnd",
2172
+ "onCompositionEndCapture",
2173
+ "onCompositionStart",
2174
+ "onCompositionStartCapture",
2175
+ "onCompositionUpdate",
2176
+ "onCompositionUpdateCapture",
2177
+ // Focus Events
2178
+ "onFocus",
2179
+ "onFocusCapture",
2180
+ "onBlur",
2181
+ "onBlurCapture",
2182
+ // Form Events
2183
+ "onDOMBeforeInput",
2184
+ "onBeforeInput",
2185
+ "onBeforeInputCapture",
2186
+ "onInput",
2187
+ "onInputCapture",
2188
+ "onReset",
2189
+ "onResetCapture",
2190
+ "onSubmit",
2191
+ "onSubmitCapture",
2192
+ "onInvalid",
2193
+ "onInvalidCapture",
2194
+ // Image Events
2195
+ "onLoad",
2196
+ "onLoadCapture",
2197
+ // Keyboard Events
2198
+ "onKeyDown",
2199
+ "onKeyDownCapture",
2200
+ "onKeyPress",
2201
+ "onKeyPressCapture",
2202
+ "onKeyUp",
2203
+ "onKeyUpCapture",
2204
+ // Media Events
2205
+ "onAbort",
2206
+ "onAbortCapture",
2207
+ "onCanPlay",
2208
+ "onCanPlayCapture",
2209
+ "onCanPlayThrough",
2210
+ "onCanPlayThroughCapture",
2211
+ "onDurationChange",
2212
+ "onDurationChangeCapture",
2213
+ "onEmptied",
2214
+ "onEmptiedCapture",
2215
+ "onEncrypted",
2216
+ "onEncryptedCapture",
2217
+ "onEnded",
2218
+ "onEndedCapture",
2219
+ "onLoadedData",
2220
+ "onLoadedDataCapture",
2221
+ "onLoadedMetadata",
2222
+ "onLoadedMetadataCapture",
2223
+ "onLoadStart",
2224
+ "onLoadStartCapture",
2225
+ "onPause",
2226
+ "onPauseCapture",
2227
+ "onPlay",
2228
+ "onPlayCapture",
2229
+ "onPlaying",
2230
+ "onPlayingCapture",
2231
+ "onProgress",
2232
+ "onProgressCapture",
2233
+ "onRateChange",
2234
+ "onRateChangeCapture",
2235
+ "onSeeked",
2236
+ "onSeekedCapture",
2237
+ "onSeeking",
2238
+ "onSeekingCapture",
2239
+ "onStalled",
2240
+ "onStalledCapture",
2241
+ "onSuspend",
2242
+ "onSuspendCapture",
2243
+ "onTimeUpdate",
2244
+ "onTimeUpdateCapture",
2245
+ "onVolumeChange",
2246
+ "onVolumeChangeCapture",
2247
+ "onWaiting",
2248
+ "onWaitingCapture",
2249
+ // MouseEvents
2250
+ "onAuxClick",
2251
+ "onAuxClickCapture",
2252
+ "onClick",
2253
+ "onClickCapture",
2254
+ "onContextMenu",
2255
+ "onContextMenuCapture",
2256
+ "onDoubleClick",
2257
+ "onDoubleClickCapture",
2258
+ "onDrag",
2259
+ "onDragCapture",
2260
+ "onDragEnd",
2261
+ "onDragEndCapture",
2262
+ "onDragEnter",
2263
+ "onDragEnterCapture",
2264
+ "onDragExit",
2265
+ "onDragExitCapture",
2266
+ "onDragLeave",
2267
+ "onDragLeaveCapture",
2268
+ "onDragOver",
2269
+ "onDragOverCapture",
2270
+ "onDragStart",
2271
+ "onDragStartCapture",
2272
+ "onDrop",
2273
+ "onDropCapture",
2274
+ "onMouseDown",
2275
+ "onMouseDownCapture",
2276
+ "onMouseEnter",
2277
+ "onMouseLeave",
2278
+ "onMouseMove",
2279
+ "onMouseMoveCapture",
2280
+ "onMouseOut",
2281
+ "onMouseOutCapture",
2282
+ "onMouseOver",
2283
+ "onMouseOverCapture",
2284
+ "onMouseUp",
2285
+ "onMouseUpCapture",
2286
+ // Selection Events
2287
+ "onSelect",
2288
+ "onSelectCapture",
2289
+ // Touch Events
2290
+ "onTouchCancel",
2291
+ "onTouchCancelCapture",
2292
+ "onTouchEnd",
2293
+ "onTouchEndCapture",
2294
+ "onTouchMove",
2295
+ "onTouchMoveCapture",
2296
+ "onTouchStart",
2297
+ "onTouchStartCapture",
2298
+ // Pointer Events
2299
+ "onPointerDown",
2300
+ "onPointerDownCapture",
2301
+ "onPointerMove",
2302
+ "onPointerMoveCapture",
2303
+ "onPointerUp",
2304
+ "onPointerUpCapture",
2305
+ "onPointerCancel",
2306
+ "onPointerCancelCapture",
2307
+ "onPointerEnter",
2308
+ "onPointerEnterCapture",
2309
+ "onPointerLeave",
2310
+ "onPointerLeaveCapture",
2311
+ "onPointerOver",
2312
+ "onPointerOverCapture",
2313
+ "onPointerOut",
2314
+ "onPointerOutCapture",
2315
+ "onGotPointerCapture",
2316
+ "onGotPointerCaptureCapture",
2317
+ "onLostPointerCapture",
2318
+ "onLostPointerCaptureCapture",
2319
+ // UI Events
2320
+ "onScroll",
2321
+ "onScrollCapture",
2322
+ // Wheel Events
2323
+ "onWheel",
2324
+ "onWheelCapture",
2325
+ // Animation Events
2326
+ "onAnimationStart",
2327
+ "onAnimationStartCapture",
2328
+ "onAnimationEnd",
2329
+ "onAnimationEndCapture",
2330
+ "onAnimationIteration",
2331
+ "onAnimationIterationCapture",
2332
+ // Transition Events
2333
+ "onTransitionEnd",
2334
+ "onTransitionEndCapture"
2335
+ ];
2336
+
2337
+ // src/hooks/useEditableProps.ts
2338
+ var useEditableProps = (editableProps = {}) => {
2339
+ const { id } = editableProps;
2340
+ const editor = useEditorRef(id);
2341
+ const selectors = usePlateSelectors(id);
2342
+ const versionDecorate = selectors.versionDecorate();
2343
+ const readOnly = selectors.readOnly();
2344
+ const storeDecorate = selectors.decorate();
2345
+ const storeRenderLeaf = selectors.renderLeaf();
2346
+ const storeRenderElement = selectors.renderElement();
2347
+ const decorateMemo = React__default.default.useMemo(() => {
2348
+ return pipeDecorate(editor, storeDecorate != null ? storeDecorate : editableProps == null ? void 0 : editableProps.decorate);
2349
+ }, [editableProps == null ? void 0 : editableProps.decorate, editor, storeDecorate]);
2350
+ const decorate = React__default.default.useMemo(() => {
2351
+ if (!versionDecorate || !decorateMemo)
2352
+ return;
2353
+ return (entry) => decorateMemo(entry);
2354
+ }, [decorateMemo, versionDecorate]);
2355
+ const renderElement = React__default.default.useMemo(() => {
2356
+ return pipeRenderElement(
2357
+ editor,
2358
+ storeRenderElement != null ? storeRenderElement : editableProps == null ? void 0 : editableProps.renderElement
2359
+ );
2360
+ }, [editableProps == null ? void 0 : editableProps.renderElement, editor, storeRenderElement]);
2361
+ const renderLeaf = React__default.default.useMemo(() => {
2362
+ return pipeRenderLeaf(editor, storeRenderLeaf != null ? storeRenderLeaf : editableProps == null ? void 0 : editableProps.renderLeaf);
2363
+ }, [editableProps == null ? void 0 : editableProps.renderLeaf, editor, storeRenderLeaf]);
2364
+ const props = index$5.useDeepCompareMemo(() => {
2365
+ const _props = {
2366
+ decorate,
2367
+ renderElement,
2368
+ renderLeaf
2369
+ };
2370
+ if (index$3.isDefined(readOnly)) {
2371
+ _props.readOnly = readOnly;
2372
+ }
2373
+ DOM_HANDLERS.forEach((handlerKey) => {
2374
+ const handler = pipeHandler(editor, {
2375
+ editableProps,
2376
+ handlerKey
2377
+ });
2378
+ if (handler) {
2379
+ _props[handlerKey] = handler;
2380
+ }
2381
+ });
2382
+ return _props;
2383
+ }, [decorate, editableProps, renderElement, renderLeaf, readOnly]);
2384
+ return index$5.useDeepCompareMemo(
2385
+ () => __spreadValues(__spreadValues({}, omit.default(editableProps, [...DOM_HANDLERS, "renderElement", "renderLeaf"])), props),
2386
+ [editableProps, props]
2387
+ );
2388
+ };
2389
+ var useSlateProps = ({
2390
+ id
2391
+ }) => {
2392
+ const editor = useEditorRef(id);
2393
+ const value = usePlateSelectors(id).value();
2394
+ const setValue = usePlateActions(id).value();
2395
+ const onChangeProp = usePlateSelectors(id).onChange();
2396
+ const onChange = React__default.default.useCallback(
2397
+ (newValue) => {
2398
+ const eventIsHandled = pipeOnChange(editor)(newValue);
2399
+ if (!eventIsHandled) {
2400
+ onChangeProp == null ? void 0 : onChangeProp(newValue);
2401
+ }
2402
+ setValue(newValue);
2403
+ },
2404
+ [editor, setValue, onChangeProp]
2405
+ );
2406
+ return React__default.default.useMemo(() => {
2407
+ return {
2408
+ key: editor.key,
2409
+ editor,
2410
+ onChange,
2411
+ value,
2412
+ initialValue: value
2413
+ };
2414
+ }, [editor, onChange, value]);
2415
+ };
2416
+ var PlateControllerEffect = ({
2417
+ id: idProp
2418
+ }) => {
2419
+ const idFromStore = usePlateId();
2420
+ const id = idProp != null ? idProp : idFromStore;
2421
+ const currentStoreAtom = React__default.default.useMemo(
2422
+ () => index_modern.focusAtom(
2423
+ plateControllerStore.atom.editorStores,
2424
+ (optic) => optic.prop(id)
2425
+ ),
2426
+ [id]
2427
+ );
2428
+ const setCurrentStore = usePlateControllerActions().atom(currentStoreAtom, {
2429
+ warnIfNoStore: false
2430
+ });
2431
+ const store = usePlateStore(id).store();
2432
+ const primary = usePlateSelectors(id).primary();
2433
+ const setPrimaryEditorIds = usePlateControllerActions().primaryEditorIds({
2434
+ warnIfNoStore: false
2435
+ });
2436
+ const focused = slateReact.useFocused();
2437
+ const setActiveId = usePlateControllerActions().activeId({
2438
+ warnIfNoStore: false
2439
+ });
2440
+ React__default.default.useEffect(() => {
2441
+ setCurrentStore(store != null ? store : null);
2442
+ return () => {
2443
+ setCurrentStore(null);
2444
+ setActiveId((activeId) => activeId === id ? null : activeId);
2445
+ };
2446
+ }, [store, setCurrentStore, setActiveId, id]);
2447
+ React__default.default.useEffect(() => {
2448
+ if (primary) {
2449
+ setPrimaryEditorIds((ids) => [...ids, id]);
2450
+ return () => {
2451
+ setPrimaryEditorIds((ids) => ids.filter((i) => i !== id));
2452
+ };
2453
+ }
2454
+ }, [id, primary, setPrimaryEditorIds]);
2455
+ React__default.default.useEffect(() => {
2456
+ if (id && focused) {
2457
+ setActiveId(id);
2458
+ }
2459
+ }, [id, focused, setActiveId]);
2460
+ return null;
2461
+ };
2462
+ function PlateSlate({
2463
+ id,
2464
+ children
2465
+ }) {
2466
+ var _a;
2467
+ const slateProps = useSlateProps({ id });
2468
+ const editor = useEditorRef(id);
2469
+ let aboveSlate = /* @__PURE__ */ React__default.default.createElement(slateReact.Slate, __spreadValues({}, slateProps), children);
2470
+ (_a = editor.plugins) == null ? void 0 : _a.forEach((plugin) => {
2471
+ const { renderAboveSlate: RenderAboveSlate } = plugin;
2472
+ if (RenderAboveSlate)
2473
+ aboveSlate = /* @__PURE__ */ React__default.default.createElement(RenderAboveSlate, null, aboveSlate);
2474
+ });
2475
+ return aboveSlate;
2476
+ }
2477
+
2478
+ // src/components/PlateContent.tsx
2479
+ var PlateContent = React__default.default.forwardRef(
2480
+ (_a, ref) => {
2481
+ var _b = _a, { renderEditable } = _b, props = __objRest(_b, ["renderEditable"]);
2482
+ const { id } = props;
2483
+ const editor = useEditorRef(id);
2484
+ if (!editor) {
2485
+ throw new Error(
2486
+ "Editor not found. Please ensure that PlateContent is rendered below Plate."
2487
+ );
2488
+ }
2489
+ const editableProps = useEditableProps(props);
2490
+ const editable = /* @__PURE__ */ React__default.default.createElement(slateReact.Editable, __spreadValues({ ref }, editableProps));
2491
+ let afterEditable = null;
2492
+ let beforeEditable = null;
2493
+ editor.plugins.forEach((plugin) => {
2494
+ const {
2495
+ renderBeforeEditable: RenderBeforeEditable,
2496
+ renderAfterEditable: RenderAfterEditable
2497
+ } = plugin;
2498
+ if (RenderAfterEditable) {
2499
+ afterEditable = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, afterEditable, /* @__PURE__ */ React__default.default.createElement(RenderAfterEditable, __spreadValues({}, editableProps)));
2500
+ }
2501
+ if (RenderBeforeEditable) {
2502
+ beforeEditable = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, beforeEditable, /* @__PURE__ */ React__default.default.createElement(RenderBeforeEditable, __spreadValues({}, editableProps)));
2503
+ }
2504
+ });
2505
+ let aboveEditable = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, beforeEditable, renderEditable ? renderEditable(editable) : editable, /* @__PURE__ */ React__default.default.createElement(EditorMethodsEffect, { id }), /* @__PURE__ */ React__default.default.createElement(EditorStateEffect, { id }), /* @__PURE__ */ React__default.default.createElement(EditorRefEffect, { id }), /* @__PURE__ */ React__default.default.createElement(PlateControllerEffect, { id }), afterEditable);
2506
+ editor.plugins.forEach((plugin) => {
2507
+ const { renderAboveEditable: RenderAboveEditable } = plugin;
2508
+ if (RenderAboveEditable)
2509
+ aboveEditable = /* @__PURE__ */ React__default.default.createElement(RenderAboveEditable, null, aboveEditable);
2510
+ });
2511
+ return /* @__PURE__ */ React__default.default.createElement(PlateSlate, { id }, aboveEditable);
2512
+ }
2513
+ );
2514
+ PlateContent.displayName = "PlateContent";
2515
+
2516
+ exports.createAtomStore = index.createAtomStore;
2517
+ exports.isHotkeyPressed = reactHotkeysHook_esm.isHotkeyPressed;
2518
+ exports.useHotkeys = reactHotkeysHook_esm.useHotkeys;
2519
+ exports.createZustandStore = index$1.createZustandStore;
2520
+ exports.atom = vanilla.atom;
2521
+ exports.DOM_HANDLERS = DOM_HANDLERS;
2522
+ exports.DefaultLeaf = DefaultLeaf;
2523
+ exports.ELEMENT_DEFAULT = ELEMENT_DEFAULT;
2524
+ exports.EXPOSED_STORE_KEYS = EXPOSED_STORE_KEYS;
2525
+ exports.EditorMethodsEffect = EditorMethodsEffect;
2526
+ exports.EditorRefEffect = EditorRefEffect;
2527
+ exports.EditorRefPluginEffect = EditorRefPluginEffect;
2528
+ exports.EditorStateEffect = EditorStateEffect;
2529
+ exports.ElementProvider = ElementProvider;
2530
+ exports.KEY_DESERIALIZE_AST = KEY_DESERIALIZE_AST;
2531
+ exports.KEY_DESERIALIZE_HTML = KEY_DESERIALIZE_HTML;
2532
+ exports.KEY_EDITOR_PROTOCOL = KEY_EDITOR_PROTOCOL;
2533
+ exports.KEY_EVENT_EDITOR = KEY_EVENT_EDITOR;
2534
+ exports.KEY_INLINE_VOID = KEY_INLINE_VOID;
2535
+ exports.KEY_INSERT_DATA = KEY_INSERT_DATA;
2536
+ exports.KEY_LENGTH = KEY_LENGTH;
2537
+ exports.KEY_NODE_FACTORY = KEY_NODE_FACTORY;
2538
+ exports.KEY_PREV_SELECTION = KEY_PREV_SELECTION;
2539
+ exports.PlateContent = PlateContent;
2540
+ exports.PlateController = PlateController;
2541
+ exports.PlateControllerEffect = PlateControllerEffect;
2542
+ exports.PlateSlate = PlateSlate;
2543
+ exports.PlateStoreProvider = PlateStoreProvider;
2544
+ exports.SCOPE_ELEMENT = SCOPE_ELEMENT;
2545
+ exports.applyDeepToNodes = applyDeepToNodes;
2546
+ exports.collapseString = collapseString;
2547
+ exports.collapseWhiteSpace = collapseWhiteSpace;
2548
+ exports.collapseWhiteSpaceChildren = collapseWhiteSpaceChildren;
2549
+ exports.collapseWhiteSpaceElement = collapseWhiteSpaceElement;
2550
+ exports.collapseWhiteSpaceNode = collapseWhiteSpaceNode;
2551
+ exports.collapseWhiteSpaceText = collapseWhiteSpaceText;
2552
+ exports.convertDomEventToSyntheticEvent = convertDomEventToSyntheticEvent;
2553
+ exports.createDeserializeAstPlugin = createDeserializeAstPlugin;
2554
+ exports.createDeserializeHtmlPlugin = createDeserializeHtmlPlugin;
2555
+ exports.createEditorProtocolPlugin = createEditorProtocolPlugin;
2556
+ exports.createEventEditorPlugin = createEventEditorPlugin;
2557
+ exports.createHistoryPlugin = createHistoryPlugin;
2558
+ exports.createInlineVoidPlugin = createInlineVoidPlugin;
2559
+ exports.createInsertDataPlugin = createInsertDataPlugin;
2560
+ exports.createLengthPlugin = createLengthPlugin;
2561
+ exports.createNodeFactoryPlugin = createNodeFactoryPlugin;
2562
+ exports.createPlateEditor = createPlateEditor;
2563
+ exports.createPlateFallbackEditor = createPlateFallbackEditor;
2564
+ exports.createPlateStore = createPlateStore;
2565
+ exports.createPluginFactory = createPluginFactory;
2566
+ exports.createPlugins = createPlugins;
2567
+ exports.createPrevSelectionPlugin = createPrevSelectionPlugin;
2568
+ exports.createReactPlugin = createReactPlugin;
2569
+ exports.deserializeHtml = deserializeHtml;
2570
+ exports.deserializeHtmlElement = deserializeHtmlElement;
2571
+ exports.deserializeHtmlNode = deserializeHtmlNode;
2572
+ exports.deserializeHtmlNodeChildren = deserializeHtmlNodeChildren;
2573
+ exports.endInlineFormattingContext = endInlineFormattingContext;
2574
+ exports.eventEditorActions = eventEditorActions;
2575
+ exports.eventEditorSelectors = eventEditorSelectors;
2576
+ exports.eventEditorStore = eventEditorStore;
2577
+ exports.flattenDeepPlugins = flattenDeepPlugins;
2578
+ exports.getInjectedPlugins = getInjectedPlugins;
2579
+ exports.getPlugin = getPlugin;
2580
+ exports.getPluginInjectProps = getPluginInjectProps;
2581
+ exports.getPluginOptions = getPluginOptions;
2582
+ exports.getPluginType = getPluginType;
2583
+ exports.getPluginTypes = getPluginTypes;
2584
+ exports.getPluginsByKey = getPluginsByKey;
2585
+ exports.getRenderNodeProps = getRenderNodeProps;
2586
+ exports.getSlateClass = getSlateClass;
2587
+ exports.htmlBodyToFragment = htmlBodyToFragment;
2588
+ exports.htmlBrToNewLine = htmlBrToNewLine;
2589
+ exports.htmlElementToElement = htmlElementToElement;
2590
+ exports.htmlElementToLeaf = htmlElementToLeaf;
2591
+ exports.htmlStringToDOMNode = htmlStringToDOMNode;
2592
+ exports.htmlTextNodeToString = htmlTextNodeToString;
2593
+ exports.inferWhiteSpaceRule = inferWhiteSpaceRule;
2594
+ exports.inlineTagNames = inlineTagNames;
2595
+ exports.isEventHandled = isEventHandled;
2596
+ exports.isHtmlBlockElement = isHtmlBlockElement;
2597
+ exports.isHtmlElement = isHtmlElement;
2598
+ exports.isHtmlInlineElement = isHtmlInlineElement;
2599
+ exports.isHtmlText = isHtmlText;
2600
+ exports.isLastNonEmptyTextOfInlineFormattingContext = isLastNonEmptyTextOfInlineFormattingContext;
2601
+ exports.mergeDeepPlugins = mergeDeepPlugins;
2602
+ exports.mergeDeepToNodes = mergeDeepToNodes;
2603
+ exports.mockPlugin = mockPlugin;
2604
+ exports.normalizeDescendantsToDocumentFragment = normalizeDescendantsToDocumentFragment;
2605
+ exports.overridePluginsByKey = overridePluginsByKey;
2606
+ exports.parseHtmlDocument = parseHtmlDocument;
2607
+ exports.pipeDecorate = pipeDecorate;
2608
+ exports.pipeDeserializeHtmlElement = pipeDeserializeHtmlElement;
2609
+ exports.pipeDeserializeHtmlLeaf = pipeDeserializeHtmlLeaf;
2610
+ exports.pipeHandler = pipeHandler;
2611
+ exports.pipeInjectProps = pipeInjectProps;
2612
+ exports.pipeInsertDataQuery = pipeInsertDataQuery;
2613
+ exports.pipeInsertFragment = pipeInsertFragment;
2614
+ exports.pipeOnChange = pipeOnChange;
2615
+ exports.pipeRenderElement = pipeRenderElement;
2616
+ exports.pipeRenderLeaf = pipeRenderLeaf;
2617
+ exports.pipeTransformData = pipeTransformData;
2618
+ exports.pipeTransformFragment = pipeTransformFragment;
2619
+ exports.plateControllerStore = plateControllerStore;
2620
+ exports.plateStore = plateStore;
2621
+ exports.pluginDeserializeHtml = pluginDeserializeHtml;
2622
+ exports.pluginInjectProps = pluginInjectProps;
2623
+ exports.pluginRenderElement = pluginRenderElement;
2624
+ exports.pluginRenderLeaf = pluginRenderLeaf;
2625
+ exports.resetEditor = resetEditor;
2626
+ exports.resetEditorChildren = resetEditorChildren;
2627
+ exports.setDefaultPlugin = setDefaultPlugin;
2628
+ exports.setPlatePlugins = setPlatePlugins;
2629
+ exports.upsertInlineFormattingContext = upsertInlineFormattingContext;
2630
+ exports.useEditableProps = useEditableProps;
2631
+ exports.useEditorRef = useEditorRef;
2632
+ exports.useEditorSelection = useEditorSelection;
2633
+ exports.useEditorSelector = useEditorSelector;
2634
+ exports.useElement = useElement;
2635
+ exports.useElementStore = useElementStore;
2636
+ exports.useIncrementVersion = useIncrementVersion;
2637
+ exports.usePlateActions = usePlateActions;
2638
+ exports.usePlateControllerActions = usePlateControllerActions;
2639
+ exports.usePlateControllerEditorStore = usePlateControllerEditorStore;
2640
+ exports.usePlateControllerExists = usePlateControllerExists;
2641
+ exports.usePlateControllerSelectors = usePlateControllerSelectors;
2642
+ exports.usePlateControllerStore = usePlateControllerStore;
2643
+ exports.usePlateEditorStore = usePlateEditorStore;
2644
+ exports.usePlateId = usePlateId;
2645
+ exports.usePlateSelectors = usePlateSelectors;
2646
+ exports.usePlateStore = usePlateStore;
2647
+ exports.useRedecorate = useRedecorate;
2648
+ exports.useSlateProps = useSlateProps;
2649
+ exports.withEditorProtocol = withEditorProtocol;
2650
+ exports.withHOC = withHOC;
2651
+ exports.withInlineVoid = withInlineVoid;
2652
+ exports.withInsertData = withInsertData;
2653
+ exports.withLength = withLength;
2654
+ exports.withPlate = withPlate;
2655
+ exports.withTHistory = withTHistory;
2656
+ exports.withTReact = withTReact;