@fewangsit/wangsvue 1.5.219-alpha.0 → 1.5.219-alpha.2

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 (598) hide show
  1. package/animation/index.es.js +54 -37
  2. package/assets/lottiejs/loading-page.es.js +14 -9
  3. package/assets/lottiejs/loading-plane.es.js +2 -2
  4. package/assets/lottiejs/loading-table.es.js +14 -9
  5. package/assets/lottiejs/no-data.es.js +14 -9
  6. package/backgroundimagecropper/index.es.js +61 -37
  7. package/badge/index.es.js +77 -67
  8. package/badgegroup/index.es.js +62 -50
  9. package/basecalendar/index.es.js +1258 -735
  10. package/basetree/index.es.js +213 -113
  11. package/breadcrumb/index.es.js +46 -38
  12. package/button/index.es.js +60 -54
  13. package/buttonbulkaction/index.es.js +168 -117
  14. package/buttoncopy/index.es.js +25 -22
  15. package/buttondownload/index.es.js +125 -76
  16. package/buttonfilter/index.es.js +21 -15
  17. package/buttonradio/index.es.js +91 -67
  18. package/buttonsearch/index.es.js +62 -46
  19. package/buttonselecttree/index.es.js +233 -172
  20. package/buttontoggle/index.es.js +8 -6
  21. package/calendar/index.es.js +113 -58
  22. package/card/index.es.js +44 -42
  23. package/checkbox/index.es.js +105 -74
  24. package/codesnippet/index.es.js +91 -71
  25. package/codesnippetadapter/index.es.js +25 -21
  26. package/columnlist/index.es.js +249 -171
  27. package/components.d.ts +0 -21
  28. package/config/defaultProps.es.js +9 -9
  29. package/config/index.es.js +11 -10
  30. package/config/locale.es.js +2 -2
  31. package/customcolumn/index.es.js +95 -78
  32. package/datatable/index.es.js +1071 -732
  33. package/dialog/index.es.js +54 -54
  34. package/dialogconfirm/index.es.js +90 -75
  35. package/dialogform/index.es.js +170 -133
  36. package/dialogselecttree/index.es.js +242 -194
  37. package/directives/focus.es.js +13 -8
  38. package/dropdown/index.es.js +250 -196
  39. package/editor/index.es.js +694 -498
  40. package/editorbutton/index.es.js +21 -19
  41. package/event-bus/index.es.js +3 -3
  42. package/event-bus/mitt.es.js +37 -20
  43. package/fieldwrapper/index.es.js +30 -25
  44. package/fileupload/index.es.js +230 -140
  45. package/filtercontainer/index.es.js +299 -222
  46. package/form/index.es.js +176 -126
  47. package/gallerypreview/index.es.js +138 -101
  48. package/icon/index.es.js +38 -36
  49. package/image/index.es.js +161 -108
  50. package/imagecompressor/index.es.js +616 -449
  51. package/imageinputinfo/index.es.js +26 -22
  52. package/inlinemessage/index.es.js +77 -65
  53. package/inputbadge/index.es.js +230 -156
  54. package/inputcurrency/index.es.js +146 -109
  55. package/inputemail/index.es.js +18 -16
  56. package/inputgroup/index.es.js +19 -16
  57. package/inputnumber/index.es.js +252 -182
  58. package/inputpassword/index.es.js +120 -94
  59. package/inputphonenumber/index.es.js +1017 -550
  60. package/inputrangenumber/index.es.js +129 -98
  61. package/inputtext/index.es.js +264 -189
  62. package/inputurl/index.es.js +31 -29
  63. package/invisiblefield/index.es.js +24 -16
  64. package/litedropdown/index.es.js +87 -81
  65. package/loading/index.es.js +21 -19
  66. package/loading-page-BXZ4fLOS.js +8 -0
  67. package/loading-page-BuLpsb_1.js +8 -0
  68. package/loading-page-CNqVBg__.js +4 -0
  69. package/loading-page-DbhhZih2.js +4 -0
  70. package/loading-page-DjfWXoOy.js +8 -0
  71. package/loading-page-S-KRY5zm.js +4 -0
  72. package/loading-plane-C1mi7Whv.js +4 -0
  73. package/loading-plane-CWq1hz_l.js +8 -0
  74. package/loading-table-B7LAXzAp.js +4 -0
  75. package/loading-table-BLmgKUsR.js +4 -0
  76. package/loading-table-CG7-cuhv.js +8 -0
  77. package/loading-table-CUPS49ta.js +4 -0
  78. package/loading-table-CuWWrTbv.js +8 -0
  79. package/loading-table-DbBzVwaZ.js +8 -0
  80. package/mentionlist/index.es.js +77 -44
  81. package/mentionsection/index.es.js +53 -43
  82. package/menu/index.es.js +65 -51
  83. package/menuitem/index.es.js +39 -37
  84. package/multirow/index.es.js +29 -28
  85. package/multiselect/index.es.js +184 -152
  86. package/no-data-B781skt3.js +4 -0
  87. package/no-data-CAksOnDl.js +4 -0
  88. package/no-data-DCsjBXQR.js +4 -0
  89. package/no-data-Dz0QOe7Q.js +8 -0
  90. package/no-data-_Huxiv9q.js +8 -0
  91. package/no-data-ybRQontJ.js +8 -0
  92. package/overlaypanel/index.es.js +49 -36
  93. package/package.json +1 -1
  94. package/paginator/index.es.js +36 -33
  95. package/plugins/WangsVue.es.js +63 -45
  96. package/plugins/formValidation.es.js +15 -11
  97. package/progressbar/index.es.js +39 -32
  98. package/quickfilter/index.es.js +94 -81
  99. package/stats.html +1 -1
  100. package/style.css +2 -2
  101. package/tabmenu/index.es.js +18 -16
  102. package/textarea/index.es.js +94 -72
  103. package/timeline/index.es.js +124 -102
  104. package/timelinecontentbytype/index.es.js +114 -92
  105. package/toast/index.es.js +67 -54
  106. package/toggleswitch/index.es.js +83 -66
  107. package/tree/index.es.js +306 -198
  108. package/treenode/index.es.js +464 -339
  109. package/treesearchinput/index.es.js +32 -26
  110. package/usergroup/index.es.js +83 -67
  111. package/username/index.es.js +99 -85
  112. package/utils/addAttachment.util.es.js +47 -21
  113. package/utils/baseToast.util.es.js +41 -33
  114. package/utils/convertJsonImage.util.es.js +24 -24
  115. package/utils/date.util.es.js +131 -106
  116. package/utils/exportToExcel.util.es.js +81 -47
  117. package/utils/filterOptions.util.es.js +8 -2
  118. package/utils/genPlaceholder.util.es.js +30 -16
  119. package/utils/getProjectPermission.util.es.js +15 -12
  120. package/utils/getSalesRole.util.es.js +4 -4
  121. package/utils/getUser.util.es.js +2 -2
  122. package/utils/getUserType.util.es.js +13 -8
  123. package/utils/isIntersect.es.js +4 -2
  124. package/utils/mergePropsWithDefaults.util.es.js +7 -6
  125. package/utils/object.util.es.js +88 -54
  126. package/utils/queryParamsStringfy.util.es.js +19 -11
  127. package/utils/role.util.es.js +5 -4
  128. package/utils/statusSeverity.util.es.js +20 -5
  129. package/utils/textFormatter.util.es.js +28 -50
  130. package/utils/toast.util.es.js +8 -5
  131. package/utils/xlsx.util.es.js +12 -6
  132. package/validatormessage/index.es.js +9 -9
  133. package/vendor/@popperjs/core/lib/createPopper.es.js +110 -83
  134. package/vendor/@popperjs/core/lib/dom-utils/contains.es.js +14 -13
  135. package/vendor/@popperjs/core/lib/dom-utils/getBoundingClientRect.es.js +33 -18
  136. package/vendor/@popperjs/core/lib/dom-utils/getClippingRect.es.js +55 -31
  137. package/vendor/@popperjs/core/lib/dom-utils/getCompositeRect.es.js +43 -22
  138. package/vendor/@popperjs/core/lib/dom-utils/getComputedStyle.es.js +4 -4
  139. package/vendor/@popperjs/core/lib/dom-utils/getDocumentElement.es.js +5 -5
  140. package/vendor/@popperjs/core/lib/dom-utils/getDocumentRect.es.js +23 -13
  141. package/vendor/@popperjs/core/lib/dom-utils/getHTMLElementScroll.es.js +4 -4
  142. package/vendor/@popperjs/core/lib/dom-utils/getLayoutRect.es.js +17 -9
  143. package/vendor/@popperjs/core/lib/dom-utils/getNodeName.es.js +3 -3
  144. package/vendor/@popperjs/core/lib/dom-utils/getNodeScroll.es.js +11 -7
  145. package/vendor/@popperjs/core/lib/dom-utils/getOffsetParent.es.js +42 -26
  146. package/vendor/@popperjs/core/lib/dom-utils/getParentNode.es.js +13 -10
  147. package/vendor/@popperjs/core/lib/dom-utils/getScrollParent.es.js +13 -7
  148. package/vendor/@popperjs/core/lib/dom-utils/getViewportRect.es.js +25 -15
  149. package/vendor/@popperjs/core/lib/dom-utils/getWindow.es.js +8 -7
  150. package/vendor/@popperjs/core/lib/dom-utils/getWindowScroll.es.js +8 -6
  151. package/vendor/@popperjs/core/lib/dom-utils/getWindowScrollBarX.es.js +6 -6
  152. package/vendor/@popperjs/core/lib/dom-utils/instanceOf.es.js +16 -15
  153. package/vendor/@popperjs/core/lib/dom-utils/isLayoutViewport.es.js +4 -4
  154. package/vendor/@popperjs/core/lib/dom-utils/isScrollParent.es.js +5 -5
  155. package/vendor/@popperjs/core/lib/dom-utils/isTableElement.es.js +4 -4
  156. package/vendor/@popperjs/core/lib/dom-utils/listScrollParents.es.js +17 -11
  157. package/vendor/@popperjs/core/lib/enums.es.js +43 -20
  158. package/vendor/@popperjs/core/lib/modifiers/applyStyles.es.js +49 -25
  159. package/vendor/@popperjs/core/lib/modifiers/arrow.es.js +61 -26
  160. package/vendor/@popperjs/core/lib/modifiers/computeStyles.es.js +101 -69
  161. package/vendor/@popperjs/core/lib/modifiers/eventListeners.es.js +30 -16
  162. package/vendor/@popperjs/core/lib/modifiers/flip.es.js +99 -60
  163. package/vendor/@popperjs/core/lib/modifiers/hide.es.js +44 -31
  164. package/vendor/@popperjs/core/lib/modifiers/offset.es.js +32 -20
  165. package/vendor/@popperjs/core/lib/modifiers/popperOffsets.es.js +11 -11
  166. package/vendor/@popperjs/core/lib/modifiers/preventOverflow.es.js +91 -40
  167. package/vendor/@popperjs/core/lib/popper.es.js +14 -13
  168. package/vendor/@popperjs/core/lib/utils/computeAutoPlacement.es.js +29 -21
  169. package/vendor/@popperjs/core/lib/utils/computeOffsets.es.js +41 -36
  170. package/vendor/@popperjs/core/lib/utils/debounce.es.js +11 -7
  171. package/vendor/@popperjs/core/lib/utils/detectOverflow.es.js +42 -28
  172. package/vendor/@popperjs/core/lib/utils/expandToHashMap.es.js +5 -4
  173. package/vendor/@popperjs/core/lib/utils/getAltAxis.es.js +3 -3
  174. package/vendor/@popperjs/core/lib/utils/getBasePlacement.es.js +3 -3
  175. package/vendor/@popperjs/core/lib/utils/getFreshSideObject.es.js +2 -2
  176. package/vendor/@popperjs/core/lib/utils/getMainAxisFromPlacement.es.js +3 -3
  177. package/vendor/@popperjs/core/lib/utils/getOppositePlacement.es.js +5 -5
  178. package/vendor/@popperjs/core/lib/utils/getOppositeVariationPlacement.es.js +5 -5
  179. package/vendor/@popperjs/core/lib/utils/getVariation.es.js +3 -3
  180. package/vendor/@popperjs/core/lib/utils/math.es.js +6 -4
  181. package/vendor/@popperjs/core/lib/utils/mergeByName.es.js +11 -10
  182. package/vendor/@popperjs/core/lib/utils/mergePaddingObject.es.js +4 -4
  183. package/vendor/@popperjs/core/lib/utils/orderModifiers.es.js +30 -22
  184. package/vendor/@popperjs/core/lib/utils/rectToClientRect.es.js +7 -7
  185. package/vendor/@popperjs/core/lib/utils/userAgent.es.js +9 -6
  186. package/vendor/@popperjs/core/lib/utils/within.es.js +8 -8
  187. package/vendor/@tiptap/core/dist/index.es.js +3494 -2000
  188. package/vendor/@tiptap/extension-bold/dist/index.es.js +29 -19
  189. package/vendor/@tiptap/extension-bubble-menu/dist/index.es.js +145 -71
  190. package/vendor/@tiptap/extension-bullet-list/dist/index.es.js +32 -19
  191. package/vendor/@tiptap/extension-code/dist/index.es.js +22 -14
  192. package/vendor/@tiptap/extension-document/dist/index.es.js +4 -4
  193. package/vendor/@tiptap/extension-floating-menu/dist/index.es.js +106 -51
  194. package/vendor/@tiptap/extension-heading/dist/index.es.js +38 -22
  195. package/vendor/@tiptap/extension-history/dist/index.es.js +11 -7
  196. package/vendor/@tiptap/extension-image/dist/index.es.js +20 -17
  197. package/vendor/@tiptap/extension-italic/dist/index.es.js +28 -18
  198. package/vendor/@tiptap/extension-link/dist/index.es.js +236 -147
  199. package/vendor/@tiptap/extension-list-item/dist/index.es.js +6 -6
  200. package/vendor/@tiptap/extension-mention/dist/index.es.js +98 -63
  201. package/vendor/@tiptap/extension-ordered-list/dist/index.es.js +38 -25
  202. package/vendor/@tiptap/extension-paragraph/dist/index.es.js +8 -6
  203. package/vendor/@tiptap/extension-placeholder/dist/index.es.js +34 -27
  204. package/vendor/@tiptap/extension-text/dist/index.es.js +3 -3
  205. package/vendor/@tiptap/extension-underline/dist/index.es.js +16 -10
  206. package/vendor/@tiptap/suggestion/dist/index.es.js +174 -90
  207. package/vendor/@tiptap/vue-3/dist/index.es.js +287 -188
  208. package/vendor/@wangs-ui/core/components/p-BU8h34na.es.js +17 -14
  209. package/vendor/@wangs-ui/core/components/p-C5lMEBcj.es.js +69 -55
  210. package/vendor/@wangs-ui/core/components/p-CKYwZoTo.es.js +26 -22
  211. package/vendor/@wangs-ui/core/components/p-CsoK-EWG.es.js +147 -102
  212. package/vendor/@wangs-ui/core/components/p-DPHEi31J.es.js +102 -77
  213. package/vendor/@wangs-ui/core/components/p-DTTCzifR.es.js +1298 -551
  214. package/vendor/@wangs-ui/core/components/p-Duri5p90.es.js +60 -49
  215. package/vendor/@wangs-ui/core/components/wangs-button.es.js +19 -15
  216. package/vendor/@wangs-ui/core/components/wangs-icon.es.js +3 -3
  217. package/vendor/@wangs-ui/core/components/wangs-input-otp.es.js +3 -3
  218. package/vendor/@wangs-ui/core/components/wangs-tab-menu.es.js +3 -3
  219. package/vendor/@wangs-ui/core/dist/esm/index-DCkh3cGv.es.js +116 -102
  220. package/vendor/@wangs-ui/vue/dist/index.es.js +77 -77
  221. package/vendor/base64toblob/base64toblob.es.js +31 -15
  222. package/vendor/highlight.js/es/core.es.js +5 -5
  223. package/vendor/highlight.js/es/languages/javascript.es.js +237 -193
  224. package/vendor/highlight.js/es/languages/json.es.js +18 -15
  225. package/vendor/highlight.js/es/languages/typescript.es.js +288 -228
  226. package/vendor/highlight.js/es/languages/vbscript-html.es.js +2 -2
  227. package/vendor/highlight.js/lib/core.es.js +1144 -666
  228. package/vendor/linkifyjs/dist/linkify.es.es.js +858 -405
  229. package/vendor/lodash/_Symbol.es.js +11 -8
  230. package/vendor/lodash/_baseGetTag.es.js +19 -12
  231. package/vendor/lodash/_baseTrim.es.js +13 -10
  232. package/vendor/lodash/_freeGlobal.es.js +10 -8
  233. package/vendor/lodash/_getRawTag.es.js +28 -15
  234. package/vendor/lodash/_objectToString.es.js +12 -9
  235. package/vendor/lodash/_root.es.js +12 -8
  236. package/vendor/lodash/_trimmedEndIndex.es.js +14 -11
  237. package/vendor/lodash/debounce.es.js +92 -54
  238. package/vendor/lodash/isObject.es.js +11 -9
  239. package/vendor/lodash/isObjectLike.es.js +10 -8
  240. package/vendor/lodash/isSymbol.es.js +14 -11
  241. package/vendor/lodash/now.es.js +12 -9
  242. package/vendor/lodash/throttle.es.js +25 -17
  243. package/vendor/lodash/toNumber.es.js +33 -23
  244. package/vendor/lodash-es/_DataView.es.js +4 -4
  245. package/vendor/lodash-es/_Hash.es.js +17 -16
  246. package/vendor/lodash-es/_ListCache.es.js +17 -16
  247. package/vendor/lodash-es/_Map.es.js +4 -4
  248. package/vendor/lodash-es/_MapCache.es.js +17 -16
  249. package/vendor/lodash-es/_Promise.es.js +4 -4
  250. package/vendor/lodash-es/_Set.es.js +4 -4
  251. package/vendor/lodash-es/_SetCache.es.js +12 -10
  252. package/vendor/lodash-es/_Stack.es.js +15 -15
  253. package/vendor/lodash-es/_Symbol.es.js +3 -3
  254. package/vendor/lodash-es/_Uint8Array.es.js +3 -3
  255. package/vendor/lodash-es/_WeakMap.es.js +4 -4
  256. package/vendor/lodash-es/_arrayEach.es.js +9 -5
  257. package/vendor/lodash-es/_arrayFilter.es.js +9 -6
  258. package/vendor/lodash-es/_arrayLikeKeys.es.js +21 -17
  259. package/vendor/lodash-es/_arrayPush.es.js +7 -5
  260. package/vendor/lodash-es/_arraySome.es.js +9 -6
  261. package/vendor/lodash-es/_assignValue.es.js +10 -7
  262. package/vendor/lodash-es/_assocIndexOf.es.js +9 -6
  263. package/vendor/lodash-es/_baseAssignValue.es.js +13 -9
  264. package/vendor/lodash-es/_baseClone.es.js +67 -49
  265. package/vendor/lodash-es/_baseCreate.es.js +15 -11
  266. package/vendor/lodash-es/_baseGetAllKeys.es.js +6 -6
  267. package/vendor/lodash-es/_baseGetTag.es.js +11 -7
  268. package/vendor/lodash-es/_baseIsArguments.es.js +6 -6
  269. package/vendor/lodash-es/_baseIsEqual.es.js +11 -5
  270. package/vendor/lodash-es/_baseIsEqualDeep.es.js +39 -26
  271. package/vendor/lodash-es/_baseIsMap.es.js +6 -6
  272. package/vendor/lodash-es/_baseIsNative.es.js +18 -12
  273. package/vendor/lodash-es/_baseIsSet.es.js +6 -6
  274. package/vendor/lodash-es/_baseIsTypedArray.es.js +11 -9
  275. package/vendor/lodash-es/_baseKeys.es.js +16 -11
  276. package/vendor/lodash-es/_baseTimes.es.js +7 -5
  277. package/vendor/lodash-es/_baseTrim.es.js +5 -5
  278. package/vendor/lodash-es/_baseUnary.es.js +4 -4
  279. package/vendor/lodash-es/_cacheHas.es.js +3 -3
  280. package/vendor/lodash-es/_cloneArrayBuffer.es.js +6 -5
  281. package/vendor/lodash-es/_cloneBuffer.es.js +11 -6
  282. package/vendor/lodash-es/_cloneDataView.es.js +5 -5
  283. package/vendor/lodash-es/_cloneRegExp.es.js +6 -5
  284. package/vendor/lodash-es/_cloneSymbol.es.js +5 -5
  285. package/vendor/lodash-es/_cloneTypedArray.es.js +5 -5
  286. package/vendor/lodash-es/_coreJsData.es.js +3 -3
  287. package/vendor/lodash-es/_defineProperty.es.js +7 -6
  288. package/vendor/lodash-es/_equalArrays.es.js +38 -28
  289. package/vendor/lodash-es/_equalByTag.es.js +55 -41
  290. package/vendor/lodash-es/_equalObjects.es.js +42 -28
  291. package/vendor/lodash-es/_freeGlobal.es.js +2 -2
  292. package/vendor/lodash-es/_getAllKeys.es.js +6 -6
  293. package/vendor/lodash-es/_getMapData.es.js +5 -5
  294. package/vendor/lodash-es/_getNative.es.js +6 -6
  295. package/vendor/lodash-es/_getPrototype.es.js +3 -3
  296. package/vendor/lodash-es/_getRawTag.es.js +20 -10
  297. package/vendor/lodash-es/_getSymbols.es.js +15 -8
  298. package/vendor/lodash-es/_getTag.es.js +31 -25
  299. package/vendor/lodash-es/_getValue.es.js +3 -3
  300. package/vendor/lodash-es/_hashClear.es.js +5 -4
  301. package/vendor/lodash-es/_hashDelete.es.js +5 -4
  302. package/vendor/lodash-es/_hashGet.es.js +11 -9
  303. package/vendor/lodash-es/_hashHas.es.js +7 -6
  304. package/vendor/lodash-es/_hashSet.es.js +8 -6
  305. package/vendor/lodash-es/_initCloneArray.es.js +10 -5
  306. package/vendor/lodash-es/_initCloneByTag.es.js +39 -38
  307. package/vendor/lodash-es/_initCloneObject.es.js +6 -6
  308. package/vendor/lodash-es/_isIndex.es.js +7 -5
  309. package/vendor/lodash-es/_isKeyable.es.js +4 -4
  310. package/vendor/lodash-es/_isMasked.es.js +7 -7
  311. package/vendor/lodash-es/_isPrototype.es.js +5 -5
  312. package/vendor/lodash-es/_listCacheClear.es.js +4 -3
  313. package/vendor/lodash-es/_listCacheDelete.es.js +17 -9
  314. package/vendor/lodash-es/_listCacheGet.es.js +5 -5
  315. package/vendor/lodash-es/_listCacheHas.es.js +4 -4
  316. package/vendor/lodash-es/_listCacheSet.es.js +11 -5
  317. package/vendor/lodash-es/_mapCacheClear.es.js +10 -9
  318. package/vendor/lodash-es/_mapCacheDelete.es.js +6 -5
  319. package/vendor/lodash-es/_mapCacheGet.es.js +4 -4
  320. package/vendor/lodash-es/_mapCacheHas.es.js +4 -4
  321. package/vendor/lodash-es/_mapCacheSet.es.js +7 -5
  322. package/vendor/lodash-es/_mapToArray.es.js +7 -6
  323. package/vendor/lodash-es/_nativeCreate.es.js +3 -3
  324. package/vendor/lodash-es/_nativeKeys.es.js +3 -3
  325. package/vendor/lodash-es/_nodeUtil.es.js +13 -6
  326. package/vendor/lodash-es/_objectToString.es.js +5 -4
  327. package/vendor/lodash-es/_overArg.es.js +4 -4
  328. package/vendor/lodash-es/_root.es.js +4 -3
  329. package/vendor/lodash-es/_setCacheAdd.es.js +5 -4
  330. package/vendor/lodash-es/_setCacheHas.es.js +3 -3
  331. package/vendor/lodash-es/_setToArray.es.js +7 -6
  332. package/vendor/lodash-es/_stackClear.es.js +5 -4
  333. package/vendor/lodash-es/_stackDelete.es.js +5 -4
  334. package/vendor/lodash-es/_stackGet.es.js +3 -3
  335. package/vendor/lodash-es/_stackHas.es.js +3 -3
  336. package/vendor/lodash-es/_stackSet.es.js +18 -13
  337. package/vendor/lodash-es/_toSource.es.js +9 -8
  338. package/vendor/lodash-es/_trimmedEndIndex.es.js +7 -6
  339. package/vendor/lodash-es/cloneDeep.es.js +5 -5
  340. package/vendor/lodash-es/debounce.es.js +84 -49
  341. package/vendor/lodash-es/eq.es.js +3 -3
  342. package/vendor/lodash-es/isArguments.es.js +9 -6
  343. package/vendor/lodash-es/isArray.es.js +2 -2
  344. package/vendor/lodash-es/isArrayLike.es.js +5 -5
  345. package/vendor/lodash-es/isBuffer.es.js +9 -4
  346. package/vendor/lodash-es/isEqual.es.js +4 -4
  347. package/vendor/lodash-es/isFunction.es.js +10 -9
  348. package/vendor/lodash-es/isLength.es.js +4 -4
  349. package/vendor/lodash-es/isMap.es.js +6 -5
  350. package/vendor/lodash-es/isObject.es.js +4 -4
  351. package/vendor/lodash-es/isObjectLike.es.js +3 -3
  352. package/vendor/lodash-es/isSet.es.js +6 -5
  353. package/vendor/lodash-es/isSymbol.es.js +6 -6
  354. package/vendor/lodash-es/isTypedArray.es.js +6 -5
  355. package/vendor/lodash-es/keys.es.js +6 -6
  356. package/vendor/lodash-es/now.es.js +4 -4
  357. package/vendor/lodash-es/stubArray.es.js +2 -2
  358. package/vendor/lodash-es/stubFalse.es.js +3 -3
  359. package/vendor/lodash-es/toNumber.es.js +25 -18
  360. package/vendor/lodash-es/toString.es.js +2 -2
  361. package/vendor/lodash-es/uniqueId.es.js +6 -6
  362. package/vendor/orderedmap/dist/index.es.js +65 -49
  363. package/vendor/primevue/api/api.esm.es.js +214 -121
  364. package/vendor/primevue/avatar/avatar.esm.es.js +44 -41
  365. package/vendor/primevue/avatar/style/avatarstyle.esm.es.js +12 -11
  366. package/vendor/primevue/avatargroup/avatargroup.esm.es.js +17 -16
  367. package/vendor/primevue/avatargroup/style/avatargroupstyle.esm.es.js +6 -5
  368. package/vendor/primevue/badge/badge.esm.es.js +21 -20
  369. package/vendor/primevue/badge/style/badgestyle.esm.es.js +19 -18
  370. package/vendor/primevue/base/style/basestyle.esm.es.js +88 -99
  371. package/vendor/primevue/basecomponent/basecomponent.esm.es.js +327 -261
  372. package/vendor/primevue/basedirective/basedirective.esm.es.js +257 -186
  373. package/vendor/primevue/baseicon/baseicon.esm.es.js +55 -49
  374. package/vendor/primevue/baseicon/style/baseiconstyle.esm.es.js +5 -35
  375. package/vendor/primevue/button/button.esm.es.js +76 -72
  376. package/vendor/primevue/button/style/buttonstyle.esm.es.js +46 -39
  377. package/vendor/primevue/card/card.esm.es.js +30 -29
  378. package/vendor/primevue/card/style/cardstyle.esm.es.js +6 -5
  379. package/vendor/primevue/checkbox/checkbox.esm.es.js +109 -101
  380. package/vendor/primevue/checkbox/style/checkboxstyle.esm.es.js +12 -11
  381. package/vendor/primevue/config/config.esm.es.js +76 -58
  382. package/vendor/primevue/dialog/dialog.esm.es.js +421 -281
  383. package/vendor/primevue/dialog/style/dialogstyle.esm.es.js +26 -22
  384. package/vendor/primevue/dropdown/dropdown.esm.es.js +956 -742
  385. package/vendor/primevue/dropdown/style/dropdownstyle.esm.es.js +33 -31
  386. package/vendor/primevue/fileupload/fileupload.esm.es.js +559 -450
  387. package/vendor/primevue/fileupload/style/fileuploadstyle.esm.es.js +14 -13
  388. package/vendor/primevue/focustrap/focustrap.esm.es.js +128 -90
  389. package/vendor/primevue/focustrap/style/focustrapstyle.esm.es.js +2 -2
  390. package/vendor/primevue/icons/angledoubleleft/index.esm.es.js +13 -11
  391. package/vendor/primevue/icons/angledoubleright/index.esm.es.js +13 -11
  392. package/vendor/primevue/icons/angledown/index.esm.es.js +13 -11
  393. package/vendor/primevue/icons/angleleft/index.esm.es.js +13 -11
  394. package/vendor/primevue/icons/angleright/index.esm.es.js +13 -11
  395. package/vendor/primevue/icons/angleup/index.esm.es.js +13 -11
  396. package/vendor/primevue/icons/blank/index.esm.es.js +13 -11
  397. package/vendor/primevue/icons/check/index.esm.es.js +13 -11
  398. package/vendor/primevue/icons/chevrondown/index.esm.es.js +13 -11
  399. package/vendor/primevue/icons/exclamationtriangle/index.esm.es.js +17 -13
  400. package/vendor/primevue/icons/eye/index.esm.es.js +13 -11
  401. package/vendor/primevue/icons/eyeslash/index.esm.es.js +13 -11
  402. package/vendor/primevue/icons/infocircle/index.esm.es.js +13 -11
  403. package/vendor/primevue/icons/plus/index.esm.es.js +13 -11
  404. package/vendor/primevue/icons/refresh/index.esm.es.js +13 -11
  405. package/vendor/primevue/icons/search/index.esm.es.js +13 -11
  406. package/vendor/primevue/icons/searchminus/index.esm.es.js +13 -11
  407. package/vendor/primevue/icons/searchplus/index.esm.es.js +13 -11
  408. package/vendor/primevue/icons/spinner/index.esm.es.js +13 -11
  409. package/vendor/primevue/icons/times/index.esm.es.js +13 -11
  410. package/vendor/primevue/icons/timescircle/index.esm.es.js +13 -11
  411. package/vendor/primevue/icons/undo/index.esm.es.js +13 -11
  412. package/vendor/primevue/icons/upload/index.esm.es.js +13 -11
  413. package/vendor/primevue/icons/windowmaximize/index.esm.es.js +13 -11
  414. package/vendor/primevue/icons/windowminimize/index.esm.es.js +13 -11
  415. package/vendor/primevue/image/image.esm.es.js +280 -235
  416. package/vendor/primevue/image/style/imagestyle.esm.es.js +18 -17
  417. package/vendor/primevue/inputgroup/inputgroup.esm.es.js +17 -16
  418. package/vendor/primevue/inputgroup/style/inputgroupstyle.esm.es.js +6 -5
  419. package/vendor/primevue/inputgroupaddon/inputgroupaddon.esm.es.js +17 -16
  420. package/vendor/primevue/inputgroupaddon/style/inputgroupaddonstyle.esm.es.js +6 -5
  421. package/vendor/primevue/inputnumber/inputnumber.esm.es.js +834 -566
  422. package/vendor/primevue/inputnumber/style/inputnumberstyle.esm.es.js +23 -22
  423. package/vendor/primevue/inputtext/inputtext.esm.es.js +32 -30
  424. package/vendor/primevue/inputtext/style/inputtextstyle.esm.es.js +13 -12
  425. package/vendor/primevue/menu/menu.esm.es.js +402 -304
  426. package/vendor/primevue/menu/style/menustyle.esm.es.js +14 -13
  427. package/vendor/primevue/message/message.esm.es.js +126 -112
  428. package/vendor/primevue/message/style/messagestyle.esm.es.js +9 -8
  429. package/vendor/primevue/multiselect/multiselect.esm.es.js +1083 -835
  430. package/vendor/primevue/multiselect/style/multiselectstyle.esm.es.js +38 -36
  431. package/vendor/primevue/overlayeventbus/overlayeventbus.esm.es.js +3 -3
  432. package/vendor/primevue/overlaypanel/overlaypanel.esm.es.js +275 -169
  433. package/vendor/primevue/overlaypanel/style/overlaypanelstyle.esm.es.js +9 -8
  434. package/vendor/primevue/paginator/paginator.esm.es.js +513 -469
  435. package/vendor/primevue/paginator/style/paginatorstyle.esm.es.js +50 -43
  436. package/vendor/primevue/password/password.esm.es.js +306 -233
  437. package/vendor/primevue/password/style/passwordstyle.esm.es.js +26 -24
  438. package/vendor/primevue/portal/portal.esm.es.js +17 -17
  439. package/vendor/primevue/progressbar/progressbar.esm.es.js +37 -35
  440. package/vendor/primevue/progressbar/style/progressbarstyle.esm.es.js +10 -9
  441. package/vendor/primevue/ripple/ripple.esm.es.js +90 -62
  442. package/vendor/primevue/ripple/style/ripplestyle.esm.es.js +6 -5
  443. package/vendor/primevue/selectbutton/selectbutton.esm.es.js +213 -167
  444. package/vendor/primevue/selectbutton/style/selectbuttonstyle.esm.es.js +14 -13
  445. package/vendor/primevue/skeleton/skeleton.esm.es.js +28 -26
  446. package/vendor/primevue/skeleton/style/skeletonstyle.esm.es.js +13 -11
  447. package/vendor/primevue/textarea/style/textareastyle.esm.es.js +12 -11
  448. package/vendor/primevue/textarea/textarea.esm.es.js +49 -33
  449. package/vendor/primevue/timeline/style/timelinestyle.esm.es.js +9 -8
  450. package/vendor/primevue/timeline/timeline.esm.es.js +53 -52
  451. package/vendor/primevue/toast/style/toaststyle.esm.es.js +54 -46
  452. package/vendor/primevue/toast/toast.esm.es.js +309 -260
  453. package/vendor/primevue/toasteventbus/toasteventbus.esm.es.js +3 -3
  454. package/vendor/primevue/toastservice/toastservice.esm.es.js +16 -15
  455. package/vendor/primevue/tooltip/style/tooltipstyle.esm.es.js +6 -5
  456. package/vendor/primevue/tooltip/tooltip.esm.es.js +383 -186
  457. package/vendor/primevue/usestyle/usestyle.esm.es.js +94 -64
  458. package/vendor/primevue/usetoast/usetoast.esm.es.js +9 -8
  459. package/vendor/primevue/utils/utils.esm.es.js +1078 -772
  460. package/vendor/primevue/virtualscroller/style/virtualscrollerstyle.esm.es.js +5 -67
  461. package/vendor/primevue/virtualscroller/virtualscroller.esm.es.js +655 -428
  462. package/vendor/prosemirror-commands/dist/index.es.js +454 -316
  463. package/vendor/prosemirror-history/dist/index.es.js +286 -178
  464. package/vendor/prosemirror-keymap/dist/index.es.js +68 -48
  465. package/vendor/prosemirror-model/dist/index.es.js +1905 -1436
  466. package/vendor/prosemirror-schema-list/dist/index.es.js +115 -73
  467. package/vendor/prosemirror-state/dist/index.es.js +467 -353
  468. package/vendor/prosemirror-transform/dist/index.es.js +1146 -829
  469. package/vendor/prosemirror-view/dist/index.es.js +4127 -2719
  470. package/vendor/rope-sequence/dist/index.es.js +165 -82
  471. package/vendor/simplebar-core/dist/index.es.js +670 -242
  472. package/vendor/simplebar-vue/dist/simplebar-vue.esm.es.js +73 -60
  473. package/vendor/single-spa/lib/es2015/esm/single-spa.min.es.js +511 -510
  474. package/vendor/tippy.js/dist/tippy.esm.es.js +971 -525
  475. package/vendor/vee-validate/dist/vee-validate.esm.es.js +1830 -1097
  476. package/vendor/vue-advanced-cropper/dist/index.esm-bundler.es.js +740 -738
  477. package/vendor/w3c-keyname/index.es.js +25 -13
  478. package/wangsvue.es.js +167 -208
  479. package/wangsvue.esm.browser.js +49417 -48026
  480. package/wangsvue.system.js +67600 -234
  481. package/api/index.es.js +0 -149
  482. package/apiitem/index.es.js +0 -611
  483. package/assignmember/index.es.js +0 -434
  484. package/attachment/index.es.js +0 -118
  485. package/attachmentchangelog/index.es.js +0 -79
  486. package/attachmentitem/index.es.js +0 -231
  487. package/attachmentthumbnail/index.es.js +0 -83
  488. package/changelog/index.d.ts +0 -164
  489. package/changelog/index.es.js +0 -85
  490. package/changelogfilter/index.es.js +0 -113
  491. package/changelogpage/index.d.ts +0 -184
  492. package/changelogpage/index.es.js +0 -176
  493. package/checklist/index.es.js +0 -571
  494. package/checklistchangelog/index.es.js +0 -85
  495. package/comment/index.d.ts +0 -187
  496. package/comment/index.es.js +0 -267
  497. package/commentblock/index.es.js +0 -337
  498. package/confirmdeploy/index.es.js +0 -64
  499. package/dependencycol/index.es.js +0 -32
  500. package/description/index.es.js +0 -135
  501. package/descriptiontab/index.es.js +0 -30
  502. package/detailmember/index.d.ts +0 -77
  503. package/detailmember/index.es.js +0 -32
  504. package/detailmemberadmin/index.es.js +0 -210
  505. package/detailmemberleader/index.es.js +0 -164
  506. package/detailmemberlog/index.es.js +0 -117
  507. package/detailsprint/index.d.ts +0 -86
  508. package/detailsprint/index.es.js +0 -414
  509. package/dialogaddattachment/index.es.js +0 -273
  510. package/dialogaddchecklist/index.es.js +0 -120
  511. package/dialogaddeditapi/index.es.js +0 -87
  512. package/dialogaddpbi/index.es.js +0 -197
  513. package/dialogadjustmenttask/index.es.js +0 -484
  514. package/dialogadjustmenttaskheader/index.es.js +0 -193
  515. package/dialogapichangelog/index.es.js +0 -83
  516. package/dialogassignmember/index.es.js +0 -171
  517. package/dialogconfirmapproval/index.es.js +0 -54
  518. package/dialogconfirmchecklist/index.es.js +0 -189
  519. package/dialogconfirmdeletetask/index.es.js +0 -70
  520. package/dialogconfirmdeletetaskpermanently/index.es.js +0 -50
  521. package/dialogconfirmedit/index.es.js +0 -50
  522. package/dialogconfirmfinishtask/index.es.js +0 -50
  523. package/dialogconfirmrestoretask/index.es.js +0 -46
  524. package/dialogconfirmsprint/index.es.js +0 -42
  525. package/dialogcopyapi/index.es.js +0 -130
  526. package/dialogcustomdependency/index.es.js +0 -55
  527. package/dialogdetailchecklisttemplate/index.es.js +0 -214
  528. package/dialogdetailcomponent/index.es.js +0 -121
  529. package/dialogdetailpbi/index.es.js +0 -192
  530. package/dialogfinishreview/index.es.js +0 -126
  531. package/dialogimprovementtask/index.es.js +0 -191
  532. package/dialogmemberadmin/index.es.js +0 -93
  533. package/dialogpreparepbi/index.es.js +0 -93
  534. package/dialogpriorityvalue/index.es.js +0 -85
  535. package/dialogreportbug/index.es.js +0 -207
  536. package/dialogreviewleader/index.es.js +0 -280
  537. package/dialogsavechecklisttemplate/index.es.js +0 -127
  538. package/dialogselectproject/index.es.js +0 -69
  539. package/dialogsetduration/index.es.js +0 -109
  540. package/dialogsettasklink/index.es.js +0 -153
  541. package/dialogtestapi/index.es.js +0 -389
  542. package/eventlogtab/index.es.js +0 -50
  543. package/infotasktab/index.es.js +0 -186
  544. package/inputadditional/index.es.js +0 -62
  545. package/inputinitialname/index.d.ts +0 -118
  546. package/inputinitialname/index.es.js +0 -95
  547. package/inputrepositoryname/index.d.ts +0 -86
  548. package/inputrepositoryname/index.es.js +0 -41
  549. package/isrequiredtext/index.es.js +0 -16
  550. package/legend/index.es.js +0 -727
  551. package/legendlist/index.es.js +0 -33
  552. package/loading-page-BrQattYE.js +0 -1
  553. package/loading-page-CgfbWppy.js +0 -1
  554. package/loading-page-CoC9UhfC.js +0 -4
  555. package/loading-page-CoXtqoc9.js +0 -4
  556. package/loading-page-DbLuqCHa.js +0 -1
  557. package/loading-page-f8D03l3G.js +0 -4
  558. package/loading-plane-CgfbWppy.js +0 -1
  559. package/loading-plane-CoXtqoc9.js +0 -4
  560. package/loading-table-Bdr9ZhtP.js +0 -1
  561. package/loading-table-ByUoWqUo.js +0 -4
  562. package/loading-table-BygEMzFM.js +0 -4
  563. package/loading-table-BzrSQlA0.js +0 -1
  564. package/loading-table-D9bw9OcI.js +0 -4
  565. package/loading-table-chOgXi94.js +0 -1
  566. package/no-data-CTKux8RI.js +0 -4
  567. package/no-data-Cgze_Rvp.js +0 -1
  568. package/no-data-DLHO1L_u.js +0 -4
  569. package/no-data-Dep79CBh.js +0 -1
  570. package/no-data-g0dJCy2p.js +0 -4
  571. package/no-data-y1X5WtcQ.js +0 -1
  572. package/notificationitem/index.d.ts +0 -107
  573. package/notificationitem/index.es.js +0 -333
  574. package/reviewitem/index.es.js +0 -65
  575. package/reviewtab/index.es.js +0 -44
  576. package/services/calendar.service.es.js +0 -32
  577. package/sonarqubesummary/index.es.js +0 -234
  578. package/sprintsummary/index.es.js +0 -73
  579. package/summaryaccordion/index.d.ts +0 -121
  580. package/summaryaccordion/index.es.js +0 -365
  581. package/taskdependency/index.es.js +0 -686
  582. package/taskdetail/index.d.ts +0 -82
  583. package/taskdetail/index.es.js +0 -491
  584. package/taskdetailpbi/index.d.ts +0 -35
  585. package/taskdetailpbi/index.es.js +0 -172
  586. package/taskdetailunassignedpbi/index.es.js +0 -261
  587. package/tasklink/index.es.js +0 -257
  588. package/tasklinkchangelog/index.es.js +0 -93
  589. package/tasklist/index.es.js +0 -92
  590. package/taskmore/index.es.js +0 -52
  591. package/taskstatusbadge/index.es.js +0 -18
  592. package/tasktable/index.d.ts +0 -87
  593. package/tasktable/index.es.js +0 -832
  594. package/ticket/index.es.js +0 -151
  595. package/tooltipspan/index.es.js +0 -30
  596. package/utils/updateSprintStatus.util.es.js +0 -17
  597. package/valueformdatainput/index.es.js +0 -70
  598. package/workcalendar/index.es.js +0 -351
