dsh-spec-collab 0.3.0 → 0.4.0

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.
package/lib/client.js CHANGED
@@ -987,7 +987,7 @@ window.__ModuleLoader__.load({
987
987
  return htmlDecoder(str, DecodingMode.Strict);
988
988
  }
989
989
  //#endregion
990
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/utils.mjs
990
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/utils.mjs
991
991
  var utils_exports = /* @__PURE__ */ __exportAll({
992
992
  arrayReplaceAt: () => arrayReplaceAt,
993
993
  asciiTrim: () => asciiTrim,
@@ -1183,7 +1183,7 @@ window.__ModuleLoader__.load({
1183
1183
  ucmicro: uc_micro_exports
1184
1184
  };
1185
1185
  //#endregion
1186
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/parse_link_label.mjs
1186
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/parse_link_label.mjs
1187
1187
  function parseLinkLabel(state, start, disableNested) {
1188
1188
  let level, found, marker, prevPos;
1189
1189
  const max = state.posMax;
@@ -1215,7 +1215,7 @@ window.__ModuleLoader__.load({
1215
1215
  return labelEnd;
1216
1216
  }
1217
1217
  //#endregion
1218
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs
1218
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs
1219
1219
  function parseLinkDestination(str, start, max) {
1220
1220
  let code;
1221
1221
  let pos = start;
@@ -1250,7 +1250,10 @@ window.__ModuleLoader__.load({
1250
1250
  if (code === 32) break;
1251
1251
  if (code < 32 || code === 127) break;
1252
1252
  if (code === 92 && pos + 1 < max) {
1253
- if (str.charCodeAt(pos + 1) === 32) break;
1253
+ if (str.charCodeAt(pos + 1) === 32) {
1254
+ pos++;
1255
+ continue;
1256
+ }
1254
1257
  pos += 2;
1255
1258
  continue;
1256
1259
  }
@@ -1272,7 +1275,7 @@ window.__ModuleLoader__.load({
1272
1275
  return result;
1273
1276
  }
1274
1277
  //#endregion
1275
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/parse_link_title.mjs
1278
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/parse_link_title.mjs
1276
1279
  function parseLinkTitle(str, start, max, prev_state) {
1277
1280
  let code;
1278
1281
  let pos = start;
@@ -1311,14 +1314,14 @@ window.__ModuleLoader__.load({
1311
1314
  return state;
1312
1315
  }
1313
1316
  //#endregion
1314
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/helpers/index.mjs
1317
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/helpers/index.mjs
1315
1318
  var helpers_exports = /* @__PURE__ */ __exportAll({
1316
1319
  parseLinkDestination: () => parseLinkDestination,
1317
1320
  parseLinkLabel: () => parseLinkLabel,
1318
1321
  parseLinkTitle: () => parseLinkTitle
1319
1322
  });
1320
1323
  //#endregion
1321
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/renderer.mjs
1324
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/renderer.mjs
1322
1325
  /**
1323
1326
  * class Renderer
1324
1327
  *
@@ -1531,7 +1534,7 @@ window.__ModuleLoader__.load({
1531
1534
  return result;
1532
1535
  };
1533
1536
  //#endregion
1534
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/ruler.mjs
1537
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/ruler.mjs
1535
1538
  /**
1536
1539
  * class Ruler
1537
1540
  *
@@ -1802,7 +1805,7 @@ window.__ModuleLoader__.load({
1802
1805
  return this.__cache__[chainName] || [];
1803
1806
  };
1804
1807
  //#endregion
1805
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/token.mjs
1808
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/token.mjs
1806
1809
  /**
1807
1810
  * class Token
1808
1811
  **/
@@ -1956,7 +1959,7 @@ window.__ModuleLoader__.load({
1956
1959
  else this.attrs[idx][1] = this.attrs[idx][1] + " " + value;
1957
1960
  };
1958
1961
  //#endregion
1959
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/state_core.mjs
1962
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/state_core.mjs
1960
1963
  function StateCore(src, md, env) {
1961
1964
  this.src = src;
1962
1965
  this.env = env;
@@ -1966,7 +1969,7 @@ window.__ModuleLoader__.load({
1966
1969
  }
1967
1970
  StateCore.prototype.Token = Token;
1968
1971
  //#endregion
1969
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/normalize.mjs
1972
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/normalize.mjs
1970
1973
  const NEWLINES_RE = /\r\n?|\n/g;
1971
1974
  const NULL_RE = /\0/g;
1972
1975
  function normalize$1(state) {
@@ -1976,7 +1979,7 @@ window.__ModuleLoader__.load({
1976
1979
  state.src = str;
1977
1980
  }
1978
1981
  //#endregion
1979
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/block.mjs
1982
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/block.mjs
1980
1983
  function block(state) {
1981
1984
  let token;
1982
1985
  if (state.inlineMode) {
@@ -1988,7 +1991,7 @@ window.__ModuleLoader__.load({
1988
1991
  } else state.md.block.parse(state.src, state.md, state.env, state.tokens);
1989
1992
  }
1990
1993
  //#endregion
1991
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/inline.mjs
1994
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/inline.mjs
1992
1995
  function inline(state) {
1993
1996
  const tokens = state.tokens;
1994
1997
  for (let i = 0, l = tokens.length; i < l; i++) {
@@ -1997,7 +2000,7 @@ window.__ModuleLoader__.load({
1997
2000
  }
1998
2001
  }
1999
2002
  //#endregion
2000
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/linkify.mjs
2003
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/linkify.mjs
2001
2004
  function isLinkOpen$1(str) {
2002
2005
  return /^<a[>\s]/i.test(str);
2003
2006
  }
@@ -2009,7 +2012,8 @@ window.__ModuleLoader__.load({
2009
2012
  if (!state.md.options.linkify) return;
2010
2013
  for (let j = 0, l = blockTokens.length; j < l; j++) {
2011
2014
  if (blockTokens[j].type !== "inline" || !state.md.linkify.pretest(blockTokens[j].content)) continue;
2012
- let tokens = blockTokens[j].children;
2015
+ const tokens = blockTokens[j].children;
2016
+ const replacements = [];
2013
2017
  let htmlLinkLevel = 0;
2014
2018
  for (let i = tokens.length - 1; i >= 0; i--) {
2015
2019
  const currentToken = tokens[i];
@@ -2068,13 +2072,32 @@ window.__ModuleLoader__.load({
2068
2072
  token.level = level;
2069
2073
  nodes.push(token);
2070
2074
  }
2071
- blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
2075
+ replacements.push({
2076
+ index: i,
2077
+ nodes
2078
+ });
2072
2079
  }
2073
2080
  }
2081
+ if (replacements.length > 0) {
2082
+ let newTokensLength = tokens.length;
2083
+ for (const replacement of replacements) newTokensLength += replacement.nodes.length - 1;
2084
+ const newTokens = new Array(newTokensLength);
2085
+ let replacementIndex = 0;
2086
+ let newTokenIndex = 0;
2087
+ replacements.reverse();
2088
+ for (let i = 0; i < tokens.length; i++) {
2089
+ const replacement = replacements[replacementIndex];
2090
+ if (replacement?.index === i) {
2091
+ for (const node of replacement.nodes) newTokens[newTokenIndex++] = node;
2092
+ replacementIndex++;
2093
+ } else newTokens[newTokenIndex++] = tokens[i];
2094
+ }
2095
+ blockTokens[j].children = newTokens;
2096
+ }
2074
2097
  }
2075
2098
  }
2076
2099
  //#endregion
2077
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/replacements.mjs
2100
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/replacements.mjs
2078
2101
  const RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
2079
2102
  const SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
2080
2103
  const SCOPED_ABBR_RE = /\((c|tm|r)\)/gi;
@@ -2116,10 +2139,18 @@ window.__ModuleLoader__.load({
2116
2139
  }
2117
2140
  }
2118
2141
  //#endregion
2119
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/smartquotes.mjs
2142
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/smartquotes.mjs
2120
2143
  const QUOTE_TEST_RE = /['"]/;
2121
2144
  const QUOTE_RE = /['"]/g;
2122
2145
  const APOSTROPHE = "’";
2146
+ const MAX_OPENERS = 1e3;
2147
+ function truncateStack(stack, heads, length) {
2148
+ while (stack.length > length) {
2149
+ const item = stack.pop();
2150
+ if (item.isSingleQuote) heads.single = item.prevSameQuoteIdx;
2151
+ else heads.double = item.prevSameQuoteIdx;
2152
+ }
2153
+ }
2123
2154
  function addReplacement(replacements, tokenIdx, pos, ch) {
2124
2155
  if (!replacements[tokenIdx]) replacements[tokenIdx] = [];
2125
2156
  replacements[tokenIdx].push({
@@ -2141,12 +2172,16 @@ window.__ModuleLoader__.load({
2141
2172
  function process_inlines(tokens, state) {
2142
2173
  let j;
2143
2174
  const stack = [];
2175
+ const heads = {
2176
+ single: -1,
2177
+ double: -1
2178
+ };
2144
2179
  const replacements = {};
2145
2180
  for (let i = 0; i < tokens.length; i++) {
2146
2181
  const token = tokens[i];
2147
2182
  const thisLevel = tokens[i].level;
2148
2183
  for (j = stack.length - 1; j >= 0; j--) if (stack[j].level <= thisLevel) break;
2149
- stack.length = j + 1;
2184
+ truncateStack(stack, heads, j + 1);
2150
2185
  if (token.type !== "text") continue;
2151
2186
  const text = token.content;
2152
2187
  let pos = 0;
@@ -2198,11 +2233,10 @@ window.__ModuleLoader__.load({
2198
2233
  if (isSingle) addReplacement(replacements, i, t.index, APOSTROPHE);
2199
2234
  continue;
2200
2235
  }
2201
- if (canClose) for (j = stack.length - 1; j >= 0; j--) {
2202
- let item = stack[j];
2203
- if (stack[j].level < thisLevel) break;
2204
- if (item.single === isSingle && stack[j].level === thisLevel) {
2205
- item = stack[j];
2236
+ if (canClose) {
2237
+ j = isSingle ? heads.single : heads.double;
2238
+ if (j >= 0 && stack[j].level === thisLevel) {
2239
+ const item = stack[j];
2206
2240
  let openQuote;
2207
2241
  let closeQuote;
2208
2242
  if (isSingle) {
@@ -2213,18 +2247,23 @@ window.__ModuleLoader__.load({
2213
2247
  closeQuote = state.md.options.quotes[1];
2214
2248
  }
2215
2249
  addReplacement(replacements, i, t.index, closeQuote);
2216
- addReplacement(replacements, item.token, item.pos, openQuote);
2217
- stack.length = j;
2250
+ addReplacement(replacements, item.tokenIdx, item.contentPos, openQuote);
2251
+ truncateStack(stack, heads, j);
2218
2252
  continue OUTER;
2219
2253
  }
2220
2254
  }
2221
- if (canOpen) stack.push({
2222
- token: i,
2223
- pos: t.index,
2224
- single: isSingle,
2225
- level: thisLevel
2226
- });
2227
- else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE);
2255
+ if (canOpen) {
2256
+ if (stack.length >= MAX_OPENERS) return;
2257
+ stack.push({
2258
+ tokenIdx: i,
2259
+ contentPos: t.index,
2260
+ isSingleQuote: isSingle,
2261
+ level: thisLevel,
2262
+ prevSameQuoteIdx: isSingle ? heads.single : heads.double
2263
+ });
2264
+ if (isSingle) heads.single = stack.length - 1;
2265
+ else heads.double = stack.length - 1;
2266
+ } else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE);
2228
2267
  }
2229
2268
  }
2230
2269
  Object.keys(replacements).forEach(function(tokenIdx) {
@@ -2239,7 +2278,7 @@ window.__ModuleLoader__.load({
2239
2278
  }
2240
2279
  }
2241
2280
  //#endregion
2242
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_core/text_join.mjs
2281
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_core/text_join.mjs
2243
2282
  function text_join(state) {
2244
2283
  let curr, last;
2245
2284
  const blockTokens = state.tokens;
@@ -2258,7 +2297,7 @@ window.__ModuleLoader__.load({
2258
2297
  }
2259
2298
  }
2260
2299
  //#endregion
2261
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/parser_core.mjs
2300
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/parser_core.mjs
2262
2301
  /** internal
2263
2302
  * class Core
2264
2303
  *
@@ -2297,7 +2336,7 @@ window.__ModuleLoader__.load({
2297
2336
  };
2298
2337
  Core.prototype.State = StateCore;
2299
2338
  //#endregion
2300
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/state_block.mjs
2339
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/state_block.mjs
2301
2340
  function StateBlock(src, md, env, tokens) {
2302
2341
  this.src = src;
2303
2342
  this.md = md;
@@ -2404,7 +2443,7 @@ window.__ModuleLoader__.load({
2404
2443
  };
2405
2444
  StateBlock.prototype.Token = Token;
2406
2445
  //#endregion
2407
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/table.mjs
2446
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/table.mjs
2408
2447
  const MAX_AUTOCOMPLETED_CELLS = 65536;
2409
2448
  function getLine(state, line) {
2410
2449
  const pos = state.bMarks[line] + state.tShift[line];
@@ -2539,7 +2578,7 @@ window.__ModuleLoader__.load({
2539
2578
  return true;
2540
2579
  }
2541
2580
  //#endregion
2542
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/code.mjs
2581
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/code.mjs
2543
2582
  function code$2(state, startLine, endLine) {
2544
2583
  if (state.sCount[startLine] - state.blkIndent < 4) return false;
2545
2584
  let nextLine = startLine + 1;
@@ -2563,7 +2602,7 @@ window.__ModuleLoader__.load({
2563
2602
  return true;
2564
2603
  }
2565
2604
  //#endregion
2566
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/fence.mjs
2605
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/fence.mjs
2567
2606
  function fence(state, startLine, endLine, silent) {
2568
2607
  let pos = state.bMarks[startLine] + state.tShift[startLine];
2569
2608
  let max = state.eMarks[startLine];
@@ -2608,7 +2647,7 @@ window.__ModuleLoader__.load({
2608
2647
  return true;
2609
2648
  }
2610
2649
  //#endregion
2611
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/blockquote.mjs
2650
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/blockquote.mjs
2612
2651
  function blockquote(state, startLine, endLine, silent) {
2613
2652
  let pos = state.bMarks[startLine] + state.tShift[startLine];
2614
2653
  let max = state.eMarks[startLine];
@@ -2711,7 +2750,7 @@ window.__ModuleLoader__.load({
2711
2750
  return true;
2712
2751
  }
2713
2752
  //#endregion
2714
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/hr.mjs
2753
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/hr.mjs
2715
2754
  function hr(state, startLine, endLine, silent) {
2716
2755
  const max = state.eMarks[startLine];
2717
2756
  if (state.sCount[startLine] - state.blkIndent >= 4) return false;
@@ -2733,7 +2772,7 @@ window.__ModuleLoader__.load({
2733
2772
  return true;
2734
2773
  }
2735
2774
  //#endregion
2736
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/list.mjs
2775
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/list.mjs
2737
2776
  function skipBulletListMarker(state, startLine) {
2738
2777
  const max = state.eMarks[startLine];
2739
2778
  let pos = state.bMarks[startLine] + state.tShift[startLine];
@@ -2886,130 +2925,142 @@ window.__ModuleLoader__.load({
2886
2925
  return true;
2887
2926
  }
2888
2927
  //#endregion
2889
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/reference.mjs
2928
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/reference.mjs
2929
+ const MAX_LABEL_LENGTH = 999;
2930
+ function countCodePoints(str) {
2931
+ let length = str.length;
2932
+ for (let i = 0; i < str.length - 1; i++) {
2933
+ const high = str.charCodeAt(i);
2934
+ if (high < 55296 || high > 56319) continue;
2935
+ const low = str.charCodeAt(i + 1);
2936
+ if (low >= 56320 && low <= 57343) {
2937
+ length--;
2938
+ i++;
2939
+ }
2940
+ }
2941
+ return length;
2942
+ }
2943
+ function lineEnd(state, line) {
2944
+ return Math.min(state.eMarks[line] + 1, state.src.length);
2945
+ }
2946
+ function getNextLinePos(state, nextLine) {
2947
+ const endLine = state.lineMax;
2948
+ if (nextLine >= endLine || state.isEmpty(nextLine)) return -1;
2949
+ let isContinuation = false;
2950
+ if (state.sCount[nextLine] - state.blkIndent > 3) isContinuation = true;
2951
+ if (state.sCount[nextLine] < 0) isContinuation = true;
2952
+ if (!isContinuation) {
2953
+ const terminatorRules = state.md.block.ruler.getRules("reference");
2954
+ const oldParentType = state.parentType;
2955
+ state.parentType = "reference";
2956
+ let terminate = false;
2957
+ for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) {
2958
+ terminate = true;
2959
+ break;
2960
+ }
2961
+ state.parentType = oldParentType;
2962
+ if (terminate) return -1;
2963
+ }
2964
+ return state.bMarks[nextLine] + state.tShift[nextLine];
2965
+ }
2890
2966
  function reference(state, startLine, _endLine, silent) {
2967
+ const src = state.src;
2891
2968
  let pos = state.bMarks[startLine] + state.tShift[startLine];
2892
- let max = state.eMarks[startLine];
2893
2969
  let nextLine = startLine + 1;
2894
2970
  if (state.sCount[startLine] - state.blkIndent >= 4) return false;
2895
- if (state.src.charCodeAt(pos) !== 91) return false;
2896
- function getNextLine(nextLine) {
2897
- const endLine = state.lineMax;
2898
- if (nextLine >= endLine || state.isEmpty(nextLine)) return null;
2899
- let isContinuation = false;
2900
- if (state.sCount[nextLine] - state.blkIndent > 3) isContinuation = true;
2901
- if (state.sCount[nextLine] < 0) isContinuation = true;
2902
- if (!isContinuation) {
2903
- const terminatorRules = state.md.block.ruler.getRules("reference");
2904
- const oldParentType = state.parentType;
2905
- state.parentType = "reference";
2906
- let terminate = false;
2907
- for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) {
2908
- terminate = true;
2909
- break;
2910
- }
2911
- state.parentType = oldParentType;
2912
- if (terminate) return null;
2913
- }
2914
- const pos = state.bMarks[nextLine] + state.tShift[nextLine];
2915
- const max = state.eMarks[nextLine];
2916
- return state.src.slice(pos, max + 1);
2917
- }
2918
- let str = state.src.slice(pos, max + 1);
2919
- max = str.length;
2971
+ if (src.charCodeAt(pos) !== 91) return false;
2972
+ let max = lineEnd(state, startLine);
2973
+ let rawLabel = "";
2920
2974
  let labelEnd = -1;
2921
- for (pos = 1; pos < max; pos++) {
2922
- const ch = str.charCodeAt(pos);
2975
+ let segmentStart = ++pos;
2976
+ while (pos < max) {
2977
+ if (rawLabel.length + pos - segmentStart > MAX_LABEL_LENGTH * 2) return false;
2978
+ let ch = src.charCodeAt(pos);
2923
2979
  if (ch === 91) return false;
2924
- else if (ch === 93) {
2980
+ if (ch === 93) {
2925
2981
  labelEnd = pos;
2926
2982
  break;
2927
- } else if (ch === 10) {
2928
- const lineContent = getNextLine(nextLine);
2929
- if (lineContent !== null) {
2930
- str += lineContent;
2931
- max = str.length;
2932
- nextLine++;
2933
- }
2934
- } else if (ch === 92) {
2935
- pos++;
2936
- if (pos < max && str.charCodeAt(pos) === 10) {
2937
- const lineContent = getNextLine(nextLine);
2938
- if (lineContent !== null) {
2939
- str += lineContent;
2940
- max = str.length;
2941
- nextLine++;
2942
- }
2943
- }
2944
2983
  }
2984
+ if (ch === 92) ch = src.charCodeAt(++pos);
2985
+ if (ch === 10 && pos < max) {
2986
+ const nextPos = getNextLinePos(state, nextLine);
2987
+ if (nextPos < 0) return false;
2988
+ rawLabel += src.slice(segmentStart, max);
2989
+ pos = segmentStart = nextPos;
2990
+ max = lineEnd(state, nextLine++);
2991
+ continue;
2992
+ }
2993
+ pos++;
2945
2994
  }
2946
- if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58) return false;
2947
- for (pos = labelEnd + 2; pos < max; pos++) {
2948
- const ch = str.charCodeAt(pos);
2995
+ if (labelEnd < 0 || src.charCodeAt(labelEnd + 1) !== 58) return false;
2996
+ rawLabel += src.slice(segmentStart, labelEnd);
2997
+ if (rawLabel.length > MAX_LABEL_LENGTH && countCodePoints(rawLabel) > MAX_LABEL_LENGTH) return false;
2998
+ pos = labelEnd + 2;
2999
+ while (pos < max) {
3000
+ const ch = src.charCodeAt(pos);
2949
3001
  if (ch === 10) {
2950
- const lineContent = getNextLine(nextLine);
2951
- if (lineContent !== null) {
2952
- str += lineContent;
2953
- max = str.length;
2954
- nextLine++;
2955
- }
2956
- } else if (isSpace(ch)) {} else break;
2957
- }
2958
- const destRes = state.md.helpers.parseLinkDestination(str, pos, max);
3002
+ const nextPos = getNextLinePos(state, nextLine);
3003
+ if (nextPos < 0) break;
3004
+ pos = nextPos;
3005
+ max = lineEnd(state, nextLine++);
3006
+ } else if (isSpace(ch)) pos++;
3007
+ else break;
3008
+ }
3009
+ const destRes = state.md.helpers.parseLinkDestination(src, pos, max);
2959
3010
  if (!destRes.ok) return false;
2960
3011
  const href = state.md.normalizeLink(destRes.str);
2961
3012
  if (!state.md.validateLink(href)) return false;
2962
3013
  pos = destRes.pos;
2963
3014
  const destEndPos = pos;
3015
+ const destEndMax = max;
2964
3016
  const destEndLineNo = nextLine;
2965
- const start = pos;
2966
- for (; pos < max; pos++) {
2967
- const ch = str.charCodeAt(pos);
3017
+ while (pos < max) {
3018
+ const ch = src.charCodeAt(pos);
2968
3019
  if (ch === 10) {
2969
- const lineContent = getNextLine(nextLine);
2970
- if (lineContent !== null) {
2971
- str += lineContent;
2972
- max = str.length;
2973
- nextLine++;
2974
- }
2975
- } else if (isSpace(ch)) {} else break;
2976
- }
2977
- let titleRes = state.md.helpers.parseLinkTitle(str, pos, max);
3020
+ const nextPos = getNextLinePos(state, nextLine);
3021
+ if (nextPos < 0) break;
3022
+ pos = nextPos;
3023
+ max = lineEnd(state, nextLine++);
3024
+ } else if (isSpace(ch)) pos++;
3025
+ else break;
3026
+ }
3027
+ const titleStart = pos;
3028
+ let titleRes = state.md.helpers.parseLinkTitle(src, pos, max);
2978
3029
  while (titleRes.can_continue) {
2979
- const lineContent = getNextLine(nextLine);
2980
- if (lineContent === null) break;
2981
- str += lineContent;
2982
- pos = max;
2983
- max = str.length;
2984
- nextLine++;
2985
- titleRes = state.md.helpers.parseLinkTitle(str, pos, max, titleRes);
3030
+ const nextPos = getNextLinePos(state, nextLine);
3031
+ if (nextPos < 0) break;
3032
+ pos = nextPos;
3033
+ max = lineEnd(state, nextLine++);
3034
+ titleRes = state.md.helpers.parseLinkTitle(src, pos, max, titleRes);
2986
3035
  }
2987
3036
  let title;
2988
- if (pos < max && start !== pos && titleRes.ok) {
3037
+ if (titleStart !== destEndPos && titleRes.ok) {
2989
3038
  title = titleRes.str;
2990
3039
  pos = titleRes.pos;
2991
3040
  } else {
2992
3041
  title = "";
2993
3042
  pos = destEndPos;
3043
+ max = destEndMax;
2994
3044
  nextLine = destEndLineNo;
2995
3045
  }
2996
3046
  while (pos < max) {
2997
- if (!isSpace(str.charCodeAt(pos))) break;
3047
+ if (!isSpace(src.charCodeAt(pos))) break;
2998
3048
  pos++;
2999
3049
  }
3000
- if (pos < max && str.charCodeAt(pos) !== 10) {
3050
+ if (pos < max && src.charCodeAt(pos) !== 10) {
3001
3051
  if (title) {
3002
3052
  title = "";
3003
3053
  pos = destEndPos;
3054
+ max = destEndMax;
3004
3055
  nextLine = destEndLineNo;
3005
3056
  while (pos < max) {
3006
- if (!isSpace(str.charCodeAt(pos))) break;
3057
+ if (!isSpace(src.charCodeAt(pos))) break;
3007
3058
  pos++;
3008
3059
  }
3009
3060
  }
3010
3061
  }
3011
- if (pos < max && str.charCodeAt(pos) !== 10) return false;
3012
- const label = normalizeReference$1(str.slice(1, labelEnd));
3062
+ if (pos < max && src.charCodeAt(pos) !== 10) return false;
3063
+ const label = normalizeReference$1(rawLabel);
3013
3064
  if (!label) return false;
3014
3065
  /* istanbul ignore if */
3015
3066
  if (silent) return true;
@@ -3022,7 +3073,7 @@ window.__ModuleLoader__.load({
3022
3073
  return true;
3023
3074
  }
3024
3075
  //#endregion
3025
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/html_blocks.mjs
3076
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/html_blocks.mjs
3026
3077
  var html_blocks_default = [
3027
3078
  "address",
3028
3079
  "article",
@@ -3088,11 +3139,10 @@ window.__ModuleLoader__.load({
3088
3139
  "ul"
3089
3140
  ];
3090
3141
  //#endregion
3091
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/common/html_re.mjs
3092
- const HTML_TAG_RE = /* @__PURE__ */ new RegExp("^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)");
3142
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/common/html_re.mjs
3093
3143
  const HTML_OPEN_CLOSE_TAG_RE = /* @__PURE__ */ new RegExp("^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>)");
3094
3144
  //#endregion
3095
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/html_block.mjs
3145
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/html_block.mjs
3096
3146
  const HTML_SEQUENCES = [
3097
3147
  [
3098
3148
  /^<(script|pre|style|textarea)(?=(\s|>|$))/i,
@@ -3110,7 +3160,7 @@ window.__ModuleLoader__.load({
3110
3160
  true
3111
3161
  ],
3112
3162
  [
3113
- /^<![A-Z]/,
3163
+ /^<![A-Za-z]/,
3114
3164
  />/,
3115
3165
  true
3116
3166
  ],
@@ -3162,7 +3212,7 @@ window.__ModuleLoader__.load({
3162
3212
  return true;
3163
3213
  }
3164
3214
  //#endregion
3165
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/heading.mjs
3215
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/heading.mjs
3166
3216
  function heading(state, startLine, endLine, silent) {
3167
3217
  let pos = state.bMarks[startLine] + state.tShift[startLine];
3168
3218
  let max = state.eMarks[startLine];
@@ -3193,7 +3243,7 @@ window.__ModuleLoader__.load({
3193
3243
  return true;
3194
3244
  }
3195
3245
  //#endregion
3196
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/lheading.mjs
3246
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/lheading.mjs
3197
3247
  function lheading(state, startLine, endLine) {
3198
3248
  const terminatorRules = state.md.block.ruler.getRules("paragraph");
3199
3249
  if (state.sCount[startLine] - state.blkIndent >= 4) return false;
@@ -3246,7 +3296,7 @@ window.__ModuleLoader__.load({
3246
3296
  return true;
3247
3297
  }
3248
3298
  //#endregion
3249
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_block/paragraph.mjs
3299
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_block/paragraph.mjs
3250
3300
  function paragraph(state, startLine, endLine) {
3251
3301
  const terminatorRules = state.md.block.ruler.getRules("paragraph");
3252
3302
  const oldParentType = state.parentType;
@@ -3275,7 +3325,7 @@ window.__ModuleLoader__.load({
3275
3325
  return true;
3276
3326
  }
3277
3327
  //#endregion
3278
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/parser_block.mjs
3328
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/parser_block.mjs
3279
3329
  /** internal
3280
3330
  * class ParserBlock
3281
3331
  *
@@ -3407,7 +3457,7 @@ window.__ModuleLoader__.load({
3407
3457
  };
3408
3458
  ParserBlock.prototype.State = StateBlock;
3409
3459
  //#endregion
3410
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/state_inline.mjs
3460
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/state_inline.mjs
3411
3461
  function StateInline(src, md, env, outTokens) {
3412
3462
  this.src = src;
3413
3463
  this.env = env;
@@ -3424,6 +3474,7 @@ window.__ModuleLoader__.load({
3424
3474
  this._prev_delimiters = [];
3425
3475
  this.backticks = {};
3426
3476
  this.backticksScanned = false;
3477
+ this.skipHtmlSpecial = false;
3427
3478
  this.linkLevel = 0;
3428
3479
  }
3429
3480
  StateInline.prototype.pushPending = function() {
@@ -3491,7 +3542,7 @@ window.__ModuleLoader__.load({
3491
3542
  };
3492
3543
  StateInline.prototype.Token = Token;
3493
3544
  //#endregion
3494
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/text.mjs
3545
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/text.mjs
3495
3546
  function isTerminatorChar(ch) {
3496
3547
  switch (ch) {
3497
3548
  case 10:
@@ -3529,8 +3580,13 @@ window.__ModuleLoader__.load({
3529
3580
  return true;
3530
3581
  }
3531
3582
  //#endregion
3532
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/linkify.mjs
3533
- const SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;
3583
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/linkify.mjs
3584
+ function isAsciiAlpha(code) {
3585
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122;
3586
+ }
3587
+ function isSchemeChar(code) {
3588
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 45 || code === 46;
3589
+ }
3534
3590
  function linkify(state, silent) {
3535
3591
  if (!state.md.options.linkify) return false;
3536
3592
  if (state.linkLevel > 0) return false;
@@ -3540,20 +3596,22 @@ window.__ModuleLoader__.load({
3540
3596
  if (state.src.charCodeAt(pos) !== 58) return false;
3541
3597
  if (state.src.charCodeAt(pos + 1) !== 47) return false;
3542
3598
  if (state.src.charCodeAt(pos + 2) !== 47) return false;
3543
- const match = state.pending.match(SCHEME_RE);
3544
- if (!match) return false;
3545
- const proto = match[1];
3546
- const link = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length));
3599
+ const protoMin = pos - Math.min(10, state.pending.length, pos);
3600
+ let protoStart = pos;
3601
+ while (protoStart > protoMin && isSchemeChar(state.src.charCodeAt(protoStart - 1))) protoStart--;
3602
+ if (protoStart === pos || !isAsciiAlpha(state.src.charCodeAt(protoStart))) return false;
3603
+ const protoLength = pos - protoStart;
3604
+ const link = state.md.linkify.matchAtStart(state.src.slice(protoStart));
3547
3605
  if (!link) return false;
3548
3606
  let url = link.url;
3549
- if (url.length <= proto.length) return false;
3607
+ if (url.length <= protoLength) return false;
3550
3608
  let urlEnd = url.length;
3551
3609
  while (urlEnd > 0 && url.charCodeAt(urlEnd - 1) === 42) urlEnd--;
3552
3610
  if (urlEnd !== url.length) url = url.slice(0, urlEnd);
3553
3611
  const fullUrl = state.md.normalizeLink(url);
3554
3612
  if (!state.md.validateLink(fullUrl)) return false;
3555
3613
  if (!silent) {
3556
- state.pending = state.pending.slice(0, -proto.length);
3614
+ state.pending = state.pending.slice(0, -protoLength);
3557
3615
  const token_o = state.push("link_open", "a", 1);
3558
3616
  token_o.attrs = [["href", fullUrl]];
3559
3617
  token_o.markup = "linkify";
@@ -3564,11 +3622,11 @@ window.__ModuleLoader__.load({
3564
3622
  token_c.markup = "linkify";
3565
3623
  token_c.info = "auto";
3566
3624
  }
3567
- state.pos += url.length - proto.length;
3625
+ state.pos += url.length - protoLength;
3568
3626
  return true;
3569
3627
  }
3570
3628
  //#endregion
3571
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/newline.mjs
3629
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/newline.mjs
3572
3630
  function newline(state, silent) {
3573
3631
  let pos = state.pos;
3574
3632
  if (state.src.charCodeAt(pos) !== 10) return false;
@@ -3590,7 +3648,7 @@ window.__ModuleLoader__.load({
3590
3648
  return true;
3591
3649
  }
3592
3650
  //#endregion
3593
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/escape.mjs
3651
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/escape.mjs
3594
3652
  const ESCAPED = [];
3595
3653
  for (let i = 0; i < 256; i++) ESCAPED.push(0);
3596
3654
  "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(ch) {
@@ -3644,7 +3702,7 @@ window.__ModuleLoader__.load({
3644
3702
  return true;
3645
3703
  }
3646
3704
  //#endregion
3647
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/backticks.mjs
3705
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/backticks.mjs
3648
3706
  function backtick(state, silent) {
3649
3707
  let pos = state.pos;
3650
3708
  if (state.src.charCodeAt(pos) !== 96) return false;
@@ -3682,7 +3740,7 @@ window.__ModuleLoader__.load({
3682
3740
  return true;
3683
3741
  }
3684
3742
  //#endregion
3685
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs
3743
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs
3686
3744
  function strikethrough_tokenize(state, silent) {
3687
3745
  const start = state.pos;
3688
3746
  const marker = state.src.charCodeAt(start);
@@ -3759,7 +3817,7 @@ window.__ModuleLoader__.load({
3759
3817
  postProcess: strikethrough_postProcess
3760
3818
  };
3761
3819
  //#endregion
3762
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/emphasis.mjs
3820
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/emphasis.mjs
3763
3821
  function emphasis_tokenize(state, silent) {
3764
3822
  const start = state.pos;
3765
3823
  const marker = state.src.charCodeAt(start);
@@ -3820,7 +3878,7 @@ window.__ModuleLoader__.load({
3820
3878
  postProcess: emphasis_post_process
3821
3879
  };
3822
3880
  //#endregion
3823
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/link.mjs
3881
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/link.mjs
3824
3882
  function link$1(state, silent) {
3825
3883
  let code, label, res, ref;
3826
3884
  let href = "";
@@ -3900,7 +3958,7 @@ window.__ModuleLoader__.load({
3900
3958
  return true;
3901
3959
  }
3902
3960
  //#endregion
3903
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/image.mjs
3961
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/image.mjs
3904
3962
  function image(state, silent) {
3905
3963
  let code, content, label, pos, ref, res, title, start;
3906
3964
  let href = "";
@@ -3978,7 +4036,7 @@ window.__ModuleLoader__.load({
3978
4036
  return true;
3979
4037
  }
3980
4038
  //#endregion
3981
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/autolink.mjs
4039
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/autolink.mjs
3982
4040
  const EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;
3983
4041
  const AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;
3984
4042
  function autolink(state, silent) {
@@ -4030,7 +4088,7 @@ window.__ModuleLoader__.load({
4030
4088
  return false;
4031
4089
  }
4032
4090
  //#endregion
4033
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/html_inline.mjs
4091
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/html_inline.mjs
4034
4092
  function isLinkOpen(str) {
4035
4093
  return /^<a[>\s]/i.test(str);
4036
4094
  }
@@ -4041,26 +4099,57 @@ window.__ModuleLoader__.load({
4041
4099
  const lc = ch | 32;
4042
4100
  return lc >= 97 && lc <= 122;
4043
4101
  }
4102
+ function scanSpecial(state, pos) {
4103
+ const src = state.src;
4104
+ let start;
4105
+ let terminator;
4106
+ if (src.startsWith("<!--", pos)) {
4107
+ if (src.startsWith(">", pos + 4)) return pos + 5;
4108
+ if (src.startsWith("->", pos + 4)) return pos + 6;
4109
+ start = pos + 4;
4110
+ terminator = "-->";
4111
+ } else if (src.startsWith("<![CDATA[", pos)) {
4112
+ start = pos + 9;
4113
+ terminator = "]]>";
4114
+ } else if (src.charCodeAt(pos + 1) === 63) {
4115
+ start = pos + 2;
4116
+ terminator = "?>";
4117
+ } else if (isLetter(src.charCodeAt(pos + 2))) {
4118
+ start = pos + 3;
4119
+ terminator = ">";
4120
+ } else return -1;
4121
+ if (state.skipHtmlSpecial) return -1;
4122
+ const end = src.indexOf(terminator, start);
4123
+ if (end < 0) {
4124
+ state.skipHtmlSpecial = true;
4125
+ return -1;
4126
+ }
4127
+ return end + terminator.length;
4128
+ }
4044
4129
  function html_inline(state, silent) {
4045
4130
  if (!state.md.options.html) return false;
4046
4131
  const max = state.posMax;
4047
4132
  const pos = state.pos;
4048
4133
  if (state.src.charCodeAt(pos) !== 60 || pos + 2 >= max) return false;
4134
+ let end;
4049
4135
  const ch = state.src.charCodeAt(pos + 1);
4050
- if (ch !== 33 && ch !== 63 && ch !== 47 && !isLetter(ch)) return false;
4051
- const match = state.src.slice(pos).match(HTML_TAG_RE);
4052
- if (!match) return false;
4136
+ if (ch === 33 || ch === 63) end = scanSpecial(state, pos);
4137
+ else if (ch === 47 || isLetter(ch)) {
4138
+ const match = state.src.slice(pos).match(HTML_OPEN_CLOSE_TAG_RE);
4139
+ end = match ? pos + match[0].length : -1;
4140
+ } else return false;
4141
+ if (end < 0) return false;
4053
4142
  if (!silent) {
4054
4143
  const token = state.push("html_inline", "", 0);
4055
- token.content = match[0];
4144
+ token.content = state.src.slice(pos, end);
4056
4145
  if (isLinkOpen(token.content)) state.linkLevel++;
4057
4146
  if (isLinkClose(token.content)) state.linkLevel--;
4058
4147
  }
4059
- state.pos += match[0].length;
4148
+ state.pos = end;
4060
4149
  return true;
4061
4150
  }
4062
4151
  //#endregion
4063
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/entity.mjs
4152
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/entity.mjs
4064
4153
  const DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
4065
4154
  const NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
4066
4155
  function entity(state, silent) {
@@ -4100,7 +4189,7 @@ window.__ModuleLoader__.load({
4100
4189
  return false;
4101
4190
  }
4102
4191
  //#endregion
4103
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs
4192
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs
4104
4193
  function processDelimiters(delimiters) {
4105
4194
  const openersBottom = {};
4106
4195
  const max = delimiters.length;
@@ -4159,7 +4248,7 @@ window.__ModuleLoader__.load({
4159
4248
  for (let curr = 0; curr < max; curr++) if (tokens_meta[curr] && tokens_meta[curr].delimiters) processDelimiters(tokens_meta[curr].delimiters);
4160
4249
  }
4161
4250
  //#endregion
4162
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs
4251
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs
4163
4252
  function fragments_join(state) {
4164
4253
  let curr, last;
4165
4254
  let level = 0;
@@ -4178,7 +4267,7 @@ window.__ModuleLoader__.load({
4178
4267
  if (curr !== last) tokens.length = last;
4179
4268
  }
4180
4269
  //#endregion
4181
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/parser_inline.mjs
4270
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/parser_inline.mjs
4182
4271
  /** internal
4183
4272
  * class ParserInline
4184
4273
  *
@@ -4778,7 +4867,7 @@ window.__ModuleLoader__.load({
4778
4867
  **/
4779
4868
  LinkifyIt.prototype.onCompile = function onCompile() {};
4780
4869
  //#endregion
4781
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/presets/default.mjs
4870
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/presets/default.mjs
4782
4871
  var import_punycode = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
4783
4872
  /** Highest positive signed 32-bit float value */
4784
4873
  const maxInt = 2147483647;
@@ -5076,7 +5165,7 @@ window.__ModuleLoader__.load({
5076
5165
  };
5077
5166
  })))(), 1);
5078
5167
  //#endregion
5079
- //#region node_modules/.pnpm/markdown-it@14.3.0/node_modules/markdown-it/lib/index.mjs
5168
+ //#region node_modules/.pnpm/markdown-it@14.3.3/node_modules/markdown-it/lib/index.mjs
5080
5169
  const config = {
5081
5170
  default: {
5082
5171
  options: {
@@ -5718,7 +5807,7 @@ window.__ModuleLoader__.load({
5718
5807
  return new OrderedMap(content);
5719
5808
  };
5720
5809
  //#endregion
5721
- //#region node_modules/.pnpm/prosemirror-model@1.25.11/node_modules/prosemirror-model/dist/index.js
5810
+ //#region node_modules/.pnpm/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js
5722
5811
  function findDiffStart(a, b, pos) {
5723
5812
  for (let i = 0;; i++) {
5724
5813
  if (i == a.childCount || i == b.childCount) return a.childCount == b.childCount ? null : pos;
@@ -6164,9 +6253,7 @@ window.__ModuleLoader__.load({
6164
6253
  if (!json) throw new RangeError("Invalid input for Mark.fromJSON");
6165
6254
  let type = schema.marks[json.type];
6166
6255
  if (!type) throw new RangeError(`There is no mark type ${json.type} in this schema`);
6167
- let mark = type.create(json.attrs);
6168
- type.checkAttrs(mark.attrs);
6169
- return mark;
6256
+ return type.create(json.attrs);
6170
6257
  }
6171
6258
  /**
6172
6259
  Test whether two sets of marks are identical.
@@ -7063,11 +7150,11 @@ window.__ModuleLoader__.load({
7063
7150
  */
7064
7151
  check() {
7065
7152
  this.type.checkContent(this.content);
7066
- this.type.checkAttrs(this.attrs);
7153
+ checkAttrs(this.type.attrs, this.attrs, "node", this.type.name);
7067
7154
  let copy = Mark$1.none;
7068
7155
  for (let i = 0; i < this.marks.length; i++) {
7069
7156
  let mark = this.marks[i];
7070
- mark.type.checkAttrs(mark.attrs);
7157
+ checkAttrs(mark.type.attrs, mark.attrs, "mark", mark.type.name);
7071
7158
  copy = mark.addToSet(copy);
7072
7159
  }
7073
7160
  if (!Mark$1.sameSet(copy, this.marks)) throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m) => m.type.name)}`);
@@ -7101,9 +7188,7 @@ window.__ModuleLoader__.load({
7101
7188
  return schema.text(json.text, marks);
7102
7189
  }
7103
7190
  let content = Fragment.fromJSON(schema, json.content);
7104
- let node = schema.nodeType(json.type).create(json.attrs, content, marks);
7105
- node.type.checkAttrs(node.attrs);
7106
- return node;
7191
+ return schema.nodeType(json.type).create(json.attrs, content, marks);
7107
7192
  }
7108
7193
  };
7109
7194
  Node$3.prototype.text = void 0;
@@ -7153,6 +7238,10 @@ window.__ModuleLoader__.load({
7153
7238
  for (let i = marks.length - 1; i >= 0; i--) str = marks[i].type.name + "(" + str + ")";
7154
7239
  return str;
7155
7240
  }
7241
+ function checkAttrs(attrs, values, type, name) {
7242
+ for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
7243
+ for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
7244
+ }
7156
7245
  /**
7157
7246
  Instances of this class represent a match state of a node type's
7158
7247
  [content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
@@ -7561,20 +7650,15 @@ window.__ModuleLoader__.load({
7561
7650
  function computeAttrs(attrs, value) {
7562
7651
  let built = Object.create(null);
7563
7652
  for (let name in attrs) {
7653
+ let attr = attrs[name];
7564
7654
  let given = value && value[name];
7565
- if (given === void 0) {
7566
- let attr = attrs[name];
7567
- if (attr.hasDefault) given = attr.default;
7568
- else throw new RangeError("No value supplied for attribute " + name);
7569
- }
7655
+ if (given === void 0) if (attr.hasDefault) given = attr.default;
7656
+ else throw new RangeError("No value supplied for attribute " + name);
7657
+ else if (attr.validate) attr.validate(given);
7570
7658
  built[name] = given;
7571
7659
  }
7572
7660
  return built;
7573
7661
  }
7574
- function checkAttrs(attrs, values, type, name) {
7575
- for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
7576
- for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
7577
- }
7578
7662
  function initAttrs(typeName, attrs) {
7579
7663
  let result = Object.create(null);
7580
7664
  if (attrs) for (let name in attrs) result[name] = new Attribute(typeName, name, attrs[name]);
@@ -7729,11 +7813,9 @@ window.__ModuleLoader__.load({
7729
7813
  if (!this.validContent(content)) throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
7730
7814
  }
7731
7815
  /**
7732
- @internal
7816
+ @internal no longer useful, but called by old prosemirror-view versions
7733
7817
  */
7734
- checkAttrs(attrs) {
7735
- checkAttrs(this.attrs, attrs, "node", this.name);
7736
- }
7818
+ checkAttrs(attrs) {}
7737
7819
  /**
7738
7820
  Check whether the given mark type is allowed in this node.
7739
7821
  */
@@ -7844,12 +7926,6 @@ window.__ModuleLoader__.load({
7844
7926
  for (let i = 0; i < set.length; i++) if (set[i].type == this) return set[i];
7845
7927
  }
7846
7928
  /**
7847
- @internal
7848
- */
7849
- checkAttrs(attrs) {
7850
- checkAttrs(this.attrs, attrs, "mark", this.name);
7851
- }
7852
- /**
7853
7929
  Queries whether a given mark type is
7854
7930
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
7855
7931
  */
@@ -8708,7 +8784,7 @@ window.__ModuleLoader__.load({
8708
8784
  };
8709
8785
  }
8710
8786
  //#endregion
8711
- //#region node_modules/.pnpm/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.js
8787
+ //#region node_modules/.pnpm/prosemirror-transform@1.12.4/node_modules/prosemirror-transform/dist/index.js
8712
8788
  const lower16 = 65535;
8713
8789
  const factor16 = Math.pow(2, 16);
8714
8790
  function makeRecover(index, offset) {
@@ -8811,8 +8887,11 @@ window.__ModuleLoader__.load({
8811
8887
  let result = start + diff + (side < 0 ? 0 : newSize);
8812
8888
  if (simple) return result;
8813
8889
  let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
8814
- let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
8815
- if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
8890
+ let del = 0;
8891
+ if (oldSize) {
8892
+ del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
8893
+ if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
8894
+ }
8816
8895
  return new MapResult(result, del, recover);
8817
8896
  }
8818
8897
  diff += newSize - oldSize;
@@ -9128,13 +9207,24 @@ window.__ModuleLoader__.load({
9128
9207
  }, parent), oldSlice.openStart, oldSlice.openEnd);
9129
9208
  return StepResult.fromReplace(doc, this.from, this.to, slice);
9130
9209
  }
9131
- invert() {
9132
- return new RemoveMarkStep(this.from, this.to, this.mark);
9210
+ invert(doc) {
9211
+ let steps = [];
9212
+ doc.nodesBetween(this.from, this.to, (node, pos) => {
9213
+ if (node.isInline && node.isAtom) {
9214
+ let added = this.mark.addToSet(node.marks);
9215
+ if (!Mark$1.sameSet(added, node.marks)) {
9216
+ let from = Math.max(this.from, pos), to = Math.min(this.to, pos + node.nodeSize);
9217
+ pushMarkStep(RemoveMarkStep, from, to, this.mark, steps);
9218
+ for (let mark of node.marks) if (!mark.isInSet(added)) pushMarkStep(AddMarkStep, from, to, mark, steps);
9219
+ }
9220
+ }
9221
+ });
9222
+ return steps.length == 1 ? steps[0] : new MarkSetStep(steps);
9133
9223
  }
9134
9224
  map(mapping) {
9135
- let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
9136
- if (from.deleted && to.deleted || from.pos >= to.pos) return null;
9137
- return new AddMarkStep(from.pos, to.pos, this.mark);
9225
+ let from = mapping.map(this.from, 1), to = mapping.map(this.to, -1);
9226
+ if (from >= to) return null;
9227
+ return new AddMarkStep(from, to, this.mark);
9138
9228
  }
9139
9229
  merge(other) {
9140
9230
  if (other instanceof AddMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
@@ -9177,13 +9267,17 @@ window.__ModuleLoader__.load({
9177
9267
  }, doc), oldSlice.openStart, oldSlice.openEnd);
9178
9268
  return StepResult.fromReplace(doc, this.from, this.to, slice);
9179
9269
  }
9180
- invert() {
9181
- return new AddMarkStep(this.from, this.to, this.mark);
9270
+ invert(doc) {
9271
+ let steps = [];
9272
+ doc.nodesBetween(this.from, this.to, (node, pos) => {
9273
+ if (node.isInline && node.isAtom && this.mark.isInSet(node.marks)) pushMarkStep(AddMarkStep, Math.max(this.from, pos), Math.min(this.to, pos + node.nodeSize), this.mark, steps);
9274
+ });
9275
+ return steps.length == 1 ? steps[0] : new MarkSetStep(steps);
9182
9276
  }
9183
9277
  map(mapping) {
9184
- let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
9185
- if (from.deleted && to.deleted || from.pos >= to.pos) return null;
9186
- return new RemoveMarkStep(from.pos, to.pos, this.mark);
9278
+ let from = mapping.map(this.from, 1), to = mapping.map(this.to, -1);
9279
+ if (from >= to) return null;
9280
+ return new RemoveMarkStep(from, to, this.mark);
9187
9281
  }
9188
9282
  merge(other) {
9189
9283
  if (other instanceof RemoveMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
@@ -9206,6 +9300,47 @@ window.__ModuleLoader__.load({
9206
9300
  }
9207
9301
  };
9208
9302
  Step.jsonID("removeMark", RemoveMarkStep);
9303
+ function pushMarkStep(cls, from, to, mark, target) {
9304
+ let last = target.length ? target[target.length - 1] : null;
9305
+ if (last && last instanceof cls && last.to == from && last.mark.eq(mark)) target[target.length - 1] = new cls(last.from, to, mark);
9306
+ else target.push(new cls(from, to, mark));
9307
+ }
9308
+ var MarkSetStep = class MarkSetStep extends Step {
9309
+ constructor(steps) {
9310
+ super();
9311
+ this.steps = steps;
9312
+ }
9313
+ apply(doc) {
9314
+ for (let step of this.steps) {
9315
+ let result = step.apply(doc);
9316
+ if (!result.doc) return result;
9317
+ doc = result.doc;
9318
+ }
9319
+ return new StepResult(doc, null);
9320
+ }
9321
+ invert(doc) {
9322
+ return new MarkSetStep(this.steps.map((s) => s.invert(doc)));
9323
+ }
9324
+ map(mapping) {
9325
+ let result = [];
9326
+ for (let step of this.steps) {
9327
+ let mapped = step.map(mapping);
9328
+ if (mapped) result.push(mapped);
9329
+ }
9330
+ return result.length ? new MarkSetStep(result) : null;
9331
+ }
9332
+ toJSON() {
9333
+ return {
9334
+ stepType: "markSet",
9335
+ steps: this.steps.map((s) => s.toJSON())
9336
+ };
9337
+ }
9338
+ static fromJSON(schema, json) {
9339
+ if (!Array.isArray(json.steps) || !json.steps.every((s) => s.stepType == "addMark" || s.stepType == "removeMark")) throw new RangeError("Invalid JSON for MarkSetStep");
9340
+ return new MarkSetStep(json.steps.map((s) => Step.fromJSON(schema, s)));
9341
+ }
9342
+ };
9343
+ Step.jsonID("markSet", MarkSetStep);
9209
9344
  /**
9210
9345
  Add a mark to a specific node.
9211
9346
  */
@@ -9466,27 +9601,18 @@ window.__ModuleLoader__.load({
9466
9601
  return false;
9467
9602
  }
9468
9603
  function addMark(tr, from, to, mark) {
9469
- let removed = [], added = [];
9470
- let removing, adding;
9604
+ let added = [];
9471
9605
  tr.doc.nodesBetween(from, to, (node, pos, parent) => {
9472
9606
  if (!node.isInline) return;
9473
9607
  let marks = node.marks;
9474
- if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {
9475
- let start = Math.max(pos, from), end = Math.min(pos + node.nodeSize, to);
9476
- let newSet = mark.addToSet(marks);
9477
- for (let i = 0; i < marks.length; i++) if (!marks[i].isInSet(newSet)) if (removing && removing.to == start && removing.mark.eq(marks[i])) removing.to = end;
9478
- else removed.push(removing = new RemoveMarkStep(start, end, marks[i]));
9479
- if (adding && adding.to == start) adding.to = end;
9480
- else added.push(adding = new AddMarkStep(start, end, mark));
9481
- }
9608
+ if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) pushMarkStep(AddMarkStep, Math.max(pos, from), Math.min(pos + node.nodeSize, to), mark, added);
9482
9609
  });
9483
- removed.forEach((s) => tr.step(s));
9484
9610
  added.forEach((s) => tr.step(s));
9485
9611
  }
9486
9612
  function removeMark(tr, from, to, mark) {
9487
9613
  let matched = [], step = 0;
9488
9614
  tr.doc.nodesBetween(from, to, (node, pos) => {
9489
- if (!node.isInline) return;
9615
+ if (!node.isInline || !node.isAtom) return;
9490
9616
  step++;
9491
9617
  let toRemove = null;
9492
9618
  if (mark instanceof MarkType) {
@@ -9908,9 +10034,9 @@ window.__ModuleLoader__.load({
9908
10034
  }
9909
10035
  openMore() {
9910
10036
  let { content, openStart, openEnd } = this.unplaced;
9911
- let inner = contentAt(content, openStart);
9912
- if (!inner.childCount || inner.firstChild.isLeaf) return false;
9913
- this.unplaced = new Slice(content, openStart + 1, Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));
10037
+ if (maxOpen(content, -1) <= openStart) return false;
10038
+ if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;
10039
+ this.unplaced = new Slice(content, openStart + 1, openEnd);
9914
10040
  return true;
9915
10041
  }
9916
10042
  dropNode() {
@@ -10044,6 +10170,13 @@ window.__ModuleLoader__.load({
10044
10170
  function definesContent(type) {
10045
10171
  return type.spec.defining || type.spec.definingForContent;
10046
10172
  }
10173
+ function maxOpen(frag, side) {
10174
+ for (let count = 0;; count++) {
10175
+ let ch = side < 0 ? frag.firstChild : frag.lastChild;
10176
+ if (!ch || ch.isAtom) return count;
10177
+ frag = ch.content;
10178
+ }
10179
+ }
10047
10180
  function replaceRange(tr, from, to, slice) {
10048
10181
  if (!slice.size) return tr.deleteRange(from, to);
10049
10182
  let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
@@ -11489,7 +11622,7 @@ window.__ModuleLoader__.load({
11489
11622
  }
11490
11623
  };
11491
11624
  //#endregion
11492
- //#region node_modules/.pnpm/prosemirror-view@1.42.2/node_modules/prosemirror-view/dist/index.js
11625
+ //#region node_modules/.pnpm/prosemirror-view@1.42.9/node_modules/prosemirror-view/dist/index.js
11493
11626
  const domIndex = function(node) {
11494
11627
  for (var index = 0;; index++) {
11495
11628
  node = node.previousSibling;
@@ -11520,12 +11653,12 @@ window.__ModuleLoader__.load({
11520
11653
  if (node == targetNode && off == targetOff) return true;
11521
11654
  if (off == (dir < 0 ? 0 : nodeSize(node))) {
11522
11655
  let parent = node.parentNode;
11523
- if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
11656
+ if (!parent || !isElt(parent) || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
11524
11657
  off = domIndex(node) + (dir < 0 ? 0 : 1);
11525
11658
  node = parent;
11526
- } else if (node.nodeType == 1) {
11659
+ } else if (isElt(node)) {
11527
11660
  let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
11528
- if (child.nodeType == 1 && child.contentEditable == "false") if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;
11661
+ if (isElt(child) && child.contentEditable == "false") if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;
11529
11662
  else return false;
11530
11663
  else {
11531
11664
  node = child;
@@ -11537,10 +11670,19 @@ window.__ModuleLoader__.load({
11537
11670
  function nodeSize(node) {
11538
11671
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
11539
11672
  }
11673
+ function isElt(node) {
11674
+ return node.nodeType == 1;
11675
+ }
11676
+ function isText(node) {
11677
+ return node.nodeType == 3;
11678
+ }
11679
+ function contains(parent, child) {
11680
+ return child ? parent.contains(isElt(child) ? child : child.parentNode) : false;
11681
+ }
11540
11682
  function textNodeBefore$1(node, offset) {
11541
11683
  for (;;) {
11542
- if (node.nodeType == 3 && offset) return node;
11543
- if (node.nodeType == 1 && offset > 0) {
11684
+ if (isText(node) && offset) return node;
11685
+ if (isElt(node) && offset > 0) {
11544
11686
  if (node.contentEditable == "false") return null;
11545
11687
  node = node.childNodes[offset - 1];
11546
11688
  offset = nodeSize(node);
@@ -11552,8 +11694,8 @@ window.__ModuleLoader__.load({
11552
11694
  }
11553
11695
  function textNodeAfter$1(node, offset) {
11554
11696
  for (;;) {
11555
- if (node.nodeType == 3 && offset < node.nodeValue.length) return node;
11556
- if (node.nodeType == 1 && offset < node.childNodes.length) {
11697
+ if (isText(node) && offset < node.nodeValue.length) return node;
11698
+ if (isElt(node) && offset < node.childNodes.length) {
11557
11699
  if (node.contentEditable == "false") return null;
11558
11700
  node = node.childNodes[offset];
11559
11701
  offset = 0;
@@ -11664,13 +11806,12 @@ window.__ModuleLoader__.load({
11664
11806
  let doc = view.dom.ownerDocument;
11665
11807
  for (let parent = startDOM || view.dom;;) {
11666
11808
  if (!parent) break;
11667
- if (parent.nodeType != 1) {
11809
+ if (!isElt(parent)) {
11668
11810
  parent = parentNode(parent);
11669
11811
  continue;
11670
11812
  }
11671
- let elt = parent;
11672
- let atTop = elt == doc.body;
11673
- let bounding = atTop ? windowRect(doc) : clientRect(elt);
11813
+ let atTop = parent == doc.body;
11814
+ let bounding = atTop ? windowRect(doc) : clientRect(parent);
11674
11815
  let moveX = 0, moveY = 0;
11675
11816
  if (rect.top < bounding.top + getSide(scrollThreshold, "top")) moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
11676
11817
  else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom")) moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
@@ -11678,10 +11819,10 @@ window.__ModuleLoader__.load({
11678
11819
  else if (rect.right > bounding.right - getSide(scrollThreshold, "right")) moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
11679
11820
  if (moveX || moveY) if (atTop) doc.defaultView.scrollBy(moveX, moveY);
11680
11821
  else {
11681
- let startX = elt.scrollLeft, startY = elt.scrollTop;
11682
- if (moveY) elt.scrollTop += moveY;
11683
- if (moveX) elt.scrollLeft += moveX;
11684
- let dX = elt.scrollLeft - startX, dY = elt.scrollTop - startY;
11822
+ let startX = parent.scrollLeft, startY = parent.scrollTop;
11823
+ if (moveY) parent.scrollTop += moveY;
11824
+ if (moveX) parent.scrollLeft += moveX;
11825
+ let dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
11685
11826
  rect = {
11686
11827
  left: rect.left - dX,
11687
11828
  top: rect.top - dY,
@@ -11751,13 +11892,14 @@ window.__ModuleLoader__.load({
11751
11892
  }
11752
11893
  }
11753
11894
  function findOffsetInNode(node, coords) {
11754
- let closest, dxClosest = 2e8, coordsClosest, offset = 0;
11895
+ let closest;
11896
+ let dxClosest = 2e8, coordsClosest, offset = 0;
11755
11897
  let rowBot = coords.top, rowTop = coords.top;
11756
11898
  let firstBelow, coordsBelow;
11757
11899
  for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
11758
11900
  let rects;
11759
- if (child.nodeType == 1) rects = child.getClientRects();
11760
- else if (child.nodeType == 3) rects = textRange(child).getClientRects();
11901
+ if (isElt(child)) rects = child.getClientRects();
11902
+ else if (isText(child)) rects = textRange(child).getClientRects();
11761
11903
  else continue;
11762
11904
  for (let i = 0; i < rects.length; i++) {
11763
11905
  let rect = rects[i];
@@ -11768,11 +11910,11 @@ window.__ModuleLoader__.load({
11768
11910
  if (dx < dxClosest) {
11769
11911
  closest = child;
11770
11912
  dxClosest = dx;
11771
- coordsClosest = dx && closest.nodeType == 3 ? {
11913
+ coordsClosest = dx && isText(closest) ? {
11772
11914
  left: rect.right < coords.left ? rect.right : rect.left,
11773
11915
  top: coords.top
11774
11916
  } : coords;
11775
- if (child.nodeType == 1 && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
11917
+ if (isElt(child) && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
11776
11918
  continue;
11777
11919
  }
11778
11920
  } else if (rect.top > coords.top && !firstBelow && rect.left <= coords.left && rect.right >= coords.left) {
@@ -11790,8 +11932,8 @@ window.__ModuleLoader__.load({
11790
11932
  coordsClosest = coordsBelow;
11791
11933
  dxClosest = 0;
11792
11934
  }
11793
- if (closest && closest.nodeType == 3) return findOffsetInText(closest, coordsClosest);
11794
- if (!closest || dxClosest && closest.nodeType == 1) return {
11935
+ if (closest && isText(closest)) return findOffsetInText(closest, coordsClosest);
11936
+ if (!closest || dxClosest) return {
11795
11937
  node,
11796
11938
  offset
11797
11939
  };
@@ -11829,7 +11971,7 @@ window.__ModuleLoader__.load({
11829
11971
  }
11830
11972
  function posFromElement(view, elt, coords) {
11831
11973
  let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
11832
- if (node.nodeType == 1 && !node.firstChild) {
11974
+ if (isElt(node) && !node.firstChild) {
11833
11975
  let rect = node.getBoundingClientRect();
11834
11976
  bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
11835
11977
  }
@@ -11841,7 +11983,7 @@ window.__ModuleLoader__.load({
11841
11983
  if (cur == view.dom) break;
11842
11984
  let desc = view.docView.nearestDesc(cur, true), rect;
11843
11985
  if (!desc) return null;
11844
- if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
11986
+ if (isElt(desc.dom) && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
11845
11987
  if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
11846
11988
  if (!sawBlock && rect.left > coords.left || rect.top > coords.top) outsideBlock = desc.posBefore;
11847
11989
  else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top) outsideBlock = desc.posAfter;
@@ -11857,7 +11999,7 @@ window.__ModuleLoader__.load({
11857
11999
  let len = element.childNodes.length;
11858
12000
  if (len && box.top < box.bottom) for (let startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {
11859
12001
  let child = element.childNodes[i];
11860
- if (child.nodeType == 1) {
12002
+ if (isElt(child)) {
11861
12003
  let rects = child.getClientRects();
11862
12004
  for (let j = 0; j < rects.length; j++) {
11863
12005
  let rect = rects[j];
@@ -11874,7 +12016,7 @@ window.__ModuleLoader__.load({
11874
12016
  if (caret) ({node, offset} = caret);
11875
12017
  let elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top);
11876
12018
  let pos;
11877
- if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {
12019
+ if (!elt || !view.dom.contains(elt)) {
11878
12020
  let box = view.dom.getBoundingClientRect();
11879
12021
  if (!inRect(coords, box)) return null;
11880
12022
  elt = elementFromPoint(view.dom, coords, box);
@@ -11885,7 +12027,7 @@ window.__ModuleLoader__.load({
11885
12027
  }
11886
12028
  elt = targetKludge(elt, coords);
11887
12029
  if (node) {
11888
- if (gecko && node.nodeType == 1) {
12030
+ if (gecko && isElt(node)) {
11889
12031
  offset = Math.min(offset, node.childNodes.length);
11890
12032
  if (offset < node.childNodes.length) {
11891
12033
  let next = node.childNodes[offset], box;
@@ -11893,9 +12035,9 @@ window.__ModuleLoader__.load({
11893
12035
  }
11894
12036
  }
11895
12037
  let prev;
11896
- if (webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
11897
- if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;
11898
- else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
12038
+ if (webkit && offset && isElt(node) && isElt(prev = node.childNodes[offset - 1]) && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
12039
+ if (node == view.dom && offset == node.childNodes.length - 1 && isElt(node.lastChild) && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;
12040
+ else if (offset == 0 || !isElt(node) || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
11899
12041
  }
11900
12042
  if (pos == null) pos = posFromElement(view, elt, coords);
11901
12043
  let desc = view.docView.nearestDesc(elt, true);
@@ -11919,7 +12061,7 @@ window.__ModuleLoader__.load({
11919
12061
  function coordsAtPos(view, pos, side) {
11920
12062
  let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
11921
12063
  let supportEmptyRange = webkit || gecko;
11922
- if (node.nodeType == 3) if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
12064
+ if (isText(node)) if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
11923
12065
  let rect = singleRect(textRange(node, offset, offset), side);
11924
12066
  if (gecko && offset && /\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {
11925
12067
  let rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1);
@@ -11944,26 +12086,26 @@ window.__ModuleLoader__.load({
11944
12086
  if (!view.state.doc.resolve(pos - (atom || 0)).parent.inlineContent) {
11945
12087
  if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
11946
12088
  let before = node.childNodes[offset - 1];
11947
- if (before.nodeType == 1) return flattenH(before.getBoundingClientRect(), false);
12089
+ if (isElt(before)) return flattenH(before.getBoundingClientRect(), false);
11948
12090
  }
11949
12091
  if (atom == null && offset < nodeSize(node)) {
11950
12092
  let after = node.childNodes[offset];
11951
- if (after.nodeType == 1) return flattenH(after.getBoundingClientRect(), true);
12093
+ if (isElt(after)) return flattenH(after.getBoundingClientRect(), true);
11952
12094
  }
11953
12095
  return flattenH(node.getBoundingClientRect(), side >= 0);
11954
12096
  }
11955
12097
  if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
11956
12098
  let before = node.childNodes[offset - 1];
11957
- let target = before.nodeType == 3 ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : before.nodeType == 1 && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
12099
+ let target = isText(before) ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : isElt(before) && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
11958
12100
  if (target) return flattenV(singleRect(target, 1), false);
11959
12101
  }
11960
12102
  if (atom == null && offset < nodeSize(node)) {
11961
12103
  let after = node.childNodes[offset];
11962
12104
  while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords) after = after.nextSibling;
11963
- let target = !after ? null : after.nodeType == 3 ? textRange(after, 0, supportEmptyRange ? 0 : 1) : after.nodeType == 1 ? after : null;
12105
+ let target = !after ? null : isText(after) ? textRange(after, 0, supportEmptyRange ? 0 : 1) : isElt(after) ? after : null;
11964
12106
  if (target) return flattenV(singleRect(target, -1), true);
11965
12107
  }
11966
- return flattenV(singleRect(node.nodeType == 3 ? textRange(node) : node, -side), side >= 0);
12108
+ return flattenV(singleRect(isText(node) ? textRange(node) : node, -side), side >= 0);
11967
12109
  }
11968
12110
  function flattenV(rect, left) {
11969
12111
  if (rect.width == 0) return rect;
@@ -12013,8 +12155,8 @@ window.__ModuleLoader__.load({
12013
12155
  let coords = coordsAtPos(view, $pos.pos, 1);
12014
12156
  for (let child = dom.firstChild; child; child = child.nextSibling) {
12015
12157
  let boxes;
12016
- if (child.nodeType == 1) boxes = child.getClientRects();
12017
- else if (child.nodeType == 3) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
12158
+ if (isElt(child)) boxes = child.getClientRects();
12159
+ else if (isText(child)) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
12018
12160
  else continue;
12019
12161
  for (let i = 0; i < boxes.length; i++) {
12020
12162
  let box = boxes[i];
@@ -12038,7 +12180,7 @@ window.__ModuleLoader__.load({
12038
12180
  sel.modify("move", dir, "character");
12039
12181
  let parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
12040
12182
  let { focusNode: newNode, focusOffset: newOff } = view.domSelectionRange();
12041
- let result = newNode && !parentDOM.contains(newNode.nodeType == 1 ? newNode : newNode.parentNode) || oldNode == newNode && oldOff == newOff;
12183
+ let result = newNode && !contains(parentDOM, newNode) || oldNode == newNode && oldOff == newOff;
12042
12184
  try {
12043
12185
  sel.collapse(anchorNode, anchorOffset);
12044
12186
  if (oldNode && (oldNode != anchorNode || oldOff != anchorOffset) && sel.extend) sel.extend(oldNode, oldOff);
@@ -12120,7 +12262,7 @@ window.__ModuleLoader__.load({
12120
12262
  return this.posAtStart + this.size - 2 * this.border;
12121
12263
  }
12122
12264
  localPosFromDOM(dom, offset, bias) {
12123
- if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) if (bias < 0) {
12265
+ if (this.contentDOM && contains(this.contentDOM, dom)) if (bias < 0) {
12124
12266
  let domBefore, desc;
12125
12267
  if (dom == this.contentDOM) domBefore = dom.childNodes[offset - 1];
12126
12268
  else {
@@ -12141,8 +12283,11 @@ window.__ModuleLoader__.load({
12141
12283
  }
12142
12284
  let atEnd;
12143
12285
  if (dom == this.dom && this.contentDOM) atEnd = offset > domIndex(this.contentDOM);
12144
- else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;
12145
- else if (this.dom.firstChild) {
12286
+ else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
12287
+ let rel = dom.compareDocumentPosition(this.contentDOM);
12288
+ if (rel & 16) atEnd = offset > Array.from(dom.childNodes).findIndex((n) => n.contains(this.contentDOM));
12289
+ else atEnd = !(rel & 4);
12290
+ } else if (this.dom.firstChild) {
12146
12291
  if (offset == 0) for (let search = dom;; search = search.parentNode) {
12147
12292
  if (search == this.dom) {
12148
12293
  atEnd = false;
@@ -12163,7 +12308,7 @@ window.__ModuleLoader__.load({
12163
12308
  nearestDesc(dom, onlyNodes = false) {
12164
12309
  for (let first = true, cur = dom; cur; cur = cur.parentNode) {
12165
12310
  let desc = this.getDesc(cur), nodeDOM;
12166
- if (desc && (!onlyNodes || desc.node)) if (first && (nodeDOM = desc.nodeDOM) && !(nodeDOM.nodeType == 1 ? nodeDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode) : nodeDOM == dom)) first = false;
12311
+ if (desc && (!onlyNodes || desc.node)) if (first && (nodeDOM = desc.nodeDOM) && !(isElt(nodeDOM) ? contains(nodeDOM, dom) : nodeDOM == dom)) first = false;
12167
12312
  else return desc;
12168
12313
  }
12169
12314
  }
@@ -12204,14 +12349,17 @@ window.__ModuleLoader__.load({
12204
12349
  let i = 0, offset = 0;
12205
12350
  for (let curPos = 0; i < this.children.length; i++) {
12206
12351
  let child = this.children[i], end = curPos + child.size;
12207
- if (end > pos || child instanceof TrailingHackViewDesc) {
12352
+ if (end > pos) {
12208
12353
  offset = pos - curPos;
12209
12354
  break;
12210
12355
  }
12211
12356
  curPos = end;
12212
12357
  }
12213
12358
  if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side);
12214
- for (let prev; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.side >= 0; i--);
12359
+ for (; i > 0; i--) {
12360
+ let prev = this.children[i - 1];
12361
+ if (prev.size || !(prev instanceof BufferHackViewDesc || prev instanceof WidgetViewDesc && prev.side >= 0)) break;
12362
+ }
12215
12363
  if (side <= 0) {
12216
12364
  let prev, enter = true;
12217
12365
  for (;; i--, enter = false) {
@@ -12291,7 +12439,7 @@ window.__ModuleLoader__.load({
12291
12439
  }
12292
12440
  domAfterPos(pos) {
12293
12441
  let { node, offset } = this.domFromPos(pos, 0);
12294
- if (node.nodeType != 1 || offset == node.childNodes.length) throw new RangeError("No node after pos " + pos);
12442
+ if (!isElt(node) || offset == node.childNodes.length) throw new RangeError("No node after pos " + pos);
12295
12443
  return node.childNodes[offset];
12296
12444
  }
12297
12445
  setSelection(anchor, head, view, force = false) {
@@ -12308,7 +12456,7 @@ window.__ModuleLoader__.load({
12308
12456
  let brKludge = false;
12309
12457
  if ((gecko || safari) && anchor == head) {
12310
12458
  let { node, offset } = anchorDOM;
12311
- if (node.nodeType == 3) {
12459
+ if (isText(node)) {
12312
12460
  brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
12313
12461
  if (brKludge && offset == node.nodeValue.length) for (let scan = node, after; scan; scan = scan.parentNode) {
12314
12462
  if (after = scan.nextSibling) {
@@ -12326,7 +12474,7 @@ window.__ModuleLoader__.load({
12326
12474
  brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
12327
12475
  }
12328
12476
  }
12329
- if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode.nodeType == 1) {
12477
+ if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && isElt(selRange.focusNode)) {
12330
12478
  let after = selRange.focusNode.childNodes[selRange.focusOffset];
12331
12479
  if (after && after.contentEditable == "false") force = true;
12332
12480
  }
@@ -12402,13 +12550,13 @@ window.__ModuleLoader__.load({
12402
12550
  if (self.parent) return self.parent.posBeforeChild(self);
12403
12551
  });
12404
12552
  if (!widget.type.spec.raw) {
12405
- if (dom.nodeType != 1) {
12406
- let wrap = document.createElement("span");
12407
- wrap.appendChild(dom);
12408
- dom = wrap;
12553
+ let elt = isElt(dom) ? dom : document.createElement("span");
12554
+ if (elt != dom) {
12555
+ elt.appendChild(dom);
12556
+ dom = elt;
12409
12557
  }
12410
- dom.contentEditable = "false";
12411
- dom.classList.add("ProseMirror-widget");
12558
+ if (!elt.hasAttribute("contenteditable")) elt.contentEditable = "false";
12559
+ elt.classList.add("ProseMirror-widget");
12412
12560
  }
12413
12561
  super(parent, [], dom, null);
12414
12562
  this.widget = widget;
@@ -12531,7 +12679,7 @@ window.__ModuleLoader__.load({
12531
12679
  let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM;
12532
12680
  if (node.isText) {
12533
12681
  if (!dom) dom = document.createTextNode(node.text);
12534
- else if (dom.nodeType != 3) throw new RangeError("Text must be rendered as a DOM text node");
12682
+ else if (!isText(dom)) throw new RangeError("Text must be rendered as a DOM text node");
12535
12683
  } else if (!dom) {
12536
12684
  let spec = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node), null, node.attrs);
12537
12685
  ({dom, contentDOM} = spec);
@@ -12564,7 +12712,7 @@ window.__ModuleLoader__.load({
12564
12712
  }
12565
12713
  }
12566
12714
  if (!rule.contentElement) {
12567
- let found = addedNodes && addedNodes.find((n) => n.nodeType == 1 && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
12715
+ let found = addedNodes && addedNodes.find((n) => isElt(n) && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
12568
12716
  if (found) rule.contentElement = found;
12569
12717
  else rule.getContent = () => Fragment.empty;
12570
12718
  }
@@ -12586,18 +12734,21 @@ window.__ModuleLoader__.load({
12586
12734
  let localComposition = composition && composition.pos > -1 ? composition : null;
12587
12735
  let compositionInChild = composition && composition.pos < 0;
12588
12736
  let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
12737
+ let addBuffers = this.node.inlineContent, atBufferPos = addBuffers && this.node.isBlock;
12589
12738
  iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
12590
12739
  if (widget.spec.marks) updater.syncToMarks(widget.spec.marks, inline, view, i);
12591
12740
  else if (widget.type.side >= 0 && !insideNode) updater.syncToMarks(i == this.node.childCount ? Mark$1.none : this.node.child(i).marks, inline, view, i);
12592
12741
  updater.placeWidget(widget, view, off);
12593
12742
  }, (child, outerDeco, innerDeco, i) => {
12594
12743
  updater.syncToMarks(child.marks, inline, view, i);
12744
+ if (atBufferPos && child.isAtom && !child.isText) updater.addHackNode("IMG", updater.top);
12595
12745
  let compIndex;
12596
12746
  if (updater.findNodeMatch(child, outerDeco, innerDeco, i));
12597
12747
  else if (compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view));
12598
12748
  else if (updater.updateNextNode(child, outerDeco, innerDeco, view, i, off));
12599
12749
  else updater.addNode(child, outerDeco, innerDeco, view, off);
12600
12750
  off += child.nodeSize;
12751
+ if (addBuffers) atBufferPos = child.isAtom && !child.isText;
12601
12752
  });
12602
12753
  updater.syncToMarks([], inline, view, 0);
12603
12754
  if (this.node.isTextblock) updater.addTextblockHacks();
@@ -12654,7 +12805,7 @@ window.__ModuleLoader__.load({
12654
12805
  }
12655
12806
  updateOuterDeco(outerDeco) {
12656
12807
  if (sameOuterDeco(outerDeco, this.outerDeco)) return;
12657
- let needsWrap = this.nodeDOM.nodeType != 1;
12808
+ let needsWrap = !isElt(this.nodeDOM);
12658
12809
  let oldDOM = this.dom;
12659
12810
  this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
12660
12811
  if (this.dom != oldDOM) {
@@ -12664,13 +12815,13 @@ window.__ModuleLoader__.load({
12664
12815
  this.outerDeco = outerDeco;
12665
12816
  }
12666
12817
  selectNode() {
12667
- if (this.nodeDOM.nodeType == 1) {
12818
+ if (isElt(this.nodeDOM)) {
12668
12819
  this.nodeDOM.classList.add("ProseMirror-selectednode");
12669
12820
  if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.draggable = true;
12670
12821
  }
12671
12822
  }
12672
12823
  deselectNode() {
12673
- if (this.nodeDOM.nodeType == 1) {
12824
+ if (isElt(this.nodeDOM)) {
12674
12825
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
12675
12826
  if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.removeAttribute("draggable");
12676
12827
  }
@@ -12738,7 +12889,7 @@ window.__ModuleLoader__.load({
12738
12889
  return this.node.text == text;
12739
12890
  }
12740
12891
  };
12741
- var TrailingHackViewDesc = class extends ViewDesc {
12892
+ var BufferHackViewDesc = class extends ViewDesc {
12742
12893
  parseRule() {
12743
12894
  return { ignore: true };
12744
12895
  }
@@ -12874,7 +13025,7 @@ window.__ModuleLoader__.load({
12874
13025
  }
12875
13026
  }
12876
13027
  function applyOuterDeco(dom, deco, node) {
12877
- return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1));
13028
+ return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, !isElt(dom)));
12878
13029
  }
12879
13030
  function sameOuterDeco(a, b) {
12880
13031
  if (a.length != b.length) return false;
@@ -13064,14 +13215,14 @@ window.__ModuleLoader__.load({
13064
13215
  dom.alt = "";
13065
13216
  }
13066
13217
  if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak";
13067
- let hack = new TrailingHackViewDesc(this.top, [], dom, null);
13218
+ let hack = new BufferHackViewDesc(this.top, [], dom, null);
13068
13219
  if (parent != this.top) parent.children.push(hack);
13069
13220
  else parent.children.splice(this.index++, 0, hack);
13070
13221
  this.changed = true;
13071
13222
  }
13072
13223
  }
13073
13224
  isLocked(node) {
13074
- return this.lock && (node == this.lock || node.nodeType == 1 && node.contains(this.lock.parentNode));
13225
+ return this.lock && (node == this.lock || isElt(node) && node.contains(this.lock.parentNode));
13075
13226
  }
13076
13227
  };
13077
13228
  function preMatch(frag, parentDesc) {
@@ -13215,10 +13366,15 @@ window.__ModuleLoader__.load({
13215
13366
  if (selectionCollapsed(domSel)) {
13216
13367
  anchor = head;
13217
13368
  while (nearestDesc && !nearestDesc.node) nearestDesc = nearestDesc.parent;
13218
- let nearestDescNode = nearestDesc.node;
13219
- if (nearestDesc && nearestDescNode.isAtom && NodeSelection.isSelectable(nearestDescNode) && nearestDesc.parent && !(nearestDescNode.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
13369
+ if (nearestDesc && nearestDesc.node.isAtom && NodeSelection.isSelectable(nearestDesc.node) && nearestDesc.parent && !(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
13220
13370
  let pos = nearestDesc.posBefore;
13221
13371
  selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
13372
+ } else if (gecko && origin == "key" && head > view.state.selection.to && isElt(domSel.focusNode) && domSel.focusOffset == domSel.focusNode.childNodes.length && nearestDesc && nearestDesc.posAtStart > view.state.selection.to) for (let scan = domSel.focusNode;; scan = scan.parentNode) {
13373
+ if (getComputedStyle(scan).overflow != "visible") {
13374
+ selection = Selection.findFrom(doc.resolve(nearestDesc.posAtStart), 1);
13375
+ break;
13376
+ }
13377
+ if (scan == nearestDesc.dom || scan.nextSibling || !scan.parentNode || !isElt(scan.parentNode)) break;
13222
13378
  }
13223
13379
  } else {
13224
13380
  if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {
@@ -13356,7 +13512,7 @@ window.__ModuleLoader__.load({
13356
13512
  let sel = view.domSelectionRange();
13357
13513
  if (!sel.anchorNode) return false;
13358
13514
  try {
13359
- return view.dom.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode) && (view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));
13515
+ return contains(view.dom, sel.anchorNode) && (view.editable || contains(view.dom, sel.focusNode));
13360
13516
  } catch (_) {
13361
13517
  return false;
13362
13518
  }
@@ -13389,14 +13545,13 @@ window.__ModuleLoader__.load({
13389
13545
  let next = moveSelectionBlock(view.state, dir);
13390
13546
  if (next && next instanceof NodeSelection) return apply$2(view, next);
13391
13547
  return false;
13392
- } else if (!(mac$2 && mods.indexOf("m") > -1)) {
13548
+ } else if (!mac$2 || mods.indexOf("m") < 0) {
13393
13549
  let $head = sel.$head, node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter, desc;
13394
13550
  if (!node || node.isText) return false;
13395
13551
  let nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;
13396
13552
  if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;
13397
13553
  if (NodeSelection.isSelectable(node)) return apply$2(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));
13398
- else if (webkit) return apply$2(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
13399
- else return false;
13554
+ else return apply$2(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
13400
13555
  }
13401
13556
  } else if (sel instanceof NodeSelection && sel.node.isInline) return apply$2(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
13402
13557
  else {
@@ -13405,12 +13560,9 @@ window.__ModuleLoader__.load({
13405
13560
  return false;
13406
13561
  }
13407
13562
  }
13408
- function nodeLen(node) {
13409
- return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
13410
- }
13411
13563
  function isIgnorable(dom, dir) {
13412
13564
  let desc = dom.pmViewDesc;
13413
- return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR");
13565
+ return desc ? desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR") : isElt(dom) && dom.contentEditable == "false";
13414
13566
  }
13415
13567
  function skipIgnoredNodes(view, dir) {
13416
13568
  return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);
@@ -13420,19 +13572,18 @@ window.__ModuleLoader__.load({
13420
13572
  let node = sel.focusNode, offset = sel.focusOffset;
13421
13573
  if (!node) return;
13422
13574
  let moveNode, moveOffset, force = false;
13423
- if (gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset], -1)) force = true;
13424
- for (;;) if (offset > 0) if (node.nodeType != 1) break;
13425
- else {
13575
+ if (gecko && isElt(node) && offset < nodeSize(node) && isIgnorable(node.childNodes[offset], -1)) force = true;
13576
+ for (;;) if (offset > 0) {
13577
+ if (!isElt(node)) break;
13426
13578
  let before = node.childNodes[offset - 1];
13427
13579
  if (isIgnorable(before, -1)) {
13428
13580
  moveNode = node;
13429
13581
  moveOffset = --offset;
13430
- } else if (before.nodeType == 3) {
13582
+ } else if (isText(before)) {
13431
13583
  node = before;
13432
13584
  offset = node.nodeValue.length;
13433
13585
  } else break;
13434
- }
13435
- else if (isBlockNode(node)) break;
13586
+ } else if (isBlockNode(node)) break;
13436
13587
  else {
13437
13588
  let prev = node.previousSibling;
13438
13589
  while (prev && isIgnorable(prev, -1)) {
@@ -13446,7 +13597,7 @@ window.__ModuleLoader__.load({
13446
13597
  offset = 0;
13447
13598
  } else {
13448
13599
  node = prev;
13449
- offset = nodeLen(node);
13600
+ offset = nodeSize(node);
13450
13601
  }
13451
13602
  }
13452
13603
  if (force) setSelFocus(view, node, offset);
@@ -13456,10 +13607,10 @@ window.__ModuleLoader__.load({
13456
13607
  let sel = view.domSelectionRange();
13457
13608
  let node = sel.focusNode, offset = sel.focusOffset;
13458
13609
  if (!node) return;
13459
- let len = nodeLen(node);
13610
+ let len = nodeSize(node);
13460
13611
  let moveNode, moveOffset;
13461
13612
  for (;;) if (offset < len) {
13462
- if (node.nodeType != 1) break;
13613
+ if (!isElt(node)) break;
13463
13614
  let after = node.childNodes[offset];
13464
13615
  if (isIgnorable(after, 1)) {
13465
13616
  moveNode = node;
@@ -13480,7 +13631,7 @@ window.__ModuleLoader__.load({
13480
13631
  } else {
13481
13632
  node = next;
13482
13633
  offset = 0;
13483
- len = nodeLen(node);
13634
+ len = nodeSize(node);
13484
13635
  }
13485
13636
  }
13486
13637
  if (moveNode) setSelFocus(view, moveNode, moveOffset);
@@ -13496,8 +13647,8 @@ window.__ModuleLoader__.load({
13496
13647
  }
13497
13648
  while (node && offset < node.childNodes.length) {
13498
13649
  let next = node.childNodes[offset];
13499
- if (next.nodeType == 3) return next;
13500
- if (next.nodeType == 1 && next.contentEditable == "false") break;
13650
+ if (isText(next)) return next;
13651
+ if (isElt(next) && next.contentEditable == "false") break;
13501
13652
  node = next;
13502
13653
  offset = 0;
13503
13654
  }
@@ -13509,14 +13660,14 @@ window.__ModuleLoader__.load({
13509
13660
  }
13510
13661
  while (node && offset) {
13511
13662
  let next = node.childNodes[offset - 1];
13512
- if (next.nodeType == 3) return next;
13513
- if (next.nodeType == 1 && next.contentEditable == "false") break;
13663
+ if (isText(next)) return next;
13664
+ if (isElt(next) && next.contentEditable == "false") break;
13514
13665
  node = next;
13515
13666
  offset = node.childNodes.length;
13516
13667
  }
13517
13668
  }
13518
13669
  function setSelFocus(view, node, offset) {
13519
- if (node.nodeType != 3) {
13670
+ if (!isText(node)) {
13520
13671
  let before, after;
13521
13672
  if (after = textNodeAfter(node, offset)) {
13522
13673
  node = after;
@@ -13526,15 +13677,13 @@ window.__ModuleLoader__.load({
13526
13677
  offset = before.nodeValue.length;
13527
13678
  }
13528
13679
  }
13529
- let sel = view.domSelection();
13680
+ let sel = view.domSelection(), range = view.domSelectionRange();
13530
13681
  if (!sel) return;
13531
- if (selectionCollapsed(sel)) {
13532
- let range = document.createRange();
13533
- range.setEnd(node, offset);
13534
- range.setStart(node, offset);
13535
- sel.removeAllRanges();
13536
- sel.addRange(range);
13537
- } else if (sel.extend) sel.extend(node, offset);
13682
+ if (selectionCollapsed(range)) sel.collapse(node, offset);
13683
+ else if (sel.extend) {
13684
+ sel.collapse(range.anchorNode, range.anchorOffset);
13685
+ sel.extend(node, offset);
13686
+ }
13538
13687
  view.domObserver.setCurSelection();
13539
13688
  let { state } = view;
13540
13689
  setTimeout(() => {
@@ -13556,7 +13705,12 @@ window.__ModuleLoader__.load({
13556
13705
  if (mid > coords.top && mid < coords.bottom && Math.abs(after.left - coords.left) > 1) return after.left > coords.left ? "ltr" : "rtl";
13557
13706
  }
13558
13707
  }
13559
- return getComputedStyle(view.dom).direction == "rtl" ? "rtl" : "ltr";
13708
+ let block = view.dom;
13709
+ for (let d = $pos.depth; d > 0; d--) if ($pos.node(d).isBlock) {
13710
+ block = view.nodeDOM($pos.before(d)) || block;
13711
+ break;
13712
+ }
13713
+ return getComputedStyle(block).direction == "rtl" ? "rtl" : "ltr";
13560
13714
  }
13561
13715
  function selectVertically(view, dir, mods) {
13562
13716
  let sel = view.state.selection;
@@ -13598,7 +13752,7 @@ window.__ModuleLoader__.load({
13598
13752
  function safariDownArrowBug(view) {
13599
13753
  if (!safari || view.state.selection.$head.parentOffset > 0) return false;
13600
13754
  let { focusNode, focusOffset } = view.domSelectionRange();
13601
- if (focusNode && focusNode.nodeType == 1 && focusOffset == 0 && focusNode.firstChild && focusNode.firstChild.contentEditable == "false") {
13755
+ if (focusNode && isElt(focusNode) && focusOffset == 0 && focusNode.firstChild && isElt(focusNode.firstChild) && focusNode.firstChild.contentEditable == "false") {
13602
13756
  let child = focusNode.firstChild;
13603
13757
  switchEditable(view, child, "true");
13604
13758
  setTimeout(() => switchEditable(view, child, "false"), 20);
@@ -13645,7 +13799,7 @@ window.__ModuleLoader__.load({
13645
13799
  let doc = detachedDoc(), wrap = doc.createElement("div");
13646
13800
  wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
13647
13801
  let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
13648
- while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
13802
+ while (firstChild && isElt(firstChild) && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
13649
13803
  for (let i = needsWrap.length - 1; i >= 0; i--) {
13650
13804
  let wrapper = doc.createElement(needsWrap[i]);
13651
13805
  while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
@@ -13654,7 +13808,7 @@ window.__ModuleLoader__.load({
13654
13808
  }
13655
13809
  firstChild = wrap.firstChild;
13656
13810
  }
13657
- if (firstChild && firstChild.nodeType == 1) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
13811
+ if (firstChild && isElt(firstChild)) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
13658
13812
  return {
13659
13813
  dom: wrap,
13660
13814
  text: view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n"),
@@ -13699,7 +13853,7 @@ window.__ModuleLoader__.load({
13699
13853
  let sliceData = contextNode && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(contextNode.getAttribute("data-pm-slice") || "");
13700
13854
  if (sliceData && sliceData[3]) for (let i = +sliceData[3]; i > 0; i--) {
13701
13855
  let child = dom.firstChild;
13702
- while (child && child.nodeType != 1) child = child.nextSibling;
13856
+ while (child && !isElt(child)) child = child.nextSibling;
13703
13857
  if (!child) break;
13704
13858
  dom = child;
13705
13859
  }
@@ -13804,7 +13958,12 @@ window.__ModuleLoader__.load({
13804
13958
  function maybeWrapTrusted(html) {
13805
13959
  let trustedTypes = window.trustedTypes;
13806
13960
  if (!trustedTypes) return html;
13807
- if (!_policy) _policy = trustedTypes.defaultPolicy || trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
13961
+ if (!_policy) {
13962
+ if (_policy = trustedTypes.defaultPolicy) try {
13963
+ return _policy.createHTML(html);
13964
+ } catch (_a) {}
13965
+ _policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
13966
+ }
13808
13967
  return _policy.createHTML(html);
13809
13968
  }
13810
13969
  function readHTML(html) {
@@ -13846,7 +14005,11 @@ window.__ModuleLoader__.load({
13846
14005
  for (let i = array.length - 2; i >= 0; i -= 2) {
13847
14006
  let type = schema.nodes[array[i]];
13848
14007
  if (!type || type.hasRequiredAttrs()) break;
13849
- content = Fragment.from(type.create(array[i + 1], content));
14008
+ try {
14009
+ content = Fragment.from(type.create(array[i + 1], content));
14010
+ } catch (e) {
14011
+ break;
14012
+ }
13850
14013
  openStart++;
13851
14014
  openEnd++;
13852
14015
  }
@@ -13864,6 +14027,7 @@ window.__ModuleLoader__.load({
13864
14027
  this.mouseDown = null;
13865
14028
  this.lastKeyCode = null;
13866
14029
  this.lastKeyCodeTime = 0;
14030
+ this.lastKeyDispatched = false;
13867
14031
  this.lastClick = {
13868
14032
  time: 0,
13869
14033
  x: 0,
@@ -13932,12 +14096,20 @@ window.__ModuleLoader__.load({
13932
14096
  function dispatchEvent(view, event) {
13933
14097
  if (!runCustomHandler(view, event) && handlers[event.type] && (view.editable || !(event.type in editHandlers))) handlers[event.type](view, event);
13934
14098
  }
14099
+ function dispatchKey(view, event) {
14100
+ let { input } = view;
14101
+ if (input.lastKeyDispatched || view.composing) return false;
14102
+ input.lastKeyDispatched = true;
14103
+ if (typeof event == "string") event = keyEvent(event == "Backspace" ? 8 : 13, event);
14104
+ return view.someProp("handleKeyDown", (f) => f(view, event));
14105
+ }
13935
14106
  editHandlers.keydown = (view, _event) => {
13936
14107
  let event = _event;
13937
14108
  view.input.shiftKey = event.keyCode == 16 || event.shiftKey;
13938
14109
  if (inOrNearComposition(view)) return;
13939
14110
  view.input.lastKeyCode = event.keyCode;
13940
14111
  view.input.lastKeyCodeTime = Date.now();
14112
+ view.input.lastKeyDispatched = false;
13941
14113
  if (android && chrome && event.keyCode == 13) return;
13942
14114
  if (event.keyCode != 229) view.domObserver.forceFlush();
13943
14115
  if (ios && event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.metaKey) {
@@ -13945,11 +14117,11 @@ window.__ModuleLoader__.load({
13945
14117
  view.input.lastIOSEnter = now;
13946
14118
  view.input.lastIOSEnterFallbackTimeout = setTimeout(() => {
13947
14119
  if (view.input.lastIOSEnter == now) {
13948
- view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")));
14120
+ dispatchKey(view, "Enter");
13949
14121
  view.input.lastIOSEnter = 0;
13950
14122
  }
13951
14123
  }, 200);
13952
- } else if (view.someProp("handleKeyDown", (f) => f(view, event)) || captureKeyDown(view, event)) event.preventDefault();
14124
+ } else if (dispatchKey(view, event) || captureKeyDown(view, event)) event.preventDefault();
13953
14125
  else setSelectionOrigin(view, "key");
13954
14126
  };
13955
14127
  editHandlers.keyup = (view, event) => {
@@ -13990,14 +14162,14 @@ window.__ModuleLoader__.load({
13990
14162
  if (!view.focused) view.focus();
13991
14163
  if (view.state.selection.eq(selection)) return;
13992
14164
  let tr = view.state.tr.setSelection(selection);
13993
- if (origin == "pointer") tr.setMeta("pointer", true);
14165
+ tr.setMeta("pointer", true);
13994
14166
  view.dispatch(tr);
13995
14167
  }
13996
14168
  function selectClickedLeaf(view, inside) {
13997
14169
  if (inside == -1) return false;
13998
14170
  let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
13999
14171
  if (node && node.isAtom && NodeSelection.isSelectable(node)) {
14000
- updateSelection(view, new NodeSelection($pos), "pointer");
14172
+ updateSelection(view, new NodeSelection($pos));
14001
14173
  return true;
14002
14174
  }
14003
14175
  return false;
@@ -14016,7 +14188,7 @@ window.__ModuleLoader__.load({
14016
14188
  }
14017
14189
  }
14018
14190
  if (selectAt != null) {
14019
- updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
14191
+ updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
14020
14192
  return true;
14021
14193
  } else return false;
14022
14194
  }
@@ -14033,7 +14205,7 @@ window.__ModuleLoader__.load({
14033
14205
  if (event.button != 0) return false;
14034
14206
  let selection = selectionForTripleClick(view, inside, true), doc = view.state.doc;
14035
14207
  if (!selection) return false;
14036
- updateSelection(view, selection, "pointer");
14208
+ updateSelection(view, selection);
14037
14209
  if (selection instanceof TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);
14038
14210
  return true;
14039
14211
  }
@@ -14119,7 +14291,7 @@ window.__ModuleLoader__.load({
14119
14291
  }
14120
14292
  const target = flushed ? null : event.target;
14121
14293
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
14122
- this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
14294
+ this.target = targetDesc && isElt(targetDesc.nodeDOM) ? targetDesc.nodeDOM : null;
14123
14295
  let { selection } = view.state;
14124
14296
  if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)) this.mightDrag = {
14125
14297
  node: targetNode,
@@ -14158,7 +14330,7 @@ window.__ModuleLoader__.load({
14158
14330
  if (this.allowDefault || !pos) setSelectionOrigin(this.view, "pointer");
14159
14331
  else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) event.preventDefault();
14160
14332
  else if (event.button == 0 && (this.flushed || safari && this.mightDrag && !this.mightDrag.node.isAtom || chrome && !this.view.state.selection.visible && Math.min(Math.abs(pos.pos - this.view.state.selection.from), Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
14161
- updateSelection(this.view, Selection.near(this.view.state.doc.resolve(pos.pos)), "pointer");
14333
+ updateSelection(this.view, Selection.near(this.view.state.doc.resolve(pos.pos)));
14162
14334
  event.preventDefault();
14163
14335
  } else setSelectionOrigin(this.view, "pointer");
14164
14336
  }
@@ -14194,7 +14366,7 @@ window.__ModuleLoader__.load({
14194
14366
  if (!target) return;
14195
14367
  let { doc } = this.view.state, start = this.startSelection;
14196
14368
  let [anchor, head] = target.from < start.from ? [start.to, target.from] : [start.from, target.to];
14197
- updateSelection(this.view, TextSelection.create(doc, anchor, head), "pointer");
14369
+ updateSelection(this.view, TextSelection.create(doc, anchor, head));
14198
14370
  }
14199
14371
  };
14200
14372
  handlers.touchstart = (view) => {
@@ -14220,7 +14392,7 @@ window.__ModuleLoader__.load({
14220
14392
  if (!view.composing) {
14221
14393
  view.domObserver.flush();
14222
14394
  let { state } = view, $pos = state.selection.$to;
14223
- if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
14395
+ if (state.selection instanceof TextSelection && state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
14224
14396
  view.markCursor = view.state.storedMarks || $pos.marks();
14225
14397
  endComposition(view, true);
14226
14398
  view.markCursor = null;
@@ -14228,10 +14400,10 @@ window.__ModuleLoader__.load({
14228
14400
  endComposition(view, !state.selection.empty);
14229
14401
  if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
14230
14402
  let sel = view.domSelectionRange();
14231
- for (let node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0;) {
14403
+ for (let node = sel.focusNode, offset = sel.focusOffset; node && isElt(node) && offset != 0;) {
14232
14404
  let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
14233
14405
  if (!before) break;
14234
- if (before.nodeType == 3) {
14406
+ if (isText(before)) {
14235
14407
  let sel = view.domSelection();
14236
14408
  if (sel) sel.collapse(before, before.nodeValue.length);
14237
14409
  break;
@@ -14248,9 +14420,9 @@ window.__ModuleLoader__.load({
14248
14420
  };
14249
14421
  function selectionBeforeUneditable(view) {
14250
14422
  let { focusNode, focusOffset } = view.domSelectionRange();
14251
- if (!focusNode || focusNode.nodeType != 1 || focusOffset >= focusNode.childNodes.length) return false;
14423
+ if (!focusNode || !isElt(focusNode) || focusOffset >= focusNode.childNodes.length) return false;
14252
14424
  let next = focusNode.childNodes[focusOffset];
14253
- return next.nodeType == 1 && next.contentEditable == "false";
14425
+ return isElt(next) && next.contentEditable == "false";
14254
14426
  }
14255
14427
  editHandlers.compositionend = (view, event) => {
14256
14428
  if (view.composing) {
@@ -14403,7 +14575,7 @@ window.__ModuleLoader__.load({
14403
14575
  let node;
14404
14576
  if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof NodeSelection ? sel.to - 1 : sel.to));
14405
14577
  else if (mouseDown && mouseDown.mightDrag) node = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
14406
- else if (event.target && event.target.nodeType == 1) {
14578
+ else if (event.target && isElt(event.target)) {
14407
14579
  let desc = view.docView.nearestDesc(event.target, true);
14408
14580
  if (desc && desc.node.type.spec.draggable && desc != view.docView) node = NodeSelection.create(view.state.doc, desc.posBefore);
14409
14581
  }
@@ -14476,9 +14648,14 @@ window.__ModuleLoader__.load({
14476
14648
  view.dom.classList.add("ProseMirror-focused");
14477
14649
  view.domObserver.start();
14478
14650
  view.focused = true;
14479
- setTimeout(() => {
14480
- if (view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq(view.domSelectionRange())) selectionToDOM(view);
14481
- }, 20);
14651
+ let startSel = view.domSelectionRange();
14652
+ if (!view.domObserver.currentSelection.eq(startSel)) {
14653
+ let { focusNode, focusOffset } = startSel;
14654
+ setTimeout(() => {
14655
+ let newSel = view.domSelectionRange();
14656
+ if (newSel.focusNode == focusNode && newSel.focusOffset == focusOffset && view.docView && view.hasFocus()) selectionToDOM(view);
14657
+ }, 20);
14658
+ }
14482
14659
  }
14483
14660
  };
14484
14661
  handlers.blur = (view, _event) => {
@@ -14496,10 +14673,10 @@ window.__ModuleLoader__.load({
14496
14673
  view.domObserver.flushSoon();
14497
14674
  let { domChangeCount } = view.input;
14498
14675
  setTimeout(() => {
14499
- if (view.input.domChangeCount != domChangeCount) return;
14676
+ if (view.input.domChangeCount != domChangeCount || view.domObserver.pendingRecords().length) return;
14500
14677
  view.dom.blur();
14501
14678
  view.focus();
14502
- if (view.someProp("handleKeyDown", (f) => f(view, keyEvent(8, "Backspace")))) return;
14679
+ if (dispatchKey(view, "Backspace")) return;
14503
14680
  let { $cursor } = view.state.selection;
14504
14681
  if ($cursor && $cursor.pos > 0) view.dispatch(view.state.tr.delete($cursor.pos - 1, $cursor.pos).scrollIntoView());
14505
14682
  }, 50);
@@ -14512,6 +14689,22 @@ window.__ModuleLoader__.load({
14512
14689
  for (let p in b) if (!(p in a)) return false;
14513
14690
  return true;
14514
14691
  }
14692
+ var FragmentCursor = class {
14693
+ constructor(frag) {
14694
+ this.frag = frag;
14695
+ this.index = 0;
14696
+ this.off = 0;
14697
+ }
14698
+ nodeAt(off) {
14699
+ while (this.off <= off && this.index < this.frag.childCount) {
14700
+ let next = this.frag.child(this.index);
14701
+ if (this.off == off) return next;
14702
+ this.off += next.nodeSize;
14703
+ this.index++;
14704
+ }
14705
+ return null;
14706
+ }
14707
+ };
14515
14708
  var WidgetType = class WidgetType {
14516
14709
  constructor(toDOM, spec) {
14517
14710
  this.toDOM = toDOM;
@@ -14565,9 +14758,9 @@ window.__ModuleLoader__.load({
14565
14758
  if (to.deleted || to.pos <= from.pos) return null;
14566
14759
  return new Decoration(from.pos - offset, to.pos - offset, this);
14567
14760
  }
14568
- valid(node, span) {
14569
- let { index, offset } = node.content.findIndex(span.from), child;
14570
- return offset == span.from && !(child = node.child(index)).isText && offset + child.nodeSize == span.to;
14761
+ valid(node, span, cursor) {
14762
+ let found = cursor.nodeAt(span.from);
14763
+ return !!found && !found.isText && span.from + found.nodeSize == span.to;
14571
14764
  }
14572
14765
  eq(other) {
14573
14766
  return this == other || other instanceof NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);
@@ -14712,10 +14905,13 @@ window.__ModuleLoader__.load({
14712
14905
  */
14713
14906
  mapInner(mapping, node, offset, oldOffset, options) {
14714
14907
  let newLocal;
14715
- for (let i = 0; i < this.local.length; i++) {
14716
- let mapped = this.local[i].map(mapping, offset, oldOffset);
14717
- if (mapped && mapped.type.valid(node, mapped)) (newLocal || (newLocal = [])).push(mapped);
14718
- else if (options.onRemove) options.onRemove(this.local[i].spec);
14908
+ if (this.local.length) {
14909
+ let cur = new FragmentCursor(node.content);
14910
+ for (let i = 0; i < this.local.length; i++) {
14911
+ let mapped = this.local[i].map(mapping, offset, oldOffset);
14912
+ if (mapped && mapped.type.valid(node, mapped, cur)) (newLocal || (newLocal = [])).push(mapped);
14913
+ else if (options.onRemove) options.onRemove(this.local[i].spec);
14914
+ }
14719
14915
  }
14720
14916
  if (this.children.length) return mapChildren(this.children, newLocal || [], mapping, node, offset, oldOffset, options);
14721
14917
  else return newLocal ? new DecorationSet(newLocal.sort(byPos), none) : empty;
@@ -14743,7 +14939,10 @@ window.__ModuleLoader__.load({
14743
14939
  childIndex += 3;
14744
14940
  });
14745
14941
  let local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset);
14746
- for (let i = 0; i < local.length; i++) if (!local[i].type.valid(doc, local[i])) local.splice(i--, 1);
14942
+ if (local.length) {
14943
+ let cur = new FragmentCursor(doc.content);
14944
+ for (let i = 0; i < local.length; i++) if (!local[i].type.valid(doc, local[i], cur)) local.splice(i--, 1);
14945
+ }
14747
14946
  return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children);
14748
14947
  }
14749
14948
  /**
@@ -15005,9 +15204,12 @@ window.__ModuleLoader__.load({
15005
15204
  }
15006
15205
  });
15007
15206
  let locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset).sort(byPos);
15008
- for (let i = 0; i < locals.length; i++) if (!locals[i].type.valid(node, locals[i])) {
15009
- if (options.onRemove) options.onRemove(locals[i].spec);
15010
- locals.splice(i--, 1);
15207
+ if (locals.length) {
15208
+ let cur = new FragmentCursor(node.content);
15209
+ for (let i = 0; i < locals.length; i++) if (!locals[i].type.valid(node, locals[i], cur)) {
15210
+ if (options.onRemove) options.onRemove(locals[i].spec);
15211
+ locals.splice(i--, 1);
15212
+ }
15011
15213
  }
15012
15214
  return locals.length || children.length ? new DecorationSet(locals, children) : empty;
15013
15215
  }
@@ -15176,7 +15378,7 @@ window.__ModuleLoader__.load({
15176
15378
  let desc = container && this.view.docView.nearestDesc(container);
15177
15379
  if (desc && desc.ignoreMutation({
15178
15380
  type: "selection",
15179
- target: container.nodeType == 3 ? container.parentNode : container
15381
+ target: isText(container) ? container.parentNode : container
15180
15382
  })) {
15181
15383
  this.setCurSelection();
15182
15384
  return true;
@@ -15191,8 +15393,11 @@ window.__ModuleLoader__.load({
15191
15393
  if (!view.docView || this.flushingSoon > -1) return;
15192
15394
  let mutations = this.pendingRecords();
15193
15395
  if (mutations.length) this.queue = [];
15194
- let sel = view.domSelectionRange();
15195
- let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(view) && !this.ignoreSelectionChange(sel);
15396
+ let selRange, newSel = false;
15397
+ if (!this.suppressingSelectionUpdates && hasFocusAndSelection(view)) {
15398
+ selRange = view.domSelectionRange();
15399
+ newSel = !this.currentSelection.eq(selRange) && !this.ignoreSelectionChange(selRange);
15400
+ }
15196
15401
  let from = -1, to = -1, typeOver = false, added = [];
15197
15402
  if (view.editable) for (let i = 0; i < mutations.length; i++) {
15198
15403
  let result = this.registerMutation(mutations[i], added);
@@ -15205,7 +15410,7 @@ window.__ModuleLoader__.load({
15205
15410
  if (added.some((n) => n.nodeName == "BR") && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some((m) => m.type == "childList" && m.removedNodes.length))) {
15206
15411
  for (let node of added) if (node.nodeName == "BR" && node.parentNode) {
15207
15412
  let after = node.nextSibling;
15208
- while (after && after.nodeType == 1) {
15413
+ while (after && isElt(after)) {
15209
15414
  if (after.contentEditable == "false") {
15210
15415
  node.parentNode.removeChild(node);
15211
15416
  break;
@@ -15228,10 +15433,10 @@ window.__ModuleLoader__.load({
15228
15433
  }
15229
15434
  }
15230
15435
  let readSel = null;
15231
- if (from < 0 && newSel && view.input.lastFocus > Date.now() - 200 && Math.max(view.input.lastTouch, view.input.lastClick.time) < Date.now() - 300 && selectionCollapsed(sel) && (readSel = selectionFromDOM(view)) && readSel.eq(Selection.near(view.state.doc.resolve(0), 1))) {
15436
+ if (from < 0 && newSel && view.input.lastFocus > Date.now() - 200 && Math.max(view.input.lastTouch, view.input.lastClick.time) < Date.now() - 300 && selectionCollapsed(selRange) && (readSel = selectionFromDOM(view)) && readSel.eq(Selection.near(view.state.doc.resolve(0), 1))) {
15232
15437
  view.input.lastFocus = 0;
15233
15438
  selectionToDOM(view);
15234
- this.currentSelection.set(sel);
15439
+ this.currentSelection.set(selRange);
15235
15440
  view.scrollToSelection();
15236
15441
  } else if (from > -1 || newSel) {
15237
15442
  if (from > -1) {
@@ -15244,8 +15449,8 @@ window.__ModuleLoader__.load({
15244
15449
  }
15245
15450
  this.handleDOMChange(from, to, typeOver, added);
15246
15451
  if (view.docView && view.docView.dirty) view.updateState(view.state);
15247
- else if (!this.currentSelection.eq(sel)) selectionToDOM(view);
15248
- this.currentSelection.set(sel);
15452
+ else if (selRange && !this.currentSelection.eq(selRange)) selectionToDOM(view);
15453
+ if (selRange) this.currentSelection.set(selRange);
15249
15454
  }
15250
15455
  }
15251
15456
  registerMutation(mut, added) {
@@ -15257,7 +15462,7 @@ window.__ModuleLoader__.load({
15257
15462
  for (let i = 0; i < mut.addedNodes.length; i++) {
15258
15463
  let node = mut.addedNodes[i];
15259
15464
  added.push(node);
15260
- if (node.nodeType == 3) this.lastChangedTextNode = node;
15465
+ if (isText(node)) this.lastChangedTextNode = node;
15261
15466
  }
15262
15467
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return {
15263
15468
  from: desc.posBefore,
@@ -15356,7 +15561,7 @@ window.__ModuleLoader__.load({
15356
15561
  let parent = nextCell;
15357
15562
  for (;;) {
15358
15563
  let first = parent.firstChild;
15359
- if (!first || first.nodeType != 1 || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName)) break;
15564
+ if (!first || !isElt(first) || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName)) break;
15360
15565
  parent = first;
15361
15566
  }
15362
15567
  parent.insertBefore(node, parent.firstChild);
@@ -15369,7 +15574,7 @@ window.__ModuleLoader__.load({
15369
15574
  let domSel = view.domSelectionRange();
15370
15575
  let find;
15371
15576
  let anchor = domSel.anchorNode;
15372
- if (anchor && view.dom.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {
15577
+ if (anchor && contains(view.dom, anchor)) {
15373
15578
  find = [{
15374
15579
  node: anchor,
15375
15580
  offset: domSel.anchorOffset
@@ -15436,7 +15641,7 @@ window.__ModuleLoader__.load({
15436
15641
  let origin = view.input.lastSelectionTime > Date.now() - 50 ? view.input.lastSelectionOrigin : null;
15437
15642
  let newSel = selectionFromDOM(view, origin);
15438
15643
  if (newSel && !view.state.selection.eq(newSel)) {
15439
- if (chrome && android && view.input.lastKeyCode === 13 && Date.now() - 100 < view.input.lastKeyCodeTime && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) return;
15644
+ if (chrome && android && view.input.lastKeyCode === 13 && Date.now() - 100 < view.input.lastKeyCodeTime && dispatchKey(view, "Enter")) return;
15440
15645
  let tr = view.state.tr.setSelection(newSel);
15441
15646
  if (origin == "pointer") tr.setMeta("pointer", true);
15442
15647
  else if (origin == "key") tr.scrollIntoView();
@@ -15463,7 +15668,7 @@ window.__ModuleLoader__.load({
15463
15668
  view.input.lastKeyCode = null;
15464
15669
  let change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
15465
15670
  if (change) view.input.domChangeCount++;
15466
- if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => n.nodeType == 1 && !isInline.test(n.nodeName)) && (!change || change.endA >= change.endB) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
15671
+ if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => isElt(n) && !isInline.test(n.nodeName)) && (!change || change.endA >= change.endB) && dispatchKey(view, "Enter")) {
15467
15672
  view.input.lastIOSEnter = 0;
15468
15673
  return;
15469
15674
  }
@@ -15499,11 +15704,11 @@ window.__ModuleLoader__.load({
15499
15704
  let $to = parse.doc.resolveNoCache(change.endB - parse.from);
15500
15705
  let $fromA = doc.resolve(change.start);
15501
15706
  let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
15502
- if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
15707
+ if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos)) && dispatchKey(view, "Enter")) {
15503
15708
  view.input.lastIOSEnter = 0;
15504
15709
  return;
15505
15710
  }
15506
- if (view.state.selection.anchor > change.start && looksLikeBackspace(doc, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(8, "Backspace")))) {
15711
+ if (view.state.selection.anchor > change.start && (inlineChange ? change.endA > change.start && change.endB == change.start : looksLikeBlockJoin(doc, change.start, change.endA, $from, $to)) && dispatchKey(view, "Backspace")) {
15507
15712
  if (android && chrome) view.domObserver.suppressSelectionUpdates();
15508
15713
  return;
15509
15714
  }
@@ -15511,11 +15716,7 @@ window.__ModuleLoader__.load({
15511
15716
  if (android && !inlineChange && $from.start() != $to.start() && $to.parentOffset == 0 && $from.depth == $to.depth && parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA) {
15512
15717
  change.endB -= 2;
15513
15718
  $to = parse.doc.resolveNoCache(change.endB - parse.from);
15514
- setTimeout(() => {
15515
- view.someProp("handleKeyDown", function(f) {
15516
- return f(view, keyEvent(13, "Enter"));
15517
- });
15518
- }, 20);
15719
+ setTimeout(() => dispatchKey(view, "Enter"), 20);
15519
15720
  }
15520
15721
  let chFrom = change.start, chTo = change.endA;
15521
15722
  let mkTr = (base) => {
@@ -15574,10 +15775,10 @@ window.__ModuleLoader__.load({
15574
15775
  type
15575
15776
  };
15576
15777
  }
15577
- function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
15778
+ function looksLikeBlockJoin(old, start, end, $newStart, $newEnd) {
15578
15779
  if (end - start <= $newEnd.pos - $newStart.pos || skipClosingAndOpening($newStart, true, false) < $newEnd.pos) return false;
15579
15780
  let $start = old.resolve(start);
15580
- if (!$newStart.parent.isTextblock) {
15781
+ if (!$newStart.parent.inlineContent) {
15581
15782
  let after = $start.nodeAfter;
15582
15783
  return after != null && end == start + after.nodeSize;
15583
15784
  }
@@ -15586,6 +15787,14 @@ window.__ModuleLoader__.load({
15586
15787
  if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) return false;
15587
15788
  return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
15588
15789
  }
15790
+ function looksLikeEnter(content, from, to) {
15791
+ let newTextlines = 0, newLeaves = 0;
15792
+ content.nodesBetween(from, to, (node, pos) => {
15793
+ if (node.isTextblock && pos >= from && pos < to) newTextlines++;
15794
+ else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf) newLeaves++;
15795
+ });
15796
+ return newLeaves == 0 && newTextlines == 1;
15797
+ }
15589
15798
  function skipClosingAndOpening($pos, fromEnd, mayOpen) {
15590
15799
  let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
15591
15800
  while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
@@ -15810,11 +16019,11 @@ window.__ModuleLoader__.load({
15810
16019
  */
15811
16020
  scrollToSelection() {
15812
16021
  let startDOM = this.domSelectionRange().focusNode;
15813
- if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode));
16022
+ if (!startDOM || !contains(this.dom, startDOM));
15814
16023
  else if (this.someProp("handleScrollToSelection", (f) => f(this)));
15815
16024
  else if (this.state.selection instanceof NodeSelection) {
15816
16025
  let target = this.docView.domAfterPos(this.state.selection.from);
15817
- if (target.nodeType == 1) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
16026
+ if (isElt(target)) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
15818
16027
  } else scrollRectIntoView(this, this.coordsAtPos(this.state.selection.head, 1), startDOM);
15819
16028
  }
15820
16029
  destroyPluginViews() {
@@ -16043,7 +16252,7 @@ window.__ModuleLoader__.load({
16043
16252
  @internal
16044
16253
  */
16045
16254
  domSelectionRange() {
16046
- let sel = this.domSelection();
16255
+ let sel = this.dom.isConnected !== false && this.domSelection();
16047
16256
  if (!sel) return {
16048
16257
  focusNode: null,
16049
16258
  focusOffset: 0,
@@ -17133,7 +17342,7 @@ window.__ModuleLoader__.load({
17133
17342
  return Append;
17134
17343
  }(RopeSequence);
17135
17344
  //#endregion
17136
- //#region node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.js
17345
+ //#region node_modules/.pnpm/prosemirror-history@1.5.1/node_modules/prosemirror-history/dist/index.js
17137
17346
  const max_empty_items = 500;
17138
17347
  var Branch = class Branch {
17139
17348
  constructor(items, eventCount) {
@@ -17226,7 +17435,8 @@ window.__ModuleLoader__.load({
17226
17435
  }
17227
17436
  rebased(rebasedTransform, rebasedCount) {
17228
17437
  if (!this.eventCount) return this;
17229
- let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);
17438
+ rebasedCount = Math.min(this.items.length, rebasedCount);
17439
+ let rebasedItems = [], start = this.items.length - rebasedCount;
17230
17440
  let mapping = rebasedTransform.mapping;
17231
17441
  let newUntil = rebasedTransform.steps.length;
17232
17442
  let eventCount = this.eventCount;
@@ -39348,6 +39558,32 @@ window.__ModuleLoader__.load({
39348
39558
  return snippets;
39349
39559
  }
39350
39560
  //#endregion
39561
+ //#region src/ready-admission.ts
39562
+ function hasCompletedCurrentReview(record, kind) {
39563
+ return record.aiRuns.some((run) => run.commit === record.currentCommit && run.kind === kind && run.status === "completed");
39564
+ }
39565
+ function hasVersionConfirmation(record, role) {
39566
+ return record.confirmations.some((item) => item.commit === record.currentCommit && item.role === role && item.scope === "version" && item.status === "active");
39567
+ }
39568
+ /** Shared by workflow guidance and the authoritative Ready write. Checks must come from the current Git body. */
39569
+ function readyAdmission(record, checks) {
39570
+ const activeRun = record.aiRuns.slice().reverse().find((run) => run.commit === record.currentCommit && (run.status === "queued" || run.status === "running"));
39571
+ const engineeringReviewed = hasCompletedCurrentReview(record, "engineering-precheck");
39572
+ const pendingPatches = record.patches.filter((item) => item.baseCommit === record.currentCommit && item.status === "pending");
39573
+ const failedChecks = checks.filter((check) => !check.passed);
39574
+ const productConfirmed = hasVersionConfirmation(record, "product");
39575
+ const engineeringConfirmed = hasVersionConfirmation(record, "engineering");
39576
+ return {
39577
+ activeRun,
39578
+ engineeringReviewed,
39579
+ pendingPatches,
39580
+ failedChecks,
39581
+ productConfirmed,
39582
+ engineeringConfirmed,
39583
+ error: record.stage !== "joint-review" ? "readiness gate is not satisfied" : !record.workspaceId?.trim() ? "review workspace is required" : activeRun ? "current version review is still running" : !engineeringReviewed ? "engineering precheck is required for the current version" : pendingPatches.length > 0 ? "current version has pending patches" : failedChecks.length > 0 ? "readiness gate is not satisfied" : !productConfirmed || !engineeringConfirmed ? "current version needs product and engineering confirmation" : void 0
39584
+ };
39585
+ }
39586
+ //#endregion
39351
39587
  //#region src/client/workflow.ts
39352
39588
  const reviewIsOpen = (status) => ![
39353
39589
  "resolved",
@@ -39358,14 +39594,9 @@ window.__ModuleLoader__.load({
39358
39594
  const blockers = requirement.reviewItems.filter((item) => item.commit === requirement.currentCommit).filter((item) => item.severity === "blocking" && reviewIsOpen(item.status));
39359
39595
  const productBlockers = blockers.filter((item) => item.status !== "joint-review");
39360
39596
  const unanswered = blockers.filter((item) => item.status === "open");
39361
- const currentPatches = requirement.patches.filter((item) => item.baseCommit === requirement.currentCommit && item.status === "pending");
39362
- const currentRuns = requirement.aiRuns.filter((run) => run.commit === requirement.currentCommit);
39363
- const activeRun = currentRuns.slice().reverse().find((run) => ["queued", "running"].includes(run.status));
39364
- const completed = (kind) => currentRuns.some((run) => run.kind === kind && run.status === "completed");
39365
- const productConfirmed = requirement.confirmations.some((item) => item.commit === requirement.currentCommit && item.role === "product" && item.scope === "version" && item.status === "active");
39366
- const engineeringConfirmed = requirement.confirmations.some((item) => item.commit === requirement.currentCommit && item.role === "engineering" && item.scope === "version" && item.status === "active");
39367
- const failedChecks = requirement.readiness.filter((check) => !check.passed);
39368
- if (!requirement.workspaceId) return {
39597
+ const { activeRun, engineeringReviewed, pendingPatches: currentPatches, failedChecks, productConfirmed, engineeringConfirmed } = readyAdmission(requirement, requirement.readiness);
39598
+ const completed = (kind) => hasCompletedCurrentReview(requirement, kind);
39599
+ if (!requirement.workspaceId?.trim()) return {
39369
39600
  eyebrow: "开始前",
39370
39601
  title: "关联需求所在的项目",
39371
39602
  detail: "AI 会从这个项目读取代码、规范和团队知识,关联后不能中途切换。",
@@ -39454,7 +39685,7 @@ window.__ModuleLoader__.load({
39454
39685
  };
39455
39686
  }
39456
39687
  if (requirement.stage === "joint-review") {
39457
- if (!completed("engineering-precheck")) return {
39688
+ if (!engineeringReviewed) return {
39458
39689
  eyebrow: "产研共审",
39459
39690
  title: "从研发视角检查可实施性",
39460
39691
  detail: "重点检查现有实现、影响范围、兼容性和测试落点。",
@@ -39555,6 +39786,9 @@ window.__ModuleLoader__.load({
39555
39786
  }
39556
39787
  function friendlyActionError(error) {
39557
39788
  return [
39789
+ ["engineering precheck is required for the current version", "需要先完成当前版本的研发检查;正文变更后请重新检查。"],
39790
+ ["current version review is still running", "当前版本的 AI 检查仍在进行,请等待完成后再生成就绪需求。"],
39791
+ ["current version has pending patches", "当前版本还有待审核的正文修改,请先接受或拒绝。"],
39558
39792
  ["product blocking review items remain", "还有阻塞问题未处理,请先完成待澄清事项。"],
39559
39793
  ["product second review is required", "需要先让 AI 根据回复整理并复核正文。"],
39560
39794
  ["product must confirm the current version", "需要产品角色确认当前版本后才能进入产研共审。"],
@@ -46523,265 +46757,265 @@ window.__ModuleLoader__.load({
46523
46757
  document.head.appendChild(tag);
46524
46758
  }
46525
46759
  var workbench_module_css_default = {
46526
- "myWorkSummary": "-kTeaG_myWorkSummary",
46527
- "editorPane": "-kTeaG_editorPane",
46528
- "selectedDecisionOption": "-kTeaG_selectedDecisionOption",
46529
- "diffHeader": "-kTeaG_diffHeader",
46530
- "commentBody": "-kTeaG_commentBody",
46760
+ "versionCopy": "-kTeaG_versionCopy",
46761
+ "reviewDecisionContext": "-kTeaG_reviewDecisionContext",
46762
+ "commentActions": "-kTeaG_commentActions",
46763
+ "rowMenuButton": "-kTeaG_rowMenuButton",
46764
+ "reviewTitle": "-kTeaG_reviewTitle",
46765
+ "insightDialog": "-kTeaG_insightDialog",
46766
+ "mobileCollab": "-kTeaG_mobileCollab",
46767
+ "panelSummary": "-kTeaG_panelSummary",
46768
+ "stage_product-confirmation": "-kTeaG_stage_product-confirmation",
46769
+ "unsaved": "-kTeaG_unsaved",
46770
+ "commentSourceButton": "-kTeaG_commentSourceButton",
46771
+ "entryActive": "-kTeaG_entryActive",
46772
+ "inlineReviewHeadActions": "-kTeaG_inlineReviewHeadActions",
46773
+ "structuredDiff": "-kTeaG_structuredDiff",
46774
+ "documentCommentAnchor": "-kTeaG_documentCommentAnchor",
46775
+ "cardActions": "-kTeaG_cardActions",
46776
+ "insightFilters": "-kTeaG_insightFilters",
46777
+ "decisionSection": "-kTeaG_decisionSection",
46778
+ "decisionEvidenceList": "-kTeaG_decisionEvidenceList",
46779
+ "collabMetric": "-kTeaG_collabMetric",
46780
+ "documentAnchorSelected": "-kTeaG_documentAnchorSelected",
46781
+ "srOnly": "-kTeaG_srOnly",
46531
46782
  "editorTitle": "-kTeaG_editorTitle",
46783
+ "decisionEmpty": "-kTeaG_decisionEmpty",
46784
+ "headerActions": "-kTeaG_headerActions",
46785
+ "checklistMeter": "-kTeaG_checklistMeter",
46786
+ "modal": "-kTeaG_modal",
46787
+ "selectionPromptButtons": "-kTeaG_selectionPromptButtons",
46788
+ "patchImpact": "-kTeaG_patchImpact",
46789
+ "productName": "-kTeaG_productName",
46790
+ "collabStateDirty": "-kTeaG_collabStateDirty",
46791
+ "tabPanel": "-kTeaG_tabPanel",
46792
+ "badges": "-kTeaG_badges",
46793
+ "patchPreview": "-kTeaG_patchPreview",
46794
+ "footer": "-kTeaG_footer",
46795
+ "recordLinkButton": "-kTeaG_recordLinkButton",
46796
+ "documentReviewHighlightBlocking": "-kTeaG_documentReviewHighlightBlocking",
46797
+ "richEditorShell": "-kTeaG_richEditorShell",
46798
+ "diffAdded": "-kTeaG_diffAdded",
46799
+ "versionActions": "-kTeaG_versionActions",
46800
+ "reviewChecklist": "-kTeaG_reviewChecklist",
46532
46801
  "documentAnchorHighlightSelected": "-kTeaG_documentAnchorHighlightSelected",
46533
- "selectionPromptCancel": "-kTeaG_selectionPromptCancel",
46802
+ "activeContext": "-kTeaG_activeContext",
46803
+ "selectedDecisionOption": "-kTeaG_selectedDecisionOption",
46804
+ "collabMetricWarn": "-kTeaG_collabMetricWarn",
46805
+ "diffCollapsed": "-kTeaG_diffCollapsed",
46806
+ "dialogHead": "-kTeaG_dialogHead",
46807
+ "documentButton": "-kTeaG_documentButton",
46808
+ "diffDialog": "-kTeaG_diffDialog",
46809
+ "mobileSpec": "-kTeaG_mobileSpec",
46810
+ "requirementMenu": "-kTeaG_requirementMenu",
46534
46811
  "reviewChecklistBlocking": "-kTeaG_reviewChecklistBlocking",
46535
- "chatError": "-kTeaG_chatError",
46536
- "decisionForm": "-kTeaG_decisionForm",
46537
- "compareColumns": "-kTeaG_compareColumns",
46538
- "selectionPromptSubmit": "-kTeaG_selectionPromptSubmit",
46539
- "reviewDecisionBody": "-kTeaG_reviewDecisionBody",
46540
- "importPreview": "-kTeaG_importPreview",
46812
+ "emptyList": "-kTeaG_emptyList",
46813
+ "notice": "-kTeaG_notice",
46814
+ "titleBlock": "-kTeaG_titleBlock",
46815
+ "iconButton": "-kTeaG_iconButton",
46816
+ "aiMessage": "-kTeaG_aiMessage",
46817
+ "replyComposer": "-kTeaG_replyComposer",
46818
+ "commentThread": "-kTeaG_commentThread",
46819
+ "insightPanel": "-kTeaG_insightPanel",
46820
+ "panelAction": "-kTeaG_panelAction",
46541
46821
  "runHistory": "-kTeaG_runHistory",
46822
+ "chatToggle": "-kTeaG_chatToggle",
46823
+ "decisionModeHint": "-kTeaG_decisionModeHint",
46824
+ "editorCollabBar": "-kTeaG_editorCollabBar",
46825
+ "insightCard": "-kTeaG_insightCard",
46826
+ "mobileViewSwitch": "-kTeaG_mobileViewSwitch",
46827
+ "editorBody": "-kTeaG_editorBody",
46828
+ "pulse": "-kTeaG_pulse",
46829
+ "decisionForm": "-kTeaG_decisionForm",
46542
46830
  "reviewChecklistSettled": "-kTeaG_reviewChecklistSettled",
46543
- "stageDone": "-kTeaG_stageDone",
46544
- "insightActions": "-kTeaG_insightActions",
46545
- "reviewHeader": "-kTeaG_reviewHeader",
46546
- "decisionSection": "-kTeaG_decisionSection",
46547
- "view": "-kTeaG_view",
46548
- "chatMessages": "-kTeaG_chatMessages",
46549
- "insightDialog": "-kTeaG_insightDialog",
46550
- "documentReviewAnchor": "-kTeaG_documentReviewAnchor",
46551
- "stageCurrent": "-kTeaG_stageCurrent",
46552
- "empty": "-kTeaG_empty",
46831
+ "notificationList": "-kTeaG_notificationList",
46832
+ "paneClosed": "-kTeaG_paneClosed",
46833
+ "insightScore": "-kTeaG_insightScore",
46834
+ "runningDot": "-kTeaG_runningDot",
46835
+ "reviewDecisionHeader": "-kTeaG_reviewDecisionHeader",
46836
+ "stage_joint-review": "-kTeaG_stage_joint-review",
46837
+ "backLabel": "-kTeaG_backLabel",
46838
+ "collabBarActions": "-kTeaG_collabBarActions",
46839
+ "collapseChat": "-kTeaG_collapseChat",
46840
+ "quietButton": "-kTeaG_quietButton",
46841
+ "review": "-kTeaG_review",
46842
+ "paneActions": "-kTeaG_paneActions",
46843
+ "documentReviewAnchorSelected": "-kTeaG_documentReviewAnchorSelected",
46844
+ "compareHead": "-kTeaG_compareHead",
46553
46845
  "myWorkList": "-kTeaG_myWorkList",
46554
- "commentThreadSelected": "-kTeaG_commentThreadSelected",
46555
- "decisionResponse": "-kTeaG_decisionResponse",
46556
- "panelAction": "-kTeaG_panelAction",
46557
- "entry": "-kTeaG_entry",
46558
- "selectedDoc": "-kTeaG_selectedDoc",
46559
- "patchImpact": "-kTeaG_patchImpact",
46560
- "discussionPanel": "-kTeaG_discussionPanel",
46561
- "iconButton": "-kTeaG_iconButton",
46562
- "identity": "-kTeaG_identity",
46563
- "diffActions": "-kTeaG_diffActions",
46564
- "richEditor": "-kTeaG_richEditor",
46565
- "commentThreadClosed": "-kTeaG_commentThreadClosed",
46566
- "decisionOptions": "-kTeaG_decisionOptions",
46567
- "requirementSearch": "-kTeaG_requirementSearch",
46846
+ "primaryNav": "-kTeaG_primaryNav",
46568
46847
  "resizer": "-kTeaG_resizer",
46569
- "diffAdded": "-kTeaG_diffAdded",
46570
- "historyGroup": "-kTeaG_historyGroup",
46571
- "threadPills": "-kTeaG_threadPills",
46572
- "editorCollabBar": "-kTeaG_editorCollabBar",
46573
- "topActions": "-kTeaG_topActions",
46574
- "saveButton": "-kTeaG_saveButton",
46848
+ "selectionPromptAbove": "-kTeaG_selectionPromptAbove",
46849
+ "versionCompare": "-kTeaG_versionCompare",
46850
+ "diffHeader": "-kTeaG_diffHeader",
46851
+ "emptyMain": "-kTeaG_emptyMain",
46852
+ "decisionQuestion": "-kTeaG_decisionQuestion",
46853
+ "chatError": "-kTeaG_chatError",
46854
+ "selectionPromptSubmit": "-kTeaG_selectionPromptSubmit",
46855
+ "selectionPrompt": "-kTeaG_selectionPrompt",
46856
+ "identity": "-kTeaG_identity",
46857
+ "decisionTags": "-kTeaG_decisionTags",
46858
+ "commentBody": "-kTeaG_commentBody",
46859
+ "statusDot": "-kTeaG_statusDot",
46860
+ "compareColumns": "-kTeaG_compareColumns",
46861
+ "inlineReviewHead": "-kTeaG_inlineReviewHead",
46862
+ "inlineReviewActions": "-kTeaG_inlineReviewActions",
46863
+ "grid": "-kTeaG_grid",
46864
+ "emptyAside": "-kTeaG_emptyAside",
46865
+ "inlineReviewDetails": "-kTeaG_inlineReviewDetails",
46866
+ "reviewHeader": "-kTeaG_reviewHeader",
46867
+ "decisionAsideHead": "-kTeaG_decisionAsideHead",
46575
46868
  "activeMode": "-kTeaG_activeMode",
46576
- "commentSourceSelected": "-kTeaG_commentSourceSelected",
46577
46869
  "aiConversation": "-kTeaG_aiConversation",
46578
- "mobileDrawerClose": "-kTeaG_mobileDrawerClose",
46579
- "documentAnchorSelected": "-kTeaG_documentAnchorSelected",
46580
- "resizerHidden": "-kTeaG_resizerHidden",
46581
- "footer": "-kTeaG_footer",
46582
- "compareHead": "-kTeaG_compareHead",
46583
- "grid": "-kTeaG_grid",
46584
- "unsaved": "-kTeaG_unsaved",
46585
- "dialogHead": "-kTeaG_dialogHead",
46586
- "quietButton": "-kTeaG_quietButton",
46587
- "workflowEyebrow": "-kTeaG_workflowEyebrow",
46870
+ "dangerText": "-kTeaG_dangerText",
46871
+ "reviewCheckMeta": "-kTeaG_reviewCheckMeta",
46872
+ "commentGlyph": "-kTeaG_commentGlyph",
46873
+ "selectionPromptCancel": "-kTeaG_selectionPromptCancel",
46588
46874
  "reviewCheckStatus": "-kTeaG_reviewCheckStatus",
46875
+ "inlineReviewBody": "-kTeaG_inlineReviewBody",
46876
+ "tabBadge": "-kTeaG_tabBadge",
46877
+ "unreadNotification": "-kTeaG_unreadNotification",
46878
+ "threadPills": "-kTeaG_threadPills",
46879
+ "checklist": "-kTeaG_checklist",
46880
+ "toolbar": "-kTeaG_toolbar",
46881
+ "decisionActions": "-kTeaG_decisionActions",
46882
+ "decisionSource": "-kTeaG_decisionSource",
46883
+ "summaryField": "-kTeaG_summaryField",
46884
+ "emptyPanel": "-kTeaG_emptyPanel",
46885
+ "checkItem": "-kTeaG_checkItem",
46886
+ "patchAccept": "-kTeaG_patchAccept",
46887
+ "requirementRow": "-kTeaG_requirementRow",
46888
+ "replyStack": "-kTeaG_replyStack",
46889
+ "discussionSummary": "-kTeaG_discussionSummary",
46890
+ "reviewDecisionDialog": "-kTeaG_reviewDecisionDialog",
46891
+ "workbench": "-kTeaG_workbench",
46892
+ "reviewDecisionAside": "-kTeaG_reviewDecisionAside",
46893
+ "myWorkButton": "-kTeaG_myWorkButton",
46894
+ "conflictColumns": "-kTeaG_conflictColumns",
46895
+ "taskAssignment": "-kTeaG_taskAssignment",
46896
+ "versionPicker": "-kTeaG_versionPicker",
46897
+ "diffContext": "-kTeaG_diffContext",
46898
+ "conflictDialog": "-kTeaG_conflictDialog",
46899
+ "importPreview": "-kTeaG_importPreview",
46589
46900
  "decisionSourceList": "-kTeaG_decisionSourceList",
46590
- "documentCommentHighlight": "-kTeaG_documentCommentHighlight",
46591
- "documentReviewAnchorBlocking": "-kTeaG_documentReviewAnchorBlocking",
46592
- "legacyWarning": "-kTeaG_legacyWarning",
46901
+ "requirementFilters": "-kTeaG_requirementFilters",
46902
+ "reviewAnchorLayer": "-kTeaG_reviewAnchorLayer",
46903
+ "decisionEvidence": "-kTeaG_decisionEvidence",
46904
+ "inlineReviewSource": "-kTeaG_inlineReviewSource",
46905
+ "insightActions": "-kTeaG_insightActions",
46906
+ "readyPackage": "-kTeaG_readyPackage",
46907
+ "myWorkSummary": "-kTeaG_myWorkSummary",
46908
+ "commentThreadClosed": "-kTeaG_commentThreadClosed",
46909
+ "stageCurrent": "-kTeaG_stageCurrent",
46910
+ "historyGroup": "-kTeaG_historyGroup",
46911
+ "reviewDecisionBody": "-kTeaG_reviewDecisionBody",
46593
46912
  "fileButton": "-kTeaG_fileButton",
46594
- "userMessage": "-kTeaG_userMessage",
46595
- "diffRemoved": "-kTeaG_diffRemoved",
46596
- "execute": "-kTeaG_execute",
46597
- "reviewChecklistAnswered": "-kTeaG_reviewChecklistAnswered",
46598
- "stage_joint-review": "-kTeaG_stage_joint-review",
46599
- "locateSourceButton": "-kTeaG_locateSourceButton",
46600
- "structuredDiff": "-kTeaG_structuredDiff",
46601
- "threadStack": "-kTeaG_threadStack",
46602
- "collabStateRunning": "-kTeaG_collabStateRunning",
46603
- "versionRow": "-kTeaG_versionRow",
46604
- "mobileSpec": "-kTeaG_mobileSpec",
46605
- "reviewChecklistSelected": "-kTeaG_reviewChecklistSelected",
46913
+ "saveButton": "-kTeaG_saveButton",
46914
+ "decisionSectionHead": "-kTeaG_decisionSectionHead",
46915
+ "notificationButton": "-kTeaG_notificationButton",
46916
+ "dialogForm": "-kTeaG_dialogForm",
46917
+ "legacyWarning": "-kTeaG_legacyWarning",
46918
+ "focusMode": "-kTeaG_focusMode",
46919
+ "taskRow": "-kTeaG_taskRow",
46920
+ "header": "-kTeaG_header",
46921
+ "stageRail": "-kTeaG_stageRail",
46922
+ "richEditor": "-kTeaG_richEditor",
46606
46923
  "checkIcon": "-kTeaG_checkIcon",
46924
+ "paneHead": "-kTeaG_paneHead",
46925
+ "workflowEyebrow": "-kTeaG_workflowEyebrow",
46926
+ "decisionSourceHead": "-kTeaG_decisionSourceHead",
46927
+ "documentReviewAnchorBlocking": "-kTeaG_documentReviewAnchorBlocking",
46928
+ "collabStateRunning": "-kTeaG_collabStateRunning",
46607
46929
  "conflictDiffs": "-kTeaG_conflictDiffs",
46608
- "inlineReviewDetails": "-kTeaG_inlineReviewDetails",
46609
- "checkPassed": "-kTeaG_checkPassed",
46610
- "toolbar": "-kTeaG_toolbar",
46611
- "selectionPromptAbove": "-kTeaG_selectionPromptAbove",
46612
- "titleBlock": "-kTeaG_titleBlock",
46613
- "disabledReason": "-kTeaG_disabledReason",
46614
- "collapseChat": "-kTeaG_collapseChat",
46615
- "collabMetricActive": "-kTeaG_collabMetricActive",
46616
- "stage_product-confirmation": "-kTeaG_stage_product-confirmation",
46930
+ "inlineDecisionOptions": "-kTeaG_inlineDecisionOptions",
46931
+ "decisionOptions": "-kTeaG_decisionOptions",
46932
+ "entry": "-kTeaG_entry",
46933
+ "filterChecks": "-kTeaG_filterChecks",
46934
+ "notificationDialog": "-kTeaG_notificationDialog",
46935
+ "mobileDocumentsOpen": "-kTeaG_mobileDocumentsOpen",
46936
+ "checkBlocked": "-kTeaG_checkBlocked",
46937
+ "insightLinks": "-kTeaG_insightLinks",
46938
+ "noticeHidden": "-kTeaG_noticeHidden",
46939
+ "reviewChecklistAnswered": "-kTeaG_reviewChecklistAnswered",
46940
+ "reviewCheckBox": "-kTeaG_reviewCheckBox",
46941
+ "inlineReviewPrompt": "-kTeaG_inlineReviewPrompt",
46942
+ "view": "-kTeaG_view",
46943
+ "editorContext": "-kTeaG_editorContext",
46944
+ "createButton": "-kTeaG_createButton",
46945
+ "reviewSourceSelected": "-kTeaG_reviewSourceSelected",
46946
+ "run": "-kTeaG_run",
46947
+ "collabBarState": "-kTeaG_collabBarState",
46948
+ "mobileDrawerClose": "-kTeaG_mobileDrawerClose",
46949
+ "reviewChecklistSelected": "-kTeaG_reviewChecklistSelected",
46950
+ "readyHead": "-kTeaG_readyHead",
46617
46951
  "reviewCard": "-kTeaG_reviewCard",
46618
- "notificationButton": "-kTeaG_notificationButton",
46619
- "discussionFilters": "-kTeaG_discussionFilters",
46620
- "inlineDecisionForm": "-kTeaG_inlineDecisionForm",
46621
- "notice": "-kTeaG_notice",
46622
- "conflictDialog": "-kTeaG_conflictDialog",
46623
- "inlineReviewHeadActions": "-kTeaG_inlineReviewHeadActions",
46624
- "patchPreview": "-kTeaG_patchPreview",
46625
- "notificationList": "-kTeaG_notificationList",
46626
- "reply": "-kTeaG_reply",
46627
- "taskAssignment": "-kTeaG_taskAssignment",
46952
+ "diffRemoved": "-kTeaG_diffRemoved",
46953
+ "readyPackageHead": "-kTeaG_readyPackageHead",
46628
46954
  "formGrid": "-kTeaG_formGrid",
46629
- "conflictHeader": "-kTeaG_conflictHeader",
46630
- "header": "-kTeaG_header",
46631
- "collabMetricWarn": "-kTeaG_collabMetricWarn",
46632
- "collapseRight": "-kTeaG_collapseRight",
46633
- "taskRow": "-kTeaG_taskRow",
46634
46955
  "commentThreadHead": "-kTeaG_commentThreadHead",
46635
- "paneActions": "-kTeaG_paneActions",
46636
- "stickyActions": "-kTeaG_stickyActions",
46637
- "selectionPrompt": "-kTeaG_selectionPrompt",
46638
- "conflictModal": "-kTeaG_conflictModal",
46639
- "selectionPromptClose": "-kTeaG_selectionPromptClose",
46640
- "requirementRow": "-kTeaG_requirementRow",
46641
- "replyStack": "-kTeaG_replyStack",
46642
- "checklist": "-kTeaG_checklist",
46643
- "dialogForm": "-kTeaG_dialogForm",
46644
- "collabMetric": "-kTeaG_collabMetric",
46645
- "mobileDocumentsTrigger": "-kTeaG_mobileDocumentsTrigger",
46646
- "dangerButton": "-kTeaG_dangerButton",
46647
- "checkBlocked": "-kTeaG_checkBlocked",
46648
- "activeContext": "-kTeaG_activeContext",
46649
- "inlineReviewBody": "-kTeaG_inlineReviewBody",
46650
- "reviewAnchorLayer": "-kTeaG_reviewAnchorLayer",
46651
- "selectionPromptHead": "-kTeaG_selectionPromptHead",
46652
- "inlineReviewSource": "-kTeaG_inlineReviewSource",
46653
- "mobileViewSwitch": "-kTeaG_mobileViewSwitch",
46654
- "patchAccept": "-kTeaG_patchAccept",
46655
- "backLabel": "-kTeaG_backLabel",
46656
- "productName": "-kTeaG_productName",
46657
46956
  "taskQueue": "-kTeaG_taskQueue",
46658
- "inlineReviewPrompt": "-kTeaG_inlineReviewPrompt",
46659
- "stage_ready": "-kTeaG_stage_ready",
46660
- "notificationDialog": "-kTeaG_notificationDialog",
46661
- "commentActions": "-kTeaG_commentActions",
46662
- "filterChecks": "-kTeaG_filterChecks",
46663
- "paneClosed": "-kTeaG_paneClosed",
46664
- "collabBarActions": "-kTeaG_collabBarActions",
46665
- "modal": "-kTeaG_modal",
46666
- "markdownBody": "-kTeaG_markdownBody",
46667
- "decisionEvidenceList": "-kTeaG_decisionEvidenceList",
46668
- "emptyMain": "-kTeaG_emptyMain",
46669
- "primaryNav": "-kTeaG_primaryNav",
46670
- "diffContext": "-kTeaG_diffContext",
46671
- "contextNav": "-kTeaG_contextNav",
46672
- "editorMeta": "-kTeaG_editorMeta",
46673
- "reviewCheckArrow": "-kTeaG_reviewCheckArrow",
46674
- "threadHeaderActions": "-kTeaG_threadHeaderActions",
46675
- "richEditorShell": "-kTeaG_richEditorShell",
46676
- "runningDot": "-kTeaG_runningDot",
46677
- "reviewDecisionHeader": "-kTeaG_reviewDecisionHeader",
46678
- "workflowFocus": "-kTeaG_workflowFocus",
46679
- "versionCompare": "-kTeaG_versionCompare",
46680
- "entryActive": "-kTeaG_entryActive",
46681
- "emptyPanel": "-kTeaG_emptyPanel",
46682
- "unreadNotification": "-kTeaG_unreadNotification",
46683
- "decisionEvidence": "-kTeaG_decisionEvidence",
46684
46957
  "documents": "-kTeaG_documents",
46685
- "createSummary": "-kTeaG_createSummary",
46686
- "commentThread": "-kTeaG_commentThread",
46687
- "focusMode": "-kTeaG_focusMode",
46688
- "mobileCollab": "-kTeaG_mobileCollab",
46689
- "recordLinkButton": "-kTeaG_recordLinkButton",
46690
- "tabBadge": "-kTeaG_tabBadge",
46691
- "run": "-kTeaG_run",
46692
- "decisionTags": "-kTeaG_decisionTags",
46693
- "versionActions": "-kTeaG_versionActions",
46694
- "review": "-kTeaG_review",
46695
- "readyPackage": "-kTeaG_readyPackage",
46696
- "requirementMenu": "-kTeaG_requirementMenu",
46697
- "documentReviewHighlight": "-kTeaG_documentReviewHighlight",
46698
- "decisionModeHint": "-kTeaG_decisionModeHint",
46699
- "formErrors": "-kTeaG_formErrors",
46700
- "createButton": "-kTeaG_createButton",
46701
- "headerActions": "-kTeaG_headerActions",
46958
+ "commentSourceSelected": "-kTeaG_commentSourceSelected",
46702
46959
  "selectionPromptBelow": "-kTeaG_selectionPromptBelow",
46703
- "aiMessage": "-kTeaG_aiMessage",
46704
- "conflictActions": "-kTeaG_conflictActions",
46960
+ "requirementSearch": "-kTeaG_requirementSearch",
46961
+ "conflictHeader": "-kTeaG_conflictHeader",
46962
+ "diffActions": "-kTeaG_diffActions",
46963
+ "editorPane": "-kTeaG_editorPane",
46964
+ "chatMessages": "-kTeaG_chatMessages",
46965
+ "contextNav": "-kTeaG_contextNav",
46966
+ "commentThreadSelected": "-kTeaG_commentThreadSelected",
46967
+ "checkPassed": "-kTeaG_checkPassed",
46968
+ "commentThreadMeta": "-kTeaG_commentThreadMeta",
46705
46969
  "chatComposer": "-kTeaG_chatComposer",
46706
- "myWorkButton": "-kTeaG_myWorkButton",
46707
- "emptyAside": "-kTeaG_emptyAside",
46708
- "documentCommentAnchor": "-kTeaG_documentCommentAnchor",
46970
+ "editorMeta": "-kTeaG_editorMeta",
46971
+ "topActions": "-kTeaG_topActions",
46972
+ "threadList": "-kTeaG_threadList",
46973
+ "locateSourceButton": "-kTeaG_locateSourceButton",
46709
46974
  "inlineReviewQuestion": "-kTeaG_inlineReviewQuestion",
46710
- "mobileDocumentsOpen": "-kTeaG_mobileDocumentsOpen",
46711
- "discussionSummary": "-kTeaG_discussionSummary",
46975
+ "discussionFilters": "-kTeaG_discussionFilters",
46976
+ "resizerHidden": "-kTeaG_resizerHidden",
46977
+ "dangerButton": "-kTeaG_dangerButton",
46978
+ "disabledReason": "-kTeaG_disabledReason",
46979
+ "stage_ready": "-kTeaG_stage_ready",
46980
+ "decisionResponse": "-kTeaG_decisionResponse",
46712
46981
  "selectionPromptActions": "-kTeaG_selectionPromptActions",
46713
- "commentSourceButton": "-kTeaG_commentSourceButton",
46714
- "statusDot": "-kTeaG_statusDot",
46715
- "decisionEmpty": "-kTeaG_decisionEmpty",
46716
- "decisionSourceHead": "-kTeaG_decisionSourceHead",
46717
- "reviewChecklist": "-kTeaG_reviewChecklist",
46718
- "diffCollapsed": "-kTeaG_diffCollapsed",
46719
- "panelSummary": "-kTeaG_panelSummary",
46720
- "selectionPromptButtons": "-kTeaG_selectionPromptButtons",
46721
- "dangerText": "-kTeaG_dangerText",
46982
+ "conflictModal": "-kTeaG_conflictModal",
46983
+ "threadStack": "-kTeaG_threadStack",
46984
+ "collabMetricActive": "-kTeaG_collabMetricActive",
46985
+ "reply": "-kTeaG_reply",
46986
+ "stageDone": "-kTeaG_stageDone",
46987
+ "createSummary": "-kTeaG_createSummary",
46988
+ "markdownBody": "-kTeaG_markdownBody",
46989
+ "workflowFocus": "-kTeaG_workflowFocus",
46722
46990
  "reviewChecklistRow": "-kTeaG_reviewChecklistRow",
46723
- "documentReviewHighlightBlocking": "-kTeaG_documentReviewHighlightBlocking",
46724
- "tabPanel": "-kTeaG_tabPanel",
46725
- "reviewCheckBox": "-kTeaG_reviewCheckBox",
46726
- "decisionSource": "-kTeaG_decisionSource",
46727
- "decisionAsideHead": "-kTeaG_decisionAsideHead",
46728
- "editorContext": "-kTeaG_editorContext",
46729
- "stageRail": "-kTeaG_stageRail",
46730
- "paneHead": "-kTeaG_paneHead",
46731
- "reviewTitle": "-kTeaG_reviewTitle",
46732
- "commentGlyph": "-kTeaG_commentGlyph",
46733
- "versionCopy": "-kTeaG_versionCopy",
46734
- "emptyList": "-kTeaG_emptyList",
46991
+ "empty": "-kTeaG_empty",
46735
46992
  "collabStateSaved": "-kTeaG_collabStateSaved",
46736
- "checkItem": "-kTeaG_checkItem",
46737
- "insightLinks": "-kTeaG_insightLinks",
46738
- "badges": "-kTeaG_badges",
46739
- "reviewDecisionModal": "-kTeaG_reviewDecisionModal",
46740
- "decisionSectionHead": "-kTeaG_decisionSectionHead",
46741
- "noticeHidden": "-kTeaG_noticeHidden",
46993
+ "threadHeaderActions": "-kTeaG_threadHeaderActions",
46994
+ "discussionPanel": "-kTeaG_discussionPanel",
46995
+ "documentCommentHighlight": "-kTeaG_documentCommentHighlight",
46996
+ "reviewCheckCopy": "-kTeaG_reviewCheckCopy",
46742
46997
  "summaryInput": "-kTeaG_summaryInput",
46743
- "workbench": "-kTeaG_workbench",
46998
+ "reviewCheckArrow": "-kTeaG_reviewCheckArrow",
46999
+ "collapseRight": "-kTeaG_collapseRight",
46744
47000
  "documentAnchorHighlight": "-kTeaG_documentAnchorHighlight",
46745
- "srOnly": "-kTeaG_srOnly",
46746
- "reviewDecisionAside": "-kTeaG_reviewDecisionAside",
46747
- "downstreamReturn": "-kTeaG_downstreamReturn",
46748
- "threadList": "-kTeaG_threadList",
46749
- "reviewDecisionContext": "-kTeaG_reviewDecisionContext",
46750
- "insightPanel": "-kTeaG_insightPanel",
46751
- "checklistMeter": "-kTeaG_checklistMeter",
46752
- "requirementFilters": "-kTeaG_requirementFilters",
46753
- "summaryField": "-kTeaG_summaryField",
46754
- "reviewSourceSelected": "-kTeaG_reviewSourceSelected",
46755
- "cardActions": "-kTeaG_cardActions",
46756
- "decisionQuestion": "-kTeaG_decisionQuestion",
46757
- "diffDialog": "-kTeaG_diffDialog",
46758
- "versionPicker": "-kTeaG_versionPicker",
46759
- "decisionActions": "-kTeaG_decisionActions",
46760
- "collabStateDirty": "-kTeaG_collabStateDirty",
46761
- "editorBody": "-kTeaG_editorBody",
46762
- "rowMenuButton": "-kTeaG_rowMenuButton",
46763
- "documentReviewAnchorSelected": "-kTeaG_documentReviewAnchorSelected",
46764
- "conflictColumns": "-kTeaG_conflictColumns",
46765
- "chatToggle": "-kTeaG_chatToggle",
46766
- "inlineReviewHead": "-kTeaG_inlineReviewHead",
46767
- "pulse": "-kTeaG_pulse",
46768
- "inlineReviewActions": "-kTeaG_inlineReviewActions",
46769
- "insightCard": "-kTeaG_insightCard",
46770
- "replyComposer": "-kTeaG_replyComposer",
46771
- "documentButton": "-kTeaG_documentButton",
46772
- "readyHead": "-kTeaG_readyHead",
46773
- "commentThreadMeta": "-kTeaG_commentThreadMeta",
46774
- "dialogSurface": "-kTeaG_dialogSurface",
46775
- "reviewCheckMeta": "-kTeaG_reviewCheckMeta",
46776
- "collabBarState": "-kTeaG_collabBarState",
47001
+ "selectionPromptClose": "-kTeaG_selectionPromptClose",
46777
47002
  "patchDetails": "-kTeaG_patchDetails",
46778
- "inlineDecisionOptions": "-kTeaG_inlineDecisionOptions",
46779
- "insightScore": "-kTeaG_insightScore",
46780
- "readyPackageHead": "-kTeaG_readyPackageHead",
46781
- "reviewCheckCopy": "-kTeaG_reviewCheckCopy",
46782
- "reviewDecisionDialog": "-kTeaG_reviewDecisionDialog",
46783
- "insightFilters": "-kTeaG_insightFilters",
46784
- "activeFilters": "-kTeaG_activeFilters"
47003
+ "userMessage": "-kTeaG_userMessage",
47004
+ "documentReviewHighlight": "-kTeaG_documentReviewHighlight",
47005
+ "inlineDecisionForm": "-kTeaG_inlineDecisionForm",
47006
+ "formErrors": "-kTeaG_formErrors",
47007
+ "mobileDocumentsTrigger": "-kTeaG_mobileDocumentsTrigger",
47008
+ "stickyActions": "-kTeaG_stickyActions",
47009
+ "dialogSurface": "-kTeaG_dialogSurface",
47010
+ "selectionPromptHead": "-kTeaG_selectionPromptHead",
47011
+ "documentReviewAnchor": "-kTeaG_documentReviewAnchor",
47012
+ "conflictActions": "-kTeaG_conflictActions",
47013
+ "downstreamReturn": "-kTeaG_downstreamReturn",
47014
+ "activeFilters": "-kTeaG_activeFilters",
47015
+ "execute": "-kTeaG_execute",
47016
+ "selectedDoc": "-kTeaG_selectedDoc",
47017
+ "reviewDecisionModal": "-kTeaG_reviewDecisionModal",
47018
+ "versionRow": "-kTeaG_versionRow"
46785
47019
  };
46786
47020
  //#endregion
46787
47021
  //#region src/client/AccessibleDialog.tsx
@@ -52222,6 +52456,11 @@ window.__ModuleLoader__.load({
52222
52456
  element: skillCenter,
52223
52457
  placement: "after"
52224
52458
  };
52459
+ const plugins = document.querySelector("button[aria-label=\"插件\"], button[aria-label=\"Plugins\"]") ?? exactTextButton(document, "插件") ?? exactTextButton(document, "Plugins");
52460
+ if (plugins !== void 0 && plugins !== null) return {
52461
+ element: plugins,
52462
+ placement: "after"
52463
+ };
52225
52464
  const settings = document.querySelector("button[aria-label=\"设置\"]") ?? exactTextButton(document, "设置");
52226
52465
  if (settings !== void 0 && settings !== null) return {
52227
52466
  element: settings,
@@ -52379,7 +52618,6 @@ window.__ModuleLoader__.load({
52379
52618
  }
52380
52619
  //#endregion
52381
52620
  //#region src/client/index.ts
52382
- const inject = ["sessions"];
52383
52621
  function apply(ctx) {
52384
52622
  const api = new SpecApi();
52385
52623
  const disposers = [];
@@ -52394,7 +52632,6 @@ window.__ModuleLoader__.load({
52394
52632
  }
52395
52633
  //#endregion
52396
52634
  exports.apply = apply;
52397
- exports.inject = inject;
52398
52635
  return module.exports;
52399
52636
  }
52400
52637
  });