@inpageedit/core 0.8.0 → 0.8.1
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/LICENSE +20 -20
- package/README.md +55 -55
- package/dist/ActionButton-BgbTKTg7.js.map +1 -1
- package/dist/CheckBox-D3rHnX7I.js.map +1 -1
- package/dist/{IconQuickEdit-YVn1ANbm.js → IconQuickEdit-CAL1HXIb.js} +4 -4
- package/dist/IconQuickEdit-CAL1HXIb.js.map +1 -0
- package/dist/InputBox-BV4m05Xs.js.map +1 -1
- package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
- package/dist/RadioBox-nJqWsxW2.js.map +1 -1
- package/dist/__test__/utils/constants.d.ts +2 -2
- package/dist/components/index.js.map +1 -1
- package/dist/index-9M1QcjCN.js +354 -0
- package/dist/index-9M1QcjCN.js.map +1 -0
- package/dist/{index-C0V2s48o.js → index-Ba7Wkale.js} +38 -33
- package/dist/index-Ba7Wkale.js.map +1 -0
- package/dist/index-Bh70Udzi.js.map +1 -1
- package/dist/{index--xn9BebC.js → index-C8dOYIIz.js} +61 -69
- package/dist/{index--xn9BebC.js.map → index-C8dOYIIz.js.map} +1 -1
- package/dist/{index-DpLwTw4C.js → index-COlXHFRg.js} +2599 -2080
- package/dist/index-COlXHFRg.js.map +1 -0
- package/dist/{index-DTA86mHU.js → index-CeXR4lOu.js} +5 -5
- package/dist/index-CeXR4lOu.js.map +1 -0
- package/dist/index-CvhkVj_L.js.map +1 -1
- package/dist/{index-VzP81S7B.js → index-DBV8FBjA.js} +2 -2
- package/dist/index-DBV8FBjA.js.map +1 -0
- package/dist/{index-DlgTb4XY.js → index-DwyuBkCK.js} +3 -3
- package/dist/index-DwyuBkCK.js.map +1 -0
- package/dist/{index-DDWds9Jg.js → index-OBerV4GU.js} +28 -28
- package/dist/index-OBerV4GU.js.map +1 -0
- package/dist/{index-TzKe6Ebm.js → index-Tn22YSmW.js} +2 -2
- package/dist/index-Tn22YSmW.js.map +1 -0
- package/dist/index-kRdAN8h3.js +193 -0
- package/dist/index-kRdAN8h3.js.map +1 -0
- package/dist/index-lZkYoUca.js.map +1 -1
- package/dist/{index-BT1mN_St.js → index-mntCdHRr.js} +3 -3
- package/dist/{index-BT1mN_St.js.map → index-mntCdHRr.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
- package/dist/models/WikiTitle/index.d.ts +1 -0
- package/dist/noop-ClDc6zv4.js.map +1 -1
- package/dist/plugins/in-article-links/index.d.ts +1 -1
- package/dist/plugins/quick-delete/index.d.ts +1 -1
- package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +1 -1
- package/dist/plugins/quick-edit/index.d.ts +1 -1
- package/dist/plugins/quick-preview/index.d.ts +1 -1
- package/dist/services/CurrentPageService.d.ts +27 -0
- package/dist/services/{ModalService/index.d.ts → ModalService.d.ts} +4 -4
- package/dist/services/WikiTitleService.d.ts +19 -7
- package/dist/style.css +1 -1
- package/lib/index.umd.js +34 -35
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +7 -6
- package/dist/IconQuickEdit-YVn1ANbm.js.map +0 -1
- package/dist/index-C0V2s48o.js.map +0 -1
- package/dist/index-DDWds9Jg.js.map +0 -1
- package/dist/index-DDef1ojx.js +0 -166
- package/dist/index-DDef1ojx.js.map +0 -1
- package/dist/index-DTA86mHU.js.map +0 -1
- package/dist/index-DlgTb4XY.js.map +0 -1
- package/dist/index-DpLwTw4C.js.map +0 -1
- package/dist/index-TzKe6Ebm.js.map +0 -1
- package/dist/index-VzP81S7B.js.map +0 -1
- package/dist/index-loWqosf7.js +0 -331
- package/dist/index-loWqosf7.js.map +0 -1
- package/dist/services/ModalService/IPEModal.d.ts +0 -235
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { j as f } from "./index-CvhkVj_L.js";
|
|
2
|
+
import { B as M, I as D, S as m } from "./index-COlXHFRg.js";
|
|
3
|
+
import { R as C } from "./Preferences-Bg3J5Ur9.js";
|
|
4
|
+
import { I as P } from "./IconQuickEdit-CAL1HXIb.js";
|
|
5
|
+
var j = Object.create, w = Object.defineProperty, N = Object.getOwnPropertyDescriptor, A = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), E = (t) => {
|
|
6
|
+
throw TypeError(t);
|
|
7
|
+
}, T = (t, e, n) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, B = (t, e) => w(t, "name", { value: e, configurable: !0 }), O = (t) => [, , , j(t?.[A("metadata")] ?? null)], W = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], x = (t) => t !== void 0 && typeof t != "function" ? E("Function expected") : t, z = (t, e, n, s, i) => ({ kind: W[t], name: e, metadata: s, addInitializer: (c) => n._ ? E("Already initialized") : i.push(x(c || null)) }), R = (t, e) => T(e, A("metadata"), t[3]), Q = (t, e, n, s) => {
|
|
8
|
+
for (var i = 0, c = t[e >> 1], r = c && c.length; i < r; i++) c[i].call(n);
|
|
9
|
+
return s;
|
|
10
|
+
}, F = (t, e, n, s, i, c) => {
|
|
11
|
+
var r, o, u, a = e & 7, d = !1, l = 0, h = t[l] || (t[l] = []), p = a && (i = i.prototype, a < 5 && (a > 3 || !d) && N(i, n));
|
|
12
|
+
B(i, n);
|
|
13
|
+
for (var k = s.length - 1; k >= 0; k--)
|
|
14
|
+
u = z(a, n, o = {}, t[3], h), r = (0, s[k])(i, u), o._ = 1, x(r) && (i = r);
|
|
15
|
+
return R(t, i), p && w(i, n, p), d ? a ^ 4 ? c : p : i;
|
|
16
|
+
}, I, _, y;
|
|
17
|
+
I = [D(["wiki", "wikiTitle", "preferences"]), C(
|
|
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 (y = M) {
|
|
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 s = e.getAttribute("href") || "";
|
|
59
|
+
if (!this.ctx.wikiTitle.validateHrefAttr(s))
|
|
60
|
+
return null;
|
|
61
|
+
const i = e.href || "", c = this.ctx.wikiTitle.parseWikiLink(i);
|
|
62
|
+
if (!c)
|
|
63
|
+
return null;
|
|
64
|
+
const r = {
|
|
65
|
+
$el: e,
|
|
66
|
+
kind: e.closest('[typeof^="mw:File"]') ? "mw:File" : "normal",
|
|
67
|
+
external: e.classList.contains("external") || !!s.startsWith("http"),
|
|
68
|
+
redlink: e.classList.contains("new") || c.params.has("redlink"),
|
|
69
|
+
...c
|
|
70
|
+
};
|
|
71
|
+
return this._cachedAnchorInfo.set(e, r), r;
|
|
72
|
+
}
|
|
73
|
+
scanAnchors(e, n) {
|
|
74
|
+
const s = e.querySelectorAll("a[href]");
|
|
75
|
+
return Array.from(s).map((i) => this.parseAnchor(i)).filter(
|
|
76
|
+
(i) => i !== null && (!n || n(i))
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
async handleQuickEdit() {
|
|
80
|
+
let e = !1;
|
|
81
|
+
const n = await this.ctx.preferences.get(
|
|
82
|
+
"inArticleLinks.quickEdit.redlinks"
|
|
83
|
+
);
|
|
84
|
+
this.ctx.inject(["quickEdit"], (s) => {
|
|
85
|
+
e = !0, s.on("dispose", () => {
|
|
86
|
+
e = !1;
|
|
87
|
+
}), window?.mw?.hook?.("wikipage.content").add((i) => {
|
|
88
|
+
if (!e)
|
|
89
|
+
return;
|
|
90
|
+
this.scanAnchors(i.get(0), ({ action: r, title: o, redlink: u }) => n || !u ? ["edit", "create"].includes(r) ? !0 : o?.isSpecial("edit") || o?.isSpecial("newsection") ? o.getMainText().split("/").length >= 2 : !1 : !1).forEach(({ $el: r, title: o, pageId: u, params: a }) => {
|
|
91
|
+
if (r.dataset.ipeEditMounted)
|
|
92
|
+
return;
|
|
93
|
+
if (r.dataset.ipeEditMounted = "1", a.has("preload") || a.has("redo"))
|
|
94
|
+
return this.ctx.logger.debug(r, "Not compatible with quick edit");
|
|
95
|
+
const l = o?.getPrefixedDBKey() || "", h = a.get("section")?.replace(/^T-/, "") || void 0, p = a.get("oldid"), k = a.has("redlink");
|
|
96
|
+
let v;
|
|
97
|
+
h === "new" || o?.isSpecial("newsection") ? v = "new" : h && /^\d+$/.test(h) && (v = parseInt(h, 10));
|
|
98
|
+
const q = p ? parseInt(p, 10) : void 0, b = {
|
|
99
|
+
title: l,
|
|
100
|
+
pageId: u || void 0,
|
|
101
|
+
section: v,
|
|
102
|
+
revision: q,
|
|
103
|
+
createOnly: k
|
|
104
|
+
}, L = /* @__PURE__ */ f(
|
|
105
|
+
"a",
|
|
106
|
+
{
|
|
107
|
+
href: "#ipe://quick-edit/",
|
|
108
|
+
dataset: b,
|
|
109
|
+
className: `${this.config.linkClassName} ipe-quick-edit ${k ? "ipe-quick-edit--create-only" : ""}`,
|
|
110
|
+
style: {
|
|
111
|
+
userSelect: "none",
|
|
112
|
+
marginLeft: "0.2em"
|
|
113
|
+
},
|
|
114
|
+
onClick: (S) => {
|
|
115
|
+
S.preventDefault(), s.quickEdit.showModal(b);
|
|
116
|
+
},
|
|
117
|
+
children: /* @__PURE__ */ f(P, { className: "ipe-icon" })
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
r.insertAdjacentElement("afterend", L);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
handleQuickDiff() {
|
|
126
|
+
let e = !1;
|
|
127
|
+
const n = (s) => ["prev", "next", "cur"].includes(s);
|
|
128
|
+
this.ctx.inject(["quickDiff"], (s) => {
|
|
129
|
+
e = !0, s.on("dispose", () => {
|
|
130
|
+
e = !1;
|
|
131
|
+
}), window?.mw?.hook?.("wikipage.content").add((i) => {
|
|
132
|
+
if (!e)
|
|
133
|
+
return;
|
|
134
|
+
this.scanAnchors(i.get(0), ({ params: r, title: o }) => !!(r.has("diff") || o?.isSpecial("diff"))).forEach(({ $el: r, title: o, params: u }) => {
|
|
135
|
+
if (r.dataset.ipeDiffMounted)
|
|
136
|
+
return;
|
|
137
|
+
r.dataset.ipeDiffMounted = "1";
|
|
138
|
+
let a, d;
|
|
139
|
+
if (o?.getNamespaceId() === -1 ? [, a, d] = o.getMainDBKey().split("/") : (a = u.get("diff"), d = u.get("oldid")), !a || !d)
|
|
140
|
+
return;
|
|
141
|
+
const l = {};
|
|
142
|
+
n(a) ? (l.fromrev = parseInt(d), l.torelative = a) : (l.fromrev = parseInt(d), l.torev = parseInt(a));
|
|
143
|
+
const h = /* @__PURE__ */ f(
|
|
144
|
+
"a",
|
|
145
|
+
{
|
|
146
|
+
href: "#ipe://quick-diff/",
|
|
147
|
+
dataset: l,
|
|
148
|
+
className: `${this.config.linkClassName} ipe-quick-diff`,
|
|
149
|
+
style: {
|
|
150
|
+
userSelect: "none",
|
|
151
|
+
marginLeft: "0.2em"
|
|
152
|
+
},
|
|
153
|
+
onClick: (p) => {
|
|
154
|
+
p.preventDefault(), s.quickDiff.comparePages(l);
|
|
155
|
+
},
|
|
156
|
+
children: /* @__PURE__ */ f(
|
|
157
|
+
"svg",
|
|
158
|
+
{
|
|
159
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
160
|
+
width: "24",
|
|
161
|
+
height: "24",
|
|
162
|
+
viewBox: "0 0 24 24",
|
|
163
|
+
fill: "none",
|
|
164
|
+
stroke: "currentColor",
|
|
165
|
+
"stroke-width": "2",
|
|
166
|
+
"stroke-linecap": "round",
|
|
167
|
+
"stroke-linejoin": "round",
|
|
168
|
+
class: "icon icon-tabler icons-tabler-outline icon-tabler-file-diff ipe-icon",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ f("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
171
|
+
/* @__PURE__ */ f("path", { d: "M14 3v4a1 1 0 0 0 1 1h4" }),
|
|
172
|
+
/* @__PURE__ */ f("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" }),
|
|
173
|
+
/* @__PURE__ */ f("path", { d: "M12 10l0 4" }),
|
|
174
|
+
/* @__PURE__ */ f("path", { d: "M10 12l4 0" }),
|
|
175
|
+
/* @__PURE__ */ f("path", { d: "M10 17l4 0" })
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
r.insertAdjacentElement("afterend", h);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
_ = O(y);
|
|
188
|
+
g = F(_, 0, "PluginInArticleLinks", I, g);
|
|
189
|
+
Q(_, 1, g);
|
|
190
|
+
export {
|
|
191
|
+
g as PluginInArticleLinks
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=index-kRdAN8h3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-kRdAN8h3.js","sources":["../src/plugins/in-article-links/index.tsx"],"sourcesContent":["import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { CompareApiRequestOptions } from '../quick-diff/PluginQuickDiffCore.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}\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 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(({ $el, title, pageId, 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 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 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(({ $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 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 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;AAkBAF,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,IAAA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A,UAAAC,gBAAAA;AAAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,OAAM;AAAA,kBACN,OAAM;AAAA,kBACN,QAAO;AAAA,kBACP,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,QAAO;AAAA,kBACP,gBAAa;AAAA,kBACb,kBAAe;AAAA,kBACf,mBAAgB;AAAA,kBAChB,OAAM;AAAA,kBAEN,UAAA;AAAA,oBAAA,gBAAAR,EAAC,UAAK,QAAO,QAAO,GAAE,iBAAgB,MAAK,QAAO;AAAA,oBAClD,gBAAAA,EAAC,QAAA,EAAK,GAAE,0BAAA,CAA0B;AAAA,oBAClC,gBAAAA,EAAC,QAAA,EAAK,GAAE,yEAAA,CAAyE;AAAA,oBACjF,gBAAAA,EAAC,QAAA,EAAK,GAAE,aAAA,CAAa;AAAA,oBACrB,gBAAAA,EAAC,QAAA,EAAK,GAAE,aAAA,CAAa;AAAA,oBACrB,gBAAAA,EAAC,QAAA,EAAK,GAAE,aAAA,CAAa;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YACvB;AAAA,UAAA;AAIJ,UAAAX,EAAI,sBAAsB,YAAYU,CAAI;AAAA,QAC5C,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;AAtQOlC,IAAA4C,EAAA3C,CAAA;AAAMI,IAANwC,gCAnBP9C,GAmBaM,CAAA;AAANyC,EAAA9C,GAAA,GAAMK,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-lZkYoUca.js","sources":["../src/components/MBox/index.tsx"],"sourcesContent":["import { ReactNode } from 'jsx-dom'\
|
|
1
|
+
{"version":3,"file":"index-lZkYoUca.js","sources":["../src/components/MBox/index.tsx"],"sourcesContent":["import { ReactNode } from 'jsx-dom'\nimport { JSX } from 'jsx-dom/jsx-runtime'\nimport styles from './styles.module.sass'\n\nexport type MBoxProps = {\n type?:\n | ''\n | 'default'\n | 'note'\n | 'info'\n | 'tip'\n | 'success'\n | 'important'\n | 'done'\n | 'warning'\n | 'caution'\n | 'error'\n title?: ReactNode\n content?: ReactNode\n closeable?: boolean\n titleProps?: JSX.IntrinsicElements['div']\n contentProps?: JSX.IntrinsicElements['div']\n} & JSX.IntrinsicElements['div']\n\nexport type MBoxElement = HTMLElement & {\n close: () => Promise<void>\n}\n\nexport const MBox = (props: MBoxProps) => {\n const {\n type = 'default',\n title,\n content,\n closeable = true,\n titleProps,\n contentProps,\n children,\n ...rest\n } = props\n let titleContent = title\n if (typeof title === 'undefined' && type !== 'default') {\n titleContent = type[0].toUpperCase() + type.slice(1).toLowerCase()\n }\n\n const close = async () => {\n if (!box) {\n return Promise.resolve()\n }\n const { promise, resolve } = Promise.withResolvers<void>()\n\n const animation = box.animate(\n [\n { opacity: '1', height: box.clientHeight + 'px' },\n { opacity: '0', height: '0px', margin: '0px' },\n ],\n {\n duration: 300,\n easing: 'ease',\n }\n )\n\n animation.addEventListener('finish', () => {\n box.remove()\n resolve()\n })\n\n return promise\n }\n\n const box = (\n <div className={`theme-ipe ipe-mbox mbox-type-${type || 'default'} ${styles.mbox}`} {...rest}>\n {titleContent && (\n <div className={`ipe-mbox-title ${styles.title}`} {...titleProps}>\n {titleContent}\n </div>\n )}\n <div className={`ipe-mbox-content ${styles.content}`} {...contentProps}>\n {children || content}\n </div>\n {closeable && (\n <a onClick={close} className={`ipe-mbox-close ${styles.close}`}>\n ×\n </a>\n )}\n </div>\n ) as MBoxElement\n box.close = close\n return box\n}\n"],"names":["MBox","props","type","title","content","closeable","titleProps","contentProps","children","rest","titleContent","close","box","promise","resolve","jsxs","styles","jsx"],"mappings":";;;;;;GA4BaA,IAAO,CAACC,MAAqB;AACxC,QAAM;AAAA,IACJ,MAAAC,IAAO;AAAA,IACP,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EAAA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B as Ni, I as Di } from "./index-COlXHFRg.js";
|
|
3
3
|
/**
|
|
4
4
|
* @vue/shared v3.5.22
|
|
5
5
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
@@ -4689,7 +4689,7 @@ const fc = { class: "preferences-ui-app" }, hc = { class: "tabs" }, dc = ["onCli
|
|
|
4689
4689
|
for (const [n, r] of t)
|
|
4690
4690
|
s[n] = r;
|
|
4691
4691
|
return s;
|
|
4692
|
-
}, _c = /* @__PURE__ */ gc(mc, [["__scopeId", "data-v-
|
|
4692
|
+
}, _c = /* @__PURE__ */ gc(mc, [["__scopeId", "data-v-e89c782f"]]);
|
|
4693
4693
|
var vc = Object.create, _n = Object.defineProperty, bc = Object.getOwnPropertyDescriptor, Ti = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), $i = (e) => {
|
|
4694
4694
|
throw TypeError(e);
|
|
4695
4695
|
}, yc = (e, t, s) => t in e ? _n(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, xc = (e, t) => _n(e, "name", { value: t, configurable: !0 }), Cc = (e) => [, , , vc(e?.[Ti("metadata")] ?? null)], Sc = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ai = (e) => e !== void 0 && typeof e != "function" ? $i("Function expected") : e, wc = (e, t, s, n, r) => ({ kind: Sc[e], name: t, metadata: n, addInitializer: (i) => s._ ? $i("Already initialized") : r.push(Ai(i || null)) }), Ec = (e, t) => yc(t, Ti("metadata"), e[3]), Tc = (e, t, s, n) => {
|
|
@@ -4787,4 +4787,4 @@ Tc(vn, 1, zs);
|
|
|
4787
4787
|
export {
|
|
4788
4788
|
zs as PluginPreferencesUI
|
|
4789
4789
|
};
|
|
4790
|
-
//# sourceMappingURL=index-
|
|
4790
|
+
//# sourceMappingURL=index-mntCdHRr.js.map
|