@@ -1,75 +1,82 @@
1
- import { O as q } from "../../orderedmap/dist/index.es.js";
2
- function Y(l, t, e) {
3
- for (let n = 0; ; n++) {
4
- if (n == l.childCount || n == t.childCount)
5
- return l.childCount == t.childCount ? null : e;
6
- let i = l.child(n), r = t.child(n);
7
- if (i == r) {
8
- e += i.nodeSize;
1
+ import { O as OrderedMap } from "../../orderedmap/dist/index.es.js";
2
+ function findDiffStart(a, b, pos) {
3
+ for (let i = 0; ; i++) {
4
+ if (i == a.childCount || i == b.childCount)
5
+ return a.childCount == b.childCount ? null : pos;
6
+ let childA = a.child(i), childB = b.child(i);
7
+ if (childA == childB) {
8
+ pos += childA.nodeSize;
9
9
  continue;
10
10
  }
11
- if (!i.sameMarkup(r))
12
- return e;
13
- if (i.isText && i.text != r.text) {
14
- for (let s = 0; i.text[s] == r.text[s]; s++)
15
- e++;
16
- return e;
11
+ if (!childA.sameMarkup(childB))
12
+ return pos;
13
+ if (childA.isText && childA.text != childB.text) {
14
+ for (let j = 0; childA.text[j] == childB.text[j]; j++)
15
+ pos++;
16
+ return pos;
17
17
  }
18
- if (i.content.size || r.content.size) {
19
- let s = Y(i.content, r.content, e + 1);
20
- if (s != null)
21
- return s;
18
+ if (childA.content.size || childB.content.size) {
19
+ let inner = findDiffStart(childA.content, childB.content, pos + 1);
20
+ if (inner != null)
21
+ return inner;
22
22
  }
23
- e += i.nodeSize;
23
+ pos += childA.nodeSize;
24
24
  }
25
25
  }
26
- function Z(l, t, e, n) {
27
- for (let i = l.childCount, r = t.childCount; ; ) {
28
- if (i == 0 || r == 0)
29
- return i == r ? null : { a: e, b: n };
30
- let s = l.child(--i), o = t.child(--r), h = s.nodeSize;
31
- if (s == o) {
32
- e -= h, n -= h;
26
+ function findDiffEnd(a, b, posA, posB) {
27
+ for (let iA = a.childCount, iB = b.childCount; ; ) {
28
+ if (iA == 0 || iB == 0)
29
+ return iA == iB ? null : { a: posA, b: posB };
30
+ let childA = a.child(--iA), childB = b.child(--iB), size = childA.nodeSize;
31
+ if (childA == childB) {
32
+ posA -= size;
33
+ posB -= size;
33
34
  continue;
34
35
  }
35
- if (!s.sameMarkup(o))
36
- return { a: e, b: n };
37
- if (s.isText && s.text != o.text) {
38
- let a = 0, f = Math.min(s.text.length, o.text.length);
39
- for (; a < f && s.text[s.text.length - a - 1] == o.text[o.text.length - a - 1]; )
40
- a++, e--, n--;
41
- return { a: e, b: n };
36
+ if (!childA.sameMarkup(childB))
37
+ return { a: posA, b: posB };
38
+ if (childA.isText && childA.text != childB.text) {
39
+ let same = 0, minSize = Math.min(childA.text.length, childB.text.length);
40
+ while (same < minSize && childA.text[childA.text.length - same - 1] == childB.text[childB.text.length - same - 1]) {
41
+ same++;
42
+ posA--;
43
+ posB--;
44
+ }
45
+ return { a: posA, b: posB };
42
46
  }
43
- if (s.content.size || o.content.size) {
44
- let a = Z(s.content, o.content, e - 1, n - 1);
45
- if (a)
46
- return a;
47
+ if (childA.content.size || childB.content.size) {
48
+ let inner = findDiffEnd(childA.content, childB.content, posA - 1, posB - 1);
49
+ if (inner)
50
+ return inner;
47
51
  }
48
- e -= h, n -= h;
52
+ posA -= size;
53
+ posB -= size;
49
54
  }
50
55
  }
51
- class c {
56
+ class Fragment {
52
57
  /**
53
58
  @internal
54
59
  */
55
- constructor(t, e) {
56
- if (this.content = t, this.size = e || 0, e == null)
57
- for (let n = 0; n < t.length; n++)
58
- this.size += t[n].nodeSize;
60
+ constructor(content, size) {
61
+ this.content = content;
62
+ this.size = size || 0;
63
+ if (size == null)
64
+ for (let i = 0; i < content.length; i++)
65
+ this.size += content[i].nodeSize;
59
66
  }
60
67
  /**
61
68
  Invoke a callback for all descendant nodes between the given two
62
69
  positions (relative to start of this fragment). Doesn't descend
63
70
  into a node when the callback returns `false`.
64
71
  */
65
- nodesBetween(t, e, n, i = 0, r) {
66
- for (let s = 0, o = 0; o < e; s++) {
67
- let h = this.content[s], a = o + h.nodeSize;
68
- if (a > t && n(h, i + o, r || null, s) !== !1 && h.content.size) {
69
- let f = o + 1;
70
- h.nodesBetween(Math.max(0, t - f), Math.min(h.content.size, e - f), n, i + f);
72
+ nodesBetween(from, to, f, nodeStart = 0, parent) {
73
+ for (let i = 0, pos = 0; pos < to; i++) {
74
+ let child = this.content[i], end = pos + child.nodeSize;
75
+ if (end > from && f(child, nodeStart + pos, parent || null, i) !== false && child.content.size) {
76
+ let start = pos + 1;
77
+ child.nodesBetween(Math.max(0, from - start), Math.min(child.content.size, to - start), f, nodeStart + start);
71
78
  }
72
- o = a;
79
+ pos = end;
73
80
  }
74
81
  }
75
82
  /**
@@ -77,89 +84,116 @@ class c {
77
84
  relative to the start of the fragment. The callback may return
78
85
  `false` to prevent traversal of a given node's children.
79
86
  */
80
- descendants(t) {
81
- this.nodesBetween(0, this.size, t);
87
+ descendants(f) {
88
+ this.nodesBetween(0, this.size, f);
82
89
  }
83
90
  /**
84
91
  Extract the text between `from` and `to`. See the same method on
85
92
  [`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
86
93
  */
87
- textBetween(t, e, n, i) {
88
- let r = "", s = !0;
89
- return this.nodesBetween(t, e, (o, h) => {
90
- let a = o.isText ? o.text.slice(Math.max(t, h) - h, e - h) : o.isLeaf ? i ? typeof i == "function" ? i(o) : i : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
91
- o.isBlock && (o.isLeaf && a || o.isTextblock) && n && (s ? s = !1 : r += n), r += a;
92
- }, 0), r;
94
+ textBetween(from, to, blockSeparator, leafText) {
95
+ let text = "", first = true;
96
+ this.nodesBetween(from, to, (node, pos) => {
97
+ let nodeText = node.isText ? node.text.slice(Math.max(from, pos) - pos, to - pos) : !node.isLeaf ? "" : leafText ? typeof leafText === "function" ? leafText(node) : leafText : node.type.spec.leafText ? node.type.spec.leafText(node) : "";
98
+ if (node.isBlock && (node.isLeaf && nodeText || node.isTextblock) && blockSeparator) {
99
+ if (first)
100
+ first = false;
101
+ else
102
+ text += blockSeparator;
103
+ }
104
+ text += nodeText;
105
+ }, 0);
106
+ return text;
93
107
  }
94
108
  /**
95
109
  Create a new fragment containing the combined content of this
96
110
  fragment and the other.
97
111
  */
98
- append(t) {
99
- if (!t.size)
112
+ append(other) {
113
+ if (!other.size)
100
114
  return this;
101
115
  if (!this.size)
102
- return t;
103
- let e = this.lastChild, n = t.firstChild, i = this.content.slice(), r = 0;
104
- for (e.isText && e.sameMarkup(n) && (i[i.length - 1] = e.withText(e.text + n.text), r = 1); r < t.content.length; r++)
105
- i.push(t.content[r]);
106
- return new c(i, this.size + t.size);
116
+ return other;
117
+ let last = this.lastChild, first = other.firstChild, content = this.content.slice(), i = 0;
118
+ if (last.isText && last.sameMarkup(first)) {
119
+ content[content.length - 1] = last.withText(last.text + first.text);
120
+ i = 1;
121
+ }
122
+ for (; i < other.content.length; i++)
123
+ content.push(other.content[i]);
124
+ return new Fragment(content, this.size + other.size);
107
125
  }
108
126
  /**
109
127
  Cut out the sub-fragment between the two given positions.
110
128
  */
111
- cut(t, e = this.size) {
112
- if (t == 0 && e == this.size)
129
+ cut(from, to = this.size) {
130
+ if (from == 0 && to == this.size)
113
131
  return this;
114
- let n = [], i = 0;
115
- if (e > t)
116
- for (let r = 0, s = 0; s < e; r++) {
117
- let o = this.content[r], h = s + o.nodeSize;
118
- h > t && ((s < t || h > e) && (o.isText ? o = o.cut(Math.max(0, t - s), Math.min(o.text.length, e - s)) : o = o.cut(Math.max(0, t - s - 1), Math.min(o.content.size, e - s - 1))), n.push(o), i += o.nodeSize), s = h;
132
+ let result = [], size = 0;
133
+ if (to > from)
134
+ for (let i = 0, pos = 0; pos < to; i++) {
135
+ let child = this.content[i], end = pos + child.nodeSize;
136
+ if (end > from) {
137
+ if (pos < from || end > to) {
138
+ if (child.isText)
139
+ child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos));
140
+ else
141
+ child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1));
142
+ }
143
+ result.push(child);
144
+ size += child.nodeSize;
145
+ }
146
+ pos = end;
119
147
  }
120
- return new c(n, i);
148
+ return new Fragment(result, size);
121
149
  }
122
150
  /**
123
151
  @internal
124
152
  */
125
- cutByIndex(t, e) {
126
- return t == e ? c.empty : t == 0 && e == this.content.length ? this : new c(this.content.slice(t, e));
153
+ cutByIndex(from, to) {
154
+ if (from == to)
155
+ return Fragment.empty;
156
+ if (from == 0 && to == this.content.length)
157
+ return this;
158
+ return new Fragment(this.content.slice(from, to));
127
159
  }
128
160
  /**
129
161
  Create a new fragment in which the node at the given index is
130
162
  replaced by the given node.
131
163
  */
132
- replaceChild(t, e) {
133
- let n = this.content[t];
134
- if (n == e)
164
+ replaceChild(index, node) {
165
+ let current = this.content[index];
166
+ if (current == node)
135
167
  return this;
136
- let i = this.content.slice(), r = this.size + e.nodeSize - n.nodeSize;
137
- return i[t] = e, new c(i, r);
168
+ let copy2 = this.content.slice();
169
+ let size = this.size + node.nodeSize - current.nodeSize;
170
+ copy2[index] = node;
171
+ return new Fragment(copy2, size);
138
172
  }
139
173
  /**
140
174
  Create a new fragment by prepending the given node to this
141
175
  fragment.
142
176
  */
143
- addToStart(t) {
144
- return new c([t].concat(this.content), this.size + t.nodeSize);
177
+ addToStart(node) {
178
+ return new Fragment([node].concat(this.content), this.size + node.nodeSize);
145
179
  }
146
180
  /**
147
181
  Create a new fragment by appending the given node to this
148
182
  fragment.
149
183
  */
150
- addToEnd(t) {
151
- return new c(this.content.concat(t), this.size + t.nodeSize);
184
+ addToEnd(node) {
185
+ return new Fragment(this.content.concat(node), this.size + node.nodeSize);
152
186
  }
153
187
  /**
154
188
  Compare this fragment to another one.
155
189
  */
156
- eq(t) {
157
- if (this.content.length != t.content.length)
158
- return !1;
159
- for (let e = 0; e < this.content.length; e++)
160
- if (!this.content[e].eq(t.content[e]))
161
- return !1;
162
- return !0;
190
+ eq(other) {
191
+ if (this.content.length != other.content.length)
192
+ return false;
193
+ for (let i = 0; i < this.content.length; i++)
194
+ if (!this.content[i].eq(other.content[i]))
195
+ return false;
196
+ return true;
163
197
  }
164
198
  /**
165
199
  The first child of the fragment, or `null` if it is empty.
@@ -183,34 +217,35 @@ class c {
183
217
  Get the child node at the given index. Raise an error when the
184
218
  index is out of range.
185
219
  */
186
- child(t) {
187
- let e = this.content[t];
188
- if (!e)
189
- throw new RangeError("Index " + t + " out of range for " + this);
190
- return e;
220
+ child(index) {
221
+ let found2 = this.content[index];
222
+ if (!found2)
223
+ throw new RangeError("Index " + index + " out of range for " + this);
224
+ return found2;
191
225
  }
192
226
  /**
193
227
  Get the child node at the given index, if it exists.
194
228
  */
195
- maybeChild(t) {
196
- return this.content[t] || null;
229
+ maybeChild(index) {
230
+ return this.content[index] || null;
197
231
  }
198
232
  /**
199
233
  Call `f` for every child node, passing the node, its offset
200
234
  into this parent node, and its index.
201
235
  */
202
- forEach(t) {
203
- for (let e = 0, n = 0; e < this.content.length; e++) {
204
- let i = this.content[e];
205
- t(i, n, e), n += i.nodeSize;
236
+ forEach(f) {
237
+ for (let i = 0, p = 0; i < this.content.length; i++) {
238
+ let child = this.content[i];
239
+ f(child, p, i);
240
+ p += child.nodeSize;
206
241
  }
207
242
  }
208
243
  /**
209
244
  Find the first position at which this fragment and another
210
245
  fragment differ, or `null` if they are the same.
211
246
  */
212
- findDiffStart(t, e = 0) {
213
- return Y(this, t, e);
247
+ findDiffStart(other, pos = 0) {
248
+ return findDiffStart(this, other, pos);
214
249
  }
215
250
  /**
216
251
  Find the first position, searching from the end, at which this
@@ -218,26 +253,29 @@ class c {
218
253
  the same. Since this position will not be the same in both
219
254
  nodes, an object with two separate positions is returned.
220
255
  */
221
- findDiffEnd(t, e = this.size, n = t.size) {
222
- return Z(this, t, e, n);
256
+ findDiffEnd(other, pos = this.size, otherPos = other.size) {
257
+ return findDiffEnd(this, other, pos, otherPos);
223
258
  }
224
259
  /**
225
260
  Find the index and inner offset corresponding to a given relative
226
261
  position in this fragment. The result object will be reused
227
262
  (overwritten) the next time the function is called. @internal
228
263
  */
229
- findIndex(t, e = -1) {
230
- if (t == 0)
231
- return O(0, t);
232
- if (t == this.size)
233
- return O(this.content.length, t);
234
- if (t > this.size || t < 0)
235
- throw new RangeError(`Position ${t} outside of fragment (${this})`);
236
- for (let n = 0, i = 0; ; n++) {
237
- let r = this.child(n), s = i + r.nodeSize;
238
- if (s >= t)
239
- return s == t || e > 0 ? O(n + 1, s) : O(n, i);
240
- i = s;
264
+ findIndex(pos, round = -1) {
265
+ if (pos == 0)
266
+ return retIndex(0, pos);
267
+ if (pos == this.size)
268
+ return retIndex(this.content.length, pos);
269
+ if (pos > this.size || pos < 0)
270
+ throw new RangeError(`Position ${pos} outside of fragment (${this})`);
271
+ for (let i = 0, curPos = 0; ; i++) {
272
+ let cur = this.child(i), end = curPos + cur.nodeSize;
273
+ if (end >= pos) {
274
+ if (end == pos || round > 0)
275
+ return retIndex(i + 1, end);
276
+ return retIndex(i, curPos);
277
+ }
278
+ curPos = end;
241
279
  }
242
280
  }
243
281
  /**
@@ -256,31 +294,38 @@ class c {
256
294
  Create a JSON-serializeable representation of this fragment.
257
295
  */
258
296
  toJSON() {
259
- return this.content.length ? this.content.map((t) => t.toJSON()) : null;
297
+ return this.content.length ? this.content.map((n) => n.toJSON()) : null;
260
298
  }
261
299
  /**
262
300
  Deserialize a fragment from its JSON representation.
263
301
  */
264
- static fromJSON(t, e) {
265
- if (!e)
266
- return c.empty;
267
- if (!Array.isArray(e))
302
+ static fromJSON(schema, value) {
303
+ if (!value)
304
+ return Fragment.empty;
305
+ if (!Array.isArray(value))
268
306
  throw new RangeError("Invalid input for Fragment.fromJSON");
269
- return new c(e.map(t.nodeFromJSON));
307
+ return new Fragment(value.map(schema.nodeFromJSON));
270
308
  }
271
309
  /**
272
310
  Build a fragment from an array of nodes. Ensures that adjacent
273
311
  text nodes with the same marks are joined together.
274
312
  */
275
- static fromArray(t) {
276
- if (!t.length)
277
- return c.empty;
278
- let e, n = 0;
279
- for (let i = 0; i < t.length; i++) {
280
- let r = t[i];
281
- n += r.nodeSize, i && r.isText && t[i - 1].sameMarkup(r) ? (e || (e = t.slice(0, i)), e[e.length - 1] = r.withText(e[e.length - 1].text + r.text)) : e && e.push(r);
313
+ static fromArray(array) {
314
+ if (!array.length)
315
+ return Fragment.empty;
316
+ let joined, size = 0;
317
+ for (let i = 0; i < array.length; i++) {
318
+ let node = array[i];
319
+ size += node.nodeSize;
320
+ if (i && node.isText && array[i - 1].sameMarkup(node)) {
321
+ if (!joined)
322
+ joined = array.slice(0, i);
323
+ joined[joined.length - 1] = node.withText(joined[joined.length - 1].text + node.text);
324
+ } else if (joined) {
325
+ joined.push(node);
326
+ }
282
327
  }
283
- return new c(e || t, n);
328
+ return new Fragment(joined || array, size);
284
329
  }
285
330
  /**
286
331
  Create a fragment from something that can be interpreted as a
@@ -288,53 +333,56 @@ class c {
288
333
  fragment, the fragment itself. For a node or array of nodes, a
289
334
  fragment containing those nodes.
290
335
  */
291
- static from(t) {
292
- if (!t)
293
- return c.empty;
294
- if (t instanceof c)
295
- return t;
296
- if (Array.isArray(t))
297
- return this.fromArray(t);
298
- if (t.attrs)
299
- return new c([t], t.nodeSize);
300
- throw new RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
301
- }
302
- }
303
- c.empty = new c([], 0);
304
- const v = { index: 0, offset: 0 };
305
- function O(l, t) {
306
- return v.index = l, v.offset = t, v;
307
- }
308
- function M(l, t) {
309
- if (l === t)
310
- return !0;
311
- if (!(l && typeof l == "object") || !(t && typeof t == "object"))
312
- return !1;
313
- let e = Array.isArray(l);
314
- if (Array.isArray(t) != e)
315
- return !1;
316
- if (e) {
317
- if (l.length != t.length)
318
- return !1;
319
- for (let n = 0; n < l.length; n++)
320
- if (!M(l[n], t[n]))
321
- return !1;
336
+ static from(nodes) {
337
+ if (!nodes)
338
+ return Fragment.empty;
339
+ if (nodes instanceof Fragment)
340
+ return nodes;
341
+ if (Array.isArray(nodes))
342
+ return this.fromArray(nodes);
343
+ if (nodes.attrs)
344
+ return new Fragment([nodes], nodes.nodeSize);
345
+ throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
346
+ }
347
+ }
348
+ Fragment.empty = new Fragment([], 0);
349
+ const found = { index: 0, offset: 0 };
350
+ function retIndex(index, offset) {
351
+ found.index = index;
352
+ found.offset = offset;
353
+ return found;
354
+ }
355
+ function compareDeep(a, b) {
356
+ if (a === b)
357
+ return true;
358
+ if (!(a && typeof a == "object") || !(b && typeof b == "object"))
359
+ return false;
360
+ let array = Array.isArray(a);
361
+ if (Array.isArray(b) != array)
362
+ return false;
363
+ if (array) {
364
+ if (a.length != b.length)
365
+ return false;
366
+ for (let i = 0; i < a.length; i++)
367
+ if (!compareDeep(a[i], b[i]))
368
+ return false;
322
369
  } else {
323
- for (let n in l)
324
- if (!(n in t) || !M(l[n], t[n]))
325
- return !1;
326
- for (let n in t)
327
- if (!(n in l))
328
- return !1;
370
+ for (let p in a)
371
+ if (!(p in b) || !compareDeep(a[p], b[p]))
372
+ return false;
373
+ for (let p in b)
374
+ if (!(p in a))
375
+ return false;
329
376
  }
330
- return !0;
377
+ return true;
331
378
  }
332
- class u {
379
+ class Mark {
333
380
  /**
334
381
  @internal
335
382
  */
336
- constructor(t, e) {
337
- this.type = t, this.attrs = e;
383
+ constructor(type, attrs) {
384
+ this.type = type;
385
+ this.attrs = attrs;
338
386
  }
339
387
  /**
340
388
  Given a set of marks, create a new set which contains this one as
@@ -343,101 +391,115 @@ class u {
343
391
  [exclusive](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) with this mark are present,
344
392
  those are replaced by this one.
345
393
  */
346
- addToSet(t) {
347
- let e, n = !1;
348
- for (let i = 0; i < t.length; i++) {
349
- let r = t[i];
350
- if (this.eq(r))
351
- return t;
352
- if (this.type.excludes(r.type))
353
- e || (e = t.slice(0, i));
354
- else {
355
- if (r.type.excludes(this.type))
356
- return t;
357
- !n && r.type.rank > this.type.rank && (e || (e = t.slice(0, i)), e.push(this), n = !0), e && e.push(r);
394
+ addToSet(set) {
395
+ let copy2, placed = false;
396
+ for (let i = 0; i < set.length; i++) {
397
+ let other = set[i];
398
+ if (this.eq(other))
399
+ return set;
400
+ if (this.type.excludes(other.type)) {
401
+ if (!copy2)
402
+ copy2 = set.slice(0, i);
403
+ } else if (other.type.excludes(this.type)) {
404
+ return set;
405
+ } else {
406
+ if (!placed && other.type.rank > this.type.rank) {
407
+ if (!copy2)
408
+ copy2 = set.slice(0, i);
409
+ copy2.push(this);
410
+ placed = true;
411
+ }
412
+ if (copy2)
413
+ copy2.push(other);
358
414
  }
359
415
  }
360
- return e || (e = t.slice()), n || e.push(this), e;
416
+ if (!copy2)
417
+ copy2 = set.slice();
418
+ if (!placed)
419
+ copy2.push(this);
420
+ return copy2;
361
421
  }
362
422
  /**
363
423
  Remove this mark from the given set, returning a new set. If this
364
424
  mark is not in the set, the set itself is returned.
365
425
  */
366
- removeFromSet(t) {
367
- for (let e = 0; e < t.length; e++)
368
- if (this.eq(t[e]))
369
- return t.slice(0, e).concat(t.slice(e + 1));
370
- return t;
426
+ removeFromSet(set) {
427
+ for (let i = 0; i < set.length; i++)
428
+ if (this.eq(set[i]))
429
+ return set.slice(0, i).concat(set.slice(i + 1));
430
+ return set;
371
431
  }
372
432
  /**
373
433
  Test whether this mark is in the given set of marks.
374
434
  */
375
- isInSet(t) {
376
- for (let e = 0; e < t.length; e++)
377
- if (this.eq(t[e]))
378
- return !0;
379
- return !1;
435
+ isInSet(set) {
436
+ for (let i = 0; i < set.length; i++)
437
+ if (this.eq(set[i]))
438
+ return true;
439
+ return false;
380
440
  }
381
441
  /**
382
442
  Test whether this mark has the same type and attributes as
383
443
  another mark.
384
444
  */
385
- eq(t) {
386
- return this == t || this.type == t.type && M(this.attrs, t.attrs);
445
+ eq(other) {
446
+ return this == other || this.type == other.type && compareDeep(this.attrs, other.attrs);
387
447
  }
388
448
  /**
389
449
  Convert this mark to a JSON-serializeable representation.
390
450
  */
391
451
  toJSON() {
392
- let t = { type: this.type.name };
393
- for (let e in this.attrs) {
394
- t.attrs = this.attrs;
452
+ let obj = { type: this.type.name };
453
+ for (let _ in this.attrs) {
454
+ obj.attrs = this.attrs;
395
455
  break;
396
456
  }
397
- return t;
457
+ return obj;
398
458
  }
399
459
  /**
400
460
  Deserialize a mark from JSON.
401
461
  */
402
- static fromJSON(t, e) {
403
- if (!e)
462
+ static fromJSON(schema, json) {
463
+ if (!json)
404
464
  throw new RangeError("Invalid input for Mark.fromJSON");
405
- let n = t.marks[e.type];
406
- if (!n)
407
- throw new RangeError(`There is no mark type ${e.type} in this schema`);
408
- let i = n.create(e.attrs);
409
- return n.checkAttrs(i.attrs), i;
465
+ let type = schema.marks[json.type];
466
+ if (!type)
467
+ throw new RangeError(`There is no mark type ${json.type} in this schema`);
468
+ let mark = type.create(json.attrs);
469
+ type.checkAttrs(mark.attrs);
470
+ return mark;
410
471
  }
411
472
  /**
412
473
  Test whether two sets of marks are identical.
413
474
  */
414
- static sameSet(t, e) {
415
- if (t == e)
416
- return !0;
417
- if (t.length != e.length)
418
- return !1;
419
- for (let n = 0; n < t.length; n++)
420
- if (!t[n].eq(e[n]))
421
- return !1;
422
- return !0;
475
+ static sameSet(a, b) {
476
+ if (a == b)
477
+ return true;
478
+ if (a.length != b.length)
479
+ return false;
480
+ for (let i = 0; i < a.length; i++)
481
+ if (!a[i].eq(b[i]))
482
+ return false;
483
+ return true;
423
484
  }
424
485
  /**
425
486
  Create a properly sorted mark set from null, a single mark, or an
426
487
  unsorted array of marks.
427
488
  */
428
- static setFrom(t) {
429
- if (!t || Array.isArray(t) && t.length == 0)
430
- return u.none;
431
- if (t instanceof u)
432
- return [t];
433
- let e = t.slice();
434
- return e.sort((n, i) => n.type.rank - i.type.rank), e;
489
+ static setFrom(marks) {
490
+ if (!marks || Array.isArray(marks) && marks.length == 0)
491
+ return Mark.none;
492
+ if (marks instanceof Mark)
493
+ return [marks];
494
+ let copy2 = marks.slice();
495
+ copy2.sort((a, b) => a.type.rank - b.type.rank);
496
+ return copy2;
435
497
  }
436
498
  }
437
- u.none = [];
438
- class I extends Error {
499
+ Mark.none = [];
500
+ class ReplaceError extends Error {
439
501
  }
440
- class d {
502
+ class Slice {
441
503
  /**
442
504
  Create a slice. When specifying a non-zero open depth, you must
443
505
  make sure that there are nodes of at least that depth at the
@@ -450,8 +512,10 @@ class d {
450
512
  start/end/middle for such a node, depending on which sides are
451
513
  open.
452
514
  */
453
- constructor(t, e, n) {
454
- this.content = t, this.openStart = e, this.openEnd = n;
515
+ constructor(content, openStart, openEnd) {
516
+ this.content = content;
517
+ this.openStart = openStart;
518
+ this.openEnd = openEnd;
455
519
  }
456
520
  /**
457
521
  The size this slice would add when inserted into a document.
@@ -462,21 +526,21 @@ class d {
462
526
  /**
463
527
  @internal
464
528
  */
465
- insertAt(t, e) {
466
- let n = $(this.content, t + this.openStart, e);
467
- return n && new d(n, this.openStart, this.openEnd);
529
+ insertAt(pos, fragment) {
530
+ let content = insertInto(this.content, pos + this.openStart, fragment);
531
+ return content && new Slice(content, this.openStart, this.openEnd);
468
532
  }
469
533
  /**
470
534
  @internal
471
535
  */
472
- removeBetween(t, e) {
473
- return new d(_(this.content, t + this.openStart, e + this.openStart), this.openStart, this.openEnd);
536
+ removeBetween(from, to) {
537
+ return new Slice(removeRange(this.content, from + this.openStart, to + this.openStart), this.openStart, this.openEnd);
474
538
  }
475
539
  /**
476
540
  Tests whether this slice is equal to another slice.
477
541
  */
478
- eq(t) {
479
- return this.content.eq(t.content) && this.openStart == t.openStart && this.openEnd == t.openEnd;
542
+ eq(other) {
543
+ return this.content.eq(other.content) && this.openStart == other.openStart && this.openEnd == other.openEnd;
480
544
  }
481
545
  /**
482
546
  @internal
@@ -490,129 +554,174 @@ class d {
490
554
  toJSON() {
491
555
  if (!this.content.size)
492
556
  return null;
493
- let t = { content: this.content.toJSON() };
494
- return this.openStart > 0 && (t.openStart = this.openStart), this.openEnd > 0 && (t.openEnd = this.openEnd), t;
557
+ let json = { content: this.content.toJSON() };
558
+ if (this.openStart > 0)
559
+ json.openStart = this.openStart;
560
+ if (this.openEnd > 0)
561
+ json.openEnd = this.openEnd;
562
+ return json;
495
563
  }
496
564
  /**
497
565
  Deserialize a slice from its JSON representation.
498
566
  */
499
- static fromJSON(t, e) {
500
- if (!e)
501
- return d.empty;
502
- let n = e.openStart || 0, i = e.openEnd || 0;
503
- if (typeof n != "number" || typeof i != "number")
567
+ static fromJSON(schema, json) {
568
+ if (!json)
569
+ return Slice.empty;
570
+ let openStart = json.openStart || 0, openEnd = json.openEnd || 0;
571
+ if (typeof openStart != "number" || typeof openEnd != "number")
504
572
  throw new RangeError("Invalid input for Slice.fromJSON");
505
- return new d(c.fromJSON(t, e.content), n, i);
573
+ return new Slice(Fragment.fromJSON(schema, json.content), openStart, openEnd);
506
574
  }
507
575
  /**
508
576
  Create a slice from a fragment by taking the maximum possible
509
577
  open value on both side of the fragment.
510
578
  */
511
- static maxOpen(t, e = !0) {
512
- let n = 0, i = 0;
513
- for (let r = t.firstChild; r && !r.isLeaf && (e || !r.type.spec.isolating); r = r.firstChild)
514
- n++;
515
- for (let r = t.lastChild; r && !r.isLeaf && (e || !r.type.spec.isolating); r = r.lastChild)
516
- i++;
517
- return new d(t, n, i);
518
- }
519
- }
520
- d.empty = new d(c.empty, 0, 0);
521
- function _(l, t, e) {
522
- let { index: n, offset: i } = l.findIndex(t), r = l.maybeChild(n), { index: s, offset: o } = l.findIndex(e);
523
- if (i == t || r.isText) {
524
- if (o != e && !l.child(s).isText)
579
+ static maxOpen(fragment, openIsolating = true) {
580
+ let openStart = 0, openEnd = 0;
581
+ for (let n = fragment.firstChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.firstChild)
582
+ openStart++;
583
+ for (let n = fragment.lastChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.lastChild)
584
+ openEnd++;
585
+ return new Slice(fragment, openStart, openEnd);
586
+ }
587
+ }
588
+ Slice.empty = new Slice(Fragment.empty, 0, 0);
589
+ function removeRange(content, from, to) {
590
+ let { index, offset } = content.findIndex(from), child = content.maybeChild(index);
591
+ let { index: indexTo, offset: offsetTo } = content.findIndex(to);
592
+ if (offset == from || child.isText) {
593
+ if (offsetTo != to && !content.child(indexTo).isText)
525
594
  throw new RangeError("Removing non-flat range");
526
- return l.cut(0, t).append(l.cut(e));
595
+ return content.cut(0, from).append(content.cut(to));
527
596
  }
528
- if (n != s)
597
+ if (index != indexTo)
529
598
  throw new RangeError("Removing non-flat range");
530
- return l.replaceChild(n, r.copy(_(r.content, t - i - 1, e - i - 1)));
531
- }
532
- function $(l, t, e, n) {
533
- let { index: i, offset: r } = l.findIndex(t), s = l.maybeChild(i);
534
- if (r == t || s.isText)
535
- return l.cut(0, t).append(e).append(l.cut(t));
536
- let o = $(s.content, t - r - 1, e);
537
- return o && l.replaceChild(i, s.copy(o));
538
- }
539
- function dt(l, t, e) {
540
- if (e.openStart > l.depth)
541
- throw new I("Inserted content deeper than insertion position");
542
- if (l.depth - e.openStart != t.depth - e.openEnd)
543
- throw new I("Inconsistent open depths");
544
- return tt(l, t, e, 0);
545
- }
546
- function tt(l, t, e, n) {
547
- let i = l.index(n), r = l.node(n);
548
- if (i == t.index(n) && n < l.depth - e.openStart) {
549
- let s = tt(l, t, e, n + 1);
550
- return r.copy(r.content.replaceChild(i, s));
551
- } else if (e.content.size)
552
- if (!e.openStart && !e.openEnd && l.depth == n && t.depth == n) {
553
- let s = l.parent, o = s.content;
554
- return m(s, o.cut(0, l.parentOffset).append(e.content).append(o.cut(t.parentOffset)));
555
- } else {
556
- let { start: s, end: o } = gt(e, l);
557
- return m(r, nt(l, s, o, t, n));
599
+ return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));
600
+ }
601
+ function insertInto(content, dist, insert, parent) {
602
+ let { index, offset } = content.findIndex(dist), child = content.maybeChild(index);
603
+ if (offset == dist || child.isText) {
604
+ return content.cut(0, dist).append(insert).append(content.cut(dist));
605
+ }
606
+ let inner = insertInto(child.content, dist - offset - 1, insert);
607
+ return inner && content.replaceChild(index, child.copy(inner));
608
+ }
609
+ function replace($from, $to, slice) {
610
+ if (slice.openStart > $from.depth)
611
+ throw new ReplaceError("Inserted content deeper than insertion position");
612
+ if ($from.depth - slice.openStart != $to.depth - slice.openEnd)
613
+ throw new ReplaceError("Inconsistent open depths");
614
+ return replaceOuter($from, $to, slice, 0);
615
+ }
616
+ function replaceOuter($from, $to, slice, depth) {
617
+ let index = $from.index(depth), node = $from.node(depth);
618
+ if (index == $to.index(depth) && depth < $from.depth - slice.openStart) {
619
+ let inner = replaceOuter($from, $to, slice, depth + 1);
620
+ return node.copy(node.content.replaceChild(index, inner));
621
+ } else if (!slice.content.size) {
622
+ return close(node, replaceTwoWay($from, $to, depth));
623
+ } else if (!slice.openStart && !slice.openEnd && $from.depth == depth && $to.depth == depth) {
624
+ let parent = $from.parent, content = parent.content;
625
+ return close(parent, content.cut(0, $from.parentOffset).append(slice.content).append(content.cut($to.parentOffset)));
626
+ } else {
627
+ let { start, end } = prepareSliceForReplace(slice, $from);
628
+ return close(node, replaceThreeWay($from, start, end, $to, depth));
629
+ }
630
+ }
631
+ function checkJoin(main, sub) {
632
+ if (!sub.type.compatibleContent(main.type))
633
+ throw new ReplaceError("Cannot join " + sub.type.name + " onto " + main.type.name);
634
+ }
635
+ function joinable($before, $after, depth) {
636
+ let node = $before.node(depth);
637
+ checkJoin(node, $after.node(depth));
638
+ return node;
639
+ }
640
+ function addNode(child, target) {
641
+ let last = target.length - 1;
642
+ if (last >= 0 && child.isText && child.sameMarkup(target[last]))
643
+ target[last] = child.withText(target[last].text + child.text);
644
+ else
645
+ target.push(child);
646
+ }
647
+ function addRange($start, $end, depth, target) {
648
+ let node = ($end || $start).node(depth);
649
+ let startIndex = 0, endIndex = $end ? $end.index(depth) : node.childCount;
650
+ if ($start) {
651
+ startIndex = $start.index(depth);
652
+ if ($start.depth > depth) {
653
+ startIndex++;
654
+ } else if ($start.textOffset) {
655
+ addNode($start.nodeAfter, target);
656
+ startIndex++;
558
657
  }
559
- else return m(r, A(l, t, n));
560
- }
561
- function et(l, t) {
562
- if (!t.type.compatibleContent(l.type))
563
- throw new I("Cannot join " + t.type.name + " onto " + l.type.name);
564
- }
565
- function D(l, t, e) {
566
- let n = l.node(e);
567
- return et(n, t.node(e)), n;
568
- }
569
- function x(l, t) {
570
- let e = t.length - 1;
571
- e >= 0 && l.isText && l.sameMarkup(t[e]) ? t[e] = l.withText(t[e].text + l.text) : t.push(l);
572
- }
573
- function k(l, t, e, n) {
574
- let i = (t || l).node(e), r = 0, s = t ? t.index(e) : i.childCount;
575
- l && (r = l.index(e), l.depth > e ? r++ : l.textOffset && (x(l.nodeAfter, n), r++));
576
- for (let o = r; o < s; o++)
577
- x(i.child(o), n);
578
- t && t.depth == e && t.textOffset && x(t.nodeBefore, n);
579
- }
580
- function m(l, t) {
581
- return l.type.checkContent(t), l.copy(t);
582
- }
583
- function nt(l, t, e, n, i) {
584
- let r = l.depth > i && D(l, t, i + 1), s = n.depth > i && D(e, n, i + 1), o = [];
585
- return k(null, l, i, o), r && s && t.index(i) == e.index(i) ? (et(r, s), x(m(r, nt(l, t, e, n, i + 1)), o)) : (r && x(m(r, A(l, t, i + 1)), o), k(t, e, i, o), s && x(m(s, A(e, n, i + 1)), o)), k(n, null, i, o), new c(o);
586
- }
587
- function A(l, t, e) {
588
- let n = [];
589
- if (k(null, l, e, n), l.depth > e) {
590
- let i = D(l, t, e + 1);
591
- x(m(i, A(l, t, e + 1)), n);
592
- }
593
- return k(t, null, e, n), new c(n);
594
- }
595
- function gt(l, t) {
596
- let e = t.depth - l.openStart, i = t.node(e).copy(l.content);
597
- for (let r = e - 1; r >= 0; r--)
598
- i = t.node(r).copy(c.from(i));
658
+ }
659
+ for (let i = startIndex; i < endIndex; i++)
660
+ addNode(node.child(i), target);
661
+ if ($end && $end.depth == depth && $end.textOffset)
662
+ addNode($end.nodeBefore, target);
663
+ }
664
+ function close(node, content) {
665
+ node.type.checkContent(content);
666
+ return node.copy(content);
667
+ }
668
+ function replaceThreeWay($from, $start, $end, $to, depth) {
669
+ let openStart = $from.depth > depth && joinable($from, $start, depth + 1);
670
+ let openEnd = $to.depth > depth && joinable($end, $to, depth + 1);
671
+ let content = [];
672
+ addRange(null, $from, depth, content);
673
+ if (openStart && openEnd && $start.index(depth) == $end.index(depth)) {
674
+ checkJoin(openStart, openEnd);
675
+ addNode(close(openStart, replaceThreeWay($from, $start, $end, $to, depth + 1)), content);
676
+ } else {
677
+ if (openStart)
678
+ addNode(close(openStart, replaceTwoWay($from, $start, depth + 1)), content);
679
+ addRange($start, $end, depth, content);
680
+ if (openEnd)
681
+ addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);
682
+ }
683
+ addRange($to, null, depth, content);
684
+ return new Fragment(content);
685
+ }
686
+ function replaceTwoWay($from, $to, depth) {
687
+ let content = [];
688
+ addRange(null, $from, depth, content);
689
+ if ($from.depth > depth) {
690
+ let type = joinable($from, $to, depth + 1);
691
+ addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);
692
+ }
693
+ addRange($to, null, depth, content);
694
+ return new Fragment(content);
695
+ }
696
+ function prepareSliceForReplace(slice, $along) {
697
+ let extra = $along.depth - slice.openStart, parent = $along.node(extra);
698
+ let node = parent.copy(slice.content);
699
+ for (let i = extra - 1; i >= 0; i--)
700
+ node = $along.node(i).copy(Fragment.from(node));
599
701
  return {
600
- start: i.resolveNoCache(l.openStart + e),
601
- end: i.resolveNoCache(i.content.size - l.openEnd - e)
702
+ start: node.resolveNoCache(slice.openStart + extra),
703
+ end: node.resolveNoCache(node.content.size - slice.openEnd - extra)
602
704
  };
603
705
  }
604
- class S {
706
+ class ResolvedPos {
605
707
  /**
606
708
  @internal
607
709
  */
608
- constructor(t, e, n) {
609
- this.pos = t, this.path = e, this.parentOffset = n, this.depth = e.length / 3 - 1;
710
+ constructor(pos, path, parentOffset) {
711
+ this.pos = pos;
712
+ this.path = path;
713
+ this.parentOffset = parentOffset;
714
+ this.depth = path.length / 3 - 1;
610
715
  }
611
716
  /**
612
717
  @internal
613
718
  */
614
- resolveDepth(t) {
615
- return t == null ? this.depth : t < 0 ? this.depth + t : t;
719
+ resolveDepth(val) {
720
+ if (val == null)
721
+ return this.depth;
722
+ if (val < 0)
723
+ return this.depth + val;
724
+ return val;
616
725
  }
617
726
  /**
618
727
  The parent node that the position points into. Note that even if
@@ -632,56 +741,61 @@ class S {
632
741
  The ancestor node at the given level. `p.node(p.depth)` is the
633
742
  same as `p.parent`.
634
743
  */
635
- node(t) {
636
- return this.path[this.resolveDepth(t) * 3];
744
+ node(depth) {
745
+ return this.path[this.resolveDepth(depth) * 3];
637
746
  }
638
747
  /**
639
748
  The index into the ancestor at the given level. If this points
640
749
  at the 3rd node in the 2nd paragraph on the top level, for
641
750
  example, `p.index(0)` is 1 and `p.index(1)` is 2.
642
751
  */
643
- index(t) {
644
- return this.path[this.resolveDepth(t) * 3 + 1];
752
+ index(depth) {
753
+ return this.path[this.resolveDepth(depth) * 3 + 1];
645
754
  }
646
755
  /**
647
756
  The index pointing after this position into the ancestor at the
648
757
  given level.
649
758
  */
650
- indexAfter(t) {
651
- return t = this.resolveDepth(t), this.index(t) + (t == this.depth && !this.textOffset ? 0 : 1);
759
+ indexAfter(depth) {
760
+ depth = this.resolveDepth(depth);
761
+ return this.index(depth) + (depth == this.depth && !this.textOffset ? 0 : 1);
652
762
  }
653
763
  /**
654
764
  The (absolute) position at the start of the node at the given
655
765
  level.
656
766
  */
657
- start(t) {
658
- return t = this.resolveDepth(t), t == 0 ? 0 : this.path[t * 3 - 1] + 1;
767
+ start(depth) {
768
+ depth = this.resolveDepth(depth);
769
+ return depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;
659
770
  }
660
771
  /**
661
772
  The (absolute) position at the end of the node at the given
662
773
  level.
663
774
  */
664
- end(t) {
665
- return t = this.resolveDepth(t), this.start(t) + this.node(t).content.size;
775
+ end(depth) {
776
+ depth = this.resolveDepth(depth);
777
+ return this.start(depth) + this.node(depth).content.size;
666
778
  }
667
779
  /**
668
780
  The (absolute) position directly before the wrapping node at the
669
781
  given level, or, when `depth` is `this.depth + 1`, the original
670
782
  position.
671
783
  */
672
- before(t) {
673
- if (t = this.resolveDepth(t), !t)
784
+ before(depth) {
785
+ depth = this.resolveDepth(depth);
786
+ if (!depth)
674
787
  throw new RangeError("There is no position before the top-level node");
675
- return t == this.depth + 1 ? this.pos : this.path[t * 3 - 1];
788
+ return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1];
676
789
  }
677
790
  /**
678
791
  The (absolute) position directly after the wrapping node at the
679
792
  given level, or the original position when `depth` is `this.depth + 1`.
680
793
  */
681
- after(t) {
682
- if (t = this.resolveDepth(t), !t)
794
+ after(depth) {
795
+ depth = this.resolveDepth(depth);
796
+ if (!depth)
683
797
  throw new RangeError("There is no position after the top-level node");
684
- return t == this.depth + 1 ? this.pos : this.path[t * 3 - 1] + this.path[t * 3].nodeSize;
798
+ return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1] + this.path[depth * 3].nodeSize;
685
799
  }
686
800
  /**
687
801
  When this position points into a text node, this returns the
@@ -697,11 +811,11 @@ class S {
697
811
  position is returned.
698
812
  */
699
813
  get nodeAfter() {
700
- let t = this.parent, e = this.index(this.depth);
701
- if (e == t.childCount)
814
+ let parent = this.parent, index = this.index(this.depth);
815
+ if (index == parent.childCount)
702
816
  return null;
703
- let n = this.pos - this.path[this.path.length - 1], i = t.child(e);
704
- return n ? t.child(e).cut(n) : i;
817
+ let dOff = this.pos - this.path[this.path.length - 1], child = parent.child(index);
818
+ return dOff ? parent.child(index).cut(dOff) : child;
705
819
  }
706
820
  /**
707
821
  Get the node directly before the position, if any. If the
@@ -709,19 +823,22 @@ class S {
709
823
  before the position is returned.
710
824
  */
711
825
  get nodeBefore() {
712
- let t = this.index(this.depth), e = this.pos - this.path[this.path.length - 1];
713
- return e ? this.parent.child(t).cut(0, e) : t == 0 ? null : this.parent.child(t - 1);
826
+ let index = this.index(this.depth);
827
+ let dOff = this.pos - this.path[this.path.length - 1];
828
+ if (dOff)
829
+ return this.parent.child(index).cut(0, dOff);
830
+ return index == 0 ? null : this.parent.child(index - 1);
714
831
  }
715
832
  /**
716
833
  Get the position at the given index in the parent node at the
717
834
  given depth (which defaults to `this.depth`).
718
835
  */
719
- posAtIndex(t, e) {
720
- e = this.resolveDepth(e);
721
- let n = this.path[e * 3], i = e == 0 ? 0 : this.path[e * 3 - 1] + 1;
722
- for (let r = 0; r < t; r++)
723
- i += n.child(r).nodeSize;
724
- return i;
836
+ posAtIndex(index, depth) {
837
+ depth = this.resolveDepth(depth);
838
+ let node = this.path[depth * 3], pos = depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;
839
+ for (let i = 0; i < index; i++)
840
+ pos += node.child(i).nodeSize;
841
+ return pos;
725
842
  }
726
843
  /**
727
844
  Get the marks at this position, factoring in the surrounding
@@ -730,20 +847,22 @@ class S {
730
847
  node after it (if any) are returned.
731
848
  */
732
849
  marks() {
733
- let t = this.parent, e = this.index();
734
- if (t.content.size == 0)
735
- return u.none;
850
+ let parent = this.parent, index = this.index();
851
+ if (parent.content.size == 0)
852
+ return Mark.none;
736
853
  if (this.textOffset)
737
- return t.child(e).marks;
738
- let n = t.maybeChild(e - 1), i = t.maybeChild(e);
739
- if (!n) {
740
- let o = n;
741
- n = i, i = o;
854
+ return parent.child(index).marks;
855
+ let main = parent.maybeChild(index - 1), other = parent.maybeChild(index);
856
+ if (!main) {
857
+ let tmp = main;
858
+ main = other;
859
+ other = tmp;
742
860
  }
743
- let r = n.marks;
744
- for (var s = 0; s < r.length; s++)
745
- r[s].type.spec.inclusive === !1 && (!i || !r[s].isInSet(i.marks)) && (r = r[s--].removeFromSet(r));
746
- return r;
861
+ let marks = main.marks;
862
+ for (var i = 0; i < marks.length; i++)
863
+ if (marks[i].type.spec.inclusive === false && (!other || !marks[i].isInSet(other.marks)))
864
+ marks = marks[i--].removeFromSet(marks);
865
+ return marks;
747
866
  }
748
867
  /**
749
868
  Get the marks after the current position, if any, except those
@@ -753,23 +872,24 @@ class S {
753
872
  its parent node or its parent node isn't a textblock (in which
754
873
  case no marks should be preserved).
755
874
  */
756
- marksAcross(t) {
757
- let e = this.parent.maybeChild(this.index());
758
- if (!e || !e.isInline)
875
+ marksAcross($end) {
876
+ let after = this.parent.maybeChild(this.index());
877
+ if (!after || !after.isInline)
759
878
  return null;
760
- let n = e.marks, i = t.parent.maybeChild(t.index());
761
- for (var r = 0; r < n.length; r++)
762
- n[r].type.spec.inclusive === !1 && (!i || !n[r].isInSet(i.marks)) && (n = n[r--].removeFromSet(n));
763
- return n;
879
+ let marks = after.marks, next = $end.parent.maybeChild($end.index());
880
+ for (var i = 0; i < marks.length; i++)
881
+ if (marks[i].type.spec.inclusive === false && (!next || !marks[i].isInSet(next.marks)))
882
+ marks = marks[i--].removeFromSet(marks);
883
+ return marks;
764
884
  }
765
885
  /**
766
886
  The depth up to which this position and the given (non-resolved)
767
887
  position share the same parent nodes.
768
888
  */
769
- sharedDepth(t) {
770
- for (let e = this.depth; e > 0; e--)
771
- if (this.start(e) <= t && this.end(e) >= t)
772
- return e;
889
+ sharedDepth(pos) {
890
+ for (let depth = this.depth; depth > 0; depth--)
891
+ if (this.start(depth) <= pos && this.end(depth) >= pos)
892
+ return depth;
773
893
  return 0;
774
894
  }
775
895
  /**
@@ -781,87 +901,99 @@ class S {
781
901
  pass in an optional predicate that will be called with a parent
782
902
  node to see if a range into that parent is acceptable.
783
903
  */
784
- blockRange(t = this, e) {
785
- if (t.pos < this.pos)
786
- return t.blockRange(this);
787
- for (let n = this.depth - (this.parent.inlineContent || this.pos == t.pos ? 1 : 0); n >= 0; n--)
788
- if (t.pos <= this.end(n) && (!e || e(this.node(n))))
789
- return new mt(this, t, n);
904
+ blockRange(other = this, pred) {
905
+ if (other.pos < this.pos)
906
+ return other.blockRange(this);
907
+ for (let d = this.depth - (this.parent.inlineContent || this.pos == other.pos ? 1 : 0); d >= 0; d--)
908
+ if (other.pos <= this.end(d) && (!pred || pred(this.node(d))))
909
+ return new NodeRange(this, other, d);
790
910
  return null;
791
911
  }
792
912
  /**
793
913
  Query whether the given position shares the same parent node.
794
914
  */
795
- sameParent(t) {
796
- return this.pos - this.parentOffset == t.pos - t.parentOffset;
915
+ sameParent(other) {
916
+ return this.pos - this.parentOffset == other.pos - other.parentOffset;
797
917
  }
798
918
  /**
799
919
  Return the greater of this and the given position.
800
920
  */
801
- max(t) {
802
- return t.pos > this.pos ? t : this;
921
+ max(other) {
922
+ return other.pos > this.pos ? other : this;
803
923
  }
804
924
  /**
805
925
  Return the smaller of this and the given position.
806
926
  */
807
- min(t) {
808
- return t.pos < this.pos ? t : this;
927
+ min(other) {
928
+ return other.pos < this.pos ? other : this;
809
929
  }
810
930
  /**
811
931
  @internal
812
932
  */
813
933
  toString() {
814
- let t = "";
815
- for (let e = 1; e <= this.depth; e++)
816
- t += (t ? "/" : "") + this.node(e).type.name + "_" + this.index(e - 1);
817
- return t + ":" + this.parentOffset;
934
+ let str = "";
935
+ for (let i = 1; i <= this.depth; i++)
936
+ str += (str ? "/" : "") + this.node(i).type.name + "_" + this.index(i - 1);
937
+ return str + ":" + this.parentOffset;
818
938
  }
819
939
  /**
820
940
  @internal
821
941
  */
822
- static resolve(t, e) {
823
- if (!(e >= 0 && e <= t.content.size))
824
- throw new RangeError("Position " + e + " out of range");
825
- let n = [], i = 0, r = e;
826
- for (let s = t; ; ) {
827
- let { index: o, offset: h } = s.content.findIndex(r), a = r - h;
828
- if (n.push(s, o, i + h), !a || (s = s.child(o), s.isText))
942
+ static resolve(doc2, pos) {
943
+ if (!(pos >= 0 && pos <= doc2.content.size))
944
+ throw new RangeError("Position " + pos + " out of range");
945
+ let path = [];
946
+ let start = 0, parentOffset = pos;
947
+ for (let node = doc2; ; ) {
948
+ let { index, offset } = node.content.findIndex(parentOffset);
949
+ let rem = parentOffset - offset;
950
+ path.push(node, index, start + offset);
951
+ if (!rem)
829
952
  break;
830
- r = a - 1, i += h + 1;
953
+ node = node.child(index);
954
+ if (node.isText)
955
+ break;
956
+ parentOffset = rem - 1;
957
+ start += offset + 1;
831
958
  }
832
- return new S(e, n, r);
959
+ return new ResolvedPos(pos, path, parentOffset);
833
960
  }
834
961
  /**
835
962
  @internal
836
963
  */
837
- static resolveCached(t, e) {
838
- let n = L.get(t);
839
- if (n)
840
- for (let r = 0; r < n.elts.length; r++) {
841
- let s = n.elts[r];
842
- if (s.pos == e)
843
- return s;
964
+ static resolveCached(doc2, pos) {
965
+ let cache = resolveCache.get(doc2);
966
+ if (cache) {
967
+ for (let i = 0; i < cache.elts.length; i++) {
968
+ let elt = cache.elts[i];
969
+ if (elt.pos == pos)
970
+ return elt;
844
971
  }
845
- else
846
- L.set(t, n = new yt());
847
- let i = n.elts[n.i] = S.resolve(t, e);
848
- return n.i = (n.i + 1) % xt, i;
972
+ } else {
973
+ resolveCache.set(doc2, cache = new ResolveCache());
974
+ }
975
+ let result = cache.elts[cache.i] = ResolvedPos.resolve(doc2, pos);
976
+ cache.i = (cache.i + 1) % resolveCacheSize;
977
+ return result;
849
978
  }
850
979
  }
851
- class yt {
980
+ class ResolveCache {
852
981
  constructor() {
853
- this.elts = [], this.i = 0;
982
+ this.elts = [];
983
+ this.i = 0;
854
984
  }
855
985
  }
856
- const xt = 12, L = /* @__PURE__ */ new WeakMap();
857
- class mt {
986
+ const resolveCacheSize = 12, resolveCache = /* @__PURE__ */ new WeakMap();
987
+ class NodeRange {
858
988
  /**
859
989
  Construct a node range. `$from` and `$to` should point into the
860
990
  same node until at least the given `depth`, since a node range
861
991
  denotes an adjacent set of nodes in a single parent node.
862
992
  */
863
- constructor(t, e, n) {
864
- this.$from = t, this.$to = e, this.depth = n;
993
+ constructor($from, $to, depth) {
994
+ this.$from = $from;
995
+ this.$to = $to;
996
+ this.depth = depth;
865
997
  }
866
998
  /**
867
999
  The position at the start of the range.
@@ -894,13 +1026,16 @@ class mt {
894
1026
  return this.$to.indexAfter(this.depth);
895
1027
  }
896
1028
  }
897
- const wt = /* @__PURE__ */ Object.create(null);
898
- class y {
1029
+ const emptyAttrs = /* @__PURE__ */ Object.create(null);
1030
+ class Node {
899
1031
  /**
900
1032
  @internal
901
1033
  */
902
- constructor(t, e, n, i = u.none) {
903
- this.type = t, this.attrs = e, this.marks = i, this.content = n || c.empty;
1034
+ constructor(type, attrs, content, marks = Mark.none) {
1035
+ this.type = type;
1036
+ this.attrs = attrs;
1037
+ this.marks = marks;
1038
+ this.content = content || Fragment.empty;
904
1039
  }
905
1040
  /**
906
1041
  The array of this node's child nodes.
@@ -928,21 +1063,21 @@ class y {
928
1063
  Get the child node at the given index. Raises an error when the
929
1064
  index is out of range.
930
1065
  */
931
- child(t) {
932
- return this.content.child(t);
1066
+ child(index) {
1067
+ return this.content.child(index);
933
1068
  }
934
1069
  /**
935
1070
  Get the child node at the given index, if it exists.
936
1071
  */
937
- maybeChild(t) {
938
- return this.content.maybeChild(t);
1072
+ maybeChild(index) {
1073
+ return this.content.maybeChild(index);
939
1074
  }
940
1075
  /**
941
1076
  Call `f` for every child node, passing the node, its offset
942
1077
  into this parent node, and its index.
943
1078
  */
944
- forEach(t) {
945
- this.content.forEach(t);
1079
+ forEach(f) {
1080
+ this.content.forEach(f);
946
1081
  }
947
1082
  /**
948
1083
  Invoke a callback for all descendant nodes recursively between
@@ -954,15 +1089,15 @@ class y {
954
1089
  recursed over. The last parameter can be used to specify a
955
1090
  starting position to count from.
956
1091
  */
957
- nodesBetween(t, e, n, i = 0) {
958
- this.content.nodesBetween(t, e, n, i, this);
1092
+ nodesBetween(from, to, f, startPos = 0) {
1093
+ this.content.nodesBetween(from, to, f, startPos, this);
959
1094
  }
960
1095
  /**
961
1096
  Call the given callback for every descendant node. Doesn't
962
1097
  descend into a node when the callback returns `false`.
963
1098
  */
964
- descendants(t) {
965
- this.nodesBetween(0, this.content.size, t);
1099
+ descendants(f) {
1100
+ this.nodesBetween(0, this.content.size, f);
966
1101
  }
967
1102
  /**
968
1103
  Concatenates all the text nodes found in this fragment and its
@@ -978,8 +1113,8 @@ class y {
978
1113
  inserted for every non-text leaf node encountered, otherwise
979
1114
  [`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec^leafText) will be used.
980
1115
  */
981
- textBetween(t, e, n, i) {
982
- return this.content.textBetween(t, e, n, i);
1116
+ textBetween(from, to, blockSeparator, leafText) {
1117
+ return this.content.textBetween(from, to, blockSeparator, leafText);
983
1118
  }
984
1119
  /**
985
1120
  Returns this node's first child, or `null` if there are no
@@ -998,54 +1133,61 @@ class y {
998
1133
  /**
999
1134
  Test whether two nodes represent the same piece of document.
1000
1135
  */
1001
- eq(t) {
1002
- return this == t || this.sameMarkup(t) && this.content.eq(t.content);
1136
+ eq(other) {
1137
+ return this == other || this.sameMarkup(other) && this.content.eq(other.content);
1003
1138
  }
1004
1139
  /**
1005
1140
  Compare the markup (type, attributes, and marks) of this node to
1006
1141
  those of another. Returns `true` if both have the same markup.
1007
1142
  */
1008
- sameMarkup(t) {
1009
- return this.hasMarkup(t.type, t.attrs, t.marks);
1143
+ sameMarkup(other) {
1144
+ return this.hasMarkup(other.type, other.attrs, other.marks);
1010
1145
  }
1011
1146
  /**
1012
1147
  Check whether this node's markup correspond to the given type,
1013
1148
  attributes, and marks.
1014
1149
  */
1015
- hasMarkup(t, e, n) {
1016
- return this.type == t && M(this.attrs, e || t.defaultAttrs || wt) && u.sameSet(this.marks, n || u.none);
1150
+ hasMarkup(type, attrs, marks) {
1151
+ return this.type == type && compareDeep(this.attrs, attrs || type.defaultAttrs || emptyAttrs) && Mark.sameSet(this.marks, marks || Mark.none);
1017
1152
  }
1018
1153
  /**
1019
1154
  Create a new node with the same markup as this node, containing
1020
1155
  the given content (or empty, if no content is given).
1021
1156
  */
1022
- copy(t = null) {
1023
- return t == this.content ? this : new y(this.type, this.attrs, t, this.marks);
1157
+ copy(content = null) {
1158
+ if (content == this.content)
1159
+ return this;
1160
+ return new Node(this.type, this.attrs, content, this.marks);
1024
1161
  }
1025
1162
  /**
1026
1163
  Create a copy of this node, with the given set of marks instead
1027
1164
  of the node's own marks.
1028
1165
  */
1029
- mark(t) {
1030
- return t == this.marks ? this : new y(this.type, this.attrs, this.content, t);
1166
+ mark(marks) {
1167
+ return marks == this.marks ? this : new Node(this.type, this.attrs, this.content, marks);
1031
1168
  }
1032
1169
  /**
1033
1170
  Create a copy of this node with only the content between the
1034
1171
  given positions. If `to` is not given, it defaults to the end of
1035
1172
  the node.
1036
1173
  */
1037
- cut(t, e = this.content.size) {
1038
- return t == 0 && e == this.content.size ? this : this.copy(this.content.cut(t, e));
1174
+ cut(from, to = this.content.size) {
1175
+ if (from == 0 && to == this.content.size)
1176
+ return this;
1177
+ return this.copy(this.content.cut(from, to));
1039
1178
  }
1040
1179
  /**
1041
1180
  Cut out the part of the document between the given positions, and
1042
1181
  return it as a `Slice` object.
1043
1182
  */
1044
- slice(t, e = this.content.size, n = !1) {
1045
- if (t == e)
1046
- return d.empty;
1047
- let i = this.resolve(t), r = this.resolve(e), s = n ? 0 : i.sharedDepth(e), o = i.start(s), a = i.node(s).content.cut(i.pos - o, r.pos - o);
1048
- return new d(a, i.depth - s, r.depth - s);
1183
+ slice(from, to = this.content.size, includeParents = false) {
1184
+ if (from == to)
1185
+ return Slice.empty;
1186
+ let $from = this.resolve(from), $to = this.resolve(to);
1187
+ let depth = includeParents ? 0 : $from.sharedDepth(to);
1188
+ let start = $from.start(depth), node = $from.node(depth);
1189
+ let content = node.content.cut($from.pos - start, $to.pos - start);
1190
+ return new Slice(content, $from.depth - depth, $to.depth - depth);
1049
1191
  }
1050
1192
  /**
1051
1193
  Replace the part of the document between the given positions with
@@ -1055,20 +1197,21 @@ class y {
1055
1197
  into. If any of this is violated, an error of type
1056
1198
  [`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown.
1057
1199
  */
1058
- replace(t, e, n) {
1059
- return dt(this.resolve(t), this.resolve(e), n);
1200
+ replace(from, to, slice) {
1201
+ return replace(this.resolve(from), this.resolve(to), slice);
1060
1202
  }
1061
1203
  /**
1062
1204
  Find the node directly after the given position.
1063
1205
  */
1064
- nodeAt(t) {
1065
- for (let e = this; ; ) {
1066
- let { index: n, offset: i } = e.content.findIndex(t);
1067
- if (e = e.maybeChild(n), !e)
1206
+ nodeAt(pos) {
1207
+ for (let node = this; ; ) {
1208
+ let { index, offset } = node.content.findIndex(pos);
1209
+ node = node.maybeChild(index);
1210
+ if (!node)
1068
1211
  return null;
1069
- if (i == t || e.isText)
1070
- return e;
1071
- t -= i + 1;
1212
+ if (offset == pos || node.isText)
1213
+ return node;
1214
+ pos -= offset + 1;
1072
1215
  }
1073
1216
  }
1074
1217
  /**
@@ -1076,44 +1219,50 @@ class y {
1076
1219
  and return it along with its index and offset relative to this
1077
1220
  node.
1078
1221
  */
1079
- childAfter(t) {
1080
- let { index: e, offset: n } = this.content.findIndex(t);
1081
- return { node: this.content.maybeChild(e), index: e, offset: n };
1222
+ childAfter(pos) {
1223
+ let { index, offset } = this.content.findIndex(pos);
1224
+ return { node: this.content.maybeChild(index), index, offset };
1082
1225
  }
1083
1226
  /**
1084
1227
  Find the (direct) child node before the given offset, if any,
1085
1228
  and return it along with its index and offset relative to this
1086
1229
  node.
1087
1230
  */
1088
- childBefore(t) {
1089
- if (t == 0)
1231
+ childBefore(pos) {
1232
+ if (pos == 0)
1090
1233
  return { node: null, index: 0, offset: 0 };
1091
- let { index: e, offset: n } = this.content.findIndex(t);
1092
- if (n < t)
1093
- return { node: this.content.child(e), index: e, offset: n };
1094
- let i = this.content.child(e - 1);
1095
- return { node: i, index: e - 1, offset: n - i.nodeSize };
1234
+ let { index, offset } = this.content.findIndex(pos);
1235
+ if (offset < pos)
1236
+ return { node: this.content.child(index), index, offset };
1237
+ let node = this.content.child(index - 1);
1238
+ return { node, index: index - 1, offset: offset - node.nodeSize };
1096
1239
  }
1097
1240
  /**
1098
1241
  Resolve the given position in the document, returning an
1099
1242
  [object](https://prosemirror.net/docs/ref/#model.ResolvedPos) with information about its context.
1100
1243
  */
1101
- resolve(t) {
1102
- return S.resolveCached(this, t);
1244
+ resolve(pos) {
1245
+ return ResolvedPos.resolveCached(this, pos);
1103
1246
  }
1104
1247
  /**
1105
1248
  @internal
1106
1249
  */
1107
- resolveNoCache(t) {
1108
- return S.resolve(this, t);
1250
+ resolveNoCache(pos) {
1251
+ return ResolvedPos.resolve(this, pos);
1109
1252
  }
1110
1253
  /**
1111
1254
  Test whether a given mark or mark type occurs in this document
1112
1255
  between the two given positions.
1113
1256
  */
1114
- rangeHasMark(t, e, n) {
1115
- let i = !1;
1116
- return e > t && this.nodesBetween(t, e, (r) => (n.isInSet(r.marks) && (i = !0), !i)), i;
1257
+ rangeHasMark(from, to, type) {
1258
+ let found2 = false;
1259
+ if (to > from)
1260
+ this.nodesBetween(from, to, (node) => {
1261
+ if (type.isInSet(node.marks))
1262
+ found2 = true;
1263
+ return !found2;
1264
+ });
1265
+ return found2;
1117
1266
  }
1118
1267
  /**
1119
1268
  True when this is a block (non-inline node)
@@ -1170,17 +1319,19 @@ class y {
1170
1319
  toString() {
1171
1320
  if (this.type.spec.toDebugString)
1172
1321
  return this.type.spec.toDebugString(this);
1173
- let t = this.type.name;
1174
- return this.content.size && (t += "(" + this.content.toStringInner() + ")"), it(this.marks, t);
1322
+ let name = this.type.name;
1323
+ if (this.content.size)
1324
+ name += "(" + this.content.toStringInner() + ")";
1325
+ return wrapMarks(this.marks, name);
1175
1326
  }
1176
1327
  /**
1177
1328
  Get the content match in this node at the given index.
1178
1329
  */
1179
- contentMatchAt(t) {
1180
- let e = this.type.contentMatch.matchFragment(this.content, 0, t);
1181
- if (!e)
1330
+ contentMatchAt(index) {
1331
+ let match = this.type.contentMatch.matchFragment(this.content, 0, index);
1332
+ if (!match)
1182
1333
  throw new Error("Called contentMatchAt on a node with invalid content");
1183
- return e;
1334
+ return match;
1184
1335
  }
1185
1336
  /**
1186
1337
  Test whether replacing the range between `from` and `to` (by
@@ -1189,24 +1340,26 @@ class y {
1189
1340
  can optionally pass `start` and `end` indices into the
1190
1341
  replacement fragment.
1191
1342
  */
1192
- canReplace(t, e, n = c.empty, i = 0, r = n.childCount) {
1193
- let s = this.contentMatchAt(t).matchFragment(n, i, r), o = s && s.matchFragment(this.content, e);
1194
- if (!o || !o.validEnd)
1195
- return !1;
1196
- for (let h = i; h < r; h++)
1197
- if (!this.type.allowsMarks(n.child(h).marks))
1198
- return !1;
1199
- return !0;
1343
+ canReplace(from, to, replacement = Fragment.empty, start = 0, end = replacement.childCount) {
1344
+ let one = this.contentMatchAt(from).matchFragment(replacement, start, end);
1345
+ let two = one && one.matchFragment(this.content, to);
1346
+ if (!two || !two.validEnd)
1347
+ return false;
1348
+ for (let i = start; i < end; i++)
1349
+ if (!this.type.allowsMarks(replacement.child(i).marks))
1350
+ return false;
1351
+ return true;
1200
1352
  }
1201
1353
  /**
1202
1354
  Test whether replacing the range `from` to `to` (by index) with
1203
1355
  a node of the given type would leave the node's content valid.
1204
1356
  */
1205
- canReplaceWith(t, e, n, i) {
1206
- if (i && !this.type.allowsMarks(i))
1207
- return !1;
1208
- let r = this.contentMatchAt(t).matchType(n), s = r && r.matchFragment(this.content, e);
1209
- return s ? s.validEnd : !1;
1357
+ canReplaceWith(from, to, type, marks) {
1358
+ if (marks && !this.type.allowsMarks(marks))
1359
+ return false;
1360
+ let start = this.contentMatchAt(from).matchType(type);
1361
+ let end = start && start.matchFragment(this.content, to);
1362
+ return end ? end.validEnd : false;
1210
1363
  }
1211
1364
  /**
1212
1365
  Test whether the given node's content could be appended to this
@@ -1214,138 +1367,161 @@ class y {
1214
1367
  is at least one node type that can appear in both nodes (to avoid
1215
1368
  merging completely incompatible nodes).
1216
1369
  */
1217
- canAppend(t) {
1218
- return t.content.size ? this.canReplace(this.childCount, this.childCount, t.content) : this.type.compatibleContent(t.type);
1370
+ canAppend(other) {
1371
+ if (other.content.size)
1372
+ return this.canReplace(this.childCount, this.childCount, other.content);
1373
+ else
1374
+ return this.type.compatibleContent(other.type);
1219
1375
  }
1220
1376
  /**
1221
1377
  Check whether this node and its descendants conform to the
1222
1378
  schema, and raise an exception when they do not.
1223
1379
  */
1224
1380
  check() {
1225
- this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
1226
- let t = u.none;
1227
- for (let e = 0; e < this.marks.length; e++) {
1228
- let n = this.marks[e];
1229
- n.type.checkAttrs(n.attrs), t = n.addToSet(t);
1381
+ this.type.checkContent(this.content);
1382
+ this.type.checkAttrs(this.attrs);
1383
+ let copy2 = Mark.none;
1384
+ for (let i = 0; i < this.marks.length; i++) {
1385
+ let mark = this.marks[i];
1386
+ mark.type.checkAttrs(mark.attrs);
1387
+ copy2 = mark.addToSet(copy2);
1230
1388
  }
1231
- if (!u.sameSet(t, this.marks))
1232
- throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
1233
- this.content.forEach((e) => e.check());
1389
+ if (!Mark.sameSet(copy2, this.marks))
1390
+ throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m) => m.type.name)}`);
1391
+ this.content.forEach((node) => node.check());
1234
1392
  }
1235
1393
  /**
1236
1394
  Return a JSON-serializeable representation of this node.
1237
1395
  */
1238
1396
  toJSON() {
1239
- let t = { type: this.type.name };
1240
- for (let e in this.attrs) {
1241
- t.attrs = this.attrs;
1397
+ let obj = { type: this.type.name };
1398
+ for (let _ in this.attrs) {
1399
+ obj.attrs = this.attrs;
1242
1400
  break;
1243
1401
  }
1244
- return this.content.size && (t.content = this.content.toJSON()), this.marks.length && (t.marks = this.marks.map((e) => e.toJSON())), t;
1402
+ if (this.content.size)
1403
+ obj.content = this.content.toJSON();
1404
+ if (this.marks.length)
1405
+ obj.marks = this.marks.map((n) => n.toJSON());
1406
+ return obj;
1245
1407
  }
1246
1408
  /**
1247
1409
  Deserialize a node from its JSON representation.
1248
1410
  */
1249
- static fromJSON(t, e) {
1250
- if (!e)
1411
+ static fromJSON(schema, json) {
1412
+ if (!json)
1251
1413
  throw new RangeError("Invalid input for Node.fromJSON");
1252
- let n;
1253
- if (e.marks) {
1254
- if (!Array.isArray(e.marks))
1414
+ let marks = void 0;
1415
+ if (json.marks) {
1416
+ if (!Array.isArray(json.marks))
1255
1417
  throw new RangeError("Invalid mark data for Node.fromJSON");
1256
- n = e.marks.map(t.markFromJSON);
1418
+ marks = json.marks.map(schema.markFromJSON);
1257
1419
  }
1258
- if (e.type == "text") {
1259
- if (typeof e.text != "string")
1420
+ if (json.type == "text") {
1421
+ if (typeof json.text != "string")
1260
1422
  throw new RangeError("Invalid text node in JSON");
1261
- return t.text(e.text, n);
1423
+ return schema.text(json.text, marks);
1262
1424
  }
1263
- let i = c.fromJSON(t, e.content), r = t.nodeType(e.type).create(e.attrs, i, n);
1264
- return r.type.checkAttrs(r.attrs), r;
1425
+ let content = Fragment.fromJSON(schema, json.content);
1426
+ let node = schema.nodeType(json.type).create(json.attrs, content, marks);
1427
+ node.type.checkAttrs(node.attrs);
1428
+ return node;
1265
1429
  }
1266
1430
  }
1267
- y.prototype.text = void 0;
1268
- class N extends y {
1431
+ Node.prototype.text = void 0;
1432
+ class TextNode extends Node {
1269
1433
  /**
1270
1434
  @internal
1271
1435
  */
1272
- constructor(t, e, n, i) {
1273
- if (super(t, e, null, i), !n)
1436
+ constructor(type, attrs, content, marks) {
1437
+ super(type, attrs, null, marks);
1438
+ if (!content)
1274
1439
  throw new RangeError("Empty text nodes are not allowed");
1275
- this.text = n;
1440
+ this.text = content;
1276
1441
  }
1277
1442
  toString() {
1278
- return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : it(this.marks, JSON.stringify(this.text));
1443
+ if (this.type.spec.toDebugString)
1444
+ return this.type.spec.toDebugString(this);
1445
+ return wrapMarks(this.marks, JSON.stringify(this.text));
1279
1446
  }
1280
1447
  get textContent() {
1281
1448
  return this.text;
1282
1449
  }
1283
- textBetween(t, e) {
1284
- return this.text.slice(t, e);
1450
+ textBetween(from, to) {
1451
+ return this.text.slice(from, to);
1285
1452
  }
1286
1453
  get nodeSize() {
1287
1454
  return this.text.length;
1288
1455
  }
1289
- mark(t) {
1290
- return t == this.marks ? this : new N(this.type, this.attrs, this.text, t);
1456
+ mark(marks) {
1457
+ return marks == this.marks ? this : new TextNode(this.type, this.attrs, this.text, marks);
1291
1458
  }
1292
- withText(t) {
1293
- return t == this.text ? this : new N(this.type, this.attrs, t, this.marks);
1459
+ withText(text) {
1460
+ if (text == this.text)
1461
+ return this;
1462
+ return new TextNode(this.type, this.attrs, text, this.marks);
1294
1463
  }
1295
- cut(t = 0, e = this.text.length) {
1296
- return t == 0 && e == this.text.length ? this : this.withText(this.text.slice(t, e));
1464
+ cut(from = 0, to = this.text.length) {
1465
+ if (from == 0 && to == this.text.length)
1466
+ return this;
1467
+ return this.withText(this.text.slice(from, to));
1297
1468
  }
1298
- eq(t) {
1299
- return this.sameMarkup(t) && this.text == t.text;
1469
+ eq(other) {
1470
+ return this.sameMarkup(other) && this.text == other.text;
1300
1471
  }
1301
1472
  toJSON() {
1302
- let t = super.toJSON();
1303
- return t.text = this.text, t;
1473
+ let base = super.toJSON();
1474
+ base.text = this.text;
1475
+ return base;
1304
1476
  }
1305
1477
  }
1306
- function it(l, t) {
1307
- for (let e = l.length - 1; e >= 0; e--)
1308
- t = l[e].type.name + "(" + t + ")";
1309
- return t;
1478
+ function wrapMarks(marks, str) {
1479
+ for (let i = marks.length - 1; i >= 0; i--)
1480
+ str = marks[i].type.name + "(" + str + ")";
1481
+ return str;
1310
1482
  }
1311
- class w {
1483
+ class ContentMatch {
1312
1484
  /**
1313
1485
  @internal
1314
1486
  */
1315
- constructor(t) {
1316
- this.validEnd = t, this.next = [], this.wrapCache = [];
1487
+ constructor(validEnd) {
1488
+ this.validEnd = validEnd;
1489
+ this.next = [];
1490
+ this.wrapCache = [];
1317
1491
  }
1318
1492
  /**
1319
1493
  @internal
1320
1494
  */
1321
- static parse(t, e) {
1322
- let n = new kt(t, e);
1323
- if (n.next == null)
1324
- return w.empty;
1325
- let i = rt(n);
1326
- n.next && n.err("Unexpected trailing text");
1327
- let r = Mt(Tt(i));
1328
- return At(r, n), r;
1495
+ static parse(string, nodeTypes) {
1496
+ let stream = new TokenStream(string, nodeTypes);
1497
+ if (stream.next == null)
1498
+ return ContentMatch.empty;
1499
+ let expr = parseExpr(stream);
1500
+ if (stream.next)
1501
+ stream.err("Unexpected trailing text");
1502
+ let match = dfa(nfa(expr));
1503
+ checkForDeadEnds(match, stream);
1504
+ return match;
1329
1505
  }
1330
1506
  /**
1331
1507
  Match a node type, returning a match after that node if
1332
1508
  successful.
1333
1509
  */
1334
- matchType(t) {
1335
- for (let e = 0; e < this.next.length; e++)
1336
- if (this.next[e].type == t)
1337
- return this.next[e].next;
1510
+ matchType(type) {
1511
+ for (let i = 0; i < this.next.length; i++)
1512
+ if (this.next[i].type == type)
1513
+ return this.next[i].next;
1338
1514
  return null;
1339
1515
  }
1340
1516
  /**
1341
1517
  Try to match a fragment. Returns the resulting match when
1342
1518
  successful.
1343
1519
  */
1344
- matchFragment(t, e = 0, n = t.childCount) {
1345
- let i = this;
1346
- for (let r = e; i && r < n; r++)
1347
- i = i.matchType(t.child(r).type);
1348
- return i;
1520
+ matchFragment(frag, start = 0, end = frag.childCount) {
1521
+ let cur = this;
1522
+ for (let i = start; cur && i < end; i++)
1523
+ cur = cur.matchType(frag.child(i).type);
1524
+ return cur;
1349
1525
  }
1350
1526
  /**
1351
1527
  @internal
@@ -1358,22 +1534,22 @@ class w {
1358
1534
  be generated.
1359
1535
  */
1360
1536
  get defaultType() {
1361
- for (let t = 0; t < this.next.length; t++) {
1362
- let { type: e } = this.next[t];
1363
- if (!(e.isText || e.hasRequiredAttrs()))
1364
- return e;
1537
+ for (let i = 0; i < this.next.length; i++) {
1538
+ let { type } = this.next[i];
1539
+ if (!(type.isText || type.hasRequiredAttrs()))
1540
+ return type;
1365
1541
  }
1366
1542
  return null;
1367
1543
  }
1368
1544
  /**
1369
1545
  @internal
1370
1546
  */
1371
- compatible(t) {
1372
- for (let e = 0; e < this.next.length; e++)
1373
- for (let n = 0; n < t.next.length; n++)
1374
- if (this.next[e].type == t.next[n].type)
1375
- return !0;
1376
- return !1;
1547
+ compatible(other) {
1548
+ for (let i = 0; i < this.next.length; i++)
1549
+ for (let j = 0; j < other.next.length; j++)
1550
+ if (this.next[i].type == other.next[j].type)
1551
+ return true;
1552
+ return false;
1377
1553
  }
1378
1554
  /**
1379
1555
  Try to match the given fragment, and if that fails, see if it can
@@ -1383,24 +1559,24 @@ class w {
1383
1559
  return a fragment if the resulting match goes to the end of the
1384
1560
  content expression.
1385
1561
  */
1386
- fillBefore(t, e = !1, n = 0) {
1387
- let i = [this];
1388
- function r(s, o) {
1389
- let h = s.matchFragment(t, n);
1390
- if (h && (!e || h.validEnd))
1391
- return c.from(o.map((a) => a.createAndFill()));
1392
- for (let a = 0; a < s.next.length; a++) {
1393
- let { type: f, next: p } = s.next[a];
1394
- if (!(f.isText || f.hasRequiredAttrs()) && i.indexOf(p) == -1) {
1395
- i.push(p);
1396
- let g = r(p, o.concat(f));
1397
- if (g)
1398
- return g;
1562
+ fillBefore(after, toEnd = false, startIndex = 0) {
1563
+ let seen = [this];
1564
+ function search(match, types) {
1565
+ let finished = match.matchFragment(after, startIndex);
1566
+ if (finished && (!toEnd || finished.validEnd))
1567
+ return Fragment.from(types.map((tp) => tp.createAndFill()));
1568
+ for (let i = 0; i < match.next.length; i++) {
1569
+ let { type, next } = match.next[i];
1570
+ if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
1571
+ seen.push(next);
1572
+ let found2 = search(next, types.concat(type));
1573
+ if (found2)
1574
+ return found2;
1399
1575
  }
1400
1576
  }
1401
1577
  return null;
1402
1578
  }
1403
- return r(this, []);
1579
+ return search(this, []);
1404
1580
  }
1405
1581
  /**
1406
1582
  Find a set of wrapping node types that would allow a node of the
@@ -1408,29 +1584,33 @@ class w {
1408
1584
  (when it fits directly) and will be null when no such wrapping
1409
1585
  exists.
1410
1586
  */
1411
- findWrapping(t) {
1412
- for (let n = 0; n < this.wrapCache.length; n += 2)
1413
- if (this.wrapCache[n] == t)
1414
- return this.wrapCache[n + 1];
1415
- let e = this.computeWrapping(t);
1416
- return this.wrapCache.push(t, e), e;
1587
+ findWrapping(target) {
1588
+ for (let i = 0; i < this.wrapCache.length; i += 2)
1589
+ if (this.wrapCache[i] == target)
1590
+ return this.wrapCache[i + 1];
1591
+ let computed = this.computeWrapping(target);
1592
+ this.wrapCache.push(target, computed);
1593
+ return computed;
1417
1594
  }
1418
1595
  /**
1419
1596
  @internal
1420
1597
  */
1421
- computeWrapping(t) {
1422
- let e = /* @__PURE__ */ Object.create(null), n = [{ match: this, type: null, via: null }];
1423
- for (; n.length; ) {
1424
- let i = n.shift(), r = i.match;
1425
- if (r.matchType(t)) {
1426
- let s = [];
1427
- for (let o = i; o.type; o = o.via)
1428
- s.push(o.type);
1429
- return s.reverse();
1598
+ computeWrapping(target) {
1599
+ let seen = /* @__PURE__ */ Object.create(null), active = [{ match: this, type: null, via: null }];
1600
+ while (active.length) {
1601
+ let current = active.shift(), match = current.match;
1602
+ if (match.matchType(target)) {
1603
+ let result = [];
1604
+ for (let obj = current; obj.type; obj = obj.via)
1605
+ result.push(obj.type);
1606
+ return result.reverse();
1430
1607
  }
1431
- for (let s = 0; s < r.next.length; s++) {
1432
- let { type: o, next: h } = r.next[s];
1433
- !o.isLeaf && !o.hasRequiredAttrs() && !(o.name in e) && (!i.type || h.validEnd) && (n.push({ match: o.contentMatch, type: o, via: i }), e[o.name] = !0);
1608
+ for (let i = 0; i < match.next.length; i++) {
1609
+ let { type, next } = match.next[i];
1610
+ if (!type.isLeaf && !type.hasRequiredAttrs() && !(type.name in seen) && (!current.type || next.validEnd)) {
1611
+ active.push({ match: type.contentMatch, type, via: current });
1612
+ seen[type.name] = true;
1613
+ }
1434
1614
  }
1435
1615
  }
1436
1616
  return null;
@@ -1446,258 +1626,320 @@ class w {
1446
1626
  Get the _n_​th outgoing edge from this node in the finite
1447
1627
  automaton that describes the content expression.
1448
1628
  */
1449
- edge(t) {
1450
- if (t >= this.next.length)
1451
- throw new RangeError(`There's no ${t}th edge in this content match`);
1452
- return this.next[t];
1629
+ edge(n) {
1630
+ if (n >= this.next.length)
1631
+ throw new RangeError(`There's no ${n}th edge in this content match`);
1632
+ return this.next[n];
1453
1633
  }
1454
1634
  /**
1455
1635
  @internal
1456
1636
  */
1457
1637
  toString() {
1458
- let t = [];
1459
- function e(n) {
1460
- t.push(n);
1461
- for (let i = 0; i < n.next.length; i++)
1462
- t.indexOf(n.next[i].next) == -1 && e(n.next[i].next);
1638
+ let seen = [];
1639
+ function scan(m) {
1640
+ seen.push(m);
1641
+ for (let i = 0; i < m.next.length; i++)
1642
+ if (seen.indexOf(m.next[i].next) == -1)
1643
+ scan(m.next[i].next);
1463
1644
  }
1464
- return e(this), t.map((n, i) => {
1465
- let r = i + (n.validEnd ? "*" : " ") + " ";
1466
- for (let s = 0; s < n.next.length; s++)
1467
- r += (s ? ", " : "") + n.next[s].type.name + "->" + t.indexOf(n.next[s].next);
1468
- return r;
1469
- }).join(`
1470
- `);
1471
- }
1472
- }
1473
- w.empty = new w(!0);
1474
- class kt {
1475
- constructor(t, e) {
1476
- this.string = t, this.nodeTypes = e, this.inline = null, this.pos = 0, this.tokens = t.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
1645
+ scan(this);
1646
+ return seen.map((m, i) => {
1647
+ let out = i + (m.validEnd ? "*" : " ") + " ";
1648
+ for (let i2 = 0; i2 < m.next.length; i2++)
1649
+ out += (i2 ? ", " : "") + m.next[i2].type.name + "->" + seen.indexOf(m.next[i2].next);
1650
+ return out;
1651
+ }).join("\n");
1652
+ }
1653
+ }
1654
+ ContentMatch.empty = new ContentMatch(true);
1655
+ class TokenStream {
1656
+ constructor(string, nodeTypes) {
1657
+ this.string = string;
1658
+ this.nodeTypes = nodeTypes;
1659
+ this.inline = null;
1660
+ this.pos = 0;
1661
+ this.tokens = string.split(/\s*(?=\b|\W|$)/);
1662
+ if (this.tokens[this.tokens.length - 1] == "")
1663
+ this.tokens.pop();
1664
+ if (this.tokens[0] == "")
1665
+ this.tokens.shift();
1477
1666
  }
1478
1667
  get next() {
1479
1668
  return this.tokens[this.pos];
1480
1669
  }
1481
- eat(t) {
1482
- return this.next == t && (this.pos++ || !0);
1483
- }
1484
- err(t) {
1485
- throw new SyntaxError(t + " (in content expression '" + this.string + "')");
1486
- }
1487
- }
1488
- function rt(l) {
1489
- let t = [];
1490
- do
1491
- t.push(St(l));
1492
- while (l.eat("|"));
1493
- return t.length == 1 ? t[0] : { type: "choice", exprs: t };
1494
- }
1495
- function St(l) {
1496
- let t = [];
1497
- do
1498
- t.push(Et(l));
1499
- while (l.next && l.next != ")" && l.next != "|");
1500
- return t.length == 1 ? t[0] : { type: "seq", exprs: t };
1501
- }
1502
- function Et(l) {
1503
- let t = bt(l);
1504
- for (; ; )
1505
- if (l.eat("+"))
1506
- t = { type: "plus", expr: t };
1507
- else if (l.eat("*"))
1508
- t = { type: "star", expr: t };
1509
- else if (l.eat("?"))
1510
- t = { type: "opt", expr: t };
1511
- else if (l.eat("{"))
1512
- t = Ot(l, t);
1670
+ eat(tok) {
1671
+ return this.next == tok && (this.pos++ || true);
1672
+ }
1673
+ err(str) {
1674
+ throw new SyntaxError(str + " (in content expression '" + this.string + "')");
1675
+ }
1676
+ }
1677
+ function parseExpr(stream) {
1678
+ let exprs = [];
1679
+ do {
1680
+ exprs.push(parseExprSeq(stream));
1681
+ } while (stream.eat("|"));
1682
+ return exprs.length == 1 ? exprs[0] : { type: "choice", exprs };
1683
+ }
1684
+ function parseExprSeq(stream) {
1685
+ let exprs = [];
1686
+ do {
1687
+ exprs.push(parseExprSubscript(stream));
1688
+ } while (stream.next && stream.next != ")" && stream.next != "|");
1689
+ return exprs.length == 1 ? exprs[0] : { type: "seq", exprs };
1690
+ }
1691
+ function parseExprSubscript(stream) {
1692
+ let expr = parseExprAtom(stream);
1693
+ for (; ; ) {
1694
+ if (stream.eat("+"))
1695
+ expr = { type: "plus", expr };
1696
+ else if (stream.eat("*"))
1697
+ expr = { type: "star", expr };
1698
+ else if (stream.eat("?"))
1699
+ expr = { type: "opt", expr };
1700
+ else if (stream.eat("{"))
1701
+ expr = parseExprRange(stream, expr);
1513
1702
  else
1514
1703
  break;
1515
- return t;
1516
- }
1517
- function W(l) {
1518
- /\D/.test(l.next) && l.err("Expected number, got '" + l.next + "'");
1519
- let t = Number(l.next);
1520
- return l.pos++, t;
1521
- }
1522
- function Ot(l, t) {
1523
- let e = W(l), n = e;
1524
- return l.eat(",") && (l.next != "}" ? n = W(l) : n = -1), l.eat("}") || l.err("Unclosed braced range"), { type: "range", min: e, max: n, expr: t };
1525
- }
1526
- function Ct(l, t) {
1527
- let e = l.nodeTypes, n = e[t];
1528
- if (n)
1529
- return [n];
1530
- let i = [];
1531
- for (let r in e) {
1532
- let s = e[r];
1533
- s.isInGroup(t) && i.push(s);
1534
- }
1535
- return i.length == 0 && l.err("No node type or group '" + t + "' found"), i;
1536
- }
1537
- function bt(l) {
1538
- if (l.eat("(")) {
1539
- let t = rt(l);
1540
- return l.eat(")") || l.err("Missing closing paren"), t;
1541
- } else if (/\W/.test(l.next))
1542
- l.err("Unexpected token '" + l.next + "'");
1543
- else {
1544
- let t = Ct(l, l.next).map((e) => (l.inline == null ? l.inline = e.isInline : l.inline != e.isInline && l.err("Mixing inline and block content"), { type: "name", value: e }));
1545
- return l.pos++, t.length == 1 ? t[0] : { type: "choice", exprs: t };
1546
- }
1547
- }
1548
- function Tt(l) {
1549
- let t = [[]];
1550
- return i(r(l, 0), e()), t;
1551
- function e() {
1552
- return t.push([]) - 1;
1553
- }
1554
- function n(s, o, h) {
1555
- let a = { term: h, to: o };
1556
- return t[s].push(a), a;
1557
- }
1558
- function i(s, o) {
1559
- s.forEach((h) => h.to = o);
1560
- }
1561
- function r(s, o) {
1562
- if (s.type == "choice")
1563
- return s.exprs.reduce((h, a) => h.concat(r(a, o)), []);
1564
- if (s.type == "seq")
1565
- for (let h = 0; ; h++) {
1566
- let a = r(s.exprs[h], o);
1567
- if (h == s.exprs.length - 1)
1568
- return a;
1569
- i(a, o = e());
1704
+ }
1705
+ return expr;
1706
+ }
1707
+ function parseNum(stream) {
1708
+ if (/\D/.test(stream.next))
1709
+ stream.err("Expected number, got '" + stream.next + "'");
1710
+ let result = Number(stream.next);
1711
+ stream.pos++;
1712
+ return result;
1713
+ }
1714
+ function parseExprRange(stream, expr) {
1715
+ let min = parseNum(stream), max = min;
1716
+ if (stream.eat(",")) {
1717
+ if (stream.next != "}")
1718
+ max = parseNum(stream);
1719
+ else
1720
+ max = -1;
1721
+ }
1722
+ if (!stream.eat("}"))
1723
+ stream.err("Unclosed braced range");
1724
+ return { type: "range", min, max, expr };
1725
+ }
1726
+ function resolveName(stream, name) {
1727
+ let types = stream.nodeTypes, type = types[name];
1728
+ if (type)
1729
+ return [type];
1730
+ let result = [];
1731
+ for (let typeName in types) {
1732
+ let type2 = types[typeName];
1733
+ if (type2.isInGroup(name))
1734
+ result.push(type2);
1735
+ }
1736
+ if (result.length == 0)
1737
+ stream.err("No node type or group '" + name + "' found");
1738
+ return result;
1739
+ }
1740
+ function parseExprAtom(stream) {
1741
+ if (stream.eat("(")) {
1742
+ let expr = parseExpr(stream);
1743
+ if (!stream.eat(")"))
1744
+ stream.err("Missing closing paren");
1745
+ return expr;
1746
+ } else if (!/\W/.test(stream.next)) {
1747
+ let exprs = resolveName(stream, stream.next).map((type) => {
1748
+ if (stream.inline == null)
1749
+ stream.inline = type.isInline;
1750
+ else if (stream.inline != type.isInline)
1751
+ stream.err("Mixing inline and block content");
1752
+ return { type: "name", value: type };
1753
+ });
1754
+ stream.pos++;
1755
+ return exprs.length == 1 ? exprs[0] : { type: "choice", exprs };
1756
+ } else {
1757
+ stream.err("Unexpected token '" + stream.next + "'");
1758
+ }
1759
+ }
1760
+ function nfa(expr) {
1761
+ let nfa2 = [[]];
1762
+ connect(compile(expr, 0), node());
1763
+ return nfa2;
1764
+ function node() {
1765
+ return nfa2.push([]) - 1;
1766
+ }
1767
+ function edge(from, to, term) {
1768
+ let edge2 = { term, to };
1769
+ nfa2[from].push(edge2);
1770
+ return edge2;
1771
+ }
1772
+ function connect(edges, to) {
1773
+ edges.forEach((edge2) => edge2.to = to);
1774
+ }
1775
+ function compile(expr2, from) {
1776
+ if (expr2.type == "choice") {
1777
+ return expr2.exprs.reduce((out, expr3) => out.concat(compile(expr3, from)), []);
1778
+ } else if (expr2.type == "seq") {
1779
+ for (let i = 0; ; i++) {
1780
+ let next = compile(expr2.exprs[i], from);
1781
+ if (i == expr2.exprs.length - 1)
1782
+ return next;
1783
+ connect(next, from = node());
1570
1784
  }
1571
- else if (s.type == "star") {
1572
- let h = e();
1573
- return n(o, h), i(r(s.expr, h), h), [n(h)];
1574
- } else if (s.type == "plus") {
1575
- let h = e();
1576
- return i(r(s.expr, o), h), i(r(s.expr, h), h), [n(h)];
1577
- } else {
1578
- if (s.type == "opt")
1579
- return [n(o)].concat(r(s.expr, o));
1580
- if (s.type == "range") {
1581
- let h = o;
1582
- for (let a = 0; a < s.min; a++) {
1583
- let f = e();
1584
- i(r(s.expr, h), f), h = f;
1585
- }
1586
- if (s.max == -1)
1587
- i(r(s.expr, h), h);
1588
- else
1589
- for (let a = s.min; a < s.max; a++) {
1590
- let f = e();
1591
- n(h, f), i(r(s.expr, h), f), h = f;
1592
- }
1593
- return [n(h)];
1785
+ } else if (expr2.type == "star") {
1786
+ let loop = node();
1787
+ edge(from, loop);
1788
+ connect(compile(expr2.expr, loop), loop);
1789
+ return [edge(loop)];
1790
+ } else if (expr2.type == "plus") {
1791
+ let loop = node();
1792
+ connect(compile(expr2.expr, from), loop);
1793
+ connect(compile(expr2.expr, loop), loop);
1794
+ return [edge(loop)];
1795
+ } else if (expr2.type == "opt") {
1796
+ return [edge(from)].concat(compile(expr2.expr, from));
1797
+ } else if (expr2.type == "range") {
1798
+ let cur = from;
1799
+ for (let i = 0; i < expr2.min; i++) {
1800
+ let next = node();
1801
+ connect(compile(expr2.expr, cur), next);
1802
+ cur = next;
1803
+ }
1804
+ if (expr2.max == -1) {
1805
+ connect(compile(expr2.expr, cur), cur);
1594
1806
  } else {
1595
- if (s.type == "name")
1596
- return [n(o, void 0, s.value)];
1597
- throw new Error("Unknown expr type");
1807
+ for (let i = expr2.min; i < expr2.max; i++) {
1808
+ let next = node();
1809
+ edge(cur, next);
1810
+ connect(compile(expr2.expr, cur), next);
1811
+ cur = next;
1812
+ }
1598
1813
  }
1814
+ return [edge(cur)];
1815
+ } else if (expr2.type == "name") {
1816
+ return [edge(from, void 0, expr2.value)];
1817
+ } else {
1818
+ throw new Error("Unknown expr type");
1599
1819
  }
1600
1820
  }
1601
1821
  }
1602
- function st(l, t) {
1603
- return t - l;
1604
- }
1605
- function j(l, t) {
1606
- let e = [];
1607
- return n(t), e.sort(st);
1608
- function n(i) {
1609
- let r = l[i];
1610
- if (r.length == 1 && !r[0].term)
1611
- return n(r[0].to);
1612
- e.push(i);
1613
- for (let s = 0; s < r.length; s++) {
1614
- let { term: o, to: h } = r[s];
1615
- !o && e.indexOf(h) == -1 && n(h);
1822
+ function cmp(a, b) {
1823
+ return b - a;
1824
+ }
1825
+ function nullFrom(nfa2, node) {
1826
+ let result = [];
1827
+ scan(node);
1828
+ return result.sort(cmp);
1829
+ function scan(node2) {
1830
+ let edges = nfa2[node2];
1831
+ if (edges.length == 1 && !edges[0].term)
1832
+ return scan(edges[0].to);
1833
+ result.push(node2);
1834
+ for (let i = 0; i < edges.length; i++) {
1835
+ let { term, to } = edges[i];
1836
+ if (!term && result.indexOf(to) == -1)
1837
+ scan(to);
1616
1838
  }
1617
1839
  }
1618
1840
  }
1619
- function Mt(l) {
1620
- let t = /* @__PURE__ */ Object.create(null);
1621
- return e(j(l, 0));
1622
- function e(n) {
1623
- let i = [];
1624
- n.forEach((s) => {
1625
- l[s].forEach(({ term: o, to: h }) => {
1626
- if (!o)
1841
+ function dfa(nfa2) {
1842
+ let labeled = /* @__PURE__ */ Object.create(null);
1843
+ return explore(nullFrom(nfa2, 0));
1844
+ function explore(states) {
1845
+ let out = [];
1846
+ states.forEach((node) => {
1847
+ nfa2[node].forEach(({ term, to }) => {
1848
+ if (!term)
1627
1849
  return;
1628
- let a;
1629
- for (let f = 0; f < i.length; f++)
1630
- i[f][0] == o && (a = i[f][1]);
1631
- j(l, h).forEach((f) => {
1632
- a || i.push([o, a = []]), a.indexOf(f) == -1 && a.push(f);
1850
+ let set;
1851
+ for (let i = 0; i < out.length; i++)
1852
+ if (out[i][0] == term)
1853
+ set = out[i][1];
1854
+ nullFrom(nfa2, to).forEach((node2) => {
1855
+ if (!set)
1856
+ out.push([term, set = []]);
1857
+ if (set.indexOf(node2) == -1)
1858
+ set.push(node2);
1633
1859
  });
1634
1860
  });
1635
1861
  });
1636
- let r = t[n.join(",")] = new w(n.indexOf(l.length - 1) > -1);
1637
- for (let s = 0; s < i.length; s++) {
1638
- let o = i[s][1].sort(st);
1639
- r.next.push({ type: i[s][0], next: t[o.join(",")] || e(o) });
1862
+ let state = labeled[states.join(",")] = new ContentMatch(states.indexOf(nfa2.length - 1) > -1);
1863
+ for (let i = 0; i < out.length; i++) {
1864
+ let states2 = out[i][1].sort(cmp);
1865
+ state.next.push({ type: out[i][0], next: labeled[states2.join(",")] || explore(states2) });
1640
1866
  }
1641
- return r;
1642
- }
1643
- }
1644
- function At(l, t) {
1645
- for (let e = 0, n = [l]; e < n.length; e++) {
1646
- let i = n[e], r = !i.validEnd, s = [];
1647
- for (let o = 0; o < i.next.length; o++) {
1648
- let { type: h, next: a } = i.next[o];
1649
- s.push(h.name), r && !(h.isText || h.hasRequiredAttrs()) && (r = !1), n.indexOf(a) == -1 && n.push(a);
1867
+ return state;
1868
+ }
1869
+ }
1870
+ function checkForDeadEnds(match, stream) {
1871
+ for (let i = 0, work = [match]; i < work.length; i++) {
1872
+ let state = work[i], dead = !state.validEnd, nodes = [];
1873
+ for (let j = 0; j < state.next.length; j++) {
1874
+ let { type, next } = state.next[j];
1875
+ nodes.push(type.name);
1876
+ if (dead && !(type.isText || type.hasRequiredAttrs()))
1877
+ dead = false;
1878
+ if (work.indexOf(next) == -1)
1879
+ work.push(next);
1650
1880
  }
1651
- r && t.err("Only non-generatable nodes (" + s.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
1881
+ if (dead)
1882
+ stream.err("Only non-generatable nodes (" + nodes.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
1652
1883
  }
1653
1884
  }
1654
- function lt(l) {
1655
- let t = /* @__PURE__ */ Object.create(null);
1656
- for (let e in l) {
1657
- let n = l[e];
1658
- if (!n.hasDefault)
1885
+ function defaultAttrs(attrs) {
1886
+ let defaults = /* @__PURE__ */ Object.create(null);
1887
+ for (let attrName in attrs) {
1888
+ let attr = attrs[attrName];
1889
+ if (!attr.hasDefault)
1659
1890
  return null;
1660
- t[e] = n.default;
1661
- }
1662
- return t;
1663
- }
1664
- function ot(l, t) {
1665
- let e = /* @__PURE__ */ Object.create(null);
1666
- for (let n in l) {
1667
- let i = t && t[n];
1668
- if (i === void 0) {
1669
- let r = l[n];
1670
- if (r.hasDefault)
1671
- i = r.default;
1891
+ defaults[attrName] = attr.default;
1892
+ }
1893
+ return defaults;
1894
+ }
1895
+ function computeAttrs(attrs, value) {
1896
+ let built = /* @__PURE__ */ Object.create(null);
1897
+ for (let name in attrs) {
1898
+ let given = value && value[name];
1899
+ if (given === void 0) {
1900
+ let attr = attrs[name];
1901
+ if (attr.hasDefault)
1902
+ given = attr.default;
1672
1903
  else
1673
- throw new RangeError("No value supplied for attribute " + n);
1904
+ throw new RangeError("No value supplied for attribute " + name);
1674
1905
  }
1675
- e[n] = i;
1906
+ built[name] = given;
1676
1907
  }
1677
- return e;
1908
+ return built;
1678
1909
  }
1679
- function ht(l, t, e, n) {
1680
- for (let i in t)
1681
- if (!(i in l))
1682
- throw new RangeError(`Unsupported attribute ${i} for ${e} of type ${i}`);
1683
- for (let i in l) {
1684
- let r = l[i];
1685
- r.validate && r.validate(t[i]);
1910
+ function checkAttrs(attrs, values, type, name) {
1911
+ for (let name2 in values)
1912
+ if (!(name2 in attrs))
1913
+ throw new RangeError(`Unsupported attribute ${name2} for ${type} of type ${name2}`);
1914
+ for (let name2 in attrs) {
1915
+ let attr = attrs[name2];
1916
+ if (attr.validate)
1917
+ attr.validate(values[name2]);
1686
1918
  }
1687
1919
  }
1688
- function at(l, t) {
1689
- let e = /* @__PURE__ */ Object.create(null);
1690
- if (t)
1691
- for (let n in t)
1692
- e[n] = new zt(l, n, t[n]);
1693
- return e;
1920
+ function initAttrs(typeName, attrs) {
1921
+ let result = /* @__PURE__ */ Object.create(null);
1922
+ if (attrs)
1923
+ for (let name in attrs)
1924
+ result[name] = new Attribute(typeName, name, attrs[name]);
1925
+ return result;
1694
1926
  }
1695
- class z {
1927
+ class NodeType {
1696
1928
  /**
1697
1929
  @internal
1698
1930
  */
1699
- constructor(t, e, n) {
1700
- this.name = t, this.schema = e, this.spec = n, this.markSet = null, this.groups = n.group ? n.group.split(" ") : [], this.attrs = at(t, n.attrs), this.defaultAttrs = lt(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(n.inline || t == "text"), this.isText = t == "text";
1931
+ constructor(name, schema, spec) {
1932
+ this.name = name;
1933
+ this.schema = schema;
1934
+ this.spec = spec;
1935
+ this.markSet = null;
1936
+ this.groups = spec.group ? spec.group.split(" ") : [];
1937
+ this.attrs = initAttrs(name, spec.attrs);
1938
+ this.defaultAttrs = defaultAttrs(this.attrs);
1939
+ this.contentMatch = null;
1940
+ this.inlineContent = null;
1941
+ this.isBlock = !(spec.inline || name == "text");
1942
+ this.isText = name == "text";
1701
1943
  }
1702
1944
  /**
1703
1945
  True if this is an inline type.
@@ -1716,7 +1958,7 @@ class z {
1716
1958
  True for node types that allow no content.
1717
1959
  */
1718
1960
  get isLeaf() {
1719
- return this.contentMatch == w.empty;
1961
+ return this.contentMatch == ContentMatch.empty;
1720
1962
  }
1721
1963
  /**
1722
1964
  True when this node is an atom, i.e. when it does not have
@@ -1729,8 +1971,8 @@ class z {
1729
1971
  Return true when this node type is part of the given
1730
1972
  [group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
1731
1973
  */
1732
- isInGroup(t) {
1733
- return this.groups.indexOf(t) > -1;
1974
+ isInGroup(group) {
1975
+ return this.groups.indexOf(group) > -1;
1734
1976
  }
1735
1977
  /**
1736
1978
  The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
@@ -1742,23 +1984,26 @@ class z {
1742
1984
  Tells you whether this node type has any required attributes.
1743
1985
  */
1744
1986
  hasRequiredAttrs() {
1745
- for (let t in this.attrs)
1746
- if (this.attrs[t].isRequired)
1747
- return !0;
1748
- return !1;
1987
+ for (let n in this.attrs)
1988
+ if (this.attrs[n].isRequired)
1989
+ return true;
1990
+ return false;
1749
1991
  }
1750
1992
  /**
1751
1993
  Indicates whether this node allows some of the same content as
1752
1994
  the given node type.
1753
1995
  */
1754
- compatibleContent(t) {
1755
- return this == t || this.contentMatch.compatible(t.contentMatch);
1996
+ compatibleContent(other) {
1997
+ return this == other || this.contentMatch.compatible(other.contentMatch);
1756
1998
  }
1757
1999
  /**
1758
2000
  @internal
1759
2001
  */
1760
- computeAttrs(t) {
1761
- return !t && this.defaultAttrs ? this.defaultAttrs : ot(this.attrs, t);
2002
+ computeAttrs(attrs) {
2003
+ if (!attrs && this.defaultAttrs)
2004
+ return this.defaultAttrs;
2005
+ else
2006
+ return computeAttrs(this.attrs, attrs);
1762
2007
  }
1763
2008
  /**
1764
2009
  Create a `Node` of this type. The given attributes are
@@ -1768,18 +2013,20 @@ class z {
1768
2013
  `null`. Similarly `marks` may be `null` to default to the empty
1769
2014
  set of marks.
1770
2015
  */
1771
- create(t = null, e, n) {
2016
+ create(attrs = null, content, marks) {
1772
2017
  if (this.isText)
1773
2018
  throw new Error("NodeType.create can't construct text nodes");
1774
- return new y(this, this.computeAttrs(t), c.from(e), u.setFrom(n));
2019
+ return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks));
1775
2020
  }
1776
2021
  /**
1777
2022
  Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
1778
2023
  against the node type's content restrictions, and throw an error
1779
2024
  if it doesn't match.
1780
2025
  */
1781
- createChecked(t = null, e, n) {
1782
- return e = c.from(e), this.checkContent(e), new y(this, this.computeAttrs(t), e, u.setFrom(n));
2026
+ createChecked(attrs = null, content, marks) {
2027
+ content = Fragment.from(content);
2028
+ this.checkContent(content);
2029
+ return new Node(this, this.computeAttrs(attrs), content, Mark.setFrom(marks));
1783
2030
  }
1784
2031
  /**
1785
2032
  Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
@@ -1789,188 +2036,219 @@ class z {
1789
2036
  always be created, this will always succeed if you pass null or
1790
2037
  `Fragment.empty` as content.
1791
2038
  */
1792
- createAndFill(t = null, e, n) {
1793
- if (t = this.computeAttrs(t), e = c.from(e), e.size) {
1794
- let s = this.contentMatch.fillBefore(e);
1795
- if (!s)
2039
+ createAndFill(attrs = null, content, marks) {
2040
+ attrs = this.computeAttrs(attrs);
2041
+ content = Fragment.from(content);
2042
+ if (content.size) {
2043
+ let before = this.contentMatch.fillBefore(content);
2044
+ if (!before)
1796
2045
  return null;
1797
- e = s.append(e);
2046
+ content = before.append(content);
1798
2047
  }
1799
- let i = this.contentMatch.matchFragment(e), r = i && i.fillBefore(c.empty, !0);
1800
- return r ? new y(this, t, e.append(r), u.setFrom(n)) : null;
2048
+ let matched = this.contentMatch.matchFragment(content);
2049
+ let after = matched && matched.fillBefore(Fragment.empty, true);
2050
+ if (!after)
2051
+ return null;
2052
+ return new Node(this, attrs, content.append(after), Mark.setFrom(marks));
1801
2053
  }
1802
2054
  /**
1803
2055
  Returns true if the given fragment is valid content for this node
1804
2056
  type.
1805
2057
  */
1806
- validContent(t) {
1807
- let e = this.contentMatch.matchFragment(t);
1808
- if (!e || !e.validEnd)
1809
- return !1;
1810
- for (let n = 0; n < t.childCount; n++)
1811
- if (!this.allowsMarks(t.child(n).marks))
1812
- return !1;
1813
- return !0;
2058
+ validContent(content) {
2059
+ let result = this.contentMatch.matchFragment(content);
2060
+ if (!result || !result.validEnd)
2061
+ return false;
2062
+ for (let i = 0; i < content.childCount; i++)
2063
+ if (!this.allowsMarks(content.child(i).marks))
2064
+ return false;
2065
+ return true;
1814
2066
  }
1815
2067
  /**
1816
2068
  Throws a RangeError if the given fragment is not valid content for this
1817
2069
  node type.
1818
2070
  @internal
1819
2071
  */
1820
- checkContent(t) {
1821
- if (!this.validContent(t))
1822
- throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0, 50)}`);
2072
+ checkContent(content) {
2073
+ if (!this.validContent(content))
2074
+ throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
1823
2075
  }
1824
2076
  /**
1825
2077
  @internal
1826
2078
  */
1827
- checkAttrs(t) {
1828
- ht(this.attrs, t, "node", this.name);
2079
+ checkAttrs(attrs) {
2080
+ checkAttrs(this.attrs, attrs, "node", this.name);
1829
2081
  }
1830
2082
  /**
1831
2083
  Check whether the given mark type is allowed in this node.
1832
2084
  */
1833
- allowsMarkType(t) {
1834
- return this.markSet == null || this.markSet.indexOf(t) > -1;
2085
+ allowsMarkType(markType) {
2086
+ return this.markSet == null || this.markSet.indexOf(markType) > -1;
1835
2087
  }
1836
2088
  /**
1837
2089
  Test whether the given set of marks are allowed in this node.
1838
2090
  */
1839
- allowsMarks(t) {
2091
+ allowsMarks(marks) {
1840
2092
  if (this.markSet == null)
1841
- return !0;
1842
- for (let e = 0; e < t.length; e++)
1843
- if (!this.allowsMarkType(t[e].type))
1844
- return !1;
1845
- return !0;
2093
+ return true;
2094
+ for (let i = 0; i < marks.length; i++)
2095
+ if (!this.allowsMarkType(marks[i].type))
2096
+ return false;
2097
+ return true;
1846
2098
  }
1847
2099
  /**
1848
2100
  Removes the marks that are not allowed in this node from the given set.
1849
2101
  */
1850
- allowedMarks(t) {
2102
+ allowedMarks(marks) {
1851
2103
  if (this.markSet == null)
1852
- return t;
1853
- let e;
1854
- for (let n = 0; n < t.length; n++)
1855
- this.allowsMarkType(t[n].type) ? e && e.push(t[n]) : e || (e = t.slice(0, n));
1856
- return e ? e.length ? e : u.none : t;
2104
+ return marks;
2105
+ let copy2;
2106
+ for (let i = 0; i < marks.length; i++) {
2107
+ if (!this.allowsMarkType(marks[i].type)) {
2108
+ if (!copy2)
2109
+ copy2 = marks.slice(0, i);
2110
+ } else if (copy2) {
2111
+ copy2.push(marks[i]);
2112
+ }
2113
+ }
2114
+ return !copy2 ? marks : copy2.length ? copy2 : Mark.none;
1857
2115
  }
1858
2116
  /**
1859
2117
  @internal
1860
2118
  */
1861
- static compile(t, e) {
1862
- let n = /* @__PURE__ */ Object.create(null);
1863
- t.forEach((r, s) => n[r] = new z(r, e, s));
1864
- let i = e.spec.topNode || "doc";
1865
- if (!n[i])
1866
- throw new RangeError("Schema is missing its top node type ('" + i + "')");
1867
- if (!n.text)
2119
+ static compile(nodes, schema) {
2120
+ let result = /* @__PURE__ */ Object.create(null);
2121
+ nodes.forEach((name, spec) => result[name] = new NodeType(name, schema, spec));
2122
+ let topType = schema.spec.topNode || "doc";
2123
+ if (!result[topType])
2124
+ throw new RangeError("Schema is missing its top node type ('" + topType + "')");
2125
+ if (!result.text)
1868
2126
  throw new RangeError("Every schema needs a 'text' type");
1869
- for (let r in n.text.attrs)
2127
+ for (let _ in result.text.attrs)
1870
2128
  throw new RangeError("The text node type should not have attributes");
1871
- return n;
2129
+ return result;
1872
2130
  }
1873
2131
  }
1874
- function Nt(l, t, e) {
1875
- let n = e.split("|");
1876
- return (i) => {
1877
- let r = i === null ? "null" : typeof i;
1878
- if (n.indexOf(r) < 0)
1879
- throw new RangeError(`Expected value of type ${n} for attribute ${t} on type ${l}, got ${r}`);
2132
+ function validateType(typeName, attrName, type) {
2133
+ let types = type.split("|");
2134
+ return (value) => {
2135
+ let name = value === null ? "null" : typeof value;
2136
+ if (types.indexOf(name) < 0)
2137
+ throw new RangeError(`Expected value of type ${types} for attribute ${attrName} on type ${typeName}, got ${name}`);
1880
2138
  };
1881
2139
  }
1882
- class zt {
1883
- constructor(t, e, n) {
1884
- this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default"), this.default = n.default, this.validate = typeof n.validate == "string" ? Nt(t, e, n.validate) : n.validate;
2140
+ class Attribute {
2141
+ constructor(typeName, attrName, options) {
2142
+ this.hasDefault = Object.prototype.hasOwnProperty.call(options, "default");
2143
+ this.default = options.default;
2144
+ this.validate = typeof options.validate == "string" ? validateType(typeName, attrName, options.validate) : options.validate;
1885
2145
  }
1886
2146
  get isRequired() {
1887
2147
  return !this.hasDefault;
1888
2148
  }
1889
2149
  }
1890
- class F {
2150
+ class MarkType {
1891
2151
  /**
1892
2152
  @internal
1893
2153
  */
1894
- constructor(t, e, n, i) {
1895
- this.name = t, this.rank = e, this.schema = n, this.spec = i, this.attrs = at(t, i.attrs), this.excluded = null;
1896
- let r = lt(this.attrs);
1897
- this.instance = r ? new u(this, r) : null;
2154
+ constructor(name, rank, schema, spec) {
2155
+ this.name = name;
2156
+ this.rank = rank;
2157
+ this.schema = schema;
2158
+ this.spec = spec;
2159
+ this.attrs = initAttrs(name, spec.attrs);
2160
+ this.excluded = null;
2161
+ let defaults = defaultAttrs(this.attrs);
2162
+ this.instance = defaults ? new Mark(this, defaults) : null;
1898
2163
  }
1899
2164
  /**
1900
2165
  Create a mark of this type. `attrs` may be `null` or an object
1901
2166
  containing only some of the mark's attributes. The others, if
1902
2167
  they have defaults, will be added.
1903
2168
  */
1904
- create(t = null) {
1905
- return !t && this.instance ? this.instance : new u(this, ot(this.attrs, t));
2169
+ create(attrs = null) {
2170
+ if (!attrs && this.instance)
2171
+ return this.instance;
2172
+ return new Mark(this, computeAttrs(this.attrs, attrs));
1906
2173
  }
1907
2174
  /**
1908
2175
  @internal
1909
2176
  */
1910
- static compile(t, e) {
1911
- let n = /* @__PURE__ */ Object.create(null), i = 0;
1912
- return t.forEach((r, s) => n[r] = new F(r, i++, e, s)), n;
2177
+ static compile(marks, schema) {
2178
+ let result = /* @__PURE__ */ Object.create(null), rank = 0;
2179
+ marks.forEach((name, spec) => result[name] = new MarkType(name, rank++, schema, spec));
2180
+ return result;
1913
2181
  }
1914
2182
  /**
1915
2183
  When there is a mark of this type in the given set, a new set
1916
2184
  without it is returned. Otherwise, the input set is returned.
1917
2185
  */
1918
- removeFromSet(t) {
1919
- for (var e = 0; e < t.length; e++)
1920
- t[e].type == this && (t = t.slice(0, e).concat(t.slice(e + 1)), e--);
1921
- return t;
2186
+ removeFromSet(set) {
2187
+ for (var i = 0; i < set.length; i++)
2188
+ if (set[i].type == this) {
2189
+ set = set.slice(0, i).concat(set.slice(i + 1));
2190
+ i--;
2191
+ }
2192
+ return set;
1922
2193
  }
1923
2194
  /**
1924
2195
  Tests whether there is a mark of this type in the given set.
1925
2196
  */
1926
- isInSet(t) {
1927
- for (let e = 0; e < t.length; e++)
1928
- if (t[e].type == this)
1929
- return t[e];
2197
+ isInSet(set) {
2198
+ for (let i = 0; i < set.length; i++)
2199
+ if (set[i].type == this)
2200
+ return set[i];
1930
2201
  }
1931
2202
  /**
1932
2203
  @internal
1933
2204
  */
1934
- checkAttrs(t) {
1935
- ht(this.attrs, t, "mark", this.name);
2205
+ checkAttrs(attrs) {
2206
+ checkAttrs(this.attrs, attrs, "mark", this.name);
1936
2207
  }
1937
2208
  /**
1938
2209
  Queries whether a given mark type is
1939
2210
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
1940
2211
  */
1941
- excludes(t) {
1942
- return this.excluded.indexOf(t) > -1;
2212
+ excludes(other) {
2213
+ return this.excluded.indexOf(other) > -1;
1943
2214
  }
1944
2215
  }
1945
- class qt {
2216
+ class Schema {
1946
2217
  /**
1947
2218
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
1948
2219
  */
1949
- constructor(t) {
1950
- this.linebreakReplacement = null, this.cached = /* @__PURE__ */ Object.create(null);
1951
- let e = this.spec = {};
1952
- for (let i in t)
1953
- e[i] = t[i];
1954
- e.nodes = q.from(t.nodes), e.marks = q.from(t.marks || {}), this.nodes = z.compile(this.spec.nodes, this), this.marks = F.compile(this.spec.marks, this);
1955
- let n = /* @__PURE__ */ Object.create(null);
1956
- for (let i in this.nodes) {
1957
- if (i in this.marks)
1958
- throw new RangeError(i + " can not be both a node and a mark");
1959
- let r = this.nodes[i], s = r.spec.content || "", o = r.spec.marks;
1960
- if (r.contentMatch = n[s] || (n[s] = w.parse(s, this.nodes)), r.inlineContent = r.contentMatch.inlineContent, r.spec.linebreakReplacement) {
2220
+ constructor(spec) {
2221
+ this.linebreakReplacement = null;
2222
+ this.cached = /* @__PURE__ */ Object.create(null);
2223
+ let instanceSpec = this.spec = {};
2224
+ for (let prop in spec)
2225
+ instanceSpec[prop] = spec[prop];
2226
+ instanceSpec.nodes = OrderedMap.from(spec.nodes), instanceSpec.marks = OrderedMap.from(spec.marks || {}), this.nodes = NodeType.compile(this.spec.nodes, this);
2227
+ this.marks = MarkType.compile(this.spec.marks, this);
2228
+ let contentExprCache = /* @__PURE__ */ Object.create(null);
2229
+ for (let prop in this.nodes) {
2230
+ if (prop in this.marks)
2231
+ throw new RangeError(prop + " can not be both a node and a mark");
2232
+ let type = this.nodes[prop], contentExpr = type.spec.content || "", markExpr = type.spec.marks;
2233
+ type.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));
2234
+ type.inlineContent = type.contentMatch.inlineContent;
2235
+ if (type.spec.linebreakReplacement) {
1961
2236
  if (this.linebreakReplacement)
1962
2237
  throw new RangeError("Multiple linebreak nodes defined");
1963
- if (!r.isInline || !r.isLeaf)
2238
+ if (!type.isInline || !type.isLeaf)
1964
2239
  throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
1965
- this.linebreakReplacement = r;
2240
+ this.linebreakReplacement = type;
1966
2241
  }
1967
- r.markSet = o == "_" ? null : o ? U(this, o.split(" ")) : o == "" || !r.inlineContent ? [] : null;
2242
+ type.markSet = markExpr == "_" ? null : markExpr ? gatherMarks(this, markExpr.split(" ")) : markExpr == "" || !type.inlineContent ? [] : null;
1968
2243
  }
1969
- for (let i in this.marks) {
1970
- let r = this.marks[i], s = r.spec.excludes;
1971
- r.excluded = s == null ? [r] : s == "" ? [] : U(this, s.split(" "));
2244
+ for (let prop in this.marks) {
2245
+ let type = this.marks[prop], excl = type.spec.excludes;
2246
+ type.excluded = excl == null ? [type] : excl == "" ? [] : gatherMarks(this, excl.split(" "));
1972
2247
  }
1973
- this.nodeFromJSON = this.nodeFromJSON.bind(this), this.markFromJSON = this.markFromJSON.bind(this), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = /* @__PURE__ */ Object.create(null);
2248
+ this.nodeFromJSON = this.nodeFromJSON.bind(this);
2249
+ this.markFromJSON = this.markFromJSON.bind(this);
2250
+ this.topNodeType = this.nodes[this.spec.topNode || "doc"];
2251
+ this.cached.wrappings = /* @__PURE__ */ Object.create(null);
1974
2252
  }
1975
2253
  /**
1976
2254
  Create a node in this schema. The `type` may be a string or a
@@ -1978,103 +2256,114 @@ class qt {
1978
2256
  `content` may be a `Fragment`, `null`, a `Node`, or an array of
1979
2257
  nodes.
1980
2258
  */
1981
- node(t, e = null, n, i) {
1982
- if (typeof t == "string")
1983
- t = this.nodeType(t);
1984
- else if (t instanceof z) {
1985
- if (t.schema != this)
1986
- throw new RangeError("Node type from different schema used (" + t.name + ")");
1987
- } else throw new RangeError("Invalid node type: " + t);
1988
- return t.createChecked(e, n, i);
2259
+ node(type, attrs = null, content, marks) {
2260
+ if (typeof type == "string")
2261
+ type = this.nodeType(type);
2262
+ else if (!(type instanceof NodeType))
2263
+ throw new RangeError("Invalid node type: " + type);
2264
+ else if (type.schema != this)
2265
+ throw new RangeError("Node type from different schema used (" + type.name + ")");
2266
+ return type.createChecked(attrs, content, marks);
1989
2267
  }
1990
2268
  /**
1991
2269
  Create a text node in the schema. Empty text nodes are not
1992
2270
  allowed.
1993
2271
  */
1994
- text(t, e) {
1995
- let n = this.nodes.text;
1996
- return new N(n, n.defaultAttrs, t, u.setFrom(e));
2272
+ text(text, marks) {
2273
+ let type = this.nodes.text;
2274
+ return new TextNode(type, type.defaultAttrs, text, Mark.setFrom(marks));
1997
2275
  }
1998
2276
  /**
1999
2277
  Create a mark with the given type and attributes.
2000
2278
  */
2001
- mark(t, e) {
2002
- return typeof t == "string" && (t = this.marks[t]), t.create(e);
2279
+ mark(type, attrs) {
2280
+ if (typeof type == "string")
2281
+ type = this.marks[type];
2282
+ return type.create(attrs);
2003
2283
  }
2004
2284
  /**
2005
2285
  Deserialize a node from its JSON representation. This method is
2006
2286
  bound.
2007
2287
  */
2008
- nodeFromJSON(t) {
2009
- return y.fromJSON(this, t);
2288
+ nodeFromJSON(json) {
2289
+ return Node.fromJSON(this, json);
2010
2290
  }
2011
2291
  /**
2012
2292
  Deserialize a mark from its JSON representation. This method is
2013
2293
  bound.
2014
2294
  */
2015
- markFromJSON(t) {
2016
- return u.fromJSON(this, t);
2295
+ markFromJSON(json) {
2296
+ return Mark.fromJSON(this, json);
2017
2297
  }
2018
2298
  /**
2019
2299
  @internal
2020
2300
  */
2021
- nodeType(t) {
2022
- let e = this.nodes[t];
2023
- if (!e)
2024
- throw new RangeError("Unknown node type: " + t);
2025
- return e;
2301
+ nodeType(name) {
2302
+ let found2 = this.nodes[name];
2303
+ if (!found2)
2304
+ throw new RangeError("Unknown node type: " + name);
2305
+ return found2;
2026
2306
  }
2027
2307
  }
2028
- function U(l, t) {
2029
- let e = [];
2030
- for (let n = 0; n < t.length; n++) {
2031
- let i = t[n], r = l.marks[i], s = r;
2032
- if (r)
2033
- e.push(r);
2034
- else
2035
- for (let o in l.marks) {
2036
- let h = l.marks[o];
2037
- (i == "_" || h.spec.group && h.spec.group.split(" ").indexOf(i) > -1) && e.push(s = h);
2308
+ function gatherMarks(schema, marks) {
2309
+ let found2 = [];
2310
+ for (let i = 0; i < marks.length; i++) {
2311
+ let name = marks[i], mark = schema.marks[name], ok = mark;
2312
+ if (mark) {
2313
+ found2.push(mark);
2314
+ } else {
2315
+ for (let prop in schema.marks) {
2316
+ let mark2 = schema.marks[prop];
2317
+ if (name == "_" || mark2.spec.group && mark2.spec.group.split(" ").indexOf(name) > -1)
2318
+ found2.push(ok = mark2);
2038
2319
  }
2039
- if (!s)
2040
- throw new SyntaxError("Unknown mark type: '" + t[n] + "'");
2320
+ }
2321
+ if (!ok)
2322
+ throw new SyntaxError("Unknown mark type: '" + marks[i] + "'");
2041
2323
  }
2042
- return e;
2324
+ return found2;
2043
2325
  }
2044
- function vt(l) {
2045
- return l.tag != null;
2326
+ function isTagRule(rule) {
2327
+ return rule.tag != null;
2046
2328
  }
2047
- function Rt(l) {
2048
- return l.style != null;
2329
+ function isStyleRule(rule) {
2330
+ return rule.style != null;
2049
2331
  }
2050
- class P {
2332
+ class DOMParser {
2051
2333
  /**
2052
2334
  Create a parser that targets the given schema, using the given
2053
2335
  parsing rules.
2054
2336
  */
2055
- constructor(t, e) {
2056
- this.schema = t, this.rules = e, this.tags = [], this.styles = [];
2057
- let n = this.matchedStyles = [];
2058
- e.forEach((i) => {
2059
- if (vt(i))
2060
- this.tags.push(i);
2061
- else if (Rt(i)) {
2062
- let r = /[^=]*/.exec(i.style)[0];
2063
- n.indexOf(r) < 0 && n.push(r), this.styles.push(i);
2337
+ constructor(schema, rules) {
2338
+ this.schema = schema;
2339
+ this.rules = rules;
2340
+ this.tags = [];
2341
+ this.styles = [];
2342
+ let matchedStyles = this.matchedStyles = [];
2343
+ rules.forEach((rule) => {
2344
+ if (isTagRule(rule)) {
2345
+ this.tags.push(rule);
2346
+ } else if (isStyleRule(rule)) {
2347
+ let prop = /[^=]*/.exec(rule.style)[0];
2348
+ if (matchedStyles.indexOf(prop) < 0)
2349
+ matchedStyles.push(prop);
2350
+ this.styles.push(rule);
2064
2351
  }
2065
- }), this.normalizeLists = !this.tags.some((i) => {
2066
- if (!/^(ul|ol)\b/.test(i.tag) || !i.node)
2067
- return !1;
2068
- let r = t.nodes[i.node];
2069
- return r.contentMatch.matchType(r);
2352
+ });
2353
+ this.normalizeLists = !this.tags.some((r) => {
2354
+ if (!/^(ul|ol)\b/.test(r.tag) || !r.node)
2355
+ return false;
2356
+ let node = schema.nodes[r.node];
2357
+ return node.contentMatch.matchType(node);
2070
2358
  });
2071
2359
  }
2072
2360
  /**
2073
2361
  Parse a document from the content of a DOM node.
2074
2362
  */
2075
- parse(t, e = {}) {
2076
- let n = new G(this, e, !1);
2077
- return n.addAll(t, u.none, e.from, e.to), n.finish();
2363
+ parse(dom, options = {}) {
2364
+ let context = new ParseContext(this, options, false);
2365
+ context.addAll(dom, Mark.none, options.from, options.to);
2366
+ return context.finish();
2078
2367
  }
2079
2368
  /**
2080
2369
  Parses the content of the given DOM node, like
@@ -2084,166 +2373,212 @@ class P {
2084
2373
  the schema constraints aren't applied to the start of nodes to
2085
2374
  the left of the input and the end of nodes at the end.
2086
2375
  */
2087
- parseSlice(t, e = {}) {
2088
- let n = new G(this, e, !0);
2089
- return n.addAll(t, u.none, e.from, e.to), d.maxOpen(n.finish());
2376
+ parseSlice(dom, options = {}) {
2377
+ let context = new ParseContext(this, options, true);
2378
+ context.addAll(dom, Mark.none, options.from, options.to);
2379
+ return Slice.maxOpen(context.finish());
2090
2380
  }
2091
2381
  /**
2092
2382
  @internal
2093
2383
  */
2094
- matchTag(t, e, n) {
2095
- for (let i = n ? this.tags.indexOf(n) + 1 : 0; i < this.tags.length; i++) {
2096
- let r = this.tags[i];
2097
- if (Pt(t, r.tag) && (r.namespace === void 0 || t.namespaceURI == r.namespace) && (!r.context || e.matchesContext(r.context))) {
2098
- if (r.getAttrs) {
2099
- let s = r.getAttrs(t);
2100
- if (s === !1)
2384
+ matchTag(dom, context, after) {
2385
+ for (let i = after ? this.tags.indexOf(after) + 1 : 0; i < this.tags.length; i++) {
2386
+ let rule = this.tags[i];
2387
+ if (matches(dom, rule.tag) && (rule.namespace === void 0 || dom.namespaceURI == rule.namespace) && (!rule.context || context.matchesContext(rule.context))) {
2388
+ if (rule.getAttrs) {
2389
+ let result = rule.getAttrs(dom);
2390
+ if (result === false)
2101
2391
  continue;
2102
- r.attrs = s || void 0;
2392
+ rule.attrs = result || void 0;
2103
2393
  }
2104
- return r;
2394
+ return rule;
2105
2395
  }
2106
2396
  }
2107
2397
  }
2108
2398
  /**
2109
2399
  @internal
2110
2400
  */
2111
- matchStyle(t, e, n, i) {
2112
- for (let r = i ? this.styles.indexOf(i) + 1 : 0; r < this.styles.length; r++) {
2113
- let s = this.styles[r], o = s.style;
2114
- if (!(o.indexOf(t) != 0 || s.context && !n.matchesContext(s.context) || // Test that the style string either precisely matches the prop,
2401
+ matchStyle(prop, value, context, after) {
2402
+ for (let i = after ? this.styles.indexOf(after) + 1 : 0; i < this.styles.length; i++) {
2403
+ let rule = this.styles[i], style = rule.style;
2404
+ if (style.indexOf(prop) != 0 || rule.context && !context.matchesContext(rule.context) || // Test that the style string either precisely matches the prop,
2115
2405
  // or has an '=' sign after the prop, followed by the given
2116
2406
  // value.
2117
- o.length > t.length && (o.charCodeAt(t.length) != 61 || o.slice(t.length + 1) != e))) {
2118
- if (s.getAttrs) {
2119
- let h = s.getAttrs(e);
2120
- if (h === !1)
2121
- continue;
2122
- s.attrs = h || void 0;
2123
- }
2124
- return s;
2407
+ style.length > prop.length && (style.charCodeAt(prop.length) != 61 || style.slice(prop.length + 1) != value))
2408
+ continue;
2409
+ if (rule.getAttrs) {
2410
+ let result = rule.getAttrs(value);
2411
+ if (result === false)
2412
+ continue;
2413
+ rule.attrs = result || void 0;
2125
2414
  }
2415
+ return rule;
2126
2416
  }
2127
2417
  }
2128
2418
  /**
2129
2419
  @internal
2130
2420
  */
2131
- static schemaRules(t) {
2132
- let e = [];
2133
- function n(i) {
2134
- let r = i.priority == null ? 50 : i.priority, s = 0;
2135
- for (; s < e.length; s++) {
2136
- let o = e[s];
2137
- if ((o.priority == null ? 50 : o.priority) < r)
2421
+ static schemaRules(schema) {
2422
+ let result = [];
2423
+ function insert(rule) {
2424
+ let priority = rule.priority == null ? 50 : rule.priority, i = 0;
2425
+ for (; i < result.length; i++) {
2426
+ let next = result[i], nextPriority = next.priority == null ? 50 : next.priority;
2427
+ if (nextPriority < priority)
2138
2428
  break;
2139
2429
  }
2140
- e.splice(s, 0, i);
2430
+ result.splice(i, 0, rule);
2141
2431
  }
2142
- for (let i in t.marks) {
2143
- let r = t.marks[i].spec.parseDOM;
2144
- r && r.forEach((s) => {
2145
- n(s = H(s)), s.mark || s.ignore || s.clearMark || (s.mark = i);
2146
- });
2432
+ for (let name in schema.marks) {
2433
+ let rules = schema.marks[name].spec.parseDOM;
2434
+ if (rules)
2435
+ rules.forEach((rule) => {
2436
+ insert(rule = copy(rule));
2437
+ if (!(rule.mark || rule.ignore || rule.clearMark))
2438
+ rule.mark = name;
2439
+ });
2147
2440
  }
2148
- for (let i in t.nodes) {
2149
- let r = t.nodes[i].spec.parseDOM;
2150
- r && r.forEach((s) => {
2151
- n(s = H(s)), s.node || s.ignore || s.mark || (s.node = i);
2152
- });
2441
+ for (let name in schema.nodes) {
2442
+ let rules = schema.nodes[name].spec.parseDOM;
2443
+ if (rules)
2444
+ rules.forEach((rule) => {
2445
+ insert(rule = copy(rule));
2446
+ if (!(rule.node || rule.ignore || rule.mark))
2447
+ rule.node = name;
2448
+ });
2153
2449
  }
2154
- return e;
2450
+ return result;
2155
2451
  }
2156
2452
  /**
2157
2453
  Construct a DOM parser using the parsing rules listed in a
2158
2454
  schema's [node specs](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM), reordered by
2159
2455
  [priority](https://prosemirror.net/docs/ref/#model.ParseRule.priority).
2160
2456
  */
2161
- static fromSchema(t) {
2162
- return t.cached.domParser || (t.cached.domParser = new P(t, P.schemaRules(t)));
2163
- }
2164
- }
2165
- const ft = {
2166
- address: !0,
2167
- article: !0,
2168
- aside: !0,
2169
- blockquote: !0,
2170
- canvas: !0,
2171
- dd: !0,
2172
- div: !0,
2173
- dl: !0,
2174
- fieldset: !0,
2175
- figcaption: !0,
2176
- figure: !0,
2177
- footer: !0,
2178
- form: !0,
2179
- h1: !0,
2180
- h2: !0,
2181
- h3: !0,
2182
- h4: !0,
2183
- h5: !0,
2184
- h6: !0,
2185
- header: !0,
2186
- hgroup: !0,
2187
- hr: !0,
2188
- li: !0,
2189
- noscript: !0,
2190
- ol: !0,
2191
- output: !0,
2192
- p: !0,
2193
- pre: !0,
2194
- section: !0,
2195
- table: !0,
2196
- tfoot: !0,
2197
- ul: !0
2198
- }, It = {
2199
- head: !0,
2200
- noscript: !0,
2201
- object: !0,
2202
- script: !0,
2203
- style: !0,
2204
- title: !0
2205
- }, ct = { ol: !0, ul: !0 }, E = 1, B = 2, b = 4;
2206
- function V(l, t, e) {
2207
- return t != null ? (t ? E : 0) | (t === "full" ? B : 0) : l && l.whitespace == "pre" ? E | B : e & -5;
2208
- }
2209
- class C {
2210
- constructor(t, e, n, i, r, s) {
2211
- this.type = t, this.attrs = e, this.marks = n, this.solid = i, this.options = s, this.content = [], this.activeMarks = u.none, this.match = r || (s & b ? null : t.contentMatch);
2212
- }
2213
- findWrapping(t) {
2457
+ static fromSchema(schema) {
2458
+ return schema.cached.domParser || (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));
2459
+ }
2460
+ }
2461
+ const blockTags = {
2462
+ address: true,
2463
+ article: true,
2464
+ aside: true,
2465
+ blockquote: true,
2466
+ canvas: true,
2467
+ dd: true,
2468
+ div: true,
2469
+ dl: true,
2470
+ fieldset: true,
2471
+ figcaption: true,
2472
+ figure: true,
2473
+ footer: true,
2474
+ form: true,
2475
+ h1: true,
2476
+ h2: true,
2477
+ h3: true,
2478
+ h4: true,
2479
+ h5: true,
2480
+ h6: true,
2481
+ header: true,
2482
+ hgroup: true,
2483
+ hr: true,
2484
+ li: true,
2485
+ noscript: true,
2486
+ ol: true,
2487
+ output: true,
2488
+ p: true,
2489
+ pre: true,
2490
+ section: true,
2491
+ table: true,
2492
+ tfoot: true,
2493
+ ul: true
2494
+ };
2495
+ const ignoreTags = {
2496
+ head: true,
2497
+ noscript: true,
2498
+ object: true,
2499
+ script: true,
2500
+ style: true,
2501
+ title: true
2502
+ };
2503
+ const listTags = { ol: true, ul: true };
2504
+ const OPT_PRESERVE_WS = 1, OPT_PRESERVE_WS_FULL = 2, OPT_OPEN_LEFT = 4;
2505
+ function wsOptionsFor(type, preserveWhitespace, base) {
2506
+ if (preserveWhitespace != null)
2507
+ return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0);
2508
+ return type && type.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & -5;
2509
+ }
2510
+ class NodeContext {
2511
+ constructor(type, attrs, marks, solid, match, options) {
2512
+ this.type = type;
2513
+ this.attrs = attrs;
2514
+ this.marks = marks;
2515
+ this.solid = solid;
2516
+ this.options = options;
2517
+ this.content = [];
2518
+ this.activeMarks = Mark.none;
2519
+ this.match = match || (options & OPT_OPEN_LEFT ? null : type.contentMatch);
2520
+ }
2521
+ findWrapping(node) {
2214
2522
  if (!this.match) {
2215
2523
  if (!this.type)
2216
2524
  return [];
2217
- let e = this.type.contentMatch.fillBefore(c.from(t));
2218
- if (e)
2219
- this.match = this.type.contentMatch.matchFragment(e);
2220
- else {
2221
- let n = this.type.contentMatch, i;
2222
- return (i = n.findWrapping(t.type)) ? (this.match = n, i) : null;
2525
+ let fill = this.type.contentMatch.fillBefore(Fragment.from(node));
2526
+ if (fill) {
2527
+ this.match = this.type.contentMatch.matchFragment(fill);
2528
+ } else {
2529
+ let start = this.type.contentMatch, wrap;
2530
+ if (wrap = start.findWrapping(node.type)) {
2531
+ this.match = start;
2532
+ return wrap;
2533
+ } else {
2534
+ return null;
2535
+ }
2223
2536
  }
2224
2537
  }
2225
- return this.match.findWrapping(t.type);
2226
- }
2227
- finish(t) {
2228
- if (!(this.options & E)) {
2229
- let n = this.content[this.content.length - 1], i;
2230
- if (n && n.isText && (i = /[ \t\r\n\u000c]+$/.exec(n.text))) {
2231
- let r = n;
2232
- n.text.length == i[0].length ? this.content.pop() : this.content[this.content.length - 1] = r.withText(r.text.slice(0, r.text.length - i[0].length));
2538
+ return this.match.findWrapping(node.type);
2539
+ }
2540
+ finish(openEnd) {
2541
+ if (!(this.options & OPT_PRESERVE_WS)) {
2542
+ let last = this.content[this.content.length - 1], m;
2543
+ if (last && last.isText && (m = /[ \t\r\n\u000c]+$/.exec(last.text))) {
2544
+ let text = last;
2545
+ if (last.text.length == m[0].length)
2546
+ this.content.pop();
2547
+ else
2548
+ this.content[this.content.length - 1] = text.withText(text.text.slice(0, text.text.length - m[0].length));
2233
2549
  }
2234
2550
  }
2235
- let e = c.from(this.content);
2236
- return !t && this.match && (e = e.append(this.match.fillBefore(c.empty, !0))), this.type ? this.type.create(this.attrs, e, this.marks) : e;
2237
- }
2238
- inlineContext(t) {
2239
- return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : t.parentNode && !ft.hasOwnProperty(t.parentNode.nodeName.toLowerCase());
2240
- }
2241
- }
2242
- class G {
2243
- constructor(t, e, n) {
2244
- this.parser = t, this.options = e, this.isOpen = n, this.open = 0, this.localPreserveWS = !1;
2245
- let i = e.topNode, r, s = V(null, e.preserveWhitespace, 0) | (n ? b : 0);
2246
- i ? r = new C(i.type, i.attrs, u.none, !0, e.topMatch || i.type.contentMatch, s) : n ? r = new C(null, null, u.none, !0, null, s) : r = new C(t.schema.topNodeType, null, u.none, !0, null, s), this.nodes = [r], this.find = e.findPositions, this.needsBlock = !1;
2551
+ let content = Fragment.from(this.content);
2552
+ if (!openEnd && this.match)
2553
+ content = content.append(this.match.fillBefore(Fragment.empty, true));
2554
+ return this.type ? this.type.create(this.attrs, content, this.marks) : content;
2555
+ }
2556
+ inlineContext(node) {
2557
+ if (this.type)
2558
+ return this.type.inlineContent;
2559
+ if (this.content.length)
2560
+ return this.content[0].isInline;
2561
+ return node.parentNode && !blockTags.hasOwnProperty(node.parentNode.nodeName.toLowerCase());
2562
+ }
2563
+ }
2564
+ class ParseContext {
2565
+ constructor(parser, options, isOpen) {
2566
+ this.parser = parser;
2567
+ this.options = options;
2568
+ this.isOpen = isOpen;
2569
+ this.open = 0;
2570
+ this.localPreserveWS = false;
2571
+ let topNode = options.topNode, topContext;
2572
+ let topOptions = wsOptionsFor(null, options.preserveWhitespace, 0) | (isOpen ? OPT_OPEN_LEFT : 0);
2573
+ if (topNode)
2574
+ topContext = new NodeContext(topNode.type, topNode.attrs, Mark.none, true, options.topMatch || topNode.type.contentMatch, topOptions);
2575
+ else if (isOpen)
2576
+ topContext = new NodeContext(null, null, Mark.none, true, null, topOptions);
2577
+ else
2578
+ topContext = new NodeContext(parser.schema.topNodeType, null, Mark.none, true, null, topOptions);
2579
+ this.nodes = [topContext];
2580
+ this.find = options.findPositions;
2581
+ this.needsBlock = false;
2247
2582
  }
2248
2583
  get top() {
2249
2584
  return this.nodes[this.open];
@@ -2251,302 +2586,404 @@ class G {
2251
2586
  // Add a DOM node to the content. Text is inserted as text node,
2252
2587
  // otherwise, the node is passed to `addElement` or, if it has a
2253
2588
  // `style` attribute, `addElementWithStyles`.
2254
- addDOM(t, e) {
2255
- t.nodeType == 3 ? this.addTextNode(t, e) : t.nodeType == 1 && this.addElement(t, e);
2256
- }
2257
- addTextNode(t, e) {
2258
- let n = t.nodeValue, i = this.top, r = i.options & B ? "full" : this.localPreserveWS || (i.options & E) > 0;
2259
- if (r === "full" || i.inlineContext(t) || /[^ \t\r\n\u000c]/.test(n)) {
2260
- if (r)
2261
- r !== "full" ? n = n.replace(/\r?\n|\r/g, " ") : n = n.replace(/\r\n?/g, `
2262
- `);
2263
- else if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
2264
- let s = i.content[i.content.length - 1], o = t.previousSibling;
2265
- (!s || o && o.nodeName == "BR" || s.isText && /[ \t\r\n\u000c]$/.test(s.text)) && (n = n.slice(1));
2589
+ addDOM(dom, marks) {
2590
+ if (dom.nodeType == 3)
2591
+ this.addTextNode(dom, marks);
2592
+ else if (dom.nodeType == 1)
2593
+ this.addElement(dom, marks);
2594
+ }
2595
+ addTextNode(dom, marks) {
2596
+ let value = dom.nodeValue;
2597
+ let top = this.top, preserveWS = top.options & OPT_PRESERVE_WS_FULL ? "full" : this.localPreserveWS || (top.options & OPT_PRESERVE_WS) > 0;
2598
+ if (preserveWS === "full" || top.inlineContext(dom) || /[^ \t\r\n\u000c]/.test(value)) {
2599
+ if (!preserveWS) {
2600
+ value = value.replace(/[ \t\r\n\u000c]+/g, " ");
2601
+ if (/^[ \t\r\n\u000c]/.test(value) && this.open == this.nodes.length - 1) {
2602
+ let nodeBefore = top.content[top.content.length - 1];
2603
+ let domNodeBefore = dom.previousSibling;
2604
+ if (!nodeBefore || domNodeBefore && domNodeBefore.nodeName == "BR" || nodeBefore.isText && /[ \t\r\n\u000c]$/.test(nodeBefore.text))
2605
+ value = value.slice(1);
2606
+ }
2607
+ } else if (preserveWS !== "full") {
2608
+ value = value.replace(/\r?\n|\r/g, " ");
2609
+ } else {
2610
+ value = value.replace(/\r\n?/g, "\n");
2266
2611
  }
2267
- n && this.insertNode(this.parser.schema.text(n), e, !/\S/.test(n)), this.findInText(t);
2268
- } else
2269
- this.findInside(t);
2612
+ if (value)
2613
+ this.insertNode(this.parser.schema.text(value), marks, !/\S/.test(value));
2614
+ this.findInText(dom);
2615
+ } else {
2616
+ this.findInside(dom);
2617
+ }
2270
2618
  }
2271
2619
  // Try to find a handler for the given tag and use that to parse. If
2272
2620
  // none is found, the element's content nodes are added directly.
2273
- addElement(t, e, n) {
2274
- let i = this.localPreserveWS, r = this.top;
2275
- (t.tagName == "PRE" || /pre/.test(t.style && t.style.whiteSpace)) && (this.localPreserveWS = !0);
2276
- let s = t.nodeName.toLowerCase(), o;
2277
- ct.hasOwnProperty(s) && this.parser.normalizeLists && Dt(t);
2278
- let h = this.options.ruleFromNode && this.options.ruleFromNode(t) || (o = this.parser.matchTag(t, this, n));
2279
- t: if (h ? h.ignore : It.hasOwnProperty(s))
2280
- this.findInside(t), this.ignoreFallback(t, e);
2281
- else if (!h || h.skip || h.closeParent) {
2282
- h && h.closeParent ? this.open = Math.max(0, this.open - 1) : h && h.skip.nodeType && (t = h.skip);
2283
- let a, f = this.needsBlock;
2284
- if (ft.hasOwnProperty(s))
2285
- r.content.length && r.content[0].isInline && this.open && (this.open--, r = this.top), a = !0, r.type || (this.needsBlock = !0);
2286
- else if (!t.firstChild) {
2287
- this.leafFallback(t, e);
2288
- break t;
2621
+ addElement(dom, marks, matchAfter) {
2622
+ let outerWS = this.localPreserveWS, top = this.top;
2623
+ if (dom.tagName == "PRE" || /pre/.test(dom.style && dom.style.whiteSpace))
2624
+ this.localPreserveWS = true;
2625
+ let name = dom.nodeName.toLowerCase(), ruleID;
2626
+ if (listTags.hasOwnProperty(name) && this.parser.normalizeLists)
2627
+ normalizeList(dom);
2628
+ let rule = this.options.ruleFromNode && this.options.ruleFromNode(dom) || (ruleID = this.parser.matchTag(dom, this, matchAfter));
2629
+ out: if (rule ? rule.ignore : ignoreTags.hasOwnProperty(name)) {
2630
+ this.findInside(dom);
2631
+ this.ignoreFallback(dom, marks);
2632
+ } else if (!rule || rule.skip || rule.closeParent) {
2633
+ if (rule && rule.closeParent)
2634
+ this.open = Math.max(0, this.open - 1);
2635
+ else if (rule && rule.skip.nodeType)
2636
+ dom = rule.skip;
2637
+ let sync, oldNeedsBlock = this.needsBlock;
2638
+ if (blockTags.hasOwnProperty(name)) {
2639
+ if (top.content.length && top.content[0].isInline && this.open) {
2640
+ this.open--;
2641
+ top = this.top;
2642
+ }
2643
+ sync = true;
2644
+ if (!top.type)
2645
+ this.needsBlock = true;
2646
+ } else if (!dom.firstChild) {
2647
+ this.leafFallback(dom, marks);
2648
+ break out;
2289
2649
  }
2290
- let p = h && h.skip ? e : this.readStyles(t, e);
2291
- p && this.addAll(t, p), a && this.sync(r), this.needsBlock = f;
2650
+ let innerMarks = rule && rule.skip ? marks : this.readStyles(dom, marks);
2651
+ if (innerMarks)
2652
+ this.addAll(dom, innerMarks);
2653
+ if (sync)
2654
+ this.sync(top);
2655
+ this.needsBlock = oldNeedsBlock;
2292
2656
  } else {
2293
- let a = this.readStyles(t, e);
2294
- a && this.addElementByRule(t, h, a, h.consuming === !1 ? o : void 0);
2657
+ let innerMarks = this.readStyles(dom, marks);
2658
+ if (innerMarks)
2659
+ this.addElementByRule(dom, rule, innerMarks, rule.consuming === false ? ruleID : void 0);
2295
2660
  }
2296
- this.localPreserveWS = i;
2661
+ this.localPreserveWS = outerWS;
2297
2662
  }
2298
2663
  // Called for leaf DOM nodes that would otherwise be ignored
2299
- leafFallback(t, e) {
2300
- t.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(t.ownerDocument.createTextNode(`
2301
- `), e);
2664
+ leafFallback(dom, marks) {
2665
+ if (dom.nodeName == "BR" && this.top.type && this.top.type.inlineContent)
2666
+ this.addTextNode(dom.ownerDocument.createTextNode("\n"), marks);
2302
2667
  }
2303
2668
  // Called for ignored nodes
2304
- ignoreFallback(t, e) {
2305
- t.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), e, !0);
2669
+ ignoreFallback(dom, marks) {
2670
+ if (dom.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent))
2671
+ this.findPlace(this.parser.schema.text("-"), marks, true);
2306
2672
  }
2307
2673
  // Run any style parser associated with the node's styles. Either
2308
2674
  // return an updated array of marks, or null to indicate some of the
2309
2675
  // styles had a rule with `ignore` set.
2310
- readStyles(t, e) {
2311
- let n = t.style;
2312
- if (n && n.length)
2676
+ readStyles(dom, marks) {
2677
+ let styles = dom.style;
2678
+ if (styles && styles.length)
2313
2679
  for (let i = 0; i < this.parser.matchedStyles.length; i++) {
2314
- let r = this.parser.matchedStyles[i], s = n.getPropertyValue(r);
2315
- if (s)
2316
- for (let o = void 0; ; ) {
2317
- let h = this.parser.matchStyle(r, s, this, o);
2318
- if (!h)
2680
+ let name = this.parser.matchedStyles[i], value = styles.getPropertyValue(name);
2681
+ if (value)
2682
+ for (let after = void 0; ; ) {
2683
+ let rule = this.parser.matchStyle(name, value, this, after);
2684
+ if (!rule)
2319
2685
  break;
2320
- if (h.ignore)
2686
+ if (rule.ignore)
2321
2687
  return null;
2322
- if (h.clearMark ? e = e.filter((a) => !h.clearMark(a)) : e = e.concat(this.parser.schema.marks[h.mark].create(h.attrs)), h.consuming === !1)
2323
- o = h;
2688
+ if (rule.clearMark)
2689
+ marks = marks.filter((m) => !rule.clearMark(m));
2690
+ else
2691
+ marks = marks.concat(this.parser.schema.marks[rule.mark].create(rule.attrs));
2692
+ if (rule.consuming === false)
2693
+ after = rule;
2324
2694
  else
2325
2695
  break;
2326
2696
  }
2327
2697
  }
2328
- return e;
2698
+ return marks;
2329
2699
  }
2330
2700
  // Look up a handler for the given node. If none are found, return
2331
2701
  // false. Otherwise, apply it, use its return value to drive the way
2332
2702
  // the node's content is wrapped, and return true.
2333
- addElementByRule(t, e, n, i) {
2334
- let r, s;
2335
- if (e.node)
2336
- if (s = this.parser.schema.nodes[e.node], s.isLeaf)
2337
- this.insertNode(s.create(e.attrs), n, t.nodeName == "BR") || this.leafFallback(t, n);
2338
- else {
2339
- let h = this.enter(s, e.attrs || null, n, e.preserveWhitespace);
2340
- h && (r = !0, n = h);
2703
+ addElementByRule(dom, rule, marks, continueAfter) {
2704
+ let sync, nodeType;
2705
+ if (rule.node) {
2706
+ nodeType = this.parser.schema.nodes[rule.node];
2707
+ if (!nodeType.isLeaf) {
2708
+ let inner = this.enter(nodeType, rule.attrs || null, marks, rule.preserveWhitespace);
2709
+ if (inner) {
2710
+ sync = true;
2711
+ marks = inner;
2712
+ }
2713
+ } else if (!this.insertNode(nodeType.create(rule.attrs), marks, dom.nodeName == "BR")) {
2714
+ this.leafFallback(dom, marks);
2341
2715
  }
2342
- else {
2343
- let h = this.parser.schema.marks[e.mark];
2344
- n = n.concat(h.create(e.attrs));
2716
+ } else {
2717
+ let markType = this.parser.schema.marks[rule.mark];
2718
+ marks = marks.concat(markType.create(rule.attrs));
2345
2719
  }
2346
- let o = this.top;
2347
- if (s && s.isLeaf)
2348
- this.findInside(t);
2349
- else if (i)
2350
- this.addElement(t, n, i);
2351
- else if (e.getContent)
2352
- this.findInside(t), e.getContent(t, this.parser.schema).forEach((h) => this.insertNode(h, n, !1));
2353
- else {
2354
- let h = t;
2355
- typeof e.contentElement == "string" ? h = t.querySelector(e.contentElement) : typeof e.contentElement == "function" ? h = e.contentElement(t) : e.contentElement && (h = e.contentElement), this.findAround(t, h, !0), this.addAll(h, n), this.findAround(t, h, !1);
2720
+ let startIn = this.top;
2721
+ if (nodeType && nodeType.isLeaf) {
2722
+ this.findInside(dom);
2723
+ } else if (continueAfter) {
2724
+ this.addElement(dom, marks, continueAfter);
2725
+ } else if (rule.getContent) {
2726
+ this.findInside(dom);
2727
+ rule.getContent(dom, this.parser.schema).forEach((node) => this.insertNode(node, marks, false));
2728
+ } else {
2729
+ let contentDOM = dom;
2730
+ if (typeof rule.contentElement == "string")
2731
+ contentDOM = dom.querySelector(rule.contentElement);
2732
+ else if (typeof rule.contentElement == "function")
2733
+ contentDOM = rule.contentElement(dom);
2734
+ else if (rule.contentElement)
2735
+ contentDOM = rule.contentElement;
2736
+ this.findAround(dom, contentDOM, true);
2737
+ this.addAll(contentDOM, marks);
2738
+ this.findAround(dom, contentDOM, false);
2356
2739
  }
2357
- r && this.sync(o) && this.open--;
2740
+ if (sync && this.sync(startIn))
2741
+ this.open--;
2358
2742
  }
2359
2743
  // Add all child nodes between `startIndex` and `endIndex` (or the
2360
2744
  // whole node, if not given). If `sync` is passed, use it to
2361
2745
  // synchronize after every block element.
2362
- addAll(t, e, n, i) {
2363
- let r = n || 0;
2364
- for (let s = n ? t.childNodes[n] : t.firstChild, o = i == null ? null : t.childNodes[i]; s != o; s = s.nextSibling, ++r)
2365
- this.findAtPoint(t, r), this.addDOM(s, e);
2366
- this.findAtPoint(t, r);
2746
+ addAll(parent, marks, startIndex, endIndex) {
2747
+ let index = startIndex || 0;
2748
+ for (let dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index) {
2749
+ this.findAtPoint(parent, index);
2750
+ this.addDOM(dom, marks);
2751
+ }
2752
+ this.findAtPoint(parent, index);
2367
2753
  }
2368
2754
  // Try to find a way to fit the given node type into the current
2369
2755
  // context. May add intermediate wrappers and/or leave non-solid
2370
2756
  // nodes that we're in.
2371
- findPlace(t, e, n) {
2372
- let i, r;
2373
- for (let s = this.open, o = 0; s >= 0; s--) {
2374
- let h = this.nodes[s], a = h.findWrapping(t);
2375
- if (a && (!i || i.length > a.length + o) && (i = a, r = h, !a.length))
2376
- break;
2377
- if (h.solid) {
2378
- if (n)
2757
+ findPlace(node, marks, cautious) {
2758
+ let route, sync;
2759
+ for (let depth = this.open, penalty = 0; depth >= 0; depth--) {
2760
+ let cx = this.nodes[depth];
2761
+ let found2 = cx.findWrapping(node);
2762
+ if (found2 && (!route || route.length > found2.length + penalty)) {
2763
+ route = found2;
2764
+ sync = cx;
2765
+ if (!found2.length)
2379
2766
  break;
2380
- o += 2;
2767
+ }
2768
+ if (cx.solid) {
2769
+ if (cautious)
2770
+ break;
2771
+ penalty += 2;
2381
2772
  }
2382
2773
  }
2383
- if (!i)
2774
+ if (!route)
2384
2775
  return null;
2385
- this.sync(r);
2386
- for (let s = 0; s < i.length; s++)
2387
- e = this.enterInner(i[s], null, e, !1);
2388
- return e;
2776
+ this.sync(sync);
2777
+ for (let i = 0; i < route.length; i++)
2778
+ marks = this.enterInner(route[i], null, marks, false);
2779
+ return marks;
2389
2780
  }
2390
2781
  // Try to insert the given node, adjusting the context when needed.
2391
- insertNode(t, e, n) {
2392
- if (t.isInline && this.needsBlock && !this.top.type) {
2393
- let r = this.textblockFromContext();
2394
- r && (e = this.enterInner(r, null, e));
2782
+ insertNode(node, marks, cautious) {
2783
+ if (node.isInline && this.needsBlock && !this.top.type) {
2784
+ let block = this.textblockFromContext();
2785
+ if (block)
2786
+ marks = this.enterInner(block, null, marks);
2395
2787
  }
2396
- let i = this.findPlace(t, e, n);
2397
- if (i) {
2788
+ let innerMarks = this.findPlace(node, marks, cautious);
2789
+ if (innerMarks) {
2398
2790
  this.closeExtra();
2399
- let r = this.top;
2400
- r.match && (r.match = r.match.matchType(t.type));
2401
- let s = u.none;
2402
- for (let o of i.concat(t.marks))
2403
- (r.type ? r.type.allowsMarkType(o.type) : K(o.type, t.type)) && (s = o.addToSet(s));
2404
- return r.content.push(t.mark(s)), !0;
2791
+ let top = this.top;
2792
+ if (top.match)
2793
+ top.match = top.match.matchType(node.type);
2794
+ let nodeMarks = Mark.none;
2795
+ for (let m of innerMarks.concat(node.marks))
2796
+ if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, node.type))
2797
+ nodeMarks = m.addToSet(nodeMarks);
2798
+ top.content.push(node.mark(nodeMarks));
2799
+ return true;
2405
2800
  }
2406
- return !1;
2801
+ return false;
2407
2802
  }
2408
2803
  // Try to start a node of the given type, adjusting the context when
2409
2804
  // necessary.
2410
- enter(t, e, n, i) {
2411
- let r = this.findPlace(t.create(e), n, !1);
2412
- return r && (r = this.enterInner(t, e, n, !0, i)), r;
2805
+ enter(type, attrs, marks, preserveWS) {
2806
+ let innerMarks = this.findPlace(type.create(attrs), marks, false);
2807
+ if (innerMarks)
2808
+ innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);
2809
+ return innerMarks;
2413
2810
  }
2414
2811
  // Open a node of the given type
2415
- enterInner(t, e, n, i = !1, r) {
2812
+ enterInner(type, attrs, marks, solid = false, preserveWS) {
2416
2813
  this.closeExtra();
2417
- let s = this.top;
2418
- s.match = s.match && s.match.matchType(t);
2419
- let o = V(t, r, s.options);
2420
- s.options & b && s.content.length == 0 && (o |= b);
2421
- let h = u.none;
2422
- return n = n.filter((a) => (s.type ? s.type.allowsMarkType(a.type) : K(a.type, t)) ? (h = a.addToSet(h), !1) : !0), this.nodes.push(new C(t, e, h, i, null, o)), this.open++, n;
2814
+ let top = this.top;
2815
+ top.match = top.match && top.match.matchType(type);
2816
+ let options = wsOptionsFor(type, preserveWS, top.options);
2817
+ if (top.options & OPT_OPEN_LEFT && top.content.length == 0)
2818
+ options |= OPT_OPEN_LEFT;
2819
+ let applyMarks = Mark.none;
2820
+ marks = marks.filter((m) => {
2821
+ if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, type)) {
2822
+ applyMarks = m.addToSet(applyMarks);
2823
+ return false;
2824
+ }
2825
+ return true;
2826
+ });
2827
+ this.nodes.push(new NodeContext(type, attrs, applyMarks, solid, null, options));
2828
+ this.open++;
2829
+ return marks;
2423
2830
  }
2424
2831
  // Make sure all nodes above this.open are finished and added to
2425
2832
  // their parents
2426
- closeExtra(t = !1) {
2427
- let e = this.nodes.length - 1;
2428
- if (e > this.open) {
2429
- for (; e > this.open; e--)
2430
- this.nodes[e - 1].content.push(this.nodes[e].finish(t));
2833
+ closeExtra(openEnd = false) {
2834
+ let i = this.nodes.length - 1;
2835
+ if (i > this.open) {
2836
+ for (; i > this.open; i--)
2837
+ this.nodes[i - 1].content.push(this.nodes[i].finish(openEnd));
2431
2838
  this.nodes.length = this.open + 1;
2432
2839
  }
2433
2840
  }
2434
2841
  finish() {
2435
- return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
2436
- }
2437
- sync(t) {
2438
- for (let e = this.open; e >= 0; e--) {
2439
- if (this.nodes[e] == t)
2440
- return this.open = e, !0;
2441
- this.localPreserveWS && (this.nodes[e].options |= E);
2842
+ this.open = 0;
2843
+ this.closeExtra(this.isOpen);
2844
+ return this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
2845
+ }
2846
+ sync(to) {
2847
+ for (let i = this.open; i >= 0; i--) {
2848
+ if (this.nodes[i] == to) {
2849
+ this.open = i;
2850
+ return true;
2851
+ } else if (this.localPreserveWS) {
2852
+ this.nodes[i].options |= OPT_PRESERVE_WS;
2853
+ }
2442
2854
  }
2443
- return !1;
2855
+ return false;
2444
2856
  }
2445
2857
  get currentPos() {
2446
2858
  this.closeExtra();
2447
- let t = 0;
2448
- for (let e = this.open; e >= 0; e--) {
2449
- let n = this.nodes[e].content;
2450
- for (let i = n.length - 1; i >= 0; i--)
2451
- t += n[i].nodeSize;
2452
- e && t++;
2859
+ let pos = 0;
2860
+ for (let i = this.open; i >= 0; i--) {
2861
+ let content = this.nodes[i].content;
2862
+ for (let j = content.length - 1; j >= 0; j--)
2863
+ pos += content[j].nodeSize;
2864
+ if (i)
2865
+ pos++;
2453
2866
  }
2454
- return t;
2867
+ return pos;
2455
2868
  }
2456
- findAtPoint(t, e) {
2869
+ findAtPoint(parent, offset) {
2457
2870
  if (this.find)
2458
- for (let n = 0; n < this.find.length; n++)
2459
- this.find[n].node == t && this.find[n].offset == e && (this.find[n].pos = this.currentPos);
2871
+ for (let i = 0; i < this.find.length; i++) {
2872
+ if (this.find[i].node == parent && this.find[i].offset == offset)
2873
+ this.find[i].pos = this.currentPos;
2874
+ }
2460
2875
  }
2461
- findInside(t) {
2876
+ findInside(parent) {
2462
2877
  if (this.find)
2463
- for (let e = 0; e < this.find.length; e++)
2464
- this.find[e].pos == null && t.nodeType == 1 && t.contains(this.find[e].node) && (this.find[e].pos = this.currentPos);
2878
+ for (let i = 0; i < this.find.length; i++) {
2879
+ if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node))
2880
+ this.find[i].pos = this.currentPos;
2881
+ }
2465
2882
  }
2466
- findAround(t, e, n) {
2467
- if (t != e && this.find)
2468
- for (let i = 0; i < this.find.length; i++)
2469
- this.find[i].pos == null && t.nodeType == 1 && t.contains(this.find[i].node) && e.compareDocumentPosition(this.find[i].node) & (n ? 2 : 4) && (this.find[i].pos = this.currentPos);
2883
+ findAround(parent, content, before) {
2884
+ if (parent != content && this.find)
2885
+ for (let i = 0; i < this.find.length; i++) {
2886
+ if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) {
2887
+ let pos = content.compareDocumentPosition(this.find[i].node);
2888
+ if (pos & (before ? 2 : 4))
2889
+ this.find[i].pos = this.currentPos;
2890
+ }
2891
+ }
2470
2892
  }
2471
- findInText(t) {
2893
+ findInText(textNode) {
2472
2894
  if (this.find)
2473
- for (let e = 0; e < this.find.length; e++)
2474
- this.find[e].node == t && (this.find[e].pos = this.currentPos - (t.nodeValue.length - this.find[e].offset));
2895
+ for (let i = 0; i < this.find.length; i++) {
2896
+ if (this.find[i].node == textNode)
2897
+ this.find[i].pos = this.currentPos - (textNode.nodeValue.length - this.find[i].offset);
2898
+ }
2475
2899
  }
2476
2900
  // Determines whether the given context string matches this context.
2477
- matchesContext(t) {
2478
- if (t.indexOf("|") > -1)
2479
- return t.split(/\s*\|\s*/).some(this.matchesContext, this);
2480
- let e = t.split("/"), n = this.options.context, i = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), r = -(n ? n.depth + 1 : 0) + (i ? 0 : 1), s = (o, h) => {
2481
- for (; o >= 0; o--) {
2482
- let a = e[o];
2483
- if (a == "") {
2484
- if (o == e.length - 1 || o == 0)
2901
+ matchesContext(context) {
2902
+ if (context.indexOf("|") > -1)
2903
+ return context.split(/\s*\|\s*/).some(this.matchesContext, this);
2904
+ let parts = context.split("/");
2905
+ let option = this.options.context;
2906
+ let useRoot = !this.isOpen && (!option || option.parent.type == this.nodes[0].type);
2907
+ let minDepth = -(option ? option.depth + 1 : 0) + (useRoot ? 0 : 1);
2908
+ let match = (i, depth) => {
2909
+ for (; i >= 0; i--) {
2910
+ let part = parts[i];
2911
+ if (part == "") {
2912
+ if (i == parts.length - 1 || i == 0)
2485
2913
  continue;
2486
- for (; h >= r; h--)
2487
- if (s(o - 1, h))
2488
- return !0;
2489
- return !1;
2914
+ for (; depth >= minDepth; depth--)
2915
+ if (match(i - 1, depth))
2916
+ return true;
2917
+ return false;
2490
2918
  } else {
2491
- let f = h > 0 || h == 0 && i ? this.nodes[h].type : n && h >= r ? n.node(h - r).type : null;
2492
- if (!f || f.name != a && !f.isInGroup(a))
2493
- return !1;
2494
- h--;
2919
+ let next = depth > 0 || depth == 0 && useRoot ? this.nodes[depth].type : option && depth >= minDepth ? option.node(depth - minDepth).type : null;
2920
+ if (!next || next.name != part && !next.isInGroup(part))
2921
+ return false;
2922
+ depth--;
2495
2923
  }
2496
2924
  }
2497
- return !0;
2925
+ return true;
2498
2926
  };
2499
- return s(e.length - 1, this.open);
2927
+ return match(parts.length - 1, this.open);
2500
2928
  }
2501
2929
  textblockFromContext() {
2502
- let t = this.options.context;
2503
- if (t)
2504
- for (let e = t.depth; e >= 0; e--) {
2505
- let n = t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;
2506
- if (n && n.isTextblock && n.defaultAttrs)
2507
- return n;
2930
+ let $context = this.options.context;
2931
+ if ($context)
2932
+ for (let d = $context.depth; d >= 0; d--) {
2933
+ let deflt = $context.node(d).contentMatchAt($context.indexAfter(d)).defaultType;
2934
+ if (deflt && deflt.isTextblock && deflt.defaultAttrs)
2935
+ return deflt;
2508
2936
  }
2509
- for (let e in this.parser.schema.nodes) {
2510
- let n = this.parser.schema.nodes[e];
2511
- if (n.isTextblock && n.defaultAttrs)
2512
- return n;
2937
+ for (let name in this.parser.schema.nodes) {
2938
+ let type = this.parser.schema.nodes[name];
2939
+ if (type.isTextblock && type.defaultAttrs)
2940
+ return type;
2513
2941
  }
2514
2942
  }
2515
2943
  }
2516
- function Dt(l) {
2517
- for (let t = l.firstChild, e = null; t; t = t.nextSibling) {
2518
- let n = t.nodeType == 1 ? t.nodeName.toLowerCase() : null;
2519
- n && ct.hasOwnProperty(n) && e ? (e.appendChild(t), t = e) : n == "li" ? e = t : n && (e = null);
2944
+ function normalizeList(dom) {
2945
+ for (let child = dom.firstChild, prevItem = null; child; child = child.nextSibling) {
2946
+ let name = child.nodeType == 1 ? child.nodeName.toLowerCase() : null;
2947
+ if (name && listTags.hasOwnProperty(name) && prevItem) {
2948
+ prevItem.appendChild(child);
2949
+ child = prevItem;
2950
+ } else if (name == "li") {
2951
+ prevItem = child;
2952
+ } else if (name) {
2953
+ prevItem = null;
2954
+ }
2520
2955
  }
2521
2956
  }
2522
- function Pt(l, t) {
2523
- return (l.matches || l.msMatchesSelector || l.webkitMatchesSelector || l.mozMatchesSelector).call(l, t);
2957
+ function matches(dom, selector) {
2958
+ return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector);
2524
2959
  }
2525
- function H(l) {
2526
- let t = {};
2527
- for (let e in l)
2528
- t[e] = l[e];
2529
- return t;
2960
+ function copy(obj) {
2961
+ let copy2 = {};
2962
+ for (let prop in obj)
2963
+ copy2[prop] = obj[prop];
2964
+ return copy2;
2530
2965
  }
2531
- function K(l, t) {
2532
- let e = t.schema.nodes;
2533
- for (let n in e) {
2534
- let i = e[n];
2535
- if (!i.allowsMarkType(l))
2966
+ function markMayApply(markType, nodeType) {
2967
+ let nodes = nodeType.schema.nodes;
2968
+ for (let name in nodes) {
2969
+ let parent = nodes[name];
2970
+ if (!parent.allowsMarkType(markType))
2536
2971
  continue;
2537
- let r = [], s = (o) => {
2538
- r.push(o);
2539
- for (let h = 0; h < o.edgeCount; h++) {
2540
- let { type: a, next: f } = o.edge(h);
2541
- if (a == t || r.indexOf(f) < 0 && s(f))
2542
- return !0;
2972
+ let seen = [], scan = (match) => {
2973
+ seen.push(match);
2974
+ for (let i = 0; i < match.edgeCount; i++) {
2975
+ let { type, next } = match.edge(i);
2976
+ if (type == nodeType)
2977
+ return true;
2978
+ if (seen.indexOf(next) < 0 && scan(next))
2979
+ return true;
2543
2980
  }
2544
2981
  };
2545
- if (s(i.contentMatch))
2546
- return !0;
2982
+ if (scan(parent.contentMatch))
2983
+ return true;
2547
2984
  }
2548
2985
  }
2549
- class ut {
2986
+ class DOMSerializer {
2550
2987
  /**
2551
2988
  Create a serializer. `nodes` should map node names to functions
2552
2989
  that take a node and return a description of the corresponding
@@ -2556,8 +2993,9 @@ class ut {
2556
2993
  serializer may be `null` to indicate that marks of that type
2557
2994
  should not be serialized.
2558
2995
  */
2559
- constructor(t, e) {
2560
- this.nodes = t, this.marks = e;
2996
+ constructor(nodes, marks) {
2997
+ this.nodes = nodes;
2998
+ this.marks = marks;
2561
2999
  }
2562
3000
  /**
2563
3001
  Serialize the content of this fragment to a DOM fragment. When
@@ -2565,43 +3003,51 @@ class ut {
2565
3003
  document, should be passed so that the serializer can create
2566
3004
  nodes.
2567
3005
  */
2568
- serializeFragment(t, e = {}, n) {
2569
- n || (n = R(e).createDocumentFragment());
2570
- let i = n, r = [];
2571
- return t.forEach((s) => {
2572
- if (r.length || s.marks.length) {
2573
- let o = 0, h = 0;
2574
- for (; o < r.length && h < s.marks.length; ) {
2575
- let a = s.marks[h];
2576
- if (!this.marks[a.type.name]) {
2577
- h++;
3006
+ serializeFragment(fragment, options = {}, target) {
3007
+ if (!target)
3008
+ target = doc(options).createDocumentFragment();
3009
+ let top = target, active = [];
3010
+ fragment.forEach((node) => {
3011
+ if (active.length || node.marks.length) {
3012
+ let keep = 0, rendered = 0;
3013
+ while (keep < active.length && rendered < node.marks.length) {
3014
+ let next = node.marks[rendered];
3015
+ if (!this.marks[next.type.name]) {
3016
+ rendered++;
2578
3017
  continue;
2579
3018
  }
2580
- if (!a.eq(r[o][0]) || a.type.spec.spanning === !1)
3019
+ if (!next.eq(active[keep][0]) || next.type.spec.spanning === false)
2581
3020
  break;
2582
- o++, h++;
3021
+ keep++;
3022
+ rendered++;
2583
3023
  }
2584
- for (; o < r.length; )
2585
- i = r.pop()[1];
2586
- for (; h < s.marks.length; ) {
2587
- let a = s.marks[h++], f = this.serializeMark(a, s.isInline, e);
2588
- f && (r.push([a, i]), i.appendChild(f.dom), i = f.contentDOM || f.dom);
3024
+ while (keep < active.length)
3025
+ top = active.pop()[1];
3026
+ while (rendered < node.marks.length) {
3027
+ let add = node.marks[rendered++];
3028
+ let markDOM = this.serializeMark(add, node.isInline, options);
3029
+ if (markDOM) {
3030
+ active.push([add, top]);
3031
+ top.appendChild(markDOM.dom);
3032
+ top = markDOM.contentDOM || markDOM.dom;
3033
+ }
2589
3034
  }
2590
3035
  }
2591
- i.appendChild(this.serializeNodeInner(s, e));
2592
- }), n;
3036
+ top.appendChild(this.serializeNodeInner(node, options));
3037
+ });
3038
+ return target;
2593
3039
  }
2594
3040
  /**
2595
3041
  @internal
2596
3042
  */
2597
- serializeNodeInner(t, e) {
2598
- let { dom: n, contentDOM: i } = T(R(e), this.nodes[t.type.name](t), null, t.attrs);
2599
- if (i) {
2600
- if (t.isLeaf)
3043
+ serializeNodeInner(node, options) {
3044
+ let { dom, contentDOM } = renderSpec(doc(options), this.nodes[node.type.name](node), null, node.attrs);
3045
+ if (contentDOM) {
3046
+ if (node.isLeaf)
2601
3047
  throw new RangeError("Content hole not allowed in a leaf node spec");
2602
- this.serializeFragment(t.content, e, i);
3048
+ this.serializeFragment(node.content, options, contentDOM);
2603
3049
  }
2604
- return n;
3050
+ return dom;
2605
3051
  }
2606
3052
  /**
2607
3053
  Serialize this node to a DOM node. This can be useful when you
@@ -2610,127 +3056,150 @@ class ut {
2610
3056
  [`serializeFragment`](https://prosemirror.net/docs/ref/#model.DOMSerializer.serializeFragment) on
2611
3057
  its [content](https://prosemirror.net/docs/ref/#model.Node.content).
2612
3058
  */
2613
- serializeNode(t, e = {}) {
2614
- let n = this.serializeNodeInner(t, e);
2615
- for (let i = t.marks.length - 1; i >= 0; i--) {
2616
- let r = this.serializeMark(t.marks[i], t.isInline, e);
2617
- r && ((r.contentDOM || r.dom).appendChild(n), n = r.dom);
3059
+ serializeNode(node, options = {}) {
3060
+ let dom = this.serializeNodeInner(node, options);
3061
+ for (let i = node.marks.length - 1; i >= 0; i--) {
3062
+ let wrap = this.serializeMark(node.marks[i], node.isInline, options);
3063
+ if (wrap) {
3064
+ (wrap.contentDOM || wrap.dom).appendChild(dom);
3065
+ dom = wrap.dom;
3066
+ }
2618
3067
  }
2619
- return n;
3068
+ return dom;
2620
3069
  }
2621
3070
  /**
2622
3071
  @internal
2623
3072
  */
2624
- serializeMark(t, e, n = {}) {
2625
- let i = this.marks[t.type.name];
2626
- return i && T(R(n), i(t, e), null, t.attrs);
3073
+ serializeMark(mark, inline, options = {}) {
3074
+ let toDOM = this.marks[mark.type.name];
3075
+ return toDOM && renderSpec(doc(options), toDOM(mark, inline), null, mark.attrs);
2627
3076
  }
2628
- static renderSpec(t, e, n = null, i) {
2629
- return T(t, e, n, i);
3077
+ static renderSpec(doc2, structure, xmlNS = null, blockArraysIn) {
3078
+ return renderSpec(doc2, structure, xmlNS, blockArraysIn);
2630
3079
  }
2631
3080
  /**
2632
3081
  Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
2633
3082
  properties in a schema's node and mark specs.
2634
3083
  */
2635
- static fromSchema(t) {
2636
- return t.cached.domSerializer || (t.cached.domSerializer = new ut(this.nodesFromSchema(t), this.marksFromSchema(t)));
3084
+ static fromSchema(schema) {
3085
+ return schema.cached.domSerializer || (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));
2637
3086
  }
2638
3087
  /**
2639
3088
  Gather the serializers in a schema's node specs into an object.
2640
3089
  This can be useful as a base to build a custom serializer from.
2641
3090
  */
2642
- static nodesFromSchema(t) {
2643
- let e = Q(t.nodes);
2644
- return e.text || (e.text = (n) => n.text), e;
3091
+ static nodesFromSchema(schema) {
3092
+ let result = gatherToDOM(schema.nodes);
3093
+ if (!result.text)
3094
+ result.text = (node) => node.text;
3095
+ return result;
2645
3096
  }
2646
3097
  /**
2647
3098
  Gather the serializers in a schema's mark specs into an object.
2648
3099
  */
2649
- static marksFromSchema(t) {
2650
- return Q(t.marks);
2651
- }
2652
- }
2653
- function Q(l) {
2654
- let t = {};
2655
- for (let e in l) {
2656
- let n = l[e].spec.toDOM;
2657
- n && (t[e] = n);
3100
+ static marksFromSchema(schema) {
3101
+ return gatherToDOM(schema.marks);
3102
+ }
3103
+ }
3104
+ function gatherToDOM(obj) {
3105
+ let result = {};
3106
+ for (let name in obj) {
3107
+ let toDOM = obj[name].spec.toDOM;
3108
+ if (toDOM)
3109
+ result[name] = toDOM;
3110
+ }
3111
+ return result;
3112
+ }
3113
+ function doc(options) {
3114
+ return options.document || window.document;
3115
+ }
3116
+ const suspiciousAttributeCache = /* @__PURE__ */ new WeakMap();
3117
+ function suspiciousAttributes(attrs) {
3118
+ let value = suspiciousAttributeCache.get(attrs);
3119
+ if (value === void 0)
3120
+ suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));
3121
+ return value;
3122
+ }
3123
+ function suspiciousAttributesInner(attrs) {
3124
+ let result = null;
3125
+ function scan(value) {
3126
+ if (value && typeof value == "object") {
3127
+ if (Array.isArray(value)) {
3128
+ if (typeof value[0] == "string") {
3129
+ if (!result)
3130
+ result = [];
3131
+ result.push(value);
3132
+ } else {
3133
+ for (let i = 0; i < value.length; i++)
3134
+ scan(value[i]);
3135
+ }
3136
+ } else {
3137
+ for (let prop in value)
3138
+ scan(value[prop]);
3139
+ }
3140
+ }
2658
3141
  }
2659
- return t;
2660
- }
2661
- function R(l) {
2662
- return l.document || window.document;
2663
- }
2664
- const X = /* @__PURE__ */ new WeakMap();
2665
- function Bt(l) {
2666
- let t = X.get(l);
2667
- return t === void 0 && X.set(l, t = Ft(l)), t;
2668
- }
2669
- function Ft(l) {
2670
- let t = null;
2671
- function e(n) {
2672
- if (n && typeof n == "object")
2673
- if (Array.isArray(n))
2674
- if (typeof n[0] == "string")
2675
- t || (t = []), t.push(n);
2676
- else
2677
- for (let i = 0; i < n.length; i++)
2678
- e(n[i]);
2679
- else
2680
- for (let i in n)
2681
- e(n[i]);
2682
- }
2683
- return e(l), t;
2684
- }
2685
- function T(l, t, e, n) {
2686
- if (typeof t == "string")
2687
- return { dom: l.createTextNode(t) };
2688
- if (t.nodeType != null)
2689
- return { dom: t };
2690
- if (t.dom && t.dom.nodeType != null)
2691
- return t;
2692
- let i = t[0], r;
2693
- if (typeof i != "string")
3142
+ scan(attrs);
3143
+ return result;
3144
+ }
3145
+ function renderSpec(doc2, structure, xmlNS, blockArraysIn) {
3146
+ if (typeof structure == "string")
3147
+ return { dom: doc2.createTextNode(structure) };
3148
+ if (structure.nodeType != null)
3149
+ return { dom: structure };
3150
+ if (structure.dom && structure.dom.nodeType != null)
3151
+ return structure;
3152
+ let tagName = structure[0], suspicious;
3153
+ if (typeof tagName != "string")
2694
3154
  throw new RangeError("Invalid array passed to renderSpec");
2695
- if (n && (r = Bt(n)) && r.indexOf(t) > -1)
3155
+ if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1)
2696
3156
  throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
2697
- let s = i.indexOf(" ");
2698
- s > 0 && (e = i.slice(0, s), i = i.slice(s + 1));
2699
- let o, h = e ? l.createElementNS(e, i) : l.createElement(i), a = t[1], f = 1;
2700
- if (a && typeof a == "object" && a.nodeType == null && !Array.isArray(a)) {
2701
- f = 2;
2702
- for (let p in a)
2703
- if (a[p] != null) {
2704
- let g = p.indexOf(" ");
2705
- g > 0 ? h.setAttributeNS(p.slice(0, g), p.slice(g + 1), a[p]) : h.setAttribute(p, a[p]);
3157
+ let space = tagName.indexOf(" ");
3158
+ if (space > 0) {
3159
+ xmlNS = tagName.slice(0, space);
3160
+ tagName = tagName.slice(space + 1);
3161
+ }
3162
+ let contentDOM;
3163
+ let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
3164
+ let attrs = structure[1], start = 1;
3165
+ if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
3166
+ start = 2;
3167
+ for (let name in attrs)
3168
+ if (attrs[name] != null) {
3169
+ let space2 = name.indexOf(" ");
3170
+ if (space2 > 0)
3171
+ dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
3172
+ else
3173
+ dom.setAttribute(name, attrs[name]);
2706
3174
  }
2707
3175
  }
2708
- for (let p = f; p < t.length; p++) {
2709
- let g = t[p];
2710
- if (g === 0) {
2711
- if (p < t.length - 1 || p > f)
3176
+ for (let i = start; i < structure.length; i++) {
3177
+ let child = structure[i];
3178
+ if (child === 0) {
3179
+ if (i < structure.length - 1 || i > start)
2712
3180
  throw new RangeError("Content hole must be the only child of its parent node");
2713
- return { dom: h, contentDOM: h };
3181
+ return { dom, contentDOM: dom };
2714
3182
  } else {
2715
- let { dom: pt, contentDOM: J } = T(l, g, e, n);
2716
- if (h.appendChild(pt), J) {
2717
- if (o)
3183
+ let { dom: inner, contentDOM: innerContent } = renderSpec(doc2, child, xmlNS, blockArraysIn);
3184
+ dom.appendChild(inner);
3185
+ if (innerContent) {
3186
+ if (contentDOM)
2718
3187
  throw new RangeError("Multiple content holes");
2719
- o = J;
3188
+ contentDOM = innerContent;
2720
3189
  }
2721
3190
  }
2722
3191
  }
2723
- return { dom: h, contentDOM: o };
3192
+ return { dom, contentDOM };
2724
3193
  }
2725
3194
  export {
2726
- ut as D,
2727
- c as F,
2728
- u as M,
2729
- y as N,
2730
- I as R,
2731
- qt as S,
2732
- P as a,
2733
- d as b,
2734
- mt as c,
2735
- F as d
3195
+ DOMSerializer as D,
3196
+ Fragment as F,
3197
+ Mark as M,
3198
+ Node as N,
3199
+ ReplaceError as R,
3200
+ Schema as S,
3201
+ DOMParser as a,
3202
+ Slice as b,
3203
+ NodeRange as c,
3204
+ MarkType as d
2736
3205
  };