@inpageedit/core 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +55 -55
  3. package/dist/ActionButton-BgbTKTg7.js.map +1 -1
  4. package/dist/InputBox-FIzJ-rPN.js.map +1 -1
  5. package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
  6. package/dist/RadioBox-CaA8VgLu.js.map +1 -1
  7. package/dist/components/index.js.map +1 -1
  8. package/dist/decorators/Preferences.d.ts +1 -1
  9. package/dist/{index-Dk3xR25y.js → index-6pczvrx6.js} +15 -15
  10. package/dist/index-6pczvrx6.js.map +1 -0
  11. package/dist/{index-QF8lvEam.js → index-7DsKuWsw.js} +52 -37
  12. package/dist/index-7DsKuWsw.js.map +1 -0
  13. package/dist/index-Bh70Udzi.js.map +1 -1
  14. package/dist/{index-CJLKdEqr.js → index-Bo7FhmY-.js} +3 -3
  15. package/dist/index-Bo7FhmY-.js.map +1 -0
  16. package/dist/{index-BIgWRk98.js → index-C5nqZrGe.js} +1258 -1297
  17. package/dist/{index-BIgWRk98.js.map → index-C5nqZrGe.js.map} +1 -1
  18. package/dist/{index-CBphMyYJ.js → index-CHb2WvLm.js} +1246 -1112
  19. package/dist/index-CHb2WvLm.js.map +1 -0
  20. package/dist/index-Cm67r8TX.js +458 -0
  21. package/dist/index-Cm67r8TX.js.map +1 -0
  22. package/dist/index-CvhkVj_L.js.map +1 -1
  23. package/dist/{index-BMmKF_kG.js → index-DiCrCoWT.js} +6 -6
  24. package/dist/index-DiCrCoWT.js.map +1 -0
  25. package/dist/index-Dnu9H-Aq.js +128 -0
  26. package/dist/index-Dnu9H-Aq.js.map +1 -0
  27. package/dist/{index-DNm9SNqM.js → index-Dz0VGQwY.js} +80 -80
  28. package/dist/{index-DNm9SNqM.js.map → index-Dz0VGQwY.js.map} +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/models/WikiPage/types/PageInfo.d.ts +2 -0
  31. package/dist/plugins/in-article-links/index.d.ts +29 -0
  32. package/dist/plugins/preferences/index.d.ts +5 -4
  33. package/dist/plugins/quick-edit/index.d.ts +15 -7
  34. package/dist/plugins/quick-preview/index.d.ts +2 -2
  35. package/dist/plugins/toolbox/index.d.ts +14 -4
  36. package/dist/services/ModalService/IPEModal.d.ts +4 -4
  37. package/dist/services/ModalService/index.d.ts +6 -14
  38. package/dist/services/SiteMetadataService.d.ts +3 -2
  39. package/dist/style.css +1 -1
  40. package/dist/utils/computeable.d.ts +2 -0
  41. package/dist/utils/makeCallable.d.ts +3 -0
  42. package/lib/index.umd.js +28 -28
  43. package/lib/index.umd.js.map +1 -1
  44. package/lib/style.css +1 -1
  45. package/package.json +1 -1
  46. package/dist/index-BMmKF_kG.js.map +0 -1
  47. package/dist/index-CBphMyYJ.js.map +0 -1
  48. package/dist/index-CJLKdEqr.js.map +0 -1
  49. package/dist/index-CX5H4xCe.js +0 -142
  50. package/dist/index-CX5H4xCe.js.map +0 -1
  51. package/dist/index-Djd6Ddcm.js +0 -414
  52. package/dist/index-Djd6Ddcm.js.map +0 -1
  53. package/dist/index-Dk3xR25y.js.map +0 -1
  54. package/dist/index-QF8lvEam.js.map +0 -1
  55. package/dist/sleep-DpyIipK-.js +0 -5
  56. package/dist/sleep-DpyIipK-.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { j as m, F as be, P as Se } from "./index-CvhkVj_L.js";
2
- import { B as G, a as Pe, S as E } from "./index-CBphMyYJ.js";
3
- import { R as Ne } from "./Preferences-Bg3J5Ur9.js";
2
+ import { B as G, a as Ne, S as E } from "./index-CHb2WvLm.js";
3
+ import { R as Pe } from "./Preferences-Bg3J5Ur9.js";
4
4
  import { R as Ee, M as We } from "./RadioBox-CaA8VgLu.js";
5
5
  class S {
6
6
  diff(e, n, i = {}) {
@@ -11,14 +11,14 @@ class S {
11
11
  }
12
12
  diffWithOptionsObj(e, n, i, s) {
13
13
  var r;
14
- const l = (c) => {
15
- if (c = this.postProcess(c, i), s) {
14
+ const l = (u) => {
15
+ if (u = this.postProcess(u, i), s) {
16
16
  setTimeout(function() {
17
- s(c);
17
+ s(u);
18
18
  }, 0);
19
19
  return;
20
20
  } else
21
- return c;
21
+ return u;
22
22
  }, o = n.length, f = e.length;
23
23
  let g = 1, a = o + f;
24
24
  i.maxEditLength != null && (a = Math.min(a, i.maxEditLength));
@@ -28,39 +28,39 @@ class S {
28
28
  return l(this.buildValues(v[0].lastComponent, n, e));
29
29
  let p = -1 / 0, x = 1 / 0;
30
30
  const C = () => {
31
- for (let c = Math.max(p, -g); c <= Math.min(x, g); c += 2) {
32
- let u;
33
- const w = v[c - 1], k = v[c + 1];
34
- w && (v[c - 1] = void 0);
31
+ for (let u = Math.max(p, -g); u <= Math.min(x, g); u += 2) {
32
+ let c;
33
+ const w = v[u - 1], k = v[u + 1];
34
+ w && (v[u - 1] = void 0);
35
35
  let b = !1;
36
36
  if (k) {
37
- const P = k.oldPos - c;
38
- b = k && 0 <= P && P < o;
37
+ const N = k.oldPos - u;
38
+ b = k && 0 <= N && N < o;
39
39
  }
40
40
  const D = w && w.oldPos + 1 < f;
41
41
  if (!b && !D) {
42
- v[c] = void 0;
42
+ v[u] = void 0;
43
43
  continue;
44
44
  }
45
- if (!D || b && w.oldPos < k.oldPos ? u = this.addToPath(k, !0, !1, 0, i) : u = this.addToPath(w, !1, !0, 1, i), d = this.extractCommon(u, n, e, c, i), u.oldPos + 1 >= f && d + 1 >= o)
46
- return l(this.buildValues(u.lastComponent, n, e)) || !0;
47
- v[c] = u, u.oldPos + 1 >= f && (x = Math.min(x, c - 1)), d + 1 >= o && (p = Math.max(p, c + 1));
45
+ if (!D || b && w.oldPos < k.oldPos ? c = this.addToPath(k, !0, !1, 0, i) : c = this.addToPath(w, !1, !0, 1, i), d = this.extractCommon(c, n, e, u, i), c.oldPos + 1 >= f && d + 1 >= o)
46
+ return l(this.buildValues(c.lastComponent, n, e)) || !0;
47
+ v[u] = c, c.oldPos + 1 >= f && (x = Math.min(x, u - 1)), d + 1 >= o && (p = Math.max(p, u + 1));
48
48
  }
49
49
  g++;
50
50
  };
51
51
  if (s)
52
- (function c() {
52
+ (function u() {
53
53
  setTimeout(function() {
54
54
  if (g > a || Date.now() > y)
55
55
  return s(void 0);
56
- C() || c();
56
+ C() || u();
57
57
  }, 0);
58
58
  })();
59
59
  else
60
60
  for (; g <= a && Date.now() <= y; ) {
61
- const c = C();
62
- if (c)
63
- return c;
61
+ const u = C();
62
+ if (u)
63
+ return u;
64
64
  }
65
65
  }
66
66
  addToPath(e, n, i, s, r) {
@@ -213,7 +213,7 @@ function _(t) {
213
213
  ;
214
214
  return t.substring(e + 1);
215
215
  }
216
- function N(t) {
216
+ function P(t) {
217
217
  const e = t.match(/^\s*/);
218
218
  return e ? e[0] : "";
219
219
  }
@@ -255,7 +255,7 @@ function ne(t, e, n) {
255
255
  }
256
256
  function X(t, e, n, i) {
257
257
  if (e && n) {
258
- const s = N(e.value), r = _(e.value), l = N(n.value), o = _(n.value);
258
+ const s = P(e.value), r = _(e.value), l = P(n.value), o = _(n.value);
259
259
  if (t) {
260
260
  const f = U(s, l);
261
261
  t.value = H(t.value, l, f), e.value = W(e.value, f), n.value = W(n.value, f);
@@ -266,23 +266,23 @@ function X(t, e, n, i) {
266
266
  }
267
267
  } else if (n) {
268
268
  if (t) {
269
- const s = N(n.value);
269
+ const s = P(n.value);
270
270
  n.value = n.value.substring(s.length);
271
271
  }
272
272
  if (i) {
273
- const s = N(i.value);
273
+ const s = P(i.value);
274
274
  i.value = i.value.substring(s.length);
275
275
  }
276
276
  } else if (t && i) {
277
- const s = N(i.value), r = N(e.value), l = _(e.value), o = U(s, r);
277
+ const s = P(i.value), r = P(e.value), l = _(e.value), o = U(s, r);
278
278
  e.value = W(e.value, o);
279
279
  const f = V(W(s, o), l);
280
280
  e.value = O(e.value, f), i.value = I(i.value, s, f), t.value = H(t.value, s, s.slice(0, s.length - f.length));
281
281
  } else if (i) {
282
- const s = N(i.value), r = _(e.value), l = Y(r, s);
282
+ const s = P(i.value), r = _(e.value), l = Y(r, s);
283
283
  e.value = O(e.value, l);
284
284
  } else if (t) {
285
- const s = _(t.value), r = N(e.value), l = Y(s, r);
285
+ const s = _(t.value), r = P(e.value), l = Y(s, r);
286
286
  e.value = W(e.value, l);
287
287
  }
288
288
  }
@@ -384,9 +384,9 @@ class Me extends S {
384
384
  return super.equals(e.replace(/,([\r\n])/g, "$1"), n.replace(/,([\r\n])/g, "$1"), i);
385
385
  }
386
386
  }
387
- const ue = new Me();
388
- function ce(t, e, n) {
389
- return ue.diff(t, e, n);
387
+ const ce = new Me();
388
+ function ue(t, e, n) {
389
+ return ce.diff(t, e, n);
390
390
  }
391
391
  function A(t, e, n, i, s) {
392
392
  e = e || [], n = n || [], i && (t = i(s === void 0 ? "" : s, t));
@@ -553,28 +553,28 @@ function Ue(t, e, n = {}) {
553
553
  else if (!l)
554
554
  return !1;
555
555
  }
556
- function h(d, p, x, C = 0, c = !0, u = [], w = 0) {
556
+ function h(d, p, x, C = 0, u = !0, c = [], w = 0) {
557
557
  let k = 0, b = !1;
558
558
  for (; C < d.length; C++) {
559
- const D = d[C], P = D.length > 0 ? D[0] : " ", z = D.length > 0 ? D.substr(1) : D;
560
- if (P === "-")
561
- if (r(p + 1, i[p], P, z))
559
+ const D = d[C], N = D.length > 0 ? D[0] : " ", z = D.length > 0 ? D.substr(1) : D;
560
+ if (N === "-")
561
+ if (r(p + 1, i[p], N, z))
562
562
  p++, k = 0;
563
563
  else
564
- return !x || i[p] == null ? null : (u[w] = i[p], h(d, p + 1, x - 1, C, !1, u, w + 1));
565
- if (P === "+") {
566
- if (!c)
564
+ return !x || i[p] == null ? null : (c[w] = i[p], h(d, p + 1, x - 1, C, !1, c, w + 1));
565
+ if (N === "+") {
566
+ if (!u)
567
567
  return null;
568
- u[w] = z, w++, k = 0, b = !0;
568
+ c[w] = z, w++, k = 0, b = !0;
569
569
  }
570
- if (P === " ")
571
- if (k++, u[w] = i[p], r(p + 1, i[p], P, z))
572
- w++, c = !0, b = !1, p++;
570
+ if (N === " ")
571
+ if (k++, c[w] = i[p], r(p + 1, i[p], N, z))
572
+ w++, u = !0, b = !1, p++;
573
573
  else
574
- return b || !x ? null : i[p] && (h(d, p + 1, x - 1, C + 1, !1, u, w + 1) || h(d, p + 1, x - 1, C, !1, u, w + 1)) || h(d, p, x - 1, C + 1, !1, u, w);
574
+ return b || !x ? null : i[p] && (h(d, p + 1, x - 1, C + 1, !1, c, w + 1) || h(d, p + 1, x - 1, C, !1, c, w + 1)) || h(d, p, x - 1, C + 1, !1, c, w);
575
575
  }
576
- return w -= k, p -= k, u.length = w, {
577
- patchedLines: u,
576
+ return w -= k, p -= k, c.length = w, {
577
+ patchedLines: c,
578
578
  oldLineLastI: p - 1
579
579
  };
580
580
  }
@@ -584,24 +584,24 @@ function Ue(t, e, n = {}) {
584
584
  const p = s[d];
585
585
  let x;
586
586
  const C = i.length - p.oldLines + l;
587
- let c;
588
- for (let u = 0; u <= l; u++) {
589
- c = p.oldStart + v - 1;
590
- const w = Qe(c, o, C);
591
- for (; c !== void 0 && (x = h(p.lines, c, u), !x); c = w())
587
+ let u;
588
+ for (let c = 0; c <= l; c++) {
589
+ u = p.oldStart + v - 1;
590
+ const w = Qe(u, o, C);
591
+ for (; u !== void 0 && (x = h(p.lines, u, c), !x); u = w())
592
592
  ;
593
593
  if (x)
594
594
  break;
595
595
  }
596
596
  if (!x)
597
597
  return !1;
598
- for (let u = o; u < c; u++)
599
- y.push(i[u]);
600
- for (let u = 0; u < x.patchedLines.length; u++) {
601
- const w = x.patchedLines[u];
598
+ for (let c = o; c < u; c++)
599
+ y.push(i[c]);
600
+ for (let c = 0; c < x.patchedLines.length; c++) {
601
+ const w = x.patchedLines[c];
602
602
  y.push(w);
603
603
  }
604
- o = x.oldLineLastI + 1, v = c + 1 - p.oldStart;
604
+ o = x.oldLineLastI + 1, v = u + 1 - p.oldStart;
605
605
  }
606
606
  for (let d = o; d < i.length; d++)
607
607
  y.push(i[d]);
@@ -655,26 +655,26 @@ function q(t, e, n, i, s, r, l) {
655
655
  if (!a)
656
656
  return;
657
657
  a.push({ value: "", lines: [] });
658
- function h(c) {
659
- return c.map(function(u) {
660
- return " " + u;
658
+ function h(u) {
659
+ return u.map(function(c) {
660
+ return " " + c;
661
661
  });
662
662
  }
663
663
  const y = [];
664
664
  let v = 0, d = 0, p = [], x = 1, C = 1;
665
- for (let c = 0; c < a.length; c++) {
666
- const u = a[c], w = u.lines || Xe(u.value);
667
- if (u.lines = w, u.added || u.removed) {
665
+ for (let u = 0; u < a.length; u++) {
666
+ const c = a[u], w = c.lines || Xe(c.value);
667
+ if (c.lines = w, c.added || c.removed) {
668
668
  if (!v) {
669
- const k = a[c - 1];
669
+ const k = a[u - 1];
670
670
  v = x, d = C, k && (p = f > 0 ? h(k.lines.slice(-f)) : [], v -= p.length, d -= p.length);
671
671
  }
672
672
  for (const k of w)
673
- p.push((u.added ? "+" : "-") + k);
674
- u.added ? C += w.length : x += w.length;
673
+ p.push((c.added ? "+" : "-") + k);
674
+ c.added ? C += w.length : x += w.length;
675
675
  } else {
676
676
  if (v)
677
- if (w.length <= f * 2 && c < a.length - 2)
677
+ if (w.length <= f * 2 && u < a.length - 2)
678
678
  for (const k of h(w))
679
679
  p.push(k);
680
680
  else {
@@ -693,10 +693,10 @@ function q(t, e, n, i, s, r, l) {
693
693
  x += w.length, C += w.length;
694
694
  }
695
695
  }
696
- for (const c of y)
697
- for (let u = 0; u < c.lines.length; u++)
698
- c.lines[u].endsWith(`
699
- `) ? c.lines[u] = c.lines[u].slice(0, -1) : (c.lines.splice(u + 1, 0, "\"), u++);
696
+ for (const u of y)
697
+ for (let c = 0; c < u.lines.length; c++)
698
+ u.lines[c].endsWith(`
699
+ `) ? u.lines[c] = u.lines[c].slice(0, -1) : (u.lines.splice(c + 1, 0, "\"), c++);
700
700
  return {
701
701
  oldFileName: t,
702
702
  newFileName: e,
@@ -778,14 +778,14 @@ const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
778
778
  diffArrays: me,
779
779
  diffChars: ee,
780
780
  diffCss: ae,
781
- diffJson: ce,
781
+ diffJson: ue,
782
782
  diffLines: F,
783
783
  diffSentences: oe,
784
784
  diffTrimmedLines: re,
785
785
  diffWords: ne,
786
786
  diffWordsWithSpace: $,
787
787
  formatPatch: L,
788
- jsonDiff: ue,
788
+ jsonDiff: ce,
789
789
  lineDiff: M,
790
790
  parsePatch: R,
791
791
  reversePatch: we,
@@ -796,7 +796,7 @@ const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
796
796
  }, Symbol.toStringTag, { value: "Module" }));
797
797
  class tt {
798
798
  constructor(e) {
799
- this.ctx = e, this.JsDiff = et, this.diffChars = ee, this.diffWords = ne, this.diffWordsWithSpace = $, this.diffLines = F, this.diffTrimmedLines = re, this.diffSentences = oe, this.diffCss = ae, this.diffJson = ce, this.diffArrays = me, this.createTwoFilesPatch = J, this.ctx.set("jsdiff", this);
799
+ this.ctx = e, this.JsDiff = et, this.diffChars = ee, this.diffWords = ne, this.diffWordsWithSpace = $, this.diffLines = F, this.diffTrimmedLines = re, this.diffSentences = oe, this.diffCss = ae, this.diffJson = ue, this.diffArrays = me, this.createTwoFilesPatch = J, this.ctx.set("jsdiff", this);
800
800
  }
801
801
  }
802
802
  const nt = {
@@ -912,12 +912,12 @@ const nt = {
912
912
  }, lt = (t, e = document) => e.querySelector(t), ot = (t, e = document) => e.querySelectorAll(t);
913
913
  var ft = Object.create, B = Object.defineProperty, at = Object.getOwnPropertyDescriptor, ve = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), ye = (t) => {
914
914
  throw TypeError(t);
915
- }, ut = (t, e, n) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ct = (t, e) => B(t, "name", { value: e, configurable: !0 }), dt = (t) => [, , , ft(t?.[ve("metadata")] ?? null)], mt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], xe = (t) => t !== void 0 && typeof t != "function" ? ye("Function expected") : t, ht = (t, e, n, i, s) => ({ kind: mt[t], name: e, metadata: i, addInitializer: (r) => n._ ? ye("Already initialized") : s.push(xe(r || null)) }), gt = (t, e) => ut(e, ve("metadata"), t[3]), pt = (t, e, n, i) => {
915
+ }, ct = (t, e, n) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ut = (t, e) => B(t, "name", { value: e, configurable: !0 }), dt = (t) => [, , , ft(t?.[ve("metadata")] ?? null)], mt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], xe = (t) => t !== void 0 && typeof t != "function" ? ye("Function expected") : t, ht = (t, e, n, i, s) => ({ kind: mt[t], name: e, metadata: i, addInitializer: (r) => n._ ? ye("Already initialized") : s.push(xe(r || null)) }), gt = (t, e) => ct(e, ve("metadata"), t[3]), pt = (t, e, n, i) => {
916
916
  for (var s = 0, r = t[e >> 1], l = r && r.length; s < l; s++) r[s].call(n);
917
917
  return i;
918
918
  }, wt = (t, e, n, i, s, r) => {
919
919
  var l, o, f, g = e & 7, a = !1, h = 0, y = t[h] || (t[h] = []), v = g && (s = s.prototype, g < 5 && (g > 3 || !a) && at(s, n));
920
- ct(s, n);
920
+ ut(s, n);
921
921
  for (var d = i.length - 1; d >= 0; d--)
922
922
  f = ht(g, n, o = {}, t[3], y), l = (0, i[d])(s, f), o._ = 1, xe(l) && (s = l);
923
923
  return gt(t, s), v && B(s, n, v), a ? g ^ 4 ? r : v : s;
@@ -929,7 +929,7 @@ const De = [
929
929
  "diffLines",
930
930
  "createTwoFilesPatch"
931
931
  ];
932
- ke = [Pe(["jsdiff"]), Ne(
932
+ ke = [Ne(["jsdiff"]), Pe(
933
933
  E.object({
934
934
  "quickDiff.preferredCompareMode": E.union([E.const("jsDiff"), E.const("mwApi")]).description("The preferred comparison mode for quick diff").default("mwApi"),
935
935
  "quickDiff.jsDiff.defaultType": E.union(De.map((t) => E.const(t))).description("The default diff type for JsDiff").default("diffSentences")
@@ -957,10 +957,10 @@ class j extends (Ce = G) {
957
957
  };
958
958
  }
959
959
  start() {
960
- this.ctx.set("quickDiff", this), this.ctx.on("quickEdit/wikiPage", this.injectQuickEdit.bind(this)), window.RLQ.push(this.injectHistoryPage.bind(this));
960
+ this.ctx.set("quickDiff", this), this.ctx.on("quick-edit/wiki-page", this.injectQuickEdit.bind(this)), window.RLQ.push(this.injectHistoryPage.bind(this));
961
961
  }
962
962
  stop() {
963
- this.ctx.off("quickEdit/wikiPage", this.injectQuickEdit.bind(this));
963
+ this.ctx.off("quick-edit/wiki-page", this.injectQuickEdit.bind(this));
964
964
  }
965
965
  injectHistoryPage() {
966
966
  const e = lt("#mw-history-compare");
@@ -999,7 +999,7 @@ class j extends (Ce = G) {
999
999
  className: "btn btn-secondary",
1000
1000
  method: () => {
1001
1001
  const s = n.title, r = n.revisions?.[0]?.content || "", l = e.get$content().querySelector('textarea[name="text"]')?.value || "";
1002
- return i = this.comparePages(
1002
+ return r === l ? this.ctx.modal.notify("info", { content: "No chages" }) : (i = this.comparePages(
1003
1003
  {
1004
1004
  fromtitle: s,
1005
1005
  fromtext: r,
@@ -1007,7 +1007,7 @@ class j extends (Ce = G) {
1007
1007
  totext: l
1008
1008
  },
1009
1009
  i
1010
- ), i;
1010
+ ), i);
1011
1011
  }
1012
1012
  },
1013
1013
  1
@@ -1137,4 +1137,4 @@ class Ct extends G {
1137
1137
  export {
1138
1138
  Ct as PluginQuickDiff
1139
1139
  };
1140
- //# sourceMappingURL=index-DNm9SNqM.js.map
1140
+ //# sourceMappingURL=index-Dz0VGQwY.js.map