@inpageedit/core 0.10.0 → 0.11.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.
- package/README.md +9 -2
- package/dist/PluginPrefSync-PIoKRRu2.js +254 -0
- package/dist/PluginPrefSync-PIoKRRu2.js.map +1 -0
- package/dist/__test__/utils/constants.d.ts +3 -2
- package/dist/constants/endpoints.d.ts +1 -1
- package/dist/{index-BR6gK_ki.js → index-B5vDBMEh.js} +44 -38
- package/dist/index-B5vDBMEh.js.map +1 -0
- package/dist/{index-BnAhw94L.js → index-BP-e8PeH.js} +2 -2
- package/dist/{index-BnAhw94L.js.map → index-BP-e8PeH.js.map} +1 -1
- package/dist/{index-ByzgI28q.js → index-BVkdBJNf.js} +6 -2
- package/dist/index-BVkdBJNf.js.map +1 -0
- package/dist/{index-eOIVMf9E.js → index-BjwVNZ_h.js} +46 -35
- package/dist/index-BjwVNZ_h.js.map +1 -0
- package/dist/{index-Cx-YiN1j.js → index-BzCqww16.js} +22 -21
- package/dist/index-BzCqww16.js.map +1 -0
- package/dist/index-CFb1PSJg.js +185 -0
- package/dist/index-CFb1PSJg.js.map +1 -0
- package/dist/{index-ByJfEsN8.js → index-D7NpqwUe.js} +148 -110
- package/dist/index-D7NpqwUe.js.map +1 -0
- package/dist/{index-Z-_kjibx.js → index-DFPN4uYd.js} +757 -698
- package/dist/index-DFPN4uYd.js.map +1 -0
- package/dist/index-DGOY4X1J.js +4912 -0
- package/dist/{index-DqJUIV2e.js.map → index-DGOY4X1J.js.map} +1 -1
- package/dist/{index-CAiGct8U.js → index-DKDtc9IF.js} +42 -42
- package/dist/index-DKDtc9IF.js.map +1 -0
- package/dist/index-DkQLtTG0.js +211 -0
- package/dist/index-DkQLtTG0.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/models/WikiTitle/index.d.ts +2 -2
- package/dist/plugins/analytics/index.d.ts +41 -0
- package/dist/plugins/in-article-links/index.d.ts +14 -0
- package/dist/plugins/preferences-ui/PluginPrefSync.d.ts +2 -0
- package/dist/plugins/preferences-ui/index.d.ts +3 -1
- package/dist/plugins/quick-delete/index.d.ts +3 -0
- package/dist/plugins/quick-diff/index.d.ts +17 -0
- package/dist/plugins/quick-edit/index.d.ts +8 -0
- package/dist/plugins/quick-move/index.d.ts +16 -0
- package/dist/plugins/quick-redirect/index.d.ts +15 -0
- package/dist/plugins/toolbox/index.d.ts +9 -0
- package/dist/services/PreferencesService.d.ts +9 -2
- package/dist/services/WikiMetadataService.d.ts +23 -23
- package/dist/style.css +1 -1
- package/dist/types/WikiMetadata.d.ts +6 -8
- package/lib/index.umd.js +24 -24
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +3 -3
- package/dist/PluginPrefSync-CNCU2DJU.js +0 -171
- package/dist/PluginPrefSync-CNCU2DJU.js.map +0 -1
- package/dist/index-2mNdeL-V.js +0 -193
- package/dist/index-2mNdeL-V.js.map +0 -1
- package/dist/index-BR6gK_ki.js.map +0 -1
- package/dist/index-ByJfEsN8.js.map +0 -1
- package/dist/index-ByzgI28q.js.map +0 -1
- package/dist/index-CAiGct8U.js.map +0 -1
- package/dist/index-Cx-YiN1j.js.map +0 -1
- package/dist/index-DqJUIV2e.js +0 -4861
- package/dist/index-Z-_kjibx.js.map +0 -1
- package/dist/index-eOIVMf9E.js.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { B as S, I as q } from "./index-
|
|
1
|
+
import { j as a, P as y } from "./index-CvhkVj_L.js";
|
|
2
|
+
import { B as S, I as q } from "./index-DFPN4uYd.js";
|
|
3
3
|
import { T as F } from "./index-Bh70Udzi.js";
|
|
4
4
|
import { C as u } from "./CheckBox-D3rHnX7I.js";
|
|
5
5
|
import { I as j } from "./InputBox-BV4m05Xs.js";
|
|
6
|
-
var E = Object.create, h = Object.defineProperty, I = Object.getOwnPropertyDescriptor,
|
|
6
|
+
var E = Object.create, h = Object.defineProperty, I = Object.getOwnPropertyDescriptor, w = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), b = (t) => {
|
|
7
7
|
throw TypeError(t);
|
|
8
|
-
}, B = (t, e, o) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, T = (t, e) => h(t, "name", { value: e, configurable: !0 }), C = (t) => [, , , E(t?.[
|
|
8
|
+
}, B = (t, e, o) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, T = (t, e) => h(t, "name", { value: e, configurable: !0 }), C = (t) => [, , , E(t?.[w("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], _ = (t) => t !== void 0 && typeof t != "function" ? b("Function expected") : t, D = (t, e, o, i, r) => ({ kind: z[t], name: e, metadata: i, addInitializer: (n) => o._ ? b("Already initialized") : r.push(_(n || null)) }), O = (t, e) => B(e, w("metadata"), t[3]), N = (t, e, o, i) => {
|
|
9
9
|
for (var r = 0, n = t[e >> 1], s = n && n.length; r < s; r++) n[r].call(o);
|
|
10
|
-
return
|
|
11
|
-
}, Q = (t, e, o,
|
|
12
|
-
var s, c, g, l = e & 7, f = !1,
|
|
10
|
+
return i;
|
|
11
|
+
}, Q = (t, e, o, i, r, n) => {
|
|
12
|
+
var s, c, g, l = e & 7, f = !1, k = 0, P = t[k] || (t[k] = []), d = l && (r = r.prototype, l < 5 && (l > 3 || !f) && I(r, o));
|
|
13
13
|
T(r, o);
|
|
14
|
-
for (var m =
|
|
15
|
-
g = D(l, o, c = {}, t[3], P), s = (0,
|
|
14
|
+
for (var m = i.length - 1; m >= 0; m--)
|
|
15
|
+
g = D(l, o, c = {}, t[3], P), s = (0, i[m])(r, g), c._ = 1, _(s) && (r = s);
|
|
16
16
|
return O(t, r), d && h(r, o, d), f ? l ^ 4 ? n : d : r;
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
class v extends (
|
|
17
|
+
}, x, p, M;
|
|
18
|
+
x = [q(["modal", "wiki"])];
|
|
19
|
+
class v extends (M = S) {
|
|
20
20
|
constructor(e) {
|
|
21
21
|
super(e, {}, "quick-move"), this.ctx = e, e.set("quickMove", this.quickMove.bind(this)), e.set("movePage", this.movePage.bind(this));
|
|
22
22
|
}
|
|
@@ -26,10 +26,10 @@ class v extends (x = S) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
injectToolbox(e) {
|
|
29
|
-
const o = window.mw?.config.get("wgPageName") || "",
|
|
29
|
+
const o = window.mw?.config.get("wgPageName") || "", i = window.mw?.config.get("wgIsProbablyEditable");
|
|
30
30
|
e.toolbox.addButton({
|
|
31
31
|
id: "quick-move",
|
|
32
|
-
icon: /* @__PURE__ */
|
|
32
|
+
icon: /* @__PURE__ */ a(
|
|
33
33
|
"svg",
|
|
34
34
|
{
|
|
35
35
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -43,13 +43,13 @@ class v extends (x = S) {
|
|
|
43
43
|
"stroke-linejoin": "round",
|
|
44
44
|
class: "icon icon-tabler icons-tabler-outline icon-tabler-forms",
|
|
45
45
|
children: [
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ a("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
47
|
+
/* @__PURE__ */ a("path", { d: "M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3" }),
|
|
48
|
+
/* @__PURE__ */ a("path", { d: "M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3" }),
|
|
49
|
+
/* @__PURE__ */ a("path", { d: "M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7" }),
|
|
50
|
+
/* @__PURE__ */ a("path", { d: "M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1" }),
|
|
51
|
+
/* @__PURE__ */ a("path", { d: "M17 12h.01" }),
|
|
52
|
+
/* @__PURE__ */ a("path", { d: "M13 12h.01" })
|
|
53
53
|
]
|
|
54
54
|
}
|
|
55
55
|
),
|
|
@@ -58,7 +58,7 @@ class v extends (x = S) {
|
|
|
58
58
|
index: 1,
|
|
59
59
|
onClick: () => {
|
|
60
60
|
this.quickMove(
|
|
61
|
-
|
|
61
|
+
i ? {
|
|
62
62
|
lockFromField: !0,
|
|
63
63
|
from: o
|
|
64
64
|
} : {}
|
|
@@ -69,26 +69,26 @@ class v extends (x = S) {
|
|
|
69
69
|
quickMove(e) {
|
|
70
70
|
const o = this.ctx.modal.createObject({
|
|
71
71
|
title: "Quick Move",
|
|
72
|
-
content: /* @__PURE__ */
|
|
72
|
+
content: /* @__PURE__ */ a(y, {}),
|
|
73
73
|
className: "quick-move compact-buttons",
|
|
74
74
|
sizeClass: "smallToMedium",
|
|
75
75
|
center: !0
|
|
76
76
|
}).init();
|
|
77
|
-
let
|
|
77
|
+
let i = null;
|
|
78
78
|
return o.setContent(
|
|
79
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ a(
|
|
80
80
|
"form",
|
|
81
81
|
{
|
|
82
|
-
ref: (r) =>
|
|
82
|
+
ref: (r) => i = r,
|
|
83
83
|
style: {
|
|
84
84
|
display: "flex",
|
|
85
85
|
flexDirection: "column",
|
|
86
86
|
gap: "1rem"
|
|
87
87
|
},
|
|
88
88
|
onSubmit: (r) => {
|
|
89
|
-
if (r.preventDefault(),
|
|
89
|
+
if (r.preventDefault(), i?.checkValidity(), !i?.reportValidity())
|
|
90
90
|
return;
|
|
91
|
-
const n = new FormData(
|
|
91
|
+
const n = new FormData(i), s = {
|
|
92
92
|
from: n.get("from")?.toString().trim(),
|
|
93
93
|
to: n.get("to")?.toString().trim(),
|
|
94
94
|
reason: n.get("reason") || "",
|
|
@@ -103,7 +103,7 @@ class v extends (x = S) {
|
|
|
103
103
|
});
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
o.setLoadingState(!0), this.movePage(s).then(() => {
|
|
106
|
+
this.ctx.emit("quick-move/submit", { ctx: this.ctx, modal: o, payload: s }), o.setLoadingState(!0), this.movePage(s).then(() => {
|
|
107
107
|
location.reload();
|
|
108
108
|
}).catch((c) => {
|
|
109
109
|
o.setLoadingState(!1), this.ctx.modal.notify("error", {
|
|
@@ -113,7 +113,7 @@ class v extends (x = S) {
|
|
|
113
113
|
});
|
|
114
114
|
},
|
|
115
115
|
children: [
|
|
116
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ a(
|
|
117
117
|
F,
|
|
118
118
|
{
|
|
119
119
|
inputs: [
|
|
@@ -132,10 +132,10 @@ class v extends (x = S) {
|
|
|
132
132
|
]
|
|
133
133
|
}
|
|
134
134
|
),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
this.ctx.wiki.hasRight("suppressredirect") && /* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
135
|
+
/* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(u, { name: "movetalk", id: "movetalk", checked: e?.movetalk, children: "Move talk page" }) }),
|
|
136
|
+
/* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(u, { name: "movesubpages", id: "movesubpages", checked: e?.movesubpages, children: "Move subpage(s) (up to 100)" }) }),
|
|
137
|
+
this.ctx.wiki.hasRight("suppressredirect") && /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(u, { name: "noredirect", id: "noredirect", checked: e?.noredirect, children: "Move without leaving a redirect" }) }),
|
|
138
|
+
/* @__PURE__ */ a(j, { label: "Reason", id: "reason", name: "reason", value: e?.reason })
|
|
139
139
|
]
|
|
140
140
|
}
|
|
141
141
|
)
|
|
@@ -144,24 +144,24 @@ class v extends (x = S) {
|
|
|
144
144
|
label: "Move",
|
|
145
145
|
className: "is-primary is-ghost",
|
|
146
146
|
method: () => {
|
|
147
|
-
|
|
147
|
+
i?.dispatchEvent(new Event("submit"));
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
]), o.show();
|
|
151
151
|
}
|
|
152
152
|
async movePage(e) {
|
|
153
|
-
const { from: o, to:
|
|
154
|
-
if (!o || !
|
|
153
|
+
const { from: o, to: i, reason: r = "", ...n } = e;
|
|
154
|
+
if (!o || !i)
|
|
155
155
|
throw new Error("From and to titles are required.");
|
|
156
|
-
if (o ===
|
|
156
|
+
if (o === i)
|
|
157
157
|
throw new Error("From and to titles cannot be the same.");
|
|
158
|
-
return (await this.ctx.wikiPage.newFromTitle(o)).moveTo(
|
|
158
|
+
return (await this.ctx.wikiPage.newFromTitle(o)).moveTo(i, r, n);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
p = C(
|
|
162
|
-
v = Q(p, 0, "PluginQuickMove",
|
|
161
|
+
p = C(M);
|
|
162
|
+
v = Q(p, 0, "PluginQuickMove", x, v);
|
|
163
163
|
N(p, 1, v);
|
|
164
164
|
export {
|
|
165
165
|
v as PluginQuickMove
|
|
166
166
|
};
|
|
167
|
-
//# sourceMappingURL=index-
|
|
167
|
+
//# sourceMappingURL=index-DKDtc9IF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DKDtc9IF.js","sources":["../src/plugins/quick-move/index.tsx"],"sourcesContent":["import { Inject, InPageEdit } from '@/InPageEdit'\nimport { IPEModal } from '@inpageedit/modal'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickMove: PluginQuickMove['quickMove']\n movePage: PluginQuickMove['movePage']\n }\n interface Events {\n 'quick-move/init-options'(payload: {\n ctx: InPageEdit\n options: Partial<QuickMoveOptions>\n }): void\n 'quick-move/show-modal'(payload: { ctx: InPageEdit; modal: IPEModal }): void\n 'quick-move/submit'(payload: {\n ctx: InPageEdit\n modal: IPEModal\n payload: MovePageOptions\n }): void\n }\n}\n\nexport interface MovePageOptions {\n from: string\n to: string\n reason?: string\n movetalk?: boolean\n movesubpages?: boolean\n noredirect?: boolean\n}\nexport interface QuickMoveOptions extends Partial<MovePageOptions> {\n lockFromField?: boolean\n lockToField?: boolean\n}\n\n@Inject(['modal', 'wiki'])\nexport class PluginQuickMove extends BasePlugin {\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quick-move')\n ctx.set('quickMove', this.quickMove.bind(this))\n ctx.set('movePage', this.movePage.bind(this))\n }\n\n protected start(): Promise<void> | void {\n this.ctx.inject(['toolbox'], (ctx) => {\n this.injectToolbox(ctx)\n })\n }\n\n private injectToolbox(ctx: InPageEdit) {\n const curPageName = window.mw?.config.get('wgPageName') || ''\n const canEdit = window.mw?.config.get('wgIsProbablyEditable')\n ctx.toolbox.addButton({\n id: 'quick-move',\n icon: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-forms\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3\" />\n <path d=\"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3\" />\n <path d=\"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7\" />\n <path d=\"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1\" />\n <path d=\"M17 12h.01\" />\n <path d=\"M13 12h.01\" />\n </svg>\n ),\n tooltip: 'Quick Move',\n group: 'group1',\n index: 1,\n onClick: () => {\n this.quickMove(\n canEdit\n ? {\n lockFromField: true,\n from: curPageName,\n }\n : {}\n )\n },\n })\n }\n\n quickMove(options?: Partial<QuickMoveOptions>) {\n const modal = this.ctx.modal\n .createObject({\n title: 'Quick Move',\n content: (<ProgressBar />) as HTMLElement,\n className: 'quick-move compact-buttons',\n sizeClass: 'smallToMedium',\n center: true,\n })\n .init()\n\n let formRef: HTMLFormElement | null = null\n modal.setContent(\n (\n <form\n ref={(el) => (formRef = el)}\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '1rem',\n }}\n onSubmit={(e) => {\n e.preventDefault()\n formRef?.checkValidity()\n if (!formRef?.reportValidity()) {\n return\n }\n const formData = new FormData(formRef!)\n const options = {\n from: formData.get('from')?.toString().trim()!,\n to: formData.get('to')?.toString().trim()!,\n reason: (formData.get('reason') as string) || '',\n movetalk: formData.get('movetalk') === 'on',\n movesubpages: formData.get('movesubpages') === 'on',\n noredirect: formData.get('noredirect') === 'on',\n }\n if (!options.from || !options.to) {\n this.ctx.modal.notify('error', {\n title: 'Failed to move',\n content: 'From and to are required.',\n })\n return\n }\n this.ctx.emit('quick-move/submit', { ctx: this.ctx, modal, payload: options })\n modal.setLoadingState(true)\n this.movePage(options)\n .then(() => {\n location.reload()\n })\n .catch((error) => {\n modal.setLoadingState(false)\n this.ctx.modal.notify('error', {\n title: 'Failed to move',\n content: error instanceof Error ? error.message : String(error),\n })\n })\n }}\n >\n <TwinSwapInput\n inputs={[\n {\n label: 'Move from',\n name: 'from',\n value: options?.from,\n required: true,\n },\n {\n label: 'Move to',\n name: 'to',\n value: options?.to,\n required: true,\n },\n ]}\n />\n <div>\n <CheckBox name=\"movetalk\" id=\"movetalk\" checked={options?.movetalk}>\n Move talk page\n </CheckBox>\n </div>\n <div>\n <CheckBox name=\"movesubpages\" id=\"movesubpages\" checked={options?.movesubpages}>\n Move subpage(s) (up to 100)\n </CheckBox>\n </div>\n {this.ctx.wiki.hasRight('suppressredirect') && (\n <div>\n <CheckBox name=\"noredirect\" id=\"noredirect\" checked={options?.noredirect}>\n Move without leaving a redirect\n </CheckBox>\n </div>\n )}\n <InputBox label=\"Reason\" id=\"reason\" name=\"reason\" value={options?.reason} />\n </form>\n ) as HTMLElement\n )\n\n modal.setButtons([\n {\n label: 'Move',\n className: 'is-primary is-ghost',\n method: () => {\n formRef?.dispatchEvent(new Event('submit'))\n },\n },\n ])\n\n return modal.show()\n }\n\n async movePage(options: MovePageOptions) {\n const { from, to, reason = '', ...rest } = options\n\n if (!from || !to) {\n throw new Error('From and to titles are required.')\n }\n if (from === to) {\n throw new Error('From and to titles cannot be the same.')\n }\n\n const wikiPage = await this.ctx.wikiPage.newFromTitle(from)\n return wikiPage.moveTo(to, reason, rest)\n }\n}\n"],"names":["_PluginQuickMove_decorators","_init","_a","Inject","PluginQuickMove","BasePlugin","ctx","curPageName","canEdit","jsxs","jsx","options","modal","ProgressBar","formRef","el","e","formData","error","TwinSwapInput","CheckBox","InputBox","from","to","reason","rest","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAmCAF,IAAA,CAACG,EAAO,CAAC,SAAS,MAAM,CAAC,CAAA;AAClB,MAAMC,WAAwBF,IAAAG,GAAW;AAAA,EAC9C,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,YAAY,GADV,KAAA,MAAAA,GAEjBA,EAAI,IAAI,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC,GAC9CA,EAAI,IAAI,YAAY,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA,EAEU,QAA8B;AACtC,SAAK,IAAI,OAAO,CAAC,SAAS,GAAG,CAACA,MAAQ;AACpC,WAAK,cAAcA,CAAG;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEQ,cAAcA,GAAiB;AACrC,UAAMC,IAAc,OAAO,IAAI,OAAO,IAAI,YAAY,KAAK,IACrDC,IAAU,OAAO,IAAI,OAAO,IAAI,sBAAsB;AAC5D,IAAAF,EAAI,QAAQ,UAAU;AAAA,MACpB,IAAI;AAAA,MACJ,MACEG,gBAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,U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GAAQC,CAAI;AAAA,EACzC;AACF;AAlLOxB,IAAAyB,EAAAxB,CAAA;AAAME,IAANuB,2BADP3B,GACaI,CAAA;AAANwB,EAAA3B,GAAA,GAAMG,CAAA;"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { j as p } from "./index-CvhkVj_L.js";
|
|
2
|
+
import { B as D, I as C, S as m } from "./index-DFPN4uYd.js";
|
|
3
|
+
import { R as P } from "./Preferences-DS4-CFWe.js";
|
|
4
|
+
import { I as j } from "./IconQuickEdit-CAL1HXIb.js";
|
|
5
|
+
var N = Object.create, w = Object.defineProperty, T = Object.getOwnPropertyDescriptor, E = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), I = (t) => {
|
|
6
|
+
throw TypeError(t);
|
|
7
|
+
}, B = (t, e, n) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, O = (t, e) => w(t, "name", { value: e, configurable: !0 }), W = (t) => [, , , N(t?.[E("metadata")] ?? null)], $ = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], q = (t) => t !== void 0 && typeof t != "function" ? I("Function expected") : t, z = (t, e, n, r, i) => ({ kind: $[t], name: e, metadata: r, addInitializer: (l) => n._ ? I("Already initialized") : i.push(q(l || null)) }), R = (t, e) => B(e, E("metadata"), t[3]), Q = (t, e, n, r) => {
|
|
8
|
+
for (var i = 0, l = t[e >> 1], s = l && l.length; i < s; i++) l[i].call(n);
|
|
9
|
+
return r;
|
|
10
|
+
}, F = (t, e, n, r, i, l) => {
|
|
11
|
+
var s, a, d, o = e & 7, c = !1, f = 0, u = t[f] || (t[f] = []), h = o && (i = i.prototype, o < 5 && (o > 3 || !c) && T(i, n));
|
|
12
|
+
O(i, n);
|
|
13
|
+
for (var k = r.length - 1; k >= 0; k--)
|
|
14
|
+
d = z(o, n, a = {}, t[3], u), s = (0, r[k])(i, d), a._ = 1, q(s) && (i = s);
|
|
15
|
+
return R(t, i), h && w(i, n, h), c ? o ^ 4 ? l : h : i;
|
|
16
|
+
}, y, _, L;
|
|
17
|
+
y = [C(["wiki", "wikiTitle", "preferences"]), P(
|
|
18
|
+
m.object({
|
|
19
|
+
"inArticleLinks.enable": m.boolean().description("Whether to enable in-article links").default(!0),
|
|
20
|
+
"inArticleLinks.quickDiff.enable": m.boolean().description("Whether to enable in-article links for quick diff").default(!0),
|
|
21
|
+
"inArticleLinks.quickEdit.enable": m.boolean().description("Whether to enable in-article links for quick edit").default(!0),
|
|
22
|
+
"inArticleLinks.quickEdit.redlinks": m.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
|
+
class g extends (L = D) {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super(
|
|
28
|
+
e,
|
|
29
|
+
{
|
|
30
|
+
linkClassName: "ipe__in-article-link"
|
|
31
|
+
},
|
|
32
|
+
"InArticleLinks"
|
|
33
|
+
), this._cachedAnchorInfo = /* @__PURE__ */ new WeakMap(), this.ctx.set("inArticleLinks", this), this.ctx.preferences.defineCategory({
|
|
34
|
+
label: "In Article Links",
|
|
35
|
+
name: "in-article-links",
|
|
36
|
+
description: "In-article links preferences",
|
|
37
|
+
index: 9
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async start() {
|
|
41
|
+
await this.ctx.preferences.get("inArticleLinks.quickEdit.enable") && this.handleQuickEdit(), await this.ctx.preferences.get("inArticleLinks.quickDiff.enable") && this.handleQuickDiff();
|
|
42
|
+
}
|
|
43
|
+
async stop() {
|
|
44
|
+
Array.from(
|
|
45
|
+
document.getElementsByClassName(this.config.linkClassName)
|
|
46
|
+
).forEach((e) => {
|
|
47
|
+
e.remove();
|
|
48
|
+
}), document.querySelectorAll("[data-ipe-edit-mounted]").forEach((e) => {
|
|
49
|
+
e.dataset.ipeEditMounted = void 0;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
parseAnchor(e) {
|
|
53
|
+
if (!(e instanceof HTMLAnchorElement))
|
|
54
|
+
return null;
|
|
55
|
+
const n = this._cachedAnchorInfo.get(e);
|
|
56
|
+
if (n)
|
|
57
|
+
return n;
|
|
58
|
+
const r = e.getAttribute("href") || "";
|
|
59
|
+
if (!this.ctx.wikiTitle.validateHrefAttr(r))
|
|
60
|
+
return null;
|
|
61
|
+
const i = e.href || "", l = this.ctx.wikiTitle.parseWikiLink(i);
|
|
62
|
+
if (!l)
|
|
63
|
+
return null;
|
|
64
|
+
const s = {
|
|
65
|
+
$el: e,
|
|
66
|
+
kind: e.closest('[typeof^="mw:File"]') ? "mw:File" : "normal",
|
|
67
|
+
external: e.classList.contains("external") || !!r.startsWith("http"),
|
|
68
|
+
redlink: e.classList.contains("new") || l.params.has("redlink"),
|
|
69
|
+
...l
|
|
70
|
+
};
|
|
71
|
+
return this._cachedAnchorInfo.set(e, s), this.ctx.emit("in-article-links/anchor-parsed", {
|
|
72
|
+
ctx: this.ctx,
|
|
73
|
+
anchor: e,
|
|
74
|
+
info: s
|
|
75
|
+
}), s;
|
|
76
|
+
}
|
|
77
|
+
scanAnchors(e, n) {
|
|
78
|
+
const r = e.querySelectorAll("a[href]");
|
|
79
|
+
return Array.from(r).map((i) => this.parseAnchor(i)).filter(
|
|
80
|
+
(i) => i !== null && (!n || n(i))
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
async handleQuickEdit() {
|
|
84
|
+
let e = !1;
|
|
85
|
+
const n = await this.ctx.preferences.get(
|
|
86
|
+
"inArticleLinks.quickEdit.redlinks"
|
|
87
|
+
);
|
|
88
|
+
this.ctx.inject(["quickEdit"], (r) => {
|
|
89
|
+
e = !0, r.on("dispose", () => {
|
|
90
|
+
e = !1;
|
|
91
|
+
}), window?.mw?.hook?.("wikipage.content").add((i) => {
|
|
92
|
+
if (!e)
|
|
93
|
+
return;
|
|
94
|
+
this.scanAnchors(i.get(0), ({ action: s, title: a, redlink: d }) => n || !d ? ["edit", "create"].includes(s) ? !0 : a?.isSpecial("edit") || a?.isSpecial("newsection") ? a.getMainText().split("/").length >= 2 : !1 : !1).forEach((s) => {
|
|
95
|
+
const { $el: a, title: d, pageId: o, params: c } = s;
|
|
96
|
+
if (a.dataset.ipeEditMounted)
|
|
97
|
+
return;
|
|
98
|
+
if (a.dataset.ipeEditMounted = "1", c.has("preload") || c.has("redo"))
|
|
99
|
+
return this.ctx.logger.debug(a, "Not compatible with quick edit");
|
|
100
|
+
const u = d?.getPrefixedDBKey() || "", h = c.get("section")?.replace(/^T-/, "") || void 0, k = c.get("oldid"), b = c.has("redlink");
|
|
101
|
+
let v;
|
|
102
|
+
h === "new" || d?.isSpecial("newsection") ? v = "new" : h && /^\d+$/.test(h) && (v = parseInt(h, 10));
|
|
103
|
+
const S = k ? parseInt(k, 10) : void 0, x = {
|
|
104
|
+
title: u,
|
|
105
|
+
pageId: o || void 0,
|
|
106
|
+
section: v,
|
|
107
|
+
revision: S,
|
|
108
|
+
createOnly: b
|
|
109
|
+
}, M = /* @__PURE__ */ p(
|
|
110
|
+
"a",
|
|
111
|
+
{
|
|
112
|
+
href: "#ipe://quick-edit/",
|
|
113
|
+
dataset: x,
|
|
114
|
+
className: `${this.config.linkClassName} ipe-quick-edit ${b ? "ipe-quick-edit--create-only" : ""}`,
|
|
115
|
+
style: {
|
|
116
|
+
userSelect: "none",
|
|
117
|
+
marginLeft: "0.2em"
|
|
118
|
+
},
|
|
119
|
+
onClick: (A) => {
|
|
120
|
+
A.preventDefault(), this.ctx.emit("in-article-links/anchor-clicked", {
|
|
121
|
+
ctx: this.ctx,
|
|
122
|
+
anchor: a,
|
|
123
|
+
info: s,
|
|
124
|
+
event: A,
|
|
125
|
+
action: "quickEdit"
|
|
126
|
+
}), r.quickEdit.showModal(x);
|
|
127
|
+
},
|
|
128
|
+
children: /* @__PURE__ */ p(j, { className: "ipe-icon" })
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
a.insertAdjacentElement("afterend", M);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
handleQuickDiff() {
|
|
137
|
+
let e = !1;
|
|
138
|
+
const n = (r) => ["prev", "next", "cur"].includes(r);
|
|
139
|
+
this.ctx.inject(["quickDiff"], (r) => {
|
|
140
|
+
e = !0, r.on("dispose", () => {
|
|
141
|
+
e = !1;
|
|
142
|
+
}), window?.mw?.hook?.("wikipage.content").add((i) => {
|
|
143
|
+
if (!e)
|
|
144
|
+
return;
|
|
145
|
+
this.scanAnchors(i.get(0), ({ params: s, title: a }) => !!(s.has("diff") || a?.isSpecial("diff"))).forEach((s) => {
|
|
146
|
+
const { $el: a, title: d, params: o } = s;
|
|
147
|
+
if (a.dataset.ipeDiffMounted)
|
|
148
|
+
return;
|
|
149
|
+
a.dataset.ipeDiffMounted = "1";
|
|
150
|
+
let c, f;
|
|
151
|
+
if (d?.getNamespaceId() === -1 ? ([, f, c] = d.getMainDBKey().split("/"), c || (c = "prev")) : (c = o.get("diff"), f = o.get("oldid")), !c || !f)
|
|
152
|
+
return;
|
|
153
|
+
const u = {};
|
|
154
|
+
n(c) ? (u.fromrev = parseInt(f), u.torelative = c) : (u.fromrev = parseInt(f), u.torev = parseInt(c));
|
|
155
|
+
const h = /* @__PURE__ */ p(
|
|
156
|
+
"a",
|
|
157
|
+
{
|
|
158
|
+
href: "#ipe://quick-diff/",
|
|
159
|
+
dataset: u,
|
|
160
|
+
className: `${this.config.linkClassName} ipe-quick-diff`,
|
|
161
|
+
style: {
|
|
162
|
+
userSelect: "none",
|
|
163
|
+
marginLeft: "0.2em"
|
|
164
|
+
},
|
|
165
|
+
onClick: (k) => {
|
|
166
|
+
k.preventDefault(), this.ctx.emit("in-article-links/anchor-clicked", {
|
|
167
|
+
ctx: this.ctx,
|
|
168
|
+
anchor: a,
|
|
169
|
+
info: s,
|
|
170
|
+
event: k,
|
|
171
|
+
action: "quickDiff"
|
|
172
|
+
}), r.quickDiff.comparePages(u);
|
|
173
|
+
},
|
|
174
|
+
children: /* @__PURE__ */ p(
|
|
175
|
+
"svg",
|
|
176
|
+
{
|
|
177
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
178
|
+
width: "24",
|
|
179
|
+
height: "24",
|
|
180
|
+
viewBox: "0 0 24 24",
|
|
181
|
+
fill: "none",
|
|
182
|
+
stroke: "currentColor",
|
|
183
|
+
"stroke-width": "2",
|
|
184
|
+
"stroke-linecap": "round",
|
|
185
|
+
"stroke-linejoin": "round",
|
|
186
|
+
class: "icon icon-tabler icons-tabler-outline icon-tabler-file-diff ipe-icon",
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ p("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
189
|
+
/* @__PURE__ */ p("path", { d: "M14 3v4a1 1 0 0 0 1 1h4" }),
|
|
190
|
+
/* @__PURE__ */ p("path", { d: "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" }),
|
|
191
|
+
/* @__PURE__ */ p("path", { d: "M12 10l0 4" }),
|
|
192
|
+
/* @__PURE__ */ p("path", { d: "M10 12l4 0" }),
|
|
193
|
+
/* @__PURE__ */ p("path", { d: "M10 17l4 0" })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
a.insertAdjacentElement("afterend", h);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
_ = W(L);
|
|
206
|
+
g = F(_, 0, "PluginInArticleLinks", y, g);
|
|
207
|
+
Q(_, 1, g);
|
|
208
|
+
export {
|
|
209
|
+
g as PluginInArticleLinks
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=index-DkQLtTG0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DkQLtTG0.js","sources":["../src/plugins/in-article-links/index.tsx"],"sourcesContent":["import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { CompareApiRequestOptions } from '../quick-diff/index.js'\nimport { QuickEditOptions } from '../quick-edit/index.js'\nimport { WikiLinkMetadata } from '@/services/WikiTitleService.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n inArticleLinks: PluginInArticleLinks\n }\n interface Events {\n 'in-article-links/anchor-parsed'(payload: {\n ctx: InPageEdit\n anchor: HTMLAnchorElement\n info: InArticleWikiAnchorMetadata\n }): void\n 'in-article-links/anchor-clicked'(payload: {\n ctx: InPageEdit\n anchor: HTMLAnchorElement\n info: InArticleWikiAnchorMetadata\n event: MouseEvent\n action: 'quickEdit' | 'quickDiff'\n }): void\n }\n}\n\nexport interface InArticleWikiAnchorMetadata extends WikiLinkMetadata {\n $el: HTMLAnchorElement\n kind: 'normal' | 'mw:File'\n external: boolean\n redlink: boolean\n}\n\n@Inject(['wiki', '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 linkClassName: string\n}> {\n constructor(ctx: InPageEdit) {\n super(\n ctx,\n {\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 Array.from(\n document.getElementsByClassName(this.config.linkClassName) as HTMLCollectionOf<HTMLElement>\n ).forEach((el) => {\n el.remove()\n })\n document.querySelectorAll<HTMLElement>('[data-ipe-edit-mounted]').forEach((el) => {\n el.dataset.ipeEditMounted = undefined\n })\n }\n\n private _cachedAnchorInfo = new WeakMap<HTMLAnchorElement, InArticleWikiAnchorMetadata>()\n parseAnchor(anchor: HTMLAnchorElement): InArticleWikiAnchorMetadata | 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.ctx.wikiTitle.validateHrefAttr(attrHref)) {\n return null\n }\n const href = anchor.href || ''\n const linkInfo = this.ctx.wikiTitle.parseWikiLink(href)\n if (!linkInfo) {\n return null\n }\n\n const info: InArticleWikiAnchorMetadata = {\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 this.ctx.emit('in-article-links/anchor-parsed', {\n ctx: this.ctx,\n anchor,\n info,\n })\n return info\n }\n\n scanAnchors(\n parent: HTMLElement,\n filter?: (info: InArticleWikiAnchorMetadata) => boolean\n ): InArticleWikiAnchorMetadata[] {\n const anchors = parent.querySelectorAll<HTMLAnchorElement>('a[href]')\n return Array.from(anchors)\n .map((anchor) => this.parseAnchor(anchor))\n .filter(\n (anchor) => anchor !== null && (!filter || filter(anchor))\n ) as InArticleWikiAnchorMetadata[]\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)!, ({ action, title, redlink }) => {\n const enabled = showButtonOnRedlinks || !redlink\n if (!enabled) {\n return false\n }\n const isActionEdit = ['edit', 'create'].includes(action)\n if (isActionEdit) {\n return true\n }\n const isSpecialEdit = title?.isSpecial('edit') || title?.isSpecial('newsection')\n if (isSpecialEdit) {\n return title!.getMainText().split('/').length >= 2\n }\n return false\n })\n anchors.forEach((info) => {\n const { $el, title, pageId, params } = info\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 const titleText = title?.getPrefixedDBKey() || ''\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' || title?.isSpecial('newsection')) {\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 pageId: pageId || undefined,\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 }}\n onClick={(e) => {\n e.preventDefault()\n this.ctx.emit('in-article-links/anchor-clicked', {\n ctx: this.ctx,\n anchor: $el,\n info,\n event: e,\n action: 'quickEdit',\n })\n ctx.quickEdit.showModal(payload)\n }}\n >\n <IconQuickEdit className=\"ipe-icon\" />\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)!, ({ params, title }) => {\n return !!(params.has('diff') || title?.isSpecial('diff'))\n })\n anchors.forEach((info) => {\n const { $el, title, params } = info\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 */, oldid, diff] = title.getMainDBKey().split('/')\n if (!diff) {\n diff = 'prev'\n }\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 const link = (\n <a\n href={`#ipe://quick-diff/`}\n dataset={compare as any}\n className={`${this.config.linkClassName} ipe-quick-diff`}\n style={{\n userSelect: 'none',\n marginLeft: '0.2em',\n }}\n onClick={(e) => {\n e.preventDefault()\n this.ctx.emit('in-article-links/anchor-clicked', {\n ctx: this.ctx,\n anchor: $el,\n info,\n event: e,\n action: 'quickDiff',\n })\n ctx.quickDiff.comparePages(compare)\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-file-diff ipe-icon\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z\" />\n <path d=\"M12 10l0 4\" />\n <path d=\"M10 12l4 0\" />\n <path d=\"M10 17l4 0\" />\n </svg>\n </a>\n )\n\n $el.insertAdjacentElement('afterend', link)\n })\n })\n })\n }\n}\n"],"names":["_PluginInArticleLinks_decorators","_init","_a","Inject","RegisterPreferences","Schema","PluginInArticleLinks","BasePlugin","ctx","el","anchor","cached","attrHref","href","linkInfo","info","parent","filter","anchors","enable","showButtonOnRedlinks","$content","action","title","redlink","$el","pageId","params","titleText","sectionRaw","revisionRaw","createOnly","section","revision","payload","link","jsx","e","IconQuickEdit","isRelative","str","diff","oldid","compare","jsxs","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAgCAF,IAAA,CAACG,EAAO,CAAC,QAAQ,aAAa,aAAa,CAAC,GAC3CC;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,MAAMC,WAA6BJ,IAAAK,GAEvC;AAA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C;AAAA,IACH,CAAC;AAAA,EACH;AACF;AA9ROlC,IAAA4C,EAAA3C,CAAA;AAAMI,IAANwC,gCAnBP9C,GAmBaM,CAAA;AAANyC,EAAA9C,GAAA,GAAMK,CAAA;"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WikiSiteInfo } from '../../types/WikiMetadata';
|
|
2
2
|
export interface IWikiTitle {
|
|
3
3
|
/**
|
|
4
4
|
* Get db key without namespace prefix
|
|
@@ -86,4 +86,4 @@ export interface WikiTitleConstructor {
|
|
|
86
86
|
new (title: string, namespace?: number): IWikiTitle;
|
|
87
87
|
create(title: string, namespace?: number): IWikiTitle;
|
|
88
88
|
}
|
|
89
|
-
export declare function createWikiTitleModel(metadata:
|
|
89
|
+
export declare function createWikiTitleModel(metadata: WikiSiteInfo): WikiTitleConstructor;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { InPageEdit } from '../../InPageEdit';
|
|
2
|
+
declare module '../../InPageEdit' {
|
|
3
|
+
interface InPageEdit {
|
|
4
|
+
analytics: PluginAnalytics;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export interface IPEBeaconPayload {
|
|
8
|
+
siteApi: string;
|
|
9
|
+
siteName?: string;
|
|
10
|
+
userId: number;
|
|
11
|
+
userName: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
usages: IPEBeaconUsage[];
|
|
14
|
+
}
|
|
15
|
+
export interface IPEBeaconUsage {
|
|
16
|
+
ts: number;
|
|
17
|
+
feature: string;
|
|
18
|
+
subtype?: string;
|
|
19
|
+
page?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class PluginAnalytics extends BasePlugin {
|
|
22
|
+
ctx: InPageEdit;
|
|
23
|
+
private _usages;
|
|
24
|
+
private _timer;
|
|
25
|
+
private readonly MAX_QUEUE_SIZE;
|
|
26
|
+
private readonly INTERVAL_MS;
|
|
27
|
+
constructor(ctx: InPageEdit);
|
|
28
|
+
protected start(): Promise<void> | void;
|
|
29
|
+
private get analyticsDashUrl();
|
|
30
|
+
private get analyticsApiBase();
|
|
31
|
+
private _setupTimer;
|
|
32
|
+
private _registerUnloadHandler;
|
|
33
|
+
private _showConfirmNotify;
|
|
34
|
+
private _initPluginListeners;
|
|
35
|
+
addEvent(feature: string, subtype?: string, page?: string): this;
|
|
36
|
+
private sendBeacon;
|
|
37
|
+
/**
|
|
38
|
+
* 清理资源
|
|
39
|
+
*/
|
|
40
|
+
protected stop(): void;
|
|
41
|
+
}
|
|
@@ -4,6 +4,20 @@ declare module '../../InPageEdit' {
|
|
|
4
4
|
interface InPageEdit {
|
|
5
5
|
inArticleLinks: PluginInArticleLinks;
|
|
6
6
|
}
|
|
7
|
+
interface Events {
|
|
8
|
+
'in-article-links/anchor-parsed'(payload: {
|
|
9
|
+
ctx: InPageEdit;
|
|
10
|
+
anchor: HTMLAnchorElement;
|
|
11
|
+
info: InArticleWikiAnchorMetadata;
|
|
12
|
+
}): void;
|
|
13
|
+
'in-article-links/anchor-clicked'(payload: {
|
|
14
|
+
ctx: InPageEdit;
|
|
15
|
+
anchor: HTMLAnchorElement;
|
|
16
|
+
info: InArticleWikiAnchorMetadata;
|
|
17
|
+
event: MouseEvent;
|
|
18
|
+
action: 'quickEdit' | 'quickDiff';
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
7
21
|
}
|
|
8
22
|
export interface InArticleWikiAnchorMetadata extends WikiLinkMetadata {
|
|
9
23
|
$el: HTMLAnchorElement;
|
|
@@ -3,6 +3,7 @@ import { CustomIPEModal } from '../../services/ModalService.js';
|
|
|
3
3
|
declare module '../../InPageEdit' {
|
|
4
4
|
interface InPageEdit {
|
|
5
5
|
preferencesUI: PluginPreferencesUI;
|
|
6
|
+
prefsModal: PluginPreferencesUI;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
export declare class PluginPreferencesUI extends BasePlugin {
|
|
@@ -11,7 +12,8 @@ export declare class PluginPreferencesUI extends BasePlugin {
|
|
|
11
12
|
protected start(): Promise<void>;
|
|
12
13
|
protected stop(): Promise<void> | void;
|
|
13
14
|
_latestModal: CustomIPEModal | null;
|
|
15
|
+
showModal(): CustomIPEModal;
|
|
16
|
+
closeModal(): void;
|
|
14
17
|
getExistingModal(): CustomIPEModal | null;
|
|
15
|
-
showModal(): void;
|
|
16
18
|
createForm(): import('vue').App<Element>;
|
|
17
19
|
}
|
|
@@ -15,6 +15,9 @@ declare module '../../InPageEdit' {
|
|
|
15
15
|
'quick-delete/delete-notice'(payload: QuickDeleteInitPayload & {
|
|
16
16
|
deleteNotices: ReactNode[];
|
|
17
17
|
}): void;
|
|
18
|
+
'quick-delete/submit'(payload: QuickDeleteSubmitPayload & {
|
|
19
|
+
ctx: InPageEdit;
|
|
20
|
+
}): void;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
export interface QuickDeleteOptions {
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { InPageEdit } from '../../InPageEdit';
|
|
2
2
|
import { IPEModal, IPEModalOptions } from '@inpageedit/modal';
|
|
3
|
+
import { IWikiPage } from '../../models/WikiPage/index.js';
|
|
3
4
|
declare module '../../InPageEdit' {
|
|
4
5
|
interface InPageEdit {
|
|
5
6
|
quickDiff: PluginQuickDiff;
|
|
6
7
|
}
|
|
8
|
+
interface Events {
|
|
9
|
+
'quick-diff/init-options'(payload: {
|
|
10
|
+
ctx: InPageEdit;
|
|
11
|
+
options: Partial<CompareApiRequestOptions>;
|
|
12
|
+
}): void;
|
|
13
|
+
'quick-diff/loaded'(payload: {
|
|
14
|
+
ctx: InPageEdit;
|
|
15
|
+
modal: IPEModal;
|
|
16
|
+
compare: CompareApiResponse['compare'];
|
|
17
|
+
}): void;
|
|
18
|
+
'quick-diff/quick-edit-modal'(payload: {
|
|
19
|
+
ctx: InPageEdit;
|
|
20
|
+
modal: IPEModal;
|
|
21
|
+
wikiPage: IWikiPage;
|
|
22
|
+
}): void;
|
|
23
|
+
}
|
|
7
24
|
}
|
|
8
25
|
export interface CompareApiRequestOptions {
|
|
9
26
|
fromtitle: string;
|
|
@@ -16,6 +16,9 @@ declare module '../../InPageEdit' {
|
|
|
16
16
|
'quick-edit/edit-notice'(payload: QuickEditEventPayload & {
|
|
17
17
|
editNotices: ReactNode[];
|
|
18
18
|
}): void;
|
|
19
|
+
'quick-edit/submit'(payload: QuickEditSubmitPayload & {
|
|
20
|
+
ctx: InPageEdit;
|
|
21
|
+
}): void;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
export interface QuickEditOptions {
|
|
@@ -57,6 +60,11 @@ export declare class PluginQuickEdit extends BasePlugin {
|
|
|
57
60
|
handleSubmit(payload: QuickEditSubmitPayload): Promise<Required<import('wiki-saikou').FexiosContext<import('wiki-saikou').MwApiResponse<{
|
|
58
61
|
success: boolean;
|
|
59
62
|
}>>>>;
|
|
63
|
+
static readonly BUILT_IN_FONT_OPTIONS: string[];
|
|
64
|
+
getEditFontOptions(): Promise<{
|
|
65
|
+
className: string;
|
|
66
|
+
fontFamily: string;
|
|
67
|
+
}>;
|
|
60
68
|
getWikiPageFromPayload(payload: Partial<QuickEditOptions>): Promise<IWikiPage>;
|
|
61
69
|
private injectToolbox;
|
|
62
70
|
protected removeToolbox(ctx: InPageEdit): void;
|