@inpageedit/core 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-K73DMVec.js → index-3FdvKxaN.js} +5 -5
- package/dist/{index-K73DMVec.js.map → index-3FdvKxaN.js.map} +1 -1
- package/dist/{index-Bo1hNwWJ.js → index-6bp2nmez.js} +17 -17
- package/dist/index-6bp2nmez.js.map +1 -0
- package/dist/{index-z5MR2HJ2.js → index-B0QzYk-q.js} +301 -295
- package/dist/index-B0QzYk-q.js.map +1 -0
- package/dist/{index-jKU6cYcH.js → index-BwVAO_o4.js} +5 -5
- package/dist/{index-jKU6cYcH.js.map → index-BwVAO_o4.js.map} +1 -1
- package/dist/index-CIzmjtBz.js +5170 -0
- package/dist/index-CIzmjtBz.js.map +1 -0
- package/dist/{index-D3yG7jFv.js → index-D1plOuGc.js} +32 -32
- package/dist/{index-D3yG7jFv.js.map → index-D1plOuGc.js.map} +1 -1
- package/dist/{index-mMAGhnbR.js → index-DXvJqlhL.js} +2 -2
- package/dist/{index-mMAGhnbR.js.map → index-DXvJqlhL.js.map} +1 -1
- package/dist/{index-BxR7MsNM.js → index-DlE7PWxs.js} +145 -130
- package/dist/index-DlE7PWxs.js.map +1 -0
- package/dist/{index-CUXLgVhg.js → index-DnpXoEP3.js} +4 -4
- package/dist/{index-CUXLgVhg.js.map → index-DnpXoEP3.js.map} +1 -1
- package/dist/index.js +9 -5139
- package/dist/index.js.map +1 -1
- package/dist/models/WikiPage/index.d.ts +5 -4
- package/dist/plugins/BasePlugin.d.ts +12 -4
- package/dist/plugins/in-article-links/index.d.ts +31 -0
- package/dist/plugins/quick-edit/index.d.ts +7 -3
- package/dist/plugins/quick-preview/index.d.ts +2 -2
- package/dist/plugins/toolbox/index.d.ts +2 -2
- package/dist/style.css +1 -1
- package/lib/index.umd.js +32 -32
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +20 -19
- package/dist/index-Bo1hNwWJ.js.map +0 -1
- package/dist/index-BxR7MsNM.js.map +0 -1
- package/dist/index-z5MR2HJ2.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { j as e, P as l } from "./index-CvhkVj_L.js";
|
|
2
|
-
import {
|
|
2
|
+
import { B as d } from "./index-CIzmjtBz.js";
|
|
3
3
|
import { T as m } from "./index-Bh70Udzi.js";
|
|
4
4
|
import { I as u, C as h } from "./InputBox-FIzJ-rPN.js";
|
|
5
5
|
class v extends d {
|
|
@@ -155,4 +155,4 @@ class v extends d {
|
|
|
155
155
|
export {
|
|
156
156
|
v as PluginQuickRedirect
|
|
157
157
|
};
|
|
158
|
-
//# sourceMappingURL=index-
|
|
158
|
+
//# sourceMappingURL=index-DXvJqlhL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-DXvJqlhL.js","sources":["../src/plugins/quick-redirect/index.tsx"],"sourcesContent":["import { InPageEdit } from '@/InPageEdit'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickRedirect: PluginQuickRedirect['quickRedirect']\n redirectPage: PluginQuickRedirect['redirectPage']\n }\n}\n\nexport interface RedirectPageOptions {\n from: string\n to: string\n reason?: string\n overwrite?: boolean\n}\nexport interface QuickRedirectOptions extends Partial<RedirectPageOptions> {}\n\nexport class PluginQuickRedirect extends BasePlugin {\n static readonly inject = ['api', 'wikiPage', 'modal']\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quick-redirect')\n }\n\n protected start(): Promise<void> | void {\n this.ctx.set('quickRedirect', this.quickRedirect.bind(this))\n this.ctx.set('redirectPage', this.redirectPage.bind(this))\n\n const curPageName = window.mw?.config.get('wgPageName') || ''\n const canEdit = window.mw?.config.get('wgIsProbablyEditable')\n this.ctx.inject(['toolbox'], (ctx) => {\n this.ctx = ctx\n ctx.toolbox.addButton({\n id: 'quick-redirect',\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-file-symlink\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M4 21v-4a3 3 0 0 1 3 -3h5\" />\n <path d=\"M9 17l3 -3l-3 -3\" />\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5\" />\n </svg>\n ) as HTMLElement,\n tooltip: 'Quick Redirect',\n group: 'group1',\n onClick: () => {\n this.quickRedirect(\n canEdit\n ? {\n to: curPageName,\n }\n : {}\n )\n },\n })\n this.addDisposeHandler((ctx) => {\n ctx.toolbox.removeButton('quick-redirect')\n })\n })\n }\n\n protected stop(): Promise<void> | void {}\n\n quickRedirect(options?: Partial<QuickRedirectOptions>) {\n const modal = this.ctx.modal\n .createObject({\n title: 'Quick Redirect',\n content: (<ProgressBar />) as HTMLElement,\n className: 'quick-redirect compact-buttons',\n sizeClass: 'medium',\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 overwrite: formData.get('overwrite') === 'on',\n }\n if (!options.from || !options.to) {\n this.ctx.modal.notify('error', {\n title: 'Failed to redirect',\n content: 'From and to are required.',\n })\n return\n }\n modal.setLoadingState(true)\n this.redirectPage(options)\n .then((res) => {\n modal.close()\n this.ctx.modal.notify('success', {\n title: 'Redirect successful',\n content: 'The redirect has been created.',\n })\n })\n .catch((error) => {\n modal.setLoadingState(false)\n this.ctx.modal.notify('error', {\n title: 'Failed to redirect',\n content: error instanceof Error ? error.message : String(error),\n })\n })\n }}\n >\n <TwinSwapInput\n inputs={[\n {\n label: 'From',\n name: 'from',\n value: options?.from,\n required: true,\n },\n {\n label: 'To',\n name: 'to',\n value: options?.to,\n required: true,\n },\n ]}\n />\n <InputBox label=\"Reason\" id=\"reason\" name=\"reason\" value={options?.reason} />\n <div>\n <CheckBox name=\"overwrite\" id=\"overwrite\" checked={options?.overwrite}>\n Force create redirect even if the from page already exists\n </CheckBox>\n </div>\n </form>\n ) as HTMLFormElement\n )\n modal.setButtons([\n {\n label: 'Create Redirect',\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 redirectPage(options: RedirectPageOptions) {\n const { from, to, reason = '', overwrite = false } = options\n const wikiPage = await this.ctx.wikiPage.newBlankPage({\n title: from,\n })\n const content = `#REDIRECT [[:${to}]]`\n const res = await wikiPage.edit(\n {\n text: content,\n summary: reason,\n },\n {\n createonly: !overwrite,\n }\n )\n if (res.data?.errors) {\n throw new Error(res.data.errors[0].text, { cause: res })\n }\n return res\n }\n}\n"],"names":["PluginQuickRedirect","BasePlugin","ctx","curPageName","canEdit","jsxs","jsx","options","modal","ProgressBar","formRef","el","e","formData","res","error","TwinSwapInput","InputBox","CheckBox","from","to","reason","overwrite","wikiPage","content"],"mappings":";;;;AAiBO,MAAMA,UAA4BC,EAAW;AAAA,EAGlD,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,gBAAgB,GADd,KAAA,MAAAA;AAAA,EAEnB;AAAA,EAJA,OAAA;AAAA,SAAgB,SAAS,CAAC,OAAO,YAAY,OAAO;AAAA,EAAA;AAAA,EAM1C,QAA8B;AACtC,SAAK,IAAI,IAA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,EAAS;AAAA,MACzB;AAAA,QACE,MAAMC;AAAA,QACN,SAASH;AAAA,MAAA;AAAA,MAEX;AAAA,QACE,YAAY,CAACC;AAAA,MAAA;AAAA,IACf;AAEF,QAAIR,EAAI,MAAM;AACZ,YAAM,IAAI,MAAMA,EAAI,KAAK,OAAO,CAAC,EAAE,MAAM,EAAE,OAAOA,GAAK;AAEzD,WAAOA;AAAA,EACT;AACF;"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import {
|
|
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
3
|
import { R as C } from "./Preferences-Bg3J5Ur9.js";
|
|
4
|
-
import {
|
|
5
|
-
import { I as z, C as
|
|
4
|
+
import { R as Q, M as y } from "./RadioBox-CaA8VgLu.js";
|
|
5
|
+
import { I as z, C as P } from "./InputBox-FIzJ-rPN.js";
|
|
6
6
|
import { s as R } from "./sleep-DpyIipK-.js";
|
|
7
|
-
var
|
|
7
|
+
var W = Object.create, _ = Object.defineProperty, H = Object.getOwnPropertyDescriptor, N = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), $ = (t) => {
|
|
8
8
|
throw TypeError(t);
|
|
9
|
-
},
|
|
10
|
-
for (var i = 0,
|
|
11
|
-
return
|
|
12
|
-
}, ee = (t, e, r,
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
for (var
|
|
16
|
-
|
|
17
|
-
return V(t, i),
|
|
18
|
-
}, M,
|
|
19
|
-
M = [
|
|
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);
|
|
11
|
+
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(
|
|
20
20
|
m.object({
|
|
21
21
|
redLinkEdit: m.boolean().description("Show quick edit entry after red links").default(!0)
|
|
22
22
|
}).description("In-article quick edit links"),
|
|
@@ -24,15 +24,15 @@ M = [A(["sitemeta", "quickEdit"]), C(
|
|
|
24
24
|
redLinkEdit: !0
|
|
25
25
|
}
|
|
26
26
|
)];
|
|
27
|
-
class w extends (
|
|
27
|
+
class w extends (B = A) {
|
|
28
28
|
constructor(e) {
|
|
29
|
-
const r = e.sitemeta.mwConfig,
|
|
29
|
+
const r = e.sitemeta.mwConfig, c = r.wgArticlePath.replace("$1", ""), i = `${location.protocol}//${r.wgServer.split("//")[1]}`;
|
|
30
30
|
super(
|
|
31
31
|
e,
|
|
32
32
|
{
|
|
33
33
|
wikiBaseUrl: i,
|
|
34
|
-
wikiArticlePath:
|
|
35
|
-
wikiArticleBaseUrl: `${i}${
|
|
34
|
+
wikiArticlePath: c,
|
|
35
|
+
wikiArticleBaseUrl: `${i}${c}`,
|
|
36
36
|
wikiScriptBaseUrl: `${i}${r.wgScriptPath}`,
|
|
37
37
|
linkClassName: "ipe-quickEdit__in-article-link"
|
|
38
38
|
},
|
|
@@ -42,23 +42,23 @@ class w extends (N = I) {
|
|
|
42
42
|
async start() {
|
|
43
43
|
mw.hook("wikipage.content").add(() => {
|
|
44
44
|
document.querySelectorAll("#mw-content-text a[href]").forEach((r) => {
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
45
|
+
const c = this.checkEditAnchor(r);
|
|
46
|
+
if (!c || r.dataset.ipeQuickEditLink)
|
|
47
47
|
return;
|
|
48
|
-
const i = /* @__PURE__ */
|
|
48
|
+
const i = /* @__PURE__ */ o(
|
|
49
49
|
"a",
|
|
50
50
|
{
|
|
51
|
-
href: `#/IPE/quickEdit/${
|
|
51
|
+
href: `#/IPE/quickEdit/${c.title}`,
|
|
52
52
|
className: this.config.linkClassName,
|
|
53
53
|
style: {
|
|
54
54
|
userSelect: "none",
|
|
55
55
|
marginLeft: "0.2em",
|
|
56
56
|
verticalAlign: "middle"
|
|
57
57
|
},
|
|
58
|
-
onClick: (
|
|
59
|
-
|
|
58
|
+
onClick: (a) => {
|
|
59
|
+
a.preventDefault(), this.ctx.quickEdit(c);
|
|
60
60
|
},
|
|
61
|
-
children: /* @__PURE__ */
|
|
61
|
+
children: /* @__PURE__ */ o(
|
|
62
62
|
"svg",
|
|
63
63
|
{
|
|
64
64
|
style: "width: 1em; height: 1em",
|
|
@@ -73,10 +73,10 @@ class w extends (N = I) {
|
|
|
73
73
|
"stroke-linejoin": "round",
|
|
74
74
|
class: "icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt",
|
|
75
75
|
children: [
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */
|
|
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" })
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
)
|
|
@@ -95,61 +95,61 @@ class w extends (N = I) {
|
|
|
95
95
|
const r = e.href || "";
|
|
96
96
|
if (!r.startsWith(this.config.wikiArticleBaseUrl) && !r.startsWith(this.config.wikiScriptBaseUrl))
|
|
97
97
|
return null;
|
|
98
|
-
const
|
|
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");
|
|
99
99
|
if (
|
|
100
100
|
// 不合法的 title
|
|
101
|
-
!
|
|
102
|
-
!["edit", "editsource", "editredlink", "submit"].includes(
|
|
101
|
+
!s || s.endsWith(".php") || // 不是 edit 相关操作
|
|
102
|
+
!["edit", "editsource", "editredlink", "submit"].includes(a) || // 暂时未兼容 undo
|
|
103
103
|
i.get("undo") || // 暂时未兼容 preload
|
|
104
104
|
i.get("preload")
|
|
105
105
|
)
|
|
106
106
|
return null;
|
|
107
|
-
let
|
|
108
|
-
return n === "new" ?
|
|
109
|
-
title:
|
|
110
|
-
section:
|
|
111
|
-
revision: parseInt("" +
|
|
107
|
+
let u;
|
|
108
|
+
return n === "new" ? u = "new" : n && /^\d+$/.test(n) && (u = parseInt(n, 10)), {
|
|
109
|
+
title: s,
|
|
110
|
+
section: u,
|
|
111
|
+
revision: parseInt("" + l, 10) || 0,
|
|
112
112
|
createOnly: !!i.get("redlink")
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
w = ee(
|
|
118
|
-
Z(
|
|
119
|
-
const
|
|
116
|
+
x = G(B);
|
|
117
|
+
w = ee(x, 0, "PluginQuickEditInArticleLinks", M, w);
|
|
118
|
+
Z(x, 1, w);
|
|
119
|
+
const I = () => {
|
|
120
120
|
};
|
|
121
121
|
var te = Object.create, b = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, O = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), T = (t) => {
|
|
122
122
|
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"],
|
|
124
|
-
for (var i = 0,
|
|
125
|
-
return
|
|
126
|
-
}, de = (t, e, r,
|
|
127
|
-
var
|
|
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);
|
|
125
|
+
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
128
|
ne(i, r);
|
|
129
|
-
for (var
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
},
|
|
133
|
-
|
|
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(
|
|
134
134
|
m.object({
|
|
135
135
|
editSummary: m.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),
|
|
136
136
|
editMinor: m.boolean().description("Whether to mark the edit as minor").default(!1),
|
|
137
137
|
outSideClose: m.boolean().description("Whether to close the modal outside").default(!0),
|
|
138
138
|
watchList: m.union([
|
|
139
|
-
m.const(
|
|
140
|
-
m.const(
|
|
141
|
-
m.const(
|
|
142
|
-
m.const(
|
|
143
|
-
]).description("Watchlist options").default(
|
|
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
144
|
}).description("Quick edit options").extra("category", "edit"),
|
|
145
145
|
{
|
|
146
146
|
editSummary: "[IPE-NEXT] Quick edit",
|
|
147
147
|
editMinor: !1,
|
|
148
148
|
outSideClose: !0,
|
|
149
|
-
watchList:
|
|
149
|
+
watchList: f.preferences
|
|
150
150
|
}
|
|
151
151
|
)];
|
|
152
|
-
class k extends (
|
|
152
|
+
class k extends (U = A) {
|
|
153
153
|
constructor(e) {
|
|
154
154
|
super(e, {}, "quick-edit"), this.ctx = e, this.DEFAULT_OPTIONS = {
|
|
155
155
|
title: "",
|
|
@@ -178,13 +178,13 @@ class k extends (F = I) {
|
|
|
178
178
|
pageId: mw.config.get("wgArticleId"),
|
|
179
179
|
revision: mw.config.get("wgRevisionId")
|
|
180
180
|
});
|
|
181
|
-
const r = await this.ctx.preferences.get("outSideClose"),
|
|
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 = {
|
|
182
182
|
...this.DEFAULT_OPTIONS,
|
|
183
183
|
editSummary: i,
|
|
184
|
-
editMinor:
|
|
184
|
+
editMinor: a,
|
|
185
185
|
...e
|
|
186
186
|
};
|
|
187
|
-
|
|
187
|
+
s.editSummary || (s.editSummary = await this.ctx.preferences.get("editSummary") || ""), s || this.ctx.emit("quick-edit/init-options", { ctx: this.ctx, options: s });
|
|
188
188
|
const n = this.ctx.modal.createObject({
|
|
189
189
|
className: "ipe-quickEdit",
|
|
190
190
|
sizeClass: "large",
|
|
@@ -194,12 +194,12 @@ class k extends (F = I) {
|
|
|
194
194
|
outSideClose: r
|
|
195
195
|
}).init();
|
|
196
196
|
n.setTitle(
|
|
197
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ o(E, { children: [
|
|
198
198
|
"Loading: ",
|
|
199
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ o("u", { children: s.title })
|
|
200
200
|
] })
|
|
201
201
|
), n.setContent(
|
|
202
|
-
/* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ o(
|
|
203
203
|
"section",
|
|
204
204
|
{
|
|
205
205
|
className: "ipe-quickEdit-loading",
|
|
@@ -210,7 +210,7 @@ class k extends (F = I) {
|
|
|
210
210
|
justifyContent: "center",
|
|
211
211
|
alignItems: "center"
|
|
212
212
|
},
|
|
213
|
-
children: /* @__PURE__ */
|
|
213
|
+
children: /* @__PURE__ */ o(D, {})
|
|
214
214
|
}
|
|
215
215
|
)
|
|
216
216
|
), n.addButton({
|
|
@@ -221,33 +221,45 @@ class k extends (F = I) {
|
|
|
221
221
|
method() {
|
|
222
222
|
n.close();
|
|
223
223
|
}
|
|
224
|
-
}), n.show(), this.ctx.emit("
|
|
225
|
-
let
|
|
224
|
+
}), n.show(), this.ctx.emit("quick-edit/show-modal", { ctx: this.ctx, modal: n, options: s });
|
|
225
|
+
let l;
|
|
226
226
|
try {
|
|
227
|
-
|
|
228
|
-
} catch (
|
|
227
|
+
l = await this.getWikiPageFromPayload(s);
|
|
228
|
+
} catch (d) {
|
|
229
229
|
n.close(), this.ctx.modal.notify("error", {
|
|
230
230
|
title: "Error",
|
|
231
|
-
content:
|
|
231
|
+
content: d instanceof Error ? d.message : String(d)
|
|
232
232
|
});
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
n.setTitle(
|
|
236
|
-
/* @__PURE__ */
|
|
236
|
+
/* @__PURE__ */ o(E, { children: [
|
|
237
237
|
"Quick ",
|
|
238
|
-
|
|
238
|
+
l.pageInfo.pageid === 0 ? "Create" : "Edit",
|
|
239
239
|
":",
|
|
240
240
|
" ",
|
|
241
|
-
/* @__PURE__ */
|
|
241
|
+
/* @__PURE__ */ o("u", { children: l.pageInfo.title })
|
|
242
242
|
] })
|
|
243
243
|
);
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
/* @__PURE__ */
|
|
247
|
-
|
|
244
|
+
const u = [];
|
|
245
|
+
l.pageInfo.pageid === 0 && u.push(
|
|
246
|
+
/* @__PURE__ */ o(y, { title: "Attention", type: "important", children: /* @__PURE__ */ o("p", { children: "This page does not exist." }) })
|
|
247
|
+
), 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." }) })
|
|
249
|
+
), this.ctx.emit("quick-edit/edit-notice", {
|
|
250
|
+
ctx: this.ctx,
|
|
251
|
+
options: s,
|
|
252
|
+
modal: n,
|
|
253
|
+
wikiPage: l,
|
|
254
|
+
editNotices: u
|
|
255
|
+
});
|
|
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(
|
|
248
260
|
"div",
|
|
249
261
|
{
|
|
250
|
-
class: "ipe-
|
|
262
|
+
class: "ipe-quickEdit__options",
|
|
251
263
|
style: {
|
|
252
264
|
display: "flex",
|
|
253
265
|
flexDirection: "column",
|
|
@@ -255,59 +267,59 @@ class k extends (F = I) {
|
|
|
255
267
|
marginTop: "1rem"
|
|
256
268
|
},
|
|
257
269
|
children: [
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
/* @__PURE__ */
|
|
260
|
-
/* @__PURE__ */
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
].map((
|
|
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(
|
|
267
279
|
Q,
|
|
268
280
|
{
|
|
269
281
|
name: "watchlist",
|
|
270
|
-
value:
|
|
271
|
-
inputProps: { checked:
|
|
272
|
-
children:
|
|
282
|
+
value: d,
|
|
283
|
+
inputProps: { checked: c === d },
|
|
284
|
+
children: d
|
|
273
285
|
},
|
|
274
|
-
|
|
286
|
+
d
|
|
275
287
|
)) })
|
|
276
288
|
] }),
|
|
277
|
-
/* @__PURE__ */
|
|
278
|
-
/* @__PURE__ */
|
|
279
|
-
/* @__PURE__ */
|
|
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" })
|
|
280
292
|
] })
|
|
281
293
|
]
|
|
282
294
|
}
|
|
283
295
|
),
|
|
284
296
|
!1
|
|
285
297
|
] });
|
|
286
|
-
n.setContent(
|
|
298
|
+
n.setContent(p), n.addButton(
|
|
287
299
|
{
|
|
288
300
|
side: "left",
|
|
289
301
|
className: "is-primary submit-btn",
|
|
290
302
|
label: "Submit",
|
|
291
303
|
method: () => {
|
|
292
|
-
const
|
|
304
|
+
const d = new FormData(p);
|
|
293
305
|
n.setLoadingState(!0), this.handleSubmit(
|
|
294
|
-
{ ctx: this.ctx, modal: n, wikiPage:
|
|
306
|
+
{ ctx: this.ctx, modal: n, wikiPage: l, options: s },
|
|
295
307
|
{
|
|
296
|
-
text:
|
|
297
|
-
summary:
|
|
298
|
-
minor:
|
|
308
|
+
text: d.get("text"),
|
|
309
|
+
summary: d.get("summary"),
|
|
310
|
+
minor: d.get("minor") === "on"
|
|
299
311
|
}
|
|
300
312
|
).then(async () => {
|
|
301
313
|
n.setOptions({
|
|
302
|
-
beforeClose:
|
|
314
|
+
beforeClose: I
|
|
303
315
|
}), n.close(), this.ctx.modal.notify("success", {
|
|
304
316
|
title: "Submission Successful",
|
|
305
317
|
content: "Your changes have been saved."
|
|
306
|
-
}),
|
|
307
|
-
}).catch((
|
|
318
|
+
}), d.get("reloadAfterSave") && (await R(500), location.reload());
|
|
319
|
+
}).catch((h) => {
|
|
308
320
|
this.ctx.modal.notify("error", {
|
|
309
321
|
title: "Submission Error",
|
|
310
|
-
content:
|
|
322
|
+
content: h instanceof Error ? h.message : String(h)
|
|
311
323
|
}), n.setLoadingState(!1);
|
|
312
324
|
});
|
|
313
325
|
}
|
|
@@ -315,8 +327,8 @@ class k extends (F = I) {
|
|
|
315
327
|
0
|
|
316
328
|
), n.setOptions({
|
|
317
329
|
beforeClose: () => {
|
|
318
|
-
const
|
|
319
|
-
return (
|
|
330
|
+
const d = l.revisions[0]?.content || "";
|
|
331
|
+
return (p.querySelector("textarea")?.value || "") === d ? !0 : (this.ctx.modal.confirm(
|
|
320
332
|
{
|
|
321
333
|
className: "is-primary",
|
|
322
334
|
title: "Unsaved Changes",
|
|
@@ -331,33 +343,34 @@ class k extends (F = I) {
|
|
|
331
343
|
className: "is-primary is-ghost"
|
|
332
344
|
}
|
|
333
345
|
},
|
|
334
|
-
(
|
|
335
|
-
beforeClose:
|
|
346
|
+
(g) => (g && (n.setOptions({
|
|
347
|
+
beforeClose: I
|
|
336
348
|
}), n.close()), !0)
|
|
337
349
|
), !1);
|
|
338
350
|
}
|
|
339
|
-
}), this.ctx.emit("
|
|
351
|
+
}), this.ctx.emit("quick-edit/wiki-page", {
|
|
340
352
|
ctx: this.ctx,
|
|
341
|
-
options:
|
|
353
|
+
options: s,
|
|
342
354
|
modal: n,
|
|
343
|
-
wikiPage:
|
|
355
|
+
wikiPage: l
|
|
344
356
|
});
|
|
345
|
-
const
|
|
346
|
-
window.addEventListener("beforeunload",
|
|
347
|
-
window.removeEventListener("beforeunload",
|
|
357
|
+
const v = (d) => p.querySelector("textarea")?.value === l.revisions[0]?.content ? !0 : (d.preventDefault(), "You have unsaved changes. Are you sure you want to leave?");
|
|
358
|
+
window.addEventListener("beforeunload", v), n.on(n.Event.Close, () => {
|
|
359
|
+
window.removeEventListener("beforeunload", v);
|
|
348
360
|
});
|
|
349
361
|
}
|
|
350
362
|
handleSubmit(e, r) {
|
|
351
|
-
const
|
|
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;
|
|
352
364
|
return e.wikiPage.edit(
|
|
353
365
|
{
|
|
354
|
-
summary:
|
|
366
|
+
summary: c,
|
|
355
367
|
text: i,
|
|
356
|
-
watchlist: n
|
|
368
|
+
watchlist: n,
|
|
369
|
+
section: l
|
|
357
370
|
},
|
|
358
371
|
{
|
|
359
|
-
minor:
|
|
360
|
-
createonly:
|
|
372
|
+
minor: a,
|
|
373
|
+
createonly: s
|
|
361
374
|
}
|
|
362
375
|
);
|
|
363
376
|
}
|
|
@@ -366,7 +379,7 @@ class k extends (F = I) {
|
|
|
366
379
|
id: "quick-edit",
|
|
367
380
|
group: "group1",
|
|
368
381
|
index: 0,
|
|
369
|
-
icon: /* @__PURE__ */
|
|
382
|
+
icon: /* @__PURE__ */ o(
|
|
370
383
|
"svg",
|
|
371
384
|
{
|
|
372
385
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -380,15 +393,17 @@ class k extends (F = I) {
|
|
|
380
393
|
"stroke-linejoin": "round",
|
|
381
394
|
class: "icon icon-tabler icons-tabler-outline icon-tabler-edit",
|
|
382
395
|
children: [
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
/* @__PURE__ */
|
|
386
|
-
/* @__PURE__ */
|
|
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" })
|
|
387
400
|
]
|
|
388
401
|
}
|
|
389
402
|
),
|
|
390
403
|
tooltip: "Edit this page quickly",
|
|
391
|
-
onClick: () => this.quickEdit(
|
|
404
|
+
onClick: () => this.quickEdit({
|
|
405
|
+
revision: mw.config.get("wgRevisionId")
|
|
406
|
+
})
|
|
392
407
|
});
|
|
393
408
|
}
|
|
394
409
|
async getWikiPageFromPayload(e) {
|
|
@@ -404,10 +419,10 @@ class k extends (F = I) {
|
|
|
404
419
|
e.toolbox.removeButton("quick-edit");
|
|
405
420
|
}
|
|
406
421
|
}
|
|
407
|
-
S = oe(
|
|
408
|
-
k = de(S, 0, "PluginQuickEdit",
|
|
422
|
+
S = oe(U);
|
|
423
|
+
k = de(S, 0, "PluginQuickEdit", F, k);
|
|
409
424
|
le(S, 1, k);
|
|
410
425
|
export {
|
|
411
426
|
k as PluginQuickEdit
|
|
412
427
|
};
|
|
413
|
-
//# sourceMappingURL=index-
|
|
428
|
+
//# sourceMappingURL=index-DlE7PWxs.js.map
|