@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,1371 @@
1
+ 'use strict';
2
+
3
+ var slate = require('slate');
4
+ var cloneDeep = require('../../../lodash/cloneDeep.js');
5
+ var React = require('react');
6
+ var index$3 = require('../../plate-resizable/dist/index.js');
7
+ var slateReact = require('slate-react');
8
+ var index$1 = require('../../plate-core/dist/index.js');
9
+ var index$4 = require('../../slate/dist/index.js');
10
+ var index$5 = require('../../slate-utils/dist/index.js');
11
+ var index = require('../../../jotai-x/dist/index.js');
12
+ var vanilla = require('../../../jotai/esm/vanilla.js');
13
+ var index$2 = require('../../slate-react/dist/index.js');
14
+
15
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
16
+
17
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
18
+
19
+ var __defProp = Object.defineProperty;
20
+ var __defProps = Object.defineProperties;
21
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
22
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
23
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
24
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
25
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
26
+ var __spreadValues = (a, b) => {
27
+ for (var prop in b || (b = {}))
28
+ if (__hasOwnProp.call(b, prop))
29
+ __defNormalProp(a, prop, b[prop]);
30
+ if (__getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(b)) {
32
+ if (__propIsEnum.call(b, prop))
33
+ __defNormalProp(a, prop, b[prop]);
34
+ }
35
+ return a;
36
+ };
37
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
38
+ var __objRest = (source, exclude) => {
39
+ var target = {};
40
+ for (var prop in source)
41
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
42
+ target[prop] = source[prop];
43
+ if (source != null && __getOwnPropSymbols)
44
+ for (var prop of __getOwnPropSymbols(source)) {
45
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
46
+ target[prop] = source[prop];
47
+ }
48
+ return target;
49
+ };
50
+
51
+ // src/queries/getColSpan.ts
52
+ var getColSpan = (cellElem) => {
53
+ var _a;
54
+ return cellElem.colSpan || Number((_a = cellElem.attributes) == null ? void 0 : _a.colspan) || 1;
55
+ };
56
+ var getCellTypes = (editor) => index$1.getPluginTypes(editor, [ELEMENT_TD, ELEMENT_TH]);
57
+ var getEmptyCellNode = (editor, { header, newCellChildren = [editor.blockFactory()] }) => {
58
+ return {
59
+ type: header ? index$1.getPluginType(editor, ELEMENT_TH) : index$1.getPluginType(editor, ELEMENT_TD),
60
+ children: newCellChildren
61
+ };
62
+ };
63
+ var getEmptyRowNode = (editor, _a = {}) => {
64
+ var _b = _a, { colCount = 1 } = _b, options = __objRest(_b, ["colCount"]);
65
+ return {
66
+ type: index$1.getPluginType(editor, ELEMENT_TR),
67
+ children: Array.from({ length: colCount }).fill(colCount).map(() => getEmptyCellNode(editor, options))
68
+ };
69
+ };
70
+ var getEmptyTableNode = (editor, {
71
+ header,
72
+ rowCount = 0,
73
+ colCount,
74
+ newCellChildren
75
+ } = {}) => {
76
+ const rows = Array.from({ length: rowCount }).fill(rowCount).map(() => getEmptyRowNode(editor, { header, colCount, newCellChildren }));
77
+ return {
78
+ type: index$1.getPluginType(editor, ELEMENT_TABLE),
79
+ children: rows
80
+ };
81
+ };
82
+
83
+ // src/queries/getLeftTableCell.ts
84
+ var getLeftTableCell = (editor, {
85
+ at: cellPath
86
+ } = {}) => {
87
+ var _a;
88
+ if (!cellPath) {
89
+ cellPath = (_a = index$4.findNode(editor, {
90
+ match: { type: getCellTypes(editor) }
91
+ })) == null ? void 0 : _a[1];
92
+ if (!cellPath)
93
+ return;
94
+ }
95
+ const cellIndex = cellPath.at(-1);
96
+ if (!cellIndex)
97
+ return;
98
+ const prevCellPath = slate.Path.previous(cellPath);
99
+ return index$4.getNodeEntry(editor, prevCellPath);
100
+ };
101
+
102
+ // src/queries/getRowSpan.ts
103
+ var getRowSpan = (cellElem) => {
104
+ var _a;
105
+ return cellElem.rowSpan || Number((_a = cellElem.attributes) == null ? void 0 : _a.rowspan) || 1;
106
+ };
107
+
108
+ // src/queries/getTableColumnCount.ts
109
+ var getTableColumnCount = (tableNode) => {
110
+ var _a, _b, _c, _d;
111
+ return (_d = (_c = (_b = (_a = tableNode.children) == null ? void 0 : _a[0]) == null ? void 0 : _b.children) == null ? void 0 : _c.length) != null ? _d : 0;
112
+ };
113
+ var getTableColumnIndex = (editor, cellNode) => {
114
+ var _a;
115
+ const path = index$2.findNodePath(editor, cellNode);
116
+ if (!path)
117
+ return 0;
118
+ const [trNode] = (_a = index$4.getParentNode(editor, path)) != null ? _a : [];
119
+ if (!trNode)
120
+ return 0;
121
+ let colIndex = 0;
122
+ trNode.children.some((item, index) => {
123
+ if (item === cellNode) {
124
+ colIndex = index;
125
+ return true;
126
+ }
127
+ return false;
128
+ });
129
+ return colIndex;
130
+ };
131
+ function computeCellIndices(editor, tableEl, cellEl) {
132
+ var _a;
133
+ const options = index$1.getPluginOptions(editor, ELEMENT_TABLE);
134
+ const tableNodes = tableEl.children;
135
+ let rowIndex = -1;
136
+ let colIndex = -1;
137
+ for (let r = 0; r < tableNodes.length; r++) {
138
+ const row = tableNodes[r];
139
+ let cIndex = 0;
140
+ for (let c = 0; c < row.children.length; c++) {
141
+ const cell = row.children[c];
142
+ if (cellEl === cell) {
143
+ colIndex = cIndex;
144
+ rowIndex = r;
145
+ break;
146
+ }
147
+ cIndex += cell.colSpan || 1;
148
+ }
149
+ }
150
+ tableNodes.slice(0, rowIndex).forEach((pR, _rowIndex) => {
151
+ const prevRow = pR;
152
+ prevRow.children.forEach((pC) => {
153
+ var _a2;
154
+ const prevCell = pC;
155
+ const prevIndices = (_a2 = options == null ? void 0 : options._cellIndices) == null ? void 0 : _a2.get(prevCell);
156
+ const _rowSpan = getRowSpan(prevCell);
157
+ if (prevIndices) {
158
+ const { col: prevColIndex } = prevIndices;
159
+ if (
160
+ // colIndex affects
161
+ prevColIndex <= colIndex && // rowSpan affects
162
+ _rowSpan && _rowSpan > 1 && rowIndex - _rowIndex < _rowSpan
163
+ ) {
164
+ colIndex += prevCell.colSpan || 1;
165
+ }
166
+ }
167
+ });
168
+ });
169
+ if (rowIndex === -1 || colIndex === -1) {
170
+ return null;
171
+ }
172
+ const indices = { row: rowIndex, col: colIndex };
173
+ (_a = options == null ? void 0 : options._cellIndices) == null ? void 0 : _a.set(cellEl, indices);
174
+ return indices;
175
+ }
176
+ var computeAllCellIndices = (editor, tableNode) => {
177
+ var _a;
178
+ const options = index$1.getPluginOptions(editor, ELEMENT_TABLE);
179
+ for (let r = 0; r < tableNode.children.length; r++) {
180
+ const row = tableNode.children[r];
181
+ for (let c = 0; c < row.children.length; c++) {
182
+ const cell = row.children[c];
183
+ const indices = computeCellIndices(editor, tableNode, cell);
184
+ if (indices) {
185
+ (_a = options._cellIndices) == null ? void 0 : _a.set(cell, indices);
186
+ }
187
+ }
188
+ }
189
+ };
190
+
191
+ // src/merge/getCellIndices.ts
192
+ var getCellIndices = (cellIndices, startCell) => {
193
+ return cellIndices == null ? void 0 : cellIndices.get(startCell);
194
+ };
195
+
196
+ // src/merge/getCellIndicesWithSpans.ts
197
+ var getCellIndicesWithSpans = ({ col, row }, endCell) => {
198
+ return {
199
+ row: row + getRowSpan(endCell) - 1,
200
+ col: col + getColSpan(endCell) - 1
201
+ };
202
+ };
203
+
204
+ // src/merge/findCellByIndexes.ts
205
+ var findCellByIndexes = (editor, table, searchRowIndex, searchColIndex) => {
206
+ const { _cellIndices: cellIndices } = index$1.getPluginOptions(
207
+ editor,
208
+ ELEMENT_TABLE
209
+ );
210
+ const allCells = table.children.flatMap(
211
+ (current) => current.children
212
+ );
213
+ const foundCell = allCells.find((cell) => {
214
+ const cellElement = cell;
215
+ const indices = getCellIndices(cellIndices, cellElement) || computeCellIndices(editor, table, cellElement);
216
+ const { col: _startColIndex, row: _startRowIndex } = indices;
217
+ const { row: _endRowIndex, col: _endColIndex } = getCellIndicesWithSpans(
218
+ indices,
219
+ cellElement
220
+ );
221
+ if (searchColIndex >= _startColIndex && searchColIndex <= _endColIndex && searchRowIndex >= _startRowIndex && searchRowIndex <= _endRowIndex) {
222
+ return true;
223
+ }
224
+ return false;
225
+ });
226
+ return foundCell;
227
+ };
228
+
229
+ // src/merge/getTableGridByRange.ts
230
+ var getTableMergeGridByRange = (editor, { at, format }) => {
231
+ var _a;
232
+ const { _cellIndices: cellIndices } = index$1.getPluginOptions(
233
+ editor,
234
+ ELEMENT_TABLE
235
+ );
236
+ const startCellEntry = index$4.findNode(editor, {
237
+ at: at.anchor.path,
238
+ match: { type: getCellTypes(editor) }
239
+ });
240
+ const endCellEntry = index$4.findNode(editor, {
241
+ at: at.focus.path,
242
+ match: { type: getCellTypes(editor) }
243
+ });
244
+ const startCell = startCellEntry[0];
245
+ const endCell = endCellEntry[0];
246
+ const startCellPath = at.anchor.path;
247
+ const tablePath = startCellPath.slice(0, -2);
248
+ const tableEntry = index$4.findNode(editor, {
249
+ at: tablePath,
250
+ match: { type: index$1.getPluginType(editor, ELEMENT_TABLE) }
251
+ });
252
+ const realTable = tableEntry[0];
253
+ const { col: _startColIndex, row: _startRowIndex } = getCellIndices(cellIndices, startCell) || computeCellIndices(editor, realTable, startCell);
254
+ const { row: _endRowIndex, col: _endColIndex } = getCellIndicesWithSpans(
255
+ getCellIndices(cellIndices, endCell) || computeCellIndices(editor, realTable, endCell),
256
+ endCell
257
+ );
258
+ const startRowIndex = Math.min(_startRowIndex, _endRowIndex);
259
+ const endRowIndex = Math.max(_startRowIndex, _endRowIndex);
260
+ const startColIndex = Math.min(_startColIndex, _endColIndex);
261
+ const endColIndex = Math.max(_startColIndex, _endColIndex);
262
+ const relativeRowIndex = endRowIndex - startRowIndex;
263
+ const relativeColIndex = endColIndex - startColIndex;
264
+ const table = getEmptyTableNode(editor, {
265
+ rowCount: relativeRowIndex + 1,
266
+ colCount: relativeColIndex + 1,
267
+ newCellChildren: []
268
+ });
269
+ const cellEntries = [];
270
+ const cellsSet = /* @__PURE__ */ new WeakSet();
271
+ let rowIndex = startRowIndex;
272
+ let colIndex = startColIndex;
273
+ while (true) {
274
+ const cell = findCellByIndexes(editor, realTable, rowIndex, colIndex);
275
+ if (!cell) {
276
+ break;
277
+ }
278
+ if (!cellsSet.has(cell)) {
279
+ cellsSet.add(cell);
280
+ const rows = table.children[rowIndex - startRowIndex].children;
281
+ rows[colIndex - startColIndex] = cell;
282
+ const cellPath = index$2.findNodePath(editor, cell);
283
+ cellEntries.push([cell, cellPath]);
284
+ }
285
+ if (colIndex + 1 <= endColIndex) {
286
+ colIndex = colIndex + 1;
287
+ } else if (rowIndex + 1 <= endRowIndex) {
288
+ colIndex = startColIndex;
289
+ rowIndex = rowIndex + 1;
290
+ } else {
291
+ break;
292
+ }
293
+ }
294
+ const formatType = format || "table";
295
+ if (formatType === "cell") {
296
+ return cellEntries;
297
+ }
298
+ (_a = table.children) == null ? void 0 : _a.forEach((rowEl) => {
299
+ var _a2;
300
+ const rowElement = rowEl;
301
+ const filteredChildren = (_a2 = rowElement.children) == null ? void 0 : _a2.filter((cellEl) => {
302
+ const cellElement = cellEl;
303
+ return !!(cellElement == null ? void 0 : cellElement.children.length);
304
+ });
305
+ rowElement.children = filteredChildren;
306
+ });
307
+ if (formatType === "table") {
308
+ return [[table, tablePath]];
309
+ }
310
+ return {
311
+ tableEntries: [[table, tablePath]],
312
+ cellEntries
313
+ };
314
+ };
315
+
316
+ // src/queries/getTableGridByRange.ts
317
+ var getTableGridByRange = (editor, { at, format = "table" }) => {
318
+ const { enableMerging } = index$1.getPluginOptions(
319
+ editor,
320
+ ELEMENT_TABLE
321
+ );
322
+ if (enableMerging) {
323
+ return getTableMergeGridByRange(editor, { at, format });
324
+ }
325
+ const startCellPath = at.anchor.path;
326
+ const endCellPath = at.focus.path;
327
+ const _startRowIndex = startCellPath.at(-2);
328
+ const _endRowIndex = endCellPath.at(-2);
329
+ const _startColIndex = startCellPath.at(-1);
330
+ const _endColIndex = endCellPath.at(-1);
331
+ const startRowIndex = Math.min(_startRowIndex, _endRowIndex);
332
+ const endRowIndex = Math.max(_startRowIndex, _endRowIndex);
333
+ const startColIndex = Math.min(_startColIndex, _endColIndex);
334
+ const endColIndex = Math.max(_startColIndex, _endColIndex);
335
+ const tablePath = startCellPath.slice(0, -2);
336
+ const relativeRowIndex = endRowIndex - startRowIndex;
337
+ const relativeColIndex = endColIndex - startColIndex;
338
+ const table = getEmptyTableNode(editor, {
339
+ rowCount: relativeRowIndex + 1,
340
+ colCount: relativeColIndex + 1,
341
+ newCellChildren: []
342
+ });
343
+ let rowIndex = startRowIndex;
344
+ let colIndex = startColIndex;
345
+ const cellEntries = [];
346
+ while (true) {
347
+ const cellPath = tablePath.concat([rowIndex, colIndex]);
348
+ const cell = index$4.getNode(editor, cellPath);
349
+ if (!cell)
350
+ break;
351
+ const rows = table.children[rowIndex - startRowIndex].children;
352
+ rows[colIndex - startColIndex] = cell;
353
+ cellEntries.push([cell, cellPath]);
354
+ if (colIndex + 1 <= endColIndex) {
355
+ colIndex += 1;
356
+ } else if (rowIndex + 1 <= endRowIndex) {
357
+ colIndex = startColIndex;
358
+ rowIndex += 1;
359
+ } else {
360
+ break;
361
+ }
362
+ }
363
+ if (format === "cell") {
364
+ return cellEntries;
365
+ }
366
+ return [[table, tablePath]];
367
+ };
368
+
369
+ // src/queries/getTableGridAbove.ts
370
+ var getTableGridAbove = (editor, _a = {}) => {
371
+ var _b = _a, { format = "table" } = _b, options = __objRest(_b, ["format"]);
372
+ const edges = index$5.getEdgeBlocksAbove(editor, __spreadValues({
373
+ match: {
374
+ type: getCellTypes(editor)
375
+ }
376
+ }, options));
377
+ if (edges) {
378
+ const [start, end] = edges;
379
+ if (!slate.Path.equals(start[1], end[1])) {
380
+ return getTableGridByRange(editor, {
381
+ at: {
382
+ anchor: {
383
+ path: start[1],
384
+ offset: 0
385
+ },
386
+ focus: {
387
+ path: end[1],
388
+ offset: 0
389
+ }
390
+ },
391
+ format
392
+ });
393
+ }
394
+ if (format === "table") {
395
+ const table = getEmptyTableNode(editor, { rowCount: 1 });
396
+ table.children[0].children = [start[0]];
397
+ return [[table, start[1].slice(0, -2)]];
398
+ }
399
+ return [start];
400
+ }
401
+ return [];
402
+ };
403
+
404
+ // src/queries/getTableOverriddenColSizes.ts
405
+ var getTableOverriddenColSizes = (tableNode, colSizeOverrides) => {
406
+ const colCount = getTableColumnCount(tableNode);
407
+ const colSizes = (tableNode.colSizes ? [...tableNode.colSizes] : Array.from({ length: colCount }).fill(0)).map((size, index) => {
408
+ var _a, _b;
409
+ return (_b = (_a = colSizeOverrides == null ? void 0 : colSizeOverrides.get) == null ? void 0 : _a.call(colSizeOverrides, index)) != null ? _b : size;
410
+ });
411
+ return colSizes;
412
+ };
413
+ var getTableRowIndex = (editor, cellNode) => {
414
+ const path = index$2.findNodePath(editor, cellNode);
415
+ if (!path)
416
+ return 0;
417
+ const rowPath = slate.Path.parent(path);
418
+ return rowPath.at(-1);
419
+ };
420
+ var getTopTableCell = (editor, {
421
+ at: cellPath
422
+ } = {}) => {
423
+ var _a;
424
+ if (!cellPath) {
425
+ cellPath = (_a = index$4.findNode(editor, {
426
+ match: { type: getCellTypes(editor) }
427
+ })) == null ? void 0 : _a[1];
428
+ if (!cellPath)
429
+ return;
430
+ }
431
+ const cellIndex = cellPath.at(-1);
432
+ const rowIndex = cellPath.at(-2);
433
+ if (rowIndex === 0)
434
+ return;
435
+ const cellAbovePath = [
436
+ ...slate.Path.parent(slate.Path.parent(cellPath)),
437
+ rowIndex - 1,
438
+ cellIndex
439
+ ];
440
+ return index$4.getNodeEntry(editor, cellAbovePath);
441
+ };
442
+ var isTableBorderHidden = (editor, border) => {
443
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
444
+ if (border === "left") {
445
+ const node = (_a = getLeftTableCell(editor)) == null ? void 0 : _a[0];
446
+ if (node) {
447
+ return ((_c = (_b = node.borders) == null ? void 0 : _b.right) == null ? void 0 : _c.size) === 0;
448
+ }
449
+ }
450
+ if (border === "top") {
451
+ const node = (_d = getTopTableCell(editor)) == null ? void 0 : _d[0];
452
+ if (node) {
453
+ return ((_f = (_e = node.borders) == null ? void 0 : _e.bottom) == null ? void 0 : _f.size) === 0;
454
+ }
455
+ }
456
+ return ((_i = (_h = (_g = index$4.findNode(editor, {
457
+ match: { type: getCellTypes(editor) }
458
+ })) == null ? void 0 : _g[0].borders) == null ? void 0 : _h[border]) == null ? void 0 : _i.size) === 0;
459
+ };
460
+ var setBorderSize = (editor, size, {
461
+ at,
462
+ border = "all"
463
+ } = {}) => {
464
+ const cellEntry = index$4.findNode(editor, {
465
+ at,
466
+ match: { type: getCellTypes(editor) }
467
+ });
468
+ if (!cellEntry)
469
+ return;
470
+ const [cellNode, cellPath] = cellEntry;
471
+ const cellIndex = cellPath.at(-1);
472
+ const rowIndex = cellPath.at(-2);
473
+ const borderStyle = {
474
+ size
475
+ };
476
+ const setNodesOptions = {
477
+ match: (n) => index$4.isElement(n) && getCellTypes(editor).includes(n.type)
478
+ };
479
+ if (border === "top") {
480
+ const isFirstRow = rowIndex === 0;
481
+ if (isFirstRow) {
482
+ const newBorders2 = __spreadProps(__spreadValues({}, cellNode.borders), {
483
+ top: borderStyle
484
+ });
485
+ index$4.setNodes(
486
+ editor,
487
+ { borders: newBorders2 },
488
+ __spreadValues({
489
+ at: cellPath
490
+ }, setNodesOptions)
491
+ );
492
+ return;
493
+ }
494
+ const cellAboveEntry = getTopTableCell(editor, { at: cellPath });
495
+ if (!cellAboveEntry)
496
+ return;
497
+ const [cellAboveNode, cellAbovePath] = cellAboveEntry;
498
+ const newBorders = __spreadProps(__spreadValues({}, cellAboveNode.borders), {
499
+ bottom: borderStyle
500
+ });
501
+ index$4.setNodes(
502
+ editor,
503
+ { borders: newBorders },
504
+ __spreadValues({
505
+ at: cellAbovePath
506
+ }, setNodesOptions)
507
+ );
508
+ } else if (border === "bottom") {
509
+ const newBorders = __spreadProps(__spreadValues({}, cellNode.borders), {
510
+ bottom: borderStyle
511
+ });
512
+ index$4.setNodes(
513
+ editor,
514
+ { borders: newBorders },
515
+ __spreadValues({
516
+ at: cellPath
517
+ }, setNodesOptions)
518
+ );
519
+ }
520
+ if (border === "left") {
521
+ const isFirstCell = cellIndex === 0;
522
+ if (isFirstCell) {
523
+ const newBorders2 = __spreadProps(__spreadValues({}, cellNode.borders), {
524
+ left: borderStyle
525
+ });
526
+ index$4.setNodes(
527
+ editor,
528
+ { borders: newBorders2 },
529
+ __spreadValues({
530
+ at: cellPath
531
+ }, setNodesOptions)
532
+ );
533
+ return;
534
+ }
535
+ const prevCellEntry = getLeftTableCell(editor, { at: cellPath });
536
+ if (!prevCellEntry)
537
+ return;
538
+ const [prevCellNode, prevCellPath] = prevCellEntry;
539
+ const newBorders = __spreadProps(__spreadValues({}, prevCellNode.borders), {
540
+ right: borderStyle
541
+ });
542
+ index$4.setNodes(
543
+ editor,
544
+ { borders: newBorders },
545
+ __spreadValues({
546
+ at: prevCellPath
547
+ }, setNodesOptions)
548
+ );
549
+ } else if (border === "right") {
550
+ const newBorders = __spreadProps(__spreadValues({}, cellNode.borders), {
551
+ right: borderStyle
552
+ });
553
+ index$4.setNodes(
554
+ editor,
555
+ { borders: newBorders },
556
+ __spreadValues({
557
+ at: cellPath
558
+ }, setNodesOptions)
559
+ );
560
+ }
561
+ if (border === "all") {
562
+ index$4.withoutNormalizing(editor, () => {
563
+ setBorderSize(editor, size, { at, border: "top" });
564
+ setBorderSize(editor, size, { at, border: "bottom" });
565
+ setBorderSize(editor, size, { at, border: "left" });
566
+ setBorderSize(editor, size, { at, border: "right" });
567
+ });
568
+ }
569
+ };
570
+ var setTableColSize = (editor, { colIndex, width }, options = {}) => {
571
+ const table = index$4.findNode(editor, __spreadValues({
572
+ match: { type: ELEMENT_TABLE }
573
+ }, options));
574
+ if (!table)
575
+ return;
576
+ const [tableNode, tablePath] = table;
577
+ const colSizes = tableNode.colSizes ? [...tableNode.colSizes] : Array.from({ length: getTableColumnCount(tableNode) }).fill(0);
578
+ colSizes[colIndex] = width;
579
+ index$4.setNodes(editor, { colSizes }, { at: tablePath });
580
+ };
581
+ var setTableMarginLeft = (editor, { marginLeft }, options = {}) => {
582
+ const table = index$4.findNode(editor, __spreadValues({
583
+ match: { type: ELEMENT_TABLE }
584
+ }, options));
585
+ if (!table)
586
+ return;
587
+ const [, tablePath] = table;
588
+ index$4.setNodes(editor, { marginLeft }, { at: tablePath });
589
+ };
590
+ var setTableRowSize = (editor, { rowIndex, height }, options = {}) => {
591
+ const table = index$4.findNode(editor, __spreadValues({
592
+ match: { type: ELEMENT_TABLE }
593
+ }, options));
594
+ if (!table)
595
+ return;
596
+ const [, tablePath] = table;
597
+ const tableRowPath = [...tablePath, rowIndex];
598
+ index$4.setNodes(editor, { size: height }, { at: tableRowPath });
599
+ };
600
+
601
+ // src/createTablePlugin.ts
602
+ var ELEMENT_TABLE = "table";
603
+ var ELEMENT_TH = "th";
604
+ var ELEMENT_TR = "tr";
605
+ var ELEMENT_TD = "td";
606
+ var getOnSelectTableBorderFactory = (editor, selectedCells) => (border) => () => {
607
+ if (selectedCells)
608
+ return;
609
+ if (border === "none") {
610
+ setBorderSize(editor, 0, { border: "all" });
611
+ } else if (border === "outer") {
612
+ setBorderSize(editor, 1, { border: "all" });
613
+ } else {
614
+ const size = isTableBorderHidden(editor, border) ? 1 : 0;
615
+ setBorderSize(editor, size, { border });
616
+ }
617
+ setTimeout(() => {
618
+ index$2.focusEditor(editor);
619
+ }, 50);
620
+ };
621
+
622
+ // src/components/TableCellElement/getTableCellBorders.ts
623
+ var getTableCellBorders = (element, {
624
+ isFirstCell,
625
+ isFirstRow,
626
+ defaultBorder = {
627
+ size: 1,
628
+ style: "solid",
629
+ color: "rgb(209 213 219)"
630
+ }
631
+ } = {}) => {
632
+ const getBorder = (dir) => {
633
+ var _a, _b, _c, _d;
634
+ const border = (_a = element.borders) == null ? void 0 : _a[dir];
635
+ return {
636
+ size: (_b = border == null ? void 0 : border.size) != null ? _b : defaultBorder.size,
637
+ style: (_c = border == null ? void 0 : border.style) != null ? _c : defaultBorder.style,
638
+ color: (_d = border == null ? void 0 : border.color) != null ? _d : defaultBorder.color
639
+ };
640
+ };
641
+ return {
642
+ bottom: getBorder("bottom"),
643
+ right: getBorder("right"),
644
+ left: isFirstCell ? getBorder("left") : void 0,
645
+ top: isFirstRow ? getBorder("top") : void 0
646
+ };
647
+ };
648
+
649
+ // src/components/TableCellElement/roundCellSizeToStep.ts
650
+ var roundCellSizeToStep = (size, step) => {
651
+ return step ? Math.round(size / step) * step : size;
652
+ };
653
+ var { tableStore, useTableStore, TableProvider } = index.createAtomStore(
654
+ {
655
+ colSizeOverrides: vanilla.atom(/* @__PURE__ */ new Map()),
656
+ rowSizeOverrides: vanilla.atom(/* @__PURE__ */ new Map()),
657
+ marginLeftOverride: null,
658
+ hoveredColIndex: null,
659
+ selectedCells: null,
660
+ selectedTable: null
661
+ },
662
+ { name: "table" }
663
+ );
664
+ var useOverrideSizeFactory = (setOverrides) => React__default.default.useCallback(
665
+ (index, size) => {
666
+ setOverrides((overrides) => {
667
+ const newOverrides = new Map(overrides);
668
+ if (size === null) {
669
+ newOverrides.delete(index);
670
+ } else {
671
+ newOverrides.set(index, size);
672
+ }
673
+ return newOverrides;
674
+ });
675
+ },
676
+ [setOverrides]
677
+ );
678
+ var useOverrideColSize = () => {
679
+ const setColSizeOverrides = useTableStore().set.colSizeOverrides();
680
+ return useOverrideSizeFactory(setColSizeOverrides);
681
+ };
682
+ var useOverrideRowSize = () => {
683
+ const setRowSizeOverrides = useTableStore().set.rowSizeOverrides();
684
+ return useOverrideSizeFactory(setRowSizeOverrides);
685
+ };
686
+ var useOverrideMarginLeft = () => useTableStore().set.marginLeftOverride();
687
+
688
+ // src/components/TableCellElement/useIsCellSelected.ts
689
+ var useIsCellSelected = (element) => {
690
+ const selectedCells = useTableStore().get.selectedCells();
691
+ return React__default.default.useMemo(
692
+ () => !!(selectedCells == null ? void 0 : selectedCells.includes(element)),
693
+ [element, selectedCells]
694
+ );
695
+ };
696
+ var useTableBordersDropdownMenuContentState = () => {
697
+ const editor = index$1.useEditorRef();
698
+ const selectedCells = useTableStore().get.selectedCells();
699
+ const hasBottomBorder = index$1.useEditorSelector(
700
+ (editor2) => !isTableBorderHidden(editor2, "bottom"),
701
+ []
702
+ );
703
+ const hasTopBorder = index$1.useEditorSelector(
704
+ (editor2) => !isTableBorderHidden(editor2, "top"),
705
+ []
706
+ );
707
+ const hasLeftBorder = index$1.useEditorSelector(
708
+ (editor2) => !isTableBorderHidden(editor2, "left"),
709
+ []
710
+ );
711
+ const hasRightBorder = index$1.useEditorSelector(
712
+ (editor2) => !isTableBorderHidden(editor2, "right"),
713
+ []
714
+ );
715
+ const hasOuterBorders = hasBottomBorder && hasTopBorder && hasLeftBorder && hasRightBorder;
716
+ const hasNoBorders = !hasBottomBorder && !hasTopBorder && !hasLeftBorder && !hasRightBorder;
717
+ return {
718
+ hasBottomBorder,
719
+ hasTopBorder,
720
+ hasLeftBorder,
721
+ hasRightBorder,
722
+ hasNoBorders,
723
+ hasOuterBorders,
724
+ getOnSelectTableBorder: getOnSelectTableBorderFactory(
725
+ editor,
726
+ selectedCells
727
+ )
728
+ };
729
+ };
730
+ var useTableColSizes = (tableNode, { disableOverrides = false } = {}) => {
731
+ const editor = index$1.useEditorRef();
732
+ const colSizeOverrides = useTableStore().get.colSizeOverrides();
733
+ const { enableUnsetSingleColSize } = index$1.getPluginOptions(
734
+ editor,
735
+ ELEMENT_TABLE
736
+ );
737
+ const overriddenColSizes = getTableOverriddenColSizes(
738
+ tableNode,
739
+ disableOverrides ? void 0 : colSizeOverrides
740
+ );
741
+ const colCount = getTableColumnCount(tableNode);
742
+ React__default.default.useEffect(() => {
743
+ var _a;
744
+ if (enableUnsetSingleColSize && colCount < 2 && ((_a = tableNode.colSizes) == null ? void 0 : _a.length)) {
745
+ index$4.unsetNodes(editor, "colSizes", {
746
+ at: index$2.findNodePath(editor, tableNode)
747
+ });
748
+ }
749
+ }, [colCount, enableUnsetSingleColSize, editor, tableNode]);
750
+ return overriddenColSizes;
751
+ };
752
+
753
+ // src/components/TableCellElement/useTableCellElementResizable.ts
754
+ var useTableCellElementResizableState = ({
755
+ colIndex,
756
+ rowIndex,
757
+ step,
758
+ stepX = step,
759
+ stepY = step,
760
+ colSpan
761
+ }) => {
762
+ const editor = index$1.useEditorRef();
763
+ const { disableMarginLeft } = index$1.getPluginOptions(
764
+ editor,
765
+ ELEMENT_TABLE
766
+ );
767
+ return {
768
+ disableMarginLeft,
769
+ colIndex,
770
+ rowIndex,
771
+ stepX,
772
+ stepY,
773
+ colSpan
774
+ };
775
+ };
776
+ var useTableCellElementResizable = ({
777
+ disableMarginLeft,
778
+ colIndex,
779
+ rowIndex,
780
+ stepX,
781
+ stepY,
782
+ colSpan
783
+ }) => {
784
+ var _a;
785
+ const editor = index$1.useEditorRef();
786
+ const element = index$1.useElement();
787
+ const tableElement = index$1.useElement(ELEMENT_TABLE);
788
+ const { minColumnWidth = 0 } = index$1.getPluginOptions(
789
+ editor,
790
+ ELEMENT_TABLE
791
+ );
792
+ let initialWidth;
793
+ if (colSpan > 1) {
794
+ initialWidth = (_a = tableElement.colSizes) == null ? void 0 : _a[colIndex];
795
+ }
796
+ const [hoveredColIndex, setHoveredColIndex] = useTableStore().use.hoveredColIndex();
797
+ const colSizesWithoutOverrides = useTableColSizes(tableElement, {
798
+ disableOverrides: true
799
+ });
800
+ const { marginLeft = 0 } = tableElement;
801
+ const overrideColSize = useOverrideColSize();
802
+ const overrideRowSize = useOverrideRowSize();
803
+ const overrideMarginLeft = useOverrideMarginLeft();
804
+ const setColSize = React__default.default.useCallback(
805
+ (colIndex2, width) => {
806
+ setTableColSize(
807
+ editor,
808
+ { colIndex: colIndex2, width },
809
+ { at: index$2.findNodePath(editor, element) }
810
+ );
811
+ setTimeout(() => overrideColSize(colIndex2, null), 0);
812
+ },
813
+ [editor, element, overrideColSize]
814
+ );
815
+ const setRowSize = React__default.default.useCallback(
816
+ (rowIndex2, height) => {
817
+ setTableRowSize(
818
+ editor,
819
+ { rowIndex: rowIndex2, height },
820
+ { at: index$2.findNodePath(editor, element) }
821
+ );
822
+ setTimeout(() => overrideRowSize(rowIndex2, null), 0);
823
+ },
824
+ [editor, element, overrideRowSize]
825
+ );
826
+ const setMarginLeft = React__default.default.useCallback(
827
+ (marginLeft2) => {
828
+ setTableMarginLeft(
829
+ editor,
830
+ { marginLeft: marginLeft2 },
831
+ { at: index$2.findNodePath(editor, element) }
832
+ );
833
+ setTimeout(() => overrideMarginLeft(null), 0);
834
+ },
835
+ [editor, element, overrideMarginLeft]
836
+ );
837
+ const handleResizeRight = React__default.default.useCallback(
838
+ ({ initialSize: currentInitial, delta, finished }) => {
839
+ const nextInitial = colSizesWithoutOverrides[colIndex + 1];
840
+ const complement = (width) => currentInitial + nextInitial - width;
841
+ const currentNew = roundCellSizeToStep(
842
+ index$3.resizeLengthClampStatic(currentInitial + delta, {
843
+ min: minColumnWidth,
844
+ max: nextInitial ? complement(minColumnWidth) : void 0
845
+ }),
846
+ stepX
847
+ );
848
+ const nextNew = nextInitial ? complement(currentNew) : void 0;
849
+ const fn = finished ? setColSize : overrideColSize;
850
+ fn(colIndex, currentNew);
851
+ if (nextNew)
852
+ fn(colIndex + 1, nextNew);
853
+ },
854
+ [
855
+ colIndex,
856
+ colSizesWithoutOverrides,
857
+ minColumnWidth,
858
+ overrideColSize,
859
+ setColSize,
860
+ stepX
861
+ ]
862
+ );
863
+ const handleResizeBottom = React__default.default.useCallback(
864
+ (event) => {
865
+ const newHeight = roundCellSizeToStep(
866
+ event.initialSize + event.delta,
867
+ stepY
868
+ );
869
+ if (event.finished) {
870
+ setRowSize(rowIndex, newHeight);
871
+ } else {
872
+ overrideRowSize(rowIndex, newHeight);
873
+ }
874
+ },
875
+ [overrideRowSize, rowIndex, setRowSize, stepY]
876
+ );
877
+ const handleResizeLeft = React__default.default.useCallback(
878
+ (event) => {
879
+ const initial = colSizesWithoutOverrides[colIndex];
880
+ const complement = (width) => initial + marginLeft - width;
881
+ const newMargin = roundCellSizeToStep(
882
+ index$3.resizeLengthClampStatic(marginLeft + event.delta, {
883
+ min: 0,
884
+ max: complement(minColumnWidth)
885
+ }),
886
+ stepX
887
+ );
888
+ const newWidth = complement(newMargin);
889
+ if (event.finished) {
890
+ setMarginLeft(newMargin);
891
+ setColSize(colIndex, newWidth);
892
+ } else {
893
+ overrideMarginLeft(newMargin);
894
+ overrideColSize(colIndex, newWidth);
895
+ }
896
+ },
897
+ [
898
+ colIndex,
899
+ colSizesWithoutOverrides,
900
+ marginLeft,
901
+ minColumnWidth,
902
+ overrideColSize,
903
+ overrideMarginLeft,
904
+ setColSize,
905
+ setMarginLeft,
906
+ stepX
907
+ ]
908
+ );
909
+ const getHandleHoverProps = (colIndex2) => ({
910
+ onHover: () => {
911
+ if (hoveredColIndex === null) {
912
+ setHoveredColIndex(colIndex2);
913
+ }
914
+ },
915
+ onHoverEnd: () => {
916
+ if (hoveredColIndex === colIndex2) {
917
+ setHoveredColIndex(null);
918
+ }
919
+ }
920
+ });
921
+ const hasLeftHandle = colIndex === 0 && !disableMarginLeft;
922
+ return {
923
+ rightProps: {
924
+ options: __spreadValues({
925
+ direction: "right",
926
+ initialSize: initialWidth,
927
+ onResize: handleResizeRight
928
+ }, getHandleHoverProps(colIndex))
929
+ },
930
+ bottomProps: {
931
+ options: {
932
+ direction: "bottom",
933
+ onResize: handleResizeBottom
934
+ }
935
+ },
936
+ hiddenLeft: !hasLeftHandle,
937
+ leftProps: {
938
+ options: __spreadValues({
939
+ direction: "left",
940
+ onResize: handleResizeLeft
941
+ }, getHandleHoverProps(-1))
942
+ }
943
+ };
944
+ };
945
+ var useTableCellElementState = ({
946
+ ignoreReadOnly
947
+ } = {}) => {
948
+ var _a, _b, _c, _d, _e, _f, _g, _h;
949
+ const editor = index$1.useEditorRef();
950
+ const cellElement = index$1.useElement();
951
+ const colSpan = getColSpan(cellElement);
952
+ const rowSpan = getRowSpan(cellElement);
953
+ const readOnly = slateReact.useReadOnly();
954
+ const isCellSelected = useIsCellSelected(cellElement);
955
+ const hoveredColIndex = useTableStore().get.hoveredColIndex();
956
+ const selectedCells = useTableStore().get.selectedCells();
957
+ const tableElement = index$1.useElement(ELEMENT_TABLE);
958
+ const rowElement = index$1.useElement(ELEMENT_TR);
959
+ const rowSizeOverrides = useTableStore().get.rowSizeOverrides();
960
+ const { enableMerging, _cellIndices } = index$1.getPluginOptions(
961
+ editor,
962
+ ELEMENT_TABLE
963
+ );
964
+ if (!enableMerging) {
965
+ const colIndex2 = getTableColumnIndex(editor, cellElement);
966
+ const rowIndex2 = getTableRowIndex(editor, cellElement);
967
+ const rowSize2 = (_c = (_b = (_a = rowSizeOverrides.get) == null ? void 0 : _a.call(rowSizeOverrides, rowIndex2)) != null ? _b : rowElement == null ? void 0 : rowElement.size) != null ? _c : void 0;
968
+ const isFirstCell2 = colIndex2 === 0;
969
+ const isFirstRow2 = ((_d = tableElement.children) == null ? void 0 : _d[0]) === rowElement;
970
+ const borders2 = getTableCellBorders(cellElement, {
971
+ isFirstCell: isFirstCell2,
972
+ isFirstRow: isFirstRow2
973
+ });
974
+ return {
975
+ colIndex: colIndex2,
976
+ rowIndex: rowIndex2,
977
+ readOnly: !ignoreReadOnly && readOnly,
978
+ selected: isCellSelected,
979
+ hovered: hoveredColIndex === colIndex2,
980
+ hoveredLeft: isFirstCell2 && hoveredColIndex === -1,
981
+ rowSize: rowSize2,
982
+ borders: borders2,
983
+ isSelectingCell: !!selectedCells,
984
+ colSpan
985
+ };
986
+ }
987
+ let result;
988
+ const calculated = getCellIndices(_cellIndices, cellElement) || computeCellIndices(editor, tableElement, cellElement);
989
+ if (calculated) {
990
+ result = calculated;
991
+ } else {
992
+ const defaultColIndex = getTableColumnIndex(editor, cellElement);
993
+ const defaultRowIndex = getTableRowIndex(editor, cellElement);
994
+ result = { col: defaultColIndex, row: defaultRowIndex };
995
+ }
996
+ const colIndex = result.col;
997
+ const rowIndex = result.row;
998
+ const endingRowIndex = rowIndex + rowSpan - 1;
999
+ const endingColIndex = colIndex + colSpan - 1;
1000
+ const rowSize = (_g = (_f = (_e = rowSizeOverrides.get) == null ? void 0 : _e.call(rowSizeOverrides, endingRowIndex)) != null ? _f : rowElement == null ? void 0 : rowElement.size) != null ? _g : void 0;
1001
+ const isFirstCell = colIndex === 0;
1002
+ const isFirstRow = ((_h = tableElement.children) == null ? void 0 : _h[0]) === rowElement;
1003
+ const borders = getTableCellBorders(cellElement, {
1004
+ isFirstCell,
1005
+ isFirstRow
1006
+ });
1007
+ return {
1008
+ colIndex: endingColIndex,
1009
+ rowIndex: endingRowIndex,
1010
+ readOnly: !ignoreReadOnly && readOnly,
1011
+ selected: isCellSelected,
1012
+ hovered: hoveredColIndex === endingColIndex,
1013
+ hoveredLeft: isFirstCell && hoveredColIndex === -1,
1014
+ rowSize,
1015
+ borders,
1016
+ isSelectingCell: !!selectedCells,
1017
+ colSpan
1018
+ };
1019
+ };
1020
+ var useTableCellElement = ({
1021
+ element
1022
+ }) => {
1023
+ const setHoveredColIndex = useTableStore().set.hoveredColIndex();
1024
+ React__default.default.useEffect(() => {
1025
+ setHoveredColIndex(null);
1026
+ }, [element, setHoveredColIndex]);
1027
+ return {
1028
+ props: {
1029
+ colSpan: element.colSpan,
1030
+ rowSpan: element.rowSpan
1031
+ }
1032
+ };
1033
+ };
1034
+ var useSelectedCells = () => {
1035
+ const readOnly = slateReact.useReadOnly();
1036
+ const selected = slateReact.useSelected();
1037
+ const editor = index$1.useEditorRef();
1038
+ const [selectedCells, setSelectedCells] = useTableStore().use.selectedCells();
1039
+ const setSelectedTable = useTableStore().set.selectedTable();
1040
+ React__default.default.useEffect(() => {
1041
+ if (!selected || readOnly) {
1042
+ setSelectedCells(null);
1043
+ setSelectedTable(null);
1044
+ }
1045
+ }, [selected, editor, setSelectedCells, readOnly, setSelectedTable]);
1046
+ React__default.default.useEffect(() => {
1047
+ if (readOnly)
1048
+ return;
1049
+ const tableEntries = getTableGridAbove(editor, { format: "table" });
1050
+ const cellEntries = getTableGridAbove(editor, { format: "cell" });
1051
+ if ((cellEntries == null ? void 0 : cellEntries.length) > 1) {
1052
+ const cells = cellEntries.map((entry) => entry[0]);
1053
+ const tables = tableEntries.map((entry) => entry[0]);
1054
+ if (JSON.stringify(cells) !== JSON.stringify(selectedCells)) {
1055
+ setSelectedCells(cells);
1056
+ setSelectedTable(tables);
1057
+ }
1058
+ } else if (selectedCells) {
1059
+ setSelectedCells(null);
1060
+ setSelectedTable(null);
1061
+ }
1062
+ }, [
1063
+ editor,
1064
+ editor.selection,
1065
+ readOnly,
1066
+ selectedCells,
1067
+ setSelectedCells,
1068
+ setSelectedTable
1069
+ ]);
1070
+ };
1071
+ var useTableElementState = ({
1072
+ transformColSizes
1073
+ } = {}) => {
1074
+ var _a;
1075
+ const editor = index$1.useEditorRef();
1076
+ const { minColumnWidth, disableMarginLeft, enableMerging } = index$1.getPluginOptions(editor, ELEMENT_TABLE);
1077
+ const element = index$1.useElement();
1078
+ const selectedCells = useTableStore().get.selectedCells();
1079
+ const marginLeftOverride = useTableStore().get.marginLeftOverride();
1080
+ const marginLeft = disableMarginLeft ? 0 : (_a = marginLeftOverride != null ? marginLeftOverride : element.marginLeft) != null ? _a : 0;
1081
+ let colSizes = useTableColSizes(element);
1082
+ React__default.default.useEffect(() => {
1083
+ if (enableMerging) {
1084
+ computeAllCellIndices(editor, element);
1085
+ }
1086
+ }, [editor, element, enableMerging]);
1087
+ if (transformColSizes) {
1088
+ colSizes = transformColSizes(colSizes);
1089
+ }
1090
+ if (!colSizes.includes(0)) {
1091
+ colSizes.push("100%");
1092
+ }
1093
+ return {
1094
+ colSizes,
1095
+ isSelectingCell: !!selectedCells,
1096
+ minColumnWidth,
1097
+ marginLeft
1098
+ };
1099
+ };
1100
+ var useTableElement = () => {
1101
+ const editor = index$1.useEditorRef();
1102
+ const selectedCells = useTableStore().get.selectedCells();
1103
+ useSelectedCells();
1104
+ return {
1105
+ props: {
1106
+ onMouseDown: () => {
1107
+ if (selectedCells) {
1108
+ index$4.collapseSelection(editor);
1109
+ }
1110
+ }
1111
+ },
1112
+ colGroupProps: {
1113
+ contentEditable: false,
1114
+ style: { width: "100%" }
1115
+ }
1116
+ };
1117
+ };
1118
+
1119
+ // src/merge/isTableRectangular.ts
1120
+ var allEqual = (arr) => arr.every((val) => val === arr[0]);
1121
+ var isTableRectangular = (table) => {
1122
+ var _a;
1123
+ const arr = [];
1124
+ (_a = table == null ? void 0 : table.children) == null ? void 0 : _a.forEach((row, rI) => {
1125
+ var _a2;
1126
+ const rowEl = row;
1127
+ (_a2 = rowEl.children) == null ? void 0 : _a2.forEach((cell) => {
1128
+ const cellElem = cell;
1129
+ Array.from({
1130
+ length: getRowSpan(cellElem) || 1
1131
+ }).forEach((_, i) => {
1132
+ if (!arr[rI + i]) {
1133
+ arr[rI + i] = 0;
1134
+ }
1135
+ arr[rI + i] += (cellElem == null ? void 0 : cellElem.colSpan) || 1;
1136
+ });
1137
+ });
1138
+ });
1139
+ return allEqual(arr);
1140
+ };
1141
+ var mergeTableCells = (editor) => {
1142
+ index$4.withoutNormalizing(editor, () => {
1143
+ var _a;
1144
+ const { _cellIndices } = index$1.getPluginOptions(
1145
+ editor,
1146
+ ELEMENT_TABLE
1147
+ );
1148
+ const tableEntry = index$5.getBlockAbove(editor, {
1149
+ at: (_a = editor.selection) == null ? void 0 : _a.anchor.path,
1150
+ match: { type: index$1.getPluginType(editor, ELEMENT_TABLE) }
1151
+ });
1152
+ const cellEntries = getTableGridAbove(editor, { format: "cell" });
1153
+ let colSpan = 0;
1154
+ for (const entry of cellEntries) {
1155
+ const [data, path] = entry;
1156
+ const rowIndex = path.at(-2);
1157
+ if (rowIndex === cellEntries[0][1].at(-2)) {
1158
+ const cellColSpan = getColSpan(data);
1159
+ colSpan += cellColSpan;
1160
+ }
1161
+ }
1162
+ let rowSpan = 0;
1163
+ const { col } = getCellIndices(
1164
+ _cellIndices,
1165
+ cellEntries[0][0]
1166
+ );
1167
+ cellEntries.forEach((cE) => {
1168
+ const cell = cE[0];
1169
+ const { col: curCol } = (_cellIndices == null ? void 0 : _cellIndices.get(cell)) || computeCellIndices(editor, tableEntry[0], cell);
1170
+ if (col === curCol) {
1171
+ rowSpan += getRowSpan(cell);
1172
+ }
1173
+ });
1174
+ const contents = [];
1175
+ for (const cellEntry of cellEntries) {
1176
+ const [el] = cellEntry;
1177
+ if (el.children.length !== 1 || !index$4.isElementEmpty(editor, el.children[0])) {
1178
+ contents.push(...cloneDeep.default(el.children));
1179
+ }
1180
+ }
1181
+ const cols = {};
1182
+ cellEntries.forEach(([entry, path]) => {
1183
+ const rowIndex = path.at(-2);
1184
+ if (cols[rowIndex]) {
1185
+ cols[rowIndex].push(path);
1186
+ } else {
1187
+ cols[rowIndex] = [path];
1188
+ }
1189
+ });
1190
+ Object.values(cols).forEach((paths) => {
1191
+ paths == null ? void 0 : paths.forEach(() => {
1192
+ index$4.removeNodes(editor, { at: paths[0] });
1193
+ });
1194
+ });
1195
+ const mergedCell = __spreadProps(__spreadValues({}, getEmptyCellNode(editor, {
1196
+ header: cellEntries[0][0].type === index$1.getPluginType(editor, ELEMENT_TH),
1197
+ newCellChildren: contents
1198
+ })), {
1199
+ colSpan,
1200
+ rowSpan
1201
+ });
1202
+ index$5.insertElements(editor, mergedCell, { at: cellEntries[0][1] });
1203
+ index$4.collapseSelection(editor);
1204
+ });
1205
+ };
1206
+ var unmergeTableCells = (editor) => {
1207
+ index$4.withoutNormalizing(editor, () => {
1208
+ const { _cellIndices: cellIndices } = index$1.getPluginOptions(
1209
+ editor,
1210
+ ELEMENT_TABLE
1211
+ );
1212
+ const cellEntries = getTableGridAbove(editor, { format: "cell" });
1213
+ const [[cellElem, path]] = cellEntries;
1214
+ const createEmptyCell2 = (children) => {
1215
+ return __spreadProps(__spreadValues({}, getEmptyCellNode(editor, {
1216
+ header: cellElem.type === index$1.getPluginType(editor, ELEMENT_TH),
1217
+ newCellChildren: children
1218
+ })), {
1219
+ colSpan: 1,
1220
+ rowSpan: 1
1221
+ });
1222
+ };
1223
+ const tablePath = path.slice(0, -2);
1224
+ const cellPath = path.slice(-2);
1225
+ const [rowPath, colPath] = cellPath;
1226
+ const colSpan = getColSpan(cellElem);
1227
+ const rowSpan = getRowSpan(cellElem);
1228
+ const colPaths = [];
1229
+ for (let i = 0; i < colSpan; i++) {
1230
+ colPaths.push(colPath + i);
1231
+ }
1232
+ index$4.removeNodes(editor, { at: path });
1233
+ const { col } = getCellIndices(
1234
+ cellIndices,
1235
+ cellElem
1236
+ );
1237
+ const getColPathForRow = (row) => {
1238
+ let newColPath = 0;
1239
+ const rowEntry = index$4.findNode(editor, {
1240
+ at: [...tablePath, row],
1241
+ match: { type: index$1.getPluginType(editor, ELEMENT_TR) }
1242
+ });
1243
+ if (!rowEntry) {
1244
+ return newColPath;
1245
+ }
1246
+ const rowEl = rowEntry[0];
1247
+ for (const item of rowEl.children) {
1248
+ const { col: c } = getCellIndices(
1249
+ cellIndices,
1250
+ item
1251
+ );
1252
+ if (c === col - 1) {
1253
+ newColPath = rowEl.children.indexOf(item) + 1;
1254
+ break;
1255
+ }
1256
+ if (col + getColSpan(cellElem) === c - 1) {
1257
+ newColPath = rowEl.children.indexOf(item);
1258
+ break;
1259
+ }
1260
+ }
1261
+ return newColPath;
1262
+ };
1263
+ for (let i = 0; i < rowSpan; i++) {
1264
+ const currentRowPath = rowPath + i;
1265
+ const pathForNextRows = getColPathForRow(currentRowPath);
1266
+ const newRowChildren = [];
1267
+ const _rowPath = [...tablePath, currentRowPath];
1268
+ const rowEntry = index$4.findNode(editor, {
1269
+ at: _rowPath,
1270
+ match: { type: index$1.getPluginType(editor, ELEMENT_TABLE) }
1271
+ });
1272
+ for (let j = 0; j < colPaths.length; j++) {
1273
+ const cellToInsert = i === 0 && j === 0 ? createEmptyCell2(cellElem.children) : createEmptyCell2();
1274
+ if (rowEntry) {
1275
+ const currentColPath = i === 0 ? colPaths[j] : pathForNextRows;
1276
+ const pathForNewCell = [...tablePath, currentRowPath, currentColPath];
1277
+ index$5.insertElements(editor, cellToInsert, { at: pathForNewCell });
1278
+ } else {
1279
+ newRowChildren.push(cellToInsert);
1280
+ }
1281
+ }
1282
+ if (!rowEntry) {
1283
+ index$5.insertElements(
1284
+ editor,
1285
+ {
1286
+ type: index$1.getPluginType(editor, ELEMENT_TR),
1287
+ children: newRowChildren
1288
+ },
1289
+ { at: _rowPath }
1290
+ );
1291
+ }
1292
+ }
1293
+ });
1294
+ };
1295
+ var useTableMergeState = () => {
1296
+ const editorRef = index$1.useEditorRef();
1297
+ const { enableMerging } = index$1.getPluginOptions(
1298
+ editorRef,
1299
+ ELEMENT_TABLE
1300
+ );
1301
+ if (!enableMerging)
1302
+ return { canMerge: false, canUnmerge: false };
1303
+ const readOnly = slateReact.useReadOnly();
1304
+ const selected = slateReact.useSelected();
1305
+ const selectionExpanded = index$1.useEditorSelector(index$5.isSelectionExpanded, []);
1306
+ const collapsed = !readOnly && selected && !selectionExpanded;
1307
+ const selectedTables = useTableStore().get.selectedTable();
1308
+ const selectedTable = selectedTables == null ? void 0 : selectedTables[0];
1309
+ const selectedCellEntries = index$1.useEditorSelector(
1310
+ (editor) => getTableGridAbove(editor, {
1311
+ format: "cell"
1312
+ }),
1313
+ []
1314
+ );
1315
+ const canMerge = !readOnly && selected && selectionExpanded && isTableRectangular(selectedTable);
1316
+ const canUnmerge = collapsed && selectedCellEntries && selectedCellEntries.length === 1 && (getColSpan(selectedCellEntries[0][0]) > 1 || getRowSpan(selectedCellEntries[0][0]) > 1);
1317
+ return { canMerge, canUnmerge };
1318
+ };
1319
+
1320
+ exports.ELEMENT_TABLE = ELEMENT_TABLE;
1321
+ exports.ELEMENT_TD = ELEMENT_TD;
1322
+ exports.ELEMENT_TH = ELEMENT_TH;
1323
+ exports.ELEMENT_TR = ELEMENT_TR;
1324
+ exports.TableProvider = TableProvider;
1325
+ exports.computeAllCellIndices = computeAllCellIndices;
1326
+ exports.computeCellIndices = computeCellIndices;
1327
+ exports.findCellByIndexes = findCellByIndexes;
1328
+ exports.getCellIndices = getCellIndices;
1329
+ exports.getCellIndicesWithSpans = getCellIndicesWithSpans;
1330
+ exports.getCellTypes = getCellTypes;
1331
+ exports.getColSpan = getColSpan;
1332
+ exports.getEmptyCellNode = getEmptyCellNode;
1333
+ exports.getEmptyRowNode = getEmptyRowNode;
1334
+ exports.getEmptyTableNode = getEmptyTableNode;
1335
+ exports.getLeftTableCell = getLeftTableCell;
1336
+ exports.getOnSelectTableBorderFactory = getOnSelectTableBorderFactory;
1337
+ exports.getRowSpan = getRowSpan;
1338
+ exports.getTableCellBorders = getTableCellBorders;
1339
+ exports.getTableColumnCount = getTableColumnCount;
1340
+ exports.getTableColumnIndex = getTableColumnIndex;
1341
+ exports.getTableGridAbove = getTableGridAbove;
1342
+ exports.getTableGridByRange = getTableGridByRange;
1343
+ exports.getTableMergeGridByRange = getTableMergeGridByRange;
1344
+ exports.getTableOverriddenColSizes = getTableOverriddenColSizes;
1345
+ exports.getTableRowIndex = getTableRowIndex;
1346
+ exports.getTopTableCell = getTopTableCell;
1347
+ exports.isTableBorderHidden = isTableBorderHidden;
1348
+ exports.isTableRectangular = isTableRectangular;
1349
+ exports.mergeTableCells = mergeTableCells;
1350
+ exports.roundCellSizeToStep = roundCellSizeToStep;
1351
+ exports.setBorderSize = setBorderSize;
1352
+ exports.setTableColSize = setTableColSize;
1353
+ exports.setTableMarginLeft = setTableMarginLeft;
1354
+ exports.setTableRowSize = setTableRowSize;
1355
+ exports.tableStore = tableStore;
1356
+ exports.unmergeTableCells = unmergeTableCells;
1357
+ exports.useIsCellSelected = useIsCellSelected;
1358
+ exports.useOverrideColSize = useOverrideColSize;
1359
+ exports.useOverrideMarginLeft = useOverrideMarginLeft;
1360
+ exports.useOverrideRowSize = useOverrideRowSize;
1361
+ exports.useSelectedCells = useSelectedCells;
1362
+ exports.useTableBordersDropdownMenuContentState = useTableBordersDropdownMenuContentState;
1363
+ exports.useTableCellElement = useTableCellElement;
1364
+ exports.useTableCellElementResizable = useTableCellElementResizable;
1365
+ exports.useTableCellElementResizableState = useTableCellElementResizableState;
1366
+ exports.useTableCellElementState = useTableCellElementState;
1367
+ exports.useTableColSizes = useTableColSizes;
1368
+ exports.useTableElement = useTableElement;
1369
+ exports.useTableElementState = useTableElementState;
1370
+ exports.useTableMergeState = useTableMergeState;
1371
+ exports.useTableStore = useTableStore;