@inpageedit/core 0.5.2 → 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 (45) hide show
  1. package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
  2. package/dist/decorators/Preferences.d.ts +1 -1
  3. package/dist/{index-6bp2nmez.js → index-6pczvrx6.js} +2 -2
  4. package/dist/{index-6bp2nmez.js.map → index-6pczvrx6.js.map} +1 -1
  5. package/dist/{index-3FdvKxaN.js → index-7DsKuWsw.js} +52 -37
  6. package/dist/index-7DsKuWsw.js.map +1 -0
  7. package/dist/{index-DXvJqlhL.js → index-Bo7FhmY-.js} +3 -3
  8. package/dist/index-Bo7FhmY-.js.map +1 -0
  9. package/dist/{index-B0QzYk-q.js → index-C5nqZrGe.js} +1258 -1297
  10. package/dist/{index-B0QzYk-q.js.map → index-C5nqZrGe.js.map} +1 -1
  11. package/dist/{index-CIzmjtBz.js → index-CHb2WvLm.js} +1246 -1112
  12. package/dist/index-CHb2WvLm.js.map +1 -0
  13. package/dist/{index-DlE7PWxs.js → index-Cm67r8TX.js} +170 -140
  14. package/dist/index-Cm67r8TX.js.map +1 -0
  15. package/dist/{index-BwVAO_o4.js → index-DiCrCoWT.js} +6 -6
  16. package/dist/index-DiCrCoWT.js.map +1 -0
  17. package/dist/index-Dnu9H-Aq.js +128 -0
  18. package/dist/index-Dnu9H-Aq.js.map +1 -0
  19. package/dist/{index-D1plOuGc.js → index-Dz0VGQwY.js} +63 -63
  20. package/dist/{index-D1plOuGc.js.map → index-Dz0VGQwY.js.map} +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/models/WikiPage/types/PageInfo.d.ts +2 -0
  23. package/dist/plugins/in-article-links/index.d.ts +6 -8
  24. package/dist/plugins/preferences/index.d.ts +5 -4
  25. package/dist/plugins/quick-edit/index.d.ts +8 -4
  26. package/dist/plugins/toolbox/index.d.ts +12 -2
  27. package/dist/services/ModalService/IPEModal.d.ts +4 -4
  28. package/dist/services/ModalService/index.d.ts +6 -14
  29. package/dist/services/SiteMetadataService.d.ts +3 -2
  30. package/dist/style.css +1 -1
  31. package/dist/utils/computeable.d.ts +2 -0
  32. package/dist/utils/makeCallable.d.ts +3 -0
  33. package/lib/index.umd.js +28 -28
  34. package/lib/index.umd.js.map +1 -1
  35. package/lib/style.css +1 -1
  36. package/package.json +1 -1
  37. package/dist/index-3FdvKxaN.js.map +0 -1
  38. package/dist/index-BwVAO_o4.js.map +0 -1
  39. package/dist/index-CIzmjtBz.js.map +0 -1
  40. package/dist/index-DXvJqlhL.js.map +0 -1
  41. package/dist/index-DlE7PWxs.js.map +0 -1
  42. package/dist/index-DnpXoEP3.js +0 -142
  43. package/dist/index-DnpXoEP3.js.map +0 -1
  44. package/dist/sleep-DpyIipK-.js +0 -5
  45. package/dist/sleep-DpyIipK-.js.map +0 -1
@@ -1,22 +1,21 @@
1
- import { j as o, F as E, P as D } from "./index-CvhkVj_L.js";
2
- import { B as A, a as q, S as m, W as f } from "./index-CIzmjtBz.js";
3
- import { R as C } from "./Preferences-Bg3J5Ur9.js";
4
- import { R as Q, M as y } from "./RadioBox-CaA8VgLu.js";
1
+ import { j as s, F as S, P as D } from "./index-CvhkVj_L.js";
2
+ import { B as I, a as C, S as m, W as g } from "./index-CHb2WvLm.js";
3
+ import { R as L } from "./Preferences-Bg3J5Ur9.js";
4
+ import { R as U, M as E } from "./RadioBox-CaA8VgLu.js";
5
5
  import { I as z, C as P } from "./InputBox-FIzJ-rPN.js";
6
- import { s as R } from "./sleep-DpyIipK-.js";
7
- var W = Object.create, _ = Object.defineProperty, H = Object.getOwnPropertyDescriptor, N = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), $ = (t) => {
6
+ var Q = Object.create, _ = Object.defineProperty, W = Object.getOwnPropertyDescriptor, M = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), O = (t) => {
8
7
  throw TypeError(t);
9
- }, Y = (t, e, r) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, X = (t, e) => _(t, "name", { value: e, configurable: !0 }), G = (t) => [, , , W(t?.[N("metadata")] ?? null)], K = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], L = (t) => t !== void 0 && typeof t != "function" ? $("Function expected") : t, J = (t, e, r, c, i) => ({ kind: K[t], name: e, metadata: c, addInitializer: (a) => r._ ? $("Already initialized") : i.push(L(a || null)) }), V = (t, e) => Y(e, N("metadata"), t[3]), Z = (t, e, r, c) => {
10
- for (var i = 0, a = t[e >> 1], s = a && a.length; i < s; i++) a[i].call(r);
8
+ }, Y = (t, e, o) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, H = (t, e) => _(t, "name", { value: e, configurable: !0 }), K = (t) => [, , , Q(t?.[M("metadata")] ?? null)], G = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], $ = (t) => t !== void 0 && typeof t != "function" ? O("Function expected") : t, X = (t, e, o, c, i) => ({ kind: G[t], name: e, metadata: c, addInitializer: (a) => o._ ? O("Already initialized") : i.push($(a || null)) }), J = (t, e) => Y(e, M("metadata"), t[3]), V = (t, e, o, c) => {
9
+ for (var i = 0, a = t[e >> 1], r = a && a.length; i < r; i++) a[i].call(o);
11
10
  return c;
12
- }, ee = (t, e, r, c, i, a) => {
13
- var s, n, l, u = e & 7, p = !1, v = 0, d = t[v] || (t[v] = []), h = u && (i = i.prototype, u < 5 && (u > 3 || !p) && H(i, r));
14
- X(i, r);
15
- for (var g = c.length - 1; g >= 0; g--)
16
- l = J(u, r, n = {}, t[3], d), s = (0, c[g])(i, l), n._ = 1, L(s) && (i = s);
17
- return V(t, i), h && _(i, r, h), p ? u ^ 4 ? a : h : i;
18
- }, M, x, B;
19
- M = [q(["sitemeta", "quickEdit"]), C(
11
+ }, Z = (t, e, o, c, i, a) => {
12
+ var r, n, l, u = e & 7, p = !1, v = 0, d = t[v] || (t[v] = []), h = u && (i = i.prototype, u < 5 && (u > 3 || !p) && W(i, o));
13
+ H(i, o);
14
+ for (var f = c.length - 1; f >= 0; f--)
15
+ l = X(u, o, n = {}, t[3], d), r = (0, c[f])(i, l), n._ = 1, $(r) && (i = r);
16
+ return J(t, i), h && _(i, o, h), p ? u ^ 4 ? a : h : i;
17
+ }, q, x, N;
18
+ q = [C(["sitemeta", "quickEdit"]), L(
20
19
  m.object({
21
20
  redLinkEdit: m.boolean().description("Show quick edit entry after red links").default(!0)
22
21
  }).description("In-article quick edit links"),
@@ -24,41 +23,41 @@ M = [q(["sitemeta", "quickEdit"]), C(
24
23
  redLinkEdit: !0
25
24
  }
26
25
  )];
27
- class w extends (B = A) {
26
+ class w extends (N = I) {
28
27
  constructor(e) {
29
- const r = e.sitemeta.mwConfig, c = r.wgArticlePath.replace("$1", ""), i = `${location.protocol}//${r.wgServer.split("//")[1]}`;
28
+ const o = e.sitemeta.mwConfig, c = o.wgArticlePath.replace("$1", ""), i = `${location.protocol}//${o.wgServer.split("//")[1]}`;
30
29
  super(
31
30
  e,
32
31
  {
33
32
  wikiBaseUrl: i,
34
33
  wikiArticlePath: c,
35
34
  wikiArticleBaseUrl: `${i}${c}`,
36
- wikiScriptBaseUrl: `${i}${r.wgScriptPath}`,
35
+ wikiScriptBaseUrl: `${i}${o.wgScriptPath}`,
37
36
  linkClassName: "ipe-quickEdit__in-article-link"
38
37
  },
39
38
  "QuickEditInArticleLinks"
40
39
  );
41
40
  }
42
41
  async start() {
43
- mw.hook("wikipage.content").add(() => {
44
- document.querySelectorAll("#mw-content-text a[href]").forEach((r) => {
45
- const c = this.checkEditAnchor(r);
46
- if (!c || r.dataset.ipeQuickEditLink)
42
+ mw.hook("wikipage.content").add((e) => {
43
+ e.find("a[href]").toArray().forEach((c) => {
44
+ const i = this.checkEditAnchor(c);
45
+ if (!i || c.dataset.ipeQuickEditLink)
47
46
  return;
48
- const i = /* @__PURE__ */ o(
47
+ const a = /* @__PURE__ */ s(
49
48
  "a",
50
49
  {
51
- href: `#/IPE/quickEdit/${c.title}`,
50
+ href: `#/IPE/quickEdit/${i.title}`,
52
51
  className: this.config.linkClassName,
53
52
  style: {
54
53
  userSelect: "none",
55
54
  marginLeft: "0.2em",
56
55
  verticalAlign: "middle"
57
56
  },
58
- onClick: (a) => {
59
- a.preventDefault(), this.ctx.quickEdit(c);
57
+ onClick: (r) => {
58
+ r.preventDefault(), this.ctx.quickEdit.showModal(i);
60
59
  },
61
- children: /* @__PURE__ */ o(
60
+ children: /* @__PURE__ */ s(
62
61
  "svg",
63
62
  {
64
63
  style: "width: 1em; height: 1em",
@@ -73,16 +72,16 @@ class w extends (B = A) {
73
72
  "stroke-linejoin": "round",
74
73
  class: "icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt",
75
74
  children: [
76
- /* @__PURE__ */ o("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
77
- /* @__PURE__ */ o("path", { d: "M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" }),
78
- /* @__PURE__ */ o("path", { d: "M13.5 6.5l4 4" }),
79
- /* @__PURE__ */ o("path", { d: "M19 16l-2 3h4l-2 3" })
75
+ /* @__PURE__ */ s("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
76
+ /* @__PURE__ */ s("path", { d: "M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" }),
77
+ /* @__PURE__ */ s("path", { d: "M13.5 6.5l4 4" }),
78
+ /* @__PURE__ */ s("path", { d: "M19 16l-2 3h4l-2 3" })
80
79
  ]
81
80
  }
82
81
  )
83
82
  }
84
83
  );
85
- r.insertAdjacentElement("afterend", i), r.dataset.ipeQuickEditLink = "true";
84
+ c.insertAdjacentElement("afterend", a), c.dataset.ipeQuickEditLink = "true";
86
85
  });
87
86
  });
88
87
  }
@@ -92,13 +91,13 @@ class w extends (B = A) {
92
91
  checkEditAnchor(e) {
93
92
  if (!(e instanceof HTMLAnchorElement))
94
93
  return null;
95
- const r = e.href || "";
96
- if (!r.startsWith(this.config.wikiArticleBaseUrl) && !r.startsWith(this.config.wikiScriptBaseUrl))
94
+ const o = e.href || "";
95
+ if (!o.startsWith(this.config.wikiArticleBaseUrl) && !o.startsWith(this.config.wikiScriptBaseUrl))
97
96
  return null;
98
- const c = new URL(r), i = c.searchParams, a = i.get("action") || "view", s = i.get("title") || decodeURI(c.pathname.substring(this.config.wikiArticlePath.length)) || "", n = i.get("section")?.replace(/^T-/, "") || void 0, l = i.get("oldid");
97
+ const c = new URL(o), i = c.searchParams, a = i.get("action") || "view", r = i.get("title") || decodeURI(c.pathname.substring(this.config.wikiArticlePath.length)) || "", n = i.get("section")?.replace(/^T-/, "") || void 0, l = i.get("oldid");
99
98
  if (
100
99
  // 不合法的 title
101
- !s || s.endsWith(".php") || // 不是 edit 相关操作
100
+ !r || r.endsWith(".php") || // 不是 edit 相关操作
102
101
  !["edit", "editsource", "editredlink", "submit"].includes(a) || // 暂时未兼容 undo
103
102
  i.get("undo") || // 暂时未兼容 preload
104
103
  i.get("preload")
@@ -106,50 +105,80 @@ class w extends (B = A) {
106
105
  return null;
107
106
  let u;
108
107
  return n === "new" ? u = "new" : n && /^\d+$/.test(n) && (u = parseInt(n, 10)), {
109
- title: s,
108
+ title: r,
110
109
  section: u,
111
110
  revision: parseInt("" + l, 10) || 0,
112
111
  createOnly: !!i.get("redlink")
113
112
  };
114
113
  }
115
114
  }
116
- x = G(B);
117
- w = ee(x, 0, "PluginQuickEditInArticleLinks", M, w);
118
- Z(x, 1, w);
119
- const I = () => {
120
- };
121
- var te = Object.create, b = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, O = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), T = (t) => {
115
+ x = K(N);
116
+ w = Z(x, 0, "PluginQuickEditInArticleLinks", q, w);
117
+ V(x, 1, w);
118
+ const ee = Symbol("@@apply"), te = Symbol("@@ctor");
119
+ function ie(t, e) {
120
+ if (typeof t != "object" || t === null || Array.isArray(t))
121
+ throw new TypeError("instance is not an object");
122
+ const o = (...a) => {
123
+ const r = t[e];
124
+ if (typeof r != "function")
125
+ throw new TypeError(`Property "${String(e)}" is not a function`);
126
+ return r.apply(t, a);
127
+ };
128
+ o[ee] = o, o[te] = t;
129
+ const c = t?.constructor?.name;
130
+ return c && (o[Symbol.toStringTag] = c), new Proxy(o, {
131
+ get(a, r, n) {
132
+ return r === "prototype" ? Reflect.get(o, r, n) : Reflect.get(t, r, t);
133
+ },
134
+ set(a, r, n) {
135
+ return Reflect.set(t, r, n);
136
+ },
137
+ has(a, r) {
138
+ return Reflect.has(t, r);
139
+ },
140
+ deleteProperty(a, r) {
141
+ return Reflect.deleteProperty(t, r);
142
+ },
143
+ ownKeys() {
144
+ return Reflect.ownKeys(t);
145
+ },
146
+ getOwnPropertyDescriptor(a, r) {
147
+ return Object.getOwnPropertyDescriptor(t, r);
148
+ },
149
+ defineProperty(a, r, n) {
150
+ return Object.defineProperty(t, r, n);
151
+ }
152
+ });
153
+ }
154
+ const A = () => {
155
+ }, re = (t = 0) => new Promise((e) => setTimeout(e, t));
156
+ var oe = Object.create, b = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, B = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), T = (t) => {
122
157
  throw TypeError(t);
123
- }, re = (t, e, r) => e in t ? b(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, ne = (t, e) => b(t, "name", { value: e, configurable: !0 }), oe = (t) => [, , , te(t?.[O("metadata")] ?? null)], se = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], j = (t) => t !== void 0 && typeof t != "function" ? T("Function expected") : t, ce = (t, e, r, c, i) => ({ kind: se[t], name: e, metadata: c, addInitializer: (a) => r._ ? T("Already initialized") : i.push(j(a || null)) }), ae = (t, e) => re(e, O("metadata"), t[3]), le = (t, e, r, c) => {
124
- for (var i = 0, a = t[e >> 1], s = a && a.length; i < s; i++) a[i].call(r);
158
+ }, se = (t, e, o) => e in t ? b(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, ce = (t, e) => b(t, "name", { value: e, configurable: !0 }), ae = (t) => [, , , oe(t?.[B("metadata")] ?? null)], le = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], j = (t) => t !== void 0 && typeof t != "function" ? T("Function expected") : t, de = (t, e, o, c, i) => ({ kind: le[t], name: e, metadata: c, addInitializer: (a) => o._ ? T("Already initialized") : i.push(j(a || null)) }), ue = (t, e) => se(e, B("metadata"), t[3]), he = (t, e, o, c) => {
159
+ for (var i = 0, a = t[e >> 1], r = a && a.length; i < r; i++) a[i].call(o);
125
160
  return c;
126
- }, de = (t, e, r, c, i, a) => {
127
- var s, n, l, u = e & 7, p = !1, v = 0, d = t[v] || (t[v] = []), h = u && (i = i.prototype, u < 5 && (u > 3 || !p) && ie(i, r));
128
- ne(i, r);
129
- for (var g = c.length - 1; g >= 0; g--)
130
- l = ce(u, r, n = {}, t[3], d), s = (0, c[g])(i, l), n._ = 1, j(s) && (i = s);
131
- return ae(t, i), h && b(i, r, h), p ? u ^ 4 ? a : h : i;
132
- }, F, S, U;
133
- F = [q(["api", "wikiPage", "modal", "preferences"]), C(
161
+ }, me = (t, e, o, c, i, a) => {
162
+ var r, n, l, u = e & 7, p = !1, v = 0, d = t[v] || (t[v] = []), h = u && (i = i.prototype, u < 5 && (u > 3 || !p) && ne(i, o));
163
+ ce(i, o);
164
+ for (var f = c.length - 1; f >= 0; f--)
165
+ l = de(u, o, n = {}, t[3], d), r = (0, c[f])(i, l), n._ = 1, j(r) && (i = r);
166
+ return ue(t, i), h && b(i, o, h), p ? u ^ 4 ? a : h : i;
167
+ }, R, y, F;
168
+ R = [C(["api", "wikiPage", "modal", "preferences"]), L(
134
169
  m.object({
135
170
  editSummary: m.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),
136
171
  editMinor: m.boolean().description("Whether to mark the edit as minor").default(!1),
137
172
  outSideClose: m.boolean().description("Whether to close the modal outside").default(!0),
138
173
  watchList: m.union([
139
- m.const(f.preferences).description("Follow my preferences"),
140
- m.const(f.nochange).description("Keep the current watchlist status"),
141
- m.const(f.watch).description("Add the page to watchlist"),
142
- m.const(f.unwatch).description("Remove the page from watchlist")
143
- ]).description("Watchlist options").default(f.preferences)
144
- }).description("Quick edit options").extra("category", "edit"),
145
- {
146
- editSummary: "[IPE-NEXT] Quick edit",
147
- editMinor: !1,
148
- outSideClose: !0,
149
- watchList: f.preferences
150
- }
174
+ m.const(g.preferences).description("Follow my preferences"),
175
+ m.const(g.nochange).description("Keep the current watchlist status"),
176
+ m.const(g.watch).description("Add the page to watchlist"),
177
+ m.const(g.unwatch).description("Remove the page from watchlist")
178
+ ]).description("Watchlist options").default(g.preferences)
179
+ }).description("Quick edit options").extra("category", "edit")
151
180
  )];
152
- class k extends (U = A) {
181
+ class k extends (F = I) {
153
182
  constructor(e) {
154
183
  super(e, {}, "quick-edit"), this.ctx = e, this.DEFAULT_OPTIONS = {
155
184
  title: "",
@@ -160,16 +189,16 @@ class k extends (U = A) {
160
189
  editSummary: "",
161
190
  createOnly: !1,
162
191
  reloadAfterSave: !0
163
- };
192
+ }, this.ctx.root.set("quickEdit", ie(this, "showModal"));
164
193
  }
165
194
  start() {
166
- this.ctx.root.set("quickEdit", this.quickEdit.bind(this)), this.ctx.inject(["toolbox"], (e) => {
195
+ this.ctx.inject(["toolbox"], (e) => {
167
196
  this.injectToolbox(e), e.on("dispose", () => {
168
197
  this.removeToolbox(e);
169
198
  });
170
199
  }), this.ctx.plugin(w);
171
200
  }
172
- async quickEdit(e) {
201
+ async showModal(e) {
173
202
  typeof e > "u" ? e = {} : typeof e == "string" && (e = {
174
203
  title: e
175
204
  }), e?.page && (e.title = e.page, delete e.page), !e.title && !e.pageId && !e.revision && (this.logger.warn("None of the title, pageId or revision provided. Using defaults."), e = {
@@ -178,28 +207,28 @@ class k extends (U = A) {
178
207
  pageId: mw.config.get("wgArticleId"),
179
208
  revision: mw.config.get("wgRevisionId")
180
209
  });
181
- const r = await this.ctx.preferences.get("outSideClose"), c = await this.ctx.preferences.get("watchList"), i = typeof e.editSummary == "string" ? e.editSummary : await this.ctx.preferences.get("editSummary"), a = typeof e.editMinor == "boolean" ? e.editMinor : await this.ctx.preferences.get("editMinor"), s = {
210
+ const o = await this.ctx.preferences.get("outSideClose"), c = await this.ctx.preferences.get("watchList"), i = typeof e.editSummary == "string" ? e.editSummary : await this.ctx.preferences.get("editSummary"), a = typeof e.editMinor == "boolean" ? e.editMinor : await this.ctx.preferences.get("editMinor"), r = {
182
211
  ...this.DEFAULT_OPTIONS,
183
212
  editSummary: i,
184
213
  editMinor: a,
185
214
  ...e
186
215
  };
187
- s.editSummary || (s.editSummary = await this.ctx.preferences.get("editSummary") || ""), s || this.ctx.emit("quick-edit/init-options", { ctx: this.ctx, options: s });
216
+ r.editSummary || (r.editSummary = await this.ctx.preferences.get("editSummary") || ""), r || this.ctx.emit("quick-edit/init-options", { ctx: this.ctx, options: r });
188
217
  const n = this.ctx.modal.createObject({
189
218
  className: "ipe-quickEdit",
190
219
  sizeClass: "large",
191
220
  // backdrop: false,
192
221
  // draggable: true,
193
222
  center: !1,
194
- outSideClose: r
223
+ outSideClose: o
195
224
  }).init();
196
225
  n.setTitle(
197
- /* @__PURE__ */ o(E, { children: [
226
+ /* @__PURE__ */ s(S, { children: [
198
227
  "Loading: ",
199
- /* @__PURE__ */ o("u", { children: s.title })
228
+ /* @__PURE__ */ s("u", { children: r.title })
200
229
  ] })
201
230
  ), n.setContent(
202
- /* @__PURE__ */ o(
231
+ /* @__PURE__ */ s(
203
232
  "section",
204
233
  {
205
234
  className: "ipe-quickEdit-loading",
@@ -210,7 +239,7 @@ class k extends (U = A) {
210
239
  justifyContent: "center",
211
240
  alignItems: "center"
212
241
  },
213
- children: /* @__PURE__ */ o(D, {})
242
+ children: /* @__PURE__ */ s(D, {})
214
243
  }
215
244
  )
216
245
  ), n.addButton({
@@ -221,42 +250,42 @@ class k extends (U = A) {
221
250
  method() {
222
251
  n.close();
223
252
  }
224
- }), n.show(), this.ctx.emit("quick-edit/show-modal", { ctx: this.ctx, modal: n, options: s });
253
+ }), n.show(), this.ctx.emit("quick-edit/show-modal", { ctx: this.ctx, modal: n, options: r });
225
254
  let l;
226
255
  try {
227
- l = await this.getWikiPageFromPayload(s);
256
+ if (l = await this.getWikiPageFromPayload(r), l.pageInfo.special)
257
+ throw new Error("Special page is not editable");
228
258
  } catch (d) {
229
- n.close(), this.ctx.modal.notify("error", {
230
- title: "Error",
259
+ n.off(n.Event.Close), n.close(), this.ctx.modal.notify("error", {
231
260
  content: d instanceof Error ? d.message : String(d)
232
261
  });
233
262
  return;
234
263
  }
235
264
  n.setTitle(
236
- /* @__PURE__ */ o(E, { children: [
265
+ /* @__PURE__ */ s(S, { children: [
237
266
  "Quick ",
238
267
  l.pageInfo.pageid === 0 ? "Create" : "Edit",
239
268
  ":",
240
269
  " ",
241
- /* @__PURE__ */ o("u", { children: l.pageInfo.title })
270
+ /* @__PURE__ */ s("u", { children: l.pageInfo.title })
242
271
  ] })
243
272
  );
244
273
  const u = [];
245
274
  l.pageInfo.pageid === 0 && u.push(
246
- /* @__PURE__ */ o(y, { title: "Attention", type: "important", children: /* @__PURE__ */ o("p", { children: "This page does not exist." }) })
275
+ /* @__PURE__ */ s(E, { title: "Attention", type: "important", children: /* @__PURE__ */ s("p", { children: "This page does not exist." }) })
247
276
  ), l.pageInfo.pageid && l.pageInfo.lastrevid !== l.revisions[0]?.revid && u.push(
248
- /* @__PURE__ */ o(y, { title: "Attention", type: "warning", children: /* @__PURE__ */ o("p", { children: "You are editing a revision that is not the latest." }) })
277
+ /* @__PURE__ */ s(E, { title: "Attention", type: "warning", children: /* @__PURE__ */ s("p", { children: "You are editing a revision that is not the latest." }) })
249
278
  ), this.ctx.emit("quick-edit/edit-notice", {
250
279
  ctx: this.ctx,
251
- options: s,
280
+ options: r,
252
281
  modal: n,
253
282
  wikiPage: l,
254
283
  editNotices: u
255
284
  });
256
- const p = /* @__PURE__ */ o("form", { className: "ipe-quickEdit__form", children: [
257
- /* @__PURE__ */ o("div", { className: "ipe-quickEdit__notices", children: u }),
258
- /* @__PURE__ */ o("div", { className: "ipe-quickEdit__content", children: /* @__PURE__ */ o("textarea", { className: "ipe-quickEdit__textarea", name: "text", id: "wpTextbox1", children: l.revisions[0]?.content || "" }) }),
259
- /* @__PURE__ */ o(
285
+ const p = /* @__PURE__ */ s("form", { className: "ipe-quickEdit__form", children: [
286
+ /* @__PURE__ */ s("div", { className: "ipe-quickEdit__notices", children: u }),
287
+ /* @__PURE__ */ s("div", { className: "ipe-quickEdit__content", children: /* @__PURE__ */ s("textarea", { className: "ipe-quickEdit__textarea", name: "text", id: "wpTextbox1", children: l.revisions[0]?.content || "" }) }),
288
+ /* @__PURE__ */ s(
260
289
  "div",
261
290
  {
262
291
  class: "ipe-quickEdit__options",
@@ -267,16 +296,16 @@ class k extends (U = A) {
267
296
  marginTop: "1rem"
268
297
  },
269
298
  children: [
270
- /* @__PURE__ */ o(z, { label: "Summary", id: "summary", name: "summary", value: s.editSummary }),
271
- /* @__PURE__ */ o("div", { className: "ipe-input-box", children: [
272
- /* @__PURE__ */ o("label", { htmlFor: "watchlist", style: { display: "block" }, children: "Watchlist" }),
273
- /* @__PURE__ */ o("div", { style: { display: "flex", gap: "1rem" }, children: [
274
- f.preferences,
275
- f.nochange,
276
- f.watch,
277
- f.unwatch
278
- ].map((d) => /* @__PURE__ */ o(
279
- Q,
299
+ /* @__PURE__ */ s(z, { label: "Summary", id: "summary", name: "summary", value: r.editSummary }),
300
+ /* @__PURE__ */ s("div", { className: "ipe-input-box", children: [
301
+ /* @__PURE__ */ s("label", { htmlFor: "watchlist", style: { display: "block" }, children: "Watchlist" }),
302
+ /* @__PURE__ */ s("div", { style: { display: "flex", gap: "1rem" }, children: [
303
+ g.preferences,
304
+ g.nochange,
305
+ g.watch,
306
+ g.unwatch
307
+ ].map((d) => /* @__PURE__ */ s(
308
+ U,
280
309
  {
281
310
  name: "watchlist",
282
311
  value: d,
@@ -286,9 +315,9 @@ class k extends (U = A) {
286
315
  d
287
316
  )) })
288
317
  ] }),
289
- /* @__PURE__ */ o("div", { style: { display: "flex", gap: "1rem" }, children: [
290
- /* @__PURE__ */ o(P, { name: "minor", id: "minor", checked: s.editMinor, children: "Minor edit" }),
291
- /* @__PURE__ */ o(P, { name: "reloadAfterSave", id: "reloadAfterSave", checked: s.reloadAfterSave, children: "Reload after save" })
318
+ /* @__PURE__ */ s("div", { style: { display: "flex", gap: "1rem" }, children: [
319
+ /* @__PURE__ */ s(P, { name: "minor", id: "minor", checked: r.editMinor, children: "Minor edit" }),
320
+ /* @__PURE__ */ s(P, { name: "reloadAfterSave", id: "reloadAfterSave", checked: r.reloadAfterSave, children: "Reload after save" })
292
321
  ] })
293
322
  ]
294
323
  }
@@ -302,20 +331,21 @@ class k extends (U = A) {
302
331
  label: "Submit",
303
332
  method: () => {
304
333
  const d = new FormData(p);
305
- n.setLoadingState(!0), this.handleSubmit(
306
- { ctx: this.ctx, modal: n, wikiPage: l, options: s },
307
- {
308
- text: d.get("text"),
309
- summary: d.get("summary"),
310
- minor: d.get("minor") === "on"
311
- }
312
- ).then(async () => {
334
+ n.setLoadingState(!0), this.handleSubmit({
335
+ wikiPage: l,
336
+ text: d.get("text"),
337
+ summary: d.get("summary"),
338
+ minor: d.get("minor") === "on",
339
+ section: r.section,
340
+ createonly: l.pageid === 0,
341
+ watchlist: c
342
+ }).then(async () => {
313
343
  n.setOptions({
314
- beforeClose: I
344
+ beforeClose: A
315
345
  }), n.close(), this.ctx.modal.notify("success", {
316
346
  title: "Submission Successful",
317
347
  content: "Your changes have been saved."
318
- }), d.get("reloadAfterSave") && (await R(500), location.reload());
348
+ }), d.get("reloadAfterSave") && (await re(500), location.reload());
319
349
  }).catch((h) => {
320
350
  this.ctx.modal.notify("error", {
321
351
  title: "Submission Error",
@@ -339,18 +369,18 @@ class k extends (U = A) {
339
369
  className: "is-danger is-ghost"
340
370
  },
341
371
  cancelBtn: {
342
- label: "Continue",
372
+ label: "Continue Editing",
343
373
  className: "is-primary is-ghost"
344
374
  }
345
375
  },
346
- (g) => (g && (n.setOptions({
347
- beforeClose: I
376
+ (f) => (f && (n.setOptions({
377
+ beforeClose: A
348
378
  }), n.close()), !0)
349
379
  ), !1);
350
380
  }
351
381
  }), this.ctx.emit("quick-edit/wiki-page", {
352
382
  ctx: this.ctx,
353
- options: s,
383
+ options: r,
354
384
  modal: n,
355
385
  wikiPage: l
356
386
  });
@@ -359,9 +389,9 @@ class k extends (U = A) {
359
389
  window.removeEventListener("beforeunload", v);
360
390
  });
361
391
  }
362
- handleSubmit(e, r) {
363
- const c = r.summary || "", i = r.text || "", a = r.minor || !1, s = r.createonly || !1, n = r.watchlist || f.nochange, l = e.options.section;
364
- return e.wikiPage.edit(
392
+ async handleSubmit(e) {
393
+ const o = e.wikiPage, c = e.summary || "", i = e.text || "", a = e.minor, r = e.createonly, n = e.watchlist, l = e.section;
394
+ return o.edit(
365
395
  {
366
396
  summary: c,
367
397
  text: i,
@@ -370,16 +400,25 @@ class k extends (U = A) {
370
400
  },
371
401
  {
372
402
  minor: a,
373
- createonly: s
403
+ createonly: r
374
404
  }
375
405
  );
376
406
  }
407
+ async getWikiPageFromPayload(e) {
408
+ if (e.revision)
409
+ return this.ctx.wikiPage.newFromRevision(e.revision, e.section);
410
+ if (e.pageId)
411
+ return this.ctx.wikiPage.newFromPageId(e.pageId, e.section);
412
+ if (e.title)
413
+ return this.ctx.wikiPage.newFromTitle(e.title, !1, e.section);
414
+ throw new Error("Invalid payload");
415
+ }
377
416
  injectToolbox(e) {
378
417
  e.toolbox.addButton({
379
418
  id: "quick-edit",
380
419
  group: "group1",
381
420
  index: 0,
382
- icon: /* @__PURE__ */ o(
421
+ icon: /* @__PURE__ */ s(
383
422
  "svg",
384
423
  {
385
424
  xmlns: "http://www.w3.org/2000/svg",
@@ -393,36 +432,27 @@ class k extends (U = A) {
393
432
  "stroke-linejoin": "round",
394
433
  class: "icon icon-tabler icons-tabler-outline icon-tabler-edit",
395
434
  children: [
396
- /* @__PURE__ */ o("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
397
- /* @__PURE__ */ o("path", { d: "M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" }),
398
- /* @__PURE__ */ o("path", { d: "M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" }),
399
- /* @__PURE__ */ o("path", { d: "M16 5l3 3" })
435
+ /* @__PURE__ */ s("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
436
+ /* @__PURE__ */ s("path", { d: "M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" }),
437
+ /* @__PURE__ */ s("path", { d: "M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" }),
438
+ /* @__PURE__ */ s("path", { d: "M16 5l3 3" })
400
439
  ]
401
440
  }
402
441
  ),
403
442
  tooltip: "Edit this page quickly",
404
- onClick: () => this.quickEdit({
443
+ onClick: () => this.showModal({
405
444
  revision: mw.config.get("wgRevisionId")
406
445
  })
407
446
  });
408
447
  }
409
- async getWikiPageFromPayload(e) {
410
- if (e.revision)
411
- return this.ctx.wikiPage.newFromRevision(e.revision, e.section);
412
- if (e.pageId)
413
- return this.ctx.wikiPage.newFromPageId(e.pageId, e.section);
414
- if (e.title)
415
- return this.ctx.wikiPage.newFromTitle(e.title, !1, e.section);
416
- throw new Error("Invalid payload");
417
- }
418
448
  removeToolbox(e) {
419
449
  e.toolbox.removeButton("quick-edit");
420
450
  }
421
451
  }
422
- S = oe(U);
423
- k = de(S, 0, "PluginQuickEdit", F, k);
424
- le(S, 1, k);
452
+ y = ae(F);
453
+ k = me(y, 0, "PluginQuickEdit", R, k);
454
+ he(y, 1, k);
425
455
  export {
426
456
  k as PluginQuickEdit
427
457
  };
428
- //# sourceMappingURL=index-DlE7PWxs.js.map
458
+ //# sourceMappingURL=index-Cm67r8TX.js.map