@bagelink/vue 0.0.589 → 0.0.596

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/dist/index.cjs CHANGED
@@ -112,12 +112,21 @@ function getPaddingObject(padding) {
112
112
  };
113
113
  }
114
114
  function rectToClientRect$1(rect) {
115
+ const {
116
+ x: x2,
117
+ y: y2,
118
+ width,
119
+ height
120
+ } = rect;
115
121
  return {
116
- ...rect,
117
- top: rect.y,
118
- left: rect.x,
119
- right: rect.x + rect.width,
120
- bottom: rect.y + rect.height
122
+ width,
123
+ height,
124
+ top: y2,
125
+ left: x2,
126
+ right: x2 + width,
127
+ bottom: y2 + height,
128
+ x: x2,
129
+ y: y2
121
130
  };
122
131
  }
123
132
  function computeCoordsFromPlacement(_ref, placement, rtl) {
@@ -288,9 +297,10 @@ async function detectOverflow$1(state2, options) {
288
297
  strategy
289
298
  }));
290
299
  const rect = elementContext === "floating" ? {
291
- ...rects.floating,
292
300
  x: x2,
293
- y: y2
301
+ y: y2,
302
+ width: rects.floating.width,
303
+ height: rects.floating.height
294
304
  } : rects.reference;
295
305
  const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
296
306
  const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
@@ -501,10 +511,12 @@ const flip$2 = function(options) {
501
511
  return {};
502
512
  }
503
513
  const side = getSide$1(placement);
514
+ const initialSideAxis = getSideAxis(initialPlacement);
504
515
  const isBasePlacement = getSide$1(initialPlacement) === initialPlacement;
505
516
  const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
506
517
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement$1(initialPlacement)] : getExpandedPlacements(initialPlacement));
507
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
518
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
519
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
508
520
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
509
521
  }
510
522
  const placements2 = [initialPlacement, ...fallbackPlacements];
