@vc-shell/framework 1.1.43 → 1.1.45

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 (453) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/core/plugins/modularity/loader.ts +120 -74
  3. package/core/services/app-bar-mobile-buttons-service.ts +1 -1
  4. package/dist/core/plugins/modularity/loader.d.ts.map +1 -1
  5. package/dist/core/services/app-bar-mobile-buttons-service.d.ts +1 -1
  6. package/dist/core/services/app-bar-mobile-buttons-service.d.ts.map +1 -1
  7. package/dist/framework.js +33347 -295
  8. package/dist/index.css +1 -9
  9. package/dist/index.d.ts +0 -4
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/locales/de.json +0 -84
  12. package/dist/locales/en.json +0 -84
  13. package/dist/shared/components/blade-navigation/components/vc-blade-navigation/_internal/vc-mobile-back-button.vue.d.ts.map +1 -1
  14. package/dist/shared/components/blade-navigation/components/vc-blade-view/vc-blade-view.d.ts +1 -1
  15. package/dist/shared/components/blade-navigation/components/vc-blade-view/vc-blade-view.d.ts.map +1 -1
  16. package/dist/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeRouteResolver.d.ts.map +1 -1
  17. package/dist/shared/components/change-password-button/change-password-button.vue.d.ts.map +1 -1
  18. package/dist/shared/components/logout-button/logout-button.vue.d.ts.map +1 -1
  19. package/dist/shared/components/settings-menu-item/settings-menu-item.vue.d.ts.map +1 -1
  20. package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +2 -2
  21. package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts +6 -6
  22. package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/ui/components/atoms/vc-hint/vc-hint.vue.d.ts.map +1 -1
  25. package/dist/ui/components/atoms/vc-icon/icons/MenuBurgerIcon.vue.d.ts.map +1 -1
  26. package/dist/ui/components/atoms/vc-icon/icons/index.d.ts +0 -26
  27. package/dist/ui/components/atoms/vc-icon/icons/index.d.ts.map +1 -1
  28. package/dist/ui/components/atoms/vc-icon/vc-bootstrap-icon.vue.d.ts.map +1 -1
  29. package/dist/ui/components/atoms/vc-icon/vc-fontawesome-icon.vue.d.ts.map +1 -1
  30. package/dist/ui/components/atoms/vc-icon/vc-icon.vue.d.ts.map +1 -1
  31. package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts +0 -5
  32. package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts.map +1 -1
  33. package/dist/ui/components/atoms/vc-icon/vc-material-icon.vue.d.ts +0 -20
  34. package/dist/ui/components/atoms/vc-icon/vc-material-icon.vue.d.ts.map +1 -1
  35. package/dist/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue.d.ts.map +1 -1
  36. package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-button.vue.d.ts +36 -0
  37. package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-button.vue.d.ts.map +1 -0
  38. package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-toolbar.vue.d.ts +17 -0
  39. package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-toolbar.vue.d.ts.map +1 -0
  40. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts +16 -2381
  41. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts.map +1 -1
  42. package/dist/ui/components/molecules/vc-form/vc-form.vue.d.ts.map +1 -1
  43. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts +1 -1
  44. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts.map +1 -1
  45. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts +1 -1
  46. package/dist/ui/components/molecules/vc-pagination/vc-pagination.vue.d.ts.map +1 -1
  47. package/dist/ui/components/organisms/vc-app/_internal/vc-app-bar/_internal/MenuSidebar.vue.d.ts.map +1 -1
  48. package/dist/ui/components/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue.d.ts.map +1 -1
  49. package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue.d.ts.map +1 -1
  50. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
  51. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue.d.ts.map +1 -1
  52. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-desktop.vue.d.ts.map +1 -1
  53. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-mobile.vue.d.ts.map +1 -1
  54. package/dist/ui/components/organisms/vc-blade/vc-blade.vue.d.ts.map +1 -1
  55. package/dist/ui/components/organisms/vc-gallery/_internal/vc-gallery-item/vc-gallery-item.vue.d.ts +2 -2
  56. package/dist/ui/components/organisms/vc-gallery/vc-gallery.vue.d.ts +2 -2
  57. package/dist/ui/components/organisms/vc-table/_internal/vc-table-filter/vc-table-filter.vue.d.ts.map +1 -1
  58. package/dist/ui/components/organisms/vc-table/_internal/vc-table-header/vc-table-header.vue.d.ts.map +1 -1
  59. package/dist/vendor-boolbase-Cp9L0GAZ.js +25 -0
  60. package/dist/vendor-cheerio-HN9zIPZn.js +3135 -0
  61. package/dist/vendor-cheerio-select-5Ry0HvBq.js +306 -0
  62. package/dist/vendor-core-js-l0sNRNKZ.js +1 -0
  63. package/dist/vendor-css-select-DRIZ9kfZ.js +966 -0
  64. package/dist/vendor-css-what-DuPJ1HEF.js +448 -0
  65. package/dist/vendor-cypress-signalr-mock-BKdBJpdt.js +778 -0
  66. package/dist/vendor-date-fns-515YWkk-.js +6724 -0
  67. package/dist/vendor-dom-serializer-nQMsqjYW.js +286 -0
  68. package/dist/vendor-dom7-CJLPMwy5.js +941 -0
  69. package/dist/vendor-domelementtype-CjSzQey5.js +53 -0
  70. package/dist/vendor-domhandler-9z8cS16a.js +484 -0
  71. package/dist/vendor-dompurify-CRFzu7ib.js +1336 -0
  72. package/dist/vendor-domutils-Bc-Opz-v.js +981 -0
  73. package/dist/vendor-entities-Bfsx4xOQ.js +636 -0
  74. package/dist/vendor-floating-ui-core-wV8u8QP4.js +511 -0
  75. package/dist/vendor-floating-ui-dom-DDnRPs17.js +706 -0
  76. package/dist/vendor-floating-ui-utils-OMIFy1QU.js +296 -0
  77. package/dist/vendor-floating-ui-vue-D-tCDAMm.js +167 -0
  78. package/dist/vendor-fontsource-plus-jakarta-sans.css +1 -0
  79. package/dist/vendor-headlessui-vue-CY9FRgTb.js +83 -0
  80. package/dist/vendor-htmlparser2-B1dhFPOs.js +1426 -0
  81. package/dist/vendor-iconify-vue-DfRGgyNu.js +1840 -0
  82. package/dist/vendor-intlify-core-base-BuknsFQe.js +1876 -0
  83. package/dist/vendor-intlify-message-compiler-CuOQDWx1.js +1508 -0
  84. package/dist/vendor-intlify-shared-Cz4YRMuC.js +241 -0
  85. package/dist/vendor-iso-639-1-BJCk9DvE.js +819 -0
  86. package/dist/vendor-linkify-it-CKUf4vsc.js +830 -0
  87. package/dist/vendor-linkifyjs-BfyGgbCh.js +1756 -0
  88. package/dist/vendor-lodash-es-BySUOlwf.js +18333 -0
  89. package/dist/vendor-markdown-it-D-apazHa.js +6000 -0
  90. package/dist/vendor-markdown-it-task-lists-rxMVH6Ku.js +131 -0
  91. package/dist/vendor-mdurl-BNh2CCgT.js +537 -0
  92. package/dist/vendor-microsoft-applicationinsights-analytics-js-kG3lLg8X.js +1275 -0
  93. package/dist/vendor-microsoft-applicationinsights-cfgsync-js-C0uQkiQq.js +591 -0
  94. package/dist/vendor-microsoft-applicationinsights-channel-js-Dyd_PXA3.js +2153 -0
  95. package/dist/vendor-microsoft-applicationinsights-common-CfmP1_Qr.js +2470 -0
  96. package/dist/vendor-microsoft-applicationinsights-core-js-Cq4YSEvZ.js +6589 -0
  97. package/dist/vendor-microsoft-applicationinsights-dependencies-js-C56OBFr4.js +1510 -0
  98. package/dist/vendor-microsoft-applicationinsights-properties-js-CBJTBawx.js +761 -0
  99. package/dist/vendor-microsoft-applicationinsights-shims-CX8sJgar.js +70 -0
  100. package/dist/vendor-microsoft-applicationinsights-web-pim2ri-g.js +667 -0
  101. package/dist/vendor-microsoft-dynamicproto-js-CFBBUu9p.js +520 -0
  102. package/dist/vendor-microsoft-signalr-dUnlRsGm.js +3339 -0
  103. package/dist/vendor-moment-Mki5YqAR.js +5679 -0
  104. package/dist/vendor-nevware21-ts-async-CLMApQ9E.js +395 -0
  105. package/dist/vendor-nevware21-ts-utils-e8v8Jty3.js +1160 -0
  106. package/dist/vendor-normalize-css.css +1 -0
  107. package/dist/vendor-nth-check-Bx8TxtJt.js +157 -0
  108. package/dist/vendor-orderedmap-dGG6uMFJ.js +137 -0
  109. package/dist/vendor-parse5-Bt2NhSzR.js +8432 -0
  110. package/dist/vendor-parse5-htmlparser2-tree-adapter-BUUtKzf8.js +216 -0
  111. package/dist/vendor-popperjs-core-Cr2byIky.js +1790 -0
  112. package/dist/vendor-prettier-B4PaeWRQ.js +98 -0
  113. package/dist/vendor-prosemirror-commands-BH9lWGpW.js +561 -0
  114. package/dist/vendor-prosemirror-dropcursor-CeyPcxrA.js +146 -0
  115. package/dist/vendor-prosemirror-gapcursor-U8UoUJII.js +236 -0
  116. package/dist/vendor-prosemirror-history-BDaJkvNx.js +414 -0
  117. package/dist/vendor-prosemirror-keymap-BbWvIWmH.js +128 -0
  118. package/dist/vendor-prosemirror-markdown-gB0PXBbz.js +866 -0
  119. package/dist/vendor-prosemirror-model-BZu3WVcD.js +3463 -0
  120. package/dist/vendor-prosemirror-schema-list-Bl9NpKA7.js +158 -0
  121. package/dist/vendor-prosemirror-state-BvL9Pxph.js +1003 -0
  122. package/dist/vendor-prosemirror-tables-17qAnviK.js +2159 -0
  123. package/dist/vendor-prosemirror-transform-CE9VV3qg.js +2156 -0
  124. package/dist/vendor-prosemirror-view-CU2WTHT7.js +5811 -0
  125. package/dist/vendor-punycode-js-iAs5RxMf.js +441 -0
  126. package/dist/vendor-rope-sequence-BdXDKoGt.js +207 -0
  127. package/dist/vendor-semver-CVLMK-S4.js +2702 -0
  128. package/dist/vendor-ssr-window-s6OpKa3O.js +150 -0
  129. package/dist/vendor-swiper-CdiyNHVt.js +5679 -0
  130. package/dist/vendor-swiper.css +1 -0
  131. package/dist/vendor-tanstack-virtual-core-l0sNRNKZ.js +1 -0
  132. package/dist/vendor-tanstack-vue-virtual-l0sNRNKZ.js +1 -0
  133. package/dist/vendor-tippy-js-DWFe2TfK.js +1647 -0
  134. package/dist/vendor-tiptap-core-NfwGfaQk.js +4910 -0
  135. package/dist/vendor-tiptap-extension-blockquote-jmWBTtsI.js +57 -0
  136. package/dist/vendor-tiptap-extension-bold-p5frh4ak.js +97 -0
  137. package/dist/vendor-tiptap-extension-bubble-menu-KUhZSfrs.js +218 -0
  138. package/dist/vendor-tiptap-extension-bullet-list-COmZRoSB.js +73 -0
  139. package/dist/vendor-tiptap-extension-code-block-DyTARZss.js +221 -0
  140. package/dist/vendor-tiptap-extension-code-jVv6CXpX.js +75 -0
  141. package/dist/vendor-tiptap-extension-document-DssuotYs.js +13 -0
  142. package/dist/vendor-tiptap-extension-dropcursor-BoO0Qv91.js +26 -0
  143. package/dist/vendor-tiptap-extension-floating-menu-CrO8CN5w.js +165 -0
  144. package/dist/vendor-tiptap-extension-gapcursor-KpsWEoMD.js +30 -0
  145. package/dist/vendor-tiptap-extension-hard-break-ldOzhSvf.js +68 -0
  146. package/dist/vendor-tiptap-extension-heading-CKz2llX0.js +77 -0
  147. package/dist/vendor-tiptap-extension-history-DeKZ2VQ9.js +48 -0
  148. package/dist/vendor-tiptap-extension-horizontal-rule-CAjWRyDS.js +92 -0
  149. package/dist/vendor-tiptap-extension-image-ZagcEYuk.js +76 -0
  150. package/dist/vendor-tiptap-extension-italic-CM4xdznY.js +96 -0
  151. package/dist/vendor-tiptap-extension-link-Z-AMC4Ri.js +414 -0
  152. package/dist/vendor-tiptap-extension-list-item-BJi5QpXc.js +37 -0
  153. package/dist/vendor-tiptap-extension-ordered-list-C_TMrfBE.js +97 -0
  154. package/dist/vendor-tiptap-extension-paragraph-CQw0E0Au.js +39 -0
  155. package/dist/vendor-tiptap-extension-placeholder-BBNVKfa_.js +66 -0
  156. package/dist/vendor-tiptap-extension-strike-DUyMYX1Z.js +79 -0
  157. package/dist/vendor-tiptap-extension-table-cell-CoDIMPA5.js +47 -0
  158. package/dist/vendor-tiptap-extension-table-header-DvbGHnmw.js +47 -0
  159. package/dist/vendor-tiptap-extension-table-row-D1uqN5Aj.js +26 -0
  160. package/dist/vendor-tiptap-extension-table-tKS4MOM4.js +354 -0
  161. package/dist/vendor-tiptap-extension-text-DtRBhKB2.js +12 -0
  162. package/dist/vendor-tiptap-extension-underline-DqaSFp_P.js +50 -0
  163. package/dist/vendor-tiptap-markdown-7-PCADTU.js +1017 -0
  164. package/dist/vendor-tiptap-pm-l0sNRNKZ.js +1 -0
  165. package/dist/vendor-tiptap-starter-kit-CDSV_Zuu.js +88 -0
  166. package/dist/vendor-tiptap-vue-3-DZg2fjq_.js +268 -0
  167. package/dist/vendor-truncate-html-3qQY0Djo.js +196 -0
  168. package/dist/vendor-uc-micro-jjt6LQ65.js +23 -0
  169. package/dist/vendor-vee-validate-i18n-v_gHjRmD.js +154 -0
  170. package/dist/vendor-vee-validate-rules-DzV3VY3N.js +536 -0
  171. package/dist/vendor-vue-currency-input-DGAkEFBO.js +545 -0
  172. package/dist/vendor-vue-demi-l0sNRNKZ.js +1 -0
  173. package/dist/vendor-vue-devtools-api-DXYR8qBG.js +169 -0
  174. package/dist/vendor-vue-i18n-Co752uk3.js +1897 -0
  175. package/dist/vendor-vue3-application-insights-CYWFCr_J.js +119 -0
  176. package/dist/vendor-vue3-touch-events-BJEAiSa3.js +416 -0
  177. package/dist/vendor-vuepic-vue-datepicker-BSWXRSiu.js +5019 -0
  178. package/dist/vendor-vuepic-vue-datepicker.css +1 -0
  179. package/dist/vendor-vueuse-components-l1bL12mE.js +339 -0
  180. package/dist/vendor-vueuse-core-DGcJOmwG.js +7743 -0
  181. package/dist/vendor-vueuse-shared-_mOXsFuM.js +1568 -0
  182. package/dist/vendor-w3c-keyname-BOm2dtJm.js +121 -0
  183. package/package.json +22 -11
  184. package/shared/components/blade-navigation/components/vc-blade-navigation/_internal/vc-mobile-back-button.vue +3 -3
  185. package/shared/components/blade-navigation/components/vc-blade-view/vc-blade-view.ts +2 -1
  186. package/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeRouteResolver.ts +1 -0
  187. package/shared/components/change-password-button/change-password-button.vue +1 -2
  188. package/shared/components/logout-button/logout-button.vue +1 -2
  189. package/shared/components/notifications/components/notification-container/index.ts +1 -1
  190. package/shared/components/notifications/core/notification.ts +1 -1
  191. package/shared/components/settings-menu-item/settings-menu-item.vue +1 -0
  192. package/shared/components/sidebar/sidebar.vue +2 -2
  193. package/shared/modules/dynamic/pages/dynamic-blade-list.vue +2 -1
  194. package/ui/components/atoms/vc-hint/vc-hint.vue +2 -0
  195. package/ui/components/atoms/vc-icon/composables/use-icon.ts +1 -1
  196. package/ui/components/atoms/vc-icon/icons/MenuBurgerIcon.vue +18 -14
  197. package/ui/components/atoms/vc-icon/icons/index.ts +1 -27
  198. package/ui/components/atoms/vc-icon/vc-bootstrap-icon.vue +7 -11
  199. package/ui/components/atoms/vc-icon/vc-fontawesome-icon.vue +37 -31
  200. package/ui/components/atoms/vc-icon/vc-icon-examples.vue +1 -1
  201. package/ui/components/atoms/vc-icon/vc-icon.stories.ts +4 -5
  202. package/ui/components/atoms/vc-icon/vc-icon.vue +33 -163
  203. package/ui/components/atoms/vc-icon/vc-lucide-icon.vue +22 -70
  204. package/ui/components/atoms/vc-icon/vc-material-icon.vue +28 -59
  205. package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue +2 -3
  206. package/ui/components/molecules/vc-editor/_internal/vc-editor-button.vue +103 -0
  207. package/ui/components/molecules/vc-editor/_internal/vc-editor-toolbar.vue +252 -0
  208. package/ui/components/molecules/vc-editor/vc-editor.stories.ts +1 -4
  209. package/ui/components/molecules/vc-editor/vc-editor.vue +666 -360
  210. package/ui/components/molecules/vc-form/vc-form.vue +7 -5
  211. package/ui/components/molecules/vc-input/vc-input.vue +1 -1
  212. package/ui/components/molecules/vc-pagination/vc-pagination.vue +4 -17
  213. package/ui/components/organisms/vc-app/_internal/vc-app-bar/_internal/AppBarMobileActions.vue +1 -1
  214. package/ui/components/organisms/vc-app/_internal/vc-app-bar/_internal/MenuSidebar.vue +1 -3
  215. package/ui/components/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue +1 -4
  216. package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue +1 -3
  217. package/ui/components/organisms/vc-app/vc-app.backupsb.ts +214 -214
  218. package/ui/components/organisms/vc-app/vc-app.vue +3 -5
  219. package/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue +3 -10
  220. package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/mobile/vc-blade-toolbar-mobile.vue +1 -1
  221. package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-desktop.vue +2 -2
  222. package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-mobile.vue +2 -2
  223. package/ui/components/organisms/vc-blade/vc-blade.vue +4 -5
  224. package/ui/components/organisms/vc-table/_internal/vc-table-filter/vc-table-filter.vue +1 -3
  225. package/ui/components/organisms/vc-table/_internal/vc-table-header/vc-table-header.vue +1 -2
  226. package/ui/components/organisms/vc-table/composables/useTableState.ts +5 -5
  227. package/dist/apl-B2DGVGxc.js +0 -76
  228. package/dist/asciiarmor-2LVJmxlE.js +0 -34
  229. package/dist/asn1-jKiBa2Ya.js +0 -95
  230. package/dist/asterisk-DS281yxp.js +0 -271
  231. package/dist/brainfuck-C_p9pTT8.js +0 -34
  232. package/dist/clike-DGTaUp48.js +0 -620
  233. package/dist/clojure-CCKyeQKf.js +0 -800
  234. package/dist/cmake-CuaCgAKt.js +0 -28
  235. package/dist/cobol-BlTKFDRj.js +0 -72
  236. package/dist/coffeescript-BVCvwO8I.js +0 -179
  237. package/dist/commonlisp-D_kxz07b.js +0 -75
  238. package/dist/crystal-D309uH6_.js +0 -217
  239. package/dist/css-BkF-NPzE.js +0 -1553
  240. package/dist/cypher-BMq4Fwjl.js +0 -68
  241. package/dist/d-BZcgY6La.js +0 -127
  242. package/dist/diff-Cg9d_RX2.js +0 -18
  243. package/dist/dockerfile-DIy8NleC.js +0 -194
  244. package/dist/dtd-CtLokQ-U.js +0 -84
  245. package/dist/dylan-QYeExnWK.js +0 -234
  246. package/dist/ebnf-DUPDuY4r.js +0 -78
  247. package/dist/ecl-CiXN-g_D.js +0 -121
  248. package/dist/eiffel-yQhjl4T1.js +0 -110
  249. package/dist/elm-CNT9vbN0.js +0 -108
  250. package/dist/erlang-CFOYdy9e.js +0 -487
  251. package/dist/factor-DDOC7X6P.js +0 -65
  252. package/dist/fcl-CPC2WYrI.js +0 -103
  253. package/dist/forth-BmxRyE9S.js +0 -60
  254. package/dist/fortran-9bvPyrOW.js +0 -442
  255. package/dist/gas-cpmYfFX2.js +0 -183
  256. package/dist/gherkin-CJuwpceU.js +0 -34
  257. package/dist/groovy-DZeT_VM-.js +0 -146
  258. package/dist/haskell-Bvt3Qq1t.js +0 -375
  259. package/dist/haxe-70NVW1pR.js +0 -359
  260. package/dist/http-D9LttvKF.js +0 -44
  261. package/dist/idl-B6TRFYjl.js +0 -947
  262. package/dist/index-4DWvmoYg.js +0 -71
  263. package/dist/index-52o7mJaX.js +0 -156
  264. package/dist/index-B0KatioT.js +0 -98
  265. package/dist/index-BP3W8zuk.js +0 -268
  266. package/dist/index-BykT5L1A.js +0 -148134
  267. package/dist/index-CfXo9hsG.js +0 -75
  268. package/dist/index-Ch37pBUt.js +0 -308
  269. package/dist/index-D2KGkAYT.js +0 -93
  270. package/dist/index-D83zQom_.js +0 -58
  271. package/dist/index-DuQrVLbu.js +0 -134
  272. package/dist/index-_fdMid5h.js +0 -288
  273. package/dist/index-a1wO-owY.js +0 -545
  274. package/dist/index-crMpNSFe.js +0 -611
  275. package/dist/index-dmBRpHHY.js +0 -137
  276. package/dist/index-kBdB14Fz.js +0 -341
  277. package/dist/index-uBhy41le.js +0 -249
  278. package/dist/index-zZrijNsr.js +0 -299
  279. package/dist/javascript-C2yteZeJ.js +0 -691
  280. package/dist/jinja2-DnB6dQmV.js +0 -154
  281. package/dist/julia-DpvXAuO6.js +0 -241
  282. package/dist/livescript-CanGTf8u.js +0 -272
  283. package/dist/lua-XplVlWi_.js +0 -217
  284. package/dist/mathematica-jaRHnSxC.js +0 -35
  285. package/dist/mbox-BctzC1hL.js +0 -76
  286. package/dist/mirc-CFBPAOaF.js +0 -72
  287. package/dist/mllike-BSnXJBGA.js +0 -272
  288. package/dist/modelica-vUgVs--1.js +0 -93
  289. package/dist/mscgen-Cpl0NYLN.js +0 -104
  290. package/dist/mumps-CQoS1kWX.js +0 -25
  291. package/dist/nginx-zDPm3Z74.js +0 -89
  292. package/dist/nsis-fePjrhq7.js +0 -62
  293. package/dist/ntriples-CsNjv2QF.js +0 -79
  294. package/dist/octave-C8PmmSRH.js +0 -143
  295. package/dist/oz-Ce8aN8oE.js +0 -151
  296. package/dist/pascal-De0D6mP7.js +0 -77
  297. package/dist/perl-B4bSCe1C.js +0 -915
  298. package/dist/pig-D24Z8EXi.js +0 -54
  299. package/dist/powershell-DkYVfTzP.js +0 -249
  300. package/dist/properties-Dn9wna3M.js +0 -26
  301. package/dist/protobuf-BPIjwpzm.js +0 -49
  302. package/dist/pug-CwAQJzGR.js +0 -248
  303. package/dist/puppet-nyd4dhjf.js +0 -45
  304. package/dist/python-BkR3uSy8.js +0 -313
  305. package/dist/q-DXjKs-tC.js +0 -83
  306. package/dist/r-LKEuhEGI.js +0 -104
  307. package/dist/rpm-IznJm2Xc.js +0 -57
  308. package/dist/ruby-CcYfvIk6.js +0 -228
  309. package/dist/sas-7E8yHoCW.js +0 -105
  310. package/dist/scheme-DjibxsNh.js +0 -124
  311. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts +0 -113
  312. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts.map +0 -1
  313. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts +0 -3
  314. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts.map +0 -1
  315. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts +0 -102
  316. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts.map +0 -1
  317. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts +0 -4
  318. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts.map +0 -1
  319. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts +0 -3
  320. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts.map +0 -1
  321. package/dist/shell-C0C2sNA_.js +0 -182
  322. package/dist/sieve-Bwz7vjP5.js +0 -72
  323. package/dist/simple-mode-B0dvCdAA.js +0 -89
  324. package/dist/smalltalk-Bhddl2pB.js +0 -48
  325. package/dist/solr-BNlsLglM.js +0 -41
  326. package/dist/sparql-FarWu_Gb.js +0 -197
  327. package/dist/spreadsheet-C-cy4P5N.js +0 -49
  328. package/dist/sql-CfG5lQ3l.js +0 -282
  329. package/dist/stex-Du4h4KAU.js +0 -129
  330. package/dist/stylus-CAdqWld3.js +0 -250
  331. package/dist/swift-DSxqR9R6.js +0 -230
  332. package/dist/tcl-xfoLljhY.js +0 -81
  333. package/dist/textile-D1AWE-pc.js +0 -295
  334. package/dist/tiddlywiki-5wqsXtSk.js +0 -155
  335. package/dist/tiki-__Kn3CeS.js +0 -181
  336. package/dist/toml-BHiuTcfn.js +0 -49
  337. package/dist/troff-D2UO-fKf.js +0 -35
  338. package/dist/ttcn-Bsa4sfRm.js +0 -123
  339. package/dist/ttcn-cfg-Bac_acMi.js +0 -88
  340. package/dist/turtle-xwJUxoPV.js +0 -80
  341. package/dist/ui/components/atoms/vc-icon/icons/AppWindowIcon.vue.d.ts +0 -7
  342. package/dist/ui/components/atoms/vc-icon/icons/AppWindowIcon.vue.d.ts.map +0 -1
  343. package/dist/ui/components/atoms/vc-icon/icons/ArrowLeftIcon.vue.d.ts +0 -7
  344. package/dist/ui/components/atoms/vc-icon/icons/ArrowLeftIcon.vue.d.ts.map +0 -1
  345. package/dist/ui/components/atoms/vc-icon/icons/ArrowRightIcon.vue.d.ts +0 -7
  346. package/dist/ui/components/atoms/vc-icon/icons/ArrowRightIcon.vue.d.ts.map +0 -1
  347. package/dist/ui/components/atoms/vc-icon/icons/BellIcon.vue.d.ts +0 -7
  348. package/dist/ui/components/atoms/vc-icon/icons/BellIcon.vue.d.ts.map +0 -1
  349. package/dist/ui/components/atoms/vc-icon/icons/ChevronDownIcon.vue.d.ts +0 -7
  350. package/dist/ui/components/atoms/vc-icon/icons/ChevronDownIcon.vue.d.ts.map +0 -1
  351. package/dist/ui/components/atoms/vc-icon/icons/ChevronLeftIcon.vue.d.ts +0 -7
  352. package/dist/ui/components/atoms/vc-icon/icons/ChevronLeftIcon.vue.d.ts.map +0 -1
  353. package/dist/ui/components/atoms/vc-icon/icons/ChevronRightIcon.vue.d.ts +0 -7
  354. package/dist/ui/components/atoms/vc-icon/icons/ChevronRightIcon.vue.d.ts.map +0 -1
  355. package/dist/ui/components/atoms/vc-icon/icons/ChevronUpIcon.vue.d.ts +0 -7
  356. package/dist/ui/components/atoms/vc-icon/icons/ChevronUpIcon.vue.d.ts.map +0 -1
  357. package/dist/ui/components/atoms/vc-icon/icons/CircleDotsIcon.vue.d.ts +0 -7
  358. package/dist/ui/components/atoms/vc-icon/icons/CircleDotsIcon.vue.d.ts.map +0 -1
  359. package/dist/ui/components/atoms/vc-icon/icons/CrossSignIcon.vue.d.ts +0 -7
  360. package/dist/ui/components/atoms/vc-icon/icons/CrossSignIcon.vue.d.ts.map +0 -1
  361. package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowLeftIcon.vue.d.ts +0 -7
  362. package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowLeftIcon.vue.d.ts.map +0 -1
  363. package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowRightIcon.vue.d.ts +0 -7
  364. package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowRightIcon.vue.d.ts.map +0 -1
  365. package/dist/ui/components/atoms/vc-icon/icons/FulfillmentCentersIcon.vue.d.ts +0 -7
  366. package/dist/ui/components/atoms/vc-icon/icons/FulfillmentCentersIcon.vue.d.ts.map +0 -1
  367. package/dist/ui/components/atoms/vc-icon/icons/GridDotsIcon.vue.d.ts +0 -7
  368. package/dist/ui/components/atoms/vc-icon/icons/GridDotsIcon.vue.d.ts.map +0 -1
  369. package/dist/ui/components/atoms/vc-icon/icons/LogoutIcon.vue.d.ts +0 -7
  370. package/dist/ui/components/atoms/vc-icon/icons/LogoutIcon.vue.d.ts.map +0 -1
  371. package/dist/ui/components/atoms/vc-icon/icons/MinusSignIcon.vue.d.ts +0 -7
  372. package/dist/ui/components/atoms/vc-icon/icons/MinusSignIcon.vue.d.ts.map +0 -1
  373. package/dist/ui/components/atoms/vc-icon/icons/OffersIcon.vue.d.ts +0 -7
  374. package/dist/ui/components/atoms/vc-icon/icons/OffersIcon.vue.d.ts.map +0 -1
  375. package/dist/ui/components/atoms/vc-icon/icons/OrdersIcon.vue.d.ts +0 -7
  376. package/dist/ui/components/atoms/vc-icon/icons/OrdersIcon.vue.d.ts.map +0 -1
  377. package/dist/ui/components/atoms/vc-icon/icons/PeopleIcon.vue.d.ts +0 -7
  378. package/dist/ui/components/atoms/vc-icon/icons/PeopleIcon.vue.d.ts.map +0 -1
  379. package/dist/ui/components/atoms/vc-icon/icons/PlusSignIcon.vue.d.ts +0 -7
  380. package/dist/ui/components/atoms/vc-icon/icons/PlusSignIcon.vue.d.ts.map +0 -1
  381. package/dist/ui/components/atoms/vc-icon/icons/ProductsIcon.vue.d.ts +0 -7
  382. package/dist/ui/components/atoms/vc-icon/icons/ProductsIcon.vue.d.ts.map +0 -1
  383. package/dist/ui/components/atoms/vc-icon/icons/ProfileIcon.vue.d.ts +0 -7
  384. package/dist/ui/components/atoms/vc-icon/icons/ProfileIcon.vue.d.ts.map +0 -1
  385. package/dist/ui/components/atoms/vc-icon/icons/SearchIcon.vue.d.ts +0 -7
  386. package/dist/ui/components/atoms/vc-icon/icons/SearchIcon.vue.d.ts.map +0 -1
  387. package/dist/ui/components/atoms/vc-icon/icons/SettingsBoltIcon.vue.d.ts +0 -7
  388. package/dist/ui/components/atoms/vc-icon/icons/SettingsBoltIcon.vue.d.ts.map +0 -1
  389. package/dist/ui/components/atoms/vc-icon/icons/ShoppingCardIcon.vue.d.ts +0 -7
  390. package/dist/ui/components/atoms/vc-icon/icons/ShoppingCardIcon.vue.d.ts.map +0 -1
  391. package/dist/ui/components/atoms/vc-icon/icons/VendorSwitchIcon.vue.d.ts +0 -7
  392. package/dist/ui/components/atoms/vc-icon/icons/VendorSwitchIcon.vue.d.ts.map +0 -1
  393. package/dist/ui/components/atoms/vc-icon/icons/VertDotsIcon.vue.d.ts +0 -7
  394. package/dist/ui/components/atoms/vc-icon/icons/VertDotsIcon.vue.d.ts.map +0 -1
  395. package/dist/vb-c2kQGd6-.js +0 -74
  396. package/dist/vbscript-1f_Dhg5H.js +0 -324
  397. package/dist/velocity-DJd0pTTC.js +0 -96
  398. package/dist/verilog-CiS1jyi5.js +0 -262
  399. package/dist/vhdl-T9HkrbI2.js +0 -106
  400. package/dist/webidl-CjfDENEo.js +0 -155
  401. package/dist/xquery-BUQdORAS.js +0 -422
  402. package/dist/yacas-C0absKBh.js +0 -73
  403. package/dist/z80-Pki2zAjW.js +0 -61
  404. package/shared/modules/dynamic/components/fields/storybook/Button.stories.ts +0 -186
  405. package/shared/modules/dynamic/components/fields/storybook/Card.stories.ts +0 -175
  406. package/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.ts +0 -185
  407. package/shared/modules/dynamic/components/fields/storybook/ContentField.stories.ts +0 -245
  408. package/shared/modules/dynamic/components/fields/storybook/EditorField.stories.ts +0 -192
  409. package/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.ts +0 -347
  410. package/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.ts +0 -239
  411. package/shared/modules/dynamic/components/fields/storybook/ImageField.stories.ts +0 -186
  412. package/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.ts +0 -281
  413. package/shared/modules/dynamic/components/fields/storybook/InputField.stories.ts +0 -312
  414. package/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.ts +0 -361
  415. package/shared/modules/dynamic/components/fields/storybook/RadioButtonGroup.stories.ts +0 -224
  416. package/shared/modules/dynamic/components/fields/storybook/RatingField.stories.ts +0 -131
  417. package/shared/modules/dynamic/components/fields/storybook/SelectField.stories.ts +0 -666
  418. package/shared/modules/dynamic/components/fields/storybook/StatusField.stories.ts +0 -202
  419. package/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.ts +0 -178
  420. package/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.ts +0 -203
  421. package/shared/modules/dynamic/components/fields/storybook/VideoField.stories.ts +0 -92
  422. package/shared/modules/dynamic/components/fields/storybook/common/args.ts +0 -130
  423. package/shared/modules/dynamic/components/fields/storybook/common/templates.ts +0 -8
  424. package/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.ts +0 -54
  425. package/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.ts +0 -16
  426. package/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.ts +0 -41
  427. package/ui/components/atoms/vc-icon/icons/AppWindowIcon.vue +0 -15
  428. package/ui/components/atoms/vc-icon/icons/ArrowLeftIcon.vue +0 -20
  429. package/ui/components/atoms/vc-icon/icons/ArrowRightIcon.vue +0 -13
  430. package/ui/components/atoms/vc-icon/icons/BellIcon.vue +0 -14
  431. package/ui/components/atoms/vc-icon/icons/ChevronDownIcon.vue +0 -13
  432. package/ui/components/atoms/vc-icon/icons/ChevronLeftIcon.vue +0 -13
  433. package/ui/components/atoms/vc-icon/icons/ChevronRightIcon.vue +0 -13
  434. package/ui/components/atoms/vc-icon/icons/ChevronUpIcon.vue +0 -13
  435. package/ui/components/atoms/vc-icon/icons/CircleDotsIcon.vue +0 -16
  436. package/ui/components/atoms/vc-icon/icons/CrossSignIcon.vue +0 -20
  437. package/ui/components/atoms/vc-icon/icons/DoubleArrowLeftIcon.vue +0 -14
  438. package/ui/components/atoms/vc-icon/icons/DoubleArrowRightIcon.vue +0 -14
  439. package/ui/components/atoms/vc-icon/icons/FulfillmentCentersIcon.vue +0 -27
  440. package/ui/components/atoms/vc-icon/icons/GridDotsIcon.vue +0 -22
  441. package/ui/components/atoms/vc-icon/icons/LogoutIcon.vue +0 -13
  442. package/ui/components/atoms/vc-icon/icons/MinusSignIcon.vue +0 -14
  443. package/ui/components/atoms/vc-icon/icons/OffersIcon.vue +0 -23
  444. package/ui/components/atoms/vc-icon/icons/OrdersIcon.vue +0 -19
  445. package/ui/components/atoms/vc-icon/icons/PeopleIcon.vue +0 -21
  446. package/ui/components/atoms/vc-icon/icons/PlusSignIcon.vue +0 -20
  447. package/ui/components/atoms/vc-icon/icons/ProductsIcon.vue +0 -23
  448. package/ui/components/atoms/vc-icon/icons/ProfileIcon.vue +0 -18
  449. package/ui/components/atoms/vc-icon/icons/SearchIcon.vue +0 -14
  450. package/ui/components/atoms/vc-icon/icons/SettingsBoltIcon.vue +0 -21
  451. package/ui/components/atoms/vc-icon/icons/ShoppingCardIcon.vue +0 -16
  452. package/ui/components/atoms/vc-icon/icons/VendorSwitchIcon.vue +0 -26
  453. package/ui/components/atoms/vc-icon/icons/VertDotsIcon.vue +0 -19
