@inpageedit/core 0.7.0 → 0.8.0

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 (69) 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/CheckBox-D3rHnX7I.js.map +1 -1
  5. package/dist/IconQuickEdit-YVn1ANbm.js.map +1 -1
  6. package/dist/InputBox-BV4m05Xs.js.map +1 -1
  7. package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
  8. package/dist/RadioBox-nJqWsxW2.js.map +1 -1
  9. package/dist/__test__/utils/constants.d.ts +1 -1
  10. package/dist/components/index.js.map +1 -1
  11. package/dist/{index-1JtE4urY.js → index--xn9BebC.js} +5 -4
  12. package/dist/{index-1JtE4urY.js.map → index--xn9BebC.js.map} +1 -1
  13. package/dist/{index-CrWxZ0yl.js → index-BT1mN_St.js} +4 -4
  14. package/dist/{index-CrWxZ0yl.js.map → index-BT1mN_St.js.map} +1 -1
  15. package/dist/index-Bh70Udzi.js.map +1 -1
  16. package/dist/index-C0V2s48o.js +122 -0
  17. package/dist/index-C0V2s48o.js.map +1 -0
  18. package/dist/index-CvhkVj_L.js.map +1 -1
  19. package/dist/{index-BCMwmSfQ.js → index-DDWds9Jg.js} +77 -74
  20. package/dist/index-DDWds9Jg.js.map +1 -0
  21. package/dist/index-DDef1ojx.js +166 -0
  22. package/dist/index-DDef1ojx.js.map +1 -0
  23. package/dist/{index-B3Bsg_nE.js → index-DTA86mHU.js} +2 -2
  24. package/dist/index-DTA86mHU.js.map +1 -0
  25. package/dist/{index-2AEdgbUL.js → index-DlgTb4XY.js} +3 -3
  26. package/dist/index-DlgTb4XY.js.map +1 -0
  27. package/dist/{index-DqfQ7hp6.js → index-DpLwTw4C.js} +1507 -1326
  28. package/dist/index-DpLwTw4C.js.map +1 -0
  29. package/dist/{index-C0ci6Ll1.js → index-TzKe6Ebm.js} +7 -7
  30. package/dist/index-TzKe6Ebm.js.map +1 -0
  31. package/dist/index-VzP81S7B.js +139 -0
  32. package/dist/index-VzP81S7B.js.map +1 -0
  33. package/dist/index-lZkYoUca.js.map +1 -1
  34. package/dist/index-loWqosf7.js +331 -0
  35. package/dist/index-loWqosf7.js.map +1 -0
  36. package/dist/index.js +1 -1
  37. package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
  38. package/dist/models/WikiPage/index.d.ts +42 -47
  39. package/dist/models/WikiTitle/index.d.ts +2 -2
  40. package/dist/noop-ClDc6zv4.js.map +1 -1
  41. package/dist/plugins/in-article-links/index.d.ts +4 -34
  42. package/dist/plugins/quick-delete/index.d.ts +7 -5
  43. package/dist/plugins/quick-edit/index.d.ts +12 -10
  44. package/dist/plugins/quick-move/index.d.ts +3 -1
  45. package/dist/plugins/quick-preview/index.d.ts +12 -15
  46. package/dist/plugins/quick-redirect/index.d.ts +3 -1
  47. package/dist/plugins/toolbox/index.d.ts +7 -2
  48. package/dist/services/{SiteMetadataService.d.ts → WikiMetadataService.d.ts} +36 -21
  49. package/dist/services/WikiPageService.d.ts +8 -7
  50. package/dist/services/WikiTitleService.d.ts +43 -3
  51. package/dist/style.css +1 -1
  52. package/dist/types/{SiteMetadata.d.ts → WikiMetadata.d.ts} +17 -17
  53. package/lib/index.umd.js +28 -28
  54. package/lib/index.umd.js.map +1 -1
  55. package/lib/style.css +1 -1
  56. package/package.json +2 -2
  57. package/dist/index-2AEdgbUL.js.map +0 -1
  58. package/dist/index-2kN4SKmT.js +0 -116
  59. package/dist/index-2kN4SKmT.js.map +0 -1
  60. package/dist/index-B3Bsg_nE.js.map +0 -1
  61. package/dist/index-BCMwmSfQ.js.map +0 -1
  62. package/dist/index-C0ci6Ll1.js.map +0 -1
  63. package/dist/index-CZnu6cRK.js +0 -319
  64. package/dist/index-CZnu6cRK.js.map +0 -1
  65. package/dist/index-CheNjwas.js +0 -128
  66. package/dist/index-CheNjwas.js.map +0 -1
  67. package/dist/index-DqfQ7hp6.js.map +0 -1
  68. package/dist/index-sfkutNHj.js +0 -201
  69. package/dist/index-sfkutNHj.js.map +0 -1