@@ -541,8 +553,16 @@ const flip$2 = function(options) {
541
553
  if (!resetPlacement) {
542
554
  switch (fallbackStrategy) {
543
555
  case "bestFit": {
544
- var _overflowsData$map$so;
545
- const placement2 = (_overflowsData$map$so = overflowsData.map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
556
+ var _overflowsData$filter2;
557
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
558
+ if (hasFallbackAxisSideDirection) {
559
+ const currentSideAxis = getSideAxis(d2.placement);
560
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
561
+ // reading directions favoring greater width.
562
+ currentSideAxis === "y";
563
+ }
564
+ return true;
565
+ }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
546
566
  if (placement2) {
547
567
  resetPlacement = placement2;
548
568
  }
@@ -737,16 +757,16 @@ const size = function(options) {
737
757
  widthSide = side;
738
758
  heightSide = alignment === "end" ? "top" : "bottom";
739
759
  }
740
- const overflowAvailableHeight = height - overflow[heightSide];
741
- const overflowAvailableWidth = width - overflow[widthSide];
760
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
761
+ const maximumClippingWidth = width - overflow.left - overflow.right;
762
+ const overflowAvailableHeight = min$3(height - overflow[heightSide], maximumClippingHeight);
763
+ const overflowAvailableWidth = min$3(width - overflow[widthSide], maximumClippingWidth);
742
764
  const noShift = !state2.middlewareData.shift;
743
765
  let availableHeight = overflowAvailableHeight;
744
766
  let availableWidth = overflowAvailableWidth;
745
767
  if (isYAxis) {
746
- const maximumClippingWidth = width - overflow.left - overflow.right;
747
768
  availableWidth = alignment || noShift ? min$3(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
748
769
  } else {
749
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
750
770
  availableHeight = alignment || noShift ? min$3(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
751
771
  }
752
772
  if (noShift && !alignment) {
@@ -3383,7 +3403,6 @@ const defaults$1 = {
3383
3403
  utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
3384
3404
  defaults$1.headers[method] = {};
3385
3405
  });
3386
- const defaults$2 = defaults$1;
3387
3406
  const ignoreDuplicateOf = utils$1.toObjectSet([
3388
3407
  "age",
3389
3408
  "authorization",
@@ -3645,11 +3664,10 @@ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
3645
3664
  };
3646
3665
  });
3647
3666
  utils$1.freezeMethods(AxiosHeaders);
3648
- const AxiosHeaders$1 = AxiosHeaders;
3649
3667
  function transformData(fns, response) {
3650
- const config = this || defaults$2;
3668
+ const config = this || defaults$1;
3651
3669
  const context = response || config;
3652
- const headers = AxiosHeaders$1.from(context.headers);
3670
+ const headers = AxiosHeaders.from(context.headers);
3653
3671
  let data2 = context.data;
3654
3672
  utils$1.forEach(fns, function transform(fn3) {
3655
3673
  data2 = fn3.call(config, data2, headers.normalize(), response ? response.status : void 0);
@@ -3848,7 +3866,7 @@ function buildFullPath(baseURL, requestedURL) {
3848
3866
  }
3849
3867
  return requestedURL;
3850
3868
  }
3851
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3869
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
3852
3870
  function mergeConfig(config1, config2) {
3853
3871
  config2 = config2 || {};
3854
3872
  const config = {};
@@ -3929,7 +3947,7 @@ function mergeConfig(config1, config2) {
3929
3947
  const resolveConfig = (config) => {
3930
3948
  const newConfig = mergeConfig({}, config);
3931
3949
  let { data: data2, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3932
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
3950
+ newConfig.headers = headers = AxiosHeaders.from(headers);
3933
3951
  newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
3934
3952
  if (auth) {
3935
3953
  headers.set(
@@ -3962,7 +3980,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3962
3980
  return new Promise(function dispatchXhrRequest(resolve, reject3) {
3963
3981
  const _config = resolveConfig(config);
3964
3982
  let requestData = _config.data;
3965
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3983
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
3966
3984
  let { responseType } = _config;
3967
3985
  let onCanceled;
3968
3986
  function done() {
@@ -3980,7 +3998,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3980
3998
  if (!request) {
3981
3999
  return;
3982
4000
  }
3983
- const responseHeaders = AxiosHeaders$1.from(
4001
+ const responseHeaders = AxiosHeaders.from(
3984
4002
  "getAllResponseHeaders" in request && request.getAllResponseHeaders()
3985
4003
  );
3986
4004
  const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
@@ -4296,7 +4314,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
4296
4314
  return await new Promise((resolve, reject3) => {
4297
4315
  settle(resolve, reject3, {
4298
4316
  data: responseData,
4299
- headers: AxiosHeaders$1.from(response.headers),
4317
+ headers: AxiosHeaders.from(response.headers),
4300
4318
  status: response.status,
4301
4319
  statusText: response.statusText,
4302
4320
  config,
@@ -4378,7 +4396,7 @@ function throwIfCancellationRequested(config) {
4378
4396
  }
4379
4397
  function dispatchRequest(config) {
4380
4398
  throwIfCancellationRequested(config);
4381
- config.headers = AxiosHeaders$1.from(config.headers);
4399
+ config.headers = AxiosHeaders.from(config.headers);
4382
4400
  config.data = transformData.call(
4383
4401
  config,
4384
4402
  config.transformRequest
@@ -4386,7 +4404,7 @@ function dispatchRequest(config) {
4386
4404
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
4387
4405
  config.headers.setContentType("application/x-www-form-urlencoded", false);
4388
4406
  }
4389
- const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter);
4407
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
4390
4408
  return adapter(config).then(function onAdapterResolution(response) {
4391
4409
  throwIfCancellationRequested(config);
4392
4410
  response.data = transformData.call(
@@ -4394,7 +4412,7 @@ function dispatchRequest(config) {
4394
4412
  config.transformResponse,
4395
4413
  response
4396
4414
  );
4397
- response.headers = AxiosHeaders$1.from(response.headers);
4415
+ response.headers = AxiosHeaders.from(response.headers);
4398
4416
  return response;
4399
4417
  }, function onAdapterRejection(reason) {
4400
4418
  if (!isCancel(reason)) {
@@ -4405,7 +4423,7 @@ function dispatchRequest(config) {
4405
4423
  config.transformResponse,
4406
4424
  reason.response
4407
4425
  );
4408
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
4426
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
4409
4427
  }
4410
4428
  }
4411
4429
  return Promise.reject(reason);
@@ -4544,7 +4562,7 @@ class Axios {
4544
4562
  delete headers[method];
4545
4563
  }
4546
4564
  );
4547
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
4565
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
4548
4566
  const requestInterceptorChain = [];
4549
4567
  let synchronousRequestInterceptors = true;
4550
4568
  this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
@@ -4628,7 +4646,6 @@ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method)
4628
4646
  Axios.prototype[method] = generateHTTPMethod();
4629
4647
  Axios.prototype[method + "Form"] = generateHTTPMethod(true);
4630
4648
  });
4631
- const Axios$1 = Axios;
4632
4649
  class CancelToken {
4633
4650
  constructor(executor) {
4634
4651
  if (typeof executor !== "function") {
@@ -4715,7 +4732,6 @@ class CancelToken {
4715
4732
  };
4716
4733
  }
4717
4734
  }
4718
- const CancelToken$1 = CancelToken;
4719
4735
  function spread(callback) {
4720
4736
  return function wrap2(arr) {
4721
4737
  return callback.apply(null, arr);
@@ -4792,21 +4808,20 @@ const HttpStatusCode = {
4792
4808
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
4793
4809
  HttpStatusCode[value] = key;
4794
4810
  });
4795
- const HttpStatusCode$1 = HttpStatusCode;
4796
4811
  function createInstance(defaultConfig2) {
4797
- const context = new Axios$1(defaultConfig2);
4798
- const instance = bind$2(Axios$1.prototype.request, context);
4799
- utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
4812
+ const context = new Axios(defaultConfig2);
4813
+ const instance = bind$2(Axios.prototype.request, context);
4814
+ utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
4800
4815
  utils$1.extend(instance, context, null, { allOwnKeys: true });
4801
4816
  instance.create = function create(instanceConfig) {
4802
4817
  return createInstance(mergeConfig(defaultConfig2, instanceConfig));
4803
4818
  };
4804
4819
  return instance;
4805
4820
  }
4806
- const axios$1 = createInstance(defaults$2);
4807
- axios$1.Axios = Axios$1;
4821
+ const axios$1 = createInstance(defaults$1);
4822
+ axios$1.Axios = Axios;
4808
4823
  axios$1.CanceledError = CanceledError;
4809
- axios$1.CancelToken = CancelToken$1;
4824
+ axios$1.CancelToken = CancelToken;
4810
4825
  axios$1.isCancel = isCancel;
4811
4826
  axios$1.VERSION = VERSION;
4812
4827
  axios$1.toFormData = toFormData;
@@ -4818,10 +4833,10 @@ axios$1.all = function all(promises) {
4818
4833
  axios$1.spread = spread;
4819
4834
  axios$1.isAxiosError = isAxiosError;
4820
4835
  axios$1.mergeConfig = mergeConfig;
4821
- axios$1.AxiosHeaders = AxiosHeaders$1;
4836
+ axios$1.AxiosHeaders = AxiosHeaders;
4822
4837
  axios$1.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4823
4838
  axios$1.getAdapter = adapters.getAdapter;
4824
- axios$1.HttpStatusCode = HttpStatusCode$1;
4839
+ axios$1.HttpStatusCode = HttpStatusCode;
4825
4840
  axios$1.default = axios$1;
4826
4841
  var __defProp = Object.defineProperty;
4827
4842
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -5065,7 +5080,10 @@ class Bagel {
5065
5080
  this._setAuthorization();
5066
5081
  const formData = new FormData();
5067
5082
  formData.append("file", file);
5068
- const { data: data2 } = await axios.post("/static_files/upload", formData, {
5083
+ let url = "/static_files/upload";
5084
+ if (options == null ? void 0 : options.topic)
5085
+ url = `/static_files/upload?topic=${options.topic}`;
5086
+ const { data: data2 } = await axios.post(url, formData, {
5069
5087
  headers: {
5070
5088
  "Content-Type": "multipart/form-data"
5071
5089
  },
@@ -6034,7 +6052,7 @@ function toValue(r2) {
6034
6052
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
6035
6053
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
6036
6054
  function getLifeCycleTarget(target) {
6037
- return target || vue.getCurrentInstance();
6055
+ return vue.getCurrentInstance();
6038
6056
  }
6039
6057
  function tryOnMounted(fn3, sync = true, target) {
6040
6058
  const instance = getLifeCycleTarget();
@@ -17270,12 +17288,7 @@ function eachDayOfInterval(interval, options) {
17270
17288
  const endTime = reversed ? +startDate : +endDate;
17271
17289
  const currentDate = reversed ? endDate : startDate;
17272
17290
  currentDate.setHours(0, 0, 0, 0);
17273
- let step = (options == null ? void 0 : options.step) ?? 1;
17274
- if (!step) return [];
17275
- if (step < 0) {
17276
- step = -step;
17277
- reversed = !reversed;
17278
- }
17291
+ let step = 1;
17279
17292
  const dates = [];
17280
17293
  while (+currentDate <= endTime) {
17281
17294
  dates.push(toDate(currentDate));
@@ -17298,12 +17311,7 @@ function eachQuarterOfInterval(interval, options) {
17298
17311
  let reversed = +startDate > +endDate;
17299
17312
  const endTime = reversed ? +startOfQuarter(startDate) : +startOfQuarter(endDate);
17300
17313
  let currentDate = reversed ? startOfQuarter(endDate) : startOfQuarter(startDate);
17301
- let step = (options == null ? void 0 : options.step) ?? 1;
17302
- if (!step) return [];
17303
- if (step < 0) {
17304
- step = -step;
17305
- reversed = !reversed;
17306
- }
17314
+ let step = 1;
17307
17315
  const dates = [];
17308
17316
  while (+currentDate <= endTime) {
17309
17317
  dates.push(toDate(currentDate));
@@ -26149,10 +26157,8 @@ function isScrolledPast(el, elSide, parentSide) {
26149
26157
  var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
26150
26158
  while (parent) {
26151
26159
  var parentSideVal = getRect(parent)[parentSide], visible = void 0;
26152
- if (parentSide === "top" || parentSide === "left") {
26160
+ {
26153
26161
  visible = elSideVal >= parentSideVal;
26154
- } else {
26155
- visible = elSideVal <= parentSideVal;
26156
26162
  }
26157
26163
  if (!visible) return parent;
26158
26164
  if (parent === getWindowScrollingElement()) break;
@@ -29527,7 +29533,7 @@ class Fragment {
29527
29533
  /**
29528
29534
  Find the index and inner offset corresponding to a given relative
29529
29535
  position in this fragment. The result object will be reused
29530
- (overwritten) the next time the function is called. (Not public.)
29536
+ (overwritten) the next time the function is called. @internal
29531
29537
  */
29532
29538
  findIndex(pos, round2 = -1) {
29533
29539
  if (pos == 0)
@@ -29733,7 +29739,9 @@ let Mark$1 = class Mark2 {
29733
29739
  let type3 = schema.marks[json.type];
29734
29740
  if (!type3)
29735
29741
  throw new RangeError(`There is no mark type ${json.type} in this schema`);
29736
- return type3.create(json.attrs);
29742
+ let mark = type3.create(json.attrs);
29743
+ type3.checkAttrs(mark.attrs);
29744
+ return mark;
29737
29745
  }
29738
29746
  /**
29739
29747
  Test whether two sets of marks are identical.
@@ -29867,8 +29875,6 @@ function removeRange(content, from2, to2) {
29867
29875
  function insertInto(content, dist, insert, parent) {
29868
29876
  let { index: index2, offset: offset2 } = content.findIndex(dist), child = content.maybeChild(index2);
29869
29877
  if (offset2 == dist || child.isText) {
29870
- if (parent && !parent.canReplace(index2, index2, insert))
29871
- return null;
29872
29878
  return content.cut(0, dist).append(insert).append(content.cut(dist));
29873
29879
  }
29874
29880
  let inner = insertInto(child.content, dist - offset2 - 1, insert);
@@ -30230,17 +30236,28 @@ class ResolvedPos {
30230
30236
  @internal
30231
30237
  */
30232
30238
  static resolveCached(doc2, pos) {
30233
- for (let i2 = 0; i2 < resolveCache.length; i2++) {
30234
- let cached2 = resolveCache[i2];
30235
- if (cached2.pos == pos && cached2.doc == doc2)
30236
- return cached2;
30239
+ let cache = resolveCache.get(doc2);
30240
+ if (cache) {
30241
+ for (let i2 = 0; i2 < cache.elts.length; i2++) {
30242
+ let elt = cache.elts[i2];
30243
+ if (elt.pos == pos)
30244
+ return elt;
30245
+ }
30246
+ } else {
30247
+ resolveCache.set(doc2, cache = new ResolveCache());
30237
30248
  }
30238
- let result2 = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc2, pos);
30239
- resolveCachePos = (resolveCachePos + 1) % resolveCacheSize;
30249
+ let result2 = cache.elts[cache.i] = ResolvedPos.resolve(doc2, pos);
30250
+ cache.i = (cache.i + 1) % resolveCacheSize;
30240
30251
  return result2;
30241
30252
  }
30242
30253
  }
30243
- let resolveCache = [], resolveCachePos = 0, resolveCacheSize = 12;
30254
+ class ResolveCache {
30255
+ constructor() {
30256
+ this.elts = [];
30257
+ this.i = 0;
30258
+ }
30259
+ }
30260
+ const resolveCacheSize = 12, resolveCache = /* @__PURE__ */ new WeakMap();
30244
30261
  class NodeRange {
30245
30262
  /**
30246
30263
  Construct a node range. `$from` and `$to` should point into the
@@ -30626,13 +30643,17 @@ let Node$3 = class Node2 {
30626
30643
  }
30627
30644
  /**
30628
30645
  Check whether this node and its descendants conform to the
30629
- schema, and raise error when they do not.
30646
+ schema, and raise an exception when they do not.
30630
30647
  */
30631
30648
  check() {
30632
30649
  this.type.checkContent(this.content);
30650
+ this.type.checkAttrs(this.attrs);
30633
30651
  let copy2 = Mark$1.none;
30634
- for (let i2 = 0; i2 < this.marks.length; i2++)
30635
- copy2 = this.marks[i2].addToSet(copy2);
30652
+ for (let i2 = 0; i2 < this.marks.length; i2++) {
30653
+ let mark = this.marks[i2];
30654
+ mark.type.checkAttrs(mark.attrs);
30655
+ copy2 = mark.addToSet(copy2);
30656
+ }
30636
30657
  if (!Mark$1.sameSet(copy2, this.marks))
30637
30658
  throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m2) => m2.type.name)}`);
30638
30659
  this.content.forEach((node) => node.check());
@@ -30658,7 +30679,7 @@ let Node$3 = class Node2 {
30658
30679
  static fromJSON(schema, json) {
30659
30680
  if (!json)
30660
30681
  throw new RangeError("Invalid input for Node.fromJSON");
30661
- let marks = null;
30682
+ let marks = void 0;
30662
30683
  if (json.marks) {
30663
30684
  if (!Array.isArray(json.marks))
30664
30685
  throw new RangeError("Invalid mark data for Node.fromJSON");
@@ -30670,7 +30691,9 @@ let Node$3 = class Node2 {
30670
30691
  return schema.text(json.text, marks);
30671
30692
  }
30672
30693
  let content = Fragment.fromJSON(schema, json.content);
30673
- return schema.nodeType(json.type).create(json.attrs, content, marks);
30694
+ let node = schema.nodeType(json.type).create(json.attrs, content, marks);
30695
+ node.type.checkAttrs(node.attrs);
30696
+ return node;
30674
30697
  }
30675
30698
  };
30676
30699
  Node$3.prototype.text = void 0;
@@ -31152,6 +31175,16 @@ function computeAttrs(attrs, value) {
31152
31175
  }
31153
31176
  return built;
31154
31177
  }
31178
+ function checkAttrs(attrs, values3, type3, name) {
31179
+ for (let name2 in values3)
31180
+ if (!(name2 in attrs))
31181
+ throw new RangeError(`Unsupported attribute ${name2} for ${type3} of type ${name2}`);
31182
+ for (let name2 in attrs) {
31183
+ let attr = attrs[name2];
31184
+ if (attr.validate)
31185
+ attr.validate(values3[name2]);
31186
+ }
31187
+ }
31155
31188
  function initAttrs(attrs) {
31156
31189
  let result2 = /* @__PURE__ */ Object.create(null);
31157
31190
  if (attrs)
@@ -31281,7 +31314,7 @@ let NodeType$1 = class NodeType2 {
31281
31314
  }
31282
31315
  /**
31283
31316
  Returns true if the given fragment is valid content for this node
31284
- type with the given attributes.
31317
+ type.
31285
31318
  */
31286
31319
  validContent(content) {
31287
31320
  let result2 = this.contentMatch.matchFragment(content);
@@ -31302,6 +31335,12 @@ let NodeType$1 = class NodeType2 {
31302
31335
  throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
31303
31336
  }
31304
31337
  /**
31338
+ @internal
31339
+ */
31340
+ checkAttrs(attrs) {
31341
+ checkAttrs(this.attrs, attrs, "node", this.name);
31342
+ }
31343
+ /**
31305
31344
  Check whether the given mark type is allowed in this node.
31306
31345
  */
31307
31346
  allowsMarkType(markType) {
@@ -31351,10 +31390,19 @@ let NodeType$1 = class NodeType2 {
31351
31390
  return result2;
31352
31391
  }
31353
31392
  };
31393
+ function validateType(type3) {
31394
+ let types = type3.split("|");
31395
+ return (value) => {
31396
+ let name = value === null ? "null" : typeof value;
31397
+ if (types.indexOf(name) < 0)
31398
+ throw new RangeError(`Expected value of type ${types}, got ${name}`);
31399
+ };
31400
+ }
31354
31401
  class Attribute {
31355
31402
  constructor(options) {
31356
31403
  this.hasDefault = Object.prototype.hasOwnProperty.call(options, "default");
31357
31404
  this.default = options.default;
31405
+ this.validate = typeof options.validate == "string" ? validateType(options.validate) : options.validate;
31358
31406
  }
31359
31407
  get isRequired() {
31360
31408
  return !this.hasDefault;
@@ -31413,6 +31461,12 @@ class MarkType {
31413
31461
  return set2[i2];
31414
31462
  }
31415
31463
  /**
31464
+ @internal
31465
+ */
31466
+ checkAttrs(attrs) {
31467
+ checkAttrs(this.attrs, attrs, "mark", this.name);
31468
+ }
31469
+ /**
31416
31470
  Queries whether a given mark type is
31417
31471
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
31418
31472
  */
@@ -31425,6 +31479,7 @@ class Schema {
31425
31479
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
31426
31480
  */
31427
31481
  constructor(spec) {
31482
+ this.linebreakReplacement = null;
31428
31483
  this.cached = /* @__PURE__ */ Object.create(null);
31429
31484
  let instanceSpec = this.spec = {};
31430
31485
  for (let prop3 in spec)
@@ -31438,6 +31493,13 @@ class Schema {
31438
31493
  let type3 = this.nodes[prop3], contentExpr = type3.spec.content || "", markExpr = type3.spec.marks;
31439
31494
  type3.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));
31440
31495
  type3.inlineContent = type3.contentMatch.inlineContent;
31496
+ if (type3.spec.linebreakReplacement) {
31497
+ if (this.linebreakReplacement)
31498
+ throw new RangeError("Multiple linebreak nodes defined");
31499
+ if (!type3.isInline || !type3.isLeaf)
31500
+ throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
31501
+ this.linebreakReplacement = type3;
31502
+ }
31441
31503
  type3.markSet = markExpr == "_" ? null : markExpr ? gatherMarks(this, markExpr.split(" ")) : markExpr == "" || !type3.inlineContent ? [] : null;
31442
31504
  }
31443
31505
  for (let prop3 in this.marks) {
@@ -31522,6 +31584,12 @@ function gatherMarks(schema, marks) {
31522
31584
  }
31523
31585
  return found2;
31524
31586
  }
31587
+ function isTagRule(rule) {
31588
+ return rule.tag != null;
31589
+ }
31590
+ function isStyleRule(rule) {
31591
+ return rule.style != null;
31592
+ }
31525
31593
  class DOMParser {
31526
31594
  /**
31527
31595
  Create a parser that targets the given schema, using the given
@@ -31532,11 +31600,16 @@ class DOMParser {
31532
31600
  this.rules = rules;
31533
31601
  this.tags = [];
31534
31602
  this.styles = [];
31603
+ let matchedStyles = this.matchedStyles = [];
31535
31604
  rules.forEach((rule) => {
31536
- if (rule.tag)
31605
+ if (isTagRule(rule)) {
31537
31606
  this.tags.push(rule);
31538
- else if (rule.style)
31607
+ } else if (isStyleRule(rule)) {
31608
+ let prop3 = /[^=]*/.exec(rule.style)[0];
31609
+ if (matchedStyles.indexOf(prop3) < 0)
31610
+ matchedStyles.push(prop3);
31539
31611
  this.styles.push(rule);
31612
+ }
31540
31613
  });
31541
31614
  this.normalizeLists = !this.tags.some((r2) => {
31542
31615
  if (!/^(ul|ol)\b/.test(r2.tag) || !r2.node)
@@ -31796,10 +31869,10 @@ class ParseContext {
31796
31869
  this.addElement(dom);
31797
31870
  }
31798
31871
  withStyleRules(dom, f2) {
31799
- let style2 = dom.getAttribute("style");
31800
- if (!style2)
31872
+ let style2 = dom.style;
31873
+ if (!style2 || !style2.length)
31801
31874
  return f2();
31802
- let marks = this.readStyles(parseStyles(style2));
31875
+ let marks = this.readStyles(dom.style);
31803
31876
  if (!marks)
31804
31877
  return;
31805
31878
  let [addMarks, removeMarks] = marks, top2 = this.top;
@@ -31893,27 +31966,30 @@ class ParseContext {
31893
31966
  // had a rule with `ignore` set.
31894
31967
  readStyles(styles) {
31895
31968
  let add2 = Mark$1.none, remove2 = Mark$1.none;
31896
- for (let i2 = 0; i2 < styles.length; i2 += 2) {
31897
- for (let after = void 0; ; ) {
31898
- let rule = this.parser.matchStyle(styles[i2], styles[i2 + 1], this, after);
31899
- if (!rule)
31900
- break;
31901
- if (rule.ignore)
31902
- return null;
31903
- if (rule.clearMark) {
31904
- this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31905
- if (rule.clearMark(m2))
31906
- remove2 = m2.addToSet(remove2);
31907
- });
31908
- } else {
31909
- add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31910
- }
31911
- if (rule.consuming === false)
31912
- after = rule;
31913
- else
31914
- break;
31969
+ if (styles.length)
31970
+ for (let i2 = 0; i2 < this.parser.matchedStyles.length; i2++) {
31971
+ let name = this.parser.matchedStyles[i2], value = styles.getPropertyValue(name);
31972
+ if (value)
31973
+ for (let after = void 0; ; ) {
31974
+ let rule = this.parser.matchStyle(name, value, this, after);
31975
+ if (!rule)
31976
+ break;
31977
+ if (rule.ignore)
31978
+ return null;
31979
+ if (rule.clearMark) {
31980
+ this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31981
+ if (rule.clearMark(m2))
31982
+ remove2 = m2.addToSet(remove2);
31983
+ });
31984
+ } else {
31985
+ add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31986
+ }
31987
+ if (rule.consuming === false)
31988
+ after = rule;
31989
+ else
31990
+ break;
31991
+ }
31915
31992
  }
31916
- }
31917
31993
  return [add2, remove2];
31918
31994
  }
31919
31995
  // Look up a handler for the given node. If none are found, return
@@ -32182,12 +32258,6 @@ function normalizeList(dom) {
32182
32258
  function matches(dom, selector2) {
32183
32259
  return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector2);
32184
32260
  }
32185
- function parseStyles(style2) {
32186
- let re2 = /\s*([\w-]+)\s*:\s*([^;]+)/g, m2, result2 = [];
32187
- while (m2 = re2.exec(style2))
32188
- result2.push(m2[1], m2[2].trim());
32189
- return result2;
32190
- }
32191
32261
  function copy$2(obj) {
32192
32262
  let copy2 = {};
32193
32263
  for (let prop3 in obj)
@@ -32278,7 +32348,7 @@ class DOMSerializer {
32278
32348
  @internal
32279
32349
  */
32280
32350
  serializeNodeInner(node, options) {
32281
- let { dom, contentDOM } = DOMSerializer.renderSpec(doc$1(options), this.nodes[node.type.name](node));
32351
+ let { dom, contentDOM } = renderSpec(doc$1(options), this.nodes[node.type.name](node), null, node.attrs);
32282
32352
  if (contentDOM) {
32283
32353
  if (node.isLeaf)
32284
32354
  throw new RangeError("Content hole not allowed in a leaf node spec");
@@ -32309,7 +32379,7 @@ class DOMSerializer {
32309
32379
  */
32310
32380
  serializeMark(mark, inline, options = {}) {
32311
32381
  let toDOM = this.marks[mark.type.name];
32312
- return toDOM && DOMSerializer.renderSpec(doc$1(options), toDOM(mark, inline));
32382
+ return toDOM && renderSpec(doc$1(options), toDOM(mark, inline), null, mark.attrs);
32313
32383
  }
32314
32384
  /**
32315
32385
  Render an [output spec](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) to a DOM node. If
@@ -32317,48 +32387,7 @@ class DOMSerializer {
32317
32387
  node with the hole.
32318
32388
  */
32319
32389
  static renderSpec(doc2, structure, xmlNS = null) {
32320
- if (typeof structure == "string")
32321
- return { dom: doc2.createTextNode(structure) };
32322
- if (structure.nodeType != null)
32323
- return { dom: structure };
32324
- if (structure.dom && structure.dom.nodeType != null)
32325
- return structure;
32326
- let tagName = structure[0], space = tagName.indexOf(" ");
32327
- if (space > 0) {
32328
- xmlNS = tagName.slice(0, space);
32329
- tagName = tagName.slice(space + 1);
32330
- }
32331
- let contentDOM;
32332
- let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32333
- let attrs = structure[1], start2 = 1;
32334
- if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32335
- start2 = 2;
32336
- for (let name in attrs)
32337
- if (attrs[name] != null) {
32338
- let space2 = name.indexOf(" ");
32339
- if (space2 > 0)
32340
- dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32341
- else
32342
- dom.setAttribute(name, attrs[name]);
32343
- }
32344
- }
32345
- for (let i2 = start2; i2 < structure.length; i2++) {
32346
- let child = structure[i2];
32347
- if (child === 0) {
32348
- if (i2 < structure.length - 1 || i2 > start2)
32349
- throw new RangeError("Content hole must be the only child of its parent node");
32350
- return { dom, contentDOM: dom };
32351
- } else {
32352
- let { dom: inner, contentDOM: innerContent } = DOMSerializer.renderSpec(doc2, child, xmlNS);
32353
- dom.appendChild(inner);
32354
- if (innerContent) {
32355
- if (contentDOM)
32356
- throw new RangeError("Multiple content holes");
32357
- contentDOM = innerContent;
32358
- }
32359
- }
32360
- }
32361
- return { dom, contentDOM };
32390
+ return renderSpec(doc2, structure, xmlNS);
32362
32391
  }
32363
32392
  /**
32364
32393
  Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
@@ -32396,6 +32425,84 @@ function gatherToDOM(obj) {
32396
32425
  function doc$1(options) {
32397
32426
  return options.document || window.document;
32398
32427
  }
32428
+ const suspiciousAttributeCache = /* @__PURE__ */ new WeakMap();
32429
+ function suspiciousAttributes(attrs) {
32430
+ let value = suspiciousAttributeCache.get(attrs);
32431
+ if (value === void 0)
32432
+ suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));
32433
+ return value;
32434
+ }
32435
+ function suspiciousAttributesInner(attrs) {
32436
+ let result2 = null;
32437
+ function scan(value) {
32438
+ if (value && typeof value == "object") {
32439
+ if (Array.isArray(value)) {
32440
+ if (typeof value[0] == "string") {
32441
+ if (!result2)
32442
+ result2 = [];
32443
+ result2.push(value);
32444
+ } else {
32445
+ for (let i2 = 0; i2 < value.length; i2++)
32446
+ scan(value[i2]);
32447
+ }
32448
+ } else {
32449
+ for (let prop3 in value)
32450
+ scan(value[prop3]);
32451
+ }
32452
+ }
32453
+ }
32454
+ scan(attrs);
32455
+ return result2;
32456
+ }
32457
+ function renderSpec(doc2, structure, xmlNS, blockArraysIn) {
32458
+ if (typeof structure == "string")
32459
+ return { dom: doc2.createTextNode(structure) };
32460
+ if (structure.nodeType != null)
32461
+ return { dom: structure };
32462
+ if (structure.dom && structure.dom.nodeType != null)
32463
+ return structure;
32464
+ let tagName = structure[0], suspicious;
32465
+ if (typeof tagName != "string")
32466
+ throw new RangeError("Invalid array passed to renderSpec");
32467
+ if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1)
32468
+ throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
32469
+ let space = tagName.indexOf(" ");
32470
+ if (space > 0) {
32471
+ xmlNS = tagName.slice(0, space);
32472
+ tagName = tagName.slice(space + 1);
32473
+ }
32474
+ let contentDOM;
32475
+ let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32476
+ let attrs = structure[1], start2 = 1;
32477
+ if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32478
+ start2 = 2;
32479
+ for (let name in attrs)
32480
+ if (attrs[name] != null) {
32481
+ let space2 = name.indexOf(" ");
32482
+ if (space2 > 0)
32483
+ dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32484
+ else
32485
+ dom.setAttribute(name, attrs[name]);
32486
+ }
32487
+ }
32488
+ for (let i2 = start2; i2 < structure.length; i2++) {
32489
+ let child = structure[i2];
32490
+ if (child === 0) {
32491
+ if (i2 < structure.length - 1 || i2 > start2)
32492
+ throw new RangeError("Content hole must be the only child of its parent node");
32493
+ return { dom, contentDOM: dom };
32494
+ } else {
32495
+ let { dom: inner, contentDOM: innerContent } = renderSpec(doc2, child, xmlNS, blockArraysIn);
32496
+ dom.appendChild(inner);
32497
+ if (innerContent) {
32498
+ if (contentDOM)
32499
+ throw new RangeError("Multiple content holes");
32500
+ contentDOM = innerContent;
32501
+ }
32502
+ }
32503
+ }
32504
+ return { dom, contentDOM };
32505
+ }
32399
32506
  const lower16 = 65535;
32400
32507
  const factor16 = Math.pow(2, 16);
32401
32508
  function makeRecover(index2, offset2) {
@@ -33055,7 +33162,8 @@ class ReplaceAroundStep extends Step$1 {
33055
33162
  }
33056
33163
  map(mapping) {
33057
33164
  let from2 = mapping.mapResult(this.from, 1), to2 = mapping.mapResult(this.to, -1);
33058
- let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);
33165
+ let gapFrom = this.from == this.gapFrom ? from2.pos : mapping.map(this.gapFrom, -1);
33166
+ let gapTo = this.to == this.gapTo ? to2.pos : mapping.map(this.gapTo, 1);
33059
33167
  if (from2.deletedAcross && to2.deletedAcross || gapFrom < from2.pos || gapTo > to2.pos)
33060
33168
  return null;
33061
33169
  return new ReplaceAroundStep(from2.pos, to2.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
@@ -33168,7 +33276,7 @@ function removeMark(tr2, from2, to2, mark) {
33168
33276
  });
33169
33277
  matched.forEach((m2) => tr2.step(new RemoveMarkStep(m2.from, m2.to, m2.style)));
33170
33278
  }
33171
- function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch) {
33279
+ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch, clearNewlines = true) {
33172
33280
  let node = tr2.doc.nodeAt(pos);
33173
33281
  let replSteps = [], cur = pos + 1;
33174
33282
  for (let i2 = 0; i2 < node.childCount; i2++) {
@@ -33181,7 +33289,7 @@ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatc
33181
33289
  for (let j2 = 0; j2 < child.marks.length; j2++)
33182
33290
  if (!parentType.allowsMarkType(child.marks[j2].type))
33183
33291
  tr2.step(new RemoveMarkStep(cur, end2, child.marks[j2]));
33184
- if (child.isText && !parentType.spec.code) {
33292
+ if (clearNewlines && child.isText && parentType.whitespace != "pre") {
33185
33293
  let m2, newline = /\r?\n|\r/g, slice4;
33186
33294
  while (m2 = newline.exec(child.text)) {
33187
33295
  if (!slice4)
@@ -33290,14 +33398,45 @@ function setBlockType$1(tr2, from2, to2, type3, attrs) {
33290
33398
  let mapFrom = tr2.steps.length;
33291
33399
  tr2.doc.nodesBetween(from2, to2, (node, pos) => {
33292
33400
  if (node.isTextblock && !node.hasMarkup(type3, attrs) && canChangeType(tr2.doc, tr2.mapping.slice(mapFrom).map(pos), type3)) {
33293
- tr2.clearIncompatible(tr2.mapping.slice(mapFrom).map(pos, 1), type3);
33401
+ let convertNewlines = null;
33402
+ if (type3.schema.linebreakReplacement) {
33403
+ let pre = type3.whitespace == "pre", supportLinebreak = !!type3.contentMatch.matchType(type3.schema.linebreakReplacement);
33404
+ if (pre && !supportLinebreak)
33405
+ convertNewlines = false;
33406
+ else if (!pre && supportLinebreak)
33407
+ convertNewlines = true;
33408
+ }
33409
+ if (convertNewlines === false)
33410
+ replaceLinebreaks(tr2, node, pos, mapFrom);
33411
+ clearIncompatible(tr2, tr2.mapping.slice(mapFrom).map(pos, 1), type3, void 0, convertNewlines === null);
33294
33412
  let mapping = tr2.mapping.slice(mapFrom);
33295
33413
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
33296
33414
  tr2.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type3.create(attrs, null, node.marks)), 0, 0), 1, true));
33415
+ if (convertNewlines === true)
33416
+ replaceNewlines(tr2, node, pos, mapFrom);
33297
33417
  return false;
33298
33418
  }
33299
33419
  });
33300
33420
  }
33421
+ function replaceNewlines(tr2, node, pos, mapFrom) {
33422
+ node.forEach((child, offset2) => {
33423
+ if (child.isText) {
33424
+ let m2, newline = /\r?\n|\r/g;
33425
+ while (m2 = newline.exec(child.text)) {
33426
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2 + m2.index);
33427
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.linebreakReplacement.create());
33428
+ }
33429
+ }
33430
+ });
33431
+ }
33432
+ function replaceLinebreaks(tr2, node, pos, mapFrom) {
33433
+ node.forEach((child, offset2) => {
33434
+ if (child.type == child.type.schema.linebreakReplacement) {
33435
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2);
33436
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.text("\n"));
33437
+ }
33438
+ });
33439
+ }
33301
33440
  function canChangeType(doc2, pos, type3) {
33302
33441
  let $pos = doc2.resolve(pos), index2 = $pos.index();
33303
33442
  return $pos.parent.canReplaceWith(index2, index2 + 1, type3);
@@ -35063,6 +35202,9 @@ const textRange = function(node, from2, to2) {
35063
35202
  range2.setStart(node, from2 || 0);
35064
35203
  return range2;
35065
35204
  };
35205
+ const clearReusedRange = function() {
35206
+ reusedRange = null;
35207
+ };
35066
35208
  const isEquivalentPosition = function(node, off2, targetNode, targetOff) {
35067
35209
  return targetNode && (scanFor(node, off2, targetNode, targetOff, -1) || scanFor(node, off2, targetNode, targetOff, 1));
35068
35210
  };
@@ -35090,6 +35232,40 @@ function scanFor(node, off2, targetNode, targetOff, dir) {
35090
35232
  function nodeSize(node) {
35091
35233
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
35092
35234
  }
35235
+ function textNodeBefore$1(node, offset2) {
35236
+ for (; ; ) {
35237
+ if (node.nodeType == 3 && offset2)
35238
+ return node;
35239
+ if (node.nodeType == 1 && offset2 > 0) {
35240
+ if (node.contentEditable == "false")
35241
+ return null;
35242
+ node = node.childNodes[offset2 - 1];
35243
+ offset2 = nodeSize(node);
35244
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35245
+ offset2 = domIndex(node);
35246
+ node = node.parentNode;
35247
+ } else {
35248
+ return null;
35249
+ }
35250
+ }
35251
+ }
35252
+ function textNodeAfter$1(node, offset2) {
35253
+ for (; ; ) {
35254
+ if (node.nodeType == 3 && offset2 < node.nodeValue.length)
35255
+ return node;
35256
+ if (node.nodeType == 1 && offset2 < node.childNodes.length) {
35257
+ if (node.contentEditable == "false")
35258
+ return null;
35259
+ node = node.childNodes[offset2];
35260
+ offset2 = 0;
35261
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35262
+ offset2 = domIndex(node) + 1;
35263
+ node = node.parentNode;
35264
+ } else {
35265
+ return null;
35266
+ }
35267
+ }
35268
+ }
35093
35269
  function isOnEdge(node, offset2, parent) {
35094
35270
  for (let atStart = offset2 == 0, atEnd = offset2 == nodeSize(node); atStart || atEnd; ) {
35095
35271
  if (node == parent)
@@ -35161,6 +35337,14 @@ const android = /Android \d/.test(agent);
35161
35337
  const webkit = !!doc && "webkitFontSmoothing" in doc.documentElement.style;
35162
35338
  const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
35163
35339
  function windowRect(doc2) {
35340
+ let vp = doc2.defaultView && doc2.defaultView.visualViewport;
35341
+ if (vp)
35342
+ return {
35343
+ left: 0,
35344
+ right: vp.width,
35345
+ top: 0,
35346
+ bottom: vp.height
35347
+ };
35164
35348
  return {
35165
35349
  left: 0,
35166
35350
  right: doc2.documentElement.clientWidth,
@@ -35362,14 +35546,14 @@ function posFromCaret(view, node, offset2, coords) {
35362
35546
  let desc = view.docView.nearestDesc(cur, true);
35363
35547
  if (!desc)
35364
35548
  return null;
35365
- if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent && !sawBlock || !desc.contentDOM)) {
35549
+ if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM)) {
35366
35550
  let rect = desc.dom.getBoundingClientRect();
35367
- if (desc.node.isBlock && desc.parent && !sawBlock) {
35368
- sawBlock = true;
35369
- if (rect.left > coords.left || rect.top > coords.top)
35551
+ if (desc.node.isBlock && desc.parent) {
35552
+ if (!sawBlock && rect.left > coords.left || rect.top > coords.top)
35370
35553
  outsideBlock = desc.posBefore;
35371
- else if (rect.right < coords.left || rect.bottom < coords.top)
35554
+ else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top)
35372
35555
  outsideBlock = desc.posAfter;
35556
+ sawBlock = true;
35373
35557
  }
35374
35558
  if (!desc.contentDOM && outsideBlock < 0 && !desc.node.isText) {
35375
35559
  let before = desc.node.isBlock ? coords.top < (rect.top + rect.bottom) / 2 : coords.left < (rect.left + rect.right) / 2;
@@ -35984,6 +36168,9 @@ class ViewDesc {
35984
36168
  get ignoreForCoords() {
35985
36169
  return false;
35986
36170
  }
36171
+ isText(text) {
36172
+ return false;
36173
+ }
35987
36174
  }
35988
36175
  class WidgetViewDesc extends ViewDesc {
35989
36176
  constructor(parent, widget, view, pos) {
@@ -36222,8 +36409,7 @@ class NodeViewDesc extends ViewDesc {
36222
36409
  let { from: from2, to: to2 } = view.state.selection;
36223
36410
  if (!(view.state.selection instanceof TextSelection) || from2 < pos || to2 > pos + this.node.content.size)
36224
36411
  return null;
36225
- let sel = view.domSelectionRange();
36226
- let textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);
36412
+ let textNode = view.input.compositionNode;
36227
36413
  if (!textNode || !this.dom.contains(textNode.parentNode))
36228
36414
  return null;
36229
36415
  if (this.node.inlineContent) {
@@ -36289,10 +36475,11 @@ class NodeViewDesc extends ViewDesc {
36289
36475
  }
36290
36476
  // Remove selected node marking from this node.
36291
36477
  deselectNode() {
36292
- if (this.nodeDOM.nodeType == 1)
36478
+ if (this.nodeDOM.nodeType == 1) {
36293
36479
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
36294
- if (this.contentDOM || !this.node.type.spec.draggable)
36295
- this.dom.removeAttribute("draggable");
36480
+ if (this.contentDOM || !this.node.type.spec.draggable)
36481
+ this.dom.removeAttribute("draggable");
36482
+ }
36296
36483
  }
36297
36484
  get domAtom() {
36298
36485
  return this.node.isAtom;
@@ -36358,6 +36545,9 @@ class TextViewDesc extends NodeViewDesc {
36358
36545
  get domAtom() {
36359
36546
  return false;
36360
36547
  }
36548
+ isText(text) {
36549
+ return this.node.text == text;
36550
+ }
36361
36551
  }
36362
36552
  class TrailingHackViewDesc extends ViewDesc {
36363
36553
  parseRule() {
@@ -36873,23 +37063,6 @@ function iosHacks(dom) {
36873
37063
  dom.style.cssText = oldCSS;
36874
37064
  }
36875
37065
  }
36876
- function nearbyTextNode(node, offset2) {
36877
- for (; ; ) {
36878
- if (node.nodeType == 3)
36879
- return node;
36880
- if (node.nodeType == 1 && offset2 > 0) {
36881
- if (node.childNodes.length > offset2 && node.childNodes[offset2].nodeType == 3)
36882
- return node.childNodes[offset2];
36883
- node = node.childNodes[offset2 - 1];
36884
- offset2 = nodeSize(node);
36885
- } else if (node.nodeType == 1 && offset2 < node.childNodes.length) {
36886
- node = node.childNodes[offset2];
36887
- offset2 = 0;
36888
- } else {
36889
- return null;
36890
- }
36891
- }
36892
- }
36893
37066
  function findTextInFragment(frag, text, from2, to2) {
36894
37067
  for (let i2 = 0, pos = 0; i2 < frag.childCount && pos <= to2; ) {
36895
37068
  let child = frag.child(i2++), childStart = pos;
@@ -37464,7 +37637,7 @@ function serializeForClipboard(view, slice4) {
37464
37637
  if (firstChild && firstChild.nodeType == 1)
37465
37638
  firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
37466
37639
  let text = view.someProp("clipboardTextSerializer", (f2) => f2(slice4, view)) || slice4.content.textBetween(0, slice4.content.size, "\n\n");
37467
- return { dom: wrap2, text };
37640
+ return { dom: wrap2, text, slice: slice4 };
37468
37641
  }
37469
37642
  function parseFromClipboard(view, text, html, plainText, $context) {
37470
37643
  let inCode = $context.parent.type.spec.code;
@@ -37684,6 +37857,7 @@ class InputState {
37684
37857
  this.lastTouch = 0;
37685
37858
  this.lastAndroidDelete = 0;
37686
37859
  this.composing = false;
37860
+ this.compositionNode = null;
37687
37861
  this.composingTimeout = -1;
37688
37862
  this.compositionNodes = [];
37689
37863
  this.compositionEndedAt = -2e8;
@@ -37811,8 +37985,7 @@ function updateSelection(view, selection, origin2) {
37811
37985
  if (!view.focused)
37812
37986
  view.focus();
37813
37987
  let tr2 = view.state.tr.setSelection(selection);
37814
- if (origin2 == "pointer")
37815
- tr2.setMeta("pointer", true);
37988
+ tr2.setMeta("pointer", true);
37816
37989
  view.dispatch(tr2);
37817
37990
  }
37818
37991
  function selectClickedLeaf(view, inside) {
@@ -37820,7 +37993,7 @@ function selectClickedLeaf(view, inside) {
37820
37993
  return false;
37821
37994
  let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
37822
37995
  if (node && node.isAtom && NodeSelection.isSelectable(node)) {
37823
- updateSelection(view, new NodeSelection($pos), "pointer");
37996
+ updateSelection(view, new NodeSelection($pos));
37824
37997
  return true;
37825
37998
  }
37826
37999
  return false;
@@ -37843,7 +38016,7 @@ function selectClickedNode(view, inside) {
37843
38016
  }
37844
38017
  }
37845
38018
  if (selectAt != null) {
37846
- updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
38019
+ updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
37847
38020
  return true;
37848
38021
  } else {
37849
38022
  return false;
@@ -37864,7 +38037,7 @@ function defaultTripleClick(view, inside, event) {
37864
38037
  let doc2 = view.state.doc;
37865
38038
  if (inside == -1) {
37866
38039
  if (doc2.inlineContent) {
37867
- updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size), "pointer");
38040
+ updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size));
37868
38041
  return true;
37869
38042
  }
37870
38043
  return false;
@@ -37874,9 +38047,9 @@ function defaultTripleClick(view, inside, event) {
37874
38047
  let node = i2 > $pos.depth ? $pos.nodeAfter : $pos.node(i2);
37875
38048
  let nodePos = $pos.before(i2);
37876
38049
  if (node.inlineContent)
37877
- updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size), "pointer");
38050
+ updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size));
37878
38051
  else if (NodeSelection.isSelectable(node))
37879
- updateSelection(view, NodeSelection.create(doc2, nodePos), "pointer");
38052
+ updateSelection(view, NodeSelection.create(doc2, nodePos));
37880
38053
  else
37881
38054
  continue;
37882
38055
  return true;
@@ -37933,7 +38106,7 @@ class MouseDown {
37933
38106
  }
37934
38107
  const target = flushed ? null : event.target;
37935
38108
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
37936
- this.target = targetDesc ? targetDesc.dom : null;
38109
+ this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
37937
38110
  let { selection } = view.state;
37938
38111
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
37939
38112
  this.mightDrag = {
@@ -37993,7 +38166,7 @@ class MouseDown {
37993
38166
  // thus doesn't get a reaction from ProseMirror. This
37994
38167
  // works around that.
37995
38168
  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)) {
37996
- updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)), "pointer");
38169
+ updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
37997
38170
  event.preventDefault();
37998
38171
  } else {
37999
38172
  setSelectionOrigin(this.view, "pointer");
@@ -38065,6 +38238,7 @@ editHandlers.compositionend = (view, event) => {
38065
38238
  view.input.composing = false;
38066
38239
  view.input.compositionEndedAt = event.timeStamp;
38067
38240
  view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
38241
+ view.input.compositionNode = null;
38068
38242
  if (view.input.compositionPendingChanges)
38069
38243
  Promise.resolve().then(() => view.domObserver.flush());
38070
38244
  view.input.compositionID++;
@@ -38084,6 +38258,26 @@ function clearComposition(view) {
38084
38258
  while (view.input.compositionNodes.length > 0)
38085
38259
  view.input.compositionNodes.pop().markParentsDirty();
38086
38260
  }
38261
+ function findCompositionNode(view) {
38262
+ let sel = view.domSelectionRange();
38263
+ if (!sel.focusNode)
38264
+ return null;
38265
+ let textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
38266
+ let textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
38267
+ if (textBefore && textAfter && textBefore != textAfter) {
38268
+ let descAfter = textAfter.pmViewDesc, lastChanged = view.domObserver.lastChangedTextNode;
38269
+ if (textBefore == lastChanged || textAfter == lastChanged)
38270
+ return lastChanged;
38271
+ if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
38272
+ return textAfter;
38273
+ } else if (view.input.compositionNode == textAfter) {
38274
+ let descBefore = textBefore.pmViewDesc;
38275
+ if (!(!descBefore || !descBefore.isText(textBefore.nodeValue)))
38276
+ return textAfter;
38277
+ }
38278
+ }
38279
+ return textBefore || textAfter;
38280
+ }
38087
38281
  function timestampFromCustomEvent() {
38088
38282
  let event = document.createEvent("Event");
38089
38283
  event.initEvent("event", true, true);
@@ -38218,7 +38412,8 @@ handlers.dragstart = (view, _event) => {
38218
38412
  if (desc && desc.node.type.spec.draggable && desc != view.docView)
38219
38413
  node = NodeSelection.create(view.state.doc, desc.posBefore);
38220
38414
  }
38221
- let slice4 = (node || view.state.selection).content(), { dom, text } = serializeForClipboard(view, slice4);
38415
+ let draggedSlice = (node || view.state.selection).content();
38416
+ let { dom, text, slice: slice4 } = serializeForClipboard(view, draggedSlice);
38222
38417
  event.dataTransfer.clearData();
38223
38418
  event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
38224
38419
  event.dataTransfer.effectAllowed = "copyMove";
@@ -38638,9 +38833,6 @@ class DecorationSet {
38638
38833
  return this;
38639
38834
  return local.length || children2.length ? new DecorationSet(local, children2) : empty$1;
38640
38835
  }
38641
- /**
38642
- @internal
38643
- */
38644
38836
  forChild(offset2, node) {
38645
38837
  if (this == empty$1)
38646
38838
  return this;
@@ -38994,6 +39186,7 @@ class DOMObserver {
38994
39186
  this.currentSelection = new SelectionState();
38995
39187
  this.onCharData = null;
38996
39188
  this.suppressingSelectionUpdates = false;
39189
+ this.lastChangedTextNode = null;
38997
39190
  this.observer = window.MutationObserver && new window.MutationObserver((mutations) => {
38998
39191
  for (let i2 = 0; i2 < mutations.length; i2++)
38999
39192
  this.queue.push(mutations[i2]);
@@ -39119,14 +39312,21 @@ class DOMObserver {
39119
39312
  }
39120
39313
  }
39121
39314
  }
39122
- if (gecko && added.length > 1) {
39315
+ if (gecko && added.length) {
39123
39316
  let brs = added.filter((n2) => n2.nodeName == "BR");
39124
39317
  if (brs.length == 2) {
39125
- let a2 = brs[0], b2 = brs[1];
39318
+ let [a2, b2] = brs;
39126
39319
  if (a2.parentNode && a2.parentNode.parentNode == b2.parentNode)
39127
39320
  b2.remove();
39128
39321
  else
39129
39322
  a2.remove();
39323
+ } else {
39324
+ let { focusNode } = this.currentSelection;
39325
+ for (let br2 of brs) {
39326
+ let parent = br2.parentNode;
39327
+ if (parent && parent.nodeName == "LI" && (!focusNode || blockParent(view, focusNode) != parent))
39328
+ br2.remove();
39329
+ }
39130
39330
  }
39131
39331
  }
39132
39332
  let readSel = null;
@@ -39158,8 +39358,12 @@ class DOMObserver {
39158
39358
  if (!desc || desc.ignoreMutation(mut))
39159
39359
  return null;
39160
39360
  if (mut.type == "childList") {
39161
- for (let i2 = 0; i2 < mut.addedNodes.length; i2++)
39162
- added.push(mut.addedNodes[i2]);
39361
+ for (let i2 = 0; i2 < mut.addedNodes.length; i2++) {
39362
+ let node = mut.addedNodes[i2];
39363
+ added.push(node);
39364
+ if (node.nodeType == 3)
39365
+ this.lastChangedTextNode = node;
39366
+ }
39163
39367
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
39164
39368
  return { from: desc.posBefore, to: desc.posAfter };
39165
39369
  let prev = mut.previousSibling, next = mut.nextSibling;
@@ -39180,6 +39384,7 @@ class DOMObserver {
39180
39384
  } else if (mut.type == "attributes") {
39181
39385
  return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border };
39182
39386
  } else {
39387
+ this.lastChangedTextNode = mut.target;
39183
39388
  return {
39184
39389
  from: desc.posAtStart,
39185
39390
  to: desc.posAtEnd,
@@ -39206,7 +39411,20 @@ function checkCSS(view) {
39206
39411
  cssCheckWarned = true;
39207
39412
  }
39208
39413
  }
39209
- function safariShadowSelectionRange(view) {
39414
+ function rangeToSelectionRange(view, range2) {
39415
+ let anchorNode = range2.startContainer, anchorOffset = range2.startOffset;
39416
+ let focusNode = range2.endContainer, focusOffset = range2.endOffset;
39417
+ let currentAnchor = view.domAtPos(view.state.selection.anchor);
39418
+ if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39419
+ [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39420
+ return { anchorNode, anchorOffset, focusNode, focusOffset };
39421
+ }
39422
+ function safariShadowSelectionRange(view, selection) {
39423
+ if (selection.getComposedRanges) {
39424
+ let range2 = selection.getComposedRanges(view.root)[0];
39425
+ if (range2)
39426
+ return rangeToSelectionRange(view, range2);
39427
+ }
39210
39428
  let found2;
39211
39429
  function read2(event) {
39212
39430
  event.preventDefault();
@@ -39216,12 +39434,15 @@ function safariShadowSelectionRange(view) {
39216
39434
  view.dom.addEventListener("beforeinput", read2, true);
39217
39435
  document.execCommand("indent");
39218
39436
  view.dom.removeEventListener("beforeinput", read2, true);
39219
- let anchorNode = found2.startContainer, anchorOffset = found2.startOffset;
39220
- let focusNode = found2.endContainer, focusOffset = found2.endOffset;
39221
- let currentAnchor = view.domAtPos(view.state.selection.anchor);
39222
- if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39223
- [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39224
- return { anchorNode, anchorOffset, focusNode, focusOffset };
39437
+ return found2 ? rangeToSelectionRange(view, found2) : null;
39438
+ }
39439
+ function blockParent(view, node) {
39440
+ for (let p2 = node.parentNode; p2 && p2 != view.dom; p2 = p2.parentNode) {
39441
+ let desc = view.docView.nearestDesc(p2, true);
39442
+ if (desc && desc.node.isBlock)
39443
+ return p2;
39444
+ }
39445
+ return null;
39225
39446
  }
39226
39447
  function parseBetween(view, from_, to_) {
39227
39448
  let { node: parent, fromOffset, toOffset, from: from2, to: to2 } = view.docView.parseRange(from_, to_);
@@ -39341,10 +39562,6 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39341
39562
  return;
39342
39563
  }
39343
39564
  }
39344
- if (chrome && view.cursorWrapper && parse2.sel && parse2.sel.anchor == view.cursorWrapper.deco.from && parse2.sel.head == parse2.sel.anchor) {
39345
- let size2 = change.endB - change.start;
39346
- parse2.sel = { anchor: parse2.sel.anchor + size2, head: parse2.sel.anchor + size2 };
39347
- }
39348
39565
  view.input.domChangeCount++;
39349
39566
  if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
39350
39567
  if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse2.from) {
@@ -39368,7 +39585,7 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39368
39585
  view.input.lastIOSEnter = 0;
39369
39586
  return;
39370
39587
  }
39371
- if (view.state.selection.anchor > change.start && looksLikeJoin(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39588
+ if (view.state.selection.anchor > change.start && looksLikeBackspace(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39372
39589
  if (android && chrome)
39373
39590
  view.domObserver.suppressSelectionUpdates();
39374
39591
  return;
@@ -39452,12 +39669,18 @@ function isMarkChange(cur, prev) {
39452
39669
  if (Fragment.from(updated).eq(cur))
39453
39670
  return { mark, type: type3 };
39454
39671
  }
39455
- function looksLikeJoin(old, start2, end2, $newStart, $newEnd) {
39456
- if (!$newStart.parent.isTextblock || // The content must have shrunk
39457
- end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39458
- skipClosingAndOpening($newStart, true, false) < $newEnd.pos)
39672
+ function looksLikeBackspace(old, start2, end2, $newStart, $newEnd) {
39673
+ if (
39674
+ // The content must have shrunk
39675
+ end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39676
+ skipClosingAndOpening($newStart, true, false) < $newEnd.pos
39677
+ )
39459
39678
  return false;
39460
39679
  let $start = old.resolve(start2);
39680
+ if (!$newStart.parent.isTextblock) {
39681
+ let after = $start.nodeAfter;
39682
+ return after != null && end2 == start2 + after.nodeSize;
39683
+ }
39461
39684
  if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock)
39462
39685
  return false;
39463
39686
  let $next = old.resolve(skipClosingAndOpening($start, true, true));
@@ -39646,8 +39869,10 @@ class EditorView {
39646
39869
  let forceSelUpdate = updateDoc && (ie$1 || chrome) && !this.composing && !prev.selection.empty && !state2.selection.empty && selectionContextChanged(prev.selection, state2.selection);
39647
39870
  if (updateDoc) {
39648
39871
  let chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;
39872
+ if (this.composing)
39873
+ this.input.compositionNode = findCompositionNode(this);
39649
39874
  if (redraw || !this.docView.update(state2.doc, outerDeco, innerDeco, this)) {
39650
- this.docView.updateOuterDeco([]);
39875
+ this.docView.updateOuterDeco(outerDeco);
39651
39876
  this.docView.destroy();
39652
39877
  this.docView = docViewDesc(state2.doc, outerDeco, innerDeco, this.dom, this);
39653
39878
  }
@@ -39906,6 +40131,7 @@ class EditorView {
39906
40131
  }
39907
40132
  this.docView.destroy();
39908
40133
  this.docView = null;
40134
+ clearReusedRange();
39909
40135
  }
39910
40136
  /**
39911
40137
  This is true when the view has been
@@ -39941,7 +40167,8 @@ class EditorView {
39941
40167
  @internal
39942
40168
  */
39943
40169
  domSelectionRange() {
39944
- return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom ? safariShadowSelectionRange(this) : this.domSelection();
40170
+ let sel = this.domSelection();
40171
+ return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;
39945
40172
  }
39946
40173
  /**
39947
40174
  @internal
@@ -40932,7 +41159,8 @@ function getAttributesFromExtensions(extensions) {
40932
41159
  const context = {
40933
41160
  name: extension.name,
40934
41161
  options: extension.options,
40935
- storage: extension.storage
41162
+ storage: extension.storage,
41163
+ extensions: nodeAndMarkExtensions
40936
41164
  };
40937
41165
  const addGlobalAttributes = getExtensionField(extension, "addGlobalAttributes", context);
40938
41166
  if (!addGlobalAttributes) {
@@ -41058,7 +41286,7 @@ function fromString(value) {
41058
41286
  return value;
41059
41287
  }
41060
41288
  function injectExtensionAttributesToParseRule(parseRule, extensionAttributes) {
41061
- if (parseRule.style) {
41289
+ if ("style" in parseRule) {
41062
41290
  return parseRule;
41063
41291
  }
41064
41292
  return {
@@ -41123,6 +41351,7 @@ function getSchemaByResolvedExtensions(extensions, editor) {
41123
41351
  selectable: callOrReturn(getExtensionField(extension, "selectable", context)),
41124
41352
  draggable: callOrReturn(getExtensionField(extension, "draggable", context)),
41125
41353
  code: callOrReturn(getExtensionField(extension, "code", context)),
41354
+ whitespace: callOrReturn(getExtensionField(extension, "whitespace", context)),
41126
41355
  defining: callOrReturn(getExtensionField(extension, "defining", context)),
41127
41356
  isolating: callOrReturn(getExtensionField(extension, "isolating", context)),
41128
41357
  attrs: Object.fromEntries(extensionAttributes.map((extensionAttribute) => {
@@ -41678,7 +41907,7 @@ class ExtensionManager {
41678
41907
  const plugins2 = [];
41679
41908
  const addKeyboardShortcuts = getExtensionField(extension, "addKeyboardShortcuts", context);
41680
41909
  let defaultBindings = {};
41681
- if (extension.type === "mark" && extension.config.exitable) {
41910
+ if (extension.type === "mark" && getExtensionField(extension, "exitable", context)) {
41682
41911
  defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension });
41683
41912
  }
41684
41913
  if (addKeyboardShortcuts) {
@@ -41826,14 +42055,10 @@ function mergeDeep(target, source) {
41826
42055
  const output = { ...target };
41827
42056
  if (isPlainObject(target) && isPlainObject(source)) {
41828
42057
  Object.keys(source).forEach((key) => {
41829
- if (isPlainObject(source[key])) {
41830
- if (!(key in target)) {
41831
- Object.assign(output, { [key]: source[key] });
41832
- } else {
41833
- output[key] = mergeDeep(target[key], source[key]);
41834
- }
42058
+ if (isPlainObject(source[key]) && isPlainObject(target[key])) {
42059
+ output[key] = mergeDeep(target[key], source[key]);
41835
42060
  } else {
41836
- Object.assign(output, { [key]: source[key] });
42061
+ output[key] = source[key];
41837
42062
  }
41838
42063
  });
41839
42064
  }
@@ -41872,13 +42097,14 @@ class Extension {
41872
42097
  return new Extension(config);
41873
42098
  }
41874
42099
  configure(options = {}) {
41875
- const extension = this.extend();
42100
+ const extension = this.extend({
42101
+ ...this.config,
42102
+ addOptions: () => {
42103
+ return mergeDeep(this.options, options);
42104
+ }
42105
+ });
42106
+ extension.name = this.name;
41876
42107
  extension.parent = this.parent;
41877
- extension.options = mergeDeep(this.options, options);
41878
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
41879
- name: extension.name,
41880
- options: extension.options
41881
- }));
41882
42108
  return extension;
41883
42109
  }
41884
42110
  extend(extendedConfig = {}) {
@@ -41886,7 +42112,7 @@ class Extension {
41886
42112
  extension.parent = this;
41887
42113
  this.child = extension;
41888
42114
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
41889
- if (extendedConfig.defaultOptions) {
42115
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
41890
42116
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
41891
42117
  }
41892
42118
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -42270,13 +42496,47 @@ function createNodeFromContent(content, schema, options) {
42270
42496
  }
42271
42497
  return schema.nodeFromJSON(content);
42272
42498
  } catch (error) {
42499
+ if (options.errorOnInvalidContent) {
42500
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: error });
42501
+ }
42273
42502
  console.warn("[tiptap warn]: Invalid content.", "Passed value:", content, "Error:", error);
42274
42503
  return createNodeFromContent("", schema, options);
42275
42504
  }
42276
42505
  }
42277
42506
  if (isTextContent) {
42278
- const parser = DOMParser.fromSchema(schema);
42279
- return options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42507
+ let schemaToUse = schema;
42508
+ let hasInvalidContent = false;
42509
+ let invalidContent = "";
42510
+ if (options.errorOnInvalidContent) {
42511
+ schemaToUse = new Schema({
42512
+ topNode: schema.spec.topNode,
42513
+ marks: schema.spec.marks,
42514
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
42515
+ // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
42516
+ nodes: schema.spec.nodes.append({
42517
+ __tiptap__private__unknown__catch__all__node: {
42518
+ content: "inline*",
42519
+ group: "block",
42520
+ parseDOM: [
42521
+ {
42522
+ tag: "*",
42523
+ getAttrs: (e) => {
42524
+ hasInvalidContent = true;
42525
+ invalidContent = typeof e === "string" ? e : e.outerHTML;
42526
+ return null;
42527
+ }
42528
+ }
42529
+ ]
42530
+ }
42531
+ })
42532
+ });
42533
+ }
42534
+ const parser = DOMParser.fromSchema(schemaToUse);
42535
+ const response = options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42536
+ if (options.errorOnInvalidContent && hasInvalidContent) {
42537
+ throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${invalidContent}`) });
42538
+ }
42539
+ return response;
42280
42540
  }
42281
42541
  return createNodeFromContent("", schema, options);
42282
42542
  }
@@ -42299,9 +42559,10 @@ function selectionToInsertionEnd(tr2, startLen, bias) {
42299
42559
  tr2.setSelection(Selection$1.near(tr2.doc.resolve(end2), bias));
42300
42560
  }
42301
42561
  const isFragment = (nodeOrFragment) => {
42302
- return nodeOrFragment.toString().startsWith("<");
42562
+ return !("type" in nodeOrFragment);
42303
42563
  };
42304
42564
  const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, editor }) => {
42565
+ var _a2;
42305
42566
  if (dispatch) {
42306
42567
  options = {
42307
42568
  parseOptions: {},
@@ -42310,14 +42571,17 @@ const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, edit
42310
42571
  applyPasteRules: false,
42311
42572
  ...options
42312
42573
  };
42313
- const content = createNodeFromContent(value, editor.schema, {
42314
- parseOptions: {
42315
- preserveWhitespace: "full",
42316
- ...options.parseOptions
42317
- }
42318
- });
42319
- if (content.toString() === "<>") {
42320
- return true;
42574
+ let content;
42575
+ try {
42576
+ content = createNodeFromContent(value, editor.schema, {
42577
+ parseOptions: {
42578
+ preserveWhitespace: "full",
42579
+ ...options.parseOptions
42580
+ },
42581
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42582
+ });
42583
+ } catch (e) {
42584
+ return false;
42321
42585
  }
42322
42586
  let { from: from2, to: to2 } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
42323
42587
  let isOnlyTextContent = true;
@@ -42374,7 +42638,7 @@ const joinBackward = () => ({ state: state2, dispatch }) => {
42374
42638
  const joinForward = () => ({ state: state2, dispatch }) => {
42375
42639
  return joinForward$1(state2, dispatch);
42376
42640
  };
42377
- const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42641
+ const joinItemBackward = () => ({ state: state2, dispatch, tr: tr2 }) => {
42378
42642
  try {
42379
42643
  const point2 = joinPoint(state2.doc, state2.selection.$from.pos, -1);
42380
42644
  if (point2 === null || point2 === void 0) {
@@ -42385,7 +42649,7 @@ const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42385
42649
  dispatch(tr2);
42386
42650
  }
42387
42651
  return true;
42388
- } catch {
42652
+ } catch (e) {
42389
42653
  return false;
42390
42654
  }
42391
42655
  };
@@ -42603,16 +42867,32 @@ const selectTextblockEnd = () => ({ state: state2, dispatch }) => {
42603
42867
  const selectTextblockStart = () => ({ state: state2, dispatch }) => {
42604
42868
  return selectTextblockStart$1(state2, dispatch);
42605
42869
  };
42606
- function createDocument(content, schema, parseOptions = {}) {
42607
- return createNodeFromContent(content, schema, { slice: false, parseOptions });
42870
+ function createDocument(content, schema, parseOptions = {}, options = {}) {
42871
+ return createNodeFromContent(content, schema, {
42872
+ slice: false,
42873
+ parseOptions,
42874
+ errorOnInvalidContent: options.errorOnInvalidContent
42875
+ });
42608
42876
  }
42609
- const setContent$1 = (content, emitUpdate = false, parseOptions = {}) => ({ tr: tr2, editor, dispatch }) => {
42877
+ const setContent$1 = (content, emitUpdate = false, parseOptions = {}, options = {}) => ({ editor, tr: tr2, dispatch, commands: commands2 }) => {
42878
+ var _a2, _b;
42610
42879
  const { doc: doc2 } = tr2;
42611
- const document2 = createDocument(content, editor.schema, parseOptions);
42880
+ if (parseOptions.preserveWhitespace !== "full") {
42881
+ const document2 = createDocument(content, editor.schema, parseOptions, {
42882
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42883
+ });
42884
+ if (dispatch) {
42885
+ tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42886
+ }
42887
+ return true;
42888
+ }
42612
42889
  if (dispatch) {
42613
- tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42890
+ tr2.setMeta("preventUpdate", !emitUpdate);
42614
42891
  }
42615
- return true;
42892
+ return commands2.insertContentAt({ from: 0, to: doc2.content.size }, content, {
42893
+ parseOptions,
42894
+ errorOnInvalidContent: (_b = options.errorOnInvalidContent) !== null && _b !== void 0 ? _b : editor.options.enableContentCheck
42895
+ });
42616
42896
  };
42617
42897
  function getMarkAttributes(state2, typeOrName) {
42618
42898
  const type3 = getMarkType(typeOrName, state2.schema);
@@ -42815,10 +43095,11 @@ function isList(name, extensions) {
42815
43095
  return group.split(" ").includes("list");
42816
43096
  }
42817
43097
  function isNodeEmpty(node) {
42818
- var _a2;
42819
- const defaultContent = (_a2 = node.type.createAndFill()) === null || _a2 === void 0 ? void 0 : _a2.toJSON();
42820
- const content = node.toJSON();
42821
- return JSON.stringify(defaultContent) === JSON.stringify(content);
43098
+ const defaultContent = node.type.createAndFill();
43099
+ if (!defaultContent) {
43100
+ return false;
43101
+ }
43102
+ return node.eq(defaultContent);
42822
43103
  }
42823
43104
  function isNodeSelection(value) {
42824
43105
  return value instanceof NodeSelection;
@@ -43333,14 +43614,14 @@ var commands = /* @__PURE__ */ Object.freeze({
43333
43614
  forEach,
43334
43615
  insertContent,
43335
43616
  insertContentAt,
43336
- joinUp,
43337
- joinDown,
43338
43617
  joinBackward,
43618
+ joinDown,
43339
43619
  joinForward,
43340
43620
  joinItemBackward,
43341
43621
  joinItemForward,
43342
43622
  joinTextblockBackward,
43343
43623
  joinTextblockForward,
43624
+ joinUp,
43344
43625
  keyboardShortcut,
43345
43626
  lift,
43346
43627
  liftEmptyBlock,
@@ -43537,13 +43818,16 @@ const Tabindex = Extension.create({
43537
43818
  new Plugin({
43538
43819
  key: new PluginKey("tabindex"),
43539
43820
  props: {
43540
- attributes: this.editor.isEditable ? { tabindex: "0" } : {}
43821
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
43541
43822
  }
43542
43823
  })
43543
43824
  ];
43544
43825
  }
43545
43826
  });
43546
43827
  class NodePos {
43828
+ get name() {
43829
+ return this.node.type.name;
43830
+ }
43547
43831
  constructor(pos, editor, isBlock = false, node = null) {
43548
43832
  this.currentNode = null;
43549
43833
  this.actualDepth = null;
@@ -43552,9 +43836,6 @@ class NodePos {
43552
43836
  this.editor = editor;
43553
43837
  this.currentNode = node;
43554
43838
  }
43555
- get name() {
43556
- return this.node.type.name;
43557
- }
43558
43839
  get node() {
43559
43840
  return this.currentNode || this.resolvedPos.node();
43560
43841
  }
@@ -43786,7 +44067,7 @@ img.ProseMirror-separator {
43786
44067
  opacity: 0
43787
44068
  }`;
43788
44069
  function createStyleTag(style2, nonce, suffix) {
43789
- const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ""}]`);
44070
+ const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${""}]`);
43790
44071
  if (tiptapStyleTag !== null) {
43791
44072
  return tiptapStyleTag;
43792
44073
  }
@@ -43794,7 +44075,7 @@ function createStyleTag(style2, nonce, suffix) {
43794
44075
  if (nonce) {
43795
44076
  styleNode.setAttribute("nonce", nonce);
43796
44077
  }
43797
- styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ""}`, "");
44078
+ styleNode.setAttribute(`data-tiptap-style${""}`, "");
43798
44079
  styleNode.innerHTML = style2;
43799
44080
  document.getElementsByTagName("head")[0].appendChild(styleNode);
43800
44081
  return styleNode;
@@ -43818,6 +44099,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43818
44099
  enableInputRules: true,
43819
44100
  enablePasteRules: true,
43820
44101
  enableCoreExtensions: true,
44102
+ enableContentCheck: false,
43821
44103
  onBeforeCreate: () => null,
43822
44104
  onCreate: () => null,
43823
44105
  onUpdate: () => null,
@@ -43825,7 +44107,10 @@ let Editor$1 = class Editor2 extends EventEmitter {
43825
44107
  onTransaction: () => null,
43826
44108
  onFocus: () => null,
43827
44109
  onBlur: () => null,
43828
- onDestroy: () => null
44110
+ onDestroy: () => null,
44111
+ onContentError: ({ error }) => {
44112
+ throw error;
44113
+ }
43829
44114
  };
43830
44115
  this.isCapturingTransaction = false;
43831
44116
  this.capturedTransaction = null;
@@ -43835,6 +44120,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43835
44120
  this.createSchema();
43836
44121
  this.on("beforeCreate", this.options.onBeforeCreate);
43837
44122
  this.emit("beforeCreate", { editor: this });
44123
+ this.on("contentError", this.options.onContentError);
43838
44124
  this.createView();
43839
44125
  this.injectCSS();
43840
44126
  this.on("create", this.options.onCreate);
@@ -43988,7 +44274,23 @@ let Editor$1 = class Editor2 extends EventEmitter {
43988
44274
  * Creates a ProseMirror view.
43989
44275
  */
43990
44276
  createView() {
43991
- const doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions);
44277
+ let doc2;
44278
+ try {
44279
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
44280
+ } catch (e) {
44281
+ if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) {
44282
+ throw e;
44283
+ }
44284
+ this.emit("contentError", {
44285
+ editor: this,
44286
+ error: e,
44287
+ disableCollaboration: () => {
44288
+ this.options.extensions = this.options.extensions.filter((extension) => extension.name !== "collaboration");
44289
+ this.createExtensionManager();
44290
+ }
44291
+ });
44292
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: false });
44293
+ }
43992
44294
  const selection = resolveFocusPosition(doc2, this.options.autofocus);
43993
44295
  this.view = new EditorView(this.options.element, {
43994
44296
  ...this.options.editorProps,
@@ -44226,7 +44528,8 @@ function nodeInputRule(config) {
44226
44528
  tr2.insertText(lastChar, start2 + match2[0].length - 1);
44227
44529
  tr2.replaceWith(matchStart, end2, newNode);
44228
44530
  } else if (match2[0]) {
44229
- tr2.insert(start2 - 1, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44531
+ const insertionStart = config.type.isInline ? start2 : start2 - 1;
44532
+ tr2.insert(insertionStart, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44230
44533
  }
44231
44534
  tr2.scrollIntoView();
44232
44535
  }
@@ -44311,20 +44614,22 @@ class Mark {
44311
44614
  return new Mark(config);
44312
44615
  }
44313
44616
  configure(options = {}) {
44314
- const extension = this.extend();
44315
- extension.options = mergeDeep(this.options, options);
44316
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44317
- name: extension.name,
44318
- options: extension.options
44319
- }));
44617
+ const extension = this.extend({
44618
+ ...this.config,
44619
+ addOptions: () => {
44620
+ return mergeDeep(this.options, options);
44621
+ }
44622
+ });
44623
+ extension.name = this.name;
44624
+ extension.parent = this.parent;
44320
44625
  return extension;
44321
44626
  }
44322
44627
  extend(extendedConfig = {}) {
44323
- const extension = new Mark({ ...this.config, ...extendedConfig });
44628
+ const extension = new Mark(extendedConfig);
44324
44629
  extension.parent = this;
44325
44630
  this.child = extension;
44326
44631
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44327
- if (extendedConfig.defaultOptions) {
44632
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44328
44633
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44329
44634
  }
44330
44635
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44390,20 +44695,22 @@ let Node$2 = class Node3 {
44390
44695
  return new Node3(config);
44391
44696
  }
44392
44697
  configure(options = {}) {
44393
- const extension = this.extend();
44394
- extension.options = mergeDeep(this.options, options);
44395
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44396
- name: extension.name,
44397
- options: extension.options
44398
- }));
44698
+ const extension = this.extend({
44699
+ ...this.config,
44700
+ addOptions: () => {
44701
+ return mergeDeep(this.options, options);
44702
+ }
44703
+ });
44704
+ extension.name = this.name;
44705
+ extension.parent = this.parent;
44399
44706
  return extension;
44400
44707
  }
44401
44708
  extend(extendedConfig = {}) {
44402
- const extension = new Node3({ ...this.config, ...extendedConfig });
44709
+ const extension = new Node3(extendedConfig);
44403
44710
  extension.parent = this;
44404
44711
  this.child = extension;
44405
44712
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44406
- if (extendedConfig.defaultOptions) {
44713
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44407
44714
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44408
44715
  }
44409
44716
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44938,14 +45245,12 @@ const CodeBlock = Node$2.create({
44938
45245
  if (!text || !language) {
44939
45246
  return false;
44940
45247
  }
44941
- const { tr: tr2 } = view.state;
44942
- if (view.state.selection.from === view.state.doc.nodeSize - (1 + view.state.selection.$to.depth * 2)) {
44943
- tr2.insert(view.state.selection.from - 1, this.type.create({ language }));
44944
- } else {
44945
- tr2.replaceSelectionWith(this.type.create({ language }));
45248
+ const { tr: tr2, schema } = view.state;
45249
+ const textNode = schema.text(text.replace(/\r\n?/g, "\n"));
45250
+ tr2.replaceSelectionWith(this.type.create({ language }, textNode));
45251
+ if (tr2.selection.$from.parent.type !== this.type) {
45252
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44946
45253
  }
44947
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44948
- tr2.insertText(text.replace(/\r\n?/g, "\n"));
44949
45254
  tr2.setMeta("paste", true);
44950
45255
  view.dispatch(tr2);
44951
45256
  return true;
@@ -45861,13 +46166,13 @@ function applyTransaction(history2, state2, tr2, options) {
45861
46166
  return history2;
45862
46167
  } else if (appended && appended.getMeta(historyKey)) {
45863
46168
  if (appended.getMeta(historyKey).redo)
45864
- return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state2)), history2.undone, rangesFor(tr2.mapping.maps[tr2.steps.length - 1]), history2.prevTime, history2.prevComposition);
46169
+ return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state2)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
45865
46170
  else
45866
46171
  return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state2)), null, history2.prevTime, history2.prevComposition);
45867
46172
  } else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
45868
46173
  let composition = tr2.getMeta("composition");
45869
46174
  let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
45870
- let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps[tr2.steps.length - 1]);
46175
+ let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
45871
46176
  return new HistoryState(history2.done.addTransform(tr2, newGroup ? state2.selection.getBookmark() : void 0, options, mustPreserveItems(state2)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
45872
46177
  } else if (rebased = tr2.getMeta("rebased")) {
45873
46178
  return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
@@ -45888,9 +46193,10 @@ function isAdjacentTo(transform, prevRanges) {
45888
46193
  });
45889
46194
  return adjacent;
45890
46195
  }
45891
- function rangesFor(map4) {
46196
+ function rangesFor(maps) {
45892
46197
  let result2 = [];
45893
- map4.forEach((_from, _to, from2, to2) => result2.push(from2, to2));
46198
+ for (let i2 = maps.length - 1; i2 >= 0 && result2.length == 0; i2--)
46199
+ maps[i2].forEach((_from, _to, from2, to2) => result2.push(from2, to2));
45894
46200
  return result2;
45895
46201
  }
45896
46202
  function mapRanges(ranges, mapping) {
@@ -45904,16 +46210,16 @@ function mapRanges(ranges, mapping) {
45904
46210
  }
45905
46211
  return result2;
45906
46212
  }
45907
- function histTransaction(history2, state2, dispatch, redo2) {
46213
+ function histTransaction(history2, state2, redo2) {
45908
46214
  let preserveItems = mustPreserveItems(state2);
45909
46215
  let histOptions = historyKey.get(state2).spec.config;
45910
46216
  let pop = (redo2 ? history2.undone : history2.done).popEvent(state2, preserveItems);
45911
46217
  if (!pop)
45912
- return;
46218
+ return null;
45913
46219
  let selection = pop.selection.resolve(pop.transform.doc);
45914
46220
  let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state2.selection.getBookmark(), histOptions, preserveItems);
45915
46221
  let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
45916
- dispatch(pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist }).scrollIntoView());
46222
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
45917
46223
  }
45918
46224
  let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
45919
46225
  function mustPreserveItems(state2) {
@@ -45961,22 +46267,21 @@ function history(config = {}) {
45961
46267
  }
45962
46268
  });
45963
46269
  }
45964
- const undo = (state2, dispatch) => {
45965
- let hist = historyKey.getState(state2);
45966
- if (!hist || hist.done.eventCount == 0)
45967
- return false;
45968
- if (dispatch)
45969
- histTransaction(hist, state2, dispatch, false);
45970
- return true;
45971
- };
45972
- const redo = (state2, dispatch) => {
45973
- let hist = historyKey.getState(state2);
45974
- if (!hist || hist.undone.eventCount == 0)
45975
- return false;
45976
- if (dispatch)
45977
- histTransaction(hist, state2, dispatch, true);
45978
- return true;
45979
- };
46270
+ function buildCommand(redo2, scroll) {
46271
+ return (state2, dispatch) => {
46272
+ let hist = historyKey.getState(state2);
46273
+ if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
46274
+ return false;
46275
+ if (dispatch) {
46276
+ let tr2 = histTransaction(hist, state2, redo2);
46277
+ if (tr2)
46278
+ dispatch(scroll ? tr2.scrollIntoView() : tr2);
46279
+ }
46280
+ return true;
46281
+ };
46282
+ }
46283
+ const undo = buildCommand(false, true);
46284
+ const redo = buildCommand(true, true);
45980
46285
  const History = Extension.create({
45981
46286
  name: "history",
45982
46287
  addOptions() {
@@ -46028,10 +46333,20 @@ const HorizontalRule = Node$2.create({
46028
46333
  addCommands() {
46029
46334
  return {
46030
46335
  setHorizontalRule: () => ({ chain, state: state2 }) => {
46031
- const { $to: $originTo } = state2.selection;
46336
+ const { selection } = state2;
46337
+ const { $from: $originFrom, $to: $originTo } = selection;
46032
46338
  const currentChain = chain();
46033
- if ($originTo.parentOffset === 0) {
46034
- currentChain.insertContentAt(Math.max($originTo.pos - 2, 0), { type: this.name });
46339
+ if ($originFrom.parentOffset === 0) {
46340
+ currentChain.insertContentAt({
46341
+ from: Math.max($originFrom.pos - 1, 0),
46342
+ to: $originTo.pos
46343
+ }, {
46344
+ type: this.name
46345
+ });
46346
+ } else if (isNodeSelection(selection)) {
46347
+ currentChain.insertContentAt($originTo.pos, {
46348
+ type: this.name
46349
+ });
46035
46350
  } else {
46036
46351
  currentChain.insertContent({ type: this.name });
46037
46352
  }
@@ -46417,11 +46732,11 @@ const StarterKit = Extension.create({
46417
46732
  addExtensions() {
46418
46733
  var _a2, _b, _c, _d, _e2, _f, _g, _h, _j, _k, _l2, _m, _o, _p, _q, _r2, _s, _t2;
46419
46734
  const extensions = [];
46420
- if (this.options.blockquote !== false) {
46421
- extensions.push(Blockquote.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.blockquote));
46422
- }
46423
46735
  if (this.options.bold !== false) {
46424
- extensions.push(Bold.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.bold));
46736
+ extensions.push(Bold.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.bold));
46737
+ }
46738
+ if (this.options.blockquote !== false) {
46739
+ extensions.push(Blockquote.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.blockquote));
46425
46740
  }
46426
46741
  if (this.options.bulletList !== false) {
46427
46742
  extensions.push(BulletList.configure((_c = this.options) === null || _c === void 0 ? void 0 : _c.bulletList));
@@ -49228,7 +49543,7 @@ class BubbleMenuView {
49228
49543
  }
49229
49544
  update(view, oldState) {
49230
49545
  const { state: state2 } = view;
49231
- const hasValidSelection = state2.selection.$from.pos !== state2.selection.$to.pos;
49546
+ const hasValidSelection = state2.selection.from !== state2.selection.to;
49232
49547
  if (this.updateDelay > 0 && hasValidSelection) {
49233
49548
  this.handleDebouncedUpdate(view, oldState);
49234
49549
  return;
@@ -52273,9 +52588,6 @@ function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
52273
52588
  return { colgroup, tableWidth, tableMinWidth };
52274
52589
  }
52275
52590
  function createCell(cellType, cellContent) {
52276
- if (cellContent) {
52277
- return cellType.createChecked(null, cellContent);
52278
- }
52279
52591
  return cellType.createAndFill();
52280
52592
  }
52281
52593
  function getTableNodeTypes(schema) {
@@ -52297,12 +52609,12 @@ function createTable$1(schema, rowsCount, colsCount, withHeaderRow, cellContent)
52297
52609
  const headerCells = [];
52298
52610
  const cells = [];
52299
52611
  for (let index2 = 0; index2 < colsCount; index2 += 1) {
52300
- const cell = createCell(types.cell, cellContent);
52612
+ const cell = createCell(types.cell);
52301
52613
  if (cell) {
52302
52614
  cells.push(cell);
52303
52615
  }
52304
52616
  if (withHeaderRow) {
52305
- const headerCell = createCell(types.header_cell, cellContent);
52617
+ const headerCell = createCell(types.header_cell);
52306
52618
  if (headerCell) {
52307
52619
  headerCells.push(headerCell);
52308
52620
  }
@@ -52380,7 +52692,7 @@ const Table = Node$2.create({
52380
52692
  insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr: tr2, dispatch, editor }) => {
52381
52693
  const node = createTable$1(editor.schema, rows, cols, withHeaderRow);
52382
52694
  if (dispatch) {
52383
- const offset2 = tr2.selection.anchor + 1;
52695
+ const offset2 = tr2.selection.from + 1;
52384
52696
  tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(offset2)));
52385
52697
  }
52386
52698
  return true;
@@ -52857,18 +53169,7 @@ function _typeof$1(obj) {
52857
53169
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
52858
53170
  }, _typeof$1(obj);
52859
53171
  }
52860
- function _defineProperties$2(target, props2) {
52861
- for (var i2 = 0; i2 < props2.length; i2++) {
52862
- var descriptor = props2[i2];
52863
- descriptor.enumerable = descriptor.enumerable || false;
52864
- descriptor.configurable = true;
52865
- if ("value" in descriptor) descriptor.writable = true;
52866
- Object.defineProperty(target, descriptor.key, descriptor);
52867
- }
52868
- }
52869
53172
  function _createClass$2(Constructor, protoProps, staticProps) {
52870
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
52871
- if (staticProps) _defineProperties$2(Constructor, staticProps);
52872
53173
  Object.defineProperty(Constructor, "prototype", { writable: false });
52873
53174
  return Constructor;
52874
53175
  }
@@ -53045,7 +53346,6 @@ function _defineProperties$1(target, props2) {
53045
53346
  }
53046
53347
  function _createClass$1(Constructor, protoProps, staticProps) {
53047
53348
  if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
53048
- if (staticProps) _defineProperties$1(Constructor, staticProps);
53049
53349
  Object.defineProperty(Constructor, "prototype", { writable: false });
53050
53350
  return Constructor;
53051
53351
  }
@@ -53687,10 +53987,10 @@ var DIGITS = {
53687
53987
  function parseDigit(character) {
53688
53988
  return DIGITS[character];
53689
53989
  }
53690
- function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53990
+ function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53691
53991
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53692
53992
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53693
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$5(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
53993
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike) {
53694
53994
  if (it2) o2 = it2;
53695
53995
  var i2 = 0;
53696
53996
  return function() {
@@ -53700,15 +54000,15 @@ function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53700
54000
  }
53701
54001
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53702
54002
  }
53703
- function _unsupportedIterableToArray$5(o2, minLen) {
54003
+ function _unsupportedIterableToArray$4(o2, minLen) {
53704
54004
  if (!o2) return;
53705
- if (typeof o2 === "string") return _arrayLikeToArray$5(o2, minLen);
54005
+ if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53706
54006
  var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53707
54007
  if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53708
54008
  if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53709
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$5(o2, minLen);
54009
+ if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53710
54010
  }
53711
- function _arrayLikeToArray$5(arr, len) {
54011
+ function _arrayLikeToArray$4(arr, len) {
53712
54012
  if (len == null || len > arr.length) len = arr.length;
53713
54013
  for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53714
54014
  arr2[i2] = arr[i2];
@@ -53717,7 +54017,7 @@ function _arrayLikeToArray$5(arr, len) {
53717
54017
  }
53718
54018
  function parseIncompletePhoneNumber(string2) {
53719
54019
  var result2 = "";
53720
- for (var _iterator = _createForOfIteratorHelperLoose$4(string2.split("")), _step; !(_step = _iterator()).done; ) {
54020
+ for (var _iterator = _createForOfIteratorHelperLoose$3(string2.split("")), _step; !(_step = _iterator()).done; ) {
53721
54021
  var character = _step.value;
53722
54022
  result2 += parsePhoneNumberCharacter(character, result2) || "";
53723
54023
  }
@@ -53726,55 +54026,12 @@ function parseIncompletePhoneNumber(string2) {
53726
54026
  function parsePhoneNumberCharacter(character, prevParsedCharacters, emitEvent) {
53727
54027
  if (character === "+") {
53728
54028
  if (prevParsedCharacters) {
53729
- if (typeof emitEvent === "function") {
53730
- emitEvent("end");
53731
- }
53732
54029
  return;
53733
54030
  }
53734
54031
  return "+";
53735
54032
  }
53736
54033
  return parseDigit(character);
53737
54034
  }
53738
- function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53739
- var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53740
- if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53741
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
53742
- if (it2) o2 = it2;
53743
- var i2 = 0;
53744
- return function() {
53745
- if (i2 >= o2.length) return { done: true };
53746
- return { done: false, value: o2[i2++] };
53747
- };
53748
- }
53749
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53750
- }
53751
- function _unsupportedIterableToArray$4(o2, minLen) {
53752
- if (!o2) return;
53753
- if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53754
- var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53755
- if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53756
- if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53757
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53758
- }
53759
- function _arrayLikeToArray$4(arr, len) {
53760
- if (len == null || len > arr.length) len = arr.length;
53761
- for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53762
- arr2[i2] = arr[i2];
53763
- }
53764
- return arr2;
53765
- }
53766
- function mergeArrays(a2, b2) {
53767
- var merged = a2.slice();
53768
- for (var _iterator = _createForOfIteratorHelperLoose$3(b2), _step; !(_step = _iterator()).done; ) {
53769
- var element = _step.value;
53770
- if (a2.indexOf(element) < 0) {
53771
- merged.push(element);
53772
- }
53773
- }
53774
- return merged.sort(function(a3, b3) {
53775
- return a3 - b3;
53776
- });
53777
- }
53778
54035
  function checkNumberLength(nationalNumber, metadata2) {
53779
54036
  return checkNumberLengthForType(nationalNumber, void 0, metadata2);
53780
54037
  }
@@ -53784,17 +54041,6 @@ function checkNumberLengthForType(nationalNumber, type3, metadata2) {
53784
54041
  if (!possible_lengths) {
53785
54042
  return "IS_POSSIBLE";
53786
54043
  }
53787
- if (type3 === "FIXED_LINE_OR_MOBILE") {
53788
- if (!metadata2.type("FIXED_LINE")) {
53789
- return checkNumberLengthForType(nationalNumber, "MOBILE", metadata2);
53790
- }
53791
- var mobile_type = metadata2.type("MOBILE");
53792
- if (mobile_type) {
53793
- possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths());
53794
- }
53795
- } else if (type3 && !type_info) {
53796
- return "INVALID_LENGTH";
53797
- }
53798
54044
  var actual_length = nationalNumber.length;
53799
54045
  var minimum_length = possible_lengths[0];
53800
54046
  if (minimum_length === actual_length) {
@@ -53859,7 +54105,7 @@ function matchesEntirely(text, regular_expression) {
53859
54105
  function _createForOfIteratorHelperLoose$2(o2, allowArrayLike) {
53860
54106
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53861
54107
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53862
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54108
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike) {
53863
54109
  if (it2) o2 = it2;
53864
54110
  var i2 = 0;
53865
54111
  return function() {
@@ -53959,8 +54205,6 @@ function applyInternationalSeparatorStyle(formattedNumber) {
53959
54205
  var FIRST_GROUP_PATTERN = /(\$\d)/;
53960
54206
  function formatNationalNumberUsingFormat(number2, format2, _ref) {
53961
54207
  var useInternationalFormat = _ref.useInternationalFormat, withNationalPrefix = _ref.withNationalPrefix;
53962
- _ref.carrierCode;
53963
- _ref.metadata;
53964
54208
  var formattedNumber = number2.replace(new RegExp(format2.pattern()), useInternationalFormat ? format2.internationalFormat() : (
53965
54209
  // This library doesn't use `domestic_carrier_code_formatting_rule`,
53966
54210
  // because that one is only used when formatting phone numbers
@@ -54006,7 +54250,7 @@ function formatRFC3966(_ref) {
54006
54250
  function _createForOfIteratorHelperLoose$1(o2, allowArrayLike) {
54007
54251
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54008
54252
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54009
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54253
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike) {
54010
54254
  if (it2) o2 = it2;
54011
54255
  var i2 = 0;
54012
54256
  return function() {
@@ -54202,7 +54446,6 @@ function _defineProperties(target, props2) {
54202
54446
  }
54203
54447
  function _createClass(Constructor, protoProps, staticProps) {
54204
54448
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54205
- if (staticProps) _defineProperties(Constructor, staticProps);
54206
54449
  Object.defineProperty(Constructor, "prototype", { writable: false });
54207
54450
  return Constructor;
54208
54451
  }
@@ -54499,7 +54742,7 @@ function extractCountryCallingCode(number2, country, callingCode, metadata2) {
54499
54742
  function _createForOfIteratorHelperLoose(o2, allowArrayLike) {
54500
54743
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54501
54744
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54502
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54745
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike) {
54503
54746
  if (it2) o2 = it2;
54504
54747
  var i2 = 0;
54505
54748
  return function() {
@@ -54553,14 +54796,8 @@ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
54553
54796
  return matchingCountries[0];
54554
54797
  }
54555
54798
  }
54556
- var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
54557
54799
  function getCountryByCallingCode(callingCode, _ref) {
54558
54800
  var nationalPhoneNumber = _ref.nationalNumber, defaultCountry = _ref.defaultCountry, metadata2 = _ref.metadata;
54559
- if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
54560
- if (metadata2.isNonGeographicCallingCode(callingCode)) {
54561
- return "001";
54562
- }
54563
- }
54564
54801
  var possibleCountries = metadata2.getCountryCodesForCallingCode(callingCode);
54565
54802
  if (!possibleCountries) {
54566
54803
  return;
@@ -57394,7 +57631,7 @@ const bisectCenter = bisector(number$2).center;
57394
57631
  function extent(values3, valueof) {
57395
57632
  let min2;
57396
57633
  let max2;
57397
- if (valueof === void 0) {
57634
+ {
57398
57635
  for (const value of values3) {
57399
57636
  if (value != null) {
57400
57637
  if (min2 === void 0) {
@@ -57405,18 +57642,6 @@ function extent(values3, valueof) {
57405
57642
  }
57406
57643
  }
57407
57644
  }
57408
- } else {
57409
- let index2 = -1;
57410
- for (let value of values3) {
57411
- if ((value = valueof(value, ++index2, values3)) != null) {
57412
- if (min2 === void 0) {
57413
- if (value >= value) min2 = max2 = value;
57414
- } else {
57415
- if (min2 > value) min2 = value;
57416
- if (max2 < value) max2 = value;
57417
- }
57418
- }
57419
- }
57420
57645
  }
57421
57646
  return [min2, max2];
57422
57647
  }