@bagelink/vue 0.0.600 → 0.0.602

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +650 -424
  2. package/dist/index.mjs +650 -424
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -110,12 +110,21 @@ function getPaddingObject(padding) {
110
110
  };
111
111
  }
112
112
  function rectToClientRect$1(rect) {
113
+ const {
114
+ x: x2,
115
+ y: y2,
116
+ width,
117
+ height
118
+ } = rect;
113
119
  return {
114
- ...rect,
115
- top: rect.y,
116
- left: rect.x,
117
- right: rect.x + rect.width,
118
- bottom: rect.y + rect.height
120
+ width,
121
+ height,
122
+ top: y2,
123
+ left: x2,
124
+ right: x2 + width,
125
+ bottom: y2 + height,
126
+ x: x2,
127
+ y: y2
119
128
  };
120
129
  }
121
130
  function computeCoordsFromPlacement(_ref, placement, rtl) {
@@ -286,9 +295,10 @@ async function detectOverflow$1(state2, options) {
286
295
  strategy
287
296
  }));
288
297
  const rect = elementContext === "floating" ? {
289
- ...rects.floating,
290
298
  x: x2,
291
- y: y2
299
+ y: y2,
300
+ width: rects.floating.width,
301
+ height: rects.floating.height
292
302
  } : rects.reference;
293
303
  const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
294
304
  const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
@@ -499,10 +509,12 @@ const flip$2 = function(options) {
499
509
  return {};
500
510
  }
501
511
  const side = getSide$1(placement);
512
+ const initialSideAxis = getSideAxis(initialPlacement);
502
513
  const isBasePlacement = getSide$1(initialPlacement) === initialPlacement;
503
514
  const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
504
515
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement$1(initialPlacement)] : getExpandedPlacements(initialPlacement));
505
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
516
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
517
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
506
518
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
507
519
  }
508
520
  const placements2 = [initialPlacement, ...fallbackPlacements];
@@ -539,8 +551,16 @@ const flip$2 = function(options) {
539
551
  if (!resetPlacement) {
540
552
  switch (fallbackStrategy) {
541
553
  case "bestFit": {
542
- var _overflowsData$map$so;
543
- 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];
554
+ var _overflowsData$filter2;
555
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
556
+ if (hasFallbackAxisSideDirection) {
557
+ const currentSideAxis = getSideAxis(d2.placement);
558
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
559
+ // reading directions favoring greater width.
560
+ currentSideAxis === "y";
561
+ }
562
+ return true;
563
+ }).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];
544
564
  if (placement2) {
545
565
  resetPlacement = placement2;
546
566
  }
@@ -735,16 +755,16 @@ const size = function(options) {
735
755
  widthSide = side;
736
756
  heightSide = alignment === "end" ? "top" : "bottom";
737
757
  }
738
- const overflowAvailableHeight = height - overflow[heightSide];
739
- const overflowAvailableWidth = width - overflow[widthSide];
758
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
759
+ const maximumClippingWidth = width - overflow.left - overflow.right;
760
+ const overflowAvailableHeight = min$3(height - overflow[heightSide], maximumClippingHeight);
761
+ const overflowAvailableWidth = min$3(width - overflow[widthSide], maximumClippingWidth);
740
762
  const noShift = !state2.middlewareData.shift;
741
763
  let availableHeight = overflowAvailableHeight;
742
764
  let availableWidth = overflowAvailableWidth;
743
765
  if (isYAxis) {
744
- const maximumClippingWidth = width - overflow.left - overflow.right;
745
766
  availableWidth = alignment || noShift ? min$3(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
746
767
  } else {
747
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
748
768
  availableHeight = alignment || noShift ? min$3(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
749
769
  }
750
770
  if (noShift && !alignment) {
@@ -3381,7 +3401,6 @@ const defaults$1 = {
3381
3401
  utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
3382
3402
  defaults$1.headers[method] = {};
3383
3403
  });
3384
- const defaults$2 = defaults$1;
3385
3404
  const ignoreDuplicateOf = utils$1.toObjectSet([
3386
3405
  "age",
3387
3406
  "authorization",
@@ -3643,11 +3662,10 @@ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
3643
3662
  };
3644
3663
  });
3645
3664
  utils$1.freezeMethods(AxiosHeaders);
3646
- const AxiosHeaders$1 = AxiosHeaders;
3647
3665
  function transformData(fns, response) {
3648
- const config = this || defaults$2;
3666
+ const config = this || defaults$1;
3649
3667
  const context = response || config;
3650
- const headers = AxiosHeaders$1.from(context.headers);
3668
+ const headers = AxiosHeaders.from(context.headers);
3651
3669
  let data2 = context.data;
3652
3670
  utils$1.forEach(fns, function transform(fn3) {
3653
3671
  data2 = fn3.call(config, data2, headers.normalize(), response ? response.status : void 0);
@@ -3846,7 +3864,7 @@ function buildFullPath(baseURL, requestedURL) {
3846
3864
  }
3847
3865
  return requestedURL;
3848
3866
  }
3849
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3867
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
3850
3868
  function mergeConfig(config1, config2) {
3851
3869
  config2 = config2 || {};
3852
3870
  const config = {};
@@ -3927,7 +3945,7 @@ function mergeConfig(config1, config2) {
3927
3945
  const resolveConfig = (config) => {
3928
3946
  const newConfig = mergeConfig({}, config);
3929
3947
  let { data: data2, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3930
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
3948
+ newConfig.headers = headers = AxiosHeaders.from(headers);
3931
3949
  newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
3932
3950
  if (auth) {
3933
3951
  headers.set(
@@ -3960,7 +3978,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3960
3978
  return new Promise(function dispatchXhrRequest(resolve, reject3) {
3961
3979
  const _config = resolveConfig(config);
3962
3980
  let requestData = _config.data;
3963
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3981
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
3964
3982
  let { responseType } = _config;
3965
3983
  let onCanceled;
3966
3984
  function done() {
@@ -3978,7 +3996,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3978
3996
  if (!request) {
3979
3997
  return;
3980
3998
  }
3981
- const responseHeaders = AxiosHeaders$1.from(
3999
+ const responseHeaders = AxiosHeaders.from(
3982
4000
  "getAllResponseHeaders" in request && request.getAllResponseHeaders()
3983
4001
  );
3984
4002
  const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
@@ -4294,7 +4312,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
4294
4312
  return await new Promise((resolve, reject3) => {
4295
4313
  settle(resolve, reject3, {
4296
4314
  data: responseData,
4297
- headers: AxiosHeaders$1.from(response.headers),
4315
+ headers: AxiosHeaders.from(response.headers),
4298
4316
  status: response.status,
4299
4317
  statusText: response.statusText,
4300
4318
  config,
@@ -4376,7 +4394,7 @@ function throwIfCancellationRequested(config) {
4376
4394
  }
4377
4395
  function dispatchRequest(config) {
4378
4396
  throwIfCancellationRequested(config);
4379
- config.headers = AxiosHeaders$1.from(config.headers);
4397
+ config.headers = AxiosHeaders.from(config.headers);
4380
4398
  config.data = transformData.call(
4381
4399
  config,
4382
4400
  config.transformRequest
@@ -4384,7 +4402,7 @@ function dispatchRequest(config) {
4384
4402
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
4385
4403
  config.headers.setContentType("application/x-www-form-urlencoded", false);
4386
4404
  }
4387
- const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter);
4405
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
4388
4406
  return adapter(config).then(function onAdapterResolution(response) {
4389
4407
  throwIfCancellationRequested(config);
4390
4408
  response.data = transformData.call(
@@ -4392,7 +4410,7 @@ function dispatchRequest(config) {
4392
4410
  config.transformResponse,
4393
4411
  response
4394
4412
  );
4395
- response.headers = AxiosHeaders$1.from(response.headers);
4413
+ response.headers = AxiosHeaders.from(response.headers);
4396
4414
  return response;
4397
4415
  }, function onAdapterRejection(reason) {
4398
4416
  if (!isCancel(reason)) {
@@ -4403,7 +4421,7 @@ function dispatchRequest(config) {
4403
4421
  config.transformResponse,
4404
4422
  reason.response
4405
4423
  );
4406
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
4424
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
4407
4425
  }
4408
4426
  }
4409
4427
  return Promise.reject(reason);
@@ -4542,7 +4560,7 @@ class Axios {
4542
4560
  delete headers[method];
4543
4561
  }
4544
4562
  );
4545
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
4563
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
4546
4564
  const requestInterceptorChain = [];
4547
4565
  let synchronousRequestInterceptors = true;
4548
4566
  this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
@@ -4626,7 +4644,6 @@ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method)
4626
4644
  Axios.prototype[method] = generateHTTPMethod();
4627
4645
  Axios.prototype[method + "Form"] = generateHTTPMethod(true);
4628
4646
  });
4629
- const Axios$1 = Axios;
4630
4647
  class CancelToken {
4631
4648
  constructor(executor) {
4632
4649
  if (typeof executor !== "function") {
@@ -4713,7 +4730,6 @@ class CancelToken {
4713
4730
  };
4714
4731
  }
4715
4732
  }
4716
- const CancelToken$1 = CancelToken;
4717
4733
  function spread(callback) {
4718
4734
  return function wrap2(arr) {
4719
4735
  return callback.apply(null, arr);
@@ -4790,21 +4806,20 @@ const HttpStatusCode = {
4790
4806
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
4791
4807
  HttpStatusCode[value] = key;
4792
4808
  });
4793
- const HttpStatusCode$1 = HttpStatusCode;
4794
4809
  function createInstance(defaultConfig2) {
4795
- const context = new Axios$1(defaultConfig2);
4796
- const instance = bind$2(Axios$1.prototype.request, context);
4797
- utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
4810
+ const context = new Axios(defaultConfig2);
4811
+ const instance = bind$2(Axios.prototype.request, context);
4812
+ utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
4798
4813
  utils$1.extend(instance, context, null, { allOwnKeys: true });
4799
4814
  instance.create = function create(instanceConfig) {
4800
4815
  return createInstance(mergeConfig(defaultConfig2, instanceConfig));
4801
4816
  };
4802
4817
  return instance;
4803
4818
  }
4804
- const axios$1 = createInstance(defaults$2);
4805
- axios$1.Axios = Axios$1;
4819
+ const axios$1 = createInstance(defaults$1);
4820
+ axios$1.Axios = Axios;
4806
4821
  axios$1.CanceledError = CanceledError;
4807
- axios$1.CancelToken = CancelToken$1;
4822
+ axios$1.CancelToken = CancelToken;
4808
4823
  axios$1.isCancel = isCancel;
4809
4824
  axios$1.VERSION = VERSION;
4810
4825
  axios$1.toFormData = toFormData;
@@ -4816,10 +4831,10 @@ axios$1.all = function all(promises) {
4816
4831
  axios$1.spread = spread;
4817
4832
  axios$1.isAxiosError = isAxiosError;
4818
4833
  axios$1.mergeConfig = mergeConfig;
4819
- axios$1.AxiosHeaders = AxiosHeaders$1;
4834
+ axios$1.AxiosHeaders = AxiosHeaders;
4820
4835
  axios$1.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4821
4836
  axios$1.getAdapter = adapters.getAdapter;
4822
- axios$1.HttpStatusCode = HttpStatusCode$1;
4837
+ axios$1.HttpStatusCode = HttpStatusCode;
4823
4838
  axios$1.default = axios$1;
4824
4839
  var __defProp = Object.defineProperty;
4825
4840
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -5063,7 +5078,11 @@ class Bagel {
5063
5078
  this._setAuthorization();
5064
5079
  const formData = new FormData();
5065
5080
  formData.append("file", file);
5066
- const { data: data2 } = await axios.post("/static_files/upload", formData, {
5081
+ let url = "/static_files/upload";
5082
+ console.log(options == null ? void 0 : options.topic);
5083
+ if (options == null ? void 0 : options.topic)
5084
+ url = `/static_files/upload?topic=${options.topic}`;
5085
+ const { data: data2 } = await axios.post(url, formData, {
5067
5086
  headers: {
5068
5087
  "Content-Type": "multipart/form-data"
5069
5088
  },
@@ -6032,7 +6051,7 @@ function toValue(r2) {
6032
6051
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
6033
6052
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
6034
6053
  function getLifeCycleTarget(target) {
6035
- return target || getCurrentInstance();
6054
+ return getCurrentInstance();
6036
6055
  }
6037
6056
  function tryOnMounted(fn3, sync = true, target) {
6038
6057
  const instance = getLifeCycleTarget();
@@ -17276,12 +17295,7 @@ function eachDayOfInterval(interval, options) {
17276
17295
  const endTime = reversed ? +startDate : +endDate;
17277
17296
  const currentDate = reversed ? endDate : startDate;
17278
17297
  currentDate.setHours(0, 0, 0, 0);
17279
- let step = (options == null ? void 0 : options.step) ?? 1;
17280
- if (!step) return [];
17281
- if (step < 0) {
17282
- step = -step;
17283
- reversed = !reversed;
17284
- }
17298
+ let step = 1;
17285
17299
  const dates = [];
17286
17300
  while (+currentDate <= endTime) {
17287
17301
  dates.push(toDate(currentDate));
@@ -17304,12 +17318,7 @@ function eachQuarterOfInterval(interval, options) {
17304
17318
  let reversed = +startDate > +endDate;
17305
17319
  const endTime = reversed ? +startOfQuarter(startDate) : +startOfQuarter(endDate);
17306
17320
  let currentDate = reversed ? startOfQuarter(endDate) : startOfQuarter(startDate);
17307
- let step = (options == null ? void 0 : options.step) ?? 1;
17308
- if (!step) return [];
17309
- if (step < 0) {
17310
- step = -step;
17311
- reversed = !reversed;
17312
- }
17321
+ let step = 1;
17313
17322
  const dates = [];
17314
17323
  while (+currentDate <= endTime) {
17315
17324
  dates.push(toDate(currentDate));
@@ -26155,10 +26164,8 @@ function isScrolledPast(el, elSide, parentSide) {
26155
26164
  var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
26156
26165
  while (parent) {
26157
26166
  var parentSideVal = getRect(parent)[parentSide], visible = void 0;
26158
- if (parentSide === "top" || parentSide === "left") {
26167
+ {
26159
26168
  visible = elSideVal >= parentSideVal;
26160
- } else {
26161
- visible = elSideVal <= parentSideVal;
26162
26169
  }
26163
26170
  if (!visible) return parent;
26164
26171
  if (parent === getWindowScrollingElement()) break;
@@ -29533,7 +29540,7 @@ class Fragment {
29533
29540
  /**
29534
29541
  Find the index and inner offset corresponding to a given relative
29535
29542
  position in this fragment. The result object will be reused
29536
- (overwritten) the next time the function is called. (Not public.)
29543
+ (overwritten) the next time the function is called. @internal
29537
29544
  */
29538
29545
  findIndex(pos, round2 = -1) {
29539
29546
  if (pos == 0)
@@ -29739,7 +29746,9 @@ let Mark$1 = class Mark2 {
29739
29746
  let type3 = schema.marks[json.type];
29740
29747
  if (!type3)
29741
29748
  throw new RangeError(`There is no mark type ${json.type} in this schema`);
29742
- return type3.create(json.attrs);
29749
+ let mark = type3.create(json.attrs);
29750
+ type3.checkAttrs(mark.attrs);
29751
+ return mark;
29743
29752
  }
29744
29753
  /**
29745
29754
  Test whether two sets of marks are identical.
@@ -29873,8 +29882,6 @@ function removeRange(content, from2, to2) {
29873
29882
  function insertInto(content, dist, insert, parent) {
29874
29883
  let { index: index2, offset: offset2 } = content.findIndex(dist), child = content.maybeChild(index2);
29875
29884
  if (offset2 == dist || child.isText) {
29876
- if (parent && !parent.canReplace(index2, index2, insert))
29877
- return null;
29878
29885
  return content.cut(0, dist).append(insert).append(content.cut(dist));
29879
29886
  }
29880
29887
  let inner = insertInto(child.content, dist - offset2 - 1, insert);
@@ -30236,17 +30243,28 @@ class ResolvedPos {
30236
30243
  @internal
30237
30244
  */
30238
30245
  static resolveCached(doc2, pos) {
30239
- for (let i2 = 0; i2 < resolveCache.length; i2++) {
30240
- let cached2 = resolveCache[i2];
30241
- if (cached2.pos == pos && cached2.doc == doc2)
30242
- return cached2;
30246
+ let cache = resolveCache.get(doc2);
30247
+ if (cache) {
30248
+ for (let i2 = 0; i2 < cache.elts.length; i2++) {
30249
+ let elt = cache.elts[i2];
30250
+ if (elt.pos == pos)
30251
+ return elt;
30252
+ }
30253
+ } else {
30254
+ resolveCache.set(doc2, cache = new ResolveCache());
30243
30255
  }
30244
- let result2 = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc2, pos);
30245
- resolveCachePos = (resolveCachePos + 1) % resolveCacheSize;
30256
+ let result2 = cache.elts[cache.i] = ResolvedPos.resolve(doc2, pos);
30257
+ cache.i = (cache.i + 1) % resolveCacheSize;
30246
30258
  return result2;
30247
30259
  }
30248
30260
  }
30249
- let resolveCache = [], resolveCachePos = 0, resolveCacheSize = 12;
30261
+ class ResolveCache {
30262
+ constructor() {
30263
+ this.elts = [];
30264
+ this.i = 0;
30265
+ }
30266
+ }
30267
+ const resolveCacheSize = 12, resolveCache = /* @__PURE__ */ new WeakMap();
30250
30268
  class NodeRange {
30251
30269
  /**
30252
30270
  Construct a node range. `$from` and `$to` should point into the
@@ -30632,13 +30650,17 @@ let Node$3 = class Node2 {
30632
30650
  }
30633
30651
  /**
30634
30652
  Check whether this node and its descendants conform to the
30635
- schema, and raise error when they do not.
30653
+ schema, and raise an exception when they do not.
30636
30654
  */
30637
30655
  check() {
30638
30656
  this.type.checkContent(this.content);
30657
+ this.type.checkAttrs(this.attrs);
30639
30658
  let copy2 = Mark$1.none;
30640
- for (let i2 = 0; i2 < this.marks.length; i2++)
30641
- copy2 = this.marks[i2].addToSet(copy2);
30659
+ for (let i2 = 0; i2 < this.marks.length; i2++) {
30660
+ let mark = this.marks[i2];
30661
+ mark.type.checkAttrs(mark.attrs);
30662
+ copy2 = mark.addToSet(copy2);
30663
+ }
30642
30664
  if (!Mark$1.sameSet(copy2, this.marks))
30643
30665
  throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m2) => m2.type.name)}`);
30644
30666
  this.content.forEach((node) => node.check());
@@ -30664,7 +30686,7 @@ let Node$3 = class Node2 {
30664
30686
  static fromJSON(schema, json) {
30665
30687
  if (!json)
30666
30688
  throw new RangeError("Invalid input for Node.fromJSON");
30667
- let marks = null;
30689
+ let marks = void 0;
30668
30690
  if (json.marks) {
30669
30691
  if (!Array.isArray(json.marks))
30670
30692
  throw new RangeError("Invalid mark data for Node.fromJSON");
@@ -30676,7 +30698,9 @@ let Node$3 = class Node2 {
30676
30698
  return schema.text(json.text, marks);
30677
30699
  }
30678
30700
  let content = Fragment.fromJSON(schema, json.content);
30679
- return schema.nodeType(json.type).create(json.attrs, content, marks);
30701
+ let node = schema.nodeType(json.type).create(json.attrs, content, marks);
30702
+ node.type.checkAttrs(node.attrs);
30703
+ return node;
30680
30704
  }
30681
30705
  };
30682
30706
  Node$3.prototype.text = void 0;
@@ -31158,6 +31182,16 @@ function computeAttrs(attrs, value) {
31158
31182
  }
31159
31183
  return built;
31160
31184
  }
31185
+ function checkAttrs(attrs, values3, type3, name) {
31186
+ for (let name2 in values3)
31187
+ if (!(name2 in attrs))
31188
+ throw new RangeError(`Unsupported attribute ${name2} for ${type3} of type ${name2}`);
31189
+ for (let name2 in attrs) {
31190
+ let attr = attrs[name2];
31191
+ if (attr.validate)
31192
+ attr.validate(values3[name2]);
31193
+ }
31194
+ }
31161
31195
  function initAttrs(attrs) {
31162
31196
  let result2 = /* @__PURE__ */ Object.create(null);
31163
31197
  if (attrs)
@@ -31287,7 +31321,7 @@ let NodeType$1 = class NodeType2 {
31287
31321
  }
31288
31322
  /**
31289
31323
  Returns true if the given fragment is valid content for this node
31290
- type with the given attributes.
31324
+ type.
31291
31325
  */
31292
31326
  validContent(content) {
31293
31327
  let result2 = this.contentMatch.matchFragment(content);
@@ -31308,6 +31342,12 @@ let NodeType$1 = class NodeType2 {
31308
31342
  throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
31309
31343
  }
31310
31344
  /**
31345
+ @internal
31346
+ */
31347
+ checkAttrs(attrs) {
31348
+ checkAttrs(this.attrs, attrs, "node", this.name);
31349
+ }
31350
+ /**
31311
31351
  Check whether the given mark type is allowed in this node.
31312
31352
  */
31313
31353
  allowsMarkType(markType) {
@@ -31357,10 +31397,19 @@ let NodeType$1 = class NodeType2 {
31357
31397
  return result2;
31358
31398
  }
31359
31399
  };
31400
+ function validateType(type3) {
31401
+ let types = type3.split("|");
31402
+ return (value) => {
31403
+ let name = value === null ? "null" : typeof value;
31404
+ if (types.indexOf(name) < 0)
31405
+ throw new RangeError(`Expected value of type ${types}, got ${name}`);
31406
+ };
31407
+ }
31360
31408
  class Attribute {
31361
31409
  constructor(options) {
31362
31410
  this.hasDefault = Object.prototype.hasOwnProperty.call(options, "default");
31363
31411
  this.default = options.default;
31412
+ this.validate = typeof options.validate == "string" ? validateType(options.validate) : options.validate;
31364
31413
  }
31365
31414
  get isRequired() {
31366
31415
  return !this.hasDefault;
@@ -31419,6 +31468,12 @@ class MarkType {
31419
31468
  return set2[i2];
31420
31469
  }
31421
31470
  /**
31471
+ @internal
31472
+ */
31473
+ checkAttrs(attrs) {
31474
+ checkAttrs(this.attrs, attrs, "mark", this.name);
31475
+ }
31476
+ /**
31422
31477
  Queries whether a given mark type is
31423
31478
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
31424
31479
  */
@@ -31431,6 +31486,7 @@ class Schema {
31431
31486
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
31432
31487
  */
31433
31488
  constructor(spec) {
31489
+ this.linebreakReplacement = null;
31434
31490
  this.cached = /* @__PURE__ */ Object.create(null);
31435
31491
  let instanceSpec = this.spec = {};
31436
31492
  for (let prop3 in spec)
@@ -31444,6 +31500,13 @@ class Schema {
31444
31500
  let type3 = this.nodes[prop3], contentExpr = type3.spec.content || "", markExpr = type3.spec.marks;
31445
31501
  type3.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));
31446
31502
  type3.inlineContent = type3.contentMatch.inlineContent;
31503
+ if (type3.spec.linebreakReplacement) {
31504
+ if (this.linebreakReplacement)
31505
+ throw new RangeError("Multiple linebreak nodes defined");
31506
+ if (!type3.isInline || !type3.isLeaf)
31507
+ throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
31508
+ this.linebreakReplacement = type3;
31509
+ }
31447
31510
  type3.markSet = markExpr == "_" ? null : markExpr ? gatherMarks(this, markExpr.split(" ")) : markExpr == "" || !type3.inlineContent ? [] : null;
31448
31511
  }
31449
31512
  for (let prop3 in this.marks) {
@@ -31528,6 +31591,12 @@ function gatherMarks(schema, marks) {
31528
31591
  }
31529
31592
  return found2;
31530
31593
  }
31594
+ function isTagRule(rule) {
31595
+ return rule.tag != null;
31596
+ }
31597
+ function isStyleRule(rule) {
31598
+ return rule.style != null;
31599
+ }
31531
31600
  class DOMParser {
31532
31601
  /**
31533
31602
  Create a parser that targets the given schema, using the given
@@ -31538,11 +31607,16 @@ class DOMParser {
31538
31607
  this.rules = rules;
31539
31608
  this.tags = [];
31540
31609
  this.styles = [];
31610
+ let matchedStyles = this.matchedStyles = [];
31541
31611
  rules.forEach((rule) => {
31542
- if (rule.tag)
31612
+ if (isTagRule(rule)) {
31543
31613
  this.tags.push(rule);
31544
- else if (rule.style)
31614
+ } else if (isStyleRule(rule)) {
31615
+ let prop3 = /[^=]*/.exec(rule.style)[0];
31616
+ if (matchedStyles.indexOf(prop3) < 0)
31617
+ matchedStyles.push(prop3);
31545
31618
  this.styles.push(rule);
31619
+ }
31546
31620
  });
31547
31621
  this.normalizeLists = !this.tags.some((r2) => {
31548
31622
  if (!/^(ul|ol)\b/.test(r2.tag) || !r2.node)
@@ -31802,10 +31876,10 @@ class ParseContext {
31802
31876
  this.addElement(dom);
31803
31877
  }
31804
31878
  withStyleRules(dom, f2) {
31805
- let style2 = dom.getAttribute("style");
31806
- if (!style2)
31879
+ let style2 = dom.style;
31880
+ if (!style2 || !style2.length)
31807
31881
  return f2();
31808
- let marks = this.readStyles(parseStyles(style2));
31882
+ let marks = this.readStyles(dom.style);
31809
31883
  if (!marks)
31810
31884
  return;
31811
31885
  let [addMarks, removeMarks] = marks, top2 = this.top;
@@ -31899,27 +31973,30 @@ class ParseContext {
31899
31973
  // had a rule with `ignore` set.
31900
31974
  readStyles(styles) {
31901
31975
  let add2 = Mark$1.none, remove2 = Mark$1.none;
31902
- for (let i2 = 0; i2 < styles.length; i2 += 2) {
31903
- for (let after = void 0; ; ) {
31904
- let rule = this.parser.matchStyle(styles[i2], styles[i2 + 1], this, after);
31905
- if (!rule)
31906
- break;
31907
- if (rule.ignore)
31908
- return null;
31909
- if (rule.clearMark) {
31910
- this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31911
- if (rule.clearMark(m2))
31912
- remove2 = m2.addToSet(remove2);
31913
- });
31914
- } else {
31915
- add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31916
- }
31917
- if (rule.consuming === false)
31918
- after = rule;
31919
- else
31920
- break;
31976
+ if (styles.length)
31977
+ for (let i2 = 0; i2 < this.parser.matchedStyles.length; i2++) {
31978
+ let name = this.parser.matchedStyles[i2], value = styles.getPropertyValue(name);
31979
+ if (value)
31980
+ for (let after = void 0; ; ) {
31981
+ let rule = this.parser.matchStyle(name, value, this, after);
31982
+ if (!rule)
31983
+ break;
31984
+ if (rule.ignore)
31985
+ return null;
31986
+ if (rule.clearMark) {
31987
+ this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31988
+ if (rule.clearMark(m2))
31989
+ remove2 = m2.addToSet(remove2);
31990
+ });
31991
+ } else {
31992
+ add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31993
+ }
31994
+ if (rule.consuming === false)
31995
+ after = rule;
31996
+ else
31997
+ break;
31998
+ }
31921
31999
  }
31922
- }
31923
32000
  return [add2, remove2];
31924
32001
  }
31925
32002
  // Look up a handler for the given node. If none are found, return
@@ -32188,12 +32265,6 @@ function normalizeList(dom) {
32188
32265
  function matches(dom, selector2) {
32189
32266
  return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector2);
32190
32267
  }
32191
- function parseStyles(style2) {
32192
- let re2 = /\s*([\w-]+)\s*:\s*([^;]+)/g, m2, result2 = [];
32193
- while (m2 = re2.exec(style2))
32194
- result2.push(m2[1], m2[2].trim());
32195
- return result2;
32196
- }
32197
32268
  function copy$2(obj) {
32198
32269
  let copy2 = {};
32199
32270
  for (let prop3 in obj)
@@ -32284,7 +32355,7 @@ class DOMSerializer {
32284
32355
  @internal
32285
32356
  */
32286
32357
  serializeNodeInner(node, options) {
32287
- let { dom, contentDOM } = DOMSerializer.renderSpec(doc$1(options), this.nodes[node.type.name](node));
32358
+ let { dom, contentDOM } = renderSpec(doc$1(options), this.nodes[node.type.name](node), null, node.attrs);
32288
32359
  if (contentDOM) {
32289
32360
  if (node.isLeaf)
32290
32361
  throw new RangeError("Content hole not allowed in a leaf node spec");
@@ -32315,7 +32386,7 @@ class DOMSerializer {
32315
32386
  */
32316
32387
  serializeMark(mark, inline, options = {}) {
32317
32388
  let toDOM = this.marks[mark.type.name];
32318
- return toDOM && DOMSerializer.renderSpec(doc$1(options), toDOM(mark, inline));
32389
+ return toDOM && renderSpec(doc$1(options), toDOM(mark, inline), null, mark.attrs);
32319
32390
  }
32320
32391
  /**
32321
32392
  Render an [output spec](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) to a DOM node. If
@@ -32323,48 +32394,7 @@ class DOMSerializer {
32323
32394
  node with the hole.
32324
32395
  */
32325
32396
  static renderSpec(doc2, structure, xmlNS = null) {
32326
- if (typeof structure == "string")
32327
- return { dom: doc2.createTextNode(structure) };
32328
- if (structure.nodeType != null)
32329
- return { dom: structure };
32330
- if (structure.dom && structure.dom.nodeType != null)
32331
- return structure;
32332
- let tagName = structure[0], space = tagName.indexOf(" ");
32333
- if (space > 0) {
32334
- xmlNS = tagName.slice(0, space);
32335
- tagName = tagName.slice(space + 1);
32336
- }
32337
- let contentDOM;
32338
- let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32339
- let attrs = structure[1], start2 = 1;
32340
- if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32341
- start2 = 2;
32342
- for (let name in attrs)
32343
- if (attrs[name] != null) {
32344
- let space2 = name.indexOf(" ");
32345
- if (space2 > 0)
32346
- dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32347
- else
32348
- dom.setAttribute(name, attrs[name]);
32349
- }
32350
- }
32351
- for (let i2 = start2; i2 < structure.length; i2++) {
32352
- let child = structure[i2];
32353
- if (child === 0) {
32354
- if (i2 < structure.length - 1 || i2 > start2)
32355
- throw new RangeError("Content hole must be the only child of its parent node");
32356
- return { dom, contentDOM: dom };
32357
- } else {
32358
- let { dom: inner, contentDOM: innerContent } = DOMSerializer.renderSpec(doc2, child, xmlNS);
32359
- dom.appendChild(inner);
32360
- if (innerContent) {
32361
- if (contentDOM)
32362
- throw new RangeError("Multiple content holes");
32363
- contentDOM = innerContent;
32364
- }
32365
- }
32366
- }
32367
- return { dom, contentDOM };
32397
+ return renderSpec(doc2, structure, xmlNS);
32368
32398
  }
32369
32399
  /**
32370
32400
  Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
@@ -32402,6 +32432,84 @@ function gatherToDOM(obj) {
32402
32432
  function doc$1(options) {
32403
32433
  return options.document || window.document;
32404
32434
  }
32435
+ const suspiciousAttributeCache = /* @__PURE__ */ new WeakMap();
32436
+ function suspiciousAttributes(attrs) {
32437
+ let value = suspiciousAttributeCache.get(attrs);
32438
+ if (value === void 0)
32439
+ suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));
32440
+ return value;
32441
+ }
32442
+ function suspiciousAttributesInner(attrs) {
32443
+ let result2 = null;
32444
+ function scan(value) {
32445
+ if (value && typeof value == "object") {
32446
+ if (Array.isArray(value)) {
32447
+ if (typeof value[0] == "string") {
32448
+ if (!result2)
32449
+ result2 = [];
32450
+ result2.push(value);
32451
+ } else {
32452
+ for (let i2 = 0; i2 < value.length; i2++)
32453
+ scan(value[i2]);
32454
+ }
32455
+ } else {
32456
+ for (let prop3 in value)
32457
+ scan(value[prop3]);
32458
+ }
32459
+ }
32460
+ }
32461
+ scan(attrs);
32462
+ return result2;
32463
+ }
32464
+ function renderSpec(doc2, structure, xmlNS, blockArraysIn) {
32465
+ if (typeof structure == "string")
32466
+ return { dom: doc2.createTextNode(structure) };
32467
+ if (structure.nodeType != null)
32468
+ return { dom: structure };
32469
+ if (structure.dom && structure.dom.nodeType != null)
32470
+ return structure;
32471
+ let tagName = structure[0], suspicious;
32472
+ if (typeof tagName != "string")
32473
+ throw new RangeError("Invalid array passed to renderSpec");
32474
+ if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1)
32475
+ throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
32476
+ let space = tagName.indexOf(" ");
32477
+ if (space > 0) {
32478
+ xmlNS = tagName.slice(0, space);
32479
+ tagName = tagName.slice(space + 1);
32480
+ }
32481
+ let contentDOM;
32482
+ let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32483
+ let attrs = structure[1], start2 = 1;
32484
+ if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32485
+ start2 = 2;
32486
+ for (let name in attrs)
32487
+ if (attrs[name] != null) {
32488
+ let space2 = name.indexOf(" ");
32489
+ if (space2 > 0)
32490
+ dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32491
+ else
32492
+ dom.setAttribute(name, attrs[name]);
32493
+ }
32494
+ }
32495
+ for (let i2 = start2; i2 < structure.length; i2++) {
32496
+ let child = structure[i2];
32497
+ if (child === 0) {
32498
+ if (i2 < structure.length - 1 || i2 > start2)
32499
+ throw new RangeError("Content hole must be the only child of its parent node");
32500
+ return { dom, contentDOM: dom };
32501
+ } else {
32502
+ let { dom: inner, contentDOM: innerContent } = renderSpec(doc2, child, xmlNS, blockArraysIn);
32503
+ dom.appendChild(inner);
32504
+ if (innerContent) {
32505
+ if (contentDOM)
32506
+ throw new RangeError("Multiple content holes");
32507
+ contentDOM = innerContent;
32508
+ }
32509
+ }
32510
+ }
32511
+ return { dom, contentDOM };
32512
+ }
32405
32513
  const lower16 = 65535;
32406
32514
  const factor16 = Math.pow(2, 16);
32407
32515
  function makeRecover(index2, offset2) {
@@ -33061,7 +33169,8 @@ class ReplaceAroundStep extends Step$1 {
33061
33169
  }
33062
33170
  map(mapping) {
33063
33171
  let from2 = mapping.mapResult(this.from, 1), to2 = mapping.mapResult(this.to, -1);
33064
- let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);
33172
+ let gapFrom = this.from == this.gapFrom ? from2.pos : mapping.map(this.gapFrom, -1);
33173
+ let gapTo = this.to == this.gapTo ? to2.pos : mapping.map(this.gapTo, 1);
33065
33174
  if (from2.deletedAcross && to2.deletedAcross || gapFrom < from2.pos || gapTo > to2.pos)
33066
33175
  return null;
33067
33176
  return new ReplaceAroundStep(from2.pos, to2.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
@@ -33174,7 +33283,7 @@ function removeMark(tr2, from2, to2, mark) {
33174
33283
  });
33175
33284
  matched.forEach((m2) => tr2.step(new RemoveMarkStep(m2.from, m2.to, m2.style)));
33176
33285
  }
33177
- function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch) {
33286
+ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch, clearNewlines = true) {
33178
33287
  let node = tr2.doc.nodeAt(pos);
33179
33288
  let replSteps = [], cur = pos + 1;
33180
33289
  for (let i2 = 0; i2 < node.childCount; i2++) {
@@ -33187,7 +33296,7 @@ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatc
33187
33296
  for (let j2 = 0; j2 < child.marks.length; j2++)
33188
33297
  if (!parentType.allowsMarkType(child.marks[j2].type))
33189
33298
  tr2.step(new RemoveMarkStep(cur, end2, child.marks[j2]));
33190
- if (child.isText && !parentType.spec.code) {
33299
+ if (clearNewlines && child.isText && parentType.whitespace != "pre") {
33191
33300
  let m2, newline = /\r?\n|\r/g, slice4;
33192
33301
  while (m2 = newline.exec(child.text)) {
33193
33302
  if (!slice4)
@@ -33296,14 +33405,45 @@ function setBlockType$1(tr2, from2, to2, type3, attrs) {
33296
33405
  let mapFrom = tr2.steps.length;
33297
33406
  tr2.doc.nodesBetween(from2, to2, (node, pos) => {
33298
33407
  if (node.isTextblock && !node.hasMarkup(type3, attrs) && canChangeType(tr2.doc, tr2.mapping.slice(mapFrom).map(pos), type3)) {
33299
- tr2.clearIncompatible(tr2.mapping.slice(mapFrom).map(pos, 1), type3);
33408
+ let convertNewlines = null;
33409
+ if (type3.schema.linebreakReplacement) {
33410
+ let pre = type3.whitespace == "pre", supportLinebreak = !!type3.contentMatch.matchType(type3.schema.linebreakReplacement);
33411
+ if (pre && !supportLinebreak)
33412
+ convertNewlines = false;
33413
+ else if (!pre && supportLinebreak)
33414
+ convertNewlines = true;
33415
+ }
33416
+ if (convertNewlines === false)
33417
+ replaceLinebreaks(tr2, node, pos, mapFrom);
33418
+ clearIncompatible(tr2, tr2.mapping.slice(mapFrom).map(pos, 1), type3, void 0, convertNewlines === null);
33300
33419
  let mapping = tr2.mapping.slice(mapFrom);
33301
33420
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
33302
33421
  tr2.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type3.create(attrs, null, node.marks)), 0, 0), 1, true));
33422
+ if (convertNewlines === true)
33423
+ replaceNewlines(tr2, node, pos, mapFrom);
33303
33424
  return false;
33304
33425
  }
33305
33426
  });
33306
33427
  }
33428
+ function replaceNewlines(tr2, node, pos, mapFrom) {
33429
+ node.forEach((child, offset2) => {
33430
+ if (child.isText) {
33431
+ let m2, newline = /\r?\n|\r/g;
33432
+ while (m2 = newline.exec(child.text)) {
33433
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2 + m2.index);
33434
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.linebreakReplacement.create());
33435
+ }
33436
+ }
33437
+ });
33438
+ }
33439
+ function replaceLinebreaks(tr2, node, pos, mapFrom) {
33440
+ node.forEach((child, offset2) => {
33441
+ if (child.type == child.type.schema.linebreakReplacement) {
33442
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2);
33443
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.text("\n"));
33444
+ }
33445
+ });
33446
+ }
33307
33447
  function canChangeType(doc2, pos, type3) {
33308
33448
  let $pos = doc2.resolve(pos), index2 = $pos.index();
33309
33449
  return $pos.parent.canReplaceWith(index2, index2 + 1, type3);
@@ -35069,6 +35209,9 @@ const textRange = function(node, from2, to2) {
35069
35209
  range2.setStart(node, from2 || 0);
35070
35210
  return range2;
35071
35211
  };
35212
+ const clearReusedRange = function() {
35213
+ reusedRange = null;
35214
+ };
35072
35215
  const isEquivalentPosition = function(node, off2, targetNode, targetOff) {
35073
35216
  return targetNode && (scanFor(node, off2, targetNode, targetOff, -1) || scanFor(node, off2, targetNode, targetOff, 1));
35074
35217
  };
@@ -35096,6 +35239,40 @@ function scanFor(node, off2, targetNode, targetOff, dir) {
35096
35239
  function nodeSize(node) {
35097
35240
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
35098
35241
  }
35242
+ function textNodeBefore$1(node, offset2) {
35243
+ for (; ; ) {
35244
+ if (node.nodeType == 3 && offset2)
35245
+ return node;
35246
+ if (node.nodeType == 1 && offset2 > 0) {
35247
+ if (node.contentEditable == "false")
35248
+ return null;
35249
+ node = node.childNodes[offset2 - 1];
35250
+ offset2 = nodeSize(node);
35251
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35252
+ offset2 = domIndex(node);
35253
+ node = node.parentNode;
35254
+ } else {
35255
+ return null;
35256
+ }
35257
+ }
35258
+ }
35259
+ function textNodeAfter$1(node, offset2) {
35260
+ for (; ; ) {
35261
+ if (node.nodeType == 3 && offset2 < node.nodeValue.length)
35262
+ return node;
35263
+ if (node.nodeType == 1 && offset2 < node.childNodes.length) {
35264
+ if (node.contentEditable == "false")
35265
+ return null;
35266
+ node = node.childNodes[offset2];
35267
+ offset2 = 0;
35268
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35269
+ offset2 = domIndex(node) + 1;
35270
+ node = node.parentNode;
35271
+ } else {
35272
+ return null;
35273
+ }
35274
+ }
35275
+ }
35099
35276
  function isOnEdge(node, offset2, parent) {
35100
35277
  for (let atStart = offset2 == 0, atEnd = offset2 == nodeSize(node); atStart || atEnd; ) {
35101
35278
  if (node == parent)
@@ -35167,6 +35344,14 @@ const android = /Android \d/.test(agent);
35167
35344
  const webkit = !!doc && "webkitFontSmoothing" in doc.documentElement.style;
35168
35345
  const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
35169
35346
  function windowRect(doc2) {
35347
+ let vp = doc2.defaultView && doc2.defaultView.visualViewport;
35348
+ if (vp)
35349
+ return {
35350
+ left: 0,
35351
+ right: vp.width,
35352
+ top: 0,
35353
+ bottom: vp.height
35354
+ };
35170
35355
  return {
35171
35356
  left: 0,
35172
35357
  right: doc2.documentElement.clientWidth,
@@ -35368,14 +35553,14 @@ function posFromCaret(view, node, offset2, coords) {
35368
35553
  let desc = view.docView.nearestDesc(cur, true);
35369
35554
  if (!desc)
35370
35555
  return null;
35371
- if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent && !sawBlock || !desc.contentDOM)) {
35556
+ if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM)) {
35372
35557
  let rect = desc.dom.getBoundingClientRect();
35373
- if (desc.node.isBlock && desc.parent && !sawBlock) {
35374
- sawBlock = true;
35375
- if (rect.left > coords.left || rect.top > coords.top)
35558
+ if (desc.node.isBlock && desc.parent) {
35559
+ if (!sawBlock && rect.left > coords.left || rect.top > coords.top)
35376
35560
  outsideBlock = desc.posBefore;
35377
- else if (rect.right < coords.left || rect.bottom < coords.top)
35561
+ else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top)
35378
35562
  outsideBlock = desc.posAfter;
35563
+ sawBlock = true;
35379
35564
  }
35380
35565
  if (!desc.contentDOM && outsideBlock < 0 && !desc.node.isText) {
35381
35566
  let before = desc.node.isBlock ? coords.top < (rect.top + rect.bottom) / 2 : coords.left < (rect.left + rect.right) / 2;
@@ -35990,6 +36175,9 @@ class ViewDesc {
35990
36175
  get ignoreForCoords() {
35991
36176
  return false;
35992
36177
  }
36178
+ isText(text) {
36179
+ return false;
36180
+ }
35993
36181
  }
35994
36182
  class WidgetViewDesc extends ViewDesc {
35995
36183
  constructor(parent, widget, view, pos) {
@@ -36228,8 +36416,7 @@ class NodeViewDesc extends ViewDesc {
36228
36416
  let { from: from2, to: to2 } = view.state.selection;
36229
36417
  if (!(view.state.selection instanceof TextSelection) || from2 < pos || to2 > pos + this.node.content.size)
36230
36418
  return null;
36231
- let sel = view.domSelectionRange();
36232
- let textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);
36419
+ let textNode = view.input.compositionNode;
36233
36420
  if (!textNode || !this.dom.contains(textNode.parentNode))
36234
36421
  return null;
36235
36422
  if (this.node.inlineContent) {
@@ -36295,10 +36482,11 @@ class NodeViewDesc extends ViewDesc {
36295
36482
  }
36296
36483
  // Remove selected node marking from this node.
36297
36484
  deselectNode() {
36298
- if (this.nodeDOM.nodeType == 1)
36485
+ if (this.nodeDOM.nodeType == 1) {
36299
36486
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
36300
- if (this.contentDOM || !this.node.type.spec.draggable)
36301
- this.dom.removeAttribute("draggable");
36487
+ if (this.contentDOM || !this.node.type.spec.draggable)
36488
+ this.dom.removeAttribute("draggable");
36489
+ }
36302
36490
  }
36303
36491
  get domAtom() {
36304
36492
  return this.node.isAtom;
@@ -36364,6 +36552,9 @@ class TextViewDesc extends NodeViewDesc {
36364
36552
  get domAtom() {
36365
36553
  return false;
36366
36554
  }
36555
+ isText(text) {
36556
+ return this.node.text == text;
36557
+ }
36367
36558
  }
36368
36559
  class TrailingHackViewDesc extends ViewDesc {
36369
36560
  parseRule() {
@@ -36879,23 +37070,6 @@ function iosHacks(dom) {
36879
37070
  dom.style.cssText = oldCSS;
36880
37071
  }
36881
37072
  }
36882
- function nearbyTextNode(node, offset2) {
36883
- for (; ; ) {
36884
- if (node.nodeType == 3)
36885
- return node;
36886
- if (node.nodeType == 1 && offset2 > 0) {
36887
- if (node.childNodes.length > offset2 && node.childNodes[offset2].nodeType == 3)
36888
- return node.childNodes[offset2];
36889
- node = node.childNodes[offset2 - 1];
36890
- offset2 = nodeSize(node);
36891
- } else if (node.nodeType == 1 && offset2 < node.childNodes.length) {
36892
- node = node.childNodes[offset2];
36893
- offset2 = 0;
36894
- } else {
36895
- return null;
36896
- }
36897
- }
36898
- }
36899
37073
  function findTextInFragment(frag, text, from2, to2) {
36900
37074
  for (let i2 = 0, pos = 0; i2 < frag.childCount && pos <= to2; ) {
36901
37075
  let child = frag.child(i2++), childStart = pos;
@@ -37470,7 +37644,7 @@ function serializeForClipboard(view, slice4) {
37470
37644
  if (firstChild && firstChild.nodeType == 1)
37471
37645
  firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
37472
37646
  let text = view.someProp("clipboardTextSerializer", (f2) => f2(slice4, view)) || slice4.content.textBetween(0, slice4.content.size, "\n\n");
37473
- return { dom: wrap2, text };
37647
+ return { dom: wrap2, text, slice: slice4 };
37474
37648
  }
37475
37649
  function parseFromClipboard(view, text, html, plainText, $context) {
37476
37650
  let inCode = $context.parent.type.spec.code;
@@ -37690,6 +37864,7 @@ class InputState {
37690
37864
  this.lastTouch = 0;
37691
37865
  this.lastAndroidDelete = 0;
37692
37866
  this.composing = false;
37867
+ this.compositionNode = null;
37693
37868
  this.composingTimeout = -1;
37694
37869
  this.compositionNodes = [];
37695
37870
  this.compositionEndedAt = -2e8;
@@ -37817,8 +37992,7 @@ function updateSelection(view, selection, origin2) {
37817
37992
  if (!view.focused)
37818
37993
  view.focus();
37819
37994
  let tr2 = view.state.tr.setSelection(selection);
37820
- if (origin2 == "pointer")
37821
- tr2.setMeta("pointer", true);
37995
+ tr2.setMeta("pointer", true);
37822
37996
  view.dispatch(tr2);
37823
37997
  }
37824
37998
  function selectClickedLeaf(view, inside) {
@@ -37826,7 +38000,7 @@ function selectClickedLeaf(view, inside) {
37826
38000
  return false;
37827
38001
  let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
37828
38002
  if (node && node.isAtom && NodeSelection.isSelectable(node)) {
37829
- updateSelection(view, new NodeSelection($pos), "pointer");
38003
+ updateSelection(view, new NodeSelection($pos));
37830
38004
  return true;
37831
38005
  }
37832
38006
  return false;
@@ -37849,7 +38023,7 @@ function selectClickedNode(view, inside) {
37849
38023
  }
37850
38024
  }
37851
38025
  if (selectAt != null) {
37852
- updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
38026
+ updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
37853
38027
  return true;
37854
38028
  } else {
37855
38029
  return false;
@@ -37870,7 +38044,7 @@ function defaultTripleClick(view, inside, event) {
37870
38044
  let doc2 = view.state.doc;
37871
38045
  if (inside == -1) {
37872
38046
  if (doc2.inlineContent) {
37873
- updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size), "pointer");
38047
+ updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size));
37874
38048
  return true;
37875
38049
  }
37876
38050
  return false;
@@ -37880,9 +38054,9 @@ function defaultTripleClick(view, inside, event) {
37880
38054
  let node = i2 > $pos.depth ? $pos.nodeAfter : $pos.node(i2);
37881
38055
  let nodePos = $pos.before(i2);
37882
38056
  if (node.inlineContent)
37883
- updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size), "pointer");
38057
+ updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size));
37884
38058
  else if (NodeSelection.isSelectable(node))
37885
- updateSelection(view, NodeSelection.create(doc2, nodePos), "pointer");
38059
+ updateSelection(view, NodeSelection.create(doc2, nodePos));
37886
38060
  else
37887
38061
  continue;
37888
38062
  return true;
@@ -37939,7 +38113,7 @@ class MouseDown {
37939
38113
  }
37940
38114
  const target = flushed ? null : event.target;
37941
38115
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
37942
- this.target = targetDesc ? targetDesc.dom : null;
38116
+ this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
37943
38117
  let { selection } = view.state;
37944
38118
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
37945
38119
  this.mightDrag = {
@@ -37999,7 +38173,7 @@ class MouseDown {
37999
38173
  // thus doesn't get a reaction from ProseMirror. This
38000
38174
  // works around that.
38001
38175
  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)) {
38002
- updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)), "pointer");
38176
+ updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
38003
38177
  event.preventDefault();
38004
38178
  } else {
38005
38179
  setSelectionOrigin(this.view, "pointer");
@@ -38071,6 +38245,7 @@ editHandlers.compositionend = (view, event) => {
38071
38245
  view.input.composing = false;
38072
38246
  view.input.compositionEndedAt = event.timeStamp;
38073
38247
  view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
38248
+ view.input.compositionNode = null;
38074
38249
  if (view.input.compositionPendingChanges)
38075
38250
  Promise.resolve().then(() => view.domObserver.flush());
38076
38251
  view.input.compositionID++;
@@ -38090,6 +38265,26 @@ function clearComposition(view) {
38090
38265
  while (view.input.compositionNodes.length > 0)
38091
38266
  view.input.compositionNodes.pop().markParentsDirty();
38092
38267
  }
38268
+ function findCompositionNode(view) {
38269
+ let sel = view.domSelectionRange();
38270
+ if (!sel.focusNode)
38271
+ return null;
38272
+ let textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
38273
+ let textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
38274
+ if (textBefore && textAfter && textBefore != textAfter) {
38275
+ let descAfter = textAfter.pmViewDesc, lastChanged = view.domObserver.lastChangedTextNode;
38276
+ if (textBefore == lastChanged || textAfter == lastChanged)
38277
+ return lastChanged;
38278
+ if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
38279
+ return textAfter;
38280
+ } else if (view.input.compositionNode == textAfter) {
38281
+ let descBefore = textBefore.pmViewDesc;
38282
+ if (!(!descBefore || !descBefore.isText(textBefore.nodeValue)))
38283
+ return textAfter;
38284
+ }
38285
+ }
38286
+ return textBefore || textAfter;
38287
+ }
38093
38288
  function timestampFromCustomEvent() {
38094
38289
  let event = document.createEvent("Event");
38095
38290
  event.initEvent("event", true, true);
@@ -38224,7 +38419,8 @@ handlers.dragstart = (view, _event) => {
38224
38419
  if (desc && desc.node.type.spec.draggable && desc != view.docView)
38225
38420
  node = NodeSelection.create(view.state.doc, desc.posBefore);
38226
38421
  }
38227
- let slice4 = (node || view.state.selection).content(), { dom, text } = serializeForClipboard(view, slice4);
38422
+ let draggedSlice = (node || view.state.selection).content();
38423
+ let { dom, text, slice: slice4 } = serializeForClipboard(view, draggedSlice);
38228
38424
  event.dataTransfer.clearData();
38229
38425
  event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
38230
38426
  event.dataTransfer.effectAllowed = "copyMove";
@@ -38644,9 +38840,6 @@ class DecorationSet {
38644
38840
  return this;
38645
38841
  return local.length || children2.length ? new DecorationSet(local, children2) : empty$1;
38646
38842
  }
38647
- /**
38648
- @internal
38649
- */
38650
38843
  forChild(offset2, node) {
38651
38844
  if (this == empty$1)
38652
38845
  return this;
@@ -39000,6 +39193,7 @@ class DOMObserver {
39000
39193
  this.currentSelection = new SelectionState();
39001
39194
  this.onCharData = null;
39002
39195
  this.suppressingSelectionUpdates = false;
39196
+ this.lastChangedTextNode = null;
39003
39197
  this.observer = window.MutationObserver && new window.MutationObserver((mutations) => {
39004
39198
  for (let i2 = 0; i2 < mutations.length; i2++)
39005
39199
  this.queue.push(mutations[i2]);
@@ -39125,14 +39319,21 @@ class DOMObserver {
39125
39319
  }
39126
39320
  }
39127
39321
  }
39128
- if (gecko && added.length > 1) {
39322
+ if (gecko && added.length) {
39129
39323
  let brs = added.filter((n2) => n2.nodeName == "BR");
39130
39324
  if (brs.length == 2) {
39131
- let a2 = brs[0], b2 = brs[1];
39325
+ let [a2, b2] = brs;
39132
39326
  if (a2.parentNode && a2.parentNode.parentNode == b2.parentNode)
39133
39327
  b2.remove();
39134
39328
  else
39135
39329
  a2.remove();
39330
+ } else {
39331
+ let { focusNode } = this.currentSelection;
39332
+ for (let br2 of brs) {
39333
+ let parent = br2.parentNode;
39334
+ if (parent && parent.nodeName == "LI" && (!focusNode || blockParent(view, focusNode) != parent))
39335
+ br2.remove();
39336
+ }
39136
39337
  }
39137
39338
  }
39138
39339
  let readSel = null;
@@ -39164,8 +39365,12 @@ class DOMObserver {
39164
39365
  if (!desc || desc.ignoreMutation(mut))
39165
39366
  return null;
39166
39367
  if (mut.type == "childList") {
39167
- for (let i2 = 0; i2 < mut.addedNodes.length; i2++)
39168
- added.push(mut.addedNodes[i2]);
39368
+ for (let i2 = 0; i2 < mut.addedNodes.length; i2++) {
39369
+ let node = mut.addedNodes[i2];
39370
+ added.push(node);
39371
+ if (node.nodeType == 3)
39372
+ this.lastChangedTextNode = node;
39373
+ }
39169
39374
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
39170
39375
  return { from: desc.posBefore, to: desc.posAfter };
39171
39376
  let prev = mut.previousSibling, next = mut.nextSibling;
@@ -39186,6 +39391,7 @@ class DOMObserver {
39186
39391
  } else if (mut.type == "attributes") {
39187
39392
  return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border };
39188
39393
  } else {
39394
+ this.lastChangedTextNode = mut.target;
39189
39395
  return {
39190
39396
  from: desc.posAtStart,
39191
39397
  to: desc.posAtEnd,
@@ -39212,7 +39418,20 @@ function checkCSS(view) {
39212
39418
  cssCheckWarned = true;
39213
39419
  }
39214
39420
  }
39215
- function safariShadowSelectionRange(view) {
39421
+ function rangeToSelectionRange(view, range2) {
39422
+ let anchorNode = range2.startContainer, anchorOffset = range2.startOffset;
39423
+ let focusNode = range2.endContainer, focusOffset = range2.endOffset;
39424
+ let currentAnchor = view.domAtPos(view.state.selection.anchor);
39425
+ if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39426
+ [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39427
+ return { anchorNode, anchorOffset, focusNode, focusOffset };
39428
+ }
39429
+ function safariShadowSelectionRange(view, selection) {
39430
+ if (selection.getComposedRanges) {
39431
+ let range2 = selection.getComposedRanges(view.root)[0];
39432
+ if (range2)
39433
+ return rangeToSelectionRange(view, range2);
39434
+ }
39216
39435
  let found2;
39217
39436
  function read2(event) {
39218
39437
  event.preventDefault();
@@ -39222,12 +39441,15 @@ function safariShadowSelectionRange(view) {
39222
39441
  view.dom.addEventListener("beforeinput", read2, true);
39223
39442
  document.execCommand("indent");
39224
39443
  view.dom.removeEventListener("beforeinput", read2, true);
39225
- let anchorNode = found2.startContainer, anchorOffset = found2.startOffset;
39226
- let focusNode = found2.endContainer, focusOffset = found2.endOffset;
39227
- let currentAnchor = view.domAtPos(view.state.selection.anchor);
39228
- if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39229
- [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39230
- return { anchorNode, anchorOffset, focusNode, focusOffset };
39444
+ return found2 ? rangeToSelectionRange(view, found2) : null;
39445
+ }
39446
+ function blockParent(view, node) {
39447
+ for (let p2 = node.parentNode; p2 && p2 != view.dom; p2 = p2.parentNode) {
39448
+ let desc = view.docView.nearestDesc(p2, true);
39449
+ if (desc && desc.node.isBlock)
39450
+ return p2;
39451
+ }
39452
+ return null;
39231
39453
  }
39232
39454
  function parseBetween(view, from_, to_) {
39233
39455
  let { node: parent, fromOffset, toOffset, from: from2, to: to2 } = view.docView.parseRange(from_, to_);
@@ -39347,10 +39569,6 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39347
39569
  return;
39348
39570
  }
39349
39571
  }
39350
- if (chrome && view.cursorWrapper && parse2.sel && parse2.sel.anchor == view.cursorWrapper.deco.from && parse2.sel.head == parse2.sel.anchor) {
39351
- let size2 = change.endB - change.start;
39352
- parse2.sel = { anchor: parse2.sel.anchor + size2, head: parse2.sel.anchor + size2 };
39353
- }
39354
39572
  view.input.domChangeCount++;
39355
39573
  if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
39356
39574
  if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse2.from) {
@@ -39374,7 +39592,7 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39374
39592
  view.input.lastIOSEnter = 0;
39375
39593
  return;
39376
39594
  }
39377
- if (view.state.selection.anchor > change.start && looksLikeJoin(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39595
+ if (view.state.selection.anchor > change.start && looksLikeBackspace(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39378
39596
  if (android && chrome)
39379
39597
  view.domObserver.suppressSelectionUpdates();
39380
39598
  return;
@@ -39458,12 +39676,18 @@ function isMarkChange(cur, prev) {
39458
39676
  if (Fragment.from(updated).eq(cur))
39459
39677
  return { mark, type: type3 };
39460
39678
  }
39461
- function looksLikeJoin(old, start2, end2, $newStart, $newEnd) {
39462
- if (!$newStart.parent.isTextblock || // The content must have shrunk
39463
- end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39464
- skipClosingAndOpening($newStart, true, false) < $newEnd.pos)
39679
+ function looksLikeBackspace(old, start2, end2, $newStart, $newEnd) {
39680
+ if (
39681
+ // The content must have shrunk
39682
+ end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39683
+ skipClosingAndOpening($newStart, true, false) < $newEnd.pos
39684
+ )
39465
39685
  return false;
39466
39686
  let $start = old.resolve(start2);
39687
+ if (!$newStart.parent.isTextblock) {
39688
+ let after = $start.nodeAfter;
39689
+ return after != null && end2 == start2 + after.nodeSize;
39690
+ }
39467
39691
  if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock)
39468
39692
  return false;
39469
39693
  let $next = old.resolve(skipClosingAndOpening($start, true, true));
@@ -39652,8 +39876,10 @@ class EditorView {
39652
39876
  let forceSelUpdate = updateDoc && (ie$1 || chrome) && !this.composing && !prev.selection.empty && !state2.selection.empty && selectionContextChanged(prev.selection, state2.selection);
39653
39877
  if (updateDoc) {
39654
39878
  let chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;
39879
+ if (this.composing)
39880
+ this.input.compositionNode = findCompositionNode(this);
39655
39881
  if (redraw || !this.docView.update(state2.doc, outerDeco, innerDeco, this)) {
39656
- this.docView.updateOuterDeco([]);
39882
+ this.docView.updateOuterDeco(outerDeco);
39657
39883
  this.docView.destroy();
39658
39884
  this.docView = docViewDesc(state2.doc, outerDeco, innerDeco, this.dom, this);
39659
39885
  }
@@ -39912,6 +40138,7 @@ class EditorView {
39912
40138
  }
39913
40139
  this.docView.destroy();
39914
40140
  this.docView = null;
40141
+ clearReusedRange();
39915
40142
  }
39916
40143
  /**
39917
40144
  This is true when the view has been
@@ -39947,7 +40174,8 @@ class EditorView {
39947
40174
  @internal
39948
40175
  */
39949
40176
  domSelectionRange() {
39950
- return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom ? safariShadowSelectionRange(this) : this.domSelection();
40177
+ let sel = this.domSelection();
40178
+ return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;
39951
40179
  }
39952
40180
  /**
39953
40181
  @internal
@@ -40938,7 +41166,8 @@ function getAttributesFromExtensions(extensions) {
40938
41166
  const context = {
40939
41167
  name: extension.name,
40940
41168
  options: extension.options,
40941
- storage: extension.storage
41169
+ storage: extension.storage,
41170
+ extensions: nodeAndMarkExtensions
40942
41171
  };
40943
41172
  const addGlobalAttributes = getExtensionField(extension, "addGlobalAttributes", context);
40944
41173
  if (!addGlobalAttributes) {
@@ -41064,7 +41293,7 @@ function fromString(value) {
41064
41293
  return value;
41065
41294
  }
41066
41295
  function injectExtensionAttributesToParseRule(parseRule, extensionAttributes) {
41067
- if (parseRule.style) {
41296
+ if ("style" in parseRule) {
41068
41297
  return parseRule;
41069
41298
  }
41070
41299
  return {
@@ -41129,6 +41358,7 @@ function getSchemaByResolvedExtensions(extensions, editor) {
41129
41358
  selectable: callOrReturn(getExtensionField(extension, "selectable", context)),
41130
41359
  draggable: callOrReturn(getExtensionField(extension, "draggable", context)),
41131
41360
  code: callOrReturn(getExtensionField(extension, "code", context)),
41361
+ whitespace: callOrReturn(getExtensionField(extension, "whitespace", context)),
41132
41362
  defining: callOrReturn(getExtensionField(extension, "defining", context)),
41133
41363
  isolating: callOrReturn(getExtensionField(extension, "isolating", context)),
41134
41364
  attrs: Object.fromEntries(extensionAttributes.map((extensionAttribute) => {
@@ -41684,7 +41914,7 @@ class ExtensionManager {
41684
41914
  const plugins2 = [];
41685
41915
  const addKeyboardShortcuts = getExtensionField(extension, "addKeyboardShortcuts", context);
41686
41916
  let defaultBindings = {};
41687
- if (extension.type === "mark" && extension.config.exitable) {
41917
+ if (extension.type === "mark" && getExtensionField(extension, "exitable", context)) {
41688
41918
  defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension });
41689
41919
  }
41690
41920
  if (addKeyboardShortcuts) {
@@ -41832,14 +42062,10 @@ function mergeDeep(target, source) {
41832
42062
  const output = { ...target };
41833
42063
  if (isPlainObject(target) && isPlainObject(source)) {
41834
42064
  Object.keys(source).forEach((key) => {
41835
- if (isPlainObject(source[key])) {
41836
- if (!(key in target)) {
41837
- Object.assign(output, { [key]: source[key] });
41838
- } else {
41839
- output[key] = mergeDeep(target[key], source[key]);
41840
- }
42065
+ if (isPlainObject(source[key]) && isPlainObject(target[key])) {
42066
+ output[key] = mergeDeep(target[key], source[key]);
41841
42067
  } else {
41842
- Object.assign(output, { [key]: source[key] });
42068
+ output[key] = source[key];
41843
42069
  }
41844
42070
  });
41845
42071
  }
@@ -41878,13 +42104,14 @@ class Extension {
41878
42104
  return new Extension(config);
41879
42105
  }
41880
42106
  configure(options = {}) {
41881
- const extension = this.extend();
42107
+ const extension = this.extend({
42108
+ ...this.config,
42109
+ addOptions: () => {
42110
+ return mergeDeep(this.options, options);
42111
+ }
42112
+ });
42113
+ extension.name = this.name;
41882
42114
  extension.parent = this.parent;
41883
- extension.options = mergeDeep(this.options, options);
41884
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
41885
- name: extension.name,
41886
- options: extension.options
41887
- }));
41888
42115
  return extension;
41889
42116
  }
41890
42117
  extend(extendedConfig = {}) {
@@ -41892,7 +42119,7 @@ class Extension {
41892
42119
  extension.parent = this;
41893
42120
  this.child = extension;
41894
42121
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
41895
- if (extendedConfig.defaultOptions) {
42122
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
41896
42123
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
41897
42124
  }
41898
42125
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -42276,13 +42503,47 @@ function createNodeFromContent(content, schema, options) {
42276
42503
  }
42277
42504
  return schema.nodeFromJSON(content);
42278
42505
  } catch (error) {
42506
+ if (options.errorOnInvalidContent) {
42507
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: error });
42508
+ }
42279
42509
  console.warn("[tiptap warn]: Invalid content.", "Passed value:", content, "Error:", error);
42280
42510
  return createNodeFromContent("", schema, options);
42281
42511
  }
42282
42512
  }
42283
42513
  if (isTextContent) {
42284
- const parser = DOMParser.fromSchema(schema);
42285
- return options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42514
+ let schemaToUse = schema;
42515
+ let hasInvalidContent = false;
42516
+ let invalidContent = "";
42517
+ if (options.errorOnInvalidContent) {
42518
+ schemaToUse = new Schema({
42519
+ topNode: schema.spec.topNode,
42520
+ marks: schema.spec.marks,
42521
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
42522
+ // 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
42523
+ nodes: schema.spec.nodes.append({
42524
+ __tiptap__private__unknown__catch__all__node: {
42525
+ content: "inline*",
42526
+ group: "block",
42527
+ parseDOM: [
42528
+ {
42529
+ tag: "*",
42530
+ getAttrs: (e) => {
42531
+ hasInvalidContent = true;
42532
+ invalidContent = typeof e === "string" ? e : e.outerHTML;
42533
+ return null;
42534
+ }
42535
+ }
42536
+ ]
42537
+ }
42538
+ })
42539
+ });
42540
+ }
42541
+ const parser = DOMParser.fromSchema(schemaToUse);
42542
+ const response = options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42543
+ if (options.errorOnInvalidContent && hasInvalidContent) {
42544
+ throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${invalidContent}`) });
42545
+ }
42546
+ return response;
42286
42547
  }
42287
42548
  return createNodeFromContent("", schema, options);
42288
42549
  }
@@ -42305,9 +42566,10 @@ function selectionToInsertionEnd(tr2, startLen, bias) {
42305
42566
  tr2.setSelection(Selection$1.near(tr2.doc.resolve(end2), bias));
42306
42567
  }
42307
42568
  const isFragment = (nodeOrFragment) => {
42308
- return nodeOrFragment.toString().startsWith("<");
42569
+ return !("type" in nodeOrFragment);
42309
42570
  };
42310
42571
  const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, editor }) => {
42572
+ var _a2;
42311
42573
  if (dispatch) {
42312
42574
  options = {
42313
42575
  parseOptions: {},
@@ -42316,14 +42578,17 @@ const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, edit
42316
42578
  applyPasteRules: false,
42317
42579
  ...options
42318
42580
  };
42319
- const content = createNodeFromContent(value, editor.schema, {
42320
- parseOptions: {
42321
- preserveWhitespace: "full",
42322
- ...options.parseOptions
42323
- }
42324
- });
42325
- if (content.toString() === "<>") {
42326
- return true;
42581
+ let content;
42582
+ try {
42583
+ content = createNodeFromContent(value, editor.schema, {
42584
+ parseOptions: {
42585
+ preserveWhitespace: "full",
42586
+ ...options.parseOptions
42587
+ },
42588
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42589
+ });
42590
+ } catch (e) {
42591
+ return false;
42327
42592
  }
42328
42593
  let { from: from2, to: to2 } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
42329
42594
  let isOnlyTextContent = true;
@@ -42380,7 +42645,7 @@ const joinBackward = () => ({ state: state2, dispatch }) => {
42380
42645
  const joinForward = () => ({ state: state2, dispatch }) => {
42381
42646
  return joinForward$1(state2, dispatch);
42382
42647
  };
42383
- const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42648
+ const joinItemBackward = () => ({ state: state2, dispatch, tr: tr2 }) => {
42384
42649
  try {
42385
42650
  const point2 = joinPoint(state2.doc, state2.selection.$from.pos, -1);
42386
42651
  if (point2 === null || point2 === void 0) {
@@ -42391,7 +42656,7 @@ const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42391
42656
  dispatch(tr2);
42392
42657
  }
42393
42658
  return true;
42394
- } catch {
42659
+ } catch (e) {
42395
42660
  return false;
42396
42661
  }
42397
42662
  };
@@ -42609,16 +42874,32 @@ const selectTextblockEnd = () => ({ state: state2, dispatch }) => {
42609
42874
  const selectTextblockStart = () => ({ state: state2, dispatch }) => {
42610
42875
  return selectTextblockStart$1(state2, dispatch);
42611
42876
  };
42612
- function createDocument(content, schema, parseOptions = {}) {
42613
- return createNodeFromContent(content, schema, { slice: false, parseOptions });
42877
+ function createDocument(content, schema, parseOptions = {}, options = {}) {
42878
+ return createNodeFromContent(content, schema, {
42879
+ slice: false,
42880
+ parseOptions,
42881
+ errorOnInvalidContent: options.errorOnInvalidContent
42882
+ });
42614
42883
  }
42615
- const setContent$1 = (content, emitUpdate = false, parseOptions = {}) => ({ tr: tr2, editor, dispatch }) => {
42884
+ const setContent$1 = (content, emitUpdate = false, parseOptions = {}, options = {}) => ({ editor, tr: tr2, dispatch, commands: commands2 }) => {
42885
+ var _a2, _b;
42616
42886
  const { doc: doc2 } = tr2;
42617
- const document2 = createDocument(content, editor.schema, parseOptions);
42887
+ if (parseOptions.preserveWhitespace !== "full") {
42888
+ const document2 = createDocument(content, editor.schema, parseOptions, {
42889
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42890
+ });
42891
+ if (dispatch) {
42892
+ tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42893
+ }
42894
+ return true;
42895
+ }
42618
42896
  if (dispatch) {
42619
- tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42897
+ tr2.setMeta("preventUpdate", !emitUpdate);
42620
42898
  }
42621
- return true;
42899
+ return commands2.insertContentAt({ from: 0, to: doc2.content.size }, content, {
42900
+ parseOptions,
42901
+ errorOnInvalidContent: (_b = options.errorOnInvalidContent) !== null && _b !== void 0 ? _b : editor.options.enableContentCheck
42902
+ });
42622
42903
  };
42623
42904
  function getMarkAttributes(state2, typeOrName) {
42624
42905
  const type3 = getMarkType(typeOrName, state2.schema);
@@ -42821,10 +43102,11 @@ function isList(name, extensions) {
42821
43102
  return group.split(" ").includes("list");
42822
43103
  }
42823
43104
  function isNodeEmpty(node) {
42824
- var _a2;
42825
- const defaultContent = (_a2 = node.type.createAndFill()) === null || _a2 === void 0 ? void 0 : _a2.toJSON();
42826
- const content = node.toJSON();
42827
- return JSON.stringify(defaultContent) === JSON.stringify(content);
43105
+ const defaultContent = node.type.createAndFill();
43106
+ if (!defaultContent) {
43107
+ return false;
43108
+ }
43109
+ return node.eq(defaultContent);
42828
43110
  }
42829
43111
  function isNodeSelection(value) {
42830
43112
  return value instanceof NodeSelection;
@@ -43339,14 +43621,14 @@ var commands = /* @__PURE__ */ Object.freeze({
43339
43621
  forEach,
43340
43622
  insertContent,
43341
43623
  insertContentAt,
43342
- joinUp,
43343
- joinDown,
43344
43624
  joinBackward,
43625
+ joinDown,
43345
43626
  joinForward,
43346
43627
  joinItemBackward,
43347
43628
  joinItemForward,
43348
43629
  joinTextblockBackward,
43349
43630
  joinTextblockForward,
43631
+ joinUp,
43350
43632
  keyboardShortcut,
43351
43633
  lift,
43352
43634
  liftEmptyBlock,
@@ -43543,13 +43825,16 @@ const Tabindex = Extension.create({
43543
43825
  new Plugin({
43544
43826
  key: new PluginKey("tabindex"),
43545
43827
  props: {
43546
- attributes: this.editor.isEditable ? { tabindex: "0" } : {}
43828
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
43547
43829
  }
43548
43830
  })
43549
43831
  ];
43550
43832
  }
43551
43833
  });
43552
43834
  class NodePos {
43835
+ get name() {
43836
+ return this.node.type.name;
43837
+ }
43553
43838
  constructor(pos, editor, isBlock = false, node = null) {
43554
43839
  this.currentNode = null;
43555
43840
  this.actualDepth = null;
@@ -43558,9 +43843,6 @@ class NodePos {
43558
43843
  this.editor = editor;
43559
43844
  this.currentNode = node;
43560
43845
  }
43561
- get name() {
43562
- return this.node.type.name;
43563
- }
43564
43846
  get node() {
43565
43847
  return this.currentNode || this.resolvedPos.node();
43566
43848
  }
@@ -43792,7 +44074,7 @@ img.ProseMirror-separator {
43792
44074
  opacity: 0
43793
44075
  }`;
43794
44076
  function createStyleTag(style2, nonce, suffix) {
43795
- const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ""}]`);
44077
+ const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${""}]`);
43796
44078
  if (tiptapStyleTag !== null) {
43797
44079
  return tiptapStyleTag;
43798
44080
  }
@@ -43800,7 +44082,7 @@ function createStyleTag(style2, nonce, suffix) {
43800
44082
  if (nonce) {
43801
44083
  styleNode.setAttribute("nonce", nonce);
43802
44084
  }
43803
- styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ""}`, "");
44085
+ styleNode.setAttribute(`data-tiptap-style${""}`, "");
43804
44086
  styleNode.innerHTML = style2;
43805
44087
  document.getElementsByTagName("head")[0].appendChild(styleNode);
43806
44088
  return styleNode;
@@ -43824,6 +44106,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43824
44106
  enableInputRules: true,
43825
44107
  enablePasteRules: true,
43826
44108
  enableCoreExtensions: true,
44109
+ enableContentCheck: false,
43827
44110
  onBeforeCreate: () => null,
43828
44111
  onCreate: () => null,
43829
44112
  onUpdate: () => null,
@@ -43831,7 +44114,10 @@ let Editor$1 = class Editor2 extends EventEmitter {
43831
44114
  onTransaction: () => null,
43832
44115
  onFocus: () => null,
43833
44116
  onBlur: () => null,
43834
- onDestroy: () => null
44117
+ onDestroy: () => null,
44118
+ onContentError: ({ error }) => {
44119
+ throw error;
44120
+ }
43835
44121
  };
43836
44122
  this.isCapturingTransaction = false;
43837
44123
  this.capturedTransaction = null;
@@ -43841,6 +44127,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43841
44127
  this.createSchema();
43842
44128
  this.on("beforeCreate", this.options.onBeforeCreate);
43843
44129
  this.emit("beforeCreate", { editor: this });
44130
+ this.on("contentError", this.options.onContentError);
43844
44131
  this.createView();
43845
44132
  this.injectCSS();
43846
44133
  this.on("create", this.options.onCreate);
@@ -43994,7 +44281,23 @@ let Editor$1 = class Editor2 extends EventEmitter {
43994
44281
  * Creates a ProseMirror view.
43995
44282
  */
43996
44283
  createView() {
43997
- const doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions);
44284
+ let doc2;
44285
+ try {
44286
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
44287
+ } catch (e) {
44288
+ if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) {
44289
+ throw e;
44290
+ }
44291
+ this.emit("contentError", {
44292
+ editor: this,
44293
+ error: e,
44294
+ disableCollaboration: () => {
44295
+ this.options.extensions = this.options.extensions.filter((extension) => extension.name !== "collaboration");
44296
+ this.createExtensionManager();
44297
+ }
44298
+ });
44299
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: false });
44300
+ }
43998
44301
  const selection = resolveFocusPosition(doc2, this.options.autofocus);
43999
44302
  this.view = new EditorView(this.options.element, {
44000
44303
  ...this.options.editorProps,
@@ -44232,7 +44535,8 @@ function nodeInputRule(config) {
44232
44535
  tr2.insertText(lastChar, start2 + match2[0].length - 1);
44233
44536
  tr2.replaceWith(matchStart, end2, newNode);
44234
44537
  } else if (match2[0]) {
44235
- tr2.insert(start2 - 1, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44538
+ const insertionStart = config.type.isInline ? start2 : start2 - 1;
44539
+ tr2.insert(insertionStart, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44236
44540
  }
44237
44541
  tr2.scrollIntoView();
44238
44542
  }
@@ -44317,20 +44621,22 @@ class Mark {
44317
44621
  return new Mark(config);
44318
44622
  }
44319
44623
  configure(options = {}) {
44320
- const extension = this.extend();
44321
- extension.options = mergeDeep(this.options, options);
44322
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44323
- name: extension.name,
44324
- options: extension.options
44325
- }));
44624
+ const extension = this.extend({
44625
+ ...this.config,
44626
+ addOptions: () => {
44627
+ return mergeDeep(this.options, options);
44628
+ }
44629
+ });
44630
+ extension.name = this.name;
44631
+ extension.parent = this.parent;
44326
44632
  return extension;
44327
44633
  }
44328
44634
  extend(extendedConfig = {}) {
44329
- const extension = new Mark({ ...this.config, ...extendedConfig });
44635
+ const extension = new Mark(extendedConfig);
44330
44636
  extension.parent = this;
44331
44637
  this.child = extension;
44332
44638
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44333
- if (extendedConfig.defaultOptions) {
44639
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44334
44640
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44335
44641
  }
44336
44642
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44396,20 +44702,22 @@ let Node$2 = class Node3 {
44396
44702
  return new Node3(config);
44397
44703
  }
44398
44704
  configure(options = {}) {
44399
- const extension = this.extend();
44400
- extension.options = mergeDeep(this.options, options);
44401
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44402
- name: extension.name,
44403
- options: extension.options
44404
- }));
44705
+ const extension = this.extend({
44706
+ ...this.config,
44707
+ addOptions: () => {
44708
+ return mergeDeep(this.options, options);
44709
+ }
44710
+ });
44711
+ extension.name = this.name;
44712
+ extension.parent = this.parent;
44405
44713
  return extension;
44406
44714
  }
44407
44715
  extend(extendedConfig = {}) {
44408
- const extension = new Node3({ ...this.config, ...extendedConfig });
44716
+ const extension = new Node3(extendedConfig);
44409
44717
  extension.parent = this;
44410
44718
  this.child = extension;
44411
44719
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44412
- if (extendedConfig.defaultOptions) {
44720
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44413
44721
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44414
44722
  }
44415
44723
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44944,14 +45252,12 @@ const CodeBlock = Node$2.create({
44944
45252
  if (!text || !language) {
44945
45253
  return false;
44946
45254
  }
44947
- const { tr: tr2 } = view.state;
44948
- if (view.state.selection.from === view.state.doc.nodeSize - (1 + view.state.selection.$to.depth * 2)) {
44949
- tr2.insert(view.state.selection.from - 1, this.type.create({ language }));
44950
- } else {
44951
- tr2.replaceSelectionWith(this.type.create({ language }));
45255
+ const { tr: tr2, schema } = view.state;
45256
+ const textNode = schema.text(text.replace(/\r\n?/g, "\n"));
45257
+ tr2.replaceSelectionWith(this.type.create({ language }, textNode));
45258
+ if (tr2.selection.$from.parent.type !== this.type) {
45259
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44952
45260
  }
44953
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44954
- tr2.insertText(text.replace(/\r\n?/g, "\n"));
44955
45261
  tr2.setMeta("paste", true);
44956
45262
  view.dispatch(tr2);
44957
45263
  return true;
@@ -45867,13 +46173,13 @@ function applyTransaction(history2, state2, tr2, options) {
45867
46173
  return history2;
45868
46174
  } else if (appended && appended.getMeta(historyKey)) {
45869
46175
  if (appended.getMeta(historyKey).redo)
45870
- 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);
46176
+ return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state2)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
45871
46177
  else
45872
46178
  return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state2)), null, history2.prevTime, history2.prevComposition);
45873
46179
  } else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
45874
46180
  let composition = tr2.getMeta("composition");
45875
46181
  let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
45876
- let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps[tr2.steps.length - 1]);
46182
+ let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
45877
46183
  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);
45878
46184
  } else if (rebased = tr2.getMeta("rebased")) {
45879
46185
  return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
@@ -45894,9 +46200,10 @@ function isAdjacentTo(transform, prevRanges) {
45894
46200
  });
45895
46201
  return adjacent;
45896
46202
  }
45897
- function rangesFor(map4) {
46203
+ function rangesFor(maps) {
45898
46204
  let result2 = [];
45899
- map4.forEach((_from, _to, from2, to2) => result2.push(from2, to2));
46205
+ for (let i2 = maps.length - 1; i2 >= 0 && result2.length == 0; i2--)
46206
+ maps[i2].forEach((_from, _to, from2, to2) => result2.push(from2, to2));
45900
46207
  return result2;
45901
46208
  }
45902
46209
  function mapRanges(ranges, mapping) {
@@ -45910,16 +46217,16 @@ function mapRanges(ranges, mapping) {
45910
46217
  }
45911
46218
  return result2;
45912
46219
  }
45913
- function histTransaction(history2, state2, dispatch, redo2) {
46220
+ function histTransaction(history2, state2, redo2) {
45914
46221
  let preserveItems = mustPreserveItems(state2);
45915
46222
  let histOptions = historyKey.get(state2).spec.config;
45916
46223
  let pop = (redo2 ? history2.undone : history2.done).popEvent(state2, preserveItems);
45917
46224
  if (!pop)
45918
- return;
46225
+ return null;
45919
46226
  let selection = pop.selection.resolve(pop.transform.doc);
45920
46227
  let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state2.selection.getBookmark(), histOptions, preserveItems);
45921
46228
  let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
45922
- dispatch(pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist }).scrollIntoView());
46229
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
45923
46230
  }
45924
46231
  let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
45925
46232
  function mustPreserveItems(state2) {
@@ -45967,22 +46274,21 @@ function history(config = {}) {
45967
46274
  }
45968
46275
  });
45969
46276
  }
45970
- const undo = (state2, dispatch) => {
45971
- let hist = historyKey.getState(state2);
45972
- if (!hist || hist.done.eventCount == 0)
45973
- return false;
45974
- if (dispatch)
45975
- histTransaction(hist, state2, dispatch, false);
45976
- return true;
45977
- };
45978
- const redo = (state2, dispatch) => {
45979
- let hist = historyKey.getState(state2);
45980
- if (!hist || hist.undone.eventCount == 0)
45981
- return false;
45982
- if (dispatch)
45983
- histTransaction(hist, state2, dispatch, true);
45984
- return true;
45985
- };
46277
+ function buildCommand(redo2, scroll) {
46278
+ return (state2, dispatch) => {
46279
+ let hist = historyKey.getState(state2);
46280
+ if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
46281
+ return false;
46282
+ if (dispatch) {
46283
+ let tr2 = histTransaction(hist, state2, redo2);
46284
+ if (tr2)
46285
+ dispatch(scroll ? tr2.scrollIntoView() : tr2);
46286
+ }
46287
+ return true;
46288
+ };
46289
+ }
46290
+ const undo = buildCommand(false, true);
46291
+ const redo = buildCommand(true, true);
45986
46292
  const History = Extension.create({
45987
46293
  name: "history",
45988
46294
  addOptions() {
@@ -46034,10 +46340,20 @@ const HorizontalRule = Node$2.create({
46034
46340
  addCommands() {
46035
46341
  return {
46036
46342
  setHorizontalRule: () => ({ chain, state: state2 }) => {
46037
- const { $to: $originTo } = state2.selection;
46343
+ const { selection } = state2;
46344
+ const { $from: $originFrom, $to: $originTo } = selection;
46038
46345
  const currentChain = chain();
46039
- if ($originTo.parentOffset === 0) {
46040
- currentChain.insertContentAt(Math.max($originTo.pos - 2, 0), { type: this.name });
46346
+ if ($originFrom.parentOffset === 0) {
46347
+ currentChain.insertContentAt({
46348
+ from: Math.max($originFrom.pos - 1, 0),
46349
+ to: $originTo.pos
46350
+ }, {
46351
+ type: this.name
46352
+ });
46353
+ } else if (isNodeSelection(selection)) {
46354
+ currentChain.insertContentAt($originTo.pos, {
46355
+ type: this.name
46356
+ });
46041
46357
  } else {
46042
46358
  currentChain.insertContent({ type: this.name });
46043
46359
  }
@@ -46423,11 +46739,11 @@ const StarterKit = Extension.create({
46423
46739
  addExtensions() {
46424
46740
  var _a2, _b, _c, _d, _e2, _f, _g, _h, _j, _k, _l2, _m, _o, _p, _q, _r2, _s, _t2;
46425
46741
  const extensions = [];
46426
- if (this.options.blockquote !== false) {
46427
- extensions.push(Blockquote.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.blockquote));
46428
- }
46429
46742
  if (this.options.bold !== false) {
46430
- extensions.push(Bold.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.bold));
46743
+ extensions.push(Bold.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.bold));
46744
+ }
46745
+ if (this.options.blockquote !== false) {
46746
+ extensions.push(Blockquote.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.blockquote));
46431
46747
  }
46432
46748
  if (this.options.bulletList !== false) {
46433
46749
  extensions.push(BulletList.configure((_c = this.options) === null || _c === void 0 ? void 0 : _c.bulletList));
@@ -49234,7 +49550,7 @@ class BubbleMenuView {
49234
49550
  }
49235
49551
  update(view, oldState) {
49236
49552
  const { state: state2 } = view;
49237
- const hasValidSelection = state2.selection.$from.pos !== state2.selection.$to.pos;
49553
+ const hasValidSelection = state2.selection.from !== state2.selection.to;
49238
49554
  if (this.updateDelay > 0 && hasValidSelection) {
49239
49555
  this.handleDebouncedUpdate(view, oldState);
49240
49556
  return;
@@ -52279,9 +52595,6 @@ function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
52279
52595
  return { colgroup, tableWidth, tableMinWidth };
52280
52596
  }
52281
52597
  function createCell(cellType, cellContent) {
52282
- if (cellContent) {
52283
- return cellType.createChecked(null, cellContent);
52284
- }
52285
52598
  return cellType.createAndFill();
52286
52599
  }
52287
52600
  function getTableNodeTypes(schema) {
@@ -52303,12 +52616,12 @@ function createTable$1(schema, rowsCount, colsCount, withHeaderRow, cellContent)
52303
52616
  const headerCells = [];
52304
52617
  const cells = [];
52305
52618
  for (let index2 = 0; index2 < colsCount; index2 += 1) {
52306
- const cell = createCell(types.cell, cellContent);
52619
+ const cell = createCell(types.cell);
52307
52620
  if (cell) {
52308
52621
  cells.push(cell);
52309
52622
  }
52310
52623
  if (withHeaderRow) {
52311
- const headerCell = createCell(types.header_cell, cellContent);
52624
+ const headerCell = createCell(types.header_cell);
52312
52625
  if (headerCell) {
52313
52626
  headerCells.push(headerCell);
52314
52627
  }
@@ -52386,7 +52699,7 @@ const Table = Node$2.create({
52386
52699
  insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr: tr2, dispatch, editor }) => {
52387
52700
  const node = createTable$1(editor.schema, rows, cols, withHeaderRow);
52388
52701
  if (dispatch) {
52389
- const offset2 = tr2.selection.anchor + 1;
52702
+ const offset2 = tr2.selection.from + 1;
52390
52703
  tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(offset2)));
52391
52704
  }
52392
52705
  return true;
@@ -52863,18 +53176,7 @@ function _typeof$1(obj) {
52863
53176
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
52864
53177
  }, _typeof$1(obj);
52865
53178
  }
52866
- function _defineProperties$2(target, props2) {
52867
- for (var i2 = 0; i2 < props2.length; i2++) {
52868
- var descriptor = props2[i2];
52869
- descriptor.enumerable = descriptor.enumerable || false;
52870
- descriptor.configurable = true;
52871
- if ("value" in descriptor) descriptor.writable = true;
52872
- Object.defineProperty(target, descriptor.key, descriptor);
52873
- }
52874
- }
52875
53179
  function _createClass$2(Constructor, protoProps, staticProps) {
52876
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
52877
- if (staticProps) _defineProperties$2(Constructor, staticProps);
52878
53180
  Object.defineProperty(Constructor, "prototype", { writable: false });
52879
53181
  return Constructor;
52880
53182
  }
@@ -53051,7 +53353,6 @@ function _defineProperties$1(target, props2) {
53051
53353
  }
53052
53354
  function _createClass$1(Constructor, protoProps, staticProps) {
53053
53355
  if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
53054
- if (staticProps) _defineProperties$1(Constructor, staticProps);
53055
53356
  Object.defineProperty(Constructor, "prototype", { writable: false });
53056
53357
  return Constructor;
53057
53358
  }
@@ -53693,10 +53994,10 @@ var DIGITS = {
53693
53994
  function parseDigit(character) {
53694
53995
  return DIGITS[character];
53695
53996
  }
53696
- function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53997
+ function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53697
53998
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53698
53999
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53699
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$5(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54000
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike) {
53700
54001
  if (it2) o2 = it2;
53701
54002
  var i2 = 0;
53702
54003
  return function() {
@@ -53706,15 +54007,15 @@ function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53706
54007
  }
53707
54008
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53708
54009
  }
53709
- function _unsupportedIterableToArray$5(o2, minLen) {
54010
+ function _unsupportedIterableToArray$4(o2, minLen) {
53710
54011
  if (!o2) return;
53711
- if (typeof o2 === "string") return _arrayLikeToArray$5(o2, minLen);
54012
+ if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53712
54013
  var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53713
54014
  if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53714
54015
  if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53715
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$5(o2, minLen);
54016
+ if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53716
54017
  }
53717
- function _arrayLikeToArray$5(arr, len) {
54018
+ function _arrayLikeToArray$4(arr, len) {
53718
54019
  if (len == null || len > arr.length) len = arr.length;
53719
54020
  for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53720
54021
  arr2[i2] = arr[i2];
@@ -53723,7 +54024,7 @@ function _arrayLikeToArray$5(arr, len) {
53723
54024
  }
53724
54025
  function parseIncompletePhoneNumber(string2) {
53725
54026
  var result2 = "";
53726
- for (var _iterator = _createForOfIteratorHelperLoose$4(string2.split("")), _step; !(_step = _iterator()).done; ) {
54027
+ for (var _iterator = _createForOfIteratorHelperLoose$3(string2.split("")), _step; !(_step = _iterator()).done; ) {
53727
54028
  var character = _step.value;
53728
54029
  result2 += parsePhoneNumberCharacter(character, result2) || "";
53729
54030
  }
@@ -53732,55 +54033,12 @@ function parseIncompletePhoneNumber(string2) {
53732
54033
  function parsePhoneNumberCharacter(character, prevParsedCharacters, emitEvent) {
53733
54034
  if (character === "+") {
53734
54035
  if (prevParsedCharacters) {
53735
- if (typeof emitEvent === "function") {
53736
- emitEvent("end");
53737
- }
53738
54036
  return;
53739
54037
  }
53740
54038
  return "+";
53741
54039
  }
53742
54040
  return parseDigit(character);
53743
54041
  }
53744
- function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53745
- var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53746
- if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53747
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
53748
- if (it2) o2 = it2;
53749
- var i2 = 0;
53750
- return function() {
53751
- if (i2 >= o2.length) return { done: true };
53752
- return { done: false, value: o2[i2++] };
53753
- };
53754
- }
53755
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53756
- }
53757
- function _unsupportedIterableToArray$4(o2, minLen) {
53758
- if (!o2) return;
53759
- if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53760
- var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53761
- if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53762
- if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53763
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53764
- }
53765
- function _arrayLikeToArray$4(arr, len) {
53766
- if (len == null || len > arr.length) len = arr.length;
53767
- for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53768
- arr2[i2] = arr[i2];
53769
- }
53770
- return arr2;
53771
- }
53772
- function mergeArrays(a2, b2) {
53773
- var merged = a2.slice();
53774
- for (var _iterator = _createForOfIteratorHelperLoose$3(b2), _step; !(_step = _iterator()).done; ) {
53775
- var element = _step.value;
53776
- if (a2.indexOf(element) < 0) {
53777
- merged.push(element);
53778
- }
53779
- }
53780
- return merged.sort(function(a3, b3) {
53781
- return a3 - b3;
53782
- });
53783
- }
53784
54042
  function checkNumberLength(nationalNumber, metadata2) {
53785
54043
  return checkNumberLengthForType(nationalNumber, void 0, metadata2);
53786
54044
  }
@@ -53790,17 +54048,6 @@ function checkNumberLengthForType(nationalNumber, type3, metadata2) {
53790
54048
  if (!possible_lengths) {
53791
54049
  return "IS_POSSIBLE";
53792
54050
  }
53793
- if (type3 === "FIXED_LINE_OR_MOBILE") {
53794
- if (!metadata2.type("FIXED_LINE")) {
53795
- return checkNumberLengthForType(nationalNumber, "MOBILE", metadata2);
53796
- }
53797
- var mobile_type = metadata2.type("MOBILE");
53798
- if (mobile_type) {
53799
- possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths());
53800
- }
53801
- } else if (type3 && !type_info) {
53802
- return "INVALID_LENGTH";
53803
- }
53804
54051
  var actual_length = nationalNumber.length;
53805
54052
  var minimum_length = possible_lengths[0];
53806
54053
  if (minimum_length === actual_length) {
@@ -53865,7 +54112,7 @@ function matchesEntirely(text, regular_expression) {
53865
54112
  function _createForOfIteratorHelperLoose$2(o2, allowArrayLike) {
53866
54113
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53867
54114
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53868
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54115
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike) {
53869
54116
  if (it2) o2 = it2;
53870
54117
  var i2 = 0;
53871
54118
  return function() {
@@ -53965,8 +54212,6 @@ function applyInternationalSeparatorStyle(formattedNumber) {
53965
54212
  var FIRST_GROUP_PATTERN = /(\$\d)/;
53966
54213
  function formatNationalNumberUsingFormat(number2, format2, _ref) {
53967
54214
  var useInternationalFormat = _ref.useInternationalFormat, withNationalPrefix = _ref.withNationalPrefix;
53968
- _ref.carrierCode;
53969
- _ref.metadata;
53970
54215
  var formattedNumber = number2.replace(new RegExp(format2.pattern()), useInternationalFormat ? format2.internationalFormat() : (
53971
54216
  // This library doesn't use `domestic_carrier_code_formatting_rule`,
53972
54217
  // because that one is only used when formatting phone numbers
@@ -54012,7 +54257,7 @@ function formatRFC3966(_ref) {
54012
54257
  function _createForOfIteratorHelperLoose$1(o2, allowArrayLike) {
54013
54258
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54014
54259
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54015
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54260
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike) {
54016
54261
  if (it2) o2 = it2;
54017
54262
  var i2 = 0;
54018
54263
  return function() {
@@ -54208,7 +54453,6 @@ function _defineProperties(target, props2) {
54208
54453
  }
54209
54454
  function _createClass(Constructor, protoProps, staticProps) {
54210
54455
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54211
- if (staticProps) _defineProperties(Constructor, staticProps);
54212
54456
  Object.defineProperty(Constructor, "prototype", { writable: false });
54213
54457
  return Constructor;
54214
54458
  }
@@ -54505,7 +54749,7 @@ function extractCountryCallingCode(number2, country, callingCode, metadata2) {
54505
54749
  function _createForOfIteratorHelperLoose(o2, allowArrayLike) {
54506
54750
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54507
54751
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54508
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54752
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike) {
54509
54753
  if (it2) o2 = it2;
54510
54754
  var i2 = 0;
54511
54755
  return function() {
@@ -54559,14 +54803,8 @@ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
54559
54803
  return matchingCountries[0];
54560
54804
  }
54561
54805
  }
54562
- var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
54563
54806
  function getCountryByCallingCode(callingCode, _ref) {
54564
54807
  var nationalPhoneNumber = _ref.nationalNumber, defaultCountry = _ref.defaultCountry, metadata2 = _ref.metadata;
54565
- if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
54566
- if (metadata2.isNonGeographicCallingCode(callingCode)) {
54567
- return "001";
54568
- }
54569
- }
54570
54808
  var possibleCountries = metadata2.getCountryCodesForCallingCode(callingCode);
54571
54809
  if (!possibleCountries) {
54572
54810
  return;
@@ -57400,7 +57638,7 @@ const bisectCenter = bisector(number$2).center;
57400
57638
  function extent(values3, valueof) {
57401
57639
  let min2;
57402
57640
  let max2;
57403
- if (valueof === void 0) {
57641
+ {
57404
57642
  for (const value of values3) {
57405
57643
  if (value != null) {
57406
57644
  if (min2 === void 0) {
@@ -57411,18 +57649,6 @@ function extent(values3, valueof) {
57411
57649
  }
57412
57650
  }
57413
57651
  }
57414
- } else {
57415
- let index2 = -1;
57416
- for (let value of values3) {
57417
- if ((value = valueof(value, ++index2, values3)) != null) {
57418
- if (min2 === void 0) {
57419
- if (value >= value) min2 = max2 = value;
57420
- } else {
57421
- if (min2 > value) min2 = value;
57422
- if (max2 < value) max2 = value;
57423
- }
57424
- }
57425
- }
57426
57652
  }
57427
57653
  return [min2, max2];
57428
57654
  }