@@ -0,0 +1,2156 @@
1
+ import { S as Slice, F as Fragment, M as Mark, c as MarkType, R as ReplaceError } from './vendor-prosemirror-model-BZu3WVcD.js';
2
+
3
+ // Recovery values encode a range index and an offset. They are
4
+ // represented as numbers, because tons of them will be created when
5
+ // mapping, for example, a large number of decorations. The number's
6
+ // lower 16 bits provide the index, the remaining bits the offset.
7
+ //
8
+ // Note: We intentionally don't use bit shift operators to en- and
9
+ // decode these, since those clip to 32 bits, which we might in rare
10
+ // cases want to overflow. A 64-bit float can represent 48-bit
11
+ // integers precisely.
12
+ const lower16 = 0xffff;
13
+ const factor16 = Math.pow(2, 16);
14
+ function makeRecover(index, offset) { return index + offset * factor16; }
15
+ function recoverIndex(value) { return value & lower16; }
16
+ function recoverOffset(value) { return (value - (value & lower16)) / factor16; }
17
+ const DEL_BEFORE = 1, DEL_AFTER = 2, DEL_ACROSS = 4, DEL_SIDE = 8;
18
+ /**
19
+ An object representing a mapped position with extra
20
+ information.
21
+ */
22
+ class MapResult {
23
+ /**
24
+ @internal
25
+ */
26
+ constructor(
27
+ /**
28
+ The mapped version of the position.
29
+ */
30
+ pos,
31
+ /**
32
+ @internal
33
+ */
34
+ delInfo,
35
+ /**
36
+ @internal
37
+ */
38
+ recover) {
39
+ this.pos = pos;
40
+ this.delInfo = delInfo;
41
+ this.recover = recover;
42
+ }
43
+ /**
44
+ Tells you whether the position was deleted, that is, whether the
45
+ step removed the token on the side queried (via the `assoc`)
46
+ argument from the document.
47
+ */
48
+ get deleted() { return (this.delInfo & DEL_SIDE) > 0; }
49
+ /**
50
+ Tells you whether the token before the mapped position was deleted.
51
+ */
52
+ get deletedBefore() { return (this.delInfo & (DEL_BEFORE | DEL_ACROSS)) > 0; }
53
+ /**
54
+ True when the token after the mapped position was deleted.
55
+ */
56
+ get deletedAfter() { return (this.delInfo & (DEL_AFTER | DEL_ACROSS)) > 0; }
57
+ /**
58
+ Tells whether any of the steps mapped through deletes across the
59
+ position (including both the token before and after the
60
+ position).
61
+ */
62
+ get deletedAcross() { return (this.delInfo & DEL_ACROSS) > 0; }
63
+ }
64
+ /**
65
+ A map describing the deletions and insertions made by a step, which
66
+ can be used to find the correspondence between positions in the
67
+ pre-step version of a document and the same position in the
68
+ post-step version.
69
+ */
70
+ class StepMap {
71
+ /**
72
+ Create a position map. The modifications to the document are
73
+ represented as an array of numbers, in which each group of three
74
+ represents a modified chunk as `[start, oldSize, newSize]`.
75
+ */
76
+ constructor(
77
+ /**
78
+ @internal
79
+ */
80
+ ranges,
81
+ /**
82
+ @internal
83
+ */
84
+ inverted = false) {
85
+ this.ranges = ranges;
86
+ this.inverted = inverted;
87
+ if (!ranges.length && StepMap.empty)
88
+ return StepMap.empty;
89
+ }
90
+ /**
91
+ @internal
92
+ */
93
+ recover(value) {
94
+ let diff = 0, index = recoverIndex(value);
95
+ if (!this.inverted)
96
+ for (let i = 0; i < index; i++)
97
+ diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
98
+ return this.ranges[index * 3] + diff + recoverOffset(value);
99
+ }
100
+ mapResult(pos, assoc = 1) { return this._map(pos, assoc, false); }
101
+ map(pos, assoc = 1) { return this._map(pos, assoc, true); }
102
+ /**
103
+ @internal
104
+ */
105
+ _map(pos, assoc, simple) {
106
+ let diff = 0, oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
107
+ for (let i = 0; i < this.ranges.length; i += 3) {
108
+ let start = this.ranges[i] - (this.inverted ? diff : 0);
109
+ if (start > pos)
110
+ break;
111
+ let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex], end = start + oldSize;
112
+ if (pos <= end) {
113
+ let side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;
114
+ let result = start + diff + (side < 0 ? 0 : newSize);
115
+ if (simple)
116
+ return result;
117
+ let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
118
+ let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
119
+ if (assoc < 0 ? pos != start : pos != end)
120
+ del |= DEL_SIDE;
121
+ return new MapResult(result, del, recover);
122
+ }
123
+ diff += newSize - oldSize;
124
+ }
125
+ return simple ? pos + diff : new MapResult(pos + diff, 0, null);
126
+ }
127
+ /**
128
+ @internal
129
+ */
130
+ touches(pos, recover) {
131
+ let diff = 0, index = recoverIndex(recover);
132
+ let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
133
+ for (let i = 0; i < this.ranges.length; i += 3) {
134
+ let start = this.ranges[i] - (this.inverted ? diff : 0);
135
+ if (start > pos)
136
+ break;
137
+ let oldSize = this.ranges[i + oldIndex], end = start + oldSize;
138
+ if (pos <= end && i == index * 3)
139
+ return true;
140
+ diff += this.ranges[i + newIndex] - oldSize;
141
+ }
142
+ return false;
143
+ }
144
+ /**
145
+ Calls the given function on each of the changed ranges included in
146
+ this map.
147
+ */
148
+ forEach(f) {
149
+ let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
150
+ for (let i = 0, diff = 0; i < this.ranges.length; i += 3) {
151
+ let start = this.ranges[i], oldStart = start - (this.inverted ? diff : 0), newStart = start + (this.inverted ? 0 : diff);
152
+ let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex];
153
+ f(oldStart, oldStart + oldSize, newStart, newStart + newSize);
154
+ diff += newSize - oldSize;
155
+ }
156
+ }
157
+ /**
158
+ Create an inverted version of this map. The result can be used to
159
+ map positions in the post-step document to the pre-step document.
160
+ */
161
+ invert() {
162
+ return new StepMap(this.ranges, !this.inverted);
163
+ }
164
+ /**
165
+ @internal
166
+ */
167
+ toString() {
168
+ return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
169
+ }
170
+ /**
171
+ Create a map that moves all positions by offset `n` (which may be
172
+ negative). This can be useful when applying steps meant for a
173
+ sub-document to a larger document, or vice-versa.
174
+ */
175
+ static offset(n) {
176
+ return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);
177
+ }
178
+ }
179
+ /**
180
+ A StepMap that contains no changed ranges.
181
+ */
182
+ StepMap.empty = new StepMap([]);
183
+ /**
184
+ A mapping represents a pipeline of zero or more [step
185
+ maps](https://prosemirror.net/docs/ref/#transform.StepMap). It has special provisions for losslessly
186
+ handling mapping positions through a series of steps in which some
187
+ steps are inverted versions of earlier steps. (This comes up when
188
+ ‘[rebasing](https://prosemirror.net/docs/guide/#transform.rebasing)’ steps for
189
+ collaboration or history management.)
190
+ */
191
+ class Mapping {
192
+ /**
193
+ Create a new mapping with the given position maps.
194
+ */
195
+ constructor(maps,
196
+ /**
197
+ @internal
198
+ */
199
+ mirror,
200
+ /**
201
+ The starting position in the `maps` array, used when `map` or
202
+ `mapResult` is called.
203
+ */
204
+ from = 0,
205
+ /**
206
+ The end position in the `maps` array.
207
+ */
208
+ to = maps ? maps.length : 0) {
209
+ this.mirror = mirror;
210
+ this.from = from;
211
+ this.to = to;
212
+ this._maps = maps || [];
213
+ this.ownData = !(maps || mirror);
214
+ }
215
+ /**
216
+ The step maps in this mapping.
217
+ */
218
+ get maps() { return this._maps; }
219
+ /**
220
+ Create a mapping that maps only through a part of this one.
221
+ */
222
+ slice(from = 0, to = this.maps.length) {
223
+ return new Mapping(this._maps, this.mirror, from, to);
224
+ }
225
+ /**
226
+ Add a step map to the end of this mapping. If `mirrors` is
227
+ given, it should be the index of the step map that is the mirror
228
+ image of this one.
229
+ */
230
+ appendMap(map, mirrors) {
231
+ if (!this.ownData) {
232
+ this._maps = this._maps.slice();
233
+ this.mirror = this.mirror && this.mirror.slice();
234
+ this.ownData = true;
235
+ }
236
+ this.to = this._maps.push(map);
237
+ if (mirrors != null)
238
+ this.setMirror(this._maps.length - 1, mirrors);
239
+ }
240
+ /**
241
+ Add all the step maps in a given mapping to this one (preserving
242
+ mirroring information).
243
+ */
244
+ appendMapping(mapping) {
245
+ for (let i = 0, startSize = this._maps.length; i < mapping._maps.length; i++) {
246
+ let mirr = mapping.getMirror(i);
247
+ this.appendMap(mapping._maps[i], mirr != null && mirr < i ? startSize + mirr : undefined);
248
+ }
249
+ }
250
+ /**
251
+ Finds the offset of the step map that mirrors the map at the
252
+ given offset, in this mapping (as per the second argument to
253
+ `appendMap`).
254
+ */
255
+ getMirror(n) {
256
+ if (this.mirror)
257
+ for (let i = 0; i < this.mirror.length; i++)
258
+ if (this.mirror[i] == n)
259
+ return this.mirror[i + (i % 2 ? -1 : 1)];
260
+ }
261
+ /**
262
+ @internal
263
+ */
264
+ setMirror(n, m) {
265
+ if (!this.mirror)
266
+ this.mirror = [];
267
+ this.mirror.push(n, m);
268
+ }
269
+ /**
270
+ Append the inverse of the given mapping to this one.
271
+ */
272
+ appendMappingInverted(mapping) {
273
+ for (let i = mapping.maps.length - 1, totalSize = this._maps.length + mapping._maps.length; i >= 0; i--) {
274
+ let mirr = mapping.getMirror(i);
275
+ this.appendMap(mapping._maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : undefined);
276
+ }
277
+ }
278
+ /**
279
+ Create an inverted version of this mapping.
280
+ */
281
+ invert() {
282
+ let inverse = new Mapping;
283
+ inverse.appendMappingInverted(this);
284
+ return inverse;
285
+ }
286
+ /**
287
+ Map a position through this mapping.
288
+ */
289
+ map(pos, assoc = 1) {
290
+ if (this.mirror)
291
+ return this._map(pos, assoc, true);
292
+ for (let i = this.from; i < this.to; i++)
293
+ pos = this._maps[i].map(pos, assoc);
294
+ return pos;
295
+ }
296
+ /**
297
+ Map a position through this mapping, returning a mapping
298
+ result.
299
+ */
300
+ mapResult(pos, assoc = 1) { return this._map(pos, assoc, false); }
301
+ /**
302
+ @internal
303
+ */
304
+ _map(pos, assoc, simple) {
305
+ let delInfo = 0;
306
+ for (let i = this.from; i < this.to; i++) {
307
+ let map = this._maps[i], result = map.mapResult(pos, assoc);
308
+ if (result.recover != null) {
309
+ let corr = this.getMirror(i);
310
+ if (corr != null && corr > i && corr < this.to) {
311
+ i = corr;
312
+ pos = this._maps[corr].recover(result.recover);
313
+ continue;
314
+ }
315
+ }
316
+ delInfo |= result.delInfo;
317
+ pos = result.pos;
318
+ }
319
+ return simple ? pos : new MapResult(pos, delInfo, null);
320
+ }
321
+ }
322
+
323
+ const stepsByID = Object.create(null);
324
+ /**
325
+ A step object represents an atomic change. It generally applies
326
+ only to the document it was created for, since the positions
327
+ stored in it will only make sense for that document.
328
+
329
+ New steps are defined by creating classes that extend `Step`,
330
+ overriding the `apply`, `invert`, `map`, `getMap` and `fromJSON`
331
+ methods, and registering your class with a unique
332
+ JSON-serialization identifier using
333
+ [`Step.jsonID`](https://prosemirror.net/docs/ref/#transform.Step^jsonID).
334
+ */
335
+ class Step {
336
+ /**
337
+ Get the step map that represents the changes made by this step,
338
+ and which can be used to transform between positions in the old
339
+ and the new document.
340
+ */
341
+ getMap() { return StepMap.empty; }
342
+ /**
343
+ Try to merge this step with another one, to be applied directly
344
+ after it. Returns the merged step when possible, null if the
345
+ steps can't be merged.
346
+ */
347
+ merge(other) { return null; }
348
+ /**
349
+ Deserialize a step from its JSON representation. Will call
350
+ through to the step class' own implementation of this method.
351
+ */
352
+ static fromJSON(schema, json) {
353
+ if (!json || !json.stepType)
354
+ throw new RangeError("Invalid input for Step.fromJSON");
355
+ let type = stepsByID[json.stepType];
356
+ if (!type)
357
+ throw new RangeError(`No step type ${json.stepType} defined`);
358
+ return type.fromJSON(schema, json);
359
+ }
360
+ /**
361
+ To be able to serialize steps to JSON, each step needs a string
362
+ ID to attach to its JSON representation. Use this method to
363
+ register an ID for your step classes. Try to pick something
364
+ that's unlikely to clash with steps from other modules.
365
+ */
366
+ static jsonID(id, stepClass) {
367
+ if (id in stepsByID)
368
+ throw new RangeError("Duplicate use of step JSON ID " + id);
369
+ stepsByID[id] = stepClass;
370
+ stepClass.prototype.jsonID = id;
371
+ return stepClass;
372
+ }
373
+ }
374
+ /**
375
+ The result of [applying](https://prosemirror.net/docs/ref/#transform.Step.apply) a step. Contains either a
376
+ new document or a failure value.
377
+ */
378
+ class StepResult {
379
+ /**
380
+ @internal
381
+ */
382
+ constructor(
383
+ /**
384
+ The transformed document, if successful.
385
+ */
386
+ doc,
387
+ /**
388
+ The failure message, if unsuccessful.
389
+ */
390
+ failed) {
391
+ this.doc = doc;
392
+ this.failed = failed;
393
+ }
394
+ /**
395
+ Create a successful step result.
396
+ */
397
+ static ok(doc) { return new StepResult(doc, null); }
398
+ /**
399
+ Create a failed step result.
400
+ */
401
+ static fail(message) { return new StepResult(null, message); }
402
+ /**
403
+ Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
404
+ arguments. Create a successful result if it succeeds, and a
405
+ failed one if it throws a `ReplaceError`.
406
+ */
407
+ static fromReplace(doc, from, to, slice) {
408
+ try {
409
+ return StepResult.ok(doc.replace(from, to, slice));
410
+ }
411
+ catch (e) {
412
+ if (e instanceof ReplaceError)
413
+ return StepResult.fail(e.message);
414
+ throw e;
415
+ }
416
+ }
417
+ }
418
+
419
+ function mapFragment(fragment, f, parent) {
420
+ let mapped = [];
421
+ for (let i = 0; i < fragment.childCount; i++) {
422
+ let child = fragment.child(i);
423
+ if (child.content.size)
424
+ child = child.copy(mapFragment(child.content, f, child));
425
+ if (child.isInline)
426
+ child = f(child, parent, i);
427
+ mapped.push(child);
428
+ }
429
+ return Fragment.fromArray(mapped);
430
+ }
431
+ /**
432
+ Add a mark to all inline content between two positions.
433
+ */
434
+ class AddMarkStep extends Step {
435
+ /**
436
+ Create a mark step.
437
+ */
438
+ constructor(
439
+ /**
440
+ The start of the marked range.
441
+ */
442
+ from,
443
+ /**
444
+ The end of the marked range.
445
+ */
446
+ to,
447
+ /**
448
+ The mark to add.
449
+ */
450
+ mark) {
451
+ super();
452
+ this.from = from;
453
+ this.to = to;
454
+ this.mark = mark;
455
+ }
456
+ apply(doc) {
457
+ let oldSlice = doc.slice(this.from, this.to), $from = doc.resolve(this.from);
458
+ let parent = $from.node($from.sharedDepth(this.to));
459
+ let slice = new Slice(mapFragment(oldSlice.content, (node, parent) => {
460
+ if (!node.isAtom || !parent.type.allowsMarkType(this.mark.type))
461
+ return node;
462
+ return node.mark(this.mark.addToSet(node.marks));
463
+ }, parent), oldSlice.openStart, oldSlice.openEnd);
464
+ return StepResult.fromReplace(doc, this.from, this.to, slice);
465
+ }
466
+ invert() {
467
+ return new RemoveMarkStep(this.from, this.to, this.mark);
468
+ }
469
+ map(mapping) {
470
+ let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
471
+ if (from.deleted && to.deleted || from.pos >= to.pos)
472
+ return null;
473
+ return new AddMarkStep(from.pos, to.pos, this.mark);
474
+ }
475
+ merge(other) {
476
+ if (other instanceof AddMarkStep &&
477
+ other.mark.eq(this.mark) &&
478
+ this.from <= other.to && this.to >= other.from)
479
+ return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
480
+ return null;
481
+ }
482
+ toJSON() {
483
+ return { stepType: "addMark", mark: this.mark.toJSON(),
484
+ from: this.from, to: this.to };
485
+ }
486
+ /**
487
+ @internal
488
+ */
489
+ static fromJSON(schema, json) {
490
+ if (typeof json.from != "number" || typeof json.to != "number")
491
+ throw new RangeError("Invalid input for AddMarkStep.fromJSON");
492
+ return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
493
+ }
494
+ }
495
+ Step.jsonID("addMark", AddMarkStep);
496
+ /**
497
+ Remove a mark from all inline content between two positions.
498
+ */
499
+ class RemoveMarkStep extends Step {
500
+ /**
501
+ Create a mark-removing step.
502
+ */
503
+ constructor(
504
+ /**
505
+ The start of the unmarked range.
506
+ */
507
+ from,
508
+ /**
509
+ The end of the unmarked range.
510
+ */
511
+ to,
512
+ /**
513
+ The mark to remove.
514
+ */
515
+ mark) {
516
+ super();
517
+ this.from = from;
518
+ this.to = to;
519
+ this.mark = mark;
520
+ }
521
+ apply(doc) {
522
+ let oldSlice = doc.slice(this.from, this.to);
523
+ let slice = new Slice(mapFragment(oldSlice.content, node => {
524
+ return node.mark(this.mark.removeFromSet(node.marks));
525
+ }, doc), oldSlice.openStart, oldSlice.openEnd);
526
+ return StepResult.fromReplace(doc, this.from, this.to, slice);
527
+ }
528
+ invert() {
529
+ return new AddMarkStep(this.from, this.to, this.mark);
530
+ }
531
+ map(mapping) {
532
+ let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
533
+ if (from.deleted && to.deleted || from.pos >= to.pos)
534
+ return null;
535
+ return new RemoveMarkStep(from.pos, to.pos, this.mark);
536
+ }
537
+ merge(other) {
538
+ if (other instanceof RemoveMarkStep &&
539
+ other.mark.eq(this.mark) &&
540
+ this.from <= other.to && this.to >= other.from)
541
+ return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
542
+ return null;
543
+ }
544
+ toJSON() {
545
+ return { stepType: "removeMark", mark: this.mark.toJSON(),
546
+ from: this.from, to: this.to };
547
+ }
548
+ /**
549
+ @internal
550
+ */
551
+ static fromJSON(schema, json) {
552
+ if (typeof json.from != "number" || typeof json.to != "number")
553
+ throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
554
+ return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
555
+ }
556
+ }
557
+ Step.jsonID("removeMark", RemoveMarkStep);
558
+ /**
559
+ Add a mark to a specific node.
560
+ */
561
+ class AddNodeMarkStep extends Step {
562
+ /**
563
+ Create a node mark step.
564
+ */
565
+ constructor(
566
+ /**
567
+ The position of the target node.
568
+ */
569
+ pos,
570
+ /**
571
+ The mark to add.
572
+ */
573
+ mark) {
574
+ super();
575
+ this.pos = pos;
576
+ this.mark = mark;
577
+ }
578
+ apply(doc) {
579
+ let node = doc.nodeAt(this.pos);
580
+ if (!node)
581
+ return StepResult.fail("No node at mark step's position");
582
+ let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
583
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
584
+ }
585
+ invert(doc) {
586
+ let node = doc.nodeAt(this.pos);
587
+ if (node) {
588
+ let newSet = this.mark.addToSet(node.marks);
589
+ if (newSet.length == node.marks.length) {
590
+ for (let i = 0; i < node.marks.length; i++)
591
+ if (!node.marks[i].isInSet(newSet))
592
+ return new AddNodeMarkStep(this.pos, node.marks[i]);
593
+ return new AddNodeMarkStep(this.pos, this.mark);
594
+ }
595
+ }
596
+ return new RemoveNodeMarkStep(this.pos, this.mark);
597
+ }
598
+ map(mapping) {
599
+ let pos = mapping.mapResult(this.pos, 1);
600
+ return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);
601
+ }
602
+ toJSON() {
603
+ return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
604
+ }
605
+ /**
606
+ @internal
607
+ */
608
+ static fromJSON(schema, json) {
609
+ if (typeof json.pos != "number")
610
+ throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
611
+ return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
612
+ }
613
+ }
614
+ Step.jsonID("addNodeMark", AddNodeMarkStep);
615
+ /**
616
+ Remove a mark from a specific node.
617
+ */
618
+ class RemoveNodeMarkStep extends Step {
619
+ /**
620
+ Create a mark-removing step.
621
+ */
622
+ constructor(
623
+ /**
624
+ The position of the target node.
625
+ */
626
+ pos,
627
+ /**
628
+ The mark to remove.
629
+ */
630
+ mark) {
631
+ super();
632
+ this.pos = pos;
633
+ this.mark = mark;
634
+ }
635
+ apply(doc) {
636
+ let node = doc.nodeAt(this.pos);
637
+ if (!node)
638
+ return StepResult.fail("No node at mark step's position");
639
+ let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
640
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
641
+ }
642
+ invert(doc) {
643
+ let node = doc.nodeAt(this.pos);
644
+ if (!node || !this.mark.isInSet(node.marks))
645
+ return this;
646
+ return new AddNodeMarkStep(this.pos, this.mark);
647
+ }
648
+ map(mapping) {
649
+ let pos = mapping.mapResult(this.pos, 1);
650
+ return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);
651
+ }
652
+ toJSON() {
653
+ return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
654
+ }
655
+ /**
656
+ @internal
657
+ */
658
+ static fromJSON(schema, json) {
659
+ if (typeof json.pos != "number")
660
+ throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
661
+ return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
662
+ }
663
+ }
664
+ Step.jsonID("removeNodeMark", RemoveNodeMarkStep);
665
+
666
+ /**
667
+ Replace a part of the document with a slice of new content.
668
+ */
669
+ class ReplaceStep extends Step {
670
+ /**
671
+ The given `slice` should fit the 'gap' between `from` and
672
+ `to`—the depths must line up, and the surrounding nodes must be
673
+ able to be joined with the open sides of the slice. When
674
+ `structure` is true, the step will fail if the content between
675
+ from and to is not just a sequence of closing and then opening
676
+ tokens (this is to guard against rebased replace steps
677
+ overwriting something they weren't supposed to).
678
+ */
679
+ constructor(
680
+ /**
681
+ The start position of the replaced range.
682
+ */
683
+ from,
684
+ /**
685
+ The end position of the replaced range.
686
+ */
687
+ to,
688
+ /**
689
+ The slice to insert.
690
+ */
691
+ slice,
692
+ /**
693
+ @internal
694
+ */
695
+ structure = false) {
696
+ super();
697
+ this.from = from;
698
+ this.to = to;
699
+ this.slice = slice;
700
+ this.structure = structure;
701
+ }
702
+ apply(doc) {
703
+ if (this.structure && contentBetween(doc, this.from, this.to))
704
+ return StepResult.fail("Structure replace would overwrite content");
705
+ return StepResult.fromReplace(doc, this.from, this.to, this.slice);
706
+ }
707
+ getMap() {
708
+ return new StepMap([this.from, this.to - this.from, this.slice.size]);
709
+ }
710
+ invert(doc) {
711
+ return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
712
+ }
713
+ map(mapping) {
714
+ let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
715
+ if (from.deletedAcross && to.deletedAcross)
716
+ return null;
717
+ return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
718
+ }
719
+ merge(other) {
720
+ if (!(other instanceof ReplaceStep) || other.structure || this.structure)
721
+ return null;
722
+ if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {
723
+ let slice = this.slice.size + other.slice.size == 0 ? Slice.empty
724
+ : new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);
725
+ return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);
726
+ }
727
+ else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {
728
+ let slice = this.slice.size + other.slice.size == 0 ? Slice.empty
729
+ : new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);
730
+ return new ReplaceStep(other.from, this.to, slice, this.structure);
731
+ }
732
+ else {
733
+ return null;
734
+ }
735
+ }
736
+ toJSON() {
737
+ let json = { stepType: "replace", from: this.from, to: this.to };
738
+ if (this.slice.size)
739
+ json.slice = this.slice.toJSON();
740
+ if (this.structure)
741
+ json.structure = true;
742
+ return json;
743
+ }
744
+ /**
745
+ @internal
746
+ */
747
+ static fromJSON(schema, json) {
748
+ if (typeof json.from != "number" || typeof json.to != "number")
749
+ throw new RangeError("Invalid input for ReplaceStep.fromJSON");
750
+ return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
751
+ }
752
+ }
753
+ Step.jsonID("replace", ReplaceStep);
754
+ /**
755
+ Replace a part of the document with a slice of content, but
756
+ preserve a range of the replaced content by moving it into the
757
+ slice.
758
+ */
759
+ class ReplaceAroundStep extends Step {
760
+ /**
761
+ Create a replace-around step with the given range and gap.
762
+ `insert` should be the point in the slice into which the content
763
+ of the gap should be moved. `structure` has the same meaning as
764
+ it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
765
+ */
766
+ constructor(
767
+ /**
768
+ The start position of the replaced range.
769
+ */
770
+ from,
771
+ /**
772
+ The end position of the replaced range.
773
+ */
774
+ to,
775
+ /**
776
+ The start of preserved range.
777
+ */
778
+ gapFrom,
779
+ /**
780
+ The end of preserved range.
781
+ */
782
+ gapTo,
783
+ /**
784
+ The slice to insert.
785
+ */
786
+ slice,
787
+ /**
788
+ The position in the slice where the preserved range should be
789
+ inserted.
790
+ */
791
+ insert,
792
+ /**
793
+ @internal
794
+ */
795
+ structure = false) {
796
+ super();
797
+ this.from = from;
798
+ this.to = to;
799
+ this.gapFrom = gapFrom;
800
+ this.gapTo = gapTo;
801
+ this.slice = slice;
802
+ this.insert = insert;
803
+ this.structure = structure;
804
+ }
805
+ apply(doc) {
806
+ if (this.structure && (contentBetween(doc, this.from, this.gapFrom) ||
807
+ contentBetween(doc, this.gapTo, this.to)))
808
+ return StepResult.fail("Structure gap-replace would overwrite content");
809
+ let gap = doc.slice(this.gapFrom, this.gapTo);
810
+ if (gap.openStart || gap.openEnd)
811
+ return StepResult.fail("Gap is not a flat range");
812
+ let inserted = this.slice.insertAt(this.insert, gap.content);
813
+ if (!inserted)
814
+ return StepResult.fail("Content does not fit in gap");
815
+ return StepResult.fromReplace(doc, this.from, this.to, inserted);
816
+ }
817
+ getMap() {
818
+ return new StepMap([this.from, this.gapFrom - this.from, this.insert,
819
+ this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);
820
+ }
821
+ invert(doc) {
822
+ let gap = this.gapTo - this.gapFrom;
823
+ return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
824
+ }
825
+ map(mapping) {
826
+ let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
827
+ let gapFrom = this.from == this.gapFrom ? from.pos : mapping.map(this.gapFrom, -1);
828
+ let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
829
+ if ((from.deletedAcross && to.deletedAcross) || gapFrom < from.pos || gapTo > to.pos)
830
+ return null;
831
+ return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
832
+ }
833
+ toJSON() {
834
+ let json = { stepType: "replaceAround", from: this.from, to: this.to,
835
+ gapFrom: this.gapFrom, gapTo: this.gapTo, insert: this.insert };
836
+ if (this.slice.size)
837
+ json.slice = this.slice.toJSON();
838
+ if (this.structure)
839
+ json.structure = true;
840
+ return json;
841
+ }
842
+ /**
843
+ @internal
844
+ */
845
+ static fromJSON(schema, json) {
846
+ if (typeof json.from != "number" || typeof json.to != "number" ||
847
+ typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
848
+ throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
849
+ return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
850
+ }
851
+ }
852
+ Step.jsonID("replaceAround", ReplaceAroundStep);
853
+ function contentBetween(doc, from, to) {
854
+ let $from = doc.resolve(from), dist = to - from, depth = $from.depth;
855
+ while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
856
+ depth--;
857
+ dist--;
858
+ }
859
+ if (dist > 0) {
860
+ let next = $from.node(depth).maybeChild($from.indexAfter(depth));
861
+ while (dist > 0) {
862
+ if (!next || next.isLeaf)
863
+ return true;
864
+ next = next.firstChild;
865
+ dist--;
866
+ }
867
+ }
868
+ return false;
869
+ }
870
+
871
+ function addMark(tr, from, to, mark) {
872
+ let removed = [], added = [];
873
+ let removing, adding;
874
+ tr.doc.nodesBetween(from, to, (node, pos, parent) => {
875
+ if (!node.isInline)
876
+ return;
877
+ let marks = node.marks;
878
+ if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {
879
+ let start = Math.max(pos, from), end = Math.min(pos + node.nodeSize, to);
880
+ let newSet = mark.addToSet(marks);
881
+ for (let i = 0; i < marks.length; i++) {
882
+ if (!marks[i].isInSet(newSet)) {
883
+ if (removing && removing.to == start && removing.mark.eq(marks[i]))
884
+ removing.to = end;
885
+ else
886
+ removed.push(removing = new RemoveMarkStep(start, end, marks[i]));
887
+ }
888
+ }
889
+ if (adding && adding.to == start)
890
+ adding.to = end;
891
+ else
892
+ added.push(adding = new AddMarkStep(start, end, mark));
893
+ }
894
+ });
895
+ removed.forEach(s => tr.step(s));
896
+ added.forEach(s => tr.step(s));
897
+ }
898
+ function removeMark(tr, from, to, mark) {
899
+ let matched = [], step = 0;
900
+ tr.doc.nodesBetween(from, to, (node, pos) => {
901
+ if (!node.isInline)
902
+ return;
903
+ step++;
904
+ let toRemove = null;
905
+ if (mark instanceof MarkType) {
906
+ let set = node.marks, found;
907
+ while (found = mark.isInSet(set)) {
908
+ (toRemove || (toRemove = [])).push(found);
909
+ set = found.removeFromSet(set);
910
+ }
911
+ }
912
+ else if (mark) {
913
+ if (mark.isInSet(node.marks))
914
+ toRemove = [mark];
915
+ }
916
+ else {
917
+ toRemove = node.marks;
918
+ }
919
+ if (toRemove && toRemove.length) {
920
+ let end = Math.min(pos + node.nodeSize, to);
921
+ for (let i = 0; i < toRemove.length; i++) {
922
+ let style = toRemove[i], found;
923
+ for (let j = 0; j < matched.length; j++) {
924
+ let m = matched[j];
925
+ if (m.step == step - 1 && style.eq(matched[j].style))
926
+ found = m;
927
+ }
928
+ if (found) {
929
+ found.to = end;
930
+ found.step = step;
931
+ }
932
+ else {
933
+ matched.push({ style, from: Math.max(pos, from), to: end, step });
934
+ }
935
+ }
936
+ }
937
+ });
938
+ matched.forEach(m => tr.step(new RemoveMarkStep(m.from, m.to, m.style)));
939
+ }
940
+ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch, clearNewlines = true) {
941
+ let node = tr.doc.nodeAt(pos);
942
+ let replSteps = [], cur = pos + 1;
943
+ for (let i = 0; i < node.childCount; i++) {
944
+ let child = node.child(i), end = cur + child.nodeSize;
945
+ let allowed = match.matchType(child.type);
946
+ if (!allowed) {
947
+ replSteps.push(new ReplaceStep(cur, end, Slice.empty));
948
+ }
949
+ else {
950
+ match = allowed;
951
+ for (let j = 0; j < child.marks.length; j++)
952
+ if (!parentType.allowsMarkType(child.marks[j].type))
953
+ tr.step(new RemoveMarkStep(cur, end, child.marks[j]));
954
+ if (clearNewlines && child.isText && parentType.whitespace != "pre") {
955
+ let m, newline = /\r?\n|\r/g, slice;
956
+ while (m = newline.exec(child.text)) {
957
+ if (!slice)
958
+ slice = new Slice(Fragment.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
959
+ replSteps.push(new ReplaceStep(cur + m.index, cur + m.index + m[0].length, slice));
960
+ }
961
+ }
962
+ }
963
+ cur = end;
964
+ }
965
+ if (!match.validEnd) {
966
+ let fill = match.fillBefore(Fragment.empty, true);
967
+ tr.replace(cur, cur, new Slice(fill, 0, 0));
968
+ }
969
+ for (let i = replSteps.length - 1; i >= 0; i--)
970
+ tr.step(replSteps[i]);
971
+ }
972
+
973
+ function canCut(node, start, end) {
974
+ return (start == 0 || node.canReplace(start, node.childCount)) &&
975
+ (end == node.childCount || node.canReplace(0, end));
976
+ }
977
+ /**
978
+ Try to find a target depth to which the content in the given range
979
+ can be lifted. Will not go across
980
+ [isolating](https://prosemirror.net/docs/ref/#model.NodeSpec.isolating) parent nodes.
981
+ */
982
+ function liftTarget(range) {
983
+ let parent = range.parent;
984
+ let content = parent.content.cutByIndex(range.startIndex, range.endIndex);
985
+ for (let depth = range.depth;; --depth) {
986
+ let node = range.$from.node(depth);
987
+ let index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth);
988
+ if (depth < range.depth && node.canReplace(index, endIndex, content))
989
+ return depth;
990
+ if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))
991
+ break;
992
+ }
993
+ return null;
994
+ }
995
+ function lift(tr, range, target) {
996
+ let { $from, $to, depth } = range;
997
+ let gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);
998
+ let start = gapStart, end = gapEnd;
999
+ let before = Fragment.empty, openStart = 0;
1000
+ for (let d = depth, splitting = false; d > target; d--)
1001
+ if (splitting || $from.index(d) > 0) {
1002
+ splitting = true;
1003
+ before = Fragment.from($from.node(d).copy(before));
1004
+ openStart++;
1005
+ }
1006
+ else {
1007
+ start--;
1008
+ }
1009
+ let after = Fragment.empty, openEnd = 0;
1010
+ for (let d = depth, splitting = false; d > target; d--)
1011
+ if (splitting || $to.after(d + 1) < $to.end(d)) {
1012
+ splitting = true;
1013
+ after = Fragment.from($to.node(d).copy(after));
1014
+ openEnd++;
1015
+ }
1016
+ else {
1017
+ end++;
1018
+ }
1019
+ tr.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
1020
+ }
1021
+ /**
1022
+ Try to find a valid way to wrap the content in the given range in a
1023
+ node of the given type. May introduce extra nodes around and inside
1024
+ the wrapper node, if necessary. Returns null if no valid wrapping
1025
+ could be found. When `innerRange` is given, that range's content is
1026
+ used as the content to fit into the wrapping, instead of the
1027
+ content of `range`.
1028
+ */
1029
+ function findWrapping(range, nodeType, attrs = null, innerRange = range) {
1030
+ let around = findWrappingOutside(range, nodeType);
1031
+ let inner = around && findWrappingInside(innerRange, nodeType);
1032
+ if (!inner)
1033
+ return null;
1034
+ return around.map(withAttrs)
1035
+ .concat({ type: nodeType, attrs }).concat(inner.map(withAttrs));
1036
+ }
1037
+ function withAttrs(type) { return { type, attrs: null }; }
1038
+ function findWrappingOutside(range, type) {
1039
+ let { parent, startIndex, endIndex } = range;
1040
+ let around = parent.contentMatchAt(startIndex).findWrapping(type);
1041
+ if (!around)
1042
+ return null;
1043
+ let outer = around.length ? around[0] : type;
1044
+ return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;
1045
+ }
1046
+ function findWrappingInside(range, type) {
1047
+ let { parent, startIndex, endIndex } = range;
1048
+ let inner = parent.child(startIndex);
1049
+ let inside = type.contentMatch.findWrapping(inner.type);
1050
+ if (!inside)
1051
+ return null;
1052
+ let lastType = inside.length ? inside[inside.length - 1] : type;
1053
+ let innerMatch = lastType.contentMatch;
1054
+ for (let i = startIndex; innerMatch && i < endIndex; i++)
1055
+ innerMatch = innerMatch.matchType(parent.child(i).type);
1056
+ if (!innerMatch || !innerMatch.validEnd)
1057
+ return null;
1058
+ return inside;
1059
+ }
1060
+ function wrap(tr, range, wrappers) {
1061
+ let content = Fragment.empty;
1062
+ for (let i = wrappers.length - 1; i >= 0; i--) {
1063
+ if (content.size) {
1064
+ let match = wrappers[i].type.contentMatch.matchFragment(content);
1065
+ if (!match || !match.validEnd)
1066
+ throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
1067
+ }
1068
+ content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
1069
+ }
1070
+ let start = range.start, end = range.end;
1071
+ tr.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
1072
+ }
1073
+ function setBlockType(tr, from, to, type, attrs) {
1074
+ if (!type.isTextblock)
1075
+ throw new RangeError("Type given to setBlockType should be a textblock");
1076
+ let mapFrom = tr.steps.length;
1077
+ tr.doc.nodesBetween(from, to, (node, pos) => {
1078
+ let attrsHere = typeof attrs == "function" ? attrs(node) : attrs;
1079
+ if (node.isTextblock && !node.hasMarkup(type, attrsHere) &&
1080
+ canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {
1081
+ let convertNewlines = null;
1082
+ if (type.schema.linebreakReplacement) {
1083
+ let pre = type.whitespace == "pre", supportLinebreak = !!type.contentMatch.matchType(type.schema.linebreakReplacement);
1084
+ if (pre && !supportLinebreak)
1085
+ convertNewlines = false;
1086
+ else if (!pre && supportLinebreak)
1087
+ convertNewlines = true;
1088
+ }
1089
+ // Ensure all markup that isn't allowed in the new node type is cleared
1090
+ if (convertNewlines === false)
1091
+ replaceLinebreaks(tr, node, pos, mapFrom);
1092
+ clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, undefined, convertNewlines === null);
1093
+ let mapping = tr.mapping.slice(mapFrom);
1094
+ let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
1095
+ tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
1096
+ if (convertNewlines === true)
1097
+ replaceNewlines(tr, node, pos, mapFrom);
1098
+ return false;
1099
+ }
1100
+ });
1101
+ }
1102
+ function replaceNewlines(tr, node, pos, mapFrom) {
1103
+ node.forEach((child, offset) => {
1104
+ if (child.isText) {
1105
+ let m, newline = /\r?\n|\r/g;
1106
+ while (m = newline.exec(child.text)) {
1107
+ let start = tr.mapping.slice(mapFrom).map(pos + 1 + offset + m.index);
1108
+ tr.replaceWith(start, start + 1, node.type.schema.linebreakReplacement.create());
1109
+ }
1110
+ }
1111
+ });
1112
+ }
1113
+ function replaceLinebreaks(tr, node, pos, mapFrom) {
1114
+ node.forEach((child, offset) => {
1115
+ if (child.type == child.type.schema.linebreakReplacement) {
1116
+ let start = tr.mapping.slice(mapFrom).map(pos + 1 + offset);
1117
+ tr.replaceWith(start, start + 1, node.type.schema.text("\n"));
1118
+ }
1119
+ });
1120
+ }
1121
+ function canChangeType(doc, pos, type) {
1122
+ let $pos = doc.resolve(pos), index = $pos.index();
1123
+ return $pos.parent.canReplaceWith(index, index + 1, type);
1124
+ }
1125
+ /**
1126
+ Change the type, attributes, and/or marks of the node at `pos`.
1127
+ When `type` isn't given, the existing node type is preserved,
1128
+ */
1129
+ function setNodeMarkup(tr, pos, type, attrs, marks) {
1130
+ let node = tr.doc.nodeAt(pos);
1131
+ if (!node)
1132
+ throw new RangeError("No node at given position");
1133
+ if (!type)
1134
+ type = node.type;
1135
+ let newNode = type.create(attrs, null, marks || node.marks);
1136
+ if (node.isLeaf)
1137
+ return tr.replaceWith(pos, pos + node.nodeSize, newNode);
1138
+ if (!type.validContent(node.content))
1139
+ throw new RangeError("Invalid content for node type " + type.name);
1140
+ tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
1141
+ }
1142
+ /**
1143
+ Check whether splitting at the given position is allowed.
1144
+ */
1145
+ function canSplit(doc, pos, depth = 1, typesAfter) {
1146
+ let $pos = doc.resolve(pos), base = $pos.depth - depth;
1147
+ let innerType = (typesAfter && typesAfter[typesAfter.length - 1]) || $pos.parent;
1148
+ if (base < 0 || $pos.parent.type.spec.isolating ||
1149
+ !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) ||
1150
+ !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))
1151
+ return false;
1152
+ for (let d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {
1153
+ let node = $pos.node(d), index = $pos.index(d);
1154
+ if (node.type.spec.isolating)
1155
+ return false;
1156
+ let rest = node.content.cutByIndex(index, node.childCount);
1157
+ let overrideChild = typesAfter && typesAfter[i + 1];
1158
+ if (overrideChild)
1159
+ rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));
1160
+ let after = (typesAfter && typesAfter[i]) || node;
1161
+ if (!node.canReplace(index + 1, node.childCount) || !after.type.validContent(rest))
1162
+ return false;
1163
+ }
1164
+ let index = $pos.indexAfter(base);
1165
+ let baseType = typesAfter && typesAfter[0];
1166
+ return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);
1167
+ }
1168
+ function split(tr, pos, depth = 1, typesAfter) {
1169
+ let $pos = tr.doc.resolve(pos), before = Fragment.empty, after = Fragment.empty;
1170
+ for (let d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {
1171
+ before = Fragment.from($pos.node(d).copy(before));
1172
+ let typeAfter = typesAfter && typesAfter[i];
1173
+ after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
1174
+ }
1175
+ tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));
1176
+ }
1177
+ /**
1178
+ Test whether the blocks before and after a given position can be
1179
+ joined.
1180
+ */
1181
+ function canJoin(doc, pos) {
1182
+ let $pos = doc.resolve(pos), index = $pos.index();
1183
+ return joinable($pos.nodeBefore, $pos.nodeAfter) &&
1184
+ $pos.parent.canReplace(index, index + 1);
1185
+ }
1186
+ function canAppendWithSubstitutedLinebreaks(a, b) {
1187
+ if (!b.content.size)
1188
+ a.type.compatibleContent(b.type);
1189
+ let match = a.contentMatchAt(a.childCount);
1190
+ let { linebreakReplacement } = a.type.schema;
1191
+ for (let i = 0; i < b.childCount; i++) {
1192
+ let child = b.child(i);
1193
+ let type = child.type == linebreakReplacement ? a.type.schema.nodes.text : child.type;
1194
+ match = match.matchType(type);
1195
+ if (!match)
1196
+ return false;
1197
+ if (!a.type.allowsMarks(child.marks))
1198
+ return false;
1199
+ }
1200
+ return match.validEnd;
1201
+ }
1202
+ function joinable(a, b) {
1203
+ return !!(a && b && !a.isLeaf && canAppendWithSubstitutedLinebreaks(a, b));
1204
+ }
1205
+ /**
1206
+ Find an ancestor of the given position that can be joined to the
1207
+ block before (or after if `dir` is positive). Returns the joinable
1208
+ point, if any.
1209
+ */
1210
+ function joinPoint(doc, pos, dir = -1) {
1211
+ let $pos = doc.resolve(pos);
1212
+ for (let d = $pos.depth;; d--) {
1213
+ let before, after, index = $pos.index(d);
1214
+ if (d == $pos.depth) {
1215
+ before = $pos.nodeBefore;
1216
+ after = $pos.nodeAfter;
1217
+ }
1218
+ else if (dir > 0) {
1219
+ before = $pos.node(d + 1);
1220
+ index++;
1221
+ after = $pos.node(d).maybeChild(index);
1222
+ }
1223
+ else {
1224
+ before = $pos.node(d).maybeChild(index - 1);
1225
+ after = $pos.node(d + 1);
1226
+ }
1227
+ if (before && !before.isTextblock && joinable(before, after) &&
1228
+ $pos.node(d).canReplace(index, index + 1))
1229
+ return pos;
1230
+ if (d == 0)
1231
+ break;
1232
+ pos = dir < 0 ? $pos.before(d) : $pos.after(d);
1233
+ }
1234
+ }
1235
+ function join(tr, pos, depth) {
1236
+ let convertNewlines = null;
1237
+ let { linebreakReplacement } = tr.doc.type.schema;
1238
+ let $before = tr.doc.resolve(pos - depth), beforeType = $before.node().type;
1239
+ if (linebreakReplacement && beforeType.inlineContent) {
1240
+ let pre = beforeType.whitespace == "pre";
1241
+ let supportLinebreak = !!beforeType.contentMatch.matchType(linebreakReplacement);
1242
+ if (pre && !supportLinebreak)
1243
+ convertNewlines = false;
1244
+ else if (!pre && supportLinebreak)
1245
+ convertNewlines = true;
1246
+ }
1247
+ let mapFrom = tr.steps.length;
1248
+ if (convertNewlines === false) {
1249
+ let $after = tr.doc.resolve(pos + depth);
1250
+ replaceLinebreaks(tr, $after.node(), $after.before(), mapFrom);
1251
+ }
1252
+ if (beforeType.inlineContent)
1253
+ clearIncompatible(tr, pos + depth - 1, beforeType, $before.node().contentMatchAt($before.index()), convertNewlines == null);
1254
+ let mapping = tr.mapping.slice(mapFrom), start = mapping.map(pos - depth);
1255
+ tr.step(new ReplaceStep(start, mapping.map(pos + depth, -1), Slice.empty, true));
1256
+ if (convertNewlines === true) {
1257
+ let $full = tr.doc.resolve(start);
1258
+ replaceNewlines(tr, $full.node(), $full.before(), tr.steps.length);
1259
+ }
1260
+ return tr;
1261
+ }
1262
+ /**
1263
+ Try to find a point where a node of the given type can be inserted
1264
+ near `pos`, by searching up the node hierarchy when `pos` itself
1265
+ isn't a valid place but is at the start or end of a node. Return
1266
+ null if no position was found.
1267
+ */
1268
+ function insertPoint(doc, pos, nodeType) {
1269
+ let $pos = doc.resolve(pos);
1270
+ if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType))
1271
+ return pos;
1272
+ if ($pos.parentOffset == 0)
1273
+ for (let d = $pos.depth - 1; d >= 0; d--) {
1274
+ let index = $pos.index(d);
1275
+ if ($pos.node(d).canReplaceWith(index, index, nodeType))
1276
+ return $pos.before(d + 1);
1277
+ if (index > 0)
1278
+ return null;
1279
+ }
1280
+ if ($pos.parentOffset == $pos.parent.content.size)
1281
+ for (let d = $pos.depth - 1; d >= 0; d--) {
1282
+ let index = $pos.indexAfter(d);
1283
+ if ($pos.node(d).canReplaceWith(index, index, nodeType))
1284
+ return $pos.after(d + 1);
1285
+ if (index < $pos.node(d).childCount)
1286
+ return null;
1287
+ }
1288
+ return null;
1289
+ }
1290
+ /**
1291
+ Finds a position at or around the given position where the given
1292
+ slice can be inserted. Will look at parent nodes' nearest boundary
1293
+ and try there, even if the original position wasn't directly at the
1294
+ start or end of that node. Returns null when no position was found.
1295
+ */
1296
+ function dropPoint(doc, pos, slice) {
1297
+ let $pos = doc.resolve(pos);
1298
+ if (!slice.content.size)
1299
+ return pos;
1300
+ let content = slice.content;
1301
+ for (let i = 0; i < slice.openStart; i++)
1302
+ content = content.firstChild.content;
1303
+ for (let pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {
1304
+ for (let d = $pos.depth; d >= 0; d--) {
1305
+ let bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
1306
+ let insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
1307
+ let parent = $pos.node(d), fits = false;
1308
+ if (pass == 1) {
1309
+ fits = parent.canReplace(insertPos, insertPos, content);
1310
+ }
1311
+ else {
1312
+ let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
1313
+ fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
1314
+ }
1315
+ if (fits)
1316
+ return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);
1317
+ }
1318
+ }
1319
+ return null;
1320
+ }
1321
+
1322
+ /**
1323
+ ‘Fit’ a slice into a given position in the document, producing a
1324
+ [step](https://prosemirror.net/docs/ref/#transform.Step) that inserts it. Will return null if
1325
+ there's no meaningful way to insert the slice here, or inserting it
1326
+ would be a no-op (an empty slice over an empty range).
1327
+ */
1328
+ function replaceStep(doc, from, to = from, slice = Slice.empty) {
1329
+ if (from == to && !slice.size)
1330
+ return null;
1331
+ let $from = doc.resolve(from), $to = doc.resolve(to);
1332
+ // Optimization -- avoid work if it's obvious that it's not needed.
1333
+ if (fitsTrivially($from, $to, slice))
1334
+ return new ReplaceStep(from, to, slice);
1335
+ return new Fitter($from, $to, slice).fit();
1336
+ }
1337
+ function fitsTrivially($from, $to, slice) {
1338
+ return !slice.openStart && !slice.openEnd && $from.start() == $to.start() &&
1339
+ $from.parent.canReplace($from.index(), $to.index(), slice.content);
1340
+ }
1341
+ // Algorithm for 'placing' the elements of a slice into a gap:
1342
+ //
1343
+ // We consider the content of each node that is open to the left to be
1344
+ // independently placeable. I.e. in <p("foo"), p("bar")>, when the
1345
+ // paragraph on the left is open, "foo" can be placed (somewhere on
1346
+ // the left side of the replacement gap) independently from p("bar").
1347
+ //
1348
+ // This class tracks the state of the placement progress in the
1349
+ // following properties:
1350
+ //
1351
+ // - `frontier` holds a stack of `{type, match}` objects that
1352
+ // represent the open side of the replacement. It starts at
1353
+ // `$from`, then moves forward as content is placed, and is finally
1354
+ // reconciled with `$to`.
1355
+ //
1356
+ // - `unplaced` is a slice that represents the content that hasn't
1357
+ // been placed yet.
1358
+ //
1359
+ // - `placed` is a fragment of placed content. Its open-start value
1360
+ // is implicit in `$from`, and its open-end value in `frontier`.
1361
+ class Fitter {
1362
+ constructor($from, $to, unplaced) {
1363
+ this.$from = $from;
1364
+ this.$to = $to;
1365
+ this.unplaced = unplaced;
1366
+ this.frontier = [];
1367
+ this.placed = Fragment.empty;
1368
+ for (let i = 0; i <= $from.depth; i++) {
1369
+ let node = $from.node(i);
1370
+ this.frontier.push({
1371
+ type: node.type,
1372
+ match: node.contentMatchAt($from.indexAfter(i))
1373
+ });
1374
+ }
1375
+ for (let i = $from.depth; i > 0; i--)
1376
+ this.placed = Fragment.from($from.node(i).copy(this.placed));
1377
+ }
1378
+ get depth() { return this.frontier.length - 1; }
1379
+ fit() {
1380
+ // As long as there's unplaced content, try to place some of it.
1381
+ // If that fails, either increase the open score of the unplaced
1382
+ // slice, or drop nodes from it, and then try again.
1383
+ while (this.unplaced.size) {
1384
+ let fit = this.findFittable();
1385
+ if (fit)
1386
+ this.placeNodes(fit);
1387
+ else
1388
+ this.openMore() || this.dropNode();
1389
+ }
1390
+ // When there's inline content directly after the frontier _and_
1391
+ // directly after `this.$to`, we must generate a `ReplaceAround`
1392
+ // step that pulls that content into the node after the frontier.
1393
+ // That means the fitting must be done to the end of the textblock
1394
+ // node after `this.$to`, not `this.$to` itself.
1395
+ let moveInline = this.mustMoveInline(), placedSize = this.placed.size - this.depth - this.$from.depth;
1396
+ let $from = this.$from, $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));
1397
+ if (!$to)
1398
+ return null;
1399
+ // If closing to `$to` succeeded, create a step
1400
+ let content = this.placed, openStart = $from.depth, openEnd = $to.depth;
1401
+ while (openStart && openEnd && content.childCount == 1) { // Normalize by dropping open parent nodes
1402
+ content = content.firstChild.content;
1403
+ openStart--;
1404
+ openEnd--;
1405
+ }
1406
+ let slice = new Slice(content, openStart, openEnd);
1407
+ if (moveInline > -1)
1408
+ return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize);
1409
+ if (slice.size || $from.pos != this.$to.pos) // Don't generate no-op steps
1410
+ return new ReplaceStep($from.pos, $to.pos, slice);
1411
+ return null;
1412
+ }
1413
+ // Find a position on the start spine of `this.unplaced` that has
1414
+ // content that can be moved somewhere on the frontier. Returns two
1415
+ // depths, one for the slice and one for the frontier.
1416
+ findFittable() {
1417
+ let startDepth = this.unplaced.openStart;
1418
+ for (let cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {
1419
+ let node = cur.firstChild;
1420
+ if (cur.childCount > 1)
1421
+ openEnd = 0;
1422
+ if (node.type.spec.isolating && openEnd <= d) {
1423
+ startDepth = d;
1424
+ break;
1425
+ }
1426
+ cur = node.content;
1427
+ }
1428
+ // Only try wrapping nodes (pass 2) after finding a place without
1429
+ // wrapping failed.
1430
+ for (let pass = 1; pass <= 2; pass++) {
1431
+ for (let sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
1432
+ let fragment, parent = null;
1433
+ if (sliceDepth) {
1434
+ parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;
1435
+ fragment = parent.content;
1436
+ }
1437
+ else {
1438
+ fragment = this.unplaced.content;
1439
+ }
1440
+ let first = fragment.firstChild;
1441
+ for (let frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {
1442
+ let { type, match } = this.frontier[frontierDepth], wrap, inject = null;
1443
+ // In pass 1, if the next node matches, or there is no next
1444
+ // node but the parents look compatible, we've found a
1445
+ // place.
1446
+ if (pass == 1 && (first ? match.matchType(first.type) || (inject = match.fillBefore(Fragment.from(first), false))
1447
+ : parent && type.compatibleContent(parent.type)))
1448
+ return { sliceDepth, frontierDepth, parent, inject };
1449
+ // In pass 2, look for a set of wrapping nodes that make
1450
+ // `first` fit here.
1451
+ else if (pass == 2 && first && (wrap = match.findWrapping(first.type)))
1452
+ return { sliceDepth, frontierDepth, parent, wrap };
1453
+ // Don't continue looking further up if the parent node
1454
+ // would fit here.
1455
+ if (parent && match.matchType(parent.type))
1456
+ break;
1457
+ }
1458
+ }
1459
+ }
1460
+ }
1461
+ openMore() {
1462
+ let { content, openStart, openEnd } = this.unplaced;
1463
+ let inner = contentAt(content, openStart);
1464
+ if (!inner.childCount || inner.firstChild.isLeaf)
1465
+ return false;
1466
+ this.unplaced = new Slice(content, openStart + 1, Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));
1467
+ return true;
1468
+ }
1469
+ dropNode() {
1470
+ let { content, openStart, openEnd } = this.unplaced;
1471
+ let inner = contentAt(content, openStart);
1472
+ if (inner.childCount <= 1 && openStart > 0) {
1473
+ let openAtEnd = content.size - openStart <= openStart + inner.size;
1474
+ this.unplaced = new Slice(dropFromFragment(content, openStart - 1, 1), openStart - 1, openAtEnd ? openStart - 1 : openEnd);
1475
+ }
1476
+ else {
1477
+ this.unplaced = new Slice(dropFromFragment(content, openStart, 1), openStart, openEnd);
1478
+ }
1479
+ }
1480
+ // Move content from the unplaced slice at `sliceDepth` to the
1481
+ // frontier node at `frontierDepth`. Close that frontier node when
1482
+ // applicable.
1483
+ placeNodes({ sliceDepth, frontierDepth, parent, inject, wrap }) {
1484
+ while (this.depth > frontierDepth)
1485
+ this.closeFrontierNode();
1486
+ if (wrap)
1487
+ for (let i = 0; i < wrap.length; i++)
1488
+ this.openFrontierNode(wrap[i]);
1489
+ let slice = this.unplaced, fragment = parent ? parent.content : slice.content;
1490
+ let openStart = slice.openStart - sliceDepth;
1491
+ let taken = 0, add = [];
1492
+ let { match, type } = this.frontier[frontierDepth];
1493
+ if (inject) {
1494
+ for (let i = 0; i < inject.childCount; i++)
1495
+ add.push(inject.child(i));
1496
+ match = match.matchFragment(inject);
1497
+ }
1498
+ // Computes the amount of (end) open nodes at the end of the
1499
+ // fragment. When 0, the parent is open, but no more. When
1500
+ // negative, nothing is open.
1501
+ let openEndCount = (fragment.size + sliceDepth) - (slice.content.size - slice.openEnd);
1502
+ // Scan over the fragment, fitting as many child nodes as
1503
+ // possible.
1504
+ while (taken < fragment.childCount) {
1505
+ let next = fragment.child(taken), matches = match.matchType(next.type);
1506
+ if (!matches)
1507
+ break;
1508
+ taken++;
1509
+ if (taken > 1 || openStart == 0 || next.content.size) { // Drop empty open nodes
1510
+ match = matches;
1511
+ add.push(closeNodeStart(next.mark(type.allowedMarks(next.marks)), taken == 1 ? openStart : 0, taken == fragment.childCount ? openEndCount : -1));
1512
+ }
1513
+ }
1514
+ let toEnd = taken == fragment.childCount;
1515
+ if (!toEnd)
1516
+ openEndCount = -1;
1517
+ this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add));
1518
+ this.frontier[frontierDepth].match = match;
1519
+ // If the parent types match, and the entire node was moved, and
1520
+ // it's not open, close this frontier node right away.
1521
+ if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)
1522
+ this.closeFrontierNode();
1523
+ // Add new frontier nodes for any open nodes at the end.
1524
+ for (let i = 0, cur = fragment; i < openEndCount; i++) {
1525
+ let node = cur.lastChild;
1526
+ this.frontier.push({ type: node.type, match: node.contentMatchAt(node.childCount) });
1527
+ cur = node.content;
1528
+ }
1529
+ // Update `this.unplaced`. Drop the entire node from which we
1530
+ // placed it we got to its end, otherwise just drop the placed
1531
+ // nodes.
1532
+ this.unplaced = !toEnd ? new Slice(dropFromFragment(slice.content, sliceDepth, taken), slice.openStart, slice.openEnd)
1533
+ : sliceDepth == 0 ? Slice.empty
1534
+ : new Slice(dropFromFragment(slice.content, sliceDepth - 1, 1), sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1);
1535
+ }
1536
+ mustMoveInline() {
1537
+ if (!this.$to.parent.isTextblock)
1538
+ return -1;
1539
+ let top = this.frontier[this.depth], level;
1540
+ if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) ||
1541
+ (this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth))
1542
+ return -1;
1543
+ let { depth } = this.$to, after = this.$to.after(depth);
1544
+ while (depth > 1 && after == this.$to.end(--depth))
1545
+ ++after;
1546
+ return after;
1547
+ }
1548
+ findCloseLevel($to) {
1549
+ scan: for (let i = Math.min(this.depth, $to.depth); i >= 0; i--) {
1550
+ let { match, type } = this.frontier[i];
1551
+ let dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));
1552
+ let fit = contentAfterFits($to, i, type, match, dropInner);
1553
+ if (!fit)
1554
+ continue;
1555
+ for (let d = i - 1; d >= 0; d--) {
1556
+ let { match, type } = this.frontier[d];
1557
+ let matches = contentAfterFits($to, d, type, match, true);
1558
+ if (!matches || matches.childCount)
1559
+ continue scan;
1560
+ }
1561
+ return { depth: i, fit, move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to };
1562
+ }
1563
+ }
1564
+ close($to) {
1565
+ let close = this.findCloseLevel($to);
1566
+ if (!close)
1567
+ return null;
1568
+ while (this.depth > close.depth)
1569
+ this.closeFrontierNode();
1570
+ if (close.fit.childCount)
1571
+ this.placed = addToFragment(this.placed, close.depth, close.fit);
1572
+ $to = close.move;
1573
+ for (let d = close.depth + 1; d <= $to.depth; d++) {
1574
+ let node = $to.node(d), add = node.type.contentMatch.fillBefore(node.content, true, $to.index(d));
1575
+ this.openFrontierNode(node.type, node.attrs, add);
1576
+ }
1577
+ return $to;
1578
+ }
1579
+ openFrontierNode(type, attrs = null, content) {
1580
+ let top = this.frontier[this.depth];
1581
+ top.match = top.match.matchType(type);
1582
+ this.placed = addToFragment(this.placed, this.depth, Fragment.from(type.create(attrs, content)));
1583
+ this.frontier.push({ type, match: type.contentMatch });
1584
+ }
1585
+ closeFrontierNode() {
1586
+ let open = this.frontier.pop();
1587
+ let add = open.match.fillBefore(Fragment.empty, true);
1588
+ if (add.childCount)
1589
+ this.placed = addToFragment(this.placed, this.frontier.length, add);
1590
+ }
1591
+ }
1592
+ function dropFromFragment(fragment, depth, count) {
1593
+ if (depth == 0)
1594
+ return fragment.cutByIndex(count, fragment.childCount);
1595
+ return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)));
1596
+ }
1597
+ function addToFragment(fragment, depth, content) {
1598
+ if (depth == 0)
1599
+ return fragment.append(content);
1600
+ return fragment.replaceChild(fragment.childCount - 1, fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content)));
1601
+ }
1602
+ function contentAt(fragment, depth) {
1603
+ for (let i = 0; i < depth; i++)
1604
+ fragment = fragment.firstChild.content;
1605
+ return fragment;
1606
+ }
1607
+ function closeNodeStart(node, openStart, openEnd) {
1608
+ if (openStart <= 0)
1609
+ return node;
1610
+ let frag = node.content;
1611
+ if (openStart > 1)
1612
+ frag = frag.replaceChild(0, closeNodeStart(frag.firstChild, openStart - 1, frag.childCount == 1 ? openEnd - 1 : 0));
1613
+ if (openStart > 0) {
1614
+ frag = node.type.contentMatch.fillBefore(frag).append(frag);
1615
+ if (openEnd <= 0)
1616
+ frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment.empty, true));
1617
+ }
1618
+ return node.copy(frag);
1619
+ }
1620
+ function contentAfterFits($to, depth, type, match, open) {
1621
+ let node = $to.node(depth), index = open ? $to.indexAfter(depth) : $to.index(depth);
1622
+ if (index == node.childCount && !type.compatibleContent(node.type))
1623
+ return null;
1624
+ let fit = match.fillBefore(node.content, true, index);
1625
+ return fit && !invalidMarks(type, node.content, index) ? fit : null;
1626
+ }
1627
+ function invalidMarks(type, fragment, start) {
1628
+ for (let i = start; i < fragment.childCount; i++)
1629
+ if (!type.allowsMarks(fragment.child(i).marks))
1630
+ return true;
1631
+ return false;
1632
+ }
1633
+ function definesContent(type) {
1634
+ return type.spec.defining || type.spec.definingForContent;
1635
+ }
1636
+ function replaceRange(tr, from, to, slice) {
1637
+ if (!slice.size)
1638
+ return tr.deleteRange(from, to);
1639
+ let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
1640
+ if (fitsTrivially($from, $to, slice))
1641
+ return tr.step(new ReplaceStep(from, to, slice));
1642
+ let targetDepths = coveredDepths($from, tr.doc.resolve(to));
1643
+ // Can't replace the whole document, so remove 0 if it's present
1644
+ if (targetDepths[targetDepths.length - 1] == 0)
1645
+ targetDepths.pop();
1646
+ // Negative numbers represent not expansion over the whole node at
1647
+ // that depth, but replacing from $from.before(-D) to $to.pos.
1648
+ let preferredTarget = -($from.depth + 1);
1649
+ targetDepths.unshift(preferredTarget);
1650
+ // This loop picks a preferred target depth, if one of the covering
1651
+ // depths is not outside of a defining node, and adds negative
1652
+ // depths for any depth that has $from at its start and does not
1653
+ // cross a defining node.
1654
+ for (let d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {
1655
+ let spec = $from.node(d).type.spec;
1656
+ if (spec.defining || spec.definingAsContext || spec.isolating)
1657
+ break;
1658
+ if (targetDepths.indexOf(d) > -1)
1659
+ preferredTarget = d;
1660
+ else if ($from.before(d) == pos)
1661
+ targetDepths.splice(1, 0, -d);
1662
+ }
1663
+ // Try to fit each possible depth of the slice into each possible
1664
+ // target depth, starting with the preferred depths.
1665
+ let preferredTargetIndex = targetDepths.indexOf(preferredTarget);
1666
+ let leftNodes = [], preferredDepth = slice.openStart;
1667
+ for (let content = slice.content, i = 0;; i++) {
1668
+ let node = content.firstChild;
1669
+ leftNodes.push(node);
1670
+ if (i == slice.openStart)
1671
+ break;
1672
+ content = node.content;
1673
+ }
1674
+ // Back up preferredDepth to cover defining textblocks directly
1675
+ // above it, possibly skipping a non-defining textblock.
1676
+ for (let d = preferredDepth - 1; d >= 0; d--) {
1677
+ let leftNode = leftNodes[d], def = definesContent(leftNode.type);
1678
+ if (def && !leftNode.sameMarkup($from.node(Math.abs(preferredTarget) - 1)))
1679
+ preferredDepth = d;
1680
+ else if (def || !leftNode.type.isTextblock)
1681
+ break;
1682
+ }
1683
+ for (let j = slice.openStart; j >= 0; j--) {
1684
+ let openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);
1685
+ let insert = leftNodes[openDepth];
1686
+ if (!insert)
1687
+ continue;
1688
+ for (let i = 0; i < targetDepths.length; i++) {
1689
+ // Loop over possible expansion levels, starting with the
1690
+ // preferred one
1691
+ let targetDepth = targetDepths[(i + preferredTargetIndex) % targetDepths.length], expand = true;
1692
+ if (targetDepth < 0) {
1693
+ expand = false;
1694
+ targetDepth = -targetDepth;
1695
+ }
1696
+ let parent = $from.node(targetDepth - 1), index = $from.index(targetDepth - 1);
1697
+ if (parent.canReplaceWith(index, index, insert.type, insert.marks))
1698
+ return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice(closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd));
1699
+ }
1700
+ }
1701
+ let startSteps = tr.steps.length;
1702
+ for (let i = targetDepths.length - 1; i >= 0; i--) {
1703
+ tr.replace(from, to, slice);
1704
+ if (tr.steps.length > startSteps)
1705
+ break;
1706
+ let depth = targetDepths[i];
1707
+ if (depth < 0)
1708
+ continue;
1709
+ from = $from.before(depth);
1710
+ to = $to.after(depth);
1711
+ }
1712
+ }
1713
+ function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
1714
+ if (depth < oldOpen) {
1715
+ let first = fragment.firstChild;
1716
+ fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));
1717
+ }
1718
+ if (depth > newOpen) {
1719
+ let match = parent.contentMatchAt(0);
1720
+ let start = match.fillBefore(fragment).append(fragment);
1721
+ fragment = start.append(match.matchFragment(start).fillBefore(Fragment.empty, true));
1722
+ }
1723
+ return fragment;
1724
+ }
1725
+ function replaceRangeWith(tr, from, to, node) {
1726
+ if (!node.isInline && from == to && tr.doc.resolve(from).parent.content.size) {
1727
+ let point = insertPoint(tr.doc, from, node.type);
1728
+ if (point != null)
1729
+ from = to = point;
1730
+ }
1731
+ tr.replaceRange(from, to, new Slice(Fragment.from(node), 0, 0));
1732
+ }
1733
+ function deleteRange(tr, from, to) {
1734
+ let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
1735
+ let covered = coveredDepths($from, $to);
1736
+ for (let i = 0; i < covered.length; i++) {
1737
+ let depth = covered[i], last = i == covered.length - 1;
1738
+ if ((last && depth == 0) || $from.node(depth).type.contentMatch.validEnd)
1739
+ return tr.delete($from.start(depth), $to.end(depth));
1740
+ if (depth > 0 && (last || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1))))
1741
+ return tr.delete($from.before(depth), $to.after(depth));
1742
+ }
1743
+ for (let d = 1; d <= $from.depth && d <= $to.depth; d++) {
1744
+ if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d &&
1745
+ $from.start(d - 1) == $to.start(d - 1) && $from.node(d - 1).canReplace($from.index(d - 1), $to.index(d - 1)))
1746
+ return tr.delete($from.before(d), to);
1747
+ }
1748
+ tr.delete(from, to);
1749
+ }
1750
+ // Returns an array of all depths for which $from - $to spans the
1751
+ // whole content of the nodes at that depth.
1752
+ function coveredDepths($from, $to) {
1753
+ let result = [], minDepth = Math.min($from.depth, $to.depth);
1754
+ for (let d = minDepth; d >= 0; d--) {
1755
+ let start = $from.start(d);
1756
+ if (start < $from.pos - ($from.depth - d) ||
1757
+ $to.end(d) > $to.pos + ($to.depth - d) ||
1758
+ $from.node(d).type.spec.isolating ||
1759
+ $to.node(d).type.spec.isolating)
1760
+ break;
1761
+ if (start == $to.start(d) ||
1762
+ (d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&
1763
+ d && $to.start(d - 1) == start - 1))
1764
+ result.push(d);
1765
+ }
1766
+ return result;
1767
+ }
1768
+
1769
+ /**
1770
+ Update an attribute in a specific node.
1771
+ */
1772
+ class AttrStep extends Step {
1773
+ /**
1774
+ Construct an attribute step.
1775
+ */
1776
+ constructor(
1777
+ /**
1778
+ The position of the target node.
1779
+ */
1780
+ pos,
1781
+ /**
1782
+ The attribute to set.
1783
+ */
1784
+ attr,
1785
+ // The attribute's new value.
1786
+ value) {
1787
+ super();
1788
+ this.pos = pos;
1789
+ this.attr = attr;
1790
+ this.value = value;
1791
+ }
1792
+ apply(doc) {
1793
+ let node = doc.nodeAt(this.pos);
1794
+ if (!node)
1795
+ return StepResult.fail("No node at attribute step's position");
1796
+ let attrs = Object.create(null);
1797
+ for (let name in node.attrs)
1798
+ attrs[name] = node.attrs[name];
1799
+ attrs[this.attr] = this.value;
1800
+ let updated = node.type.create(attrs, null, node.marks);
1801
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
1802
+ }
1803
+ getMap() {
1804
+ return StepMap.empty;
1805
+ }
1806
+ invert(doc) {
1807
+ return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);
1808
+ }
1809
+ map(mapping) {
1810
+ let pos = mapping.mapResult(this.pos, 1);
1811
+ return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value);
1812
+ }
1813
+ toJSON() {
1814
+ return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
1815
+ }
1816
+ static fromJSON(schema, json) {
1817
+ if (typeof json.pos != "number" || typeof json.attr != "string")
1818
+ throw new RangeError("Invalid input for AttrStep.fromJSON");
1819
+ return new AttrStep(json.pos, json.attr, json.value);
1820
+ }
1821
+ }
1822
+ Step.jsonID("attr", AttrStep);
1823
+ /**
1824
+ Update an attribute in the doc node.
1825
+ */
1826
+ class DocAttrStep extends Step {
1827
+ /**
1828
+ Construct an attribute step.
1829
+ */
1830
+ constructor(
1831
+ /**
1832
+ The attribute to set.
1833
+ */
1834
+ attr,
1835
+ // The attribute's new value.
1836
+ value) {
1837
+ super();
1838
+ this.attr = attr;
1839
+ this.value = value;
1840
+ }
1841
+ apply(doc) {
1842
+ let attrs = Object.create(null);
1843
+ for (let name in doc.attrs)
1844
+ attrs[name] = doc.attrs[name];
1845
+ attrs[this.attr] = this.value;
1846
+ let updated = doc.type.create(attrs, doc.content, doc.marks);
1847
+ return StepResult.ok(updated);
1848
+ }
1849
+ getMap() {
1850
+ return StepMap.empty;
1851
+ }
1852
+ invert(doc) {
1853
+ return new DocAttrStep(this.attr, doc.attrs[this.attr]);
1854
+ }
1855
+ map(mapping) {
1856
+ return this;
1857
+ }
1858
+ toJSON() {
1859
+ return { stepType: "docAttr", attr: this.attr, value: this.value };
1860
+ }
1861
+ static fromJSON(schema, json) {
1862
+ if (typeof json.attr != "string")
1863
+ throw new RangeError("Invalid input for DocAttrStep.fromJSON");
1864
+ return new DocAttrStep(json.attr, json.value);
1865
+ }
1866
+ }
1867
+ Step.jsonID("docAttr", DocAttrStep);
1868
+
1869
+ /**
1870
+ @internal
1871
+ */
1872
+ let TransformError = class extends Error {
1873
+ };
1874
+ TransformError = function TransformError(message) {
1875
+ let err = Error.call(this, message);
1876
+ err.__proto__ = TransformError.prototype;
1877
+ return err;
1878
+ };
1879
+ TransformError.prototype = Object.create(Error.prototype);
1880
+ TransformError.prototype.constructor = TransformError;
1881
+ TransformError.prototype.name = "TransformError";
1882
+ /**
1883
+ Abstraction to build up and track an array of
1884
+ [steps](https://prosemirror.net/docs/ref/#transform.Step) representing a document transformation.
1885
+
1886
+ Most transforming methods return the `Transform` object itself, so
1887
+ that they can be chained.
1888
+ */
1889
+ class Transform {
1890
+ /**
1891
+ Create a transform that starts with the given document.
1892
+ */
1893
+ constructor(
1894
+ /**
1895
+ The current document (the result of applying the steps in the
1896
+ transform).
1897
+ */
1898
+ doc) {
1899
+ this.doc = doc;
1900
+ /**
1901
+ The steps in this transform.
1902
+ */
1903
+ this.steps = [];
1904
+ /**
1905
+ The documents before each of the steps.
1906
+ */
1907
+ this.docs = [];
1908
+ /**
1909
+ A mapping with the maps for each of the steps in this transform.
1910
+ */
1911
+ this.mapping = new Mapping;
1912
+ }
1913
+ /**
1914
+ The starting document.
1915
+ */
1916
+ get before() { return this.docs.length ? this.docs[0] : this.doc; }
1917
+ /**
1918
+ Apply a new step in this transform, saving the result. Throws an
1919
+ error when the step fails.
1920
+ */
1921
+ step(step) {
1922
+ let result = this.maybeStep(step);
1923
+ if (result.failed)
1924
+ throw new TransformError(result.failed);
1925
+ return this;
1926
+ }
1927
+ /**
1928
+ Try to apply a step in this transformation, ignoring it if it
1929
+ fails. Returns the step result.
1930
+ */
1931
+ maybeStep(step) {
1932
+ let result = step.apply(this.doc);
1933
+ if (!result.failed)
1934
+ this.addStep(step, result.doc);
1935
+ return result;
1936
+ }
1937
+ /**
1938
+ True when the document has been changed (when there are any
1939
+ steps).
1940
+ */
1941
+ get docChanged() {
1942
+ return this.steps.length > 0;
1943
+ }
1944
+ /**
1945
+ @internal
1946
+ */
1947
+ addStep(step, doc) {
1948
+ this.docs.push(this.doc);
1949
+ this.steps.push(step);
1950
+ this.mapping.appendMap(step.getMap());
1951
+ this.doc = doc;
1952
+ }
1953
+ /**
1954
+ Replace the part of the document between `from` and `to` with the
1955
+ given `slice`.
1956
+ */
1957
+ replace(from, to = from, slice = Slice.empty) {
1958
+ let step = replaceStep(this.doc, from, to, slice);
1959
+ if (step)
1960
+ this.step(step);
1961
+ return this;
1962
+ }
1963
+ /**
1964
+ Replace the given range with the given content, which may be a
1965
+ fragment, node, or array of nodes.
1966
+ */
1967
+ replaceWith(from, to, content) {
1968
+ return this.replace(from, to, new Slice(Fragment.from(content), 0, 0));
1969
+ }
1970
+ /**
1971
+ Delete the content between the given positions.
1972
+ */
1973
+ delete(from, to) {
1974
+ return this.replace(from, to, Slice.empty);
1975
+ }
1976
+ /**
1977
+ Insert the given content at the given position.
1978
+ */
1979
+ insert(pos, content) {
1980
+ return this.replaceWith(pos, pos, content);
1981
+ }
1982
+ /**
1983
+ Replace a range of the document with a given slice, using
1984
+ `from`, `to`, and the slice's
1985
+ [`openStart`](https://prosemirror.net/docs/ref/#model.Slice.openStart) property as hints, rather
1986
+ than fixed start and end points. This method may grow the
1987
+ replaced area or close open nodes in the slice in order to get a
1988
+ fit that is more in line with WYSIWYG expectations, by dropping
1989
+ fully covered parent nodes of the replaced region when they are
1990
+ marked [non-defining as
1991
+ context](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext), or including an
1992
+ open parent node from the slice that _is_ marked as [defining
1993
+ its content](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
1994
+
1995
+ This is the method, for example, to handle paste. The similar
1996
+ [`replace`](https://prosemirror.net/docs/ref/#transform.Transform.replace) method is a more
1997
+ primitive tool which will _not_ move the start and end of its given
1998
+ range, and is useful in situations where you need more precise
1999
+ control over what happens.
2000
+ */
2001
+ replaceRange(from, to, slice) {
2002
+ replaceRange(this, from, to, slice);
2003
+ return this;
2004
+ }
2005
+ /**
2006
+ Replace the given range with a node, but use `from` and `to` as
2007
+ hints, rather than precise positions. When from and to are the same
2008
+ and are at the start or end of a parent node in which the given
2009
+ node doesn't fit, this method may _move_ them out towards a parent
2010
+ that does allow the given node to be placed. When the given range
2011
+ completely covers a parent node, this method may completely replace
2012
+ that parent node.
2013
+ */
2014
+ replaceRangeWith(from, to, node) {
2015
+ replaceRangeWith(this, from, to, node);
2016
+ return this;
2017
+ }
2018
+ /**
2019
+ Delete the given range, expanding it to cover fully covered
2020
+ parent nodes until a valid replace is found.
2021
+ */
2022
+ deleteRange(from, to) {
2023
+ deleteRange(this, from, to);
2024
+ return this;
2025
+ }
2026
+ /**
2027
+ Split the content in the given range off from its parent, if there
2028
+ is sibling content before or after it, and move it up the tree to
2029
+ the depth specified by `target`. You'll probably want to use
2030
+ [`liftTarget`](https://prosemirror.net/docs/ref/#transform.liftTarget) to compute `target`, to make
2031
+ sure the lift is valid.
2032
+ */
2033
+ lift(range, target) {
2034
+ lift(this, range, target);
2035
+ return this;
2036
+ }
2037
+ /**
2038
+ Join the blocks around the given position. If depth is 2, their
2039
+ last and first siblings are also joined, and so on.
2040
+ */
2041
+ join(pos, depth = 1) {
2042
+ join(this, pos, depth);
2043
+ return this;
2044
+ }
2045
+ /**
2046
+ Wrap the given [range](https://prosemirror.net/docs/ref/#model.NodeRange) in the given set of wrappers.
2047
+ The wrappers are assumed to be valid in this position, and should
2048
+ probably be computed with [`findWrapping`](https://prosemirror.net/docs/ref/#transform.findWrapping).
2049
+ */
2050
+ wrap(range, wrappers) {
2051
+ wrap(this, range, wrappers);
2052
+ return this;
2053
+ }
2054
+ /**
2055
+ Set the type of all textblocks (partly) between `from` and `to` to
2056
+ the given node type with the given attributes.
2057
+ */
2058
+ setBlockType(from, to = from, type, attrs = null) {
2059
+ setBlockType(this, from, to, type, attrs);
2060
+ return this;
2061
+ }
2062
+ /**
2063
+ Change the type, attributes, and/or marks of the node at `pos`.
2064
+ When `type` isn't given, the existing node type is preserved,
2065
+ */
2066
+ setNodeMarkup(pos, type, attrs = null, marks) {
2067
+ setNodeMarkup(this, pos, type, attrs, marks);
2068
+ return this;
2069
+ }
2070
+ /**
2071
+ Set a single attribute on a given node to a new value.
2072
+ The `pos` addresses the document content. Use `setDocAttribute`
2073
+ to set attributes on the document itself.
2074
+ */
2075
+ setNodeAttribute(pos, attr, value) {
2076
+ this.step(new AttrStep(pos, attr, value));
2077
+ return this;
2078
+ }
2079
+ /**
2080
+ Set a single attribute on the document to a new value.
2081
+ */
2082
+ setDocAttribute(attr, value) {
2083
+ this.step(new DocAttrStep(attr, value));
2084
+ return this;
2085
+ }
2086
+ /**
2087
+ Add a mark to the node at position `pos`.
2088
+ */
2089
+ addNodeMark(pos, mark) {
2090
+ this.step(new AddNodeMarkStep(pos, mark));
2091
+ return this;
2092
+ }
2093
+ /**
2094
+ Remove a mark (or all marks of the given type) from the node at
2095
+ position `pos`.
2096
+ */
2097
+ removeNodeMark(pos, mark) {
2098
+ let node = this.doc.nodeAt(pos);
2099
+ if (!node)
2100
+ throw new RangeError("No node at position " + pos);
2101
+ if (mark instanceof Mark) {
2102
+ if (mark.isInSet(node.marks))
2103
+ this.step(new RemoveNodeMarkStep(pos, mark));
2104
+ }
2105
+ else {
2106
+ let set = node.marks, found, steps = [];
2107
+ while (found = mark.isInSet(set)) {
2108
+ steps.push(new RemoveNodeMarkStep(pos, found));
2109
+ set = found.removeFromSet(set);
2110
+ }
2111
+ for (let i = steps.length - 1; i >= 0; i--)
2112
+ this.step(steps[i]);
2113
+ }
2114
+ return this;
2115
+ }
2116
+ /**
2117
+ Split the node at the given position, and optionally, if `depth` is
2118
+ greater than one, any number of nodes above that. By default, the
2119
+ parts split off will inherit the node type of the original node.
2120
+ This can be changed by passing an array of types and attributes to
2121
+ use after the split (with the outermost nodes coming first).
2122
+ */
2123
+ split(pos, depth = 1, typesAfter) {
2124
+ split(this, pos, depth, typesAfter);
2125
+ return this;
2126
+ }
2127
+ /**
2128
+ Add the given mark to the inline content between `from` and `to`.
2129
+ */
2130
+ addMark(from, to, mark) {
2131
+ addMark(this, from, to, mark);
2132
+ return this;
2133
+ }
2134
+ /**
2135
+ Remove marks from inline nodes between `from` and `to`. When
2136
+ `mark` is a single mark, remove precisely that mark. When it is
2137
+ a mark type, remove all marks of that type. When it is null,
2138
+ remove all marks of any type.
2139
+ */
2140
+ removeMark(from, to, mark) {
2141
+ removeMark(this, from, to, mark);
2142
+ return this;
2143
+ }
2144
+ /**
2145
+ Removes all marks and nodes from the content of the node at
2146
+ `pos` that don't match the given new parent node type. Accepts
2147
+ an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as
2148
+ third argument.
2149
+ */
2150
+ clearIncompatible(pos, parentType, match) {
2151
+ clearIncompatible(this, pos, parentType, match);
2152
+ return this;
2153
+ }
2154
+ }
2155
+
2156
+ export { Mapping as M, ReplaceStep as R, Transform as T, canJoin as a, ReplaceAroundStep as b, canSplit as c, dropPoint as d, findWrapping as f, joinPoint as j, liftTarget as l, replaceStep as r };