@burdenoff/microfe-support 2026.1114.1 → 2026.1118.1

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 (206) hide show
  1. package/dist/generated/global-operations.d.ts +62 -0
  2. package/dist/generated/global-operations.js +104 -69
  3. package/dist/generated/global-operations.js.map +1 -1
  4. package/dist/generated/global-types.js +17 -15
  5. package/dist/generated/global-types.js.map +1 -1
  6. package/dist/support/SupportUserRoot.js +32 -28
  7. package/dist/support/SupportUserRoot.js.map +1 -1
  8. package/dist/support/SupportUserRoutes.d.ts +1 -0
  9. package/dist/support/SupportUserRoutes.js +31 -28
  10. package/dist/support/SupportUserRoutes.js.map +1 -1
  11. package/dist/support/components/PageLayout.js +35 -35
  12. package/dist/support/components/RouteHelpers.d.ts +2 -1
  13. package/dist/support/components/RouteHelpers.js +3 -3
  14. package/dist/support/components/RouteHelpers.js.map +1 -1
  15. package/dist/support/components/careers/RichTextEditor.js +31 -31
  16. package/dist/support/components/careers/RichTextEditor.js.map +1 -1
  17. package/dist/support/components/help/RelatedArticles.d.ts +12 -0
  18. package/dist/support/components/help/RelatedArticles.js +55 -0
  19. package/dist/support/components/help/RelatedArticles.js.map +1 -0
  20. package/dist/support/components/help/RequestDetailHeader.d.ts +18 -0
  21. package/dist/support/components/help/RequestDetailHeader.js +129 -0
  22. package/dist/support/components/help/RequestDetailHeader.js.map +1 -0
  23. package/dist/support/components/help/SatisfactionReview.d.ts +18 -0
  24. package/dist/support/components/help/SatisfactionReview.js +103 -0
  25. package/dist/support/components/help/SatisfactionReview.js.map +1 -0
  26. package/dist/support/components/help/StarRating.d.ts +16 -0
  27. package/dist/support/components/help/StarRating.js +63 -0
  28. package/dist/support/components/help/StarRating.js.map +1 -0
  29. package/dist/support/components/help/StatusGroupPill.d.ts +11 -0
  30. package/dist/support/components/help/StatusGroupPill.js +19 -0
  31. package/dist/support/components/help/StatusGroupPill.js.map +1 -0
  32. package/dist/support/components/settings/TicketCategoriesSettings.js +69 -69
  33. package/dist/support/components/settings/TicketCategoriesSettings.js.map +1 -1
  34. package/dist/support/components/tickets/MessageComposer.js +7 -7
  35. package/dist/support/components/tickets/MessageComposer.js.map +1 -1
  36. package/dist/support/components/tickets/TicketDetailHeader.js +54 -60
  37. package/dist/support/components/tickets/TicketDetailHeader.js.map +1 -1
  38. package/dist/support/components/ui.js +1 -1
  39. package/dist/support/constants.d.ts +23 -0
  40. package/dist/support/constants.js +2 -2
  41. package/dist/support/constants.js.map +1 -1
  42. package/dist/support/hooks/useDebouncedValue.d.ts +6 -0
  43. package/dist/support/hooks/useDebouncedValue.js +12 -0
  44. package/dist/support/hooks/useDebouncedValue.js.map +1 -0
  45. package/dist/support/hooks/useKnowledgeBaseOperations.d.ts +8 -1
  46. package/dist/support/hooks/useKnowledgeBaseOperations.js +86 -81
  47. package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
  48. package/dist/support/hooks/useSupportVariant.d.ts +11 -0
  49. package/dist/support/hooks/useSupportVariant.js +11 -0
  50. package/dist/support/hooks/useSupportVariant.js.map +1 -0
  51. package/dist/support/hooks/useTicketCreatedToast.d.ts +16 -0
  52. package/dist/support/hooks/useTicketCreatedToast.js +25 -0
  53. package/dist/support/hooks/useTicketCreatedToast.js.map +1 -0
  54. package/dist/support/hooks/useTicketLabels.d.ts +22 -0
  55. package/dist/support/hooks/useTicketLabels.js +40 -0
  56. package/dist/support/hooks/useTicketLabels.js.map +1 -0
  57. package/dist/support/index.d.ts +1 -1
  58. package/dist/support/pages/ArticleDetailAdminPage.js +84 -84
  59. package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
  60. package/dist/support/pages/ArticleDetailUserPage.d.ts +5 -0
  61. package/dist/support/pages/ArticleDetailUserPage.js +133 -69
  62. package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
  63. package/dist/support/pages/AskForHelpPage.d.ts +11 -0
  64. package/dist/support/pages/AskForHelpPage.js +396 -0
  65. package/dist/support/pages/AskForHelpPage.js.map +1 -0
  66. package/dist/support/pages/ContactInquiriesPage.js +73 -73
  67. package/dist/support/pages/ContactInquiryDetailPage.js +47 -47
  68. package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
  69. package/dist/support/pages/CreateTicketPage.d.ts +4 -0
  70. package/dist/support/pages/CreateTicketPage.js +121 -117
  71. package/dist/support/pages/CreateTicketPage.js.map +1 -1
  72. package/dist/support/pages/HelpHubPage.d.ts +9 -0
  73. package/dist/support/pages/HelpHubPage.js +272 -0
  74. package/dist/support/pages/HelpHubPage.js.map +1 -0
  75. package/dist/support/pages/JobApplicationDetailPage.js +388 -388
  76. package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
  77. package/dist/support/pages/JobApplicationsPage.js +35 -35
  78. package/dist/support/pages/JobPostingDetailPage.js +236 -236
  79. package/dist/support/pages/JobPostingDetailPage.js.map +1 -1
  80. package/dist/support/pages/KnowledgeBaseUserPage.d.ts +6 -1
  81. package/dist/support/pages/KnowledgeBaseUserPage.js +188 -137
  82. package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
  83. package/dist/support/pages/MyRequestsPage.d.ts +16 -0
  84. package/dist/support/pages/MyRequestsPage.js +389 -0
  85. package/dist/support/pages/MyRequestsPage.js.map +1 -0
  86. package/dist/support/pages/TicketDetailUserPage.d.ts +5 -0
  87. package/dist/support/pages/TicketDetailUserPage.js +285 -192
  88. package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
  89. package/dist/support/pages/TicketListPage.d.ts +7 -0
  90. package/dist/support/pages/TicketListPage.js +150 -153
  91. package/dist/support/pages/TicketListPage.js.map +1 -1
  92. package/dist/support/providers/SupportProvider.js +8 -7
  93. package/dist/support/providers/SupportProvider.js.map +1 -1
  94. package/dist/support/store/supportStore.d.ts +5 -0
  95. package/dist/support/store/supportStore.js +1 -0
  96. package/dist/support/store/supportStore.js.map +1 -1
  97. package/dist/support/translations/en.d.ts +279 -0
  98. package/dist/support/translations/en.js +270 -1
  99. package/dist/support/translations/en.js.map +1 -1
  100. package/dist/support/types/index.d.ts +13 -0
  101. package/dist/support/utils/cameFrom.d.ts +16 -0
  102. package/dist/support/utils/cameFrom.js +22 -0
  103. package/dist/support/utils/cameFrom.js.map +1 -0
  104. package/dist/support/utils/dates.d.ts +15 -0
  105. package/dist/support/utils/dates.js +35 -0
  106. package/dist/support/utils/dates.js.map +1 -0
  107. package/dist/support/utils/reopen.d.ts +27 -0
  108. package/dist/support/utils/reopen.js +27 -0
  109. package/dist/support/utils/reopen.js.map +1 -0
  110. package/dist/support/utils/requestTechnicalDetails.d.ts +13 -0
  111. package/dist/support/utils/requestTechnicalDetails.js +38 -0
  112. package/dist/support/utils/requestTechnicalDetails.js.map +1 -0
  113. package/dist/support/utils/ticketFilters.d.ts +16 -0
  114. package/dist/support/utils/ticketFilters.js +24 -12
  115. package/dist/support/utils/ticketFilters.js.map +1 -1
  116. package/dist/support/utils/ticketStatusGroups.d.ts +20 -0
  117. package/dist/support/utils/ticketStatusGroups.js +39 -0
  118. package/dist/support/utils/ticketStatusGroups.js.map +1 -0
  119. package/package.json +2 -2
  120. package/dist/_virtual/_rolldown/runtime.js +0 -6
  121. package/dist/node_modules/@tiptap/core/dist/index.js +0 -3491
  122. package/dist/node_modules/@tiptap/core/dist/index.js.map +0 -1
  123. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +0 -44
  124. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +0 -1
  125. package/dist/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js +0 -12
  126. package/dist/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js.map +0 -1
  127. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +0 -75
  128. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js.map +0 -1
  129. package/dist/node_modules/@tiptap/extension-bold/dist/index.js +0 -73
  130. package/dist/node_modules/@tiptap/extension-bold/dist/index.js.map +0 -1
  131. package/dist/node_modules/@tiptap/extension-code/dist/index.js +0 -78
  132. package/dist/node_modules/@tiptap/extension-code/dist/index.js.map +0 -1
  133. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +0 -157
  134. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js.map +0 -1
  135. package/dist/node_modules/@tiptap/extension-document/dist/index.js +0 -11
  136. package/dist/node_modules/@tiptap/extension-document/dist/index.js.map +0 -1
  137. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +0 -50
  138. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js.map +0 -1
  139. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +0 -70
  140. package/dist/node_modules/@tiptap/extension-heading/dist/index.js.map +0 -1
  141. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +0 -49
  142. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js.map +0 -1
  143. package/dist/node_modules/@tiptap/extension-italic/dist/index.js +0 -70
  144. package/dist/node_modules/@tiptap/extension-italic/dist/index.js.map +0 -1
  145. package/dist/node_modules/@tiptap/extension-link/dist/index.js +0 -389
  146. package/dist/node_modules/@tiptap/extension-link/dist/index.js.map +0 -1
  147. package/dist/node_modules/@tiptap/extension-list/dist/index.js +0 -967
  148. package/dist/node_modules/@tiptap/extension-list/dist/index.js.map +0 -1
  149. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +0 -46
  150. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js.map +0 -1
  151. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +0 -6
  152. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js.map +0 -1
  153. package/dist/node_modules/@tiptap/extension-strike/dist/index.js +0 -55
  154. package/dist/node_modules/@tiptap/extension-strike/dist/index.js.map +0 -1
  155. package/dist/node_modules/@tiptap/extension-text/dist/index.js +0 -14
  156. package/dist/node_modules/@tiptap/extension-text/dist/index.js.map +0 -1
  157. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +0 -72
  158. package/dist/node_modules/@tiptap/extension-underline/dist/index.js.map +0 -1
  159. package/dist/node_modules/@tiptap/extensions/dist/index.js +0 -457
  160. package/dist/node_modules/@tiptap/extensions/dist/index.js.map +0 -1
  161. package/dist/node_modules/@tiptap/react/dist/index.js +0 -332
  162. package/dist/node_modules/@tiptap/react/dist/index.js.map +0 -1
  163. package/dist/node_modules/@tiptap/starter-kit/dist/index.js +0 -28
  164. package/dist/node_modules/@tiptap/starter-kit/dist/index.js.map +0 -1
  165. package/dist/node_modules/fast-equals/dist/es/index.js +0 -298
  166. package/dist/node_modules/fast-equals/dist/es/index.js.map +0 -1
  167. package/dist/node_modules/linkifyjs/dist/linkify.js +0 -527
  168. package/dist/node_modules/linkifyjs/dist/linkify.js.map +0 -1
  169. package/dist/node_modules/orderedmap/dist/index.js +0 -68
  170. package/dist/node_modules/orderedmap/dist/index.js.map +0 -1
  171. package/dist/node_modules/prosemirror-commands/dist/index.js +0 -334
  172. package/dist/node_modules/prosemirror-commands/dist/index.js.map +0 -1
  173. package/dist/node_modules/prosemirror-dropcursor/dist/index.js +0 -112
  174. package/dist/node_modules/prosemirror-dropcursor/dist/index.js.map +0 -1
  175. package/dist/node_modules/prosemirror-gapcursor/dist/index.js +0 -168
  176. package/dist/node_modules/prosemirror-gapcursor/dist/index.js.map +0 -1
  177. package/dist/node_modules/prosemirror-history/dist/index.js +0 -219
  178. package/dist/node_modules/prosemirror-history/dist/index.js.map +0 -1
  179. package/dist/node_modules/prosemirror-keymap/dist/index.js +0 -51
  180. package/dist/node_modules/prosemirror-keymap/dist/index.js.map +0 -1
  181. package/dist/node_modules/prosemirror-model/dist/index.js +0 -1775
  182. package/dist/node_modules/prosemirror-model/dist/index.js.map +0 -1
  183. package/dist/node_modules/prosemirror-schema-list/dist/index.js +0 -77
  184. package/dist/node_modules/prosemirror-schema-list/dist/index.js.map +0 -1
  185. package/dist/node_modules/prosemirror-state/dist/index.js +0 -526
  186. package/dist/node_modules/prosemirror-state/dist/index.js.map +0 -1
  187. package/dist/node_modules/prosemirror-transform/dist/index.js +0 -1204
  188. package/dist/node_modules/prosemirror-transform/dist/index.js.map +0 -1
  189. package/dist/node_modules/prosemirror-view/dist/index.js +0 -3355
  190. package/dist/node_modules/prosemirror-view/dist/index.js.map +0 -1
  191. package/dist/node_modules/rope-sequence/dist/index.js +0 -84
  192. package/dist/node_modules/rope-sequence/dist/index.js.map +0 -1
  193. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -55
  194. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -1
  195. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +0 -53
  196. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +0 -1
  197. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -53
  198. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
  199. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -45
  200. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +0 -1
  201. package/dist/node_modules/use-sync-external-store/shim/index.js +0 -11
  202. package/dist/node_modules/use-sync-external-store/shim/index.js.map +0 -1
  203. package/dist/node_modules/use-sync-external-store/shim/with-selector.js +0 -11
  204. package/dist/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -1
  205. package/dist/node_modules/w3c-keyname/index.js +0 -89
  206. package/dist/node_modules/w3c-keyname/index.js.map +0 -1
@@ -1,3355 +0,0 @@
1
- import { AllSelection as e, NodeSelection as t, Selection as n, TextSelection as r } from "../../prosemirror-state/dist/index.js";
2
- import { DOMParser as i, DOMSerializer as a, Fragment as o, Mark as s, Slice as c } from "../../prosemirror-model/dist/index.js";
3
- import { dropPoint as l } from "../../prosemirror-transform/dist/index.js";
4
- // node_modules/prosemirror-view/dist/index.js
5
- var u = function(e) {
6
- for (var t = 0;; t++) if (e = e.previousSibling, !e) return t;
7
- }, d = function(e) {
8
- let t = e.assignedSlot || e.parentNode;
9
- return t && t.nodeType == 11 ? t.host : t;
10
- }, f = null, p = function(e, t, n) {
11
- let r = f ||= document.createRange();
12
- return r.setEnd(e, n ?? e.nodeValue.length), r.setStart(e, t || 0), r;
13
- }, m = function() {
14
- f = null;
15
- }, h = function(e, t, n, r) {
16
- return n && (_(e, t, n, r, -1) || _(e, t, n, r, 1));
17
- }, g = /^(img|br|input|textarea|hr)$/i;
18
- function _(e, t, n, r, i) {
19
- for (;;) {
20
- if (e == n && t == r) return !0;
21
- if (t == (i < 0 ? 0 : v(e))) {
22
- let n = e.parentNode;
23
- if (!n || !y(n) || te(e) || g.test(e.nodeName) || e.contentEditable == "false") return !1;
24
- t = u(e) + (i < 0 ? 0 : 1), e = n;
25
- } else if (y(e)) {
26
- let n = e.childNodes[t + (i < 0 ? -1 : 0)];
27
- if (y(n) && n.contentEditable == "false") {
28
- if (n.pmViewDesc?.ignoreForSelection) t += i;
29
- else return !1;
30
- } else e = n, t = i < 0 ? v(e) : 0;
31
- } else return !1;
32
- }
33
- }
34
- function v(e) {
35
- return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length;
36
- }
37
- function y(e) {
38
- return e.nodeType == 1;
39
- }
40
- function b(e) {
41
- return e.nodeType == 3;
42
- }
43
- function x(e, t) {
44
- return t ? e.contains(y(t) ? t : t.parentNode) : !1;
45
- }
46
- function S(e, t) {
47
- for (;;) {
48
- if (b(e) && t) return e;
49
- if (y(e) && t > 0) {
50
- if (e.contentEditable == "false") return null;
51
- e = e.childNodes[t - 1], t = v(e);
52
- } else if (e.parentNode && !te(e)) t = u(e), e = e.parentNode;
53
- else return null;
54
- }
55
- }
56
- function C(e, t) {
57
- for (;;) {
58
- if (b(e) && t < e.nodeValue.length) return e;
59
- if (y(e) && t < e.childNodes.length) {
60
- if (e.contentEditable == "false") return null;
61
- e = e.childNodes[t], t = 0;
62
- } else if (e.parentNode && !te(e)) t = u(e) + 1, e = e.parentNode;
63
- else return null;
64
- }
65
- }
66
- function ee(e, t, n) {
67
- for (let r = t == 0, i = t == v(e); r || i;) {
68
- if (e == n) return !0;
69
- let t = u(e);
70
- if (e = e.parentNode, !e) return !1;
71
- r &&= t == 0, i &&= t == v(e);
72
- }
73
- }
74
- function te(e) {
75
- let t;
76
- for (let n = e; n && !(t = n.pmViewDesc); n = n.parentNode);
77
- return t && t.node && t.node.isBlock && (t.dom == e || t.contentDOM == e);
78
- }
79
- var ne = function(e) {
80
- return e.focusNode && h(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset);
81
- };
82
- function re(e, t) {
83
- let n = document.createEvent("Event");
84
- return n.initEvent("keydown", !0, !0), n.keyCode = e, n.key = n.code = t, n;
85
- }
86
- function ie(e) {
87
- let t = e.activeElement;
88
- for (; t && t.shadowRoot;) t = t.shadowRoot.activeElement;
89
- return t;
90
- }
91
- function ae(e, t, n) {
92
- if (e.caretPositionFromPoint) try {
93
- let r = e.caretPositionFromPoint(t, n);
94
- if (r) return {
95
- node: r.offsetNode,
96
- offset: Math.min(v(r.offsetNode), r.offset)
97
- };
98
- } catch {}
99
- if (e.caretRangeFromPoint) {
100
- let r = e.caretRangeFromPoint(t, n);
101
- if (r) return {
102
- node: r.startContainer,
103
- offset: Math.min(v(r.startContainer), r.startOffset)
104
- };
105
- }
106
- }
107
- var w = typeof navigator < "u" ? navigator : null, oe = typeof document < "u" ? document : null, T = w && w.userAgent || "", se = /Edge\/(\d+)/.exec(T), ce = /MSIE \d/.exec(T), le = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(T), E = !!(ce || le || se), D = ce ? document.documentMode : le ? +le[1] : se ? +se[1] : 0, O = !E && /gecko\/(\d+)/i.test(T);
108
- O && +(/Firefox\/(\d+)/.exec(T) || [0, 0])[1];
109
- var ue = !E && /Chrome\/(\d+)/.exec(T), k = !!ue, de = ue ? +ue[1] : 0, A = !E && !!w && /Apple Computer/.test(w.vendor), fe = A && (/Mobile\/\w+/.test(T) || !!w && w.maxTouchPoints > 2), j = fe || (w ? /Mac/.test(w.platform) : !1), pe = w ? /Win/.test(w.platform) : !1, M = /Android \d/.test(T), me = !!oe && "webkitFontSmoothing" in oe.documentElement.style, he = me ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
110
- function ge(e) {
111
- let t = e.defaultView && e.defaultView.visualViewport;
112
- return t ? {
113
- left: 0,
114
- right: t.width,
115
- top: 0,
116
- bottom: t.height
117
- } : {
118
- left: 0,
119
- right: e.documentElement.clientWidth,
120
- top: 0,
121
- bottom: e.documentElement.clientHeight
122
- };
123
- }
124
- function N(e, t) {
125
- return typeof e == "number" ? e : e[t];
126
- }
127
- function _e(e) {
128
- let t = e.getBoundingClientRect(), n = t.width / e.offsetWidth || 1, r = t.height / e.offsetHeight || 1;
129
- return {
130
- left: t.left,
131
- right: t.left + e.clientWidth * n,
132
- top: t.top,
133
- bottom: t.top + e.clientHeight * r
134
- };
135
- }
136
- function ve(e, t, n) {
137
- if (!Me(t) && t.left == 0) return;
138
- let r = e.someProp("scrollThreshold") || 0, i = e.someProp("scrollMargin") || 5, a = e.dom.ownerDocument;
139
- for (let o = n || e.dom; o;) {
140
- if (!y(o)) {
141
- o = d(o);
142
- continue;
143
- }
144
- let e = o == a.body, n = e ? ge(a) : _e(o), s = 0, c = 0;
145
- if (t.top < n.top + N(r, "top") ? c = -(n.top - t.top + N(i, "top")) : t.bottom > n.bottom - N(r, "bottom") && (c = t.bottom - t.top > n.bottom - n.top ? t.top + N(i, "top") - n.top : t.bottom - n.bottom + N(i, "bottom")), t.left < n.left + N(r, "left") ? s = -(n.left - t.left + N(i, "left")) : t.right > n.right - N(r, "right") && (s = t.right - n.right + N(i, "right")), s || c) {
146
- if (e) a.defaultView.scrollBy(s, c);
147
- else {
148
- let e = o.scrollLeft, n = o.scrollTop;
149
- c && (o.scrollTop += c), s && (o.scrollLeft += s);
150
- let r = o.scrollLeft - e, i = o.scrollTop - n;
151
- t = {
152
- left: t.left - r,
153
- top: t.top - i,
154
- right: t.right - r,
155
- bottom: t.bottom - i
156
- };
157
- }
158
- }
159
- let l = e ? "fixed" : getComputedStyle(o).position;
160
- if (/^(fixed|sticky)$/.test(l)) break;
161
- o = l == "absolute" ? o.offsetParent : d(o);
162
- }
163
- }
164
- function ye(e) {
165
- let t = e.dom.getBoundingClientRect(), n = Math.max(0, t.top), r, i;
166
- for (let a = (t.left + t.right) / 2, o = n + 1; o < Math.min(innerHeight, t.bottom); o += 5) {
167
- let t = e.root.elementFromPoint(a, o);
168
- if (!t || t == e.dom || !e.dom.contains(t)) continue;
169
- let s = t.getBoundingClientRect();
170
- if (s.top >= n - 20) {
171
- r = t, i = s.top;
172
- break;
173
- }
174
- }
175
- return {
176
- refDOM: r,
177
- refTop: i,
178
- stack: be(e.dom)
179
- };
180
- }
181
- function be(e) {
182
- let t = [], n = e.ownerDocument;
183
- for (let r = e; r && (t.push({
184
- dom: r,
185
- top: r.scrollTop,
186
- left: r.scrollLeft
187
- }), e != n); r = d(r));
188
- return t;
189
- }
190
- function xe({ refDOM: e, refTop: t, stack: n }) {
191
- let r = e ? e.getBoundingClientRect().top : 0;
192
- Se(n, r == 0 ? 0 : r - t);
193
- }
194
- function Se(e, t) {
195
- for (let n = 0; n < e.length; n++) {
196
- let { dom: r, top: i, left: a } = e[n];
197
- r.scrollTop != i + t && (r.scrollTop = i + t), r.scrollLeft != a && (r.scrollLeft = a);
198
- }
199
- }
200
- var P = null;
201
- function Ce(e) {
202
- if (e.setActive) return e.setActive();
203
- if (P) return e.focus(P);
204
- let t = be(e);
205
- e.focus(P == null ? { get preventScroll() {
206
- return P = { preventScroll: !0 }, !0;
207
- } } : void 0), P || (P = !1, Se(t, 0));
208
- }
209
- function we(e, t) {
210
- let n, r = 2e8, i, a = 0, o = t.top, s = t.top, c, l;
211
- for (let u = e.firstChild, d = 0; u; u = u.nextSibling, d++) {
212
- let e;
213
- if (y(u)) e = u.getClientRects();
214
- else if (b(u)) e = p(u).getClientRects();
215
- else continue;
216
- for (let f = 0; f < e.length; f++) {
217
- let p = e[f];
218
- if (p.top <= o && p.bottom >= s) {
219
- o = Math.max(p.bottom, o), s = Math.min(p.top, s);
220
- let e = p.left > t.left ? p.left - t.left : p.right < t.left ? t.left - p.right : 0;
221
- if (e < r) {
222
- n = u, r = e, i = e && b(n) ? {
223
- left: p.right < t.left ? p.right : p.left,
224
- top: t.top
225
- } : t, y(u) && e && (a = d + +(t.left >= (p.left + p.right) / 2));
226
- continue;
227
- }
228
- } else p.top > t.top && !c && p.left <= t.left && p.right >= t.left && (c = u, l = {
229
- left: Math.max(p.left, Math.min(p.right, t.left)),
230
- top: p.top
231
- });
232
- !n && (t.left >= p.right && t.top >= p.top || t.left >= p.left && t.top >= p.bottom) && (a = d + 1);
233
- }
234
- }
235
- return !n && c && (n = c, i = l, r = 0), n && b(n) ? Te(n, i) : !n || r ? {
236
- node: e,
237
- offset: a
238
- } : we(n, i);
239
- }
240
- function Te(e, t) {
241
- let n = e.nodeValue.length, r = document.createRange(), i;
242
- for (let a = 0; a < n; a++) {
243
- r.setEnd(e, a + 1), r.setStart(e, a);
244
- let n = F(r, 1);
245
- if (n.top != n.bottom && Ee(t, n)) {
246
- i = {
247
- node: e,
248
- offset: a + +(t.left >= (n.left + n.right) / 2)
249
- };
250
- break;
251
- }
252
- }
253
- return r.detach(), i || {
254
- node: e,
255
- offset: 0
256
- };
257
- }
258
- function Ee(e, t) {
259
- return e.left >= t.left - 1 && e.left <= t.right + 1 && e.top >= t.top - 1 && e.top <= t.bottom + 1;
260
- }
261
- function De(e, t) {
262
- let n = e.parentNode;
263
- return n && /^li$/i.test(n.nodeName) && t.left < e.getBoundingClientRect().left ? n : e;
264
- }
265
- function Oe(e, t, n) {
266
- let { node: r, offset: i } = we(t, n), a = -1;
267
- if (y(r) && !r.firstChild) {
268
- let e = r.getBoundingClientRect();
269
- a = e.left != e.right && n.left > (e.left + e.right) / 2 ? 1 : -1;
270
- }
271
- return e.docView.posFromDOM(r, i, a);
272
- }
273
- function ke(e, t, n, r) {
274
- let i = -1;
275
- for (let n = t, a = !1; n != e.dom;) {
276
- let t = e.docView.nearestDesc(n, !0), o;
277
- if (!t) return null;
278
- if (y(t.dom) && (t.node.isBlock && t.parent || !t.contentDOM) && ((o = t.dom.getBoundingClientRect()).width || o.height) && (t.node.isBlock && t.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName) && (!a && o.left > r.left || o.top > r.top ? i = t.posBefore : (!a && o.right < r.left || o.bottom < r.top) && (i = t.posAfter), a = !0), !t.contentDOM && i < 0 && !t.node.isText)) return (t.node.isBlock ? r.top < (o.top + o.bottom) / 2 : r.left < (o.left + o.right) / 2) ? t.posBefore : t.posAfter;
279
- n = t.dom.parentNode;
280
- }
281
- return i > -1 ? i : e.docView.posFromDOM(t, n, -1);
282
- }
283
- function Ae(e, t, n) {
284
- let r = e.childNodes.length;
285
- if (r && n.top < n.bottom) for (let i = Math.max(0, Math.min(r - 1, Math.floor(r * (t.top - n.top) / (n.bottom - n.top)) - 2)), a = i;;) {
286
- let n = e.childNodes[a];
287
- if (y(n)) {
288
- let e = n.getClientRects();
289
- for (let r = 0; r < e.length; r++) {
290
- let i = e[r];
291
- if (Ee(t, i)) return Ae(n, t, i);
292
- }
293
- }
294
- if ((a = (a + 1) % r) == i) break;
295
- }
296
- return e;
297
- }
298
- function je(e, t) {
299
- let n = e.dom.ownerDocument, r, i = 0, a = ae(n, t.left, t.top);
300
- a && ({node: r, offset: i} = a);
301
- let o = (e.root.elementFromPoint ? e.root : n).elementFromPoint(t.left, t.top), s;
302
- if (!o || !e.dom.contains(o)) {
303
- let n = e.dom.getBoundingClientRect();
304
- if (!Ee(t, n) || (o = Ae(e.dom, t, n), !o)) return null;
305
- }
306
- if (A) for (let e = o; r && e; e = d(e)) e.draggable && (r = void 0);
307
- if (o = De(o, t), r) {
308
- if (O && y(r) && (i = Math.min(i, r.childNodes.length), i < r.childNodes.length)) {
309
- let e = r.childNodes[i], n;
310
- e.nodeName == "IMG" && (n = e.getBoundingClientRect()).right <= t.left && n.bottom > t.top && i++;
311
- }
312
- let n;
313
- me && i && y(r) && y(n = r.childNodes[i - 1]) && n.contentEditable == "false" && n.getBoundingClientRect().top >= t.top && i--, r == e.dom && i == r.childNodes.length - 1 && y(r.lastChild) && t.top > r.lastChild.getBoundingClientRect().bottom ? s = e.state.doc.content.size : i != 0 && y(r) && r.childNodes[i - 1].nodeName == "BR" || (s = ke(e, r, i, t));
314
- }
315
- s ??= Oe(e, o, t);
316
- let c = e.docView.nearestDesc(o, !0);
317
- return {
318
- pos: s,
319
- inside: c ? c.posAtStart - c.border : -1
320
- };
321
- }
322
- function Me(e) {
323
- return e.top < e.bottom || e.left < e.right;
324
- }
325
- function F(e, t) {
326
- let n = e.getClientRects();
327
- if (n.length) {
328
- let e = n[t < 0 ? 0 : n.length - 1];
329
- if (Me(e)) return e;
330
- }
331
- return Array.prototype.find.call(n, Me) || e.getBoundingClientRect();
332
- }
333
- var Ne = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
334
- function Pe(e, t, n) {
335
- let { node: r, offset: i, atom: a } = e.docView.domFromPos(t, n < 0 ? -1 : 1), o = me || O;
336
- if (b(r)) {
337
- if (o && (Ne.test(r.nodeValue) || (n < 0 ? !i : i == r.nodeValue.length))) {
338
- let e = F(p(r, i, i), n);
339
- if (O && i && /\s/.test(r.nodeValue[i - 1]) && i < r.nodeValue.length) {
340
- let t = F(p(r, i - 1, i - 1), -1);
341
- if (t.top == e.top) {
342
- let n = F(p(r, i, i + 1), -1);
343
- if (n.top != e.top) return Fe(n, n.left < t.left);
344
- }
345
- }
346
- return e;
347
- }
348
- {
349
- let e = i, t = i, a = n < 0 ? 1 : -1;
350
- return n < 0 && !i ? (t++, a = -1) : n >= 0 && i == r.nodeValue.length ? (e--, a = 1) : n < 0 ? e-- : t++, Fe(F(p(r, e, t), a), a < 0);
351
- }
352
- }
353
- if (!e.state.doc.resolve(t - (a || 0)).parent.inlineContent) {
354
- if (a == null && i && (n < 0 || i == v(r))) {
355
- let e = r.childNodes[i - 1];
356
- if (y(e)) return Ie(e.getBoundingClientRect(), !1);
357
- }
358
- if (a == null && i < v(r)) {
359
- let e = r.childNodes[i];
360
- if (y(e)) return Ie(e.getBoundingClientRect(), !0);
361
- }
362
- return Ie(r.getBoundingClientRect(), n >= 0);
363
- }
364
- if (a == null && i && (n < 0 || i == v(r))) {
365
- let e = r.childNodes[i - 1], t = b(e) ? p(e, v(e) - +!o) : y(e) && (e.nodeName != "BR" || !e.nextSibling) ? e : null;
366
- if (t) return Fe(F(t, 1), !1);
367
- }
368
- if (a == null && i < v(r)) {
369
- let e = r.childNodes[i];
370
- for (; e.pmViewDesc && e.pmViewDesc.ignoreForCoords;) e = e.nextSibling;
371
- let t = e ? b(e) ? p(e, 0, +!o) : y(e) ? e : null : null;
372
- if (t) return Fe(F(t, -1), !0);
373
- }
374
- return Fe(F(b(r) ? p(r) : r, -n), n >= 0);
375
- }
376
- function Fe(e, t) {
377
- if (e.width == 0) return e;
378
- let n = t ? e.left : e.right;
379
- return {
380
- top: e.top,
381
- bottom: e.bottom,
382
- left: n,
383
- right: n
384
- };
385
- }
386
- function Ie(e, t) {
387
- if (e.height == 0) return e;
388
- let n = t ? e.top : e.bottom;
389
- return {
390
- top: n,
391
- bottom: n,
392
- left: e.left,
393
- right: e.right
394
- };
395
- }
396
- function Le(e, t, n) {
397
- let r = e.state, i = e.root.activeElement;
398
- r != t && e.updateState(t), i != e.dom && e.focus();
399
- try {
400
- return n();
401
- } finally {
402
- r != t && e.updateState(r), i != e.dom && i && i.focus();
403
- }
404
- }
405
- function Re(e, t, n) {
406
- let r = t.selection, i = n == "up" ? r.$from : r.$to;
407
- return Le(e, t, () => {
408
- let { node: t } = e.docView.domFromPos(i.pos, n == "up" ? -1 : 1);
409
- for (;;) {
410
- let n = e.docView.nearestDesc(t, !0);
411
- if (!n) break;
412
- if (n.node.isBlock) {
413
- t = n.contentDOM || n.dom;
414
- break;
415
- }
416
- t = n.dom.parentNode;
417
- }
418
- let r = Pe(e, i.pos, 1);
419
- for (let e = t.firstChild; e; e = e.nextSibling) {
420
- let t;
421
- if (y(e)) t = e.getClientRects();
422
- else if (b(e)) t = p(e, 0, e.nodeValue.length).getClientRects();
423
- else continue;
424
- for (let e = 0; e < t.length; e++) {
425
- let i = t[e];
426
- if (i.bottom > i.top + 1 && (n == "up" ? r.top - i.top > (i.bottom - r.top) * 2 : i.bottom - r.bottom > (r.bottom - i.top) * 2)) return !1;
427
- }
428
- }
429
- return !0;
430
- });
431
- }
432
- var ze = /[\u0590-\u08ac]/;
433
- function Be(e, t, n) {
434
- let { $head: r } = t.selection;
435
- if (!r.parent.isTextblock) return !1;
436
- let i = r.parentOffset, a = !i, o = i == r.parent.content.size, s = e.domSelection();
437
- return s ? !ze.test(r.parent.textContent) || !s.modify ? n == "left" || n == "backward" ? a : o : Le(e, t, () => {
438
- let { focusNode: t, focusOffset: i, anchorNode: a, anchorOffset: o } = e.domSelectionRange(), c = s.caretBidiLevel;
439
- s.modify("move", n, "character");
440
- let l = r.depth ? e.docView.domAfterPos(r.before()) : e.dom, { focusNode: u, focusOffset: d } = e.domSelectionRange(), f = u && !x(l, u) || t == u && i == d;
441
- try {
442
- s.collapse(a, o), t && (t != a || i != o) && s.extend && s.extend(t, i);
443
- } catch {}
444
- return c != null && (s.caretBidiLevel = c), f;
445
- }) : r.pos == r.start() || r.pos == r.end();
446
- }
447
- var Ve = null, He = null, Ue = !1;
448
- function We(e, t, n) {
449
- return Ve == t && He == n ? Ue : (Ve = t, He = n, Ue = n == "up" || n == "down" ? Re(e, t, n) : Be(e, t, n));
450
- }
451
- var I = 0, Ge = 1, L = 2, R = 3, Ke = class {
452
- constructor(e, t, n, r) {
453
- this.parent = e, this.children = t, this.dom = n, this.contentDOM = r, this.dirty = I, n.pmViewDesc = this;
454
- }
455
- matchesWidget(e) {
456
- return !1;
457
- }
458
- matchesMark(e) {
459
- return !1;
460
- }
461
- matchesNode(e, t, n) {
462
- return !1;
463
- }
464
- matchesHack(e) {
465
- return !1;
466
- }
467
- parseRule(e) {
468
- return null;
469
- }
470
- stopEvent(e) {
471
- return !1;
472
- }
473
- get size() {
474
- let e = 0;
475
- for (let t = 0; t < this.children.length; t++) e += this.children[t].size;
476
- return e;
477
- }
478
- get border() {
479
- return 0;
480
- }
481
- destroy() {
482
- this.parent = void 0, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0);
483
- for (let e = 0; e < this.children.length; e++) this.children[e].destroy();
484
- }
485
- posBeforeChild(e) {
486
- for (let t = 0, n = this.posAtStart;; t++) {
487
- let r = this.children[t];
488
- if (r == e) return n;
489
- n += r.size;
490
- }
491
- }
492
- get posBefore() {
493
- return this.parent.posBeforeChild(this);
494
- }
495
- get posAtStart() {
496
- return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;
497
- }
498
- get posAfter() {
499
- return this.posBefore + this.size;
500
- }
501
- get posAtEnd() {
502
- return this.posAtStart + this.size - 2 * this.border;
503
- }
504
- localPosFromDOM(e, t, n) {
505
- if (this.contentDOM && x(this.contentDOM, e)) {
506
- if (n < 0) {
507
- let n, r;
508
- if (e == this.contentDOM) n = e.childNodes[t - 1];
509
- else {
510
- for (; e.parentNode != this.contentDOM;) e = e.parentNode;
511
- n = e.previousSibling;
512
- }
513
- for (; n && !((r = n.pmViewDesc) && r.parent == this);) n = n.previousSibling;
514
- return n ? this.posBeforeChild(r) + r.size : this.posAtStart;
515
- }
516
- {
517
- let n, r;
518
- if (e == this.contentDOM) n = e.childNodes[t];
519
- else {
520
- for (; e.parentNode != this.contentDOM;) e = e.parentNode;
521
- n = e.nextSibling;
522
- }
523
- for (; n && !((r = n.pmViewDesc) && r.parent == this);) n = n.nextSibling;
524
- return n ? this.posBeforeChild(r) : this.posAtEnd;
525
- }
526
- }
527
- let r;
528
- if (e == this.dom && this.contentDOM) r = t > u(this.contentDOM);
529
- else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
530
- let n = e.compareDocumentPosition(this.contentDOM);
531
- r = n & 16 ? t > Array.from(e.childNodes).findIndex((e) => e.contains(this.contentDOM)) : !(n & 4);
532
- } else if (this.dom.firstChild) {
533
- if (t == 0) for (let t = e;; t = t.parentNode) {
534
- if (t == this.dom) {
535
- r = !1;
536
- break;
537
- }
538
- if (t.previousSibling) break;
539
- }
540
- if (r == null && t == e.childNodes.length) for (let t = e;; t = t.parentNode) {
541
- if (t == this.dom) {
542
- r = !0;
543
- break;
544
- }
545
- if (t.nextSibling) break;
546
- }
547
- }
548
- return r ?? n > 0 ? this.posAtEnd : this.posAtStart;
549
- }
550
- nearestDesc(e, t = !1) {
551
- for (let n = !0, r = e; r; r = r.parentNode) {
552
- let i = this.getDesc(r), a;
553
- if (i && (!t || i.node)) {
554
- if (n && (a = i.nodeDOM) && !(y(a) ? x(a, e) : a == e)) n = !1;
555
- else return i;
556
- }
557
- }
558
- }
559
- getDesc(e) {
560
- let t = e.pmViewDesc;
561
- for (let e = t; e; e = e.parent) if (e == this) return t;
562
- }
563
- posFromDOM(e, t, n) {
564
- for (let r = e; r; r = r.parentNode) {
565
- let i = this.getDesc(r);
566
- if (i) return i.localPosFromDOM(e, t, n);
567
- }
568
- return -1;
569
- }
570
- descAt(e) {
571
- for (let t = 0, n = 0; t < this.children.length; t++) {
572
- let r = this.children[t], i = n + r.size;
573
- if (n == e && i != n) {
574
- for (; !r.border && r.children.length;) for (let e = 0; e < r.children.length; e++) {
575
- let t = r.children[e];
576
- if (t.size) {
577
- r = t;
578
- break;
579
- }
580
- }
581
- return r;
582
- }
583
- if (e < i) return r.descAt(e - n - r.border);
584
- n = i;
585
- }
586
- }
587
- domFromPos(e, t) {
588
- if (!this.contentDOM) return {
589
- node: this.dom,
590
- offset: 0,
591
- atom: e + 1
592
- };
593
- let n = 0, r = 0;
594
- for (let t = 0; n < this.children.length; n++) {
595
- let i = this.children[n], a = t + i.size;
596
- if (a > e) {
597
- r = e - t;
598
- break;
599
- }
600
- t = a;
601
- }
602
- if (r) return this.children[n].domFromPos(r - this.children[n].border, t);
603
- for (; n > 0; n--) {
604
- let e = this.children[n - 1];
605
- if (e.size || !(e instanceof Qe || e instanceof qe && e.side >= 0)) break;
606
- }
607
- if (t <= 0) {
608
- let e, r = !0;
609
- for (; e = n ? this.children[n - 1] : null, e && e.dom.parentNode != this.contentDOM; n--, r = !1);
610
- return e && t && r && !e.border && !e.domAtom ? e.domFromPos(e.size, t) : {
611
- node: this.contentDOM,
612
- offset: e ? u(e.dom) + 1 : 0
613
- };
614
- }
615
- {
616
- let e, r = !0;
617
- for (; e = n < this.children.length ? this.children[n] : null, e && e.dom.parentNode != this.contentDOM; n++, r = !1);
618
- return e && r && !e.border && !e.domAtom ? e.domFromPos(0, t) : {
619
- node: this.contentDOM,
620
- offset: e ? u(e.dom) : this.contentDOM.childNodes.length
621
- };
622
- }
623
- }
624
- parseRange(e, t, n = 0) {
625
- if (this.children.length == 0) return {
626
- node: this.contentDOM,
627
- from: e,
628
- to: t,
629
- fromOffset: 0,
630
- toOffset: this.contentDOM.childNodes.length
631
- };
632
- let r = -1, i = -1;
633
- for (let a = n, o = 0;; o++) {
634
- let n = this.children[o], s = a + n.size;
635
- if (r == -1 && e <= s) {
636
- let i = a + n.border;
637
- if (e >= i && t <= s - n.border && n.node && n.contentDOM && this.contentDOM.contains(n.contentDOM)) return n.parseRange(e, t, i);
638
- e = a;
639
- for (let t = o; t > 0; t--) {
640
- let n = this.children[t - 1];
641
- if (n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(1)) {
642
- r = u(n.dom) + 1;
643
- break;
644
- }
645
- e -= n.size;
646
- }
647
- r == -1 && (r = 0);
648
- }
649
- if (r > -1 && (s > t || o == this.children.length - 1)) {
650
- t = s;
651
- for (let e = o + 1; e < this.children.length; e++) {
652
- let n = this.children[e];
653
- if (n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(-1)) {
654
- i = u(n.dom);
655
- break;
656
- }
657
- t += n.size;
658
- }
659
- i == -1 && (i = this.contentDOM.childNodes.length);
660
- break;
661
- }
662
- a = s;
663
- }
664
- return {
665
- node: this.contentDOM,
666
- from: e,
667
- to: t,
668
- fromOffset: r,
669
- toOffset: i
670
- };
671
- }
672
- emptyChildAt(e) {
673
- if (this.border || !this.contentDOM || !this.children.length) return !1;
674
- let t = this.children[e < 0 ? 0 : this.children.length - 1];
675
- return t.size == 0 || t.emptyChildAt(e);
676
- }
677
- domAfterPos(e) {
678
- let { node: t, offset: n } = this.domFromPos(e, 0);
679
- if (!y(t) || n == t.childNodes.length) throw RangeError("No node after pos " + e);
680
- return t.childNodes[n];
681
- }
682
- setSelection(e, t, n, r = !1) {
683
- let i = Math.min(e, t), a = Math.max(e, t);
684
- for (let o = 0, s = 0; o < this.children.length; o++) {
685
- let c = this.children[o], l = s + c.size;
686
- if (i > s && a < l) return c.setSelection(e - s - c.border, t - s - c.border, n, r);
687
- s = l;
688
- }
689
- let o = this.domFromPos(e, e ? -1 : 1), s = t == e ? o : this.domFromPos(t, t ? -1 : 1), c = n.root.getSelection(), l = n.domSelectionRange(), d = !1;
690
- if ((O || A) && e == t) {
691
- let { node: e, offset: t } = o;
692
- if (b(e)) {
693
- if (d = !!(t && e.nodeValue[t - 1] == "\n"), d && t == e.nodeValue.length) for (let t = e, n; t; t = t.parentNode) {
694
- if (n = t.nextSibling) {
695
- n.nodeName == "BR" && (o = s = {
696
- node: n.parentNode,
697
- offset: u(n) + 1
698
- });
699
- break;
700
- }
701
- let e = t.pmViewDesc;
702
- if (e && e.node && e.node.isBlock) break;
703
- }
704
- } else {
705
- let n = e.childNodes[t - 1];
706
- d = n && (n.nodeName == "BR" || n.contentEditable == "false");
707
- }
708
- }
709
- if (O && l.focusNode && l.focusNode != s.node && y(l.focusNode)) {
710
- let e = l.focusNode.childNodes[l.focusOffset];
711
- e && e.contentEditable == "false" && (r = !0);
712
- }
713
- if (!(r || d && A) && h(o.node, o.offset, l.anchorNode, l.anchorOffset) && h(s.node, s.offset, l.focusNode, l.focusOffset)) return;
714
- let f = !1;
715
- if ((c.extend || e == t) && !(d && O)) {
716
- c.collapse(o.node, o.offset);
717
- try {
718
- e != t && c.extend(s.node, s.offset), f = !0;
719
- } catch {}
720
- }
721
- if (!f) {
722
- if (e > t) {
723
- let e = o;
724
- o = s, s = e;
725
- }
726
- let n = document.createRange();
727
- n.setEnd(s.node, s.offset), n.setStart(o.node, o.offset), c.removeAllRanges(), c.addRange(n);
728
- }
729
- }
730
- ignoreMutation(e) {
731
- return !this.contentDOM && e.type != "selection";
732
- }
733
- get contentLost() {
734
- return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);
735
- }
736
- markDirty(e, t) {
737
- for (let n = 0, r = 0; r < this.children.length; r++) {
738
- let i = this.children[r], a = n + i.size;
739
- if (n == a ? e <= a && t >= n : e < a && t > n) {
740
- let r = n + i.border, o = a - i.border;
741
- if (e >= r && t <= o) {
742
- this.dirty = e == n || t == a ? L : Ge, e == r && t == o && (i.contentLost || i.dom.parentNode != this.contentDOM) ? i.dirty = R : i.markDirty(e - r, t - r);
743
- return;
744
- }
745
- i.dirty = i.dom == i.contentDOM && i.dom.parentNode == this.contentDOM && !i.children.length ? L : R;
746
- }
747
- n = a;
748
- }
749
- this.dirty = L;
750
- }
751
- markParentsDirty() {
752
- let e = 1;
753
- for (let t = this.parent; t; t = t.parent, e++) {
754
- let n = e == 1 ? L : Ge;
755
- t.dirty < n && (t.dirty = n);
756
- }
757
- }
758
- get domAtom() {
759
- return !1;
760
- }
761
- get ignoreForCoords() {
762
- return !1;
763
- }
764
- get ignoreForSelection() {
765
- return !1;
766
- }
767
- isText(e) {
768
- return !1;
769
- }
770
- }, qe = class extends Ke {
771
- constructor(e, t, n, r) {
772
- let i, a = t.type.toDOM;
773
- if (typeof a == "function" && (a = a(n, () => {
774
- if (!i) return r;
775
- if (i.parent) return i.parent.posBeforeChild(i);
776
- })), !t.type.spec.raw) {
777
- let e = y(a) ? a : document.createElement("span");
778
- e != a && (e.appendChild(a), a = e), e.hasAttribute("contenteditable") || (e.contentEditable = "false"), e.classList.add("ProseMirror-widget");
779
- }
780
- super(e, [], a, null), this.widget = t, this.widget = t, i = this;
781
- }
782
- matchesWidget(e) {
783
- return this.dirty == I && e.type.eq(this.widget.type);
784
- }
785
- parseRule() {
786
- return { ignore: !0 };
787
- }
788
- stopEvent(e) {
789
- let t = this.widget.spec.stopEvent;
790
- return t ? t(e) : !1;
791
- }
792
- ignoreMutation(e) {
793
- return e.type != "selection" || this.widget.spec.ignoreSelection;
794
- }
795
- destroy() {
796
- this.widget.type.destroy(this.dom), super.destroy();
797
- }
798
- get domAtom() {
799
- return !0;
800
- }
801
- get ignoreForSelection() {
802
- return !!this.widget.type.spec.relaxedSide;
803
- }
804
- get side() {
805
- return this.widget.type.side;
806
- }
807
- }, Je = class extends Ke {
808
- constructor(e, t, n, r) {
809
- super(e, [], t, null), this.textDOM = n, this.text = r;
810
- }
811
- get size() {
812
- return this.text.length;
813
- }
814
- localPosFromDOM(e, t) {
815
- return e == this.textDOM ? this.posAtStart + t : this.posAtStart + (t ? this.size : 0);
816
- }
817
- domFromPos(e) {
818
- return {
819
- node: this.textDOM,
820
- offset: e
821
- };
822
- }
823
- ignoreMutation(e) {
824
- return e.type === "characterData" && e.target.nodeValue == e.oldValue;
825
- }
826
- }, Ye = class e extends Ke {
827
- constructor(e, t, n, r, i) {
828
- super(e, [], n, r), this.mark = t, this.spec = i;
829
- }
830
- static create(t, n, r, i) {
831
- let o = i.nodeViews[n.type.name], s = o && o(n, i, r);
832
- return s && s.dom || (s = a.renderSpec(document, n.type.spec.toDOM(n, r), null, n.attrs)), new e(t, n, s.dom, s.contentDOM || s.dom, s);
833
- }
834
- parseRule() {
835
- return this.dirty & R || this.mark.type.spec.reparseInView ? null : {
836
- mark: this.mark.type.name,
837
- attrs: this.mark.attrs,
838
- contentElement: this.contentDOM
839
- };
840
- }
841
- matchesMark(e) {
842
- return this.dirty != R && this.mark.eq(e);
843
- }
844
- markDirty(e, t) {
845
- if (super.markDirty(e, t), this.dirty != I) {
846
- let e = this.parent;
847
- for (; !e.node;) e = e.parent;
848
- e.dirty < this.dirty && (e.dirty = this.dirty), this.dirty = I;
849
- }
850
- }
851
- slice(t, n, r) {
852
- let i = e.create(this.parent, this.mark, !0, r), a = this.children, o = this.size;
853
- n < o && (a = mt(a, n, o, r)), t > 0 && (a = mt(a, 0, t, r));
854
- for (let e = 0; e < a.length; e++) a[e].parent = i;
855
- return i.children = a, i;
856
- }
857
- ignoreMutation(e) {
858
- return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
859
- }
860
- destroy() {
861
- this.spec.destroy && this.spec.destroy(), super.destroy();
862
- }
863
- }, z = class e extends Ke {
864
- constructor(e, t, n, r, i, a, o) {
865
- super(e, [], i, a), this.node = t, this.outerDeco = n, this.innerDeco = r, this.nodeDOM = o;
866
- }
867
- static create(t, n, r, i, o, s) {
868
- let c = o.nodeViews[n.type.name], l, u = c && c(n, o, () => {
869
- if (!l) return s;
870
- if (l.parent) return l.parent.posBeforeChild(l);
871
- }, r, i), d = u && u.dom, f = u && u.contentDOM;
872
- if (n.isText) {
873
- if (!d) d = document.createTextNode(n.text);
874
- else if (!b(d)) throw RangeError("Text must be rendered as a DOM text node");
875
- } else if (!d) {
876
- let e = a.renderSpec(document, n.type.spec.toDOM(n), null, n.attrs);
877
- ({dom: d, contentDOM: f} = e);
878
- }
879
- !f && !n.isText && d.nodeName != "BR" && (d.hasAttribute("contenteditable") || (d.contentEditable = "false"), n.type.spec.draggable && (d.draggable = !0));
880
- let p = d;
881
- return d = at(d, r, n), u ? l = new $e(t, n, r, i, d, f || null, p, u) : n.isText ? new Ze(t, n, r, i, d, p) : new e(t, n, r, i, d, f || null, p);
882
- }
883
- parseRule(e) {
884
- if (this.node.type.spec.reparseInView) return null;
885
- let t = {
886
- node: this.node.type.name,
887
- attrs: this.node.attrs
888
- };
889
- if (this.node.type.whitespace == "pre" && (t.preserveWhitespace = "full"), !this.contentDOM) t.getContent = () => this.node.content;
890
- else if (!this.contentLost) t.contentElement = this.contentDOM;
891
- else {
892
- for (let e = this.children.length - 1; e >= 0; e--) {
893
- let n = this.children[e];
894
- if (this.dom.contains(n.dom.parentNode)) {
895
- t.contentElement = n.dom.parentNode;
896
- break;
897
- }
898
- }
899
- if (!t.contentElement) {
900
- let n = e && e.find((t) => y(t) && e.indexOf(t.parentNode) < 0 && this.dom.contains(t));
901
- n ? t.contentElement = n : t.getContent = () => o.empty;
902
- }
903
- }
904
- return t;
905
- }
906
- matchesNode(e, t, n) {
907
- return this.dirty == I && e.eq(this.node) && ot(t, this.outerDeco) && n.eq(this.innerDeco);
908
- }
909
- get size() {
910
- return this.node.nodeSize;
911
- }
912
- get border() {
913
- return +!this.node.isLeaf;
914
- }
915
- updateChildren(e, t) {
916
- let n = this.node.inlineContent, r = t, i = e.composing ? this.localCompositionInfo(e, t) : null, a = i && i.pos > -1 ? i : null, o = i && i.pos < 0, c = new ct(this, a && a.node, e), l = this.node.inlineContent, u = l && this.node.isBlock;
917
- dt(this.node, this.innerDeco, (t, i, a) => {
918
- t.spec.marks ? c.syncToMarks(t.spec.marks, n, e, i) : t.type.side >= 0 && !a && c.syncToMarks(i == this.node.childCount ? s.none : this.node.child(i).marks, n, e, i), c.placeWidget(t, e, r);
919
- }, (t, a, s, d) => {
920
- c.syncToMarks(t.marks, n, e, d), u && t.isAtom && !t.isText && c.addHackNode("IMG", c.top);
921
- let f;
922
- c.findNodeMatch(t, a, s, d) || o && e.state.selection.from > r && e.state.selection.to < r + t.nodeSize && (f = c.findIndexWithChild(i.node)) > -1 && c.updateNodeAt(t, a, s, f, e) || c.updateNextNode(t, a, s, e, d, r) || c.addNode(t, a, s, e, r), r += t.nodeSize, l && (u = t.isAtom && !t.isText);
923
- }), c.syncToMarks([], n, e, 0), this.node.isTextblock && c.addTextblockHacks(), c.destroyRest(), (c.changed || this.dirty == L) && (a && this.protectLocalComposition(e, a), et(this.contentDOM, this.children, e), fe && ft(this.dom));
924
- }
925
- localCompositionInfo(e, t) {
926
- let { from: n, to: i } = e.state.selection;
927
- if (!(e.state.selection instanceof r) || n < t || i > t + this.node.content.size) return null;
928
- let a = e.input.compositionNode;
929
- if (!a || !this.dom.contains(a.parentNode)) return null;
930
- if (this.node.inlineContent) {
931
- let e = a.nodeValue, r = pt(this.node.content, e, n - t, i - t);
932
- return r < 0 ? null : {
933
- node: a,
934
- pos: r,
935
- text: e
936
- };
937
- }
938
- return {
939
- node: a,
940
- pos: -1,
941
- text: ""
942
- };
943
- }
944
- protectLocalComposition(e, { node: t, pos: n, text: r }) {
945
- if (this.getDesc(t)) return;
946
- let i = t;
947
- for (; i.parentNode != this.contentDOM; i = i.parentNode) {
948
- for (; i.previousSibling;) i.parentNode.removeChild(i.previousSibling);
949
- for (; i.nextSibling;) i.parentNode.removeChild(i.nextSibling);
950
- i.pmViewDesc && (i.pmViewDesc = void 0);
951
- }
952
- let a = new Je(this, i, t, r);
953
- e.input.compositionNodes.push(a), this.children = mt(this.children, n, n + r.length, e, a);
954
- }
955
- update(e, t, n, r) {
956
- return this.dirty == R || !e.sameMarkup(this.node) ? !1 : (this.updateInner(e, t, n, r), !0);
957
- }
958
- updateInner(e, t, n, r) {
959
- this.updateOuterDeco(t), this.node = e, this.innerDeco = n, this.contentDOM && this.updateChildren(r, this.posAtStart), this.dirty = I;
960
- }
961
- updateOuterDeco(e) {
962
- if (ot(e, this.outerDeco)) return;
963
- let t = !y(this.nodeDOM), n = this.dom;
964
- this.dom = rt(this.dom, this.nodeDOM, nt(this.outerDeco, this.node, t), nt(e, this.node, t)), this.dom != n && (n.pmViewDesc = void 0, this.dom.pmViewDesc = this), this.outerDeco = e;
965
- }
966
- selectNode() {
967
- y(this.nodeDOM) && (this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.nodeDOM.draggable = !0));
968
- }
969
- deselectNode() {
970
- y(this.nodeDOM) && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.nodeDOM.removeAttribute("draggable"));
971
- }
972
- get domAtom() {
973
- return this.node.isAtom;
974
- }
975
- };
976
- function Xe(e, t, n, r, i) {
977
- at(r, t, e);
978
- let a = new z(void 0, e, t, n, r, r, r);
979
- return a.contentDOM && a.updateChildren(i, 0), a;
980
- }
981
- var Ze = class e extends z {
982
- constructor(e, t, n, r, i, a) {
983
- super(e, t, n, r, i, null, a);
984
- }
985
- parseRule() {
986
- let e = this.nodeDOM.parentNode;
987
- for (; e && e != this.dom && !e.pmIsDeco;) e = e.parentNode;
988
- return { skip: e || !0 };
989
- }
990
- update(e, t, n, r) {
991
- return this.dirty == R || this.dirty != I && !this.inParent() || !e.sameMarkup(this.node) ? !1 : (this.updateOuterDeco(t), (this.dirty != I || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = e.text, r.trackWrites == this.nodeDOM && (r.trackWrites = null)), this.node = e, this.dirty = I, !0);
992
- }
993
- inParent() {
994
- let e = this.parent.contentDOM;
995
- for (let t = this.nodeDOM; t; t = t.parentNode) if (t == e) return !0;
996
- return !1;
997
- }
998
- domFromPos(e) {
999
- return {
1000
- node: this.nodeDOM,
1001
- offset: e
1002
- };
1003
- }
1004
- localPosFromDOM(e, t, n) {
1005
- return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, n);
1006
- }
1007
- ignoreMutation(e) {
1008
- return e.type != "characterData" && e.type != "selection";
1009
- }
1010
- slice(t, n, r) {
1011
- let i = this.node.cut(t, n), a = document.createTextNode(i.text);
1012
- return new e(this.parent, i, this.outerDeco, this.innerDeco, a, a);
1013
- }
1014
- markDirty(e, t) {
1015
- super.markDirty(e, t), this.dom != this.nodeDOM && (e == 0 || t == this.nodeDOM.nodeValue.length) && (this.dirty = R);
1016
- }
1017
- get domAtom() {
1018
- return !1;
1019
- }
1020
- isText(e) {
1021
- return this.node.text == e;
1022
- }
1023
- }, Qe = class extends Ke {
1024
- parseRule() {
1025
- return { ignore: !0 };
1026
- }
1027
- matchesHack(e) {
1028
- return this.dirty == I && this.dom.nodeName == e;
1029
- }
1030
- get domAtom() {
1031
- return !0;
1032
- }
1033
- get ignoreForCoords() {
1034
- return this.dom.nodeName == "IMG";
1035
- }
1036
- }, $e = class extends z {
1037
- constructor(e, t, n, r, i, a, o, s) {
1038
- super(e, t, n, r, i, a, o), this.spec = s;
1039
- }
1040
- update(e, t, n, r) {
1041
- if (this.dirty == R) return !1;
1042
- if (this.spec.update && (this.node.type == e.type || this.spec.multiType)) {
1043
- let i = this.spec.update(e, t, n);
1044
- return i && this.updateInner(e, t, n, r), i;
1045
- }
1046
- return !this.contentDOM && !e.isLeaf ? !1 : super.update(e, t, n, r);
1047
- }
1048
- selectNode() {
1049
- this.spec.selectNode ? this.spec.selectNode() : super.selectNode();
1050
- }
1051
- deselectNode() {
1052
- this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode();
1053
- }
1054
- setSelection(e, t, n, r) {
1055
- this.spec.setSelection ? this.spec.setSelection(e, t, n.root) : super.setSelection(e, t, n, r);
1056
- }
1057
- destroy() {
1058
- this.spec.destroy && this.spec.destroy(), super.destroy();
1059
- }
1060
- stopEvent(e) {
1061
- return this.spec.stopEvent ? this.spec.stopEvent(e) : !1;
1062
- }
1063
- ignoreMutation(e) {
1064
- return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
1065
- }
1066
- };
1067
- function et(e, t, n) {
1068
- let r = e.firstChild, i = !1;
1069
- for (let a = 0; a < t.length; a++) {
1070
- let o = t[a], s = o.dom;
1071
- if (s.parentNode == e) {
1072
- for (; s != r;) r = st(r), i = !0;
1073
- r = r.nextSibling;
1074
- } else i = !0, e.insertBefore(s, r);
1075
- if (o instanceof Ye) {
1076
- let t = r ? r.previousSibling : e.lastChild;
1077
- et(o.contentDOM, o.children, n), r = t ? t.nextSibling : e.firstChild;
1078
- }
1079
- }
1080
- for (; r;) r = st(r), i = !0;
1081
- i && n.trackWrites == e && (n.trackWrites = null);
1082
- }
1083
- var tt = function(e) {
1084
- e && (this.nodeName = e);
1085
- };
1086
- tt.prototype = Object.create(null);
1087
- var B = [new tt()];
1088
- function nt(e, t, n) {
1089
- if (e.length == 0) return B;
1090
- let r = n ? B[0] : new tt(), i = [r];
1091
- for (let a = 0; a < e.length; a++) {
1092
- let o = e[a].type.attrs;
1093
- if (o) {
1094
- o.nodeName && i.push(r = new tt(o.nodeName));
1095
- for (let e in o) {
1096
- let a = o[e];
1097
- a != null && (n && i.length == 1 && i.push(r = new tt(t.isInline ? "span" : "div")), e == "class" ? r.class = (r.class ? r.class + " " : "") + a : e == "style" ? r.style = (r.style ? r.style + ";" : "") + a : e != "nodeName" && (r[e] = a));
1098
- }
1099
- }
1100
- }
1101
- return i;
1102
- }
1103
- function rt(e, t, n, r) {
1104
- if (n == B && r == B) return t;
1105
- let i = t;
1106
- for (let t = 0; t < r.length; t++) {
1107
- let a = r[t], o = n[t];
1108
- if (t) {
1109
- let t;
1110
- o && o.nodeName == a.nodeName && i != e && (t = i.parentNode) && t.nodeName.toLowerCase() == a.nodeName || (t = document.createElement(a.nodeName), t.pmIsDeco = !0, t.appendChild(i), o = B[0]), i = t;
1111
- }
1112
- it(i, o || B[0], a);
1113
- }
1114
- return i;
1115
- }
1116
- function it(e, t, n) {
1117
- for (let r in t) r != "class" && r != "style" && r != "nodeName" && !(r in n) && e.removeAttribute(r);
1118
- for (let r in n) r != "class" && r != "style" && r != "nodeName" && n[r] != t[r] && e.setAttribute(r, n[r]);
1119
- if (t.class != n.class) {
1120
- let r = t.class ? t.class.split(" ").filter(Boolean) : [], i = n.class ? n.class.split(" ").filter(Boolean) : [];
1121
- for (let t = 0; t < r.length; t++) i.indexOf(r[t]) == -1 && e.classList.remove(r[t]);
1122
- for (let t = 0; t < i.length; t++) r.indexOf(i[t]) == -1 && e.classList.add(i[t]);
1123
- e.classList.length == 0 && e.removeAttribute("class");
1124
- }
1125
- if (t.style != n.style) {
1126
- if (t.style) {
1127
- let n = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, r;
1128
- for (; r = n.exec(t.style);) e.style.removeProperty(r[1]);
1129
- }
1130
- n.style && (e.style.cssText += n.style);
1131
- }
1132
- }
1133
- function at(e, t, n) {
1134
- return rt(e, e, B, nt(t, n, !y(e)));
1135
- }
1136
- function ot(e, t) {
1137
- if (e.length != t.length) return !1;
1138
- for (let n = 0; n < e.length; n++) if (!e[n].type.eq(t[n].type)) return !1;
1139
- return !0;
1140
- }
1141
- function st(e) {
1142
- let t = e.nextSibling;
1143
- return e.parentNode.removeChild(e), t;
1144
- }
1145
- var ct = class {
1146
- constructor(e, t, n) {
1147
- this.lock = t, this.view = n, this.index = 0, this.stack = [], this.changed = !1, this.top = e, this.preMatch = lt(e.node.content, e);
1148
- }
1149
- destroyBetween(e, t) {
1150
- if (e != t) {
1151
- for (let n = e; n < t; n++) this.top.children[n].destroy();
1152
- this.top.children.splice(e, t - e), this.changed = !0;
1153
- }
1154
- }
1155
- destroyRest() {
1156
- this.destroyBetween(this.index, this.top.children.length);
1157
- }
1158
- syncToMarks(e, t, n, r) {
1159
- let i = 0, a = this.stack.length >> 1, o = Math.min(a, e.length);
1160
- for (; i < o && (i == a - 1 ? this.top : this.stack[i + 1 << 1]).matchesMark(e[i]) && e[i].type.spec.spanning !== !1;) i++;
1161
- for (; i < a;) this.destroyRest(), this.top.dirty = I, this.index = this.stack.pop(), this.top = this.stack.pop(), a--;
1162
- for (; a < e.length;) {
1163
- this.stack.push(this.top, this.index + 1);
1164
- let i = -1, o = this.top.children.length;
1165
- r < this.preMatch.index && (o = Math.min(this.index + 3, o));
1166
- for (let t = this.index; t < o; t++) {
1167
- let n = this.top.children[t];
1168
- if (n.matchesMark(e[a]) && !this.isLocked(n.dom)) {
1169
- i = t;
1170
- break;
1171
- }
1172
- }
1173
- if (i < 0 && this.index < this.top.children.length) {
1174
- let t = this.top.children[this.index];
1175
- t instanceof Ye && t.dirty != R && t.mark.type == e[a].type && t.spec.update && !this.isLocked(t.dom) && t.spec.update(e[a]) && (t.mark = e[a], i = this.index, this.changed = !0);
1176
- }
1177
- if (i > -1) i > this.index && (this.changed = !0, this.destroyBetween(this.index, i)), this.top = this.top.children[this.index];
1178
- else {
1179
- let r = Ye.create(this.top, e[a], t, n);
1180
- this.top.children.splice(this.index, 0, r), this.top = r, this.changed = !0;
1181
- }
1182
- this.index = 0, a++;
1183
- }
1184
- }
1185
- findNodeMatch(e, t, n, r) {
1186
- let i = -1, a;
1187
- if (r >= this.preMatch.index && (a = this.preMatch.matches[r - this.preMatch.index]).parent == this.top && a.matchesNode(e, t, n)) i = this.top.children.indexOf(a, this.index);
1188
- else for (let r = this.index, a = Math.min(this.top.children.length, r + 5); r < a; r++) {
1189
- let a = this.top.children[r];
1190
- if (a.matchesNode(e, t, n) && !this.preMatch.matched.has(a)) {
1191
- i = r;
1192
- break;
1193
- }
1194
- }
1195
- return i < 0 ? !1 : (this.destroyBetween(this.index, i), this.index++, !0);
1196
- }
1197
- updateNodeAt(e, t, n, r, i) {
1198
- let a = this.top.children[r];
1199
- return a.dirty == R && a.dom == a.contentDOM && (a.dirty = L), a.update(e, t, n, i) ? (this.destroyBetween(this.index, r), this.index++, !0) : !1;
1200
- }
1201
- findIndexWithChild(e) {
1202
- for (;;) {
1203
- let t = e.parentNode;
1204
- if (!t) return -1;
1205
- if (t == this.top.contentDOM) {
1206
- let t = e.pmViewDesc;
1207
- if (t) {
1208
- for (let e = this.index; e < this.top.children.length; e++) if (this.top.children[e] == t) return e;
1209
- }
1210
- return -1;
1211
- }
1212
- e = t;
1213
- }
1214
- }
1215
- updateNextNode(e, t, n, r, i, a) {
1216
- for (let o = this.index; o < this.top.children.length; o++) {
1217
- let s = this.top.children[o];
1218
- if (s instanceof z) {
1219
- let c = this.preMatch.matched.get(s);
1220
- if (c != null && c != i) return !1;
1221
- let l = s.dom, u, d = this.isLocked(l) && !(e.isText && s.node && s.node.isText && s.nodeDOM.nodeValue == e.text && s.dirty != R && ot(t, s.outerDeco));
1222
- if (!d && s.update(e, t, n, r)) return this.destroyBetween(this.index, o), s.dom != l && (this.changed = !0), this.index++, !0;
1223
- if (!d && (u = this.recreateWrapper(s, e, t, n, r, a))) return this.destroyBetween(this.index, o), this.top.children[this.index] = u, u.contentDOM && (u.dirty = L, u.updateChildren(r, a + 1), u.dirty = I), this.changed = !0, this.index++, !0;
1224
- break;
1225
- }
1226
- }
1227
- return !1;
1228
- }
1229
- recreateWrapper(e, t, n, r, i, a) {
1230
- if (e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !ot(n, e.outerDeco) || !r.eq(e.innerDeco)) return null;
1231
- let o = z.create(this.top, t, n, r, i, a);
1232
- if (o.contentDOM) {
1233
- o.children = e.children, e.children = [];
1234
- for (let e of o.children) e.parent = o;
1235
- }
1236
- return e.destroy(), o;
1237
- }
1238
- addNode(e, t, n, r, i) {
1239
- let a = z.create(this.top, e, t, n, r, i);
1240
- a.contentDOM && a.updateChildren(r, i + 1), this.top.children.splice(this.index++, 0, a), this.changed = !0;
1241
- }
1242
- placeWidget(e, t, n) {
1243
- let r = this.index < this.top.children.length ? this.top.children[this.index] : null;
1244
- if (r && r.matchesWidget(e) && (e == r.widget || !r.widget.type.toDOM.parentNode)) this.index++;
1245
- else {
1246
- let r = new qe(this.top, e, t, n);
1247
- this.top.children.splice(this.index++, 0, r), this.changed = !0;
1248
- }
1249
- }
1250
- addTextblockHacks() {
1251
- let e = this.top.children[this.index - 1], t = this.top;
1252
- for (; e instanceof Ye;) t = e, e = t.children[t.children.length - 1];
1253
- (!e || !(e instanceof Ze) || /\n$/.test(e.node.text) || this.view.requiresGeckoHackNode && /\s$/.test(e.node.text)) && ((A || k) && e && e.dom.contentEditable == "false" && this.addHackNode("IMG", t), this.addHackNode("BR", this.top));
1254
- }
1255
- addHackNode(e, t) {
1256
- if (t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e)) this.index++;
1257
- else {
1258
- let n = document.createElement(e);
1259
- e == "IMG" && (n.className = "ProseMirror-separator", n.alt = ""), e == "BR" && (n.className = "ProseMirror-trailingBreak");
1260
- let r = new Qe(this.top, [], n, null);
1261
- t == this.top ? t.children.splice(this.index++, 0, r) : t.children.push(r), this.changed = !0;
1262
- }
1263
- }
1264
- isLocked(e) {
1265
- return this.lock && (e == this.lock || y(e) && e.contains(this.lock.parentNode));
1266
- }
1267
- };
1268
- function lt(e, t) {
1269
- let n = t, r = n.children.length, i = e.childCount, a = /* @__PURE__ */ new Map(), o = [];
1270
- outer: for (; i > 0;) {
1271
- let s;
1272
- for (;;) if (r) {
1273
- let e = n.children[r - 1];
1274
- if (e instanceof Ye) n = e, r = e.children.length;
1275
- else {
1276
- s = e, r--;
1277
- break;
1278
- }
1279
- } else if (n == t) break outer;
1280
- else r = n.parent.children.indexOf(n), n = n.parent;
1281
- let c = s.node;
1282
- if (c) {
1283
- if (c != e.child(i - 1)) break;
1284
- --i, a.set(s, i), o.push(s);
1285
- }
1286
- }
1287
- return {
1288
- index: i,
1289
- matched: a,
1290
- matches: o.reverse()
1291
- };
1292
- }
1293
- function ut(e, t) {
1294
- return e.type.side - t.type.side;
1295
- }
1296
- function dt(e, t, n, r) {
1297
- let i = t.locals(e), a = 0;
1298
- if (i.length == 0) {
1299
- for (let n = 0; n < e.childCount; n++) {
1300
- let o = e.child(n);
1301
- r(o, i, t.forChild(a, o), n), a += o.nodeSize;
1302
- }
1303
- return;
1304
- }
1305
- let o = 0, s = [], c = null;
1306
- for (let l = 0;;) {
1307
- let u, d;
1308
- for (; o < i.length && i[o].to == a;) {
1309
- let e = i[o++];
1310
- e.widget && (u ? (d ||= [u]).push(e) : u = e);
1311
- }
1312
- if (u) {
1313
- if (d) {
1314
- d.sort(ut);
1315
- for (let e = 0; e < d.length; e++) n(d[e], l, !!c);
1316
- } else n(u, l, !!c);
1317
- }
1318
- let f, p;
1319
- if (c) p = -1, f = c, c = null;
1320
- else if (l < e.childCount) p = l, f = e.child(l++);
1321
- else break;
1322
- for (let e = 0; e < s.length; e++) s[e].to <= a && s.splice(e--, 1);
1323
- for (; o < i.length && i[o].from <= a && i[o].to > a;) s.push(i[o++]);
1324
- let m = a + f.nodeSize;
1325
- if (f.isText) {
1326
- let e = m;
1327
- o < i.length && i[o].from < e && (e = i[o].from);
1328
- for (let t = 0; t < s.length; t++) s[t].to < e && (e = s[t].to);
1329
- e < m && (c = f.cut(e - a), f = f.cut(0, e - a), m = e, p = -1);
1330
- } else for (; o < i.length && i[o].to < m;) o++;
1331
- let h = f.isInline && !f.isLeaf ? s.filter((e) => !e.inline) : s.slice();
1332
- r(f, h, t.forChild(a, f), p), a = m;
1333
- }
1334
- }
1335
- function ft(e) {
1336
- if (e.nodeName == "UL" || e.nodeName == "OL") {
1337
- let t = e.style.cssText;
1338
- e.style.cssText = t + "; list-style: square !important", window.getComputedStyle(e).listStyle, e.style.cssText = t;
1339
- }
1340
- }
1341
- function pt(e, t, n, r) {
1342
- for (let i = 0, a = 0; i < e.childCount && a <= r;) {
1343
- let o = e.child(i++), s = a;
1344
- if (a += o.nodeSize, !o.isText) continue;
1345
- let c = o.text;
1346
- for (; i < e.childCount;) {
1347
- let t = e.child(i++);
1348
- if (a += t.nodeSize, !t.isText) break;
1349
- c += t.text;
1350
- }
1351
- if (a >= n) {
1352
- if (a >= r && c.slice(r - t.length - s, r - s) == t) return r - t.length;
1353
- let e = s < r ? c.lastIndexOf(t, r - s - 1) : -1;
1354
- if (e >= 0 && e + t.length + s >= n) return s + e;
1355
- if (n == r && c.length >= r + t.length - s && c.slice(r - s, r - s + t.length) == t) return r;
1356
- }
1357
- }
1358
- return -1;
1359
- }
1360
- function mt(e, t, n, r, i) {
1361
- let a = [];
1362
- for (let o = 0, s = 0; o < e.length; o++) {
1363
- let c = e[o], l = s, u = s += c.size;
1364
- l >= n || u <= t ? a.push(c) : (l < t && a.push(c.slice(0, t - l, r)), i &&= (a.push(i), void 0), u > n && a.push(c.slice(n - l, c.size, r)));
1365
- }
1366
- return a;
1367
- }
1368
- function ht(e, r = null) {
1369
- let i = e.domSelectionRange(), a = e.state.doc;
1370
- if (!i.focusNode) return null;
1371
- let o = e.docView.nearestDesc(i.focusNode), s = o && o.size == 0, c = e.docView.posFromDOM(i.focusNode, i.focusOffset, 1);
1372
- if (c < 0) return null;
1373
- let l = a.resolve(c), u, d;
1374
- if (ne(i)) {
1375
- for (u = c; o && !o.node;) o = o.parent;
1376
- if (o && o.node.isAtom && t.isSelectable(o.node) && o.parent && !(o.node.isInline && ee(i.focusNode, i.focusOffset, o.dom))) {
1377
- let e = o.posBefore;
1378
- d = new t(c == e ? l : a.resolve(e));
1379
- } else if (O && r == "key" && c > e.state.selection.to && y(i.focusNode) && i.focusOffset == i.focusNode.childNodes.length && o && o.posAtStart > e.state.selection.to) for (let e = i.focusNode;; e = e.parentNode) {
1380
- if (getComputedStyle(e).overflow != "visible") {
1381
- d = n.findFrom(a.resolve(o.posAtStart), 1);
1382
- break;
1383
- }
1384
- if (e == o.dom || e.nextSibling || !e.parentNode || !y(e.parentNode)) break;
1385
- }
1386
- } else {
1387
- if (i instanceof e.dom.ownerDocument.defaultView.Selection && i.rangeCount > 1) {
1388
- let t = c, n = c;
1389
- for (let r = 0; r < i.rangeCount; r++) {
1390
- let a = i.getRangeAt(r);
1391
- t = Math.min(t, e.docView.posFromDOM(a.startContainer, a.startOffset, 1)), n = Math.max(n, e.docView.posFromDOM(a.endContainer, a.endOffset, -1));
1392
- }
1393
- if (t < 0) return null;
1394
- [u, c] = n == e.state.selection.anchor ? [n, t] : [t, n], l = a.resolve(c);
1395
- } else u = e.docView.posFromDOM(i.anchorNode, i.anchorOffset, 1);
1396
- if (u < 0) return null;
1397
- }
1398
- let f = a.resolve(u);
1399
- if (!d) {
1400
- let t = r == "pointer" || e.state.selection.head < l.pos && !s ? 1 : -1;
1401
- d = Tt(e, f, l, t);
1402
- }
1403
- return d;
1404
- }
1405
- function gt(e) {
1406
- return e.editable ? e.hasFocus() : Dt(e) && document.activeElement && document.activeElement.contains(e.dom);
1407
- }
1408
- function V(e, t = !1) {
1409
- let n = e.state.selection;
1410
- if (Ct(e, n), !gt(e)) return;
1411
- let i = e.input.mouseDown;
1412
- if (!t && k && i) {
1413
- let t = e.domSelectionRange(), n = e.domObserver.currentSelection;
1414
- if (t.anchorNode && n.anchorNode && h(t.anchorNode, t.anchorOffset, n.anchorNode, n.anchorOffset) && i.delaySelUpdate()) {
1415
- e.domObserver.setCurSelection();
1416
- return;
1417
- }
1418
- }
1419
- if (e.domObserver.disconnectSelection(), e.cursorWrapper) St(e);
1420
- else {
1421
- let { anchor: i, head: a } = n, o, s;
1422
- _t && !(n instanceof r) && (n.$from.parent.inlineContent || (o = vt(e, n.from)), !n.empty && !n.$from.parent.inlineContent && (s = vt(e, n.to))), e.docView.setSelection(i, a, e, t), _t && (o && bt(o), s && bt(s)), n.visible ? e.dom.classList.remove("ProseMirror-hideselection") : (e.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && xt(e));
1423
- }
1424
- e.domObserver.setCurSelection(), e.domObserver.connectSelection();
1425
- }
1426
- var _t = A || k && de < 63;
1427
- function vt(e, t) {
1428
- let { node: n, offset: r } = e.docView.domFromPos(t, 0), i = r < n.childNodes.length ? n.childNodes[r] : null, a = r ? n.childNodes[r - 1] : null;
1429
- if (A && i && i.contentEditable == "false") return yt(i);
1430
- if ((!i || i.contentEditable == "false") && (!a || a.contentEditable == "false")) {
1431
- if (i) return yt(i);
1432
- if (a) return yt(a);
1433
- }
1434
- }
1435
- function yt(e) {
1436
- return e.contentEditable = "true", A && e.draggable && (e.draggable = !1, e.wasDraggable = !0), e;
1437
- }
1438
- function bt(e) {
1439
- e.contentEditable = "false", e.wasDraggable &&= (e.draggable = !0, null);
1440
- }
1441
- function xt(e) {
1442
- let t = e.dom.ownerDocument;
1443
- t.removeEventListener("selectionchange", e.input.hideSelectionGuard);
1444
- let n = e.domSelectionRange(), r = n.anchorNode, i = n.anchorOffset;
1445
- t.addEventListener("selectionchange", e.input.hideSelectionGuard = () => {
1446
- (n.anchorNode != r || n.anchorOffset != i) && (t.removeEventListener("selectionchange", e.input.hideSelectionGuard), setTimeout(() => {
1447
- (!gt(e) || e.state.selection.visible) && e.dom.classList.remove("ProseMirror-hideselection");
1448
- }, 20));
1449
- });
1450
- }
1451
- function St(e) {
1452
- let t = e.domSelection();
1453
- if (!t) return;
1454
- let n = e.cursorWrapper.dom, r = n.nodeName == "IMG";
1455
- r ? t.collapse(n.parentNode, u(n) + 1) : t.collapse(n, 0), !r && !e.state.selection.visible && E && D <= 11 && (n.disabled = !0, n.disabled = !1);
1456
- }
1457
- function Ct(e, n) {
1458
- if (n instanceof t) {
1459
- let t = e.docView.descAt(n.from);
1460
- t != e.lastSelectedViewDesc && (wt(e), t && t.selectNode(), e.lastSelectedViewDesc = t);
1461
- } else wt(e);
1462
- }
1463
- function wt(e) {
1464
- e.lastSelectedViewDesc &&= (e.lastSelectedViewDesc.parent && e.lastSelectedViewDesc.deselectNode(), void 0);
1465
- }
1466
- function Tt(e, t, n, i) {
1467
- return e.someProp("createSelectionBetween", (r) => r(e, t, n)) || r.between(t, n, i);
1468
- }
1469
- function Et(e) {
1470
- return e.editable && !e.hasFocus() ? !1 : Dt(e);
1471
- }
1472
- function Dt(e) {
1473
- let t = e.domSelectionRange();
1474
- if (!t.anchorNode) return !1;
1475
- try {
1476
- return x(e.dom, t.anchorNode) && (e.editable || x(e.dom, t.focusNode));
1477
- } catch {
1478
- return !1;
1479
- }
1480
- }
1481
- function Ot(e) {
1482
- let t = e.docView.domFromPos(e.state.selection.anchor, 0), n = e.domSelectionRange();
1483
- return h(t.node, t.offset, n.anchorNode, n.anchorOffset);
1484
- }
1485
- function kt(e, t) {
1486
- let { $anchor: r, $head: i } = e.selection, a = t > 0 ? r.max(i) : r.min(i), o = a.parent.inlineContent ? a.depth ? e.doc.resolve(t > 0 ? a.after() : a.before()) : null : a;
1487
- return o && n.findFrom(o, t);
1488
- }
1489
- function H(e, t) {
1490
- return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()), !0;
1491
- }
1492
- function At(e, n, i) {
1493
- let a = e.state.selection;
1494
- if (a instanceof r) {
1495
- if (i.indexOf("s") > -1) {
1496
- let { $head: t } = a, i = t.textOffset ? null : n < 0 ? t.nodeBefore : t.nodeAfter;
1497
- if (!i || i.isText || !i.isLeaf) return !1;
1498
- let o = e.state.doc.resolve(t.pos + i.nodeSize * (n < 0 ? -1 : 1));
1499
- return H(e, new r(a.$anchor, o));
1500
- }
1501
- if (!a.empty) return !1;
1502
- if (e.endOfTextblock(n > 0 ? "forward" : "backward")) {
1503
- let r = kt(e.state, n);
1504
- return r && r instanceof t ? H(e, r) : !1;
1505
- }
1506
- if (!j || i.indexOf("m") < 0) {
1507
- let i = a.$head, o = i.textOffset ? null : n < 0 ? i.nodeBefore : i.nodeAfter, s;
1508
- if (!o || o.isText) return !1;
1509
- let c = n < 0 ? i.pos - o.nodeSize : i.pos;
1510
- return o.isAtom || (s = e.docView.descAt(c)) && !s.contentDOM ? t.isSelectable(o) ? H(e, new t(n < 0 ? e.state.doc.resolve(i.pos - o.nodeSize) : i)) : H(e, new r(e.state.doc.resolve(n < 0 ? c : c + o.nodeSize))) : !1;
1511
- }
1512
- } else if (a instanceof t && a.node.isInline) return H(e, new r(n > 0 ? a.$to : a.$from));
1513
- else {
1514
- let t = kt(e.state, n);
1515
- return t ? H(e, t) : !1;
1516
- }
1517
- }
1518
- function jt(e, t) {
1519
- let n = e.pmViewDesc;
1520
- return n ? n.size == 0 && (t < 0 || e.nextSibling || e.nodeName != "BR") : y(e) && e.contentEditable == "false";
1521
- }
1522
- function U(e, t) {
1523
- return t < 0 ? Mt(e) : Nt(e);
1524
- }
1525
- function Mt(e) {
1526
- let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset;
1527
- if (!n) return;
1528
- let i, a, o = !1;
1529
- for (O && y(n) && r < v(n) && jt(n.childNodes[r], -1) && (o = !0);;) if (r > 0) {
1530
- if (!y(n)) break;
1531
- let e = n.childNodes[r - 1];
1532
- if (jt(e, -1)) i = n, a = --r;
1533
- else if (b(e)) n = e, r = n.nodeValue.length;
1534
- else break;
1535
- } else if (Pt(n)) break;
1536
- else {
1537
- let t = n.previousSibling;
1538
- for (; t && jt(t, -1);) i = n.parentNode, a = u(t), t = t.previousSibling;
1539
- if (t) n = t, r = v(n);
1540
- else {
1541
- if (n = n.parentNode, n == e.dom) break;
1542
- r = 0;
1543
- }
1544
- }
1545
- o ? Lt(e, n, r) : i && Lt(e, i, a);
1546
- }
1547
- function Nt(e) {
1548
- let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset;
1549
- if (!n) return;
1550
- let i = v(n), a, o;
1551
- for (;;) if (r < i) {
1552
- if (!y(n)) break;
1553
- let e = n.childNodes[r];
1554
- if (jt(e, 1)) a = n, o = ++r;
1555
- else break;
1556
- } else if (Pt(n)) break;
1557
- else {
1558
- let t = n.nextSibling;
1559
- for (; t && jt(t, 1);) a = t.parentNode, o = u(t) + 1, t = t.nextSibling;
1560
- if (t) n = t, r = 0, i = v(n);
1561
- else {
1562
- if (n = n.parentNode, n == e.dom) break;
1563
- r = i = 0;
1564
- }
1565
- }
1566
- a && Lt(e, a, o);
1567
- }
1568
- function Pt(e) {
1569
- let t = e.pmViewDesc;
1570
- return t && t.node && t.node.isBlock;
1571
- }
1572
- function Ft(e, t) {
1573
- for (; e && t == e.childNodes.length && !te(e);) t = u(e) + 1, e = e.parentNode;
1574
- for (; e && t < e.childNodes.length;) {
1575
- let n = e.childNodes[t];
1576
- if (b(n)) return n;
1577
- if (y(n) && n.contentEditable == "false") break;
1578
- e = n, t = 0;
1579
- }
1580
- }
1581
- function It(e, t) {
1582
- for (; e && !t && !te(e);) t = u(e), e = e.parentNode;
1583
- for (; e && t;) {
1584
- let n = e.childNodes[t - 1];
1585
- if (b(n)) return n;
1586
- if (y(n) && n.contentEditable == "false") break;
1587
- e = n, t = e.childNodes.length;
1588
- }
1589
- }
1590
- function Lt(e, t, n) {
1591
- if (!b(t)) {
1592
- let e, r;
1593
- (r = Ft(t, n)) ? (t = r, n = 0) : (e = It(t, n)) && (t = e, n = e.nodeValue.length);
1594
- }
1595
- let r = e.domSelection(), i = e.domSelectionRange();
1596
- if (!r) return;
1597
- ne(i) ? r.collapse(t, n) : r.extend && (r.collapse(i.anchorNode, i.anchorOffset), r.extend(t, n)), e.domObserver.setCurSelection();
1598
- let { state: a } = e;
1599
- setTimeout(() => {
1600
- e.state == a && V(e);
1601
- }, 50);
1602
- }
1603
- function Rt(e, t) {
1604
- let n = e.state.doc.resolve(t);
1605
- if (!(k || pe) && n.parent.inlineContent) {
1606
- let r = e.coordsAtPos(t);
1607
- if (t > n.start()) {
1608
- let n = e.coordsAtPos(t - 1), i = (n.top + n.bottom) / 2;
1609
- if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left < r.left ? "ltr" : "rtl";
1610
- }
1611
- if (t < n.end()) {
1612
- let n = e.coordsAtPos(t + 1), i = (n.top + n.bottom) / 2;
1613
- if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left > r.left ? "ltr" : "rtl";
1614
- }
1615
- }
1616
- let r = e.dom;
1617
- for (let t = n.depth; t > 0; t--) if (n.node(t).isBlock) {
1618
- r = e.nodeDOM(n.before(t)) || r;
1619
- break;
1620
- }
1621
- return getComputedStyle(r).direction == "rtl" ? "rtl" : "ltr";
1622
- }
1623
- function zt(i, a, o) {
1624
- let s = i.state.selection;
1625
- if (s instanceof r && !s.empty || o.indexOf("s") > -1 || j && o.indexOf("m") > -1) return !1;
1626
- let { $from: c, $to: l } = s;
1627
- if (!c.parent.inlineContent || i.endOfTextblock(a < 0 ? "up" : "down")) {
1628
- let e = kt(i.state, a);
1629
- if (e && e instanceof t) return H(i, e);
1630
- }
1631
- if (!c.parent.inlineContent) {
1632
- let t = a < 0 ? c : l, r = s instanceof e ? n.near(t, a) : n.findFrom(t, a);
1633
- return r ? H(i, r) : !1;
1634
- }
1635
- return !1;
1636
- }
1637
- function Bt(e, t) {
1638
- if (!(e.state.selection instanceof r)) return !0;
1639
- let { $head: n, $anchor: i, empty: a } = e.state.selection;
1640
- if (!n.sameParent(i)) return !0;
1641
- if (!a) return !1;
1642
- if (e.endOfTextblock(t > 0 ? "forward" : "backward")) return !0;
1643
- let o = !n.textOffset && (t < 0 ? n.nodeBefore : n.nodeAfter);
1644
- if (o && !o.isText) {
1645
- let r = e.state.tr;
1646
- return t < 0 ? r.delete(n.pos - o.nodeSize, n.pos) : r.delete(n.pos, n.pos + o.nodeSize), e.dispatch(r), !0;
1647
- }
1648
- return !1;
1649
- }
1650
- function Vt(e, t, n) {
1651
- e.domObserver.stop(), t.contentEditable = n, e.domObserver.start();
1652
- }
1653
- function Ht(e) {
1654
- if (!A || e.state.selection.$head.parentOffset > 0) return !1;
1655
- let { focusNode: t, focusOffset: n } = e.domSelectionRange();
1656
- if (t && y(t) && n == 0 && t.firstChild && y(t.firstChild) && t.firstChild.contentEditable == "false") {
1657
- let n = t.firstChild;
1658
- Vt(e, n, "true"), setTimeout(() => Vt(e, n, "false"), 20);
1659
- }
1660
- return !1;
1661
- }
1662
- function Ut(e) {
1663
- let t = "";
1664
- return e.ctrlKey && (t += "c"), e.metaKey && (t += "m"), e.altKey && (t += "a"), e.shiftKey && (t += "s"), t;
1665
- }
1666
- function Wt(e, t) {
1667
- let n = t.keyCode, r = Ut(t);
1668
- if (n == 8 || j && n == 72 && r == "c") return Bt(e, -1) || U(e, -1);
1669
- if (n == 46 && !t.shiftKey || j && n == 68 && r == "c") return Bt(e, 1) || U(e, 1);
1670
- if (n == 13 || n == 27) return !0;
1671
- if (n == 37 || j && n == 66 && r == "c") {
1672
- let t = n == 37 ? Rt(e, e.state.selection.from) == "ltr" ? -1 : 1 : -1;
1673
- return At(e, t, r) || U(e, t);
1674
- }
1675
- if (n == 39 || j && n == 70 && r == "c") {
1676
- let t = n == 39 ? Rt(e, e.state.selection.from) == "ltr" ? 1 : -1 : 1;
1677
- return At(e, t, r) || U(e, t);
1678
- }
1679
- return n == 38 || j && n == 80 && r == "c" ? zt(e, -1, r) || U(e, -1) : n == 40 || j && n == 78 && r == "c" ? Ht(e) || zt(e, 1, r) || U(e, 1) : !(r != (j ? "m" : "c") || n != 66 && n != 73 && n != 89 && n != 90);
1680
- }
1681
- function Gt(e, t) {
1682
- e.someProp("transformCopied", (n) => {
1683
- t = n(t, e);
1684
- });
1685
- let n = [], { content: r, openStart: i, openEnd: o } = t;
1686
- for (; i > 1 && o > 1 && r.childCount == 1 && r.firstChild.childCount == 1;) {
1687
- i--, o--;
1688
- let e = r.firstChild;
1689
- n.push(e.type.name, e.attrs == e.type.defaultAttrs ? null : e.attrs), r = e.content;
1690
- }
1691
- let s = e.someProp("clipboardSerializer") || a.fromSchema(e.state.schema), c = tn(), l = c.createElement("div");
1692
- l.appendChild(s.serializeFragment(r, { document: c }));
1693
- let u = l.firstChild, d, f = 0;
1694
- for (; u && y(u) && (d = en[u.nodeName.toLowerCase()]);) {
1695
- for (let e = d.length - 1; e >= 0; e--) {
1696
- let t = c.createElement(d[e]);
1697
- for (; l.firstChild;) t.appendChild(l.firstChild);
1698
- l.appendChild(t), f++;
1699
- }
1700
- u = l.firstChild;
1701
- }
1702
- return u && y(u) && u.setAttribute("data-pm-slice", `${i} ${o}${f ? ` -${f}` : ""} ${JSON.stringify(n)}`), {
1703
- dom: l,
1704
- text: e.someProp("clipboardTextSerializer", (n) => n(t, e)) || t.content.textBetween(0, t.content.size, "\n\n"),
1705
- slice: t
1706
- };
1707
- }
1708
- function Kt(e, t, n, r, s) {
1709
- let l = s.parent.type.spec.code, u, d;
1710
- if (!n && !t) return null;
1711
- let f = !!t && (r || l || !n);
1712
- if (f) {
1713
- if (e.someProp("transformPastedText", (n) => {
1714
- t = n(t, l || r, e);
1715
- }), l) return d = new c(o.from(e.state.schema.text(t.replace(/\r\n?/g, "\n"))), 0, 0), e.someProp("transformPasted", (t) => {
1716
- d = t(d, e, !0);
1717
- }), d;
1718
- let n = e.someProp("clipboardTextParser", (n) => n(t, s, r, e));
1719
- if (n) d = n;
1720
- else {
1721
- let n = s.marks(), { schema: r } = e.state, i = a.fromSchema(r);
1722
- u = document.createElement("div"), t.split(/(?:\r\n?|\n)+/).forEach((e) => {
1723
- let t = u.appendChild(document.createElement("p"));
1724
- e && t.appendChild(i.serializeNode(r.text(e, n)));
1725
- });
1726
- }
1727
- } else e.someProp("transformPastedHTML", (t) => {
1728
- n = t(n, e);
1729
- }), u = an(n), me && on(u);
1730
- let p = u && u.querySelector("[data-pm-slice]"), m = p && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(p.getAttribute("data-pm-slice") || "");
1731
- if (m && m[3]) for (let e = +m[3]; e > 0; e--) {
1732
- let e = u.firstChild;
1733
- for (; e && !y(e);) e = e.nextSibling;
1734
- if (!e) break;
1735
- u = e;
1736
- }
1737
- if (d ||= (e.someProp("clipboardParser") || e.someProp("domParser") || i.fromSchema(e.state.schema)).parseSlice(u, {
1738
- preserveWhitespace: !!(f || m),
1739
- context: s,
1740
- ruleFromNode(e) {
1741
- return e.nodeName == "BR" && !e.nextSibling && e.parentNode && !qt.test(e.parentNode.nodeName) ? { ignore: !0 } : null;
1742
- }
1743
- }), m) d = sn($t(d, +m[1], +m[2]), m[4]);
1744
- else if (d = c.maxOpen(Jt(d.content, s), !0), d.openStart || d.openEnd) {
1745
- let e = 0, t = 0;
1746
- for (let t = d.content.firstChild; e < d.openStart && !t.type.spec.isolating; e++, t = t.firstChild);
1747
- for (let e = d.content.lastChild; t < d.openEnd && !e.type.spec.isolating; t++, e = e.lastChild);
1748
- d = $t(d, e, t);
1749
- }
1750
- return e.someProp("transformPasted", (t) => {
1751
- d = t(d, e, f);
1752
- }), d;
1753
- }
1754
- var qt = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
1755
- function Jt(e, t) {
1756
- if (e.childCount < 2) return e;
1757
- for (let n = t.depth; n >= 0; n--) {
1758
- let r = t.node(n).contentMatchAt(t.index(n)), i, a = [];
1759
- if (e.forEach((e) => {
1760
- if (!a) return;
1761
- let t = r.findWrapping(e.type), n;
1762
- if (!t) return a = null;
1763
- if (n = a.length && i.length && Xt(t, i, e, a[a.length - 1], 0)) a[a.length - 1] = n;
1764
- else {
1765
- a.length && (a[a.length - 1] = Zt(a[a.length - 1], i.length));
1766
- let n = Yt(e, t);
1767
- a.push(n), r = r.matchType(n.type), i = t;
1768
- }
1769
- }), a) return o.from(a);
1770
- }
1771
- return e;
1772
- }
1773
- function Yt(e, t, n = 0) {
1774
- for (let r = t.length - 1; r >= n; r--) e = t[r].create(null, o.from(e));
1775
- return e;
1776
- }
1777
- function Xt(e, t, n, r, i) {
1778
- if (i < e.length && i < t.length && e[i] == t[i]) {
1779
- let a = Xt(e, t, n, r.lastChild, i + 1);
1780
- if (a) return r.copy(r.content.replaceChild(r.childCount - 1, a));
1781
- if (r.contentMatchAt(r.childCount).matchType(i == e.length - 1 ? n.type : e[i + 1])) return r.copy(r.content.append(o.from(Yt(n, e, i + 1))));
1782
- }
1783
- }
1784
- function Zt(e, t) {
1785
- if (t == 0) return e;
1786
- let n = e.content.replaceChild(e.childCount - 1, Zt(e.lastChild, t - 1)), r = e.contentMatchAt(e.childCount).fillBefore(o.empty, !0);
1787
- return e.copy(n.append(r));
1788
- }
1789
- function Qt(e, t, n, r, i, a) {
1790
- let s = t < 0 ? e.firstChild : e.lastChild, c = s.content;
1791
- return e.childCount > 1 && (a = 0), i < r - 1 && (c = Qt(c, t, n, r, i + 1, a)), i >= n && (c = t < 0 ? s.contentMatchAt(0).fillBefore(c, a <= i).append(c) : c.append(s.contentMatchAt(s.childCount).fillBefore(o.empty, !0))), e.replaceChild(t < 0 ? 0 : e.childCount - 1, s.copy(c));
1792
- }
1793
- function $t(e, t, n) {
1794
- return t < e.openStart && (e = new c(Qt(e.content, -1, t, e.openStart, 0, e.openEnd), t, e.openEnd)), n < e.openEnd && (e = new c(Qt(e.content, 1, n, e.openEnd, 0, 0), e.openStart, n)), e;
1795
- }
1796
- var en = {
1797
- thead: ["table"],
1798
- tbody: ["table"],
1799
- tfoot: ["table"],
1800
- caption: ["table"],
1801
- colgroup: ["table"],
1802
- col: ["table", "colgroup"],
1803
- tr: ["table", "tbody"],
1804
- td: [
1805
- "table",
1806
- "tbody",
1807
- "tr"
1808
- ],
1809
- th: [
1810
- "table",
1811
- "tbody",
1812
- "tr"
1813
- ]
1814
- };
1815
- function tn() {
1816
- return document.implementation.createHTMLDocument("title");
1817
- }
1818
- var nn = null;
1819
- function rn(e) {
1820
- let t = window.trustedTypes;
1821
- if (!t) return e;
1822
- if (!nn) {
1823
- if (nn = t.defaultPolicy) try {
1824
- return nn.createHTML(e);
1825
- } catch {}
1826
- nn = t.createPolicy("ProseMirrorClipboard", { createHTML: (e) => e });
1827
- }
1828
- return nn.createHTML(e);
1829
- }
1830
- function an(e) {
1831
- let t = /^(\s*<meta [^>]*>)*/.exec(e);
1832
- t && (e = e.slice(t[0].length));
1833
- let n = tn(), r = n.body, i = /<([a-z][^>\s]+)/i.exec(e), a;
1834
- if ((a = i && en[i[1].toLowerCase()]) && (e = a.map((e) => "<" + e + ">").join("") + e + a.map((e) => "</" + e + ">").reverse().join("")), r.innerHTML = rn(e), a) for (let e = 0; e < a.length; e++) r = r.querySelector(a[e]) || r;
1835
- for (let e = 0; e < n.styleSheets.length; e++) {
1836
- let t = n.styleSheets[e];
1837
- for (let e = 0; e < t.rules.length; e++) {
1838
- let n = t.rules[e];
1839
- if (n instanceof CSSStyleRule) {
1840
- let e = r.querySelectorAll(n.selectorText);
1841
- for (let t = 0; t < e.length; t++) e[t].style.cssText += n.style.cssText;
1842
- }
1843
- }
1844
- }
1845
- return r;
1846
- }
1847
- function on(e) {
1848
- let t = e.querySelectorAll(k ? "span:not([class]):not([style])" : "span.Apple-converted-space");
1849
- for (let n = 0; n < t.length; n++) {
1850
- let r = t[n];
1851
- r.childNodes.length == 1 && r.textContent == "\xA0" && r.parentNode && r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "), r);
1852
- }
1853
- }
1854
- function sn(e, t) {
1855
- if (!e.size) return e;
1856
- let n = e.content.firstChild.type.schema, r;
1857
- try {
1858
- r = JSON.parse(t);
1859
- } catch {
1860
- return e;
1861
- }
1862
- let { content: i, openStart: a, openEnd: s } = e;
1863
- for (let e = r.length - 2; e >= 0; e -= 2) {
1864
- let t = n.nodes[r[e]];
1865
- if (!t || t.hasRequiredAttrs()) break;
1866
- try {
1867
- i = o.from(t.create(r[e + 1], i));
1868
- } catch {
1869
- break;
1870
- }
1871
- a++, s++;
1872
- }
1873
- return new c(i, a, s);
1874
- }
1875
- var W = {}, G = {}, cn = {
1876
- touchstart: !0,
1877
- touchmove: !0
1878
- }, ln = class {
1879
- constructor() {
1880
- this.shiftKey = !1, this.mouseDown = null, this.lastKeyCode = null, this.lastKeyCodeTime = 0, this.lastKeyDispatched = !1, this.lastClick = {
1881
- time: 0,
1882
- x: 0,
1883
- y: 0,
1884
- type: "",
1885
- button: 0
1886
- }, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastIOSEnter = 0, this.lastIOSEnterFallbackTimeout = -1, this.lastFocus = 0, this.lastTouch = 0, this.lastChromeDelete = 0, this.composing = !1, this.compositionNode = null, this.composingTimeout = -1, this.compositionNodes = [], this.compositionEndedAt = -2e8, this.compositionID = 1, this.badSafariComposition = !1, this.compositionPendingChanges = 0, this.domChangeCount = 0, this.eventHandlers = Object.create(null), this.hideSelectionGuard = null;
1887
- }
1888
- };
1889
- function un(e) {
1890
- for (let t in W) {
1891
- let n = W[t];
1892
- e.dom.addEventListener(t, e.input.eventHandlers[t] = (t) => {
1893
- mn(e, t) && !pn(e, t) && (e.editable || !(t.type in G)) && n(e, t);
1894
- }, cn[t] ? { passive: !0 } : void 0);
1895
- }
1896
- A && e.dom.addEventListener("input", () => null), fn(e);
1897
- }
1898
- function K(e, t) {
1899
- e.input.lastSelectionOrigin = t, e.input.lastSelectionTime = Date.now();
1900
- }
1901
- function dn(e) {
1902
- e.input.mouseDown && e.input.mouseDown.done(), e.domObserver.stop();
1903
- for (let t in e.input.eventHandlers) e.dom.removeEventListener(t, e.input.eventHandlers[t]);
1904
- clearTimeout(e.input.composingTimeout), clearTimeout(e.input.lastIOSEnterFallbackTimeout);
1905
- }
1906
- function fn(e) {
1907
- e.someProp("handleDOMEvents", (t) => {
1908
- for (let n in t) e.input.eventHandlers[n] || e.dom.addEventListener(n, e.input.eventHandlers[n] = (t) => pn(e, t));
1909
- });
1910
- }
1911
- function pn(e, t) {
1912
- return e.someProp("handleDOMEvents", (n) => {
1913
- let r = n[t.type];
1914
- return r ? r(e, t) || t.defaultPrevented : !1;
1915
- });
1916
- }
1917
- function mn(e, t) {
1918
- if (!t.bubbles) return !0;
1919
- if (t.defaultPrevented) return !1;
1920
- for (let n = t.target; n != e.dom; n = n.parentNode) if (!n || n.nodeType == 11 || n.pmViewDesc && n.pmViewDesc.stopEvent(t)) return !1;
1921
- return !0;
1922
- }
1923
- function hn(e, t) {
1924
- !pn(e, t) && W[t.type] && (e.editable || !(t.type in G)) && W[t.type](e, t);
1925
- }
1926
- function q(e, t) {
1927
- let { input: n } = e;
1928
- return n.lastKeyDispatched || e.composing ? !1 : (n.lastKeyDispatched = !0, typeof t == "string" && (t = re(t == "Backspace" ? 8 : 13, t)), e.someProp("handleKeyDown", (n) => n(e, t)));
1929
- }
1930
- G.keydown = (e, t) => {
1931
- let n = t;
1932
- if (e.input.shiftKey = n.keyCode == 16 || n.shiftKey, !Mn(e) && (e.input.lastKeyCode = n.keyCode, e.input.lastKeyCodeTime = Date.now(), e.input.lastKeyDispatched = !1, !(M && k && n.keyCode == 13))) {
1933
- if (n.keyCode != 229 && e.domObserver.forceFlush(), fe && n.keyCode == 13 && !n.ctrlKey && !n.altKey && !n.metaKey) {
1934
- let t = Date.now();
1935
- e.input.lastIOSEnter = t, e.input.lastIOSEnterFallbackTimeout = setTimeout(() => {
1936
- e.input.lastIOSEnter == t && (q(e, "Enter"), e.input.lastIOSEnter = 0);
1937
- }, 200);
1938
- } else q(e, n) || Wt(e, n) ? n.preventDefault() : K(e, "key");
1939
- }
1940
- }, G.keyup = (e, t) => {
1941
- t.keyCode == 16 && (e.input.shiftKey = !1);
1942
- }, G.keypress = (e, t) => {
1943
- let n = t;
1944
- if (Mn(e) || !n.charCode || n.ctrlKey && !n.altKey || j && n.metaKey) return;
1945
- if (e.someProp("handleKeyPress", (t) => t(e, n))) {
1946
- n.preventDefault();
1947
- return;
1948
- }
1949
- let i = e.state.selection;
1950
- if (!(i instanceof r) || !i.$from.sameParent(i.$to)) {
1951
- let t = String.fromCharCode(n.charCode), r = () => e.state.tr.insertText(t).scrollIntoView();
1952
- !/[\r\n]/.test(t) && !e.someProp("handleTextInput", (n) => n(e, i.$from.pos, i.$to.pos, t, r)) && e.dispatch(r()), n.preventDefault();
1953
- }
1954
- };
1955
- function gn(e) {
1956
- return {
1957
- left: e.clientX,
1958
- top: e.clientY
1959
- };
1960
- }
1961
- function _n(e, t) {
1962
- let n = t.x - e.clientX, r = t.y - e.clientY;
1963
- return n * n + r * r < 100;
1964
- }
1965
- function vn(e, t, n, r, i) {
1966
- if (r == -1) return !1;
1967
- let a = e.state.doc.resolve(r);
1968
- for (let r = a.depth + 1; r > 0; r--) if (e.someProp(t, (t) => r > a.depth ? t(e, n, a.nodeAfter, a.before(r), i, !0) : t(e, n, a.node(r), a.before(r), i, !1))) return !0;
1969
- return !1;
1970
- }
1971
- function yn(e, t, n) {
1972
- if (e.focused || e.focus(), e.state.selection.eq(t)) return;
1973
- let r = e.state.tr.setSelection(t);
1974
- r.setMeta("pointer", !0), e.dispatch(r);
1975
- }
1976
- function bn(e, n) {
1977
- if (n == -1) return !1;
1978
- let r = e.state.doc.resolve(n), i = r.nodeAfter;
1979
- return i && i.isAtom && t.isSelectable(i) ? (yn(e, new t(r)), !0) : !1;
1980
- }
1981
- function xn(e, n) {
1982
- if (n == -1) return !1;
1983
- let r = e.state.selection, i, a;
1984
- r instanceof t && (i = r.node);
1985
- let o = e.state.doc.resolve(n);
1986
- for (let e = o.depth + 1; e > 0; e--) {
1987
- let n = e > o.depth ? o.nodeAfter : o.node(e);
1988
- if (t.isSelectable(n)) {
1989
- a = i && r.$from.depth > 0 && e >= r.$from.depth && o.before(r.$from.depth + 1) == r.$from.pos ? o.before(r.$from.depth) : o.before(e);
1990
- break;
1991
- }
1992
- }
1993
- return a != null && (yn(e, t.create(e.state.doc, a)), !0);
1994
- }
1995
- function Sn(e, t, n, r, i) {
1996
- return vn(e, "handleClickOn", t, n, r) || e.someProp("handleClick", (n) => n(e, t, r)) || (i ? xn(e, n) : bn(e, n));
1997
- }
1998
- function Cn(e, t, n, r) {
1999
- return vn(e, "handleDoubleClickOn", t, n, r) || e.someProp("handleDoubleClick", (n) => n(e, t, r));
2000
- }
2001
- function wn(e, t, n, r) {
2002
- return vn(e, "handleTripleClickOn", t, n, r) || e.someProp("handleTripleClick", (n) => n(e, t, r)) || Tn(e, n, r);
2003
- }
2004
- function Tn(e, t, n) {
2005
- if (n.button != 0) return !1;
2006
- let i = En(e, t, !0), a = e.state.doc;
2007
- return i ? (yn(e, i), i instanceof r && a.eq(e.state.doc) && (e.input.mouseDown = new jn(e, i)), !0) : !1;
2008
- }
2009
- function En(e, n, i) {
2010
- let a = e.state.doc;
2011
- if (n == -1) return a.inlineContent ? r.create(a, 0, a.content.size) : null;
2012
- let o = a.resolve(n);
2013
- for (let e = o.depth + 1; e > 0; e--) {
2014
- let n = e > o.depth ? o.nodeAfter : o.node(e), s = o.before(e);
2015
- if (n.inlineContent) return r.create(a, s + 1, s + 1 + n.content.size);
2016
- if (i && t.isSelectable(n)) return t.create(a, s);
2017
- }
2018
- return null;
2019
- }
2020
- function Dn(e) {
2021
- return Rn(e);
2022
- }
2023
- var On = j ? "metaKey" : "ctrlKey";
2024
- W.mousedown = (e, t) => {
2025
- let n = t;
2026
- e.input.shiftKey = n.shiftKey;
2027
- let r = Dn(e), i = Date.now(), a = "singleClick";
2028
- i - e.input.lastClick.time < 500 && _n(n, e.input.lastClick) && !n[On] && e.input.lastClick.button == n.button && (e.input.lastClick.type == "singleClick" ? a = "doubleClick" : e.input.lastClick.type == "doubleClick" && (a = "tripleClick")), e.input.lastClick = {
2029
- time: i,
2030
- x: n.clientX,
2031
- y: n.clientY,
2032
- type: a,
2033
- button: n.button
2034
- }, e.input.mouseDown && e.input.mouseDown.done();
2035
- let o = e.posAtCoords(gn(n));
2036
- o && (a == "singleClick" ? e.input.mouseDown = new An(e, o, n, !!r) : (a == "doubleClick" ? Cn : wn)(e, o.pos, o.inside, n) ? n.preventDefault() : K(e, "pointer"));
2037
- };
2038
- var kn = class {
2039
- constructor(e) {
2040
- this.view = e, this.mightDrag = null, e.root.addEventListener("mouseup", this.up = this.up.bind(this)), e.root.addEventListener("mousemove", this.move = this.move.bind(this));
2041
- }
2042
- up(e) {
2043
- this.done();
2044
- }
2045
- move(e) {
2046
- e.buttons == 0 && this.done();
2047
- }
2048
- done() {
2049
- this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.view.input.mouseDown == this && (this.view.input.mouseDown = null);
2050
- }
2051
- delaySelUpdate() {
2052
- return !1;
2053
- }
2054
- }, An = class extends kn {
2055
- constructor(e, n, r, i) {
2056
- super(e), this.pos = n, this.event = r, this.flushed = i, this.delayedSelectionSync = !1, this.startDoc = e.state.doc, this.selectNode = !!r[On], this.allowDefault = r.shiftKey;
2057
- let a, o;
2058
- if (n.inside > -1) a = e.state.doc.nodeAt(n.inside), o = n.inside;
2059
- else {
2060
- let t = e.state.doc.resolve(n.pos);
2061
- a = t.parent, o = t.depth ? t.before() : 0;
2062
- }
2063
- let s = i ? null : r.target, c = s ? e.docView.nearestDesc(s, !0) : null;
2064
- this.target = c && y(c.nodeDOM) ? c.nodeDOM : null;
2065
- let { selection: l } = e.state;
2066
- r.button == 0 && (a.type.spec.draggable && a.type.spec.selectable !== !1 || l instanceof t && l.from <= o && l.to > o) && (this.mightDrag = {
2067
- node: a,
2068
- pos: o,
2069
- addAttr: !(!this.target || this.target.draggable),
2070
- setUneditable: !!(this.target && O && !this.target.hasAttribute("contentEditable"))
2071
- }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(() => {
2072
- this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false");
2073
- }, 20), this.view.domObserver.start()), K(e, "pointer");
2074
- }
2075
- done() {
2076
- super.done(), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(() => {
2077
- this.view.isDestroyed || V(this.view);
2078
- });
2079
- }
2080
- up(e) {
2081
- if (this.done(), !this.view.dom.contains(e.target)) return;
2082
- let t = this.pos;
2083
- this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(gn(e))), this.updateAllowDefault(e), this.allowDefault || !t ? K(this.view, "pointer") : Sn(this.view, t.pos, t.inside, e, this.selectNode) ? e.preventDefault() : e.button == 0 && (this.flushed || A && this.mightDrag && !this.mightDrag.node.isAtom || k && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (yn(this.view, n.near(this.view.state.doc.resolve(t.pos))), e.preventDefault()) : K(this.view, "pointer");
2084
- }
2085
- move(e) {
2086
- this.updateAllowDefault(e), K(this.view, "pointer"), super.move(e);
2087
- }
2088
- updateAllowDefault(e) {
2089
- !this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = !0);
2090
- }
2091
- delaySelUpdate() {
2092
- return this.allowDefault ? (this.delayedSelectionSync = !0, !0) : !1;
2093
- }
2094
- }, jn = class extends kn {
2095
- constructor(e, t) {
2096
- super(e), this.startSelection = t, this.startDoc = e.state.doc;
2097
- }
2098
- move(e) {
2099
- if (e.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) {
2100
- this.done();
2101
- return;
2102
- }
2103
- e.preventDefault(), K(this.view, "pointer");
2104
- let t = this.view.posAtCoords(gn(e)), n = t && En(this.view, t.inside, !1);
2105
- if (!n) return;
2106
- let { doc: i } = this.view.state, a = this.startSelection, [o, s] = n.from < a.from ? [a.to, n.from] : [a.from, n.to];
2107
- yn(this.view, r.create(i, o, s));
2108
- }
2109
- };
2110
- W.touchstart = (e) => {
2111
- e.input.lastTouch = Date.now(), Dn(e), K(e, "pointer");
2112
- }, W.touchmove = (e) => {
2113
- e.input.lastTouch = Date.now(), K(e, "pointer");
2114
- }, W.contextmenu = (e) => Dn(e);
2115
- function Mn(e, t) {
2116
- return e.composing ? !0 : A && Math.abs(Date.now() - e.input.compositionEndedAt) < 500 ? (e.input.compositionEndedAt = -2e8, !0) : !1;
2117
- }
2118
- var Nn = M ? 5e3 : -1;
2119
- G.compositionstart = G.compositionupdate = (e) => {
2120
- if (!e.composing) {
2121
- e.domObserver.flush();
2122
- let { state: t } = e, n = t.selection.$to;
2123
- if (t.selection instanceof r && t.selection.empty && (t.storedMarks || !n.textOffset && n.parentOffset && n.nodeBefore.marks.some((e) => e.type.spec.inclusive === !1) || k && pe && Pn(e))) e.markCursor = e.state.storedMarks || n.marks(), Rn(e, !0), e.markCursor = null;
2124
- else if (Rn(e, !t.selection.empty), O && t.selection.empty && n.parentOffset && !n.textOffset && n.nodeBefore.marks.length) {
2125
- let t = e.domSelectionRange();
2126
- for (let n = t.focusNode, r = t.focusOffset; n && y(n) && r != 0;) {
2127
- let t = r < 0 ? n.lastChild : n.childNodes[r - 1];
2128
- if (!t) break;
2129
- if (b(t)) {
2130
- let n = e.domSelection();
2131
- n && n.collapse(t, t.nodeValue.length);
2132
- break;
2133
- }
2134
- n = t, r = -1;
2135
- }
2136
- }
2137
- e.input.composing = !0;
2138
- }
2139
- Fn(e, Nn);
2140
- };
2141
- function Pn(e) {
2142
- let { focusNode: t, focusOffset: n } = e.domSelectionRange();
2143
- if (!t || !y(t) || n >= t.childNodes.length) return !1;
2144
- let r = t.childNodes[n];
2145
- return y(r) && r.contentEditable == "false";
2146
- }
2147
- G.compositionend = (e, t) => {
2148
- e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Date.now(), e.input.compositionPendingChanges = e.domObserver.pendingRecords().length ? e.input.compositionID : 0, e.input.compositionNode = null, e.input.badSafariComposition ? e.domObserver.forceFlush() : e.input.compositionPendingChanges && Promise.resolve().then(() => e.domObserver.flush()), e.input.compositionID++, Fn(e, 20));
2149
- };
2150
- function Fn(e, t) {
2151
- clearTimeout(e.input.composingTimeout), t > -1 && (e.input.composingTimeout = setTimeout(() => Rn(e), t));
2152
- }
2153
- function In(e) {
2154
- for (e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Date.now()); e.input.compositionNodes.length > 0;) e.input.compositionNodes.pop().markParentsDirty();
2155
- }
2156
- function Ln(e) {
2157
- let t = e.domSelectionRange();
2158
- if (!t.focusNode) return null;
2159
- let n = S(t.focusNode, t.focusOffset), r = C(t.focusNode, t.focusOffset);
2160
- if (n && r && n != r) {
2161
- let t = r.pmViewDesc, i = e.domObserver.lastChangedTextNode;
2162
- if (n == i || r == i) return i;
2163
- if (!t || !t.isText(r.nodeValue)) return r;
2164
- if (e.input.compositionNode == r) {
2165
- let e = n.pmViewDesc;
2166
- if (e && e.isText(n.nodeValue)) return r;
2167
- }
2168
- }
2169
- return n || r;
2170
- }
2171
- function Rn(e, t = !1) {
2172
- if (!(M && e.domObserver.flushingSoon >= 0)) {
2173
- if (e.domObserver.forceFlush(), In(e), t || e.docView && e.docView.dirty) {
2174
- let n = ht(e), r = e.state.selection;
2175
- return n && !n.eq(r) ? e.dispatch(e.state.tr.setSelection(n)) : (e.markCursor || t) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? e.dispatch(e.state.tr.deleteSelection()) : e.updateState(e.state), !0;
2176
- }
2177
- return !1;
2178
- }
2179
- }
2180
- function zn(e, t) {
2181
- if (!e.dom.parentNode) return;
2182
- let n = e.dom.parentNode.appendChild(document.createElement("div"));
2183
- n.appendChild(t), n.style.cssText = "position: fixed; left: -10000px; top: 10px";
2184
- let r = getSelection(), i = document.createRange();
2185
- i.selectNodeContents(t), e.dom.blur(), r.removeAllRanges(), r.addRange(i), setTimeout(() => {
2186
- n.parentNode && n.parentNode.removeChild(n), e.focus();
2187
- }, 50);
2188
- }
2189
- var Bn = E && D < 15 || fe && he < 604;
2190
- W.copy = G.cut = (e, t) => {
2191
- let n = t, r = e.state.selection, i = n.type == "cut";
2192
- if (r.empty) return;
2193
- let a = Bn ? null : n.clipboardData, { dom: o, text: s } = Gt(e, r.content());
2194
- a ? (n.preventDefault(), a.clearData(), a.setData("text/html", o.innerHTML), a.setData("text/plain", s)) : zn(e, o), i && e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut"));
2195
- };
2196
- function Vn(e) {
2197
- return e.openStart == 0 && e.openEnd == 0 && e.content.childCount == 1 ? e.content.firstChild : null;
2198
- }
2199
- function Hn(e, t) {
2200
- if (!e.dom.parentNode) return;
2201
- let n = e.input.shiftKey || e.state.selection.$from.parent.type.spec.code, r = e.dom.parentNode.appendChild(document.createElement(n ? "textarea" : "div"));
2202
- n || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus();
2203
- let i = e.input.shiftKey && e.input.lastKeyCode != 45;
2204
- setTimeout(() => {
2205
- e.focus(), r.parentNode && r.parentNode.removeChild(r), n ? Un(e, r.value, null, i, t) : Un(e, r.textContent, r.innerHTML, i, t);
2206
- }, 50);
2207
- }
2208
- function Un(e, t, n, r, i) {
2209
- let a = Kt(e, t, n, r, e.state.selection.$from);
2210
- if (e.someProp("handlePaste", (t) => t(e, i, a || c.empty))) return !0;
2211
- if (!a) return !1;
2212
- let o = Vn(a), s = o ? e.state.tr.replaceSelectionWith(o, r) : e.state.tr.replaceSelection(a);
2213
- return e.dispatch(s.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0;
2214
- }
2215
- function Wn(e) {
2216
- let t = e.getData("text/plain") || e.getData("Text");
2217
- if (t) return t;
2218
- let n = e.getData("text/uri-list");
2219
- return n ? n.replace(/\r?\n/g, " ") : "";
2220
- }
2221
- G.paste = (e, t) => {
2222
- let n = t;
2223
- if (e.composing && !M) return;
2224
- let r = Bn ? null : n.clipboardData, i = e.input.shiftKey && e.input.lastKeyCode != 45;
2225
- r && Un(e, Wn(r), r.getData("text/html"), i, n) ? n.preventDefault() : Hn(e, n);
2226
- };
2227
- var Gn = class {
2228
- constructor(e, t, n) {
2229
- this.slice = e, this.move = t, this.node = n;
2230
- }
2231
- }, Kn = j ? "altKey" : "ctrlKey";
2232
- function qn(e, t) {
2233
- let n;
2234
- return e.someProp("dragCopies", (e) => {
2235
- n ||= e(t);
2236
- }), n == null ? !t[Kn] : !n;
2237
- }
2238
- W.dragstart = (e, n) => {
2239
- let r = n, i = e.input.mouseDown;
2240
- if (i && i.done(), !r.dataTransfer) return;
2241
- let a = e.state.selection, o = a.empty ? null : e.posAtCoords(gn(r)), s;
2242
- if (!(o && o.pos >= a.from && o.pos <= (a instanceof t ? a.to - 1 : a.to))) {
2243
- if (i && i.mightDrag) s = t.create(e.state.doc, i.mightDrag.pos);
2244
- else if (r.target && y(r.target)) {
2245
- let n = e.docView.nearestDesc(r.target, !0);
2246
- n && n.node.type.spec.draggable && n != e.docView && (s = t.create(e.state.doc, n.posBefore));
2247
- }
2248
- }
2249
- let { dom: c, text: l, slice: u } = Gt(e, (s || e.state.selection).content());
2250
- (!r.dataTransfer.files.length || !k || de > 120) && r.dataTransfer.clearData(), r.dataTransfer.setData(Bn ? "Text" : "text/html", c.innerHTML), r.dataTransfer.effectAllowed = "copyMove", Bn || r.dataTransfer.setData("text/plain", l), e.dragging = new Gn(u, qn(e, r), s);
2251
- }, W.dragend = (e) => {
2252
- let t = e.dragging;
2253
- window.setTimeout(() => {
2254
- e.dragging == t && (e.dragging = null);
2255
- }, 50);
2256
- }, G.dragover = G.dragenter = (e, t) => t.preventDefault(), G.drop = (e, t) => {
2257
- try {
2258
- Jn(e, t, e.dragging);
2259
- } finally {
2260
- e.dragging = null;
2261
- }
2262
- };
2263
- function Jn(e, n, r) {
2264
- if (!n.dataTransfer) return;
2265
- let i = e.posAtCoords(gn(n));
2266
- if (!i) return;
2267
- let a = e.state.doc.resolve(i.pos), o = r && r.slice;
2268
- o ? e.someProp("transformPasted", (t) => {
2269
- o = t(o, e, !1);
2270
- }) : o = Kt(e, Wn(n.dataTransfer), Bn ? null : n.dataTransfer.getData("text/html"), !1, a);
2271
- let s = !!(r && qn(e, n));
2272
- if (e.someProp("handleDrop", (t) => t(e, n, o || c.empty, s))) {
2273
- n.preventDefault();
2274
- return;
2275
- }
2276
- if (!o) return;
2277
- n.preventDefault();
2278
- let u = o ? l(e.state.doc, a.pos, o) : a.pos;
2279
- u ??= a.pos;
2280
- let d = e.state.tr;
2281
- if (s) {
2282
- let { node: e } = r;
2283
- e ? e.replace(d) : d.deleteSelection();
2284
- }
2285
- let f = d.mapping.map(u), p = o.openStart == 0 && o.openEnd == 0 && o.content.childCount == 1, m = d.doc;
2286
- if (p ? d.replaceRangeWith(f, f, o.content.firstChild) : d.replaceRange(f, f, o), d.doc.eq(m)) return;
2287
- let h = d.doc.resolve(f);
2288
- if (p && t.isSelectable(o.content.firstChild) && h.nodeAfter && h.nodeAfter.sameMarkup(o.content.firstChild)) d.setSelection(new t(h));
2289
- else {
2290
- let t = d.mapping.map(u);
2291
- d.mapping.maps[d.mapping.maps.length - 1].forEach((e, n, r, i) => t = i), d.setSelection(Tt(e, h, d.doc.resolve(t)));
2292
- }
2293
- e.focus(), e.dispatch(d.setMeta("uiEvent", "drop"));
2294
- }
2295
- W.focus = (e) => {
2296
- if (e.input.lastFocus = Date.now(), !e.focused) {
2297
- e.domObserver.stop(), e.dom.classList.add("ProseMirror-focused"), e.domObserver.start(), e.focused = !0;
2298
- let t = e.domSelectionRange();
2299
- if (!e.domObserver.currentSelection.eq(t)) {
2300
- let { focusNode: n, focusOffset: r } = t;
2301
- setTimeout(() => {
2302
- let t = e.domSelectionRange();
2303
- t.focusNode == n && t.focusOffset == r && e.docView && e.hasFocus() && V(e);
2304
- }, 20);
2305
- }
2306
- }
2307
- }, W.blur = (e, t) => {
2308
- let n = t;
2309
- e.focused &&= (e.domObserver.stop(), e.dom.classList.remove("ProseMirror-focused"), e.domObserver.start(), n.relatedTarget && e.dom.contains(n.relatedTarget) && e.domObserver.currentSelection.clear(), !1);
2310
- }, W.beforeinput = (e, t) => {
2311
- if (M && t.inputType == "deleteContentBackward") {
2312
- e.domObserver.flushSoon();
2313
- let { domChangeCount: t } = e.input;
2314
- setTimeout(() => {
2315
- if (e.input.domChangeCount != t || e.domObserver.pendingRecords().length || (e.dom.blur(), e.focus(), q(e, "Backspace"))) return;
2316
- let { $cursor: n } = e.state.selection;
2317
- n && n.pos > 0 && e.dispatch(e.state.tr.delete(n.pos - 1, n.pos).scrollIntoView());
2318
- }, 50);
2319
- }
2320
- };
2321
- for (let e in G) W[e] = G[e];
2322
- function Yn(e, t) {
2323
- if (e == t) return !0;
2324
- for (let n in e) if (e[n] !== t[n]) return !1;
2325
- for (let n in t) if (!(n in e)) return !1;
2326
- return !0;
2327
- }
2328
- var Xn = class {
2329
- constructor(e) {
2330
- this.frag = e, this.index = 0, this.off = 0;
2331
- }
2332
- nodeAt(e) {
2333
- for (; this.off <= e && this.index < this.frag.childCount;) {
2334
- let t = this.frag.child(this.index);
2335
- if (this.off == e) return t;
2336
- this.off += t.nodeSize, this.index++;
2337
- }
2338
- return null;
2339
- }
2340
- }, Zn = class e {
2341
- constructor(e, t) {
2342
- this.toDOM = e, this.spec = t || X, this.side = this.spec.side || 0;
2343
- }
2344
- map(e, t, n, r) {
2345
- let { pos: i, deleted: a } = e.mapResult(t.from + r, this.side < 0 ? -1 : 1);
2346
- return a ? null : new J(i - n, i - n, this);
2347
- }
2348
- valid() {
2349
- return !0;
2350
- }
2351
- eq(t) {
2352
- return this == t || t instanceof e && (this.spec.key && this.spec.key == t.spec.key || this.toDOM == t.toDOM && Yn(this.spec, t.spec));
2353
- }
2354
- destroy(e) {
2355
- this.spec.destroy && this.spec.destroy(e);
2356
- }
2357
- }, Qn = class e {
2358
- constructor(e, t) {
2359
- this.attrs = e, this.spec = t || X;
2360
- }
2361
- map(e, t, n, r) {
2362
- let i = e.map(t.from + r, this.spec.inclusiveStart ? -1 : 1) - n, a = e.map(t.to + r, this.spec.inclusiveEnd ? 1 : -1) - n;
2363
- return i >= a ? null : new J(i, a, this);
2364
- }
2365
- valid(e, t) {
2366
- return t.from < t.to;
2367
- }
2368
- eq(t) {
2369
- return this == t || t instanceof e && Yn(this.attrs, t.attrs) && Yn(this.spec, t.spec);
2370
- }
2371
- static is(t) {
2372
- return t.type instanceof e;
2373
- }
2374
- destroy() {}
2375
- }, $n = class e {
2376
- constructor(e, t) {
2377
- this.attrs = e, this.spec = t || X;
2378
- }
2379
- map(e, t, n, r) {
2380
- let i = e.mapResult(t.from + r, 1);
2381
- if (i.deleted) return null;
2382
- let a = e.mapResult(t.to + r, -1);
2383
- return a.deleted || a.pos <= i.pos ? null : new J(i.pos - n, a.pos - n, this);
2384
- }
2385
- valid(e, t, n) {
2386
- let r = n.nodeAt(t.from);
2387
- return !!r && !r.isText && t.from + r.nodeSize == t.to;
2388
- }
2389
- eq(t) {
2390
- return this == t || t instanceof e && Yn(this.attrs, t.attrs) && Yn(this.spec, t.spec);
2391
- }
2392
- destroy() {}
2393
- }, J = class e {
2394
- constructor(e, t, n) {
2395
- this.from = e, this.to = t, this.type = n;
2396
- }
2397
- copy(t, n) {
2398
- return new e(t, n, this.type);
2399
- }
2400
- eq(e, t = 0) {
2401
- return this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to;
2402
- }
2403
- map(e, t, n) {
2404
- return this.type.map(e, this, t, n);
2405
- }
2406
- static widget(t, n, r) {
2407
- return new e(t, t, new Zn(n, r));
2408
- }
2409
- static inline(t, n, r, i) {
2410
- return new e(t, n, new Qn(r, i));
2411
- }
2412
- static node(t, n, r, i) {
2413
- return new e(t, n, new $n(r, i));
2414
- }
2415
- get spec() {
2416
- return this.type.spec;
2417
- }
2418
- get inline() {
2419
- return this.type instanceof Qn;
2420
- }
2421
- get widget() {
2422
- return this.type instanceof Zn;
2423
- }
2424
- }, Y = [], X = {}, Z = class e {
2425
- constructor(e, t) {
2426
- this.local = e.length ? e : Y, this.children = t.length ? t : Y;
2427
- }
2428
- static create(e, t) {
2429
- return t.length ? or(t, e, 0, X) : Q;
2430
- }
2431
- find(e, t, n) {
2432
- let r = [];
2433
- return this.findInner(e ?? 0, t ?? 1e9, r, 0, n), r;
2434
- }
2435
- findInner(e, t, n, r, i) {
2436
- for (let a = 0; a < this.local.length; a++) {
2437
- let o = this.local[a];
2438
- o.from <= t && o.to >= e && (!i || i(o.spec)) && n.push(o.copy(o.from + r, o.to + r));
2439
- }
2440
- for (let a = 0; a < this.children.length; a += 3) if (this.children[a] < t && this.children[a + 1] > e) {
2441
- let o = this.children[a] + 1;
2442
- this.children[a + 2].findInner(e - o, t - o, n, r + o, i);
2443
- }
2444
- }
2445
- map(e, t, n) {
2446
- return this == Q || e.maps.length == 0 ? this : this.mapInner(e, t, 0, 0, n || X);
2447
- }
2448
- mapInner(t, n, r, i, a) {
2449
- let o;
2450
- if (this.local.length) {
2451
- let e = new Xn(n.content);
2452
- for (let s = 0; s < this.local.length; s++) {
2453
- let c = this.local[s].map(t, r, i);
2454
- c && c.type.valid(n, c, e) ? (o ||= []).push(c) : a.onRemove && a.onRemove(this.local[s].spec);
2455
- }
2456
- }
2457
- return this.children.length ? tr(this.children, o || [], t, n, r, i, a) : o ? new e(o.sort($), Y) : Q;
2458
- }
2459
- add(t, n) {
2460
- return n.length ? this == Q ? e.create(t, n) : this.addInner(t, n, 0) : this;
2461
- }
2462
- addInner(t, n, r) {
2463
- let i, a = 0;
2464
- t.forEach((e, t) => {
2465
- let o = t + r, s;
2466
- if (s = ir(n, e, o)) {
2467
- for (i ||= this.children.slice(); a < i.length && i[a] < t;) a += 3;
2468
- i[a] == t ? i[a + 2] = i[a + 2].addInner(e, s, o + 1) : i.splice(a, 0, t, t + e.nodeSize, or(s, e, o + 1, X)), a += 3;
2469
- }
2470
- });
2471
- let o = nr(a ? ar(n) : n, -r);
2472
- if (o.length) {
2473
- let e = new Xn(t.content);
2474
- for (let n = 0; n < o.length; n++) o[n].type.valid(t, o[n], e) || o.splice(n--, 1);
2475
- }
2476
- return new e(o.length ? this.local.concat(o).sort($) : this.local, i || this.children);
2477
- }
2478
- remove(e) {
2479
- return e.length == 0 || this == Q ? this : this.removeInner(e, 0);
2480
- }
2481
- removeInner(t, n) {
2482
- let r = this.children, i = this.local;
2483
- for (let e = 0; e < r.length; e += 3) {
2484
- let i, a = r[e] + n, o = r[e + 1] + n;
2485
- for (let e = 0, n; e < t.length; e++) (n = t[e]) && n.from > a && n.to < o && (t[e] = null, (i ||= []).push(n));
2486
- if (!i) continue;
2487
- r == this.children && (r = this.children.slice());
2488
- let s = r[e + 2].removeInner(i, a + 1);
2489
- s == Q ? (r.splice(e, 3), e -= 3) : r[e + 2] = s;
2490
- }
2491
- if (i.length) {
2492
- for (let e = 0, r; e < t.length; e++) if (r = t[e]) for (let e = 0; e < i.length; e++) i[e].eq(r, n) && (i == this.local && (i = this.local.slice()), i.splice(e--, 1));
2493
- }
2494
- return r == this.children && i == this.local ? this : i.length || r.length ? new e(i, r) : Q;
2495
- }
2496
- forChild(t, n) {
2497
- if (this == Q) return this;
2498
- if (n.isLeaf) return e.empty;
2499
- let r, i;
2500
- for (let e = 0; e < this.children.length; e += 3) if (this.children[e] >= t) {
2501
- this.children[e] == t && (r = this.children[e + 2]);
2502
- break;
2503
- }
2504
- let a = t + 1, o = a + n.content.size;
2505
- for (let e = 0; e < this.local.length; e++) {
2506
- let t = this.local[e];
2507
- if (t.from < o && t.to > a && t.type instanceof Qn) {
2508
- let e = Math.max(a, t.from) - a, n = Math.min(o, t.to) - a;
2509
- e < n && (i ||= []).push(t.copy(e, n));
2510
- }
2511
- }
2512
- if (i) {
2513
- let t = new e(i.sort($), Y);
2514
- return r ? new er([t, r]) : t;
2515
- }
2516
- return r || Q;
2517
- }
2518
- eq(t) {
2519
- if (this == t) return !0;
2520
- if (!(t instanceof e) || this.local.length != t.local.length || this.children.length != t.children.length) return !1;
2521
- for (let e = 0; e < this.local.length; e++) if (!this.local[e].eq(t.local[e])) return !1;
2522
- for (let e = 0; e < this.children.length; e += 3) if (this.children[e] != t.children[e] || this.children[e + 1] != t.children[e + 1] || !this.children[e + 2].eq(t.children[e + 2])) return !1;
2523
- return !0;
2524
- }
2525
- locals(e) {
2526
- return sr(this.localsInner(e));
2527
- }
2528
- localsInner(e) {
2529
- if (this == Q) return Y;
2530
- if (e.inlineContent || !this.local.some(Qn.is)) return this.local;
2531
- let t = [];
2532
- for (let e = 0; e < this.local.length; e++) this.local[e].type instanceof Qn || t.push(this.local[e]);
2533
- return t;
2534
- }
2535
- forEachSet(e) {
2536
- e(this);
2537
- }
2538
- };
2539
- Z.empty = new Z([], []), Z.removeOverlap = sr;
2540
- var Q = Z.empty, er = class e {
2541
- constructor(e) {
2542
- this.members = e;
2543
- }
2544
- map(t, n) {
2545
- let r = this.members.map((e) => e.map(t, n, X));
2546
- return e.from(r);
2547
- }
2548
- forChild(t, n) {
2549
- if (n.isLeaf) return Z.empty;
2550
- let r = [];
2551
- for (let i = 0; i < this.members.length; i++) {
2552
- let a = this.members[i].forChild(t, n);
2553
- a != Q && (a instanceof e ? r = r.concat(a.members) : r.push(a));
2554
- }
2555
- return e.from(r);
2556
- }
2557
- eq(t) {
2558
- if (!(t instanceof e) || t.members.length != this.members.length) return !1;
2559
- for (let e = 0; e < this.members.length; e++) if (!this.members[e].eq(t.members[e])) return !1;
2560
- return !0;
2561
- }
2562
- locals(e) {
2563
- let t, n = !0;
2564
- for (let r = 0; r < this.members.length; r++) {
2565
- let i = this.members[r].localsInner(e);
2566
- if (i.length) {
2567
- if (!t) t = i;
2568
- else {
2569
- n &&= (t = t.slice(), !1);
2570
- for (let e = 0; e < i.length; e++) t.push(i[e]);
2571
- }
2572
- }
2573
- }
2574
- return t ? sr(n ? t : t.sort($)) : Y;
2575
- }
2576
- static from(t) {
2577
- switch (t.length) {
2578
- case 0: return Q;
2579
- case 1: return t[0];
2580
- default: return new e(t.every((e) => e instanceof Z) ? t : t.reduce((e, t) => e.concat(t instanceof Z ? t : t.members), []));
2581
- }
2582
- }
2583
- forEachSet(e) {
2584
- for (let t = 0; t < this.members.length; t++) this.members[t].forEachSet(e);
2585
- }
2586
- };
2587
- function tr(e, t, n, r, i, a, o) {
2588
- let s = e.slice();
2589
- for (let e = 0, t = a; e < n.maps.length; e++) {
2590
- let r = 0;
2591
- n.maps[e].forEach((e, n, i, a) => {
2592
- let o = a - i - (n - e);
2593
- for (let i = 0; i < s.length; i += 3) {
2594
- let a = s[i + 1];
2595
- if (a < 0 || e > a + t - r) continue;
2596
- let c = s[i] + t - r;
2597
- n >= c ? s[i + 1] = e <= c ? -2 : -1 : e >= t && o && (s[i] += o, s[i + 1] += o);
2598
- }
2599
- r += o;
2600
- }), t = n.maps[e].map(t, -1);
2601
- }
2602
- let c = !1;
2603
- for (let t = 0; t < s.length; t += 3) if (s[t + 1] < 0) {
2604
- if (s[t + 1] == -2) {
2605
- c = !0, s[t + 1] = -1;
2606
- continue;
2607
- }
2608
- let l = n.map(e[t] + a), u = l - i;
2609
- if (u < 0 || u >= r.content.size) {
2610
- c = !0;
2611
- continue;
2612
- }
2613
- let d = n.map(e[t + 1] + a, -1) - i, { index: f, offset: p } = r.content.findIndex(u), m = r.maybeChild(f);
2614
- if (m && p == u && p + m.nodeSize == d) {
2615
- let r = s[t + 2].mapInner(n, m, l + 1, e[t] + a + 1, o);
2616
- r == Q ? (s[t + 1] = -2, c = !0) : (s[t] = u, s[t + 1] = d, s[t + 2] = r);
2617
- } else c = !0;
2618
- }
2619
- if (c) {
2620
- let c = or(rr(s, e, t, n, i, a, o), r, 0, o);
2621
- t = c.local;
2622
- for (let e = 0; e < s.length; e += 3) s[e + 1] < 0 && (s.splice(e, 3), e -= 3);
2623
- for (let e = 0, t = 0; e < c.children.length; e += 3) {
2624
- let n = c.children[e];
2625
- for (; t < s.length && s[t] < n;) t += 3;
2626
- s.splice(t, 0, c.children[e], c.children[e + 1], c.children[e + 2]);
2627
- }
2628
- }
2629
- return new Z(t.sort($), s);
2630
- }
2631
- function nr(e, t) {
2632
- if (!t || !e.length) return e;
2633
- let n = [];
2634
- for (let r = 0; r < e.length; r++) {
2635
- let i = e[r];
2636
- n.push(new J(i.from + t, i.to + t, i.type));
2637
- }
2638
- return n;
2639
- }
2640
- function rr(e, t, n, r, i, a, o) {
2641
- function s(e, t) {
2642
- for (let a = 0; a < e.local.length; a++) {
2643
- let s = e.local[a].map(r, i, t);
2644
- s ? n.push(s) : o.onRemove && o.onRemove(e.local[a].spec);
2645
- }
2646
- for (let n = 0; n < e.children.length; n += 3) s(e.children[n + 2], e.children[n] + t + 1);
2647
- }
2648
- for (let n = 0; n < e.length; n += 3) e[n + 1] == -1 && s(e[n + 2], t[n] + a + 1);
2649
- return n;
2650
- }
2651
- function ir(e, t, n) {
2652
- if (t.isLeaf) return null;
2653
- let r = n + t.nodeSize, i = null;
2654
- for (let t = 0, a; t < e.length; t++) (a = e[t]) && a.from > n && a.to < r && ((i ||= []).push(a), e[t] = null);
2655
- return i;
2656
- }
2657
- function ar(e) {
2658
- let t = [];
2659
- for (let n = 0; n < e.length; n++) e[n] != null && t.push(e[n]);
2660
- return t;
2661
- }
2662
- function or(e, t, n, r) {
2663
- let i = [], a = !1;
2664
- t.forEach((t, o) => {
2665
- let s = ir(e, t, o + n);
2666
- if (s) {
2667
- a = !0;
2668
- let e = or(s, t, n + o + 1, r);
2669
- e != Q && i.push(o, o + t.nodeSize, e);
2670
- }
2671
- });
2672
- let o = nr(a ? ar(e) : e, -n).sort($);
2673
- if (o.length) {
2674
- let e = new Xn(t.content);
2675
- for (let n = 0; n < o.length; n++) o[n].type.valid(t, o[n], e) || (r.onRemove && r.onRemove(o[n].spec), o.splice(n--, 1));
2676
- }
2677
- return o.length || i.length ? new Z(o, i) : Q;
2678
- }
2679
- function $(e, t) {
2680
- return e.from - t.from || e.to - t.to;
2681
- }
2682
- function sr(e) {
2683
- let t = e;
2684
- for (let n = 0; n < t.length - 1; n++) {
2685
- let r = t[n];
2686
- if (r.from != r.to) for (let i = n + 1; i < t.length; i++) {
2687
- let a = t[i];
2688
- if (a.from == r.from) a.to != r.to && (t == e && (t = e.slice()), t[i] = a.copy(a.from, r.to), cr(t, i + 1, a.copy(r.to, a.to)));
2689
- else {
2690
- a.from < r.to && (t == e && (t = e.slice()), t[n] = r.copy(r.from, a.from), cr(t, i, r.copy(a.from, r.to)));
2691
- break;
2692
- }
2693
- }
2694
- }
2695
- return t;
2696
- }
2697
- function cr(e, t, n) {
2698
- for (; t < e.length && $(n, e[t]) > 0;) t++;
2699
- e.splice(t, 0, n);
2700
- }
2701
- function lr(e) {
2702
- let t = [];
2703
- return e.someProp("decorations", (n) => {
2704
- let r = n(e.state);
2705
- r && r != Q && t.push(r);
2706
- }), e.cursorWrapper && t.push(Z.create(e.state.doc, [e.cursorWrapper.deco])), er.from(t);
2707
- }
2708
- var ur = {
2709
- childList: !0,
2710
- characterData: !0,
2711
- characterDataOldValue: !0,
2712
- attributes: !0,
2713
- attributeOldValue: !0,
2714
- subtree: !0
2715
- }, dr = E && D <= 11, fr = class {
2716
- constructor() {
2717
- this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
2718
- }
2719
- set(e) {
2720
- this.anchorNode = e.anchorNode, this.anchorOffset = e.anchorOffset, this.focusNode = e.focusNode, this.focusOffset = e.focusOffset;
2721
- }
2722
- clear() {
2723
- this.anchorNode = this.focusNode = null;
2724
- }
2725
- eq(e) {
2726
- return e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset;
2727
- }
2728
- }, pr = class {
2729
- constructor(e, t) {
2730
- this.view = e, this.handleDOMChange = t, this.queue = [], this.flushingSoon = -1, this.observer = null, this.currentSelection = new fr(), this.onCharData = null, this.suppressingSelectionUpdates = !1, this.lastChangedTextNode = null, this.observer = window.MutationObserver && new window.MutationObserver((t) => {
2731
- for (let e = 0; e < t.length; e++) this.queue.push(t[e]);
2732
- E && D <= 11 && t.some((e) => e.type == "childList" && e.removedNodes.length || e.type == "characterData" && e.oldValue.length > e.target.nodeValue.length) ? this.flushSoon() : A && e.composing && t.some((e) => e.type == "childList" && e.target.nodeName == "TR") ? (e.input.badSafariComposition = !0, this.flushSoon()) : this.flush();
2733
- }), dr && (this.onCharData = (e) => {
2734
- this.queue.push({
2735
- target: e.target,
2736
- type: "characterData",
2737
- oldValue: e.prevValue
2738
- }), this.flushSoon();
2739
- }), this.onSelectionChange = this.onSelectionChange.bind(this);
2740
- }
2741
- flushSoon() {
2742
- this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(() => {
2743
- this.flushingSoon = -1, this.flush();
2744
- }, 20));
2745
- }
2746
- forceFlush() {
2747
- this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush());
2748
- }
2749
- start() {
2750
- this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, ur)), this.onCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection();
2751
- }
2752
- stop() {
2753
- if (this.observer) {
2754
- let e = this.observer.takeRecords();
2755
- if (e.length) {
2756
- for (let t = 0; t < e.length; t++) this.queue.push(e[t]);
2757
- window.setTimeout(() => this.flush(), 20);
2758
- }
2759
- this.observer.disconnect();
2760
- }
2761
- this.onCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection();
2762
- }
2763
- connectSelection() {
2764
- this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
2765
- }
2766
- disconnectSelection() {
2767
- this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
2768
- }
2769
- suppressSelectionUpdates() {
2770
- this.suppressingSelectionUpdates = !0, setTimeout(() => this.suppressingSelectionUpdates = !1, 50);
2771
- }
2772
- onSelectionChange() {
2773
- if (Et(this.view)) {
2774
- if (this.suppressingSelectionUpdates) return V(this.view);
2775
- if (E && D <= 11 && !this.view.state.selection.empty) {
2776
- let e = this.view.domSelectionRange();
2777
- if (e.focusNode && h(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset)) return this.flushSoon();
2778
- }
2779
- this.flush();
2780
- }
2781
- }
2782
- setCurSelection() {
2783
- this.currentSelection.set(this.view.domSelectionRange());
2784
- }
2785
- ignoreSelectionChange(e) {
2786
- if (!e.focusNode) return !0;
2787
- let t = /* @__PURE__ */ new Set(), n;
2788
- for (let n = e.focusNode; n; n = d(n)) t.add(n);
2789
- for (let r = e.anchorNode; r; r = d(r)) if (t.has(r)) {
2790
- n = r;
2791
- break;
2792
- }
2793
- let r = n && this.view.docView.nearestDesc(n);
2794
- if (r && r.ignoreMutation({
2795
- type: "selection",
2796
- target: b(n) ? n.parentNode : n
2797
- })) return this.setCurSelection(), !0;
2798
- }
2799
- pendingRecords() {
2800
- if (this.observer) for (let e of this.observer.takeRecords()) this.queue.push(e);
2801
- return this.queue;
2802
- }
2803
- flush() {
2804
- let { view: e } = this;
2805
- if (!e.docView || this.flushingSoon > -1) return;
2806
- let t = this.pendingRecords();
2807
- t.length && (this.queue = []);
2808
- let r, i = !1;
2809
- !this.suppressingSelectionUpdates && Et(e) && (r = e.domSelectionRange(), i = !this.currentSelection.eq(r) && !this.ignoreSelectionChange(r));
2810
- let a = -1, o = -1, s = !1, c = [];
2811
- if (e.editable) for (let e = 0; e < t.length; e++) {
2812
- let n = this.registerMutation(t[e], c);
2813
- n && (a = a < 0 ? n.from : Math.min(n.from, a), o = o < 0 ? n.to : Math.max(n.to, o), n.typeOver && (s = !0));
2814
- }
2815
- if (c.some((e) => e.nodeName == "BR") && (e.input.lastKeyCode == 8 || e.input.lastKeyCode == 46 || k && (e.composing || e.input.compositionEndedAt > Date.now() - 50) && t.some((e) => e.type == "childList" && e.removedNodes.length))) {
2816
- for (let e of c) if (e.nodeName == "BR" && e.parentNode) {
2817
- let t = e.nextSibling;
2818
- for (; t && y(t);) {
2819
- if (t.contentEditable == "false") {
2820
- e.parentNode.removeChild(e);
2821
- break;
2822
- }
2823
- t = t.firstChild;
2824
- }
2825
- }
2826
- } else if (O && c.length) {
2827
- let t = c.filter((e) => e.nodeName == "BR");
2828
- if (t.length == 2) {
2829
- let [e, n] = t;
2830
- e.parentNode && e.parentNode.parentNode == n.parentNode ? n.remove() : e.remove();
2831
- } else {
2832
- let { focusNode: n } = this.currentSelection;
2833
- for (let r of t) {
2834
- let t = r.parentNode;
2835
- t && t.nodeName == "LI" && (!n || yr(e, n) != t) && r.remove();
2836
- }
2837
- }
2838
- }
2839
- let l = null;
2840
- a < 0 && i && e.input.lastFocus > Date.now() - 200 && Math.max(e.input.lastTouch, e.input.lastClick.time) < Date.now() - 300 && ne(r) && (l = ht(e)) && l.eq(n.near(e.state.doc.resolve(0), 1)) ? (e.input.lastFocus = 0, V(e), this.currentSelection.set(r), e.scrollToSelection()) : (a > -1 || i) && (a > -1 && (e.docView.markDirty(a, o), gr(e)), e.input.badSafariComposition && (e.input.badSafariComposition = !1, br(e, c)), this.handleDOMChange(a, o, s, c), e.docView && e.docView.dirty ? e.updateState(e.state) : r && !this.currentSelection.eq(r) && V(e), r && this.currentSelection.set(r));
2841
- }
2842
- registerMutation(e, t) {
2843
- if (t.indexOf(e.target) > -1) return null;
2844
- let n = this.view.docView.nearestDesc(e.target);
2845
- if (e.type == "attributes" && (n == this.view.docView || e.attributeName == "contenteditable" || e.attributeName == "style" && !e.oldValue && !e.target.getAttribute("style")) || !n || n.ignoreMutation(e)) return null;
2846
- if (e.type == "childList") {
2847
- for (let n = 0; n < e.addedNodes.length; n++) {
2848
- let r = e.addedNodes[n];
2849
- t.push(r), b(r) && (this.lastChangedTextNode = r);
2850
- }
2851
- if (n.contentDOM && n.contentDOM != n.dom && !n.contentDOM.contains(e.target)) return {
2852
- from: n.posBefore,
2853
- to: n.posAfter
2854
- };
2855
- let r = e.previousSibling, i = e.nextSibling;
2856
- if (E && D <= 11 && e.addedNodes.length) for (let t = 0; t < e.addedNodes.length; t++) {
2857
- let { previousSibling: n, nextSibling: a } = e.addedNodes[t];
2858
- (!n || Array.prototype.indexOf.call(e.addedNodes, n) < 0) && (r = n), (!a || Array.prototype.indexOf.call(e.addedNodes, a) < 0) && (i = a);
2859
- }
2860
- let a = r && r.parentNode == e.target ? u(r) + 1 : 0, o = n.localPosFromDOM(e.target, a, -1), s = i && i.parentNode == e.target ? u(i) : e.target.childNodes.length;
2861
- return {
2862
- from: o,
2863
- to: n.localPosFromDOM(e.target, s, 1)
2864
- };
2865
- }
2866
- return e.type == "attributes" ? {
2867
- from: n.posAtStart - n.border,
2868
- to: n.posAtEnd + n.border
2869
- } : (this.lastChangedTextNode = e.target, {
2870
- from: n.posAtStart,
2871
- to: n.posAtEnd,
2872
- typeOver: e.target.nodeValue == e.oldValue
2873
- });
2874
- }
2875
- }, mr = /* @__PURE__ */ new WeakMap(), hr = !1;
2876
- function gr(e) {
2877
- if (!mr.has(e) && (mr.set(e, null), [
2878
- "normal",
2879
- "nowrap",
2880
- "pre-line"
2881
- ].indexOf(getComputedStyle(e.dom).whiteSpace) !== -1)) {
2882
- if (e.requiresGeckoHackNode = O, hr) return;
2883
- console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."), hr = !0;
2884
- }
2885
- }
2886
- function _r(e, t) {
2887
- let n = t.startContainer, r = t.startOffset, i = t.endContainer, a = t.endOffset, o = e.domAtPos(e.state.selection.anchor);
2888
- return h(o.node, o.offset, i, a) && ([n, r, i, a] = [
2889
- i,
2890
- a,
2891
- n,
2892
- r
2893
- ]), {
2894
- anchorNode: n,
2895
- anchorOffset: r,
2896
- focusNode: i,
2897
- focusOffset: a
2898
- };
2899
- }
2900
- function vr(e, t) {
2901
- if (t.getComposedRanges) {
2902
- let n = t.getComposedRanges(e.root)[0];
2903
- if (n) return _r(e, n);
2904
- }
2905
- let n;
2906
- function r(e) {
2907
- e.preventDefault(), e.stopImmediatePropagation(), n = e.getTargetRanges()[0];
2908
- }
2909
- return e.dom.addEventListener("beforeinput", r, !0), document.execCommand("indent"), e.dom.removeEventListener("beforeinput", r, !0), n ? _r(e, n) : null;
2910
- }
2911
- function yr(e, t) {
2912
- for (let n = t.parentNode; n && n != e.dom; n = n.parentNode) {
2913
- let t = e.docView.nearestDesc(n, !0);
2914
- if (t && t.node.isBlock) return n;
2915
- }
2916
- return null;
2917
- }
2918
- function br(e, t) {
2919
- let { focusNode: n, focusOffset: r } = e.domSelectionRange();
2920
- for (let i of t) if (i.parentNode?.nodeName == "TR") {
2921
- let t = i.nextSibling;
2922
- for (; t && t.nodeName != "TD" && t.nodeName != "TH";) t = t.nextSibling;
2923
- if (t) {
2924
- let a = t;
2925
- for (;;) {
2926
- let e = a.firstChild;
2927
- if (!e || !y(e) || e.contentEditable == "false" || /^(BR|IMG)$/.test(e.nodeName)) break;
2928
- a = e;
2929
- }
2930
- a.insertBefore(i, a.firstChild), n == i && e.domSelection().collapse(i, r);
2931
- } else i.parentNode.removeChild(i);
2932
- }
2933
- }
2934
- function xr(e, t, n, r) {
2935
- let { node: a, fromOffset: o, toOffset: s, from: c, to: l } = e.docView.parseRange(t, n), u = e.domSelectionRange(), d, f = u.anchorNode;
2936
- if (f && x(e.dom, f) && (d = [{
2937
- node: f,
2938
- offset: u.anchorOffset
2939
- }], ne(u) || d.push({
2940
- node: u.focusNode,
2941
- offset: u.focusOffset
2942
- })), k && e.input.lastKeyCode === 8) for (let e = s; e > o; e--) {
2943
- let t = a.childNodes[e - 1], n = t.pmViewDesc;
2944
- if (t.nodeName == "BR" && !n) {
2945
- s = e;
2946
- break;
2947
- }
2948
- if (!n || n.size) break;
2949
- }
2950
- let p = e.state.doc, m = e.someProp("domParser") || i.fromSchema(e.state.schema), h = p.resolve(c), g = null, _ = m.parse(a, {
2951
- topNode: h.parent,
2952
- topMatch: h.parent.contentMatchAt(h.index()),
2953
- topOpen: !0,
2954
- from: o,
2955
- to: s,
2956
- preserveWhitespace: h.parent.type.whitespace != "pre" || "full",
2957
- findPositions: d,
2958
- ruleFromNode: Sr(r),
2959
- context: h
2960
- });
2961
- if (d && d[0].pos != null) {
2962
- let e = d[0].pos, t = d[1] && d[1].pos;
2963
- t ??= e, g = {
2964
- anchor: e + c,
2965
- head: t + c
2966
- };
2967
- }
2968
- return {
2969
- doc: _,
2970
- sel: g,
2971
- from: c,
2972
- to: l
2973
- };
2974
- }
2975
- var Sr = (e) => (t) => {
2976
- let n = t.pmViewDesc;
2977
- if (n) return n.parseRule(e);
2978
- if (t.nodeName == "BR" && t.parentNode) {
2979
- if (A && /^(ul|ol)$/i.test(t.parentNode.nodeName)) {
2980
- let e = document.createElement("div");
2981
- return e.appendChild(document.createElement("li")), { skip: e };
2982
- }
2983
- if (t.parentNode.lastChild == t || A && /^(tr|table)$/i.test(t.parentNode.nodeName)) return { ignore: !0 };
2984
- } else if (t.nodeName == "IMG" && t.getAttribute("mark-placeholder")) return { ignore: !0 };
2985
- return null;
2986
- }, Cr = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
2987
- function wr(e, t, n, i, a) {
2988
- let o = e.input.compositionPendingChanges || (e.composing ? e.input.compositionID : 0);
2989
- if (e.input.compositionPendingChanges = 0, t < 0) {
2990
- let t = e.input.lastSelectionTime > Date.now() - 50 ? e.input.lastSelectionOrigin : null, n = ht(e, t);
2991
- if (n && !e.state.selection.eq(n)) {
2992
- if (k && M && e.input.lastKeyCode === 13 && Date.now() - 100 < e.input.lastKeyCodeTime && q(e, "Enter")) return;
2993
- let r = e.state.tr.setSelection(n);
2994
- t == "pointer" ? r.setMeta("pointer", !0) : t == "key" && r.scrollIntoView(), o && r.setMeta("composition", o), e.dispatch(r);
2995
- }
2996
- return;
2997
- }
2998
- let s = e.state.doc.resolve(t), c = s.sharedDepth(n);
2999
- t = s.before(c + 1), n = e.state.doc.resolve(n).after(c + 1);
3000
- let l = e.state.selection, u = xr(e, t, n, a), d = e.state.doc, f = d.slice(u.from, u.to), p, m;
3001
- e.input.lastKeyCode === 8 && Date.now() - 100 < e.input.lastKeyCodeTime ? (p = e.state.selection.to, m = "end") : (p = e.state.selection.from, m = "start"), e.input.lastKeyCode = null;
3002
- let h = Ar(f.content, u.doc.content, u.from, p, m);
3003
- if (h && e.input.domChangeCount++, (fe && e.input.lastIOSEnter > Date.now() - 225 || M) && a.some((e) => y(e) && !Cr.test(e.nodeName)) && (!h || h.endA >= h.endB) && q(e, "Enter")) {
3004
- e.input.lastIOSEnter = 0;
3005
- return;
3006
- }
3007
- if (!h) {
3008
- if (i && l instanceof r && !l.empty && l.$head.sameParent(l.$anchor) && !e.composing && !(u.sel && u.sel.anchor != u.sel.head)) h = {
3009
- start: l.from,
3010
- endA: l.to,
3011
- endB: l.to
3012
- };
3013
- else {
3014
- if (u.sel) {
3015
- let t = Tr(e, e.state.doc, u.sel);
3016
- if (t && !t.eq(e.state.selection)) {
3017
- let n = e.state.tr.setSelection(t);
3018
- o && n.setMeta("composition", o), e.dispatch(n);
3019
- }
3020
- }
3021
- return;
3022
- }
3023
- }
3024
- e.state.selection.from < e.state.selection.to && h.start == h.endB && e.state.selection instanceof r && (h.start > e.state.selection.from && h.start <= e.state.selection.from + 2 && e.state.selection.from >= u.from ? h.start = e.state.selection.from : h.endA < e.state.selection.to && h.endA >= e.state.selection.to - 2 && e.state.selection.to <= u.to && (h.endB += e.state.selection.to - h.endA, h.endA = e.state.selection.to)), E && D <= 11 && h.endB == h.start + 1 && h.endA == h.start && h.start > u.from && u.doc.textBetween(h.start - u.from - 1, h.start - u.from + 1) == " \xA0" && (h.start--, h.endA--, h.endB--);
3025
- let g = u.doc.resolveNoCache(h.start - u.from), _ = u.doc.resolveNoCache(h.endB - u.from), v = d.resolve(h.start), b = g.sameParent(_) && g.parent.inlineContent && v.end() >= h.endA;
3026
- if ((fe && e.input.lastIOSEnter > Date.now() - 225 && (!b || a.some((e) => e.nodeName == "DIV" || e.nodeName == "P")) || !b && Or(u.doc, g.pos, _.pos)) && q(e, "Enter")) {
3027
- e.input.lastIOSEnter = 0;
3028
- return;
3029
- }
3030
- if (e.state.selection.anchor > h.start && (b ? h.endA > h.start && h.endB == h.start : Dr(d, h.start, h.endA, g, _)) && q(e, "Backspace")) {
3031
- M && k && e.domObserver.suppressSelectionUpdates();
3032
- return;
3033
- }
3034
- k && h.endB == h.start && (e.input.lastChromeDelete = Date.now()), M && !b && g.start() != _.start() && _.parentOffset == 0 && g.depth == _.depth && u.sel && u.sel.anchor == u.sel.head && u.sel.head == h.endA && (h.endB -= 2, _ = u.doc.resolveNoCache(h.endB - u.from), setTimeout(() => q(e, "Enter"), 20));
3035
- let x = h.start, S = h.endA, C = (t) => {
3036
- let n = t || e.state.tr.replace(x, S, u.doc.slice(h.start - u.from, h.endB - u.from));
3037
- if (u.sel) {
3038
- let t = Tr(e, n.doc, u.sel);
3039
- t && !(k && e.composing && t.empty && (h.start != h.endB || e.input.lastChromeDelete < Date.now() - 100) && (t.head == x || t.head == n.mapping.map(S) - 1) || E && t.empty && t.head == x) && n.setSelection(t);
3040
- }
3041
- return o && n.setMeta("composition", o), n.scrollIntoView();
3042
- }, ee;
3043
- if (b) {
3044
- if (g.pos == _.pos) {
3045
- E && D <= 11 && g.parentOffset == 0 && (e.domObserver.suppressSelectionUpdates(), setTimeout(() => V(e), 20));
3046
- let t = C(e.state.tr.delete(x, S)), n = d.resolve(h.start).marksAcross(d.resolve(h.endA));
3047
- n && t.ensureMarks(n), e.dispatch(t);
3048
- } else if (h.endA == h.endB && (ee = Er(g.parent.content.cut(g.parentOffset, _.parentOffset), v.parent.content.cut(v.parentOffset, h.endA - v.start())))) {
3049
- let t = C(e.state.tr);
3050
- ee.type == "add" ? t.addMark(x, S, ee.mark) : t.removeMark(x, S, ee.mark), e.dispatch(t);
3051
- } else if (g.parent.child(g.index()).isText && g.index() == _.index() - +!_.textOffset) {
3052
- let t = g.parent.textBetween(g.parentOffset, _.parentOffset), n = () => C(e.state.tr.insertText(t, x, S));
3053
- e.someProp("handleTextInput", (r) => r(e, x, S, t, n)) || e.dispatch(n());
3054
- } else e.dispatch(C());
3055
- } else e.dispatch(C());
3056
- }
3057
- function Tr(e, t, n) {
3058
- return Math.max(n.anchor, n.head) > t.content.size ? null : Tt(e, t.resolve(n.anchor), t.resolve(n.head));
3059
- }
3060
- function Er(e, t) {
3061
- let n = e.firstChild.marks, r = t.firstChild.marks, i = n, a = r, s, c, l;
3062
- for (let e = 0; e < r.length; e++) i = r[e].removeFromSet(i);
3063
- for (let e = 0; e < n.length; e++) a = n[e].removeFromSet(a);
3064
- if (i.length == 1 && a.length == 0) c = i[0], s = "add", l = (e) => e.mark(c.addToSet(e.marks));
3065
- else if (i.length == 0 && a.length == 1) c = a[0], s = "remove", l = (e) => e.mark(c.removeFromSet(e.marks));
3066
- else return null;
3067
- let u = [];
3068
- for (let e = 0; e < t.childCount; e++) u.push(l(t.child(e)));
3069
- if (o.from(u).eq(e)) return {
3070
- mark: c,
3071
- type: s
3072
- };
3073
- }
3074
- function Dr(e, t, n, r, i) {
3075
- if (n - t <= i.pos - r.pos || kr(r, !0, !1) < i.pos) return !1;
3076
- let a = e.resolve(t);
3077
- if (!r.parent.inlineContent) {
3078
- let e = a.nodeAfter;
3079
- return e != null && n == t + e.nodeSize;
3080
- }
3081
- if (a.parentOffset < a.parent.content.size || !a.parent.isTextblock) return !1;
3082
- let o = e.resolve(kr(a, !0, !0));
3083
- return !o.parent.isTextblock || o.pos > n || kr(o, !0, !1) < n ? !1 : r.parent.content.cut(r.parentOffset).eq(o.parent.content);
3084
- }
3085
- function Or(e, t, n) {
3086
- let r = 0, i = 0;
3087
- return e.nodesBetween(t, n, (e, a) => {
3088
- e.isTextblock && a >= t && a < n ? r++ : (e.isText ? /\S/.test(e.text.slice(Math.max(0, t - a), Math.min(e.nodeSize, n - a))) : e.isLeaf) && i++;
3089
- }), i == 0 && r == 1;
3090
- }
3091
- function kr(e, t, n) {
3092
- let r = e.depth, i = t ? e.end() : e.pos;
3093
- for (; r > 0 && (t || e.indexAfter(r) == e.node(r).childCount);) r--, i++, t = !1;
3094
- if (n) {
3095
- let t = e.node(r).maybeChild(e.indexAfter(r));
3096
- for (; t && !t.isLeaf;) t = t.firstChild, i++;
3097
- }
3098
- return i;
3099
- }
3100
- function Ar(e, t, n, r, i) {
3101
- let a = e.findDiffStart(t, n), o = n + e.size, s = n + t.size;
3102
- if (a == null) return null;
3103
- let { a: c, b: l } = e.findDiffEnd(t, o, s);
3104
- if (i == "end") {
3105
- let e = Math.max(0, a - Math.min(c, l));
3106
- r -= c + e - a;
3107
- }
3108
- if (c < a && o < s) {
3109
- let e = r <= a && r >= c ? a - r : 0;
3110
- a -= e, l = a + (l - c), c = a;
3111
- } else if (l < a) {
3112
- let e = r <= a && r >= l ? a - r : 0;
3113
- a -= e, c = a + (c - l), l = a;
3114
- }
3115
- return {
3116
- start: a,
3117
- endA: c,
3118
- endB: l
3119
- };
3120
- }
3121
- var jr = class {
3122
- constructor(e, t) {
3123
- this._root = null, this.focused = !1, this.trackWrites = null, this.mounted = !1, this.markCursor = null, this.cursorWrapper = null, this.lastSelectedViewDesc = void 0, this.input = new ln(), this.prevDirectPlugins = [], this.pluginViews = [], this.requiresGeckoHackNode = !1, this.dragging = null, this._props = t, this.state = t.state, this.directPlugins = t.plugins || [], this.directPlugins.forEach(Rr), this.dispatch = this.dispatch.bind(this), this.dom = e && e.mount || document.createElement("div"), e && (e.appendChild ? e.appendChild(this.dom) : typeof e == "function" ? e(this.dom) : e.mount && (this.mounted = !0)), this.editable = Pr(this), Nr(this), this.nodeViews = Ir(this), this.docView = Xe(this.state.doc, Mr(this), lr(this), this.dom, this), this.domObserver = new pr(this, (e, t, n, r) => wr(this, e, t, n, r)), this.domObserver.start(), un(this), this.updatePluginViews();
3124
- }
3125
- get composing() {
3126
- return this.input.composing;
3127
- }
3128
- get props() {
3129
- if (this._props.state != this.state) {
3130
- let e = this._props;
3131
- this._props = {};
3132
- for (let t in e) this._props[t] = e[t];
3133
- this._props.state = this.state;
3134
- }
3135
- return this._props;
3136
- }
3137
- update(e) {
3138
- e.handleDOMEvents != this._props.handleDOMEvents && fn(this);
3139
- let t = this._props;
3140
- this._props = e, e.plugins && (e.plugins.forEach(Rr), this.directPlugins = e.plugins), this.updateStateInner(e.state, t);
3141
- }
3142
- setProps(e) {
3143
- let t = {};
3144
- for (let e in this._props) t[e] = this._props[e];
3145
- t.state = this.state;
3146
- for (let n in e) t[n] = e[n];
3147
- this.update(t);
3148
- }
3149
- updateState(e) {
3150
- this.updateStateInner(e, this._props);
3151
- }
3152
- updateStateInner(e, t) {
3153
- let n = this.state, r = !1, i = !1;
3154
- e.storedMarks && this.composing && (In(this), i = !0), this.state = e;
3155
- let a = n.plugins != e.plugins || this._props.plugins != t.plugins;
3156
- if (a || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews) {
3157
- let e = Ir(this);
3158
- Lr(e, this.nodeViews) && (this.nodeViews = e, r = !0);
3159
- }
3160
- (a || t.handleDOMEvents != this._props.handleDOMEvents) && fn(this), this.editable = Pr(this), Nr(this);
3161
- let o = lr(this), s = Mr(this), c = n.plugins != e.plugins && !n.doc.eq(e.doc) ? "reset" : e.scrollToSelection > n.scrollToSelection ? "to selection" : "preserve", l = r || !this.docView.matchesNode(e.doc, s, o);
3162
- (l || !e.selection.eq(n.selection)) && (i = !0);
3163
- let u = c == "preserve" && i && this.dom.style.overflowAnchor == null && ye(this);
3164
- if (i) {
3165
- this.domObserver.stop();
3166
- let t = l && (E || k) && !this.composing && !n.selection.empty && !e.selection.empty && Fr(n.selection, e.selection);
3167
- if (l) {
3168
- let n = k ? this.trackWrites = this.domSelectionRange().focusNode : null;
3169
- this.composing && (this.input.compositionNode = Ln(this)), (r || !this.docView.update(e.doc, s, o, this)) && (this.docView.updateOuterDeco(s), this.docView.destroy(), this.docView = Xe(e.doc, s, o, this.dom, this)), !n || this.trackWrites && this.dom.contains(this.trackWrites) || (t = !0);
3170
- }
3171
- let i = this.input.mouseDown;
3172
- t || !(i && this.domObserver.currentSelection.eq(this.domSelectionRange()) && Ot(this) && i.delaySelUpdate()) ? V(this, t) : (Ct(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start();
3173
- }
3174
- this.updatePluginViews(n), this.dragging?.node && !n.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, n), c == "reset" ? this.dom.scrollTop = 0 : c == "to selection" ? this.scrollToSelection() : u && xe(u);
3175
- }
3176
- scrollToSelection() {
3177
- let e = this.domSelectionRange().focusNode;
3178
- if (e && x(this.dom, e) && !this.someProp("handleScrollToSelection", (e) => e(this))) {
3179
- if (this.state.selection instanceof t) {
3180
- let t = this.docView.domAfterPos(this.state.selection.from);
3181
- y(t) && ve(this, t.getBoundingClientRect(), e);
3182
- } else ve(this, this.coordsAtPos(this.state.selection.head, 1), e);
3183
- }
3184
- }
3185
- destroyPluginViews() {
3186
- let e;
3187
- for (; e = this.pluginViews.pop();) e.destroy && e.destroy();
3188
- }
3189
- updatePluginViews(e) {
3190
- if (!e || e.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) {
3191
- this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews();
3192
- for (let e = 0; e < this.directPlugins.length; e++) {
3193
- let t = this.directPlugins[e];
3194
- t.spec.view && this.pluginViews.push(t.spec.view(this));
3195
- }
3196
- for (let e = 0; e < this.state.plugins.length; e++) {
3197
- let t = this.state.plugins[e];
3198
- t.spec.view && this.pluginViews.push(t.spec.view(this));
3199
- }
3200
- } else for (let t = 0; t < this.pluginViews.length; t++) {
3201
- let n = this.pluginViews[t];
3202
- n.update && n.update(this, e);
3203
- }
3204
- }
3205
- updateDraggedNode(e, n) {
3206
- let r = e.node, i = -1;
3207
- if (r.from < this.state.doc.content.size && this.state.doc.nodeAt(r.from) == r.node) i = r.from;
3208
- else {
3209
- let e = r.from + (this.state.doc.content.size - n.doc.content.size);
3210
- (e > 0 && e < this.state.doc.content.size && this.state.doc.nodeAt(e)) == r.node && (i = e);
3211
- }
3212
- this.dragging = new Gn(e.slice, e.move, i < 0 ? void 0 : t.create(this.state.doc, i));
3213
- }
3214
- someProp(e, t) {
3215
- let n = this._props && this._props[e], r;
3216
- if (n != null && (r = t ? t(n) : n)) return r;
3217
- for (let n = 0; n < this.directPlugins.length; n++) {
3218
- let i = this.directPlugins[n].props[e];
3219
- if (i != null && (r = t ? t(i) : i)) return r;
3220
- }
3221
- let i = this.state.plugins;
3222
- if (i) for (let n = 0; n < i.length; n++) {
3223
- let a = i[n].props[e];
3224
- if (a != null && (r = t ? t(a) : a)) return r;
3225
- }
3226
- }
3227
- hasFocus() {
3228
- if (E) {
3229
- let e = this.root.activeElement;
3230
- if (e == this.dom) return !0;
3231
- if (!e || !this.dom.contains(e)) return !1;
3232
- for (; e && this.dom != e && this.dom.contains(e);) {
3233
- if (e.contentEditable == "false") return !1;
3234
- e = e.parentElement;
3235
- }
3236
- return !0;
3237
- }
3238
- return this.root.activeElement == this.dom;
3239
- }
3240
- focus() {
3241
- this.domObserver.stop(), this.editable && Ce(this.dom), V(this), this.domObserver.start();
3242
- }
3243
- get root() {
3244
- let e = this._root;
3245
- if (e == null) {
3246
- for (let e = this.dom.parentNode; e; e = e.parentNode) if (e.nodeType == 9 || e.nodeType == 11 && e.host) return e.getSelection || (Object.getPrototypeOf(e).getSelection = () => e.ownerDocument.getSelection()), this._root = e;
3247
- }
3248
- return e || document;
3249
- }
3250
- updateRoot() {
3251
- this._root = null;
3252
- }
3253
- posAtCoords(e) {
3254
- return je(this, e);
3255
- }
3256
- coordsAtPos(e, t = 1) {
3257
- return Pe(this, e, t);
3258
- }
3259
- domAtPos(e, t = 0) {
3260
- return this.docView.domFromPos(e, t);
3261
- }
3262
- nodeDOM(e) {
3263
- let t = this.docView.descAt(e);
3264
- return t ? t.nodeDOM : null;
3265
- }
3266
- posAtDOM(e, t, n = -1) {
3267
- let r = this.docView.posFromDOM(e, t, n);
3268
- if (r == null) throw RangeError("DOM position not inside the editor");
3269
- return r;
3270
- }
3271
- endOfTextblock(e, t) {
3272
- return We(this, t || this.state, e);
3273
- }
3274
- pasteHTML(e, t) {
3275
- return Un(this, "", e, !1, t || new ClipboardEvent("paste"));
3276
- }
3277
- pasteText(e, t) {
3278
- return Un(this, e, null, !0, t || new ClipboardEvent("paste"));
3279
- }
3280
- serializeForClipboard(e) {
3281
- return Gt(this, e);
3282
- }
3283
- destroy() {
3284
- this.docView && (dn(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], lr(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null, m());
3285
- }
3286
- get isDestroyed() {
3287
- return this.docView == null;
3288
- }
3289
- dispatchEvent(e) {
3290
- return hn(this, e);
3291
- }
3292
- domSelectionRange() {
3293
- let e = this.dom.isConnected !== !1 && this.domSelection();
3294
- return e ? A && this.root.nodeType === 11 && ie(this.dom.ownerDocument) == this.dom && vr(this, e) || e : {
3295
- focusNode: null,
3296
- focusOffset: 0,
3297
- anchorNode: null,
3298
- anchorOffset: 0
3299
- };
3300
- }
3301
- domSelection() {
3302
- return this.root.getSelection();
3303
- }
3304
- };
3305
- jr.prototype.dispatch = function(e) {
3306
- let t = this._props.dispatchTransaction;
3307
- t ? t.call(this, e) : this.updateState(this.state.apply(e));
3308
- };
3309
- function Mr(e) {
3310
- let t = Object.create(null);
3311
- return t.class = "ProseMirror", t.contenteditable = String(e.editable), e.someProp("attributes", (n) => {
3312
- if (typeof n == "function" && (n = n(e.state)), n) for (let e in n) e == "class" ? t.class += " " + n[e] : e == "style" ? t.style = (t.style ? t.style + ";" : "") + n[e] : !t[e] && e != "contenteditable" && e != "nodeName" && (t[e] = String(n[e]));
3313
- }), t.translate ||= "no", [J.node(0, e.state.doc.content.size, t)];
3314
- }
3315
- function Nr(e) {
3316
- if (e.markCursor) {
3317
- let t = document.createElement("img");
3318
- t.className = "ProseMirror-separator", t.setAttribute("mark-placeholder", "true"), t.setAttribute("alt", ""), e.cursorWrapper = {
3319
- dom: t,
3320
- deco: J.widget(e.state.selection.from, t, {
3321
- raw: !0,
3322
- marks: e.markCursor
3323
- })
3324
- };
3325
- } else e.cursorWrapper = null;
3326
- }
3327
- function Pr(e) {
3328
- return !e.someProp("editable", (t) => t(e.state) === !1);
3329
- }
3330
- function Fr(e, t) {
3331
- let n = Math.min(e.$anchor.sharedDepth(e.head), t.$anchor.sharedDepth(t.head));
3332
- return e.$anchor.start(n) != t.$anchor.start(n);
3333
- }
3334
- function Ir(e) {
3335
- let t = Object.create(null);
3336
- function n(e) {
3337
- for (let n in e) Object.prototype.hasOwnProperty.call(t, n) || (t[n] = e[n]);
3338
- }
3339
- return e.someProp("nodeViews", n), e.someProp("markViews", n), t;
3340
- }
3341
- function Lr(e, t) {
3342
- let n = 0, r = 0;
3343
- for (let r in e) {
3344
- if (e[r] != t[r]) return !0;
3345
- n++;
3346
- }
3347
- for (let e in t) r++;
3348
- return n != r;
3349
- }
3350
- function Rr(e) {
3351
- if (e.spec.state || e.spec.filterTransaction || e.spec.appendTransaction) throw RangeError("Plugins passed directly to the view must not have a state component");
3352
- }
3353
- export { J as Decoration, Z as DecorationSet, jr as EditorView };
3354
-
3355
- //# sourceMappingURL=index.js.map