@@ -1,201 +0,0 @@
1
- import { j as A } from "./index-CvhkVj_L.js";
2
- import { B as q, m as B, I as T, S as g } from "./index-DqfQ7hp6.js";
3
- import { R } from "./Preferences-Bg3J5Ur9.js";
4
- import { I as j } from "./IconQuickEdit-YVn1ANbm.js";
5
- var W = Object.create, v = Object.defineProperty, M = Object.getOwnPropertyDescriptor, I = (i, e) => (e = Symbol[i]) ? e : Symbol.for("Symbol." + i), P = (i) => {
6
- throw TypeError(i);
7
- }, U = (i, e, t) => e in i ? v(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, K = (i, e) => v(i, "name", { value: e, configurable: !0 }), C = (i) => [, , , W(i?.[I("metadata")] ?? null)], H = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], y = (i) => i !== void 0 && typeof i != "function" ? P("Function expected") : i, N = (i, e, t, n, s) => ({ kind: H[i], name: e, metadata: n, addInitializer: (l) => t._ ? P("Already initialized") : s.push(y(l || null)) }), O = (i, e) => U(e, I("metadata"), i[3]), F = (i, e, t, n) => {
8
- for (var s = 0, l = i[e >> 1], r = l && l.length; s < r; s++) l[s].call(t);
9
- return n;
10
- }, Q = (i, e, t, n, s, l) => {
11
- var r, a, o, d = e & 7, c = !1, f = 0, p = i[f] || (i[f] = []), k = d && (s = s.prototype, d < 5 && (d > 3 || !c) && M(s, t));
12
- K(s, t);
13
- for (var h = n.length - 1; h >= 0; h--)
14
- o = N(d, t, a = {}, i[3], p), r = (0, n[h])(s, o), a._ = 1, y(r) && (s = r);
15
- return O(i, s), k && v(s, t, k), c ? d ^ 4 ? l : k : s;
16
- }, x, w, L;
17
- x = [T(["sitemeta", "wikiTitle", "preferences"]), R(
18
- g.object({
19
- "inArticleLinks.enable": g.boolean().description("Whether to enable in-article links").default(!0),
20
- "inArticleLinks.quickDiff.enable": g.boolean().description("Whether to enable in-article links for quick diff").default(!0),
21
- "inArticleLinks.quickEdit.enable": g.boolean().description("Whether to enable in-article links for quick edit").default(!0),
22
- "inArticleLinks.quickEdit.redlinks": g.boolean().description("Whether to show quick edit button for redlinks").default(!0)
23
- }).description("In-article links preferences").extra("category", "in-article-links")
24
- )];
25
- let _ = class E extends (L = q) {
26
- constructor(e) {
27
- super(
28
- e,
29
- {
30
- wikiBaseUrl: e.sitemeta.baseUrl,
31
- wikiArticlePath: e.sitemeta.articlePath.replace("$1", ""),
32
- wikiArticleBaseUrl: e.sitemeta.articleBaseUrl.replace("$1", ""),
33
- wikiScriptBaseUrl: e.sitemeta.scriptBaseUrl,
34
- linkClassName: "ipe__in-article-link"
35
- },
36
- "InArticleLinks"
37
- ), this._cachedAnchorInfo = /* @__PURE__ */ new WeakMap(), this.ctx.set("inArticleLinks", this), this.ctx.preferences.defineCategory({
38
- label: "In Article Links",
39
- name: "in-article-links",
40
- description: "In-article links preferences",
41
- index: 9
42
- });
43
- }
44
- async start() {
45
- await this.ctx.preferences.get("inArticleLinks.quickEdit.enable") && this.handleQuickEdit(), await this.ctx.preferences.get("inArticleLinks.quickDiff.enable") && this.handleQuickDiff();
46
- }
47
- async stop() {
48
- }
49
- isWikiLink(e) {
50
- return e.startsWith(this.config.wikiArticleBaseUrl) || e.startsWith(this.config.wikiScriptBaseUrl + "/index.php");
51
- }
52
- static {
53
- this.REG_SKIPPED_HREF = /^(#|javascript:|vbscript:|file:)/i;
54
- }
55
- validateHrefAttr(e) {
56
- return typeof e != "string" ? !1 : !E.REG_SKIPPED_HREF.test(e);
57
- }
58
- parseAnchor(e) {
59
- if (!(e instanceof HTMLAnchorElement))
60
- return null;
61
- const t = this._cachedAnchorInfo.get(e);
62
- if (t)
63
- return t;
64
- const n = e.getAttribute("href") || "";
65
- if (!this.validateHrefAttr(n))
66
- return null;
67
- const s = e.href || "", l = this.parseLink(s);
68
- if (!l)
69
- return null;
70
- const r = {
71
- $el: e,
72
- kind: e.closest('[typeof^="mw:File"]') ? "mw:File" : "normal",
73
- external: e.classList.contains("external") || !!n.startsWith("http"),
74
- redlink: e.classList.contains("new") || l.params.has("redlink"),
75
- ...l
76
- };
77
- return this._cachedAnchorInfo.set(e, r), r;
78
- }
79
- parseLink(e) {
80
- if (!e || typeof e == "string" && !this.validateHrefAttr(e))
81
- return null;
82
- const t = B(e);
83
- if (!this.isWikiLink(t.toString()))
84
- return null;
85
- const n = t.searchParams, s = t.hash.replace("#", ""), l = n.get("action") || "view", r = t.pathname.endsWith(".php") ? n.get("title") : (() => {
86
- try {
87
- return decodeURI(t.pathname.substring(this.config.wikiArticlePath.length));
88
- } catch (a) {
89
- return this.logger.error("parseLink", t, a), null;
90
- }
91
- })();
92
- return r ? {
93
- url: t,
94
- params: n,
95
- hash: s,
96
- action: l,
97
- title: this.ctx.wikiTitle.create(r)
98
- } : null;
99
- }
100
- scanAnchors(e) {
101
- const t = e.querySelectorAll("a[href]");
102
- return Array.from(t).map((n) => this.parseAnchor(n)).filter((n) => n !== null);
103
- }
104
- async handleQuickEdit() {
105
- let e = !1;
106
- const t = await this.ctx.preferences.get(
107
- "inArticleLinks.quickEdit.redlinks"
108
- );
109
- this.ctx.inject(["quickEdit"], (n) => {
110
- e = !0, n.on("dispose", () => {
111
- e = !1;
112
- }), window?.mw?.hook?.("wikipage.content").add((s) => {
113
- if (!e)
114
- return;
115
- this.scanAnchors(s.get(0)).filter(({ action: r, title: a, redlink: o }) => (["edit", "create"].includes(r) || a.isSpecial("edit")) && // 添加对showButtonOnRedlinks的判断
116
- (t || !o)).forEach(({ $el: r, title: a, params: o }) => {
117
- if (r.dataset.ipeEditMounted)
118
- return;
119
- if (r.dataset.ipeEditMounted = "1", o.has("preload") || o.has("redo"))
120
- return this.ctx.logger.debug(r, "Not compatible with quick edit");
121
- let c;
122
- if (a.getNamespaceId() === -1) {
123
- const u = a.getMainDBKey().split("/").slice(1).join("/") || "";
124
- if (a.isSpecial("edit"))
125
- c = u;
126
- else if (a.isSpecial("talkpage")) {
127
- const m = a.newTitle(u).getTalkPage();
128
- if (!m)
129
- return this.ctx.logger.debug(r, "Talk page not found.");
130
- c = m.getPrefixedDBKey();
131
- } else if (a.isSpecial("mypage"))
132
- c = a.newTitle(this.ctx.sitemeta.userInfo.name, 2).getPrefixedDBKey() + (u ? `/${u}` : "");
133
- else if (a.isSpecial("mytalk"))
134
- c = a.newTitle(this.ctx.sitemeta.userInfo.name, 3).getPrefixedDBKey() + (u ? `/${u}` : "");
135
- else
136
- return this.ctx.logger.debug(r, "Special page cannot be edited");
137
- } else
138
- c = a.getPrefixedDBKey();
139
- const f = o.get("section")?.replace(/^T-/, "") || void 0, p = o.get("oldid"), k = o.has("redlink");
140
- let h;
141
- f === "new" ? h = "new" : f && /^\d+$/.test(f) && (h = parseInt(f, 10));
142
- const S = p ? parseInt(p, 10) : void 0, b = {
143
- title: c,
144
- section: h,
145
- revision: S,
146
- createOnly: k
147
- }, D = /* @__PURE__ */ A(
148
- "a",
149
- {
150
- href: "#ipe://quick-edit/",
151
- dataset: b,
152
- className: `${this.config.linkClassName} ipe-quick-edit ${k ? "ipe-quick-edit--create-only" : ""}`,
153
- style: {
154
- userSelect: "none",
155
- marginLeft: "0.2em",
156
- verticalAlign: "middle"
157
- },
158
- onClick: (u) => {
159
- u.preventDefault(), n.quickEdit.showModal(b);
160
- },
161
- children: /* @__PURE__ */ A(j, { style: "width: 1em; height: 1em" })
162
- }
163
- );
164
- r.insertAdjacentElement("afterend", D);
165
- });
166
- });
167
- });
168
- }
169
- handleQuickDiff() {
170
- let e = !1;
171
- const t = (n) => ["prev", "next", "cur"].includes(n);
172
- this.ctx.inject(["quickDiff"], (n) => {
173
- e = !0, n.on("dispose", () => {
174
- e = !1;
175
- }), window?.mw?.hook?.("wikipage.content").add((s) => {
176
- if (!e)
177
- return;
178
- this.scanAnchors(s.get(0)).filter(({ params: r, title: a }) => r.has("diff") || a.isSpecial("diff")).forEach(({ $el: r, title: a, params: o }) => {
179
- if (r.dataset.ipeDiffMounted)
180
- return;
181
- r.dataset.ipeDiffMounted = "1";
182
- let d, c;
183
- if (a.getNamespaceId() === -1 ? [, d, c] = a.getMainDBKey().split("/") : (d = o.get("diff"), c = o.get("oldid")), !d || !c)
184
- return;
185
- const f = {};
186
- t(d) ? (f.fromrev = parseInt(c), f.torelative = d) : (f.fromrev = parseInt(c), f.torev = parseInt(d)), r.addEventListener("click", (p) => {
187
- p.preventDefault(), n.quickDiff.comparePages(f);
188
- });
189
- });
190
- });
191
- });
192
- }
193
- };
194
- w = C(L);
195
- _ = Q(w, 0, "PluginInArticleLinks", x, _);
196
- F(w, 1, _);
197
- let V = _;
198
- export {
199
- V as PluginInArticleLinks
200
- };
201
- //# sourceMappingURL=index-sfkutNHj.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-sfkutNHj.js","sources":["../src/plugins/in-article-links/index.tsx"],"sourcesContent":["import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { IWikiTitle } from '@/models/WikiTitle/index.js'\nimport { CompareApiRequestOptions } from '../quick-diff/PluginQuickDiffCore.js'\nimport { QuickEditOptions } from '../quick-edit/index.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n inArticleLinks: PluginInArticleLinks\n }\n}\n\nexport interface InArticleWikiLinkInfo {\n title: IWikiTitle\n url: URL\n params: URLSearchParams\n hash: string\n action: 'view' | 'edit' | 'create' | 'diff' | string\n}\n\nexport interface InArticleWikiAnchorInfo extends InArticleWikiLinkInfo {\n $el: HTMLAnchorElement\n kind: 'normal' | 'mw:File'\n external: boolean\n redlink: boolean\n}\n\n@Inject(['sitemeta', 'wikiTitle', 'preferences'])\n@RegisterPreferences(\n Schema.object({\n 'inArticleLinks.enable': Schema.boolean()\n .description('Whether to enable in-article links')\n .default(true),\n 'inArticleLinks.quickDiff.enable': Schema.boolean()\n .description('Whether to enable in-article links for quick diff')\n .default(true),\n 'inArticleLinks.quickEdit.enable': Schema.boolean()\n .description('Whether to enable in-article links for quick edit')\n .default(true),\n 'inArticleLinks.quickEdit.redlinks': Schema.boolean()\n .description('Whether to show quick edit button for redlinks')\n .default(true),\n })\n .description('In-article links preferences')\n .extra('category', 'in-article-links')\n)\nexport class PluginInArticleLinks extends BasePlugin<{\n /**\n * @example \"https://example.com\"\n */\n wikiBaseUrl: string\n /**\n * Article path, with trailing slash\n * @example \"/wiki/\" (if wgArticlePath is \"/wiki/$1\")\n */\n wikiArticlePath: string\n /**\n * Article base URL, with trailing slash\n * @example \"https://example.com/wiki/\" (if wgArticlePath is \"/wiki/$1\")\n */\n wikiArticleBaseUrl: string\n /**\n * Script base URL, **without** trailing slash\n * @example \"https://example.com/w\" (if wgScriptPath is \"/w\")\n */\n wikiScriptBaseUrl: string\n linkClassName: string\n}> {\n constructor(ctx: InPageEdit) {\n super(\n ctx,\n {\n wikiBaseUrl: ctx.sitemeta.baseUrl,\n wikiArticlePath: ctx.sitemeta.articlePath.replace('$1', ''),\n wikiArticleBaseUrl: ctx.sitemeta.articleBaseUrl.replace('$1', ''),\n wikiScriptBaseUrl: ctx.sitemeta.scriptBaseUrl,\n linkClassName: 'ipe__in-article-link',\n },\n 'InArticleLinks'\n )\n this.ctx.set('inArticleLinks', this)\n\n this.ctx.preferences.defineCategory({\n label: 'In Article Links',\n name: 'in-article-links',\n description: 'In-article links preferences',\n index: 9,\n })\n }\n\n protected async start() {\n // TODO: 这些都不应该硬编码,暂时先这样\n if (await this.ctx.preferences.get<boolean>('inArticleLinks.quickEdit.enable')) {\n this.handleQuickEdit()\n }\n if (await this.ctx.preferences.get<boolean>('inArticleLinks.quickDiff.enable')) {\n this.handleQuickDiff()\n }\n }\n\n protected async stop() {}\n\n isWikiLink(url: string): boolean {\n return (\n url.startsWith(this.config.wikiArticleBaseUrl) ||\n url.startsWith(this.config.wikiScriptBaseUrl + '/index.php')\n )\n }\n\n static readonly REG_SKIPPED_HREF = /^(#|javascript:|vbscript:|file:)/i\n private validateHrefAttr(href: string | null): boolean {\n if (typeof href !== 'string') {\n return false\n }\n return !PluginInArticleLinks.REG_SKIPPED_HREF.test(href)\n }\n\n private _cachedAnchorInfo = new WeakMap<HTMLAnchorElement, InArticleWikiAnchorInfo>()\n parseAnchor(anchor: HTMLAnchorElement): InArticleWikiAnchorInfo | null {\n // 不是链接元素\n if (!(anchor instanceof HTMLAnchorElement)) {\n return null\n }\n\n const cached = this._cachedAnchorInfo.get(anchor)\n if (cached) {\n return cached\n }\n\n const attrHref = anchor.getAttribute('href') || ''\n if (!this.validateHrefAttr(attrHref)) {\n return null\n }\n const href = anchor.href || ''\n const linkInfo = this.parseLink(href)\n if (!linkInfo) {\n return null\n }\n\n const info: InArticleWikiAnchorInfo = {\n $el: anchor,\n kind: anchor.closest('[typeof^=\"mw:File\"]') ? 'mw:File' : 'normal',\n external: anchor.classList.contains('external') || !!attrHref.startsWith('http'),\n redlink: anchor.classList.contains('new') || linkInfo.params.has('redlink'),\n ...linkInfo,\n }\n this._cachedAnchorInfo.set(anchor, info)\n return info\n }\n\n parseLink(link: string | URL): InArticleWikiLinkInfo | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'string' && !this.validateHrefAttr(link)) {\n return null\n }\n\n const url = makeURL(link)\n if (!this.isWikiLink(url.toString())) {\n return null\n }\n\n const params = url.searchParams\n const hash = url.hash.replace('#', '')\n const action = params.get('action') || 'view'\n const titleText = url.pathname.endsWith('.php')\n ? params.get('title')\n : (() => {\n try {\n return decodeURI(url.pathname.substring(this.config.wikiArticlePath.length))\n } catch (e) {\n this.logger.error('parseLink', url, e)\n return null\n }\n })()\n\n if (!titleText) {\n return null\n }\n\n return {\n url,\n params,\n hash,\n action,\n title: this.ctx.wikiTitle.create(titleText),\n }\n }\n\n scanAnchors(parent: HTMLElement): InArticleWikiAnchorInfo[] {\n const anchors = parent.querySelectorAll<HTMLAnchorElement>('a[href]')\n return Array.from(anchors)\n .map((anchor) => this.parseAnchor(anchor))\n .filter((anchor) => anchor !== null)\n }\n\n async handleQuickEdit() {\n let enable = false\n const showButtonOnRedlinks = await this.ctx.preferences.get<boolean>(\n 'inArticleLinks.quickEdit.redlinks'\n )\n\n this.ctx.inject(['quickEdit'], (ctx) => {\n enable = true\n ctx.on('dispose', () => {\n enable = false\n })\n\n window?.mw?.hook?.('wikipage.content').add(($content) => {\n if (!enable) {\n return\n }\n const anchors = this.scanAnchors($content.get(0)!).filter(({ action, title, redlink }) => {\n return (\n (['edit', 'create'].includes(action) || title.isSpecial('edit')) &&\n // 添加对showButtonOnRedlinks的判断\n (showButtonOnRedlinks || !redlink)\n )\n })\n anchors.forEach(({ $el, title, params }) => {\n if ($el.dataset.ipeEditMounted) {\n return\n }\n $el.dataset.ipeEditMounted = '1'\n\n const notCompatible = params.has('preload') || params.has('redo')\n if (notCompatible) {\n return this.ctx.logger.debug($el, `Not compatible with quick edit`)\n }\n\n let titleText: string\n if (title.getNamespaceId() === -1) {\n const sub = title.getMainDBKey().split('/').slice(1).join('/') || ''\n if (title.isSpecial('edit')) {\n titleText = sub\n } else if (title.isSpecial('talkpage')) {\n const talkPage = title.newTitle(sub).getTalkPage()\n if (!talkPage) {\n return this.ctx.logger.debug($el, `Talk page not found.`)\n }\n titleText = talkPage.getPrefixedDBKey()\n } else if (title.isSpecial('mypage')) {\n const userPage = title.newTitle(this.ctx.sitemeta.userInfo.name, 2)\n titleText = userPage.getPrefixedDBKey() + (sub ? `/${sub}` : '')\n } else if (title.isSpecial('mytalk')) {\n const userTalkPage = title.newTitle(this.ctx.sitemeta.userInfo.name, 3)\n titleText = userTalkPage.getPrefixedDBKey() + (sub ? `/${sub}` : '')\n } else {\n return this.ctx.logger.debug($el, `Special page cannot be edited`)\n }\n } else {\n titleText = title.getPrefixedDBKey()\n }\n\n const sectionRaw = params.get('section')?.replace(/^T-/, '') || undefined\n const revisionRaw = params.get('oldid')\n const createOnly = params.has('redlink')\n\n let section: 'new' | number | undefined = undefined\n if (sectionRaw === 'new') {\n section = 'new'\n } else if (sectionRaw && /^\\d+$/.test(sectionRaw)) {\n section = parseInt(sectionRaw, 10)\n }\n\n const revision = revisionRaw ? parseInt(revisionRaw, 10) : undefined\n\n const payload: Partial<QuickEditOptions> = {\n title: titleText,\n section,\n revision,\n createOnly,\n }\n\n const link = (\n <a\n href={`#ipe://quick-edit/`}\n dataset={payload as any}\n className={`${this.config.linkClassName} ipe-quick-edit ${createOnly ? 'ipe-quick-edit--create-only' : ''}`}\n style={{\n userSelect: 'none',\n marginLeft: '0.2em',\n verticalAlign: 'middle',\n }}\n onClick={(e) => {\n e.preventDefault()\n ctx.quickEdit.showModal(payload)\n }}\n >\n <IconQuickEdit style=\"width: 1em; height: 1em\" />\n </a>\n )\n\n $el.insertAdjacentElement('afterend', link)\n })\n })\n })\n }\n\n handleQuickDiff() {\n let enable = false\n const isRelative = (str: string): str is 'prev' | 'next' | 'cur' =>\n ['prev', 'next', 'cur'].includes(str)\n\n this.ctx.inject(['quickDiff'], (ctx) => {\n enable = true\n ctx.on('dispose', () => {\n enable = false\n })\n\n window?.mw?.hook?.('wikipage.content').add(($content) => {\n if (!enable) {\n return\n }\n const anchors = this.scanAnchors($content.get(0)!).filter(({ params, title }) => {\n return params.has('diff') || title.isSpecial('diff')\n })\n anchors.forEach(({ $el, title, params }) => {\n if ($el.dataset.ipeDiffMounted) {\n return\n }\n $el.dataset.ipeDiffMounted = '1'\n\n let diff: string | null\n let oldid: string | null\n if (title.getNamespaceId() === -1) {\n // prettier-ignore\n ;[/** special page name */, diff, oldid] = title.getMainDBKey().split('/')\n } else {\n diff = params.get('diff')\n oldid = params.get('oldid')\n }\n if (!diff || !oldid) {\n return\n }\n\n const compare: Partial<CompareApiRequestOptions> = {}\n if (isRelative(diff)) {\n compare.fromrev = parseInt(oldid)\n compare.torelative = diff\n } else {\n compare.fromrev = parseInt(oldid)\n compare.torev = parseInt(diff)\n }\n\n $el.addEventListener('click', (e) => {\n e.preventDefault()\n ctx.quickDiff.comparePages(compare)\n })\n })\n })\n })\n }\n}\n"],"names":["_PluginInArticleLinks_decorators","_init","_a","Inject","RegisterPreferences","Schema","_PluginInArticleLinks","BasePlugin","ctx","url","href","anchor","cached","attrHref","linkInfo","info","link","makeURL","params","hash","action","titleText","e","parent","anchors","enable","showButtonOnRedlinks","$content","title","redlink","$el","sub","talkPage","sectionRaw","revisionRaw","createOnly","section","revision","payload","jsx","IconQuickEdit","isRelative","str","diff","oldid","compare","__decoratorStart","__decorateElement","__runInitializers","PluginInArticleLinks"],"mappings":";;;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AA0BAF,IAAA,CAACG,EAAO,CAAC,YAAY,aAAa,aAAa,CAAC,GAC/CC;AAAA,EACCC,EAAO,OAAO;AAAA,IACZ,yBAAyBA,EAAO,QAAA,EAC7B,YAAY,oCAAoC,EAChD,QAAQ,EAAI;AAAA,IACf,mCAAmCA,EAAO,QAAA,EACvC,YAAY,mDAAmD,EAC/D,QAAQ,EAAI;AAAA,IACf,mCAAmCA,EAAO,QAAA,EACvC,YAAY,mDAAmD,EAC/D,QAAQ,EAAI;AAAA,IACf,qCAAqCA,EAAO,QAAA,EACzC,YAAY,gDAAgD,EAC5D,QAAQ,EAAI;AAAA,EAAA,CAChB,EACE,YAAY,8BAA8B,EAC1C,MAAM,YAAY,kBAAkB;AACzC,CAAA;AACO,IAAMC,IAAN,MAAMA,WAA6BJ,IAAAK,GAqBvC;AAAA,EACD,YAAYC,GAAiB;AAC3B;AAAA,MACEA;AAAA,MACA;AAAA,QACE,aAAaA,EAAI,SAAS;AAAA,QAC1B,iBAAiBA,EAAI,SAAS,YAAY,QAAQ,MAAM,EAAE;AAAA,QAC1D,oBAAoBA,EAAI,SAAS,eAAe,QAAQ,MAAM,EAAE;AAAA,QAChE,mBAAmBA,EAAI,SAAS;AAAA,QAChC,eAAe;AAAA,MAAA;AAAA,MAEjB;AAAA,IAAA,GAuCJ,KAAQ,wCAAwB,QAAA,GArC9B,KAAK,IAAI,IAAI,kBAAkB,IAAI,GAEnC,KAAK,IAAI,YAAY,eAAe;AAAA,MAClC,OAAO;A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