@bagelink/vue 0.0.598 → 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.
package/dist/index.cjs CHANGED
@@ -112,12 +112,21 @@ function getPaddingObject(padding) {
112
112
  };
113
113
  }
114
114
  function rectToClientRect$1(rect) {
115
+ const {
116
+ x: x2,
117
+ y: y2,
118
+ width,
119
+ height
120
+ } = rect;
115
121
  return {
116
- ...rect,
117
- top: rect.y,
118
- left: rect.x,
119
- right: rect.x + rect.width,
120
- bottom: rect.y + rect.height
122
+ width,
123
+ height,
124
+ top: y2,
125
+ left: x2,
126
+ right: x2 + width,
127
+ bottom: y2 + height,
128
+ x: x2,
129
+ y: y2
121
130
  };
122
131
  }
123
132
  function computeCoordsFromPlacement(_ref, placement, rtl) {
@@ -288,9 +297,10 @@ async function detectOverflow$1(state2, options) {
288
297
  strategy
289
298
  }));
290
299
  const rect = elementContext === "floating" ? {
291
- ...rects.floating,
292
300
  x: x2,
293
- y: y2
301
+ y: y2,
302
+ width: rects.floating.width,
303
+ height: rects.floating.height
294
304
  } : rects.reference;
295
305
  const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
296
306
  const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
@@ -501,10 +511,12 @@ const flip$2 = function(options) {
501
511
  return {};
502
512
  }
503
513
  const side = getSide$1(placement);
514
+ const initialSideAxis = getSideAxis(initialPlacement);
504
515
  const isBasePlacement = getSide$1(initialPlacement) === initialPlacement;
505
516
  const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
506
517
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement$1(initialPlacement)] : getExpandedPlacements(initialPlacement));
507
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
518
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
519
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
508
520
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
509
521
  }
510
522
  const placements2 = [initialPlacement, ...fallbackPlacements];
@@ -541,8 +553,16 @@ const flip$2 = function(options) {
541
553
  if (!resetPlacement) {
542
554
  switch (fallbackStrategy) {
543
555
  case "bestFit": {
544
- var _overflowsData$map$so;
545
- const placement2 = (_overflowsData$map$so = overflowsData.map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
556
+ var _overflowsData$filter2;
557
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
558
+ if (hasFallbackAxisSideDirection) {
559
+ const currentSideAxis = getSideAxis(d2.placement);
560
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
561
+ // reading directions favoring greater width.
562
+ currentSideAxis === "y";
563
+ }
564
+ return true;
565
+ }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
546
566
  if (placement2) {
547
567
  resetPlacement = placement2;
548
568
  }
@@ -737,16 +757,16 @@ const size = function(options) {
737
757
  widthSide = side;
738
758
  heightSide = alignment === "end" ? "top" : "bottom";
739
759
  }
740
- const overflowAvailableHeight = height - overflow[heightSide];
741
- const overflowAvailableWidth = width - overflow[widthSide];
760
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
761
+ const maximumClippingWidth = width - overflow.left - overflow.right;
762
+ const overflowAvailableHeight = min$3(height - overflow[heightSide], maximumClippingHeight);
763
+ const overflowAvailableWidth = min$3(width - overflow[widthSide], maximumClippingWidth);
742
764
  const noShift = !state2.middlewareData.shift;
743
765
  let availableHeight = overflowAvailableHeight;
744
766
  let availableWidth = overflowAvailableWidth;
745
767
  if (isYAxis) {
746
- const maximumClippingWidth = width - overflow.left - overflow.right;
747
768
  availableWidth = alignment || noShift ? min$3(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
748
769
  } else {
749
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
750
770
  availableHeight = alignment || noShift ? min$3(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
751
771
  }
752
772
  if (noShift && !alignment) {
@@ -3383,7 +3403,6 @@ const defaults$1 = {
3383
3403
  utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
3384
3404
  defaults$1.headers[method] = {};
3385
3405
  });
3386
- const defaults$2 = defaults$1;
3387
3406
  const ignoreDuplicateOf = utils$1.toObjectSet([
3388
3407
  "age",
3389
3408
  "authorization",
@@ -3645,11 +3664,10 @@ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
3645
3664
  };
3646
3665
  });
3647
3666
  utils$1.freezeMethods(AxiosHeaders);
3648
- const AxiosHeaders$1 = AxiosHeaders;
3649
3667
  function transformData(fns, response) {
3650
- const config = this || defaults$2;
3668
+ const config = this || defaults$1;
3651
3669
  const context = response || config;
3652
- const headers = AxiosHeaders$1.from(context.headers);
3670
+ const headers = AxiosHeaders.from(context.headers);
3653
3671
  let data2 = context.data;
3654
3672
  utils$1.forEach(fns, function transform(fn3) {
3655
3673
  data2 = fn3.call(config, data2, headers.normalize(), response ? response.status : void 0);
@@ -3848,7 +3866,7 @@ function buildFullPath(baseURL, requestedURL) {
3848
3866
  }
3849
3867
  return requestedURL;
3850
3868
  }
3851
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3869
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
3852
3870
  function mergeConfig(config1, config2) {
3853
3871
  config2 = config2 || {};
3854
3872
  const config = {};
@@ -3929,7 +3947,7 @@ function mergeConfig(config1, config2) {
3929
3947
  const resolveConfig = (config) => {
3930
3948
  const newConfig = mergeConfig({}, config);
3931
3949
  let { data: data2, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3932
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
3950
+ newConfig.headers = headers = AxiosHeaders.from(headers);
3933
3951
  newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
3934
3952
  if (auth) {
3935
3953
  headers.set(
@@ -3962,7 +3980,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3962
3980
  return new Promise(function dispatchXhrRequest(resolve, reject3) {
3963
3981
  const _config = resolveConfig(config);
3964
3982
  let requestData = _config.data;
3965
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3983
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
3966
3984
  let { responseType } = _config;
3967
3985
  let onCanceled;
3968
3986
  function done() {
@@ -3980,7 +3998,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3980
3998
  if (!request) {
3981
3999
  return;
3982
4000
  }
3983
- const responseHeaders = AxiosHeaders$1.from(
4001
+ const responseHeaders = AxiosHeaders.from(
3984
4002
  "getAllResponseHeaders" in request && request.getAllResponseHeaders()
3985
4003
  );
3986
4004
  const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
@@ -4296,7 +4314,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
4296
4314
  return await new Promise((resolve, reject3) => {
4297
4315
  settle(resolve, reject3, {
4298
4316
  data: responseData,
4299
- headers: AxiosHeaders$1.from(response.headers),
4317
+ headers: AxiosHeaders.from(response.headers),
4300
4318
  status: response.status,
4301
4319
  statusText: response.statusText,
4302
4320
  config,
@@ -4378,7 +4396,7 @@ function throwIfCancellationRequested(config) {
4378
4396
  }
4379
4397
  function dispatchRequest(config) {
4380
4398
  throwIfCancellationRequested(config);
4381
- config.headers = AxiosHeaders$1.from(config.headers);
4399
+ config.headers = AxiosHeaders.from(config.headers);
4382
4400
  config.data = transformData.call(
4383
4401
  config,
4384
4402
  config.transformRequest
@@ -4386,7 +4404,7 @@ function dispatchRequest(config) {
4386
4404
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
4387
4405
  config.headers.setContentType("application/x-www-form-urlencoded", false);
4388
4406
  }
4389
- const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter);
4407
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
4390
4408
  return adapter(config).then(function onAdapterResolution(response) {
4391
4409
  throwIfCancellationRequested(config);
4392
4410
  response.data = transformData.call(
@@ -4394,7 +4412,7 @@ function dispatchRequest(config) {
4394
4412
  config.transformResponse,
4395
4413
  response
4396
4414
  );
4397
- response.headers = AxiosHeaders$1.from(response.headers);
4415
+ response.headers = AxiosHeaders.from(response.headers);
4398
4416
  return response;
4399
4417
  }, function onAdapterRejection(reason) {
4400
4418
  if (!isCancel(reason)) {
@@ -4405,7 +4423,7 @@ function dispatchRequest(config) {
4405
4423
  config.transformResponse,
4406
4424
  reason.response
4407
4425
  );
4408
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
4426
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
4409
4427
  }
4410
4428
  }
4411
4429
  return Promise.reject(reason);
@@ -4544,7 +4562,7 @@ class Axios {
4544
4562
  delete headers[method];
4545
4563
  }
4546
4564
  );
4547
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
4565
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
4548
4566
  const requestInterceptorChain = [];
4549
4567
  let synchronousRequestInterceptors = true;
4550
4568
  this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
@@ -4628,7 +4646,6 @@ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method)
4628
4646
  Axios.prototype[method] = generateHTTPMethod();
4629
4647
  Axios.prototype[method + "Form"] = generateHTTPMethod(true);
4630
4648
  });
4631
- const Axios$1 = Axios;
4632
4649
  class CancelToken {
4633
4650
  constructor(executor) {
4634
4651
  if (typeof executor !== "function") {
@@ -4715,7 +4732,6 @@ class CancelToken {
4715
4732
  };
4716
4733
  }
4717
4734
  }
4718
- const CancelToken$1 = CancelToken;
4719
4735
  function spread(callback) {
4720
4736
  return function wrap2(arr) {
4721
4737
  return callback.apply(null, arr);
@@ -4792,21 +4808,20 @@ const HttpStatusCode = {
4792
4808
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
4793
4809
  HttpStatusCode[value] = key;
4794
4810
  });
4795
- const HttpStatusCode$1 = HttpStatusCode;
4796
4811
  function createInstance(defaultConfig2) {
4797
- const context = new Axios$1(defaultConfig2);
4798
- const instance = bind$2(Axios$1.prototype.request, context);
4799
- utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
4812
+ const context = new Axios(defaultConfig2);
4813
+ const instance = bind$2(Axios.prototype.request, context);
4814
+ utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
4800
4815
  utils$1.extend(instance, context, null, { allOwnKeys: true });
4801
4816
  instance.create = function create(instanceConfig) {
4802
4817
  return createInstance(mergeConfig(defaultConfig2, instanceConfig));
4803
4818
  };
4804
4819
  return instance;
4805
4820
  }
4806
- const axios$1 = createInstance(defaults$2);
4807
- axios$1.Axios = Axios$1;
4821
+ const axios$1 = createInstance(defaults$1);
4822
+ axios$1.Axios = Axios;
4808
4823
  axios$1.CanceledError = CanceledError;
4809
- axios$1.CancelToken = CancelToken$1;
4824
+ axios$1.CancelToken = CancelToken;
4810
4825
  axios$1.isCancel = isCancel;
4811
4826
  axios$1.VERSION = VERSION;
4812
4827
  axios$1.toFormData = toFormData;
@@ -4818,10 +4833,10 @@ axios$1.all = function all(promises) {
4818
4833
  axios$1.spread = spread;
4819
4834
  axios$1.isAxiosError = isAxiosError;
4820
4835
  axios$1.mergeConfig = mergeConfig;
4821
- axios$1.AxiosHeaders = AxiosHeaders$1;
4836
+ axios$1.AxiosHeaders = AxiosHeaders;
4822
4837
  axios$1.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4823
4838
  axios$1.getAdapter = adapters.getAdapter;
4824
- axios$1.HttpStatusCode = HttpStatusCode$1;
4839
+ axios$1.HttpStatusCode = HttpStatusCode;
4825
4840
  axios$1.default = axios$1;
4826
4841
  var __defProp = Object.defineProperty;
4827
4842
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -5065,7 +5080,11 @@ class Bagel {
5065
5080
  this._setAuthorization();
5066
5081
  const formData = new FormData();
5067
5082
  formData.append("file", file);
5068
- const { data: data2 } = await axios.post("/static_files/upload", formData, {
5083
+ let url = "/static_files/upload";
5084
+ console.log(options == null ? void 0 : options.topic);
5085
+ if (options == null ? void 0 : options.topic)
5086
+ url = `/static_files/upload?topic=${options.topic}`;
5087
+ const { data: data2 } = await axios.post(url, formData, {
5069
5088
  headers: {
5070
5089
  "Content-Type": "multipart/form-data"
5071
5090
  },
@@ -6034,7 +6053,7 @@ function toValue(r2) {
6034
6053
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
6035
6054
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
6036
6055
  function getLifeCycleTarget(target) {
6037
- return target || vue.getCurrentInstance();
6056
+ return vue.getCurrentInstance();
6038
6057
  }
6039
6058
  function tryOnMounted(fn3, sync = true, target) {
6040
6059
  const instance = getLifeCycleTarget();
@@ -6603,7 +6622,7 @@ const _hoisted_1$A = {
6603
6622
  };
6604
6623
  const _hoisted_2$s = {
6605
6624
  key: 0,
6606
- class: "data-row"
6625
+ class: "data-row m_py-05"
6607
6626
  };
6608
6627
  const _hoisted_3$i = { class: "key" };
6609
6628
  const _hoisted_4$c = { class: "m-0" };
@@ -6677,7 +6696,7 @@ const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
6677
6696
  };
6678
6697
  }
6679
6698
  });
6680
- const DataPreview = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-02756011"]]);
6699
+ const DataPreview = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-792f7ec0"]]);
6681
6700
  const _hoisted_1$z = {
6682
6701
  key: 0,
6683
6702
  class: "card_label"
@@ -17278,12 +17297,7 @@ function eachDayOfInterval(interval, options) {
17278
17297
  const endTime = reversed ? +startDate : +endDate;
17279
17298
  const currentDate = reversed ? endDate : startDate;
17280
17299
  currentDate.setHours(0, 0, 0, 0);
17281
- let step = (options == null ? void 0 : options.step) ?? 1;
17282
- if (!step) return [];
17283
- if (step < 0) {
17284
- step = -step;
17285
- reversed = !reversed;
17286
- }
17300
+ let step = 1;
17287
17301
  const dates = [];
17288
17302
  while (+currentDate <= endTime) {
17289
17303
  dates.push(toDate(currentDate));
@@ -17306,12 +17320,7 @@ function eachQuarterOfInterval(interval, options) {
17306
17320
  let reversed = +startDate > +endDate;
17307
17321
  const endTime = reversed ? +startOfQuarter(startDate) : +startOfQuarter(endDate);
17308
17322
  let currentDate = reversed ? startOfQuarter(endDate) : startOfQuarter(startDate);
17309
- let step = (options == null ? void 0 : options.step) ?? 1;
17310
- if (!step) return [];
17311
- if (step < 0) {
17312
- step = -step;
17313
- reversed = !reversed;
17314
- }
17323
+ let step = 1;
17315
17324
  const dates = [];
17316
17325
  while (+currentDate <= endTime) {
17317
17326
  dates.push(toDate(currentDate));
@@ -26157,10 +26166,8 @@ function isScrolledPast(el, elSide, parentSide) {
26157
26166
  var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
26158
26167
  while (parent) {
26159
26168
  var parentSideVal = getRect(parent)[parentSide], visible = void 0;
26160
- if (parentSide === "top" || parentSide === "left") {
26169
+ {
26161
26170
  visible = elSideVal >= parentSideVal;
26162
- } else {
26163
- visible = elSideVal <= parentSideVal;
26164
26171
  }
26165
26172
  if (!visible) return parent;
26166
26173
  if (parent === getWindowScrollingElement()) break;
@@ -29535,7 +29542,7 @@ class Fragment {
29535
29542
  /**
29536
29543
  Find the index and inner offset corresponding to a given relative
29537
29544
  position in this fragment. The result object will be reused
29538
- (overwritten) the next time the function is called. (Not public.)
29545
+ (overwritten) the next time the function is called. @internal
29539
29546
  */
29540
29547
  findIndex(pos, round2 = -1) {
29541
29548
  if (pos == 0)
@@ -29741,7 +29748,9 @@ let Mark$1 = class Mark2 {
29741
29748
  let type3 = schema.marks[json.type];
29742
29749
  if (!type3)
29743
29750
  throw new RangeError(`There is no mark type ${json.type} in this schema`);
29744
- return type3.create(json.attrs);
29751
+ let mark = type3.create(json.attrs);
29752
+ type3.checkAttrs(mark.attrs);
29753
+ return mark;
29745
29754
  }
29746
29755
  /**
29747
29756
  Test whether two sets of marks are identical.
@@ -29875,8 +29884,6 @@ function removeRange(content, from2, to2) {
29875
29884
  function insertInto(content, dist, insert, parent) {
29876
29885
  let { index: index2, offset: offset2 } = content.findIndex(dist), child = content.maybeChild(index2);
29877
29886
  if (offset2 == dist || child.isText) {
29878
- if (parent && !parent.canReplace(index2, index2, insert))
29879
- return null;
29880
29887
  return content.cut(0, dist).append(insert).append(content.cut(dist));
29881
29888
  }
29882
29889
  let inner = insertInto(child.content, dist - offset2 - 1, insert);
@@ -30238,17 +30245,28 @@ class ResolvedPos {
30238
30245
  @internal
30239
30246
  */
30240
30247
  static resolveCached(doc2, pos) {
30241
- for (let i2 = 0; i2 < resolveCache.length; i2++) {
30242
- let cached2 = resolveCache[i2];
30243
- if (cached2.pos == pos && cached2.doc == doc2)
30244
- return cached2;
30248
+ let cache = resolveCache.get(doc2);
30249
+ if (cache) {
30250
+ for (let i2 = 0; i2 < cache.elts.length; i2++) {
30251
+ let elt = cache.elts[i2];
30252
+ if (elt.pos == pos)
30253
+ return elt;
30254
+ }
30255
+ } else {
30256
+ resolveCache.set(doc2, cache = new ResolveCache());
30245
30257
  }
30246
- let result2 = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc2, pos);
30247
- resolveCachePos = (resolveCachePos + 1) % resolveCacheSize;
30258
+ let result2 = cache.elts[cache.i] = ResolvedPos.resolve(doc2, pos);
30259
+ cache.i = (cache.i + 1) % resolveCacheSize;
30248
30260
  return result2;
30249
30261
  }
30250
30262
  }
30251
- let resolveCache = [], resolveCachePos = 0, resolveCacheSize = 12;
30263
+ class ResolveCache {
30264
+ constructor() {
30265
+ this.elts = [];
30266
+ this.i = 0;
30267
+ }
30268
+ }
30269
+ const resolveCacheSize = 12, resolveCache = /* @__PURE__ */ new WeakMap();
30252
30270
  class NodeRange {
30253
30271
  /**
30254
30272
  Construct a node range. `$from` and `$to` should point into the
@@ -30634,13 +30652,17 @@ let Node$3 = class Node2 {
30634
30652
  }
30635
30653
  /**
30636
30654
  Check whether this node and its descendants conform to the
30637
- schema, and raise error when they do not.
30655
+ schema, and raise an exception when they do not.
30638
30656
  */
30639
30657
  check() {
30640
30658
  this.type.checkContent(this.content);
30659
+ this.type.checkAttrs(this.attrs);
30641
30660
  let copy2 = Mark$1.none;
30642
- for (let i2 = 0; i2 < this.marks.length; i2++)
30643
- copy2 = this.marks[i2].addToSet(copy2);
30661
+ for (let i2 = 0; i2 < this.marks.length; i2++) {
30662
+ let mark = this.marks[i2];
30663
+ mark.type.checkAttrs(mark.attrs);
30664
+ copy2 = mark.addToSet(copy2);
30665
+ }
30644
30666
  if (!Mark$1.sameSet(copy2, this.marks))
30645
30667
  throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m2) => m2.type.name)}`);
30646
30668
  this.content.forEach((node) => node.check());
@@ -30666,7 +30688,7 @@ let Node$3 = class Node2 {
30666
30688
  static fromJSON(schema, json) {
30667
30689
  if (!json)
30668
30690
  throw new RangeError("Invalid input for Node.fromJSON");
30669
- let marks = null;
30691
+ let marks = void 0;
30670
30692
  if (json.marks) {
30671
30693
  if (!Array.isArray(json.marks))
30672
30694
  throw new RangeError("Invalid mark data for Node.fromJSON");
@@ -30678,7 +30700,9 @@ let Node$3 = class Node2 {
30678
30700
  return schema.text(json.text, marks);
30679
30701
  }
30680
30702
  let content = Fragment.fromJSON(schema, json.content);
30681
- return schema.nodeType(json.type).create(json.attrs, content, marks);
30703
+ let node = schema.nodeType(json.type).create(json.attrs, content, marks);
30704
+ node.type.checkAttrs(node.attrs);
30705
+ return node;
30682
30706
  }
30683
30707
  };
30684
30708
  Node$3.prototype.text = void 0;
@@ -31160,6 +31184,16 @@ function computeAttrs(attrs, value) {
31160
31184
  }
31161
31185
  return built;
31162
31186
  }
31187
+ function checkAttrs(attrs, values3, type3, name) {
31188
+ for (let name2 in values3)
31189
+ if (!(name2 in attrs))
31190
+ throw new RangeError(`Unsupported attribute ${name2} for ${type3} of type ${name2}`);
31191
+ for (let name2 in attrs) {
31192
+ let attr = attrs[name2];
31193
+ if (attr.validate)
31194
+ attr.validate(values3[name2]);
31195
+ }
31196
+ }
31163
31197
  function initAttrs(attrs) {
31164
31198
  let result2 = /* @__PURE__ */ Object.create(null);
31165
31199
  if (attrs)
@@ -31289,7 +31323,7 @@ let NodeType$1 = class NodeType2 {
31289
31323
  }
31290
31324
  /**
31291
31325
  Returns true if the given fragment is valid content for this node
31292
- type with the given attributes.
31326
+ type.
31293
31327
  */
31294
31328
  validContent(content) {
31295
31329
  let result2 = this.contentMatch.matchFragment(content);
@@ -31310,6 +31344,12 @@ let NodeType$1 = class NodeType2 {
31310
31344
  throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
31311
31345
  }
31312
31346
  /**
31347
+ @internal
31348
+ */
31349
+ checkAttrs(attrs) {
31350
+ checkAttrs(this.attrs, attrs, "node", this.name);
31351
+ }
31352
+ /**
31313
31353
  Check whether the given mark type is allowed in this node.
31314
31354
  */
31315
31355
  allowsMarkType(markType) {
@@ -31359,10 +31399,19 @@ let NodeType$1 = class NodeType2 {
31359
31399
  return result2;
31360
31400
  }
31361
31401
  };
31402
+ function validateType(type3) {
31403
+ let types = type3.split("|");
31404
+ return (value) => {
31405
+ let name = value === null ? "null" : typeof value;
31406
+ if (types.indexOf(name) < 0)
31407
+ throw new RangeError(`Expected value of type ${types}, got ${name}`);
31408
+ };
31409
+ }
31362
31410
  class Attribute {
31363
31411
  constructor(options) {
31364
31412
  this.hasDefault = Object.prototype.hasOwnProperty.call(options, "default");
31365
31413
  this.default = options.default;
31414
+ this.validate = typeof options.validate == "string" ? validateType(options.validate) : options.validate;
31366
31415
  }
31367
31416
  get isRequired() {
31368
31417
  return !this.hasDefault;
@@ -31421,6 +31470,12 @@ class MarkType {
31421
31470
  return set2[i2];
31422
31471
  }
31423
31472
  /**
31473
+ @internal
31474
+ */
31475
+ checkAttrs(attrs) {
31476
+ checkAttrs(this.attrs, attrs, "mark", this.name);
31477
+ }
31478
+ /**
31424
31479
  Queries whether a given mark type is
31425
31480
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
31426
31481
  */
@@ -31433,6 +31488,7 @@ class Schema {
31433
31488
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
31434
31489
  */
31435
31490
  constructor(spec) {
31491
+ this.linebreakReplacement = null;
31436
31492
  this.cached = /* @__PURE__ */ Object.create(null);
31437
31493
  let instanceSpec = this.spec = {};
31438
31494
  for (let prop3 in spec)
@@ -31446,6 +31502,13 @@ class Schema {
31446
31502
  let type3 = this.nodes[prop3], contentExpr = type3.spec.content || "", markExpr = type3.spec.marks;
31447
31503
  type3.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));
31448
31504
  type3.inlineContent = type3.contentMatch.inlineContent;
31505
+ if (type3.spec.linebreakReplacement) {
31506
+ if (this.linebreakReplacement)
31507
+ throw new RangeError("Multiple linebreak nodes defined");
31508
+ if (!type3.isInline || !type3.isLeaf)
31509
+ throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
31510
+ this.linebreakReplacement = type3;
31511
+ }
31449
31512
  type3.markSet = markExpr == "_" ? null : markExpr ? gatherMarks(this, markExpr.split(" ")) : markExpr == "" || !type3.inlineContent ? [] : null;
31450
31513
  }
31451
31514
  for (let prop3 in this.marks) {
@@ -31530,6 +31593,12 @@ function gatherMarks(schema, marks) {
31530
31593
  }
31531
31594
  return found2;
31532
31595
  }
31596
+ function isTagRule(rule) {
31597
+ return rule.tag != null;
31598
+ }
31599
+ function isStyleRule(rule) {
31600
+ return rule.style != null;
31601
+ }
31533
31602
  class DOMParser {
31534
31603
  /**
31535
31604
  Create a parser that targets the given schema, using the given
@@ -31540,11 +31609,16 @@ class DOMParser {
31540
31609
  this.rules = rules;
31541
31610
  this.tags = [];
31542
31611
  this.styles = [];
31612
+ let matchedStyles = this.matchedStyles = [];
31543
31613
  rules.forEach((rule) => {
31544
- if (rule.tag)
31614
+ if (isTagRule(rule)) {
31545
31615
  this.tags.push(rule);
31546
- else if (rule.style)
31616
+ } else if (isStyleRule(rule)) {
31617
+ let prop3 = /[^=]*/.exec(rule.style)[0];
31618
+ if (matchedStyles.indexOf(prop3) < 0)
31619
+ matchedStyles.push(prop3);
31547
31620
  this.styles.push(rule);
31621
+ }
31548
31622
  });
31549
31623
  this.normalizeLists = !this.tags.some((r2) => {
31550
31624
  if (!/^(ul|ol)\b/.test(r2.tag) || !r2.node)
@@ -31804,10 +31878,10 @@ class ParseContext {
31804
31878
  this.addElement(dom);
31805
31879
  }
31806
31880
  withStyleRules(dom, f2) {
31807
- let style2 = dom.getAttribute("style");
31808
- if (!style2)
31881
+ let style2 = dom.style;
31882
+ if (!style2 || !style2.length)
31809
31883
  return f2();
31810
- let marks = this.readStyles(parseStyles(style2));
31884
+ let marks = this.readStyles(dom.style);
31811
31885
  if (!marks)
31812
31886
  return;
31813
31887
  let [addMarks, removeMarks] = marks, top2 = this.top;
@@ -31901,27 +31975,30 @@ class ParseContext {
31901
31975
  // had a rule with `ignore` set.
31902
31976
  readStyles(styles) {
31903
31977
  let add2 = Mark$1.none, remove2 = Mark$1.none;
31904
- for (let i2 = 0; i2 < styles.length; i2 += 2) {
31905
- for (let after = void 0; ; ) {
31906
- let rule = this.parser.matchStyle(styles[i2], styles[i2 + 1], this, after);
31907
- if (!rule)
31908
- break;
31909
- if (rule.ignore)
31910
- return null;
31911
- if (rule.clearMark) {
31912
- this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31913
- if (rule.clearMark(m2))
31914
- remove2 = m2.addToSet(remove2);
31915
- });
31916
- } else {
31917
- add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31918
- }
31919
- if (rule.consuming === false)
31920
- after = rule;
31921
- else
31922
- break;
31978
+ if (styles.length)
31979
+ for (let i2 = 0; i2 < this.parser.matchedStyles.length; i2++) {
31980
+ let name = this.parser.matchedStyles[i2], value = styles.getPropertyValue(name);
31981
+ if (value)
31982
+ for (let after = void 0; ; ) {
31983
+ let rule = this.parser.matchStyle(name, value, this, after);
31984
+ if (!rule)
31985
+ break;
31986
+ if (rule.ignore)
31987
+ return null;
31988
+ if (rule.clearMark) {
31989
+ this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31990
+ if (rule.clearMark(m2))
31991
+ remove2 = m2.addToSet(remove2);
31992
+ });
31993
+ } else {
31994
+ add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31995
+ }
31996
+ if (rule.consuming === false)
31997
+ after = rule;
31998
+ else
31999
+ break;
32000
+ }
31923
32001
  }
31924
- }
31925
32002
  return [add2, remove2];
31926
32003
  }
31927
32004
  // Look up a handler for the given node. If none are found, return
@@ -32190,12 +32267,6 @@ function normalizeList(dom) {
32190
32267
  function matches(dom, selector2) {
32191
32268
  return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector2);
32192
32269
  }
32193
- function parseStyles(style2) {
32194
- let re2 = /\s*([\w-]+)\s*:\s*([^;]+)/g, m2, result2 = [];
32195
- while (m2 = re2.exec(style2))
32196
- result2.push(m2[1], m2[2].trim());
32197
- return result2;
32198
- }
32199
32270
  function copy$2(obj) {
32200
32271
  let copy2 = {};
32201
32272
  for (let prop3 in obj)
@@ -32286,7 +32357,7 @@ class DOMSerializer {
32286
32357
  @internal
32287
32358
  */
32288
32359
  serializeNodeInner(node, options) {
32289
- let { dom, contentDOM } = DOMSerializer.renderSpec(doc$1(options), this.nodes[node.type.name](node));
32360
+ let { dom, contentDOM } = renderSpec(doc$1(options), this.nodes[node.type.name](node), null, node.attrs);
32290
32361
  if (contentDOM) {
32291
32362
  if (node.isLeaf)
32292
32363
  throw new RangeError("Content hole not allowed in a leaf node spec");
@@ -32317,7 +32388,7 @@ class DOMSerializer {
32317
32388
  */
32318
32389
  serializeMark(mark, inline, options = {}) {
32319
32390
  let toDOM = this.marks[mark.type.name];
32320
- return toDOM && DOMSerializer.renderSpec(doc$1(options), toDOM(mark, inline));
32391
+ return toDOM && renderSpec(doc$1(options), toDOM(mark, inline), null, mark.attrs);
32321
32392
  }
32322
32393
  /**
32323
32394
  Render an [output spec](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) to a DOM node. If
@@ -32325,48 +32396,7 @@ class DOMSerializer {
32325
32396
  node with the hole.
32326
32397
  */
32327
32398
  static renderSpec(doc2, structure, xmlNS = null) {
32328
- if (typeof structure == "string")
32329
- return { dom: doc2.createTextNode(structure) };
32330
- if (structure.nodeType != null)
32331
- return { dom: structure };
32332
- if (structure.dom && structure.dom.nodeType != null)
32333
- return structure;
32334
- let tagName = structure[0], space = tagName.indexOf(" ");
32335
- if (space > 0) {
32336
- xmlNS = tagName.slice(0, space);
32337
- tagName = tagName.slice(space + 1);
32338
- }
32339
- let contentDOM;
32340
- let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32341
- let attrs = structure[1], start2 = 1;
32342
- if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32343
- start2 = 2;
32344
- for (let name in attrs)
32345
- if (attrs[name] != null) {
32346
- let space2 = name.indexOf(" ");
32347
- if (space2 > 0)
32348
- dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32349
- else
32350
- dom.setAttribute(name, attrs[name]);
32351
- }
32352
- }
32353
- for (let i2 = start2; i2 < structure.length; i2++) {
32354
- let child = structure[i2];
32355
- if (child === 0) {
32356
- if (i2 < structure.length - 1 || i2 > start2)
32357
- throw new RangeError("Content hole must be the only child of its parent node");
32358
- return { dom, contentDOM: dom };
32359
- } else {
32360
- let { dom: inner, contentDOM: innerContent } = DOMSerializer.renderSpec(doc2, child, xmlNS);
32361
- dom.appendChild(inner);
32362
- if (innerContent) {
32363
- if (contentDOM)
32364
- throw new RangeError("Multiple content holes");
32365
- contentDOM = innerContent;
32366
- }
32367
- }
32368
- }
32369
- return { dom, contentDOM };
32399
+ return renderSpec(doc2, structure, xmlNS);
32370
32400
  }
32371
32401
  /**
32372
32402
  Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
@@ -32404,6 +32434,84 @@ function gatherToDOM(obj) {
32404
32434
  function doc$1(options) {
32405
32435
  return options.document || window.document;
32406
32436
  }
32437
+ const suspiciousAttributeCache = /* @__PURE__ */ new WeakMap();
32438
+ function suspiciousAttributes(attrs) {
32439
+ let value = suspiciousAttributeCache.get(attrs);
32440
+ if (value === void 0)
32441
+ suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));
32442
+ return value;
32443
+ }
32444
+ function suspiciousAttributesInner(attrs) {
32445
+ let result2 = null;
32446
+ function scan(value) {
32447
+ if (value && typeof value == "object") {
32448
+ if (Array.isArray(value)) {
32449
+ if (typeof value[0] == "string") {
32450
+ if (!result2)
32451
+ result2 = [];
32452
+ result2.push(value);
32453
+ } else {
32454
+ for (let i2 = 0; i2 < value.length; i2++)
32455
+ scan(value[i2]);
32456
+ }
32457
+ } else {
32458
+ for (let prop3 in value)
32459
+ scan(value[prop3]);
32460
+ }
32461
+ }
32462
+ }
32463
+ scan(attrs);
32464
+ return result2;
32465
+ }
32466
+ function renderSpec(doc2, structure, xmlNS, blockArraysIn) {
32467
+ if (typeof structure == "string")
32468
+ return { dom: doc2.createTextNode(structure) };
32469
+ if (structure.nodeType != null)
32470
+ return { dom: structure };
32471
+ if (structure.dom && structure.dom.nodeType != null)
32472
+ return structure;
32473
+ let tagName = structure[0], suspicious;
32474
+ if (typeof tagName != "string")
32475
+ throw new RangeError("Invalid array passed to renderSpec");
32476
+ if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1)
32477
+ throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
32478
+ let space = tagName.indexOf(" ");
32479
+ if (space > 0) {
32480
+ xmlNS = tagName.slice(0, space);
32481
+ tagName = tagName.slice(space + 1);
32482
+ }
32483
+ let contentDOM;
32484
+ let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32485
+ let attrs = structure[1], start2 = 1;
32486
+ if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32487
+ start2 = 2;
32488
+ for (let name in attrs)
32489
+ if (attrs[name] != null) {
32490
+ let space2 = name.indexOf(" ");
32491
+ if (space2 > 0)
32492
+ dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32493
+ else
32494
+ dom.setAttribute(name, attrs[name]);
32495
+ }
32496
+ }
32497
+ for (let i2 = start2; i2 < structure.length; i2++) {
32498
+ let child = structure[i2];
32499
+ if (child === 0) {
32500
+ if (i2 < structure.length - 1 || i2 > start2)
32501
+ throw new RangeError("Content hole must be the only child of its parent node");
32502
+ return { dom, contentDOM: dom };
32503
+ } else {
32504
+ let { dom: inner, contentDOM: innerContent } = renderSpec(doc2, child, xmlNS, blockArraysIn);
32505
+ dom.appendChild(inner);
32506
+ if (innerContent) {
32507
+ if (contentDOM)
32508
+ throw new RangeError("Multiple content holes");
32509
+ contentDOM = innerContent;
32510
+ }
32511
+ }
32512
+ }
32513
+ return { dom, contentDOM };
32514
+ }
32407
32515
  const lower16 = 65535;
32408
32516
  const factor16 = Math.pow(2, 16);
32409
32517
  function makeRecover(index2, offset2) {
@@ -33063,7 +33171,8 @@ class ReplaceAroundStep extends Step$1 {
33063
33171
  }
33064
33172
  map(mapping) {
33065
33173
  let from2 = mapping.mapResult(this.from, 1), to2 = mapping.mapResult(this.to, -1);
33066
- let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);
33174
+ let gapFrom = this.from == this.gapFrom ? from2.pos : mapping.map(this.gapFrom, -1);
33175
+ let gapTo = this.to == this.gapTo ? to2.pos : mapping.map(this.gapTo, 1);
33067
33176
  if (from2.deletedAcross && to2.deletedAcross || gapFrom < from2.pos || gapTo > to2.pos)
33068
33177
  return null;
33069
33178
  return new ReplaceAroundStep(from2.pos, to2.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
@@ -33176,7 +33285,7 @@ function removeMark(tr2, from2, to2, mark) {
33176
33285
  });
33177
33286
  matched.forEach((m2) => tr2.step(new RemoveMarkStep(m2.from, m2.to, m2.style)));
33178
33287
  }
33179
- function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch) {
33288
+ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch, clearNewlines = true) {
33180
33289
  let node = tr2.doc.nodeAt(pos);
33181
33290
  let replSteps = [], cur = pos + 1;
33182
33291
  for (let i2 = 0; i2 < node.childCount; i2++) {
@@ -33189,7 +33298,7 @@ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatc
33189
33298
  for (let j2 = 0; j2 < child.marks.length; j2++)
33190
33299
  if (!parentType.allowsMarkType(child.marks[j2].type))
33191
33300
  tr2.step(new RemoveMarkStep(cur, end2, child.marks[j2]));
33192
- if (child.isText && !parentType.spec.code) {
33301
+ if (clearNewlines && child.isText && parentType.whitespace != "pre") {
33193
33302
  let m2, newline = /\r?\n|\r/g, slice4;
33194
33303
  while (m2 = newline.exec(child.text)) {
33195
33304
  if (!slice4)
@@ -33298,14 +33407,45 @@ function setBlockType$1(tr2, from2, to2, type3, attrs) {
33298
33407
  let mapFrom = tr2.steps.length;
33299
33408
  tr2.doc.nodesBetween(from2, to2, (node, pos) => {
33300
33409
  if (node.isTextblock && !node.hasMarkup(type3, attrs) && canChangeType(tr2.doc, tr2.mapping.slice(mapFrom).map(pos), type3)) {
33301
- tr2.clearIncompatible(tr2.mapping.slice(mapFrom).map(pos, 1), type3);
33410
+ let convertNewlines = null;
33411
+ if (type3.schema.linebreakReplacement) {
33412
+ let pre = type3.whitespace == "pre", supportLinebreak = !!type3.contentMatch.matchType(type3.schema.linebreakReplacement);
33413
+ if (pre && !supportLinebreak)
33414
+ convertNewlines = false;
33415
+ else if (!pre && supportLinebreak)
33416
+ convertNewlines = true;
33417
+ }
33418
+ if (convertNewlines === false)
33419
+ replaceLinebreaks(tr2, node, pos, mapFrom);
33420
+ clearIncompatible(tr2, tr2.mapping.slice(mapFrom).map(pos, 1), type3, void 0, convertNewlines === null);
33302
33421
  let mapping = tr2.mapping.slice(mapFrom);
33303
33422
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
33304
33423
  tr2.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type3.create(attrs, null, node.marks)), 0, 0), 1, true));
33424
+ if (convertNewlines === true)
33425
+ replaceNewlines(tr2, node, pos, mapFrom);
33305
33426
  return false;
33306
33427
  }
33307
33428
  });
33308
33429
  }
33430
+ function replaceNewlines(tr2, node, pos, mapFrom) {
33431
+ node.forEach((child, offset2) => {
33432
+ if (child.isText) {
33433
+ let m2, newline = /\r?\n|\r/g;
33434
+ while (m2 = newline.exec(child.text)) {
33435
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2 + m2.index);
33436
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.linebreakReplacement.create());
33437
+ }
33438
+ }
33439
+ });
33440
+ }
33441
+ function replaceLinebreaks(tr2, node, pos, mapFrom) {
33442
+ node.forEach((child, offset2) => {
33443
+ if (child.type == child.type.schema.linebreakReplacement) {
33444
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2);
33445
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.text("\n"));
33446
+ }
33447
+ });
33448
+ }
33309
33449
  function canChangeType(doc2, pos, type3) {
33310
33450
  let $pos = doc2.resolve(pos), index2 = $pos.index();
33311
33451
  return $pos.parent.canReplaceWith(index2, index2 + 1, type3);
@@ -35071,6 +35211,9 @@ const textRange = function(node, from2, to2) {
35071
35211
  range2.setStart(node, from2 || 0);
35072
35212
  return range2;
35073
35213
  };
35214
+ const clearReusedRange = function() {
35215
+ reusedRange = null;
35216
+ };
35074
35217
  const isEquivalentPosition = function(node, off2, targetNode, targetOff) {
35075
35218
  return targetNode && (scanFor(node, off2, targetNode, targetOff, -1) || scanFor(node, off2, targetNode, targetOff, 1));
35076
35219
  };
@@ -35098,6 +35241,40 @@ function scanFor(node, off2, targetNode, targetOff, dir) {
35098
35241
  function nodeSize(node) {
35099
35242
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
35100
35243
  }
35244
+ function textNodeBefore$1(node, offset2) {
35245
+ for (; ; ) {
35246
+ if (node.nodeType == 3 && offset2)
35247
+ return node;
35248
+ if (node.nodeType == 1 && offset2 > 0) {
35249
+ if (node.contentEditable == "false")
35250
+ return null;
35251
+ node = node.childNodes[offset2 - 1];
35252
+ offset2 = nodeSize(node);
35253
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35254
+ offset2 = domIndex(node);
35255
+ node = node.parentNode;
35256
+ } else {
35257
+ return null;
35258
+ }
35259
+ }
35260
+ }
35261
+ function textNodeAfter$1(node, offset2) {
35262
+ for (; ; ) {
35263
+ if (node.nodeType == 3 && offset2 < node.nodeValue.length)
35264
+ return node;
35265
+ if (node.nodeType == 1 && offset2 < node.childNodes.length) {
35266
+ if (node.contentEditable == "false")
35267
+ return null;
35268
+ node = node.childNodes[offset2];
35269
+ offset2 = 0;
35270
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35271
+ offset2 = domIndex(node) + 1;
35272
+ node = node.parentNode;
35273
+ } else {
35274
+ return null;
35275
+ }
35276
+ }
35277
+ }
35101
35278
  function isOnEdge(node, offset2, parent) {
35102
35279
  for (let atStart = offset2 == 0, atEnd = offset2 == nodeSize(node); atStart || atEnd; ) {
35103
35280
  if (node == parent)
@@ -35169,6 +35346,14 @@ const android = /Android \d/.test(agent);
35169
35346
  const webkit = !!doc && "webkitFontSmoothing" in doc.documentElement.style;
35170
35347
  const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
35171
35348
  function windowRect(doc2) {
35349
+ let vp = doc2.defaultView && doc2.defaultView.visualViewport;
35350
+ if (vp)
35351
+ return {
35352
+ left: 0,
35353
+ right: vp.width,
35354
+ top: 0,
35355
+ bottom: vp.height
35356
+ };
35172
35357
  return {
35173
35358
  left: 0,
35174
35359
  right: doc2.documentElement.clientWidth,
@@ -35370,14 +35555,14 @@ function posFromCaret(view, node, offset2, coords) {
35370
35555
  let desc = view.docView.nearestDesc(cur, true);
35371
35556
  if (!desc)
35372
35557
  return null;
35373
- if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent && !sawBlock || !desc.contentDOM)) {
35558
+ if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM)) {
35374
35559
  let rect = desc.dom.getBoundingClientRect();
35375
- if (desc.node.isBlock && desc.parent && !sawBlock) {
35376
- sawBlock = true;
35377
- if (rect.left > coords.left || rect.top > coords.top)
35560
+ if (desc.node.isBlock && desc.parent) {
35561
+ if (!sawBlock && rect.left > coords.left || rect.top > coords.top)
35378
35562
  outsideBlock = desc.posBefore;
35379
- else if (rect.right < coords.left || rect.bottom < coords.top)
35563
+ else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top)
35380
35564
  outsideBlock = desc.posAfter;
35565
+ sawBlock = true;
35381
35566
  }
35382
35567
  if (!desc.contentDOM && outsideBlock < 0 && !desc.node.isText) {
35383
35568
  let before = desc.node.isBlock ? coords.top < (rect.top + rect.bottom) / 2 : coords.left < (rect.left + rect.right) / 2;
@@ -35992,6 +36177,9 @@ class ViewDesc {
35992
36177
  get ignoreForCoords() {
35993
36178
  return false;
35994
36179
  }
36180
+ isText(text) {
36181
+ return false;
36182
+ }
35995
36183
  }
35996
36184
  class WidgetViewDesc extends ViewDesc {
35997
36185
  constructor(parent, widget, view, pos) {
@@ -36230,8 +36418,7 @@ class NodeViewDesc extends ViewDesc {
36230
36418
  let { from: from2, to: to2 } = view.state.selection;
36231
36419
  if (!(view.state.selection instanceof TextSelection) || from2 < pos || to2 > pos + this.node.content.size)
36232
36420
  return null;
36233
- let sel = view.domSelectionRange();
36234
- let textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);
36421
+ let textNode = view.input.compositionNode;
36235
36422
  if (!textNode || !this.dom.contains(textNode.parentNode))
36236
36423
  return null;
36237
36424
  if (this.node.inlineContent) {
@@ -36297,10 +36484,11 @@ class NodeViewDesc extends ViewDesc {
36297
36484
  }
36298
36485
  // Remove selected node marking from this node.
36299
36486
  deselectNode() {
36300
- if (this.nodeDOM.nodeType == 1)
36487
+ if (this.nodeDOM.nodeType == 1) {
36301
36488
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
36302
- if (this.contentDOM || !this.node.type.spec.draggable)
36303
- this.dom.removeAttribute("draggable");
36489
+ if (this.contentDOM || !this.node.type.spec.draggable)
36490
+ this.dom.removeAttribute("draggable");
36491
+ }
36304
36492
  }
36305
36493
  get domAtom() {
36306
36494
  return this.node.isAtom;
@@ -36366,6 +36554,9 @@ class TextViewDesc extends NodeViewDesc {
36366
36554
  get domAtom() {
36367
36555
  return false;
36368
36556
  }
36557
+ isText(text) {
36558
+ return this.node.text == text;
36559
+ }
36369
36560
  }
36370
36561
  class TrailingHackViewDesc extends ViewDesc {
36371
36562
  parseRule() {
@@ -36881,23 +37072,6 @@ function iosHacks(dom) {
36881
37072
  dom.style.cssText = oldCSS;
36882
37073
  }
36883
37074
  }
36884
- function nearbyTextNode(node, offset2) {
36885
- for (; ; ) {
36886
- if (node.nodeType == 3)
36887
- return node;
36888
- if (node.nodeType == 1 && offset2 > 0) {
36889
- if (node.childNodes.length > offset2 && node.childNodes[offset2].nodeType == 3)
36890
- return node.childNodes[offset2];
36891
- node = node.childNodes[offset2 - 1];
36892
- offset2 = nodeSize(node);
36893
- } else if (node.nodeType == 1 && offset2 < node.childNodes.length) {
36894
- node = node.childNodes[offset2];
36895
- offset2 = 0;
36896
- } else {
36897
- return null;
36898
- }
36899
- }
36900
- }
36901
37075
  function findTextInFragment(frag, text, from2, to2) {
36902
37076
  for (let i2 = 0, pos = 0; i2 < frag.childCount && pos <= to2; ) {
36903
37077
  let child = frag.child(i2++), childStart = pos;
@@ -37472,7 +37646,7 @@ function serializeForClipboard(view, slice4) {
37472
37646
  if (firstChild && firstChild.nodeType == 1)
37473
37647
  firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
37474
37648
  let text = view.someProp("clipboardTextSerializer", (f2) => f2(slice4, view)) || slice4.content.textBetween(0, slice4.content.size, "\n\n");
37475
- return { dom: wrap2, text };
37649
+ return { dom: wrap2, text, slice: slice4 };
37476
37650
  }
37477
37651
  function parseFromClipboard(view, text, html, plainText, $context) {
37478
37652
  let inCode = $context.parent.type.spec.code;
@@ -37692,6 +37866,7 @@ class InputState {
37692
37866
  this.lastTouch = 0;
37693
37867
  this.lastAndroidDelete = 0;
37694
37868
  this.composing = false;
37869
+ this.compositionNode = null;
37695
37870
  this.composingTimeout = -1;
37696
37871
  this.compositionNodes = [];
37697
37872
  this.compositionEndedAt = -2e8;
@@ -37819,8 +37994,7 @@ function updateSelection(view, selection, origin2) {
37819
37994
  if (!view.focused)
37820
37995
  view.focus();
37821
37996
  let tr2 = view.state.tr.setSelection(selection);
37822
- if (origin2 == "pointer")
37823
- tr2.setMeta("pointer", true);
37997
+ tr2.setMeta("pointer", true);
37824
37998
  view.dispatch(tr2);
37825
37999
  }
37826
38000
  function selectClickedLeaf(view, inside) {
@@ -37828,7 +38002,7 @@ function selectClickedLeaf(view, inside) {
37828
38002
  return false;
37829
38003
  let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
37830
38004
  if (node && node.isAtom && NodeSelection.isSelectable(node)) {
37831
- updateSelection(view, new NodeSelection($pos), "pointer");
38005
+ updateSelection(view, new NodeSelection($pos));
37832
38006
  return true;
37833
38007
  }
37834
38008
  return false;
@@ -37851,7 +38025,7 @@ function selectClickedNode(view, inside) {
37851
38025
  }
37852
38026
  }
37853
38027
  if (selectAt != null) {
37854
- updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
38028
+ updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
37855
38029
  return true;
37856
38030
  } else {
37857
38031
  return false;
@@ -37872,7 +38046,7 @@ function defaultTripleClick(view, inside, event) {
37872
38046
  let doc2 = view.state.doc;
37873
38047
  if (inside == -1) {
37874
38048
  if (doc2.inlineContent) {
37875
- updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size), "pointer");
38049
+ updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size));
37876
38050
  return true;
37877
38051
  }
37878
38052
  return false;
@@ -37882,9 +38056,9 @@ function defaultTripleClick(view, inside, event) {
37882
38056
  let node = i2 > $pos.depth ? $pos.nodeAfter : $pos.node(i2);
37883
38057
  let nodePos = $pos.before(i2);
37884
38058
  if (node.inlineContent)
37885
- updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size), "pointer");
38059
+ updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size));
37886
38060
  else if (NodeSelection.isSelectable(node))
37887
- updateSelection(view, NodeSelection.create(doc2, nodePos), "pointer");
38061
+ updateSelection(view, NodeSelection.create(doc2, nodePos));
37888
38062
  else
37889
38063
  continue;
37890
38064
  return true;
@@ -37941,7 +38115,7 @@ class MouseDown {
37941
38115
  }
37942
38116
  const target = flushed ? null : event.target;
37943
38117
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
37944
- this.target = targetDesc ? targetDesc.dom : null;
38118
+ this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
37945
38119
  let { selection } = view.state;
37946
38120
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
37947
38121
  this.mightDrag = {
@@ -38001,7 +38175,7 @@ class MouseDown {
38001
38175
  // thus doesn't get a reaction from ProseMirror. This
38002
38176
  // works around that.
38003
38177
  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)) {
38004
- updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)), "pointer");
38178
+ updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
38005
38179
  event.preventDefault();
38006
38180
  } else {
38007
38181
  setSelectionOrigin(this.view, "pointer");
@@ -38073,6 +38247,7 @@ editHandlers.compositionend = (view, event) => {
38073
38247
  view.input.composing = false;
38074
38248
  view.input.compositionEndedAt = event.timeStamp;
38075
38249
  view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
38250
+ view.input.compositionNode = null;
38076
38251
  if (view.input.compositionPendingChanges)
38077
38252
  Promise.resolve().then(() => view.domObserver.flush());
38078
38253
  view.input.compositionID++;
@@ -38092,6 +38267,26 @@ function clearComposition(view) {
38092
38267
  while (view.input.compositionNodes.length > 0)
38093
38268
  view.input.compositionNodes.pop().markParentsDirty();
38094
38269
  }
38270
+ function findCompositionNode(view) {
38271
+ let sel = view.domSelectionRange();
38272
+ if (!sel.focusNode)
38273
+ return null;
38274
+ let textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
38275
+ let textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
38276
+ if (textBefore && textAfter && textBefore != textAfter) {
38277
+ let descAfter = textAfter.pmViewDesc, lastChanged = view.domObserver.lastChangedTextNode;
38278
+ if (textBefore == lastChanged || textAfter == lastChanged)
38279
+ return lastChanged;
38280
+ if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
38281
+ return textAfter;
38282
+ } else if (view.input.compositionNode == textAfter) {
38283
+ let descBefore = textBefore.pmViewDesc;
38284
+ if (!(!descBefore || !descBefore.isText(textBefore.nodeValue)))
38285
+ return textAfter;
38286
+ }
38287
+ }
38288
+ return textBefore || textAfter;
38289
+ }
38095
38290
  function timestampFromCustomEvent() {
38096
38291
  let event = document.createEvent("Event");
38097
38292
  event.initEvent("event", true, true);
@@ -38226,7 +38421,8 @@ handlers.dragstart = (view, _event) => {
38226
38421
  if (desc && desc.node.type.spec.draggable && desc != view.docView)
38227
38422
  node = NodeSelection.create(view.state.doc, desc.posBefore);
38228
38423
  }
38229
- let slice4 = (node || view.state.selection).content(), { dom, text } = serializeForClipboard(view, slice4);
38424
+ let draggedSlice = (node || view.state.selection).content();
38425
+ let { dom, text, slice: slice4 } = serializeForClipboard(view, draggedSlice);
38230
38426
  event.dataTransfer.clearData();
38231
38427
  event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
38232
38428
  event.dataTransfer.effectAllowed = "copyMove";
@@ -38646,9 +38842,6 @@ class DecorationSet {
38646
38842
  return this;
38647
38843
  return local.length || children2.length ? new DecorationSet(local, children2) : empty$1;
38648
38844
  }
38649
- /**
38650
- @internal
38651
- */
38652
38845
  forChild(offset2, node) {
38653
38846
  if (this == empty$1)
38654
38847
  return this;
@@ -39002,6 +39195,7 @@ class DOMObserver {
39002
39195
  this.currentSelection = new SelectionState();
39003
39196
  this.onCharData = null;
39004
39197
  this.suppressingSelectionUpdates = false;
39198
+ this.lastChangedTextNode = null;
39005
39199
  this.observer = window.MutationObserver && new window.MutationObserver((mutations) => {
39006
39200
  for (let i2 = 0; i2 < mutations.length; i2++)
39007
39201
  this.queue.push(mutations[i2]);
@@ -39127,14 +39321,21 @@ class DOMObserver {
39127
39321
  }
39128
39322
  }
39129
39323
  }
39130
- if (gecko && added.length > 1) {
39324
+ if (gecko && added.length) {
39131
39325
  let brs = added.filter((n2) => n2.nodeName == "BR");
39132
39326
  if (brs.length == 2) {
39133
- let a2 = brs[0], b2 = brs[1];
39327
+ let [a2, b2] = brs;
39134
39328
  if (a2.parentNode && a2.parentNode.parentNode == b2.parentNode)
39135
39329
  b2.remove();
39136
39330
  else
39137
39331
  a2.remove();
39332
+ } else {
39333
+ let { focusNode } = this.currentSelection;
39334
+ for (let br2 of brs) {
39335
+ let parent = br2.parentNode;
39336
+ if (parent && parent.nodeName == "LI" && (!focusNode || blockParent(view, focusNode) != parent))
39337
+ br2.remove();
39338
+ }
39138
39339
  }
39139
39340
  }
39140
39341
  let readSel = null;
@@ -39166,8 +39367,12 @@ class DOMObserver {
39166
39367
  if (!desc || desc.ignoreMutation(mut))
39167
39368
  return null;
39168
39369
  if (mut.type == "childList") {
39169
- for (let i2 = 0; i2 < mut.addedNodes.length; i2++)
39170
- added.push(mut.addedNodes[i2]);
39370
+ for (let i2 = 0; i2 < mut.addedNodes.length; i2++) {
39371
+ let node = mut.addedNodes[i2];
39372
+ added.push(node);
39373
+ if (node.nodeType == 3)
39374
+ this.lastChangedTextNode = node;
39375
+ }
39171
39376
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
39172
39377
  return { from: desc.posBefore, to: desc.posAfter };
39173
39378
  let prev = mut.previousSibling, next = mut.nextSibling;
@@ -39188,6 +39393,7 @@ class DOMObserver {
39188
39393
  } else if (mut.type == "attributes") {
39189
39394
  return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border };
39190
39395
  } else {
39396
+ this.lastChangedTextNode = mut.target;
39191
39397
  return {
39192
39398
  from: desc.posAtStart,
39193
39399
  to: desc.posAtEnd,
@@ -39214,7 +39420,20 @@ function checkCSS(view) {
39214
39420
  cssCheckWarned = true;
39215
39421
  }
39216
39422
  }
39217
- function safariShadowSelectionRange(view) {
39423
+ function rangeToSelectionRange(view, range2) {
39424
+ let anchorNode = range2.startContainer, anchorOffset = range2.startOffset;
39425
+ let focusNode = range2.endContainer, focusOffset = range2.endOffset;
39426
+ let currentAnchor = view.domAtPos(view.state.selection.anchor);
39427
+ if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39428
+ [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39429
+ return { anchorNode, anchorOffset, focusNode, focusOffset };
39430
+ }
39431
+ function safariShadowSelectionRange(view, selection) {
39432
+ if (selection.getComposedRanges) {
39433
+ let range2 = selection.getComposedRanges(view.root)[0];
39434
+ if (range2)
39435
+ return rangeToSelectionRange(view, range2);
39436
+ }
39218
39437
  let found2;
39219
39438
  function read2(event) {
39220
39439
  event.preventDefault();
@@ -39224,12 +39443,15 @@ function safariShadowSelectionRange(view) {
39224
39443
  view.dom.addEventListener("beforeinput", read2, true);
39225
39444
  document.execCommand("indent");
39226
39445
  view.dom.removeEventListener("beforeinput", read2, true);
39227
- let anchorNode = found2.startContainer, anchorOffset = found2.startOffset;
39228
- let focusNode = found2.endContainer, focusOffset = found2.endOffset;
39229
- let currentAnchor = view.domAtPos(view.state.selection.anchor);
39230
- if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39231
- [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39232
- return { anchorNode, anchorOffset, focusNode, focusOffset };
39446
+ return found2 ? rangeToSelectionRange(view, found2) : null;
39447
+ }
39448
+ function blockParent(view, node) {
39449
+ for (let p2 = node.parentNode; p2 && p2 != view.dom; p2 = p2.parentNode) {
39450
+ let desc = view.docView.nearestDesc(p2, true);
39451
+ if (desc && desc.node.isBlock)
39452
+ return p2;
39453
+ }
39454
+ return null;
39233
39455
  }
39234
39456
  function parseBetween(view, from_, to_) {
39235
39457
  let { node: parent, fromOffset, toOffset, from: from2, to: to2 } = view.docView.parseRange(from_, to_);
@@ -39349,10 +39571,6 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39349
39571
  return;
39350
39572
  }
39351
39573
  }
39352
- if (chrome && view.cursorWrapper && parse2.sel && parse2.sel.anchor == view.cursorWrapper.deco.from && parse2.sel.head == parse2.sel.anchor) {
39353
- let size2 = change.endB - change.start;
39354
- parse2.sel = { anchor: parse2.sel.anchor + size2, head: parse2.sel.anchor + size2 };
39355
- }
39356
39574
  view.input.domChangeCount++;
39357
39575
  if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
39358
39576
  if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse2.from) {
@@ -39376,7 +39594,7 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39376
39594
  view.input.lastIOSEnter = 0;
39377
39595
  return;
39378
39596
  }
39379
- if (view.state.selection.anchor > change.start && looksLikeJoin(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39597
+ if (view.state.selection.anchor > change.start && looksLikeBackspace(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39380
39598
  if (android && chrome)
39381
39599
  view.domObserver.suppressSelectionUpdates();
39382
39600
  return;
@@ -39460,12 +39678,18 @@ function isMarkChange(cur, prev) {
39460
39678
  if (Fragment.from(updated).eq(cur))
39461
39679
  return { mark, type: type3 };
39462
39680
  }
39463
- function looksLikeJoin(old, start2, end2, $newStart, $newEnd) {
39464
- if (!$newStart.parent.isTextblock || // The content must have shrunk
39465
- end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39466
- skipClosingAndOpening($newStart, true, false) < $newEnd.pos)
39681
+ function looksLikeBackspace(old, start2, end2, $newStart, $newEnd) {
39682
+ if (
39683
+ // The content must have shrunk
39684
+ end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39685
+ skipClosingAndOpening($newStart, true, false) < $newEnd.pos
39686
+ )
39467
39687
  return false;
39468
39688
  let $start = old.resolve(start2);
39689
+ if (!$newStart.parent.isTextblock) {
39690
+ let after = $start.nodeAfter;
39691
+ return after != null && end2 == start2 + after.nodeSize;
39692
+ }
39469
39693
  if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock)
39470
39694
  return false;
39471
39695
  let $next = old.resolve(skipClosingAndOpening($start, true, true));
@@ -39654,8 +39878,10 @@ class EditorView {
39654
39878
  let forceSelUpdate = updateDoc && (ie$1 || chrome) && !this.composing && !prev.selection.empty && !state2.selection.empty && selectionContextChanged(prev.selection, state2.selection);
39655
39879
  if (updateDoc) {
39656
39880
  let chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;
39881
+ if (this.composing)
39882
+ this.input.compositionNode = findCompositionNode(this);
39657
39883
  if (redraw || !this.docView.update(state2.doc, outerDeco, innerDeco, this)) {
39658
- this.docView.updateOuterDeco([]);
39884
+ this.docView.updateOuterDeco(outerDeco);
39659
39885
  this.docView.destroy();
39660
39886
  this.docView = docViewDesc(state2.doc, outerDeco, innerDeco, this.dom, this);
39661
39887
  }
@@ -39914,6 +40140,7 @@ class EditorView {
39914
40140
  }
39915
40141
  this.docView.destroy();
39916
40142
  this.docView = null;
40143
+ clearReusedRange();
39917
40144
  }
39918
40145
  /**
39919
40146
  This is true when the view has been
@@ -39949,7 +40176,8 @@ class EditorView {
39949
40176
  @internal
39950
40177
  */
39951
40178
  domSelectionRange() {
39952
- return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom ? safariShadowSelectionRange(this) : this.domSelection();
40179
+ let sel = this.domSelection();
40180
+ return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;
39953
40181
  }
39954
40182
  /**
39955
40183
  @internal
@@ -40940,7 +41168,8 @@ function getAttributesFromExtensions(extensions) {
40940
41168
  const context = {
40941
41169
  name: extension.name,
40942
41170
  options: extension.options,
40943
- storage: extension.storage
41171
+ storage: extension.storage,
41172
+ extensions: nodeAndMarkExtensions
40944
41173
  };
40945
41174
  const addGlobalAttributes = getExtensionField(extension, "addGlobalAttributes", context);
40946
41175
  if (!addGlobalAttributes) {
@@ -41066,7 +41295,7 @@ function fromString(value) {
41066
41295
  return value;
41067
41296
  }
41068
41297
  function injectExtensionAttributesToParseRule(parseRule, extensionAttributes) {
41069
- if (parseRule.style) {
41298
+ if ("style" in parseRule) {
41070
41299
  return parseRule;
41071
41300
  }
41072
41301
  return {
@@ -41131,6 +41360,7 @@ function getSchemaByResolvedExtensions(extensions, editor) {
41131
41360
  selectable: callOrReturn(getExtensionField(extension, "selectable", context)),
41132
41361
  draggable: callOrReturn(getExtensionField(extension, "draggable", context)),
41133
41362
  code: callOrReturn(getExtensionField(extension, "code", context)),
41363
+ whitespace: callOrReturn(getExtensionField(extension, "whitespace", context)),
41134
41364
  defining: callOrReturn(getExtensionField(extension, "defining", context)),
41135
41365
  isolating: callOrReturn(getExtensionField(extension, "isolating", context)),
41136
41366
  attrs: Object.fromEntries(extensionAttributes.map((extensionAttribute) => {
@@ -41686,7 +41916,7 @@ class ExtensionManager {
41686
41916
  const plugins2 = [];
41687
41917
  const addKeyboardShortcuts = getExtensionField(extension, "addKeyboardShortcuts", context);
41688
41918
  let defaultBindings = {};
41689
- if (extension.type === "mark" && extension.config.exitable) {
41919
+ if (extension.type === "mark" && getExtensionField(extension, "exitable", context)) {
41690
41920
  defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension });
41691
41921
  }
41692
41922
  if (addKeyboardShortcuts) {
@@ -41834,14 +42064,10 @@ function mergeDeep(target, source) {
41834
42064
  const output = { ...target };
41835
42065
  if (isPlainObject(target) && isPlainObject(source)) {
41836
42066
  Object.keys(source).forEach((key) => {
41837
- if (isPlainObject(source[key])) {
41838
- if (!(key in target)) {
41839
- Object.assign(output, { [key]: source[key] });
41840
- } else {
41841
- output[key] = mergeDeep(target[key], source[key]);
41842
- }
42067
+ if (isPlainObject(source[key]) && isPlainObject(target[key])) {
42068
+ output[key] = mergeDeep(target[key], source[key]);
41843
42069
  } else {
41844
- Object.assign(output, { [key]: source[key] });
42070
+ output[key] = source[key];
41845
42071
  }
41846
42072
  });
41847
42073
  }
@@ -41880,13 +42106,14 @@ class Extension {
41880
42106
  return new Extension(config);
41881
42107
  }
41882
42108
  configure(options = {}) {
41883
- const extension = this.extend();
42109
+ const extension = this.extend({
42110
+ ...this.config,
42111
+ addOptions: () => {
42112
+ return mergeDeep(this.options, options);
42113
+ }
42114
+ });
42115
+ extension.name = this.name;
41884
42116
  extension.parent = this.parent;
41885
- extension.options = mergeDeep(this.options, options);
41886
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
41887
- name: extension.name,
41888
- options: extension.options
41889
- }));
41890
42117
  return extension;
41891
42118
  }
41892
42119
  extend(extendedConfig = {}) {
@@ -41894,7 +42121,7 @@ class Extension {
41894
42121
  extension.parent = this;
41895
42122
  this.child = extension;
41896
42123
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
41897
- if (extendedConfig.defaultOptions) {
42124
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
41898
42125
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
41899
42126
  }
41900
42127
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -42278,13 +42505,47 @@ function createNodeFromContent(content, schema, options) {
42278
42505
  }
42279
42506
  return schema.nodeFromJSON(content);
42280
42507
  } catch (error) {
42508
+ if (options.errorOnInvalidContent) {
42509
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: error });
42510
+ }
42281
42511
  console.warn("[tiptap warn]: Invalid content.", "Passed value:", content, "Error:", error);
42282
42512
  return createNodeFromContent("", schema, options);
42283
42513
  }
42284
42514
  }
42285
42515
  if (isTextContent) {
42286
- const parser = DOMParser.fromSchema(schema);
42287
- return options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42516
+ let schemaToUse = schema;
42517
+ let hasInvalidContent = false;
42518
+ let invalidContent = "";
42519
+ if (options.errorOnInvalidContent) {
42520
+ schemaToUse = new Schema({
42521
+ topNode: schema.spec.topNode,
42522
+ marks: schema.spec.marks,
42523
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
42524
+ // 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
42525
+ nodes: schema.spec.nodes.append({
42526
+ __tiptap__private__unknown__catch__all__node: {
42527
+ content: "inline*",
42528
+ group: "block",
42529
+ parseDOM: [
42530
+ {
42531
+ tag: "*",
42532
+ getAttrs: (e) => {
42533
+ hasInvalidContent = true;
42534
+ invalidContent = typeof e === "string" ? e : e.outerHTML;
42535
+ return null;
42536
+ }
42537
+ }
42538
+ ]
42539
+ }
42540
+ })
42541
+ });
42542
+ }
42543
+ const parser = DOMParser.fromSchema(schemaToUse);
42544
+ const response = options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42545
+ if (options.errorOnInvalidContent && hasInvalidContent) {
42546
+ throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${invalidContent}`) });
42547
+ }
42548
+ return response;
42288
42549
  }
42289
42550
  return createNodeFromContent("", schema, options);
42290
42551
  }
@@ -42307,9 +42568,10 @@ function selectionToInsertionEnd(tr2, startLen, bias) {
42307
42568
  tr2.setSelection(Selection$1.near(tr2.doc.resolve(end2), bias));
42308
42569
  }
42309
42570
  const isFragment = (nodeOrFragment) => {
42310
- return nodeOrFragment.toString().startsWith("<");
42571
+ return !("type" in nodeOrFragment);
42311
42572
  };
42312
42573
  const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, editor }) => {
42574
+ var _a2;
42313
42575
  if (dispatch) {
42314
42576
  options = {
42315
42577
  parseOptions: {},
@@ -42318,14 +42580,17 @@ const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, edit
42318
42580
  applyPasteRules: false,
42319
42581
  ...options
42320
42582
  };
42321
- const content = createNodeFromContent(value, editor.schema, {
42322
- parseOptions: {
42323
- preserveWhitespace: "full",
42324
- ...options.parseOptions
42325
- }
42326
- });
42327
- if (content.toString() === "<>") {
42328
- return true;
42583
+ let content;
42584
+ try {
42585
+ content = createNodeFromContent(value, editor.schema, {
42586
+ parseOptions: {
42587
+ preserveWhitespace: "full",
42588
+ ...options.parseOptions
42589
+ },
42590
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42591
+ });
42592
+ } catch (e) {
42593
+ return false;
42329
42594
  }
42330
42595
  let { from: from2, to: to2 } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
42331
42596
  let isOnlyTextContent = true;
@@ -42382,7 +42647,7 @@ const joinBackward = () => ({ state: state2, dispatch }) => {
42382
42647
  const joinForward = () => ({ state: state2, dispatch }) => {
42383
42648
  return joinForward$1(state2, dispatch);
42384
42649
  };
42385
- const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42650
+ const joinItemBackward = () => ({ state: state2, dispatch, tr: tr2 }) => {
42386
42651
  try {
42387
42652
  const point2 = joinPoint(state2.doc, state2.selection.$from.pos, -1);
42388
42653
  if (point2 === null || point2 === void 0) {
@@ -42393,7 +42658,7 @@ const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42393
42658
  dispatch(tr2);
42394
42659
  }
42395
42660
  return true;
42396
- } catch {
42661
+ } catch (e) {
42397
42662
  return false;
42398
42663
  }
42399
42664
  };
@@ -42611,16 +42876,32 @@ const selectTextblockEnd = () => ({ state: state2, dispatch }) => {
42611
42876
  const selectTextblockStart = () => ({ state: state2, dispatch }) => {
42612
42877
  return selectTextblockStart$1(state2, dispatch);
42613
42878
  };
42614
- function createDocument(content, schema, parseOptions = {}) {
42615
- return createNodeFromContent(content, schema, { slice: false, parseOptions });
42879
+ function createDocument(content, schema, parseOptions = {}, options = {}) {
42880
+ return createNodeFromContent(content, schema, {
42881
+ slice: false,
42882
+ parseOptions,
42883
+ errorOnInvalidContent: options.errorOnInvalidContent
42884
+ });
42616
42885
  }
42617
- const setContent$1 = (content, emitUpdate = false, parseOptions = {}) => ({ tr: tr2, editor, dispatch }) => {
42886
+ const setContent$1 = (content, emitUpdate = false, parseOptions = {}, options = {}) => ({ editor, tr: tr2, dispatch, commands: commands2 }) => {
42887
+ var _a2, _b;
42618
42888
  const { doc: doc2 } = tr2;
42619
- const document2 = createDocument(content, editor.schema, parseOptions);
42889
+ if (parseOptions.preserveWhitespace !== "full") {
42890
+ const document2 = createDocument(content, editor.schema, parseOptions, {
42891
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42892
+ });
42893
+ if (dispatch) {
42894
+ tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42895
+ }
42896
+ return true;
42897
+ }
42620
42898
  if (dispatch) {
42621
- tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42899
+ tr2.setMeta("preventUpdate", !emitUpdate);
42622
42900
  }
42623
- return true;
42901
+ return commands2.insertContentAt({ from: 0, to: doc2.content.size }, content, {
42902
+ parseOptions,
42903
+ errorOnInvalidContent: (_b = options.errorOnInvalidContent) !== null && _b !== void 0 ? _b : editor.options.enableContentCheck
42904
+ });
42624
42905
  };
42625
42906
  function getMarkAttributes(state2, typeOrName) {
42626
42907
  const type3 = getMarkType(typeOrName, state2.schema);
@@ -42823,10 +43104,11 @@ function isList(name, extensions) {
42823
43104
  return group.split(" ").includes("list");
42824
43105
  }
42825
43106
  function isNodeEmpty(node) {
42826
- var _a2;
42827
- const defaultContent = (_a2 = node.type.createAndFill()) === null || _a2 === void 0 ? void 0 : _a2.toJSON();
42828
- const content = node.toJSON();
42829
- return JSON.stringify(defaultContent) === JSON.stringify(content);
43107
+ const defaultContent = node.type.createAndFill();
43108
+ if (!defaultContent) {
43109
+ return false;
43110
+ }
43111
+ return node.eq(defaultContent);
42830
43112
  }
42831
43113
  function isNodeSelection(value) {
42832
43114
  return value instanceof NodeSelection;
@@ -43341,14 +43623,14 @@ var commands = /* @__PURE__ */ Object.freeze({
43341
43623
  forEach,
43342
43624
  insertContent,
43343
43625
  insertContentAt,
43344
- joinUp,
43345
- joinDown,
43346
43626
  joinBackward,
43627
+ joinDown,
43347
43628
  joinForward,
43348
43629
  joinItemBackward,
43349
43630
  joinItemForward,
43350
43631
  joinTextblockBackward,
43351
43632
  joinTextblockForward,
43633
+ joinUp,
43352
43634
  keyboardShortcut,
43353
43635
  lift,
43354
43636
  liftEmptyBlock,
@@ -43545,13 +43827,16 @@ const Tabindex = Extension.create({
43545
43827
  new Plugin({
43546
43828
  key: new PluginKey("tabindex"),
43547
43829
  props: {
43548
- attributes: this.editor.isEditable ? { tabindex: "0" } : {}
43830
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
43549
43831
  }
43550
43832
  })
43551
43833
  ];
43552
43834
  }
43553
43835
  });
43554
43836
  class NodePos {
43837
+ get name() {
43838
+ return this.node.type.name;
43839
+ }
43555
43840
  constructor(pos, editor, isBlock = false, node = null) {
43556
43841
  this.currentNode = null;
43557
43842
  this.actualDepth = null;
@@ -43560,9 +43845,6 @@ class NodePos {
43560
43845
  this.editor = editor;
43561
43846
  this.currentNode = node;
43562
43847
  }
43563
- get name() {
43564
- return this.node.type.name;
43565
- }
43566
43848
  get node() {
43567
43849
  return this.currentNode || this.resolvedPos.node();
43568
43850
  }
@@ -43794,7 +44076,7 @@ img.ProseMirror-separator {
43794
44076
  opacity: 0
43795
44077
  }`;
43796
44078
  function createStyleTag(style2, nonce, suffix) {
43797
- const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ""}]`);
44079
+ const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${""}]`);
43798
44080
  if (tiptapStyleTag !== null) {
43799
44081
  return tiptapStyleTag;
43800
44082
  }
@@ -43802,7 +44084,7 @@ function createStyleTag(style2, nonce, suffix) {
43802
44084
  if (nonce) {
43803
44085
  styleNode.setAttribute("nonce", nonce);
43804
44086
  }
43805
- styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ""}`, "");
44087
+ styleNode.setAttribute(`data-tiptap-style${""}`, "");
43806
44088
  styleNode.innerHTML = style2;
43807
44089
  document.getElementsByTagName("head")[0].appendChild(styleNode);
43808
44090
  return styleNode;
@@ -43826,6 +44108,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43826
44108
  enableInputRules: true,
43827
44109
  enablePasteRules: true,
43828
44110
  enableCoreExtensions: true,
44111
+ enableContentCheck: false,
43829
44112
  onBeforeCreate: () => null,
43830
44113
  onCreate: () => null,
43831
44114
  onUpdate: () => null,
@@ -43833,7 +44116,10 @@ let Editor$1 = class Editor2 extends EventEmitter {
43833
44116
  onTransaction: () => null,
43834
44117
  onFocus: () => null,
43835
44118
  onBlur: () => null,
43836
- onDestroy: () => null
44119
+ onDestroy: () => null,
44120
+ onContentError: ({ error }) => {
44121
+ throw error;
44122
+ }
43837
44123
  };
43838
44124
  this.isCapturingTransaction = false;
43839
44125
  this.capturedTransaction = null;
@@ -43843,6 +44129,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43843
44129
  this.createSchema();
43844
44130
  this.on("beforeCreate", this.options.onBeforeCreate);
43845
44131
  this.emit("beforeCreate", { editor: this });
44132
+ this.on("contentError", this.options.onContentError);
43846
44133
  this.createView();
43847
44134
  this.injectCSS();
43848
44135
  this.on("create", this.options.onCreate);
@@ -43996,7 +44283,23 @@ let Editor$1 = class Editor2 extends EventEmitter {
43996
44283
  * Creates a ProseMirror view.
43997
44284
  */
43998
44285
  createView() {
43999
- const doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions);
44286
+ let doc2;
44287
+ try {
44288
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
44289
+ } catch (e) {
44290
+ if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) {
44291
+ throw e;
44292
+ }
44293
+ this.emit("contentError", {
44294
+ editor: this,
44295
+ error: e,
44296
+ disableCollaboration: () => {
44297
+ this.options.extensions = this.options.extensions.filter((extension) => extension.name !== "collaboration");
44298
+ this.createExtensionManager();
44299
+ }
44300
+ });
44301
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: false });
44302
+ }
44000
44303
  const selection = resolveFocusPosition(doc2, this.options.autofocus);
44001
44304
  this.view = new EditorView(this.options.element, {
44002
44305
  ...this.options.editorProps,
@@ -44234,7 +44537,8 @@ function nodeInputRule(config) {
44234
44537
  tr2.insertText(lastChar, start2 + match2[0].length - 1);
44235
44538
  tr2.replaceWith(matchStart, end2, newNode);
44236
44539
  } else if (match2[0]) {
44237
- tr2.insert(start2 - 1, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44540
+ const insertionStart = config.type.isInline ? start2 : start2 - 1;
44541
+ tr2.insert(insertionStart, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44238
44542
  }
44239
44543
  tr2.scrollIntoView();
44240
44544
  }
@@ -44319,20 +44623,22 @@ class Mark {
44319
44623
  return new Mark(config);
44320
44624
  }
44321
44625
  configure(options = {}) {
44322
- const extension = this.extend();
44323
- extension.options = mergeDeep(this.options, options);
44324
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44325
- name: extension.name,
44326
- options: extension.options
44327
- }));
44626
+ const extension = this.extend({
44627
+ ...this.config,
44628
+ addOptions: () => {
44629
+ return mergeDeep(this.options, options);
44630
+ }
44631
+ });
44632
+ extension.name = this.name;
44633
+ extension.parent = this.parent;
44328
44634
  return extension;
44329
44635
  }
44330
44636
  extend(extendedConfig = {}) {
44331
- const extension = new Mark({ ...this.config, ...extendedConfig });
44637
+ const extension = new Mark(extendedConfig);
44332
44638
  extension.parent = this;
44333
44639
  this.child = extension;
44334
44640
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44335
- if (extendedConfig.defaultOptions) {
44641
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44336
44642
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44337
44643
  }
44338
44644
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44398,20 +44704,22 @@ let Node$2 = class Node3 {
44398
44704
  return new Node3(config);
44399
44705
  }
44400
44706
  configure(options = {}) {
44401
- const extension = this.extend();
44402
- extension.options = mergeDeep(this.options, options);
44403
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44404
- name: extension.name,
44405
- options: extension.options
44406
- }));
44707
+ const extension = this.extend({
44708
+ ...this.config,
44709
+ addOptions: () => {
44710
+ return mergeDeep(this.options, options);
44711
+ }
44712
+ });
44713
+ extension.name = this.name;
44714
+ extension.parent = this.parent;
44407
44715
  return extension;
44408
44716
  }
44409
44717
  extend(extendedConfig = {}) {
44410
- const extension = new Node3({ ...this.config, ...extendedConfig });
44718
+ const extension = new Node3(extendedConfig);
44411
44719
  extension.parent = this;
44412
44720
  this.child = extension;
44413
44721
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44414
- if (extendedConfig.defaultOptions) {
44722
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44415
44723
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44416
44724
  }
44417
44725
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44946,14 +45254,12 @@ const CodeBlock = Node$2.create({
44946
45254
  if (!text || !language) {
44947
45255
  return false;
44948
45256
  }
44949
- const { tr: tr2 } = view.state;
44950
- if (view.state.selection.from === view.state.doc.nodeSize - (1 + view.state.selection.$to.depth * 2)) {
44951
- tr2.insert(view.state.selection.from - 1, this.type.create({ language }));
44952
- } else {
44953
- tr2.replaceSelectionWith(this.type.create({ language }));
45257
+ const { tr: tr2, schema } = view.state;
45258
+ const textNode = schema.text(text.replace(/\r\n?/g, "\n"));
45259
+ tr2.replaceSelectionWith(this.type.create({ language }, textNode));
45260
+ if (tr2.selection.$from.parent.type !== this.type) {
45261
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44954
45262
  }
44955
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44956
- tr2.insertText(text.replace(/\r\n?/g, "\n"));
44957
45263
  tr2.setMeta("paste", true);
44958
45264
  view.dispatch(tr2);
44959
45265
  return true;
@@ -45869,13 +46175,13 @@ function applyTransaction(history2, state2, tr2, options) {
45869
46175
  return history2;
45870
46176
  } else if (appended && appended.getMeta(historyKey)) {
45871
46177
  if (appended.getMeta(historyKey).redo)
45872
- 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);
46178
+ return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state2)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
45873
46179
  else
45874
46180
  return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state2)), null, history2.prevTime, history2.prevComposition);
45875
46181
  } else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
45876
46182
  let composition = tr2.getMeta("composition");
45877
46183
  let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
45878
- let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps[tr2.steps.length - 1]);
46184
+ let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
45879
46185
  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);
45880
46186
  } else if (rebased = tr2.getMeta("rebased")) {
45881
46187
  return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
@@ -45896,9 +46202,10 @@ function isAdjacentTo(transform, prevRanges) {
45896
46202
  });
45897
46203
  return adjacent;
45898
46204
  }
45899
- function rangesFor(map4) {
46205
+ function rangesFor(maps) {
45900
46206
  let result2 = [];
45901
- map4.forEach((_from, _to, from2, to2) => result2.push(from2, to2));
46207
+ for (let i2 = maps.length - 1; i2 >= 0 && result2.length == 0; i2--)
46208
+ maps[i2].forEach((_from, _to, from2, to2) => result2.push(from2, to2));
45902
46209
  return result2;
45903
46210
  }
45904
46211
  function mapRanges(ranges, mapping) {
@@ -45912,16 +46219,16 @@ function mapRanges(ranges, mapping) {
45912
46219
  }
45913
46220
  return result2;
45914
46221
  }
45915
- function histTransaction(history2, state2, dispatch, redo2) {
46222
+ function histTransaction(history2, state2, redo2) {
45916
46223
  let preserveItems = mustPreserveItems(state2);
45917
46224
  let histOptions = historyKey.get(state2).spec.config;
45918
46225
  let pop = (redo2 ? history2.undone : history2.done).popEvent(state2, preserveItems);
45919
46226
  if (!pop)
45920
- return;
46227
+ return null;
45921
46228
  let selection = pop.selection.resolve(pop.transform.doc);
45922
46229
  let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state2.selection.getBookmark(), histOptions, preserveItems);
45923
46230
  let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
45924
- dispatch(pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist }).scrollIntoView());
46231
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
45925
46232
  }
45926
46233
  let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
45927
46234
  function mustPreserveItems(state2) {
@@ -45969,22 +46276,21 @@ function history(config = {}) {
45969
46276
  }
45970
46277
  });
45971
46278
  }
45972
- const undo = (state2, dispatch) => {
45973
- let hist = historyKey.getState(state2);
45974
- if (!hist || hist.done.eventCount == 0)
45975
- return false;
45976
- if (dispatch)
45977
- histTransaction(hist, state2, dispatch, false);
45978
- return true;
45979
- };
45980
- const redo = (state2, dispatch) => {
45981
- let hist = historyKey.getState(state2);
45982
- if (!hist || hist.undone.eventCount == 0)
45983
- return false;
45984
- if (dispatch)
45985
- histTransaction(hist, state2, dispatch, true);
45986
- return true;
45987
- };
46279
+ function buildCommand(redo2, scroll) {
46280
+ return (state2, dispatch) => {
46281
+ let hist = historyKey.getState(state2);
46282
+ if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
46283
+ return false;
46284
+ if (dispatch) {
46285
+ let tr2 = histTransaction(hist, state2, redo2);
46286
+ if (tr2)
46287
+ dispatch(scroll ? tr2.scrollIntoView() : tr2);
46288
+ }
46289
+ return true;
46290
+ };
46291
+ }
46292
+ const undo = buildCommand(false, true);
46293
+ const redo = buildCommand(true, true);
45988
46294
  const History = Extension.create({
45989
46295
  name: "history",
45990
46296
  addOptions() {
@@ -46036,10 +46342,20 @@ const HorizontalRule = Node$2.create({
46036
46342
  addCommands() {
46037
46343
  return {
46038
46344
  setHorizontalRule: () => ({ chain, state: state2 }) => {
46039
- const { $to: $originTo } = state2.selection;
46345
+ const { selection } = state2;
46346
+ const { $from: $originFrom, $to: $originTo } = selection;
46040
46347
  const currentChain = chain();
46041
- if ($originTo.parentOffset === 0) {
46042
- currentChain.insertContentAt(Math.max($originTo.pos - 2, 0), { type: this.name });
46348
+ if ($originFrom.parentOffset === 0) {
46349
+ currentChain.insertContentAt({
46350
+ from: Math.max($originFrom.pos - 1, 0),
46351
+ to: $originTo.pos
46352
+ }, {
46353
+ type: this.name
46354
+ });
46355
+ } else if (isNodeSelection(selection)) {
46356
+ currentChain.insertContentAt($originTo.pos, {
46357
+ type: this.name
46358
+ });
46043
46359
  } else {
46044
46360
  currentChain.insertContent({ type: this.name });
46045
46361
  }
@@ -46425,11 +46741,11 @@ const StarterKit = Extension.create({
46425
46741
  addExtensions() {
46426
46742
  var _a2, _b, _c, _d, _e2, _f, _g, _h, _j, _k, _l2, _m, _o, _p, _q, _r2, _s, _t2;
46427
46743
  const extensions = [];
46428
- if (this.options.blockquote !== false) {
46429
- extensions.push(Blockquote.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.blockquote));
46430
- }
46431
46744
  if (this.options.bold !== false) {
46432
- extensions.push(Bold.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.bold));
46745
+ extensions.push(Bold.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.bold));
46746
+ }
46747
+ if (this.options.blockquote !== false) {
46748
+ extensions.push(Blockquote.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.blockquote));
46433
46749
  }
46434
46750
  if (this.options.bulletList !== false) {
46435
46751
  extensions.push(BulletList.configure((_c = this.options) === null || _c === void 0 ? void 0 : _c.bulletList));
@@ -49236,7 +49552,7 @@ class BubbleMenuView {
49236
49552
  }
49237
49553
  update(view, oldState) {
49238
49554
  const { state: state2 } = view;
49239
- const hasValidSelection = state2.selection.$from.pos !== state2.selection.$to.pos;
49555
+ const hasValidSelection = state2.selection.from !== state2.selection.to;
49240
49556
  if (this.updateDelay > 0 && hasValidSelection) {
49241
49557
  this.handleDebouncedUpdate(view, oldState);
49242
49558
  return;
@@ -52281,9 +52597,6 @@ function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
52281
52597
  return { colgroup, tableWidth, tableMinWidth };
52282
52598
  }
52283
52599
  function createCell(cellType, cellContent) {
52284
- if (cellContent) {
52285
- return cellType.createChecked(null, cellContent);
52286
- }
52287
52600
  return cellType.createAndFill();
52288
52601
  }
52289
52602
  function getTableNodeTypes(schema) {
@@ -52305,12 +52618,12 @@ function createTable$1(schema, rowsCount, colsCount, withHeaderRow, cellContent)
52305
52618
  const headerCells = [];
52306
52619
  const cells = [];
52307
52620
  for (let index2 = 0; index2 < colsCount; index2 += 1) {
52308
- const cell = createCell(types.cell, cellContent);
52621
+ const cell = createCell(types.cell);
52309
52622
  if (cell) {
52310
52623
  cells.push(cell);
52311
52624
  }
52312
52625
  if (withHeaderRow) {
52313
- const headerCell = createCell(types.header_cell, cellContent);
52626
+ const headerCell = createCell(types.header_cell);
52314
52627
  if (headerCell) {
52315
52628
  headerCells.push(headerCell);
52316
52629
  }
@@ -52388,7 +52701,7 @@ const Table = Node$2.create({
52388
52701
  insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr: tr2, dispatch, editor }) => {
52389
52702
  const node = createTable$1(editor.schema, rows, cols, withHeaderRow);
52390
52703
  if (dispatch) {
52391
- const offset2 = tr2.selection.anchor + 1;
52704
+ const offset2 = tr2.selection.from + 1;
52392
52705
  tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(offset2)));
52393
52706
  }
52394
52707
  return true;
@@ -52865,18 +53178,7 @@ function _typeof$1(obj) {
52865
53178
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
52866
53179
  }, _typeof$1(obj);
52867
53180
  }
52868
- function _defineProperties$2(target, props2) {
52869
- for (var i2 = 0; i2 < props2.length; i2++) {
52870
- var descriptor = props2[i2];
52871
- descriptor.enumerable = descriptor.enumerable || false;
52872
- descriptor.configurable = true;
52873
- if ("value" in descriptor) descriptor.writable = true;
52874
- Object.defineProperty(target, descriptor.key, descriptor);
52875
- }
52876
- }
52877
53181
  function _createClass$2(Constructor, protoProps, staticProps) {
52878
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
52879
- if (staticProps) _defineProperties$2(Constructor, staticProps);
52880
53182
  Object.defineProperty(Constructor, "prototype", { writable: false });
52881
53183
  return Constructor;
52882
53184
  }
@@ -53053,7 +53355,6 @@ function _defineProperties$1(target, props2) {
53053
53355
  }
53054
53356
  function _createClass$1(Constructor, protoProps, staticProps) {
53055
53357
  if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
53056
- if (staticProps) _defineProperties$1(Constructor, staticProps);
53057
53358
  Object.defineProperty(Constructor, "prototype", { writable: false });
53058
53359
  return Constructor;
53059
53360
  }
@@ -53695,10 +53996,10 @@ var DIGITS = {
53695
53996
  function parseDigit(character) {
53696
53997
  return DIGITS[character];
53697
53998
  }
53698
- function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53999
+ function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53699
54000
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53700
54001
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53701
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$5(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54002
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike) {
53702
54003
  if (it2) o2 = it2;
53703
54004
  var i2 = 0;
53704
54005
  return function() {
@@ -53708,15 +54009,15 @@ function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53708
54009
  }
53709
54010
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53710
54011
  }
53711
- function _unsupportedIterableToArray$5(o2, minLen) {
54012
+ function _unsupportedIterableToArray$4(o2, minLen) {
53712
54013
  if (!o2) return;
53713
- if (typeof o2 === "string") return _arrayLikeToArray$5(o2, minLen);
54014
+ if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53714
54015
  var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53715
54016
  if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53716
54017
  if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53717
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$5(o2, minLen);
54018
+ if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53718
54019
  }
53719
- function _arrayLikeToArray$5(arr, len) {
54020
+ function _arrayLikeToArray$4(arr, len) {
53720
54021
  if (len == null || len > arr.length) len = arr.length;
53721
54022
  for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53722
54023
  arr2[i2] = arr[i2];
@@ -53725,7 +54026,7 @@ function _arrayLikeToArray$5(arr, len) {
53725
54026
  }
53726
54027
  function parseIncompletePhoneNumber(string2) {
53727
54028
  var result2 = "";
53728
- for (var _iterator = _createForOfIteratorHelperLoose$4(string2.split("")), _step; !(_step = _iterator()).done; ) {
54029
+ for (var _iterator = _createForOfIteratorHelperLoose$3(string2.split("")), _step; !(_step = _iterator()).done; ) {
53729
54030
  var character = _step.value;
53730
54031
  result2 += parsePhoneNumberCharacter(character, result2) || "";
53731
54032
  }
@@ -53734,55 +54035,12 @@ function parseIncompletePhoneNumber(string2) {
53734
54035
  function parsePhoneNumberCharacter(character, prevParsedCharacters, emitEvent) {
53735
54036
  if (character === "+") {
53736
54037
  if (prevParsedCharacters) {
53737
- if (typeof emitEvent === "function") {
53738
- emitEvent("end");
53739
- }
53740
54038
  return;
53741
54039
  }
53742
54040
  return "+";
53743
54041
  }
53744
54042
  return parseDigit(character);
53745
54043
  }
53746
- function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53747
- var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53748
- if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53749
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
53750
- if (it2) o2 = it2;
53751
- var i2 = 0;
53752
- return function() {
53753
- if (i2 >= o2.length) return { done: true };
53754
- return { done: false, value: o2[i2++] };
53755
- };
53756
- }
53757
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53758
- }
53759
- function _unsupportedIterableToArray$4(o2, minLen) {
53760
- if (!o2) return;
53761
- if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53762
- var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53763
- if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53764
- if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53765
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53766
- }
53767
- function _arrayLikeToArray$4(arr, len) {
53768
- if (len == null || len > arr.length) len = arr.length;
53769
- for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53770
- arr2[i2] = arr[i2];
53771
- }
53772
- return arr2;
53773
- }
53774
- function mergeArrays(a2, b2) {
53775
- var merged = a2.slice();
53776
- for (var _iterator = _createForOfIteratorHelperLoose$3(b2), _step; !(_step = _iterator()).done; ) {
53777
- var element = _step.value;
53778
- if (a2.indexOf(element) < 0) {
53779
- merged.push(element);
53780
- }
53781
- }
53782
- return merged.sort(function(a3, b3) {
53783
- return a3 - b3;
53784
- });
53785
- }
53786
54044
  function checkNumberLength(nationalNumber, metadata2) {
53787
54045
  return checkNumberLengthForType(nationalNumber, void 0, metadata2);
53788
54046
  }
@@ -53792,17 +54050,6 @@ function checkNumberLengthForType(nationalNumber, type3, metadata2) {
53792
54050
  if (!possible_lengths) {
53793
54051
  return "IS_POSSIBLE";
53794
54052
  }
53795
- if (type3 === "FIXED_LINE_OR_MOBILE") {
53796
- if (!metadata2.type("FIXED_LINE")) {
53797
- return checkNumberLengthForType(nationalNumber, "MOBILE", metadata2);
53798
- }
53799
- var mobile_type = metadata2.type("MOBILE");
53800
- if (mobile_type) {
53801
- possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths());
53802
- }
53803
- } else if (type3 && !type_info) {
53804
- return "INVALID_LENGTH";
53805
- }
53806
54053
  var actual_length = nationalNumber.length;
53807
54054
  var minimum_length = possible_lengths[0];
53808
54055
  if (minimum_length === actual_length) {
@@ -53867,7 +54114,7 @@ function matchesEntirely(text, regular_expression) {
53867
54114
  function _createForOfIteratorHelperLoose$2(o2, allowArrayLike) {
53868
54115
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53869
54116
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53870
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54117
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike) {
53871
54118
  if (it2) o2 = it2;
53872
54119
  var i2 = 0;
53873
54120
  return function() {
@@ -53967,8 +54214,6 @@ function applyInternationalSeparatorStyle(formattedNumber) {
53967
54214
  var FIRST_GROUP_PATTERN = /(\$\d)/;
53968
54215
  function formatNationalNumberUsingFormat(number2, format2, _ref) {
53969
54216
  var useInternationalFormat = _ref.useInternationalFormat, withNationalPrefix = _ref.withNationalPrefix;
53970
- _ref.carrierCode;
53971
- _ref.metadata;
53972
54217
  var formattedNumber = number2.replace(new RegExp(format2.pattern()), useInternationalFormat ? format2.internationalFormat() : (
53973
54218
  // This library doesn't use `domestic_carrier_code_formatting_rule`,
53974
54219
  // because that one is only used when formatting phone numbers
@@ -54014,7 +54259,7 @@ function formatRFC3966(_ref) {
54014
54259
  function _createForOfIteratorHelperLoose$1(o2, allowArrayLike) {
54015
54260
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54016
54261
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54017
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54262
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike) {
54018
54263
  if (it2) o2 = it2;
54019
54264
  var i2 = 0;
54020
54265
  return function() {
@@ -54210,7 +54455,6 @@ function _defineProperties(target, props2) {
54210
54455
  }
54211
54456
  function _createClass(Constructor, protoProps, staticProps) {
54212
54457
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54213
- if (staticProps) _defineProperties(Constructor, staticProps);
54214
54458
  Object.defineProperty(Constructor, "prototype", { writable: false });
54215
54459
  return Constructor;
54216
54460
  }
@@ -54507,7 +54751,7 @@ function extractCountryCallingCode(number2, country, callingCode, metadata2) {
54507
54751
  function _createForOfIteratorHelperLoose(o2, allowArrayLike) {
54508
54752
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54509
54753
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54510
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54754
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike) {
54511
54755
  if (it2) o2 = it2;
54512
54756
  var i2 = 0;
54513
54757
  return function() {
@@ -54561,14 +54805,8 @@ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
54561
54805
  return matchingCountries[0];
54562
54806
  }
54563
54807
  }
54564
- var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
54565
54808
  function getCountryByCallingCode(callingCode, _ref) {
54566
54809
  var nationalPhoneNumber = _ref.nationalNumber, defaultCountry = _ref.defaultCountry, metadata2 = _ref.metadata;
54567
- if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
54568
- if (metadata2.isNonGeographicCallingCode(callingCode)) {
54569
- return "001";
54570
- }
54571
- }
54572
54810
  var possibleCountries = metadata2.getCountryCodesForCallingCode(callingCode);
54573
54811
  if (!possibleCountries) {
54574
54812
  return;
@@ -57402,7 +57640,7 @@ const bisectCenter = bisector(number$2).center;
57402
57640
  function extent(values3, valueof) {
57403
57641
  let min2;
57404
57642
  let max2;
57405
- if (valueof === void 0) {
57643
+ {
57406
57644
  for (const value of values3) {
57407
57645
  if (value != null) {
57408
57646
  if (min2 === void 0) {
@@ -57413,18 +57651,6 @@ function extent(values3, valueof) {
57413
57651
  }
57414
57652
  }
57415
57653
  }
57416
- } else {
57417
- let index2 = -1;
57418
- for (let value of values3) {
57419
- if ((value = valueof(value, ++index2, values3)) != null) {
57420
- if (min2 === void 0) {
57421
- if (value >= value) min2 = max2 = value;
57422
- } else {
57423
- if (min2 > value) min2 = value;
57424
- if (max2 < value) max2 = value;
57425
- }
57426
- }
57427
- }
57428
57654
  }
57429
57655
  return [min2, max2];
57430
57656
  }