@inpageedit/core 0.5.4 → 0.7.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/dist/CheckBox-D3rHnX7I.js +13 -0
- package/dist/CheckBox-D3rHnX7I.js.map +1 -0
- package/dist/IconQuickEdit-YVn1ANbm.js +27 -0
- package/dist/IconQuickEdit-YVn1ANbm.js.map +1 -0
- package/dist/InPageEdit.d.ts +7 -5
- package/dist/InputBox-BV4m05Xs.js +22 -0
- package/dist/InputBox-BV4m05Xs.js.map +1 -0
- package/dist/RadioBox-nJqWsxW2.js +13 -0
- package/dist/RadioBox-nJqWsxW2.js.map +1 -0
- package/dist/__test__/utils/constants.d.ts +2 -0
- package/dist/components/Icon/IconEdit.d.ts +2 -0
- package/dist/components/Icon/IconQuickEdit.d.ts +2 -0
- package/dist/components/MwUserLinks.d.ts +2 -0
- package/dist/components/index.js +13 -11
- package/dist/components/index.js.map +1 -1
- package/dist/{index-i-Uf0vuA.js → index-1JtE4urY.js} +490 -374
- package/dist/{index-i-Uf0vuA.js.map → index-1JtE4urY.js.map} +1 -1
- package/dist/{index-UyiZ7umI.js → index-2AEdgbUL.js} +4 -4
- package/dist/index-2AEdgbUL.js.map +1 -0
- package/dist/index-2kN4SKmT.js +116 -0
- package/dist/index-2kN4SKmT.js.map +1 -0
- package/dist/{index-BSjnoNn2.js → index-B3Bsg_nE.js} +5 -3
- package/dist/index-B3Bsg_nE.js.map +1 -0
- package/dist/index-BCMwmSfQ.js +295 -0
- package/dist/index-BCMwmSfQ.js.map +1 -0
- package/dist/{index-BedbUMp8.js → index-C0ci6Ll1.js} +14 -12
- package/dist/index-C0ci6Ll1.js.map +1 -0
- package/dist/index-CZnu6cRK.js +319 -0
- package/dist/index-CZnu6cRK.js.map +1 -0
- package/dist/{index-xJ2bdsOD.js → index-CheNjwas.js} +5 -5
- package/dist/{index-xJ2bdsOD.js.map → index-CheNjwas.js.map} +1 -1
- package/dist/{index-DtOC8Ck-.js → index-CrWxZ0yl.js} +66 -63
- package/dist/{index-DtOC8Ck-.js.map → index-CrWxZ0yl.js.map} +1 -1
- package/dist/{index-DNQjqBV-.js → index-DqfQ7hp6.js} +3359 -3037
- package/dist/index-DqfQ7hp6.js.map +1 -0
- package/dist/index-lZkYoUca.js +46 -0
- package/dist/index-lZkYoUca.js.map +1 -0
- package/dist/index-sfkutNHj.js +201 -0
- package/dist/index-sfkutNHj.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/makeCallable-LDU0xZMJ.js +40 -0
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -0
- package/dist/models/WikiPage/index.d.ts +2 -2
- package/dist/models/WikiTitle/index.d.ts +87 -11
- package/dist/models/WikiTitle/index.spec.d.ts +1 -0
- package/dist/noop-ClDc6zv4.js +6 -0
- package/dist/noop-ClDc6zv4.js.map +1 -0
- package/dist/plugins/in-article-links/index.d.ts +33 -7
- package/dist/plugins/quick-delete/index.d.ts +47 -0
- package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +4 -2
- package/dist/plugins/quick-diff/components/DiffTable.d.ts +17 -0
- package/dist/plugins/quick-preview/index.d.ts +6 -3
- package/dist/services/ApiService.d.ts +2 -2
- package/dist/services/ModalService/IPEModal.d.ts +1 -1
- package/dist/services/SiteMetadataService.d.ts +43 -4
- package/dist/services/WikiPageService.d.ts +2 -2
- package/dist/services/WikiTitleService.d.ts +14 -0
- package/dist/style.css +1 -1
- package/dist/types/SiteMetadata.d.ts +1 -1
- package/dist/utils/url.d.ts +24 -0
- package/lib/index.umd.js +28 -28
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +10 -1
- package/dist/InputBox-FIzJ-rPN.js +0 -30
- package/dist/InputBox-FIzJ-rPN.js.map +0 -1
- package/dist/RadioBox-CaA8VgLu.js +0 -54
- package/dist/RadioBox-CaA8VgLu.js.map +0 -1
- package/dist/index-BSjnoNn2.js.map +0 -1
- package/dist/index-BedbUMp8.js.map +0 -1
- package/dist/index-DNQjqBV-.js.map +0 -1
- package/dist/index-UyiZ7umI.js.map +0 -1
- package/dist/index-e7eyr1FL.js +0 -96
- package/dist/index-e7eyr1FL.js.map +0 -1
- package/dist/index-rMDuLpcz.js +0 -458
- package/dist/index-rMDuLpcz.js.map +0 -1
- package/dist/plugins/quick-edit/PluginQuickEditInArticleLinks.d.ts +0 -14
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-UyiZ7umI.js","sources":["../src/utils/computeable.ts","../src/plugins/preferences/index.tsx"],"sourcesContent":["export type ComputeAble<T> = (() => T | Promise<T>) | T\nconst isFunction = (value: any): value is Function => typeof value === 'function'\nexport async function computeFallback<T>(value: ComputeAble<T>): Promise<T> {\n if (isFunction(value)) {\n return await value()\n } else {\n return value\n }\n}\n","import { Inject, InPageEdit, Schema } from '@/InPageEdit.js'\nimport { IPEStorageItem, IPEStorageManager } from '@/services/StorageService.js'\nimport { computeFallback, ComputeAble } from '@/utils/computeable.js'\n\ndeclare module '@/InPageEdit' {\n export interface InPageEdit {\n preferences: PluginPreferences\n }\n}\n\nexport interface InPageEditPreferenceUICategory {\n name: string\n label: string\n description?: string\n index?: number\n}\n\nexport interface InPageEditPreferenceUIRegistryItem {\n name: string\n schema: Schema\n defaults: Record<string, any>\n category: string\n}\n\n@Inject(['sitemeta', 'storage'])\nexport class PluginPreferences extends BasePlugin {\n private db: IPEStorageManager<any>\n public customRegistries: InPageEditPreferenceUIRegistryItem[] = []\n public categoryDefinitions: InPageEditPreferenceUICategory[] = []\n private _defaultPreferences: Record<string, any> = {}\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'preferences')\n this.db = ctx.storage.createDatabse<any>('preferences', Infinity)\n this.ctx.set('preferences', this)\n }\n\n async start() {\n this.defineCategory({\n name: 'general',\n label: 'General',\n description: 'General settings',\n })\n this.defineCategory({\n name: 'edit',\n label: 'Editing',\n description: 'Settings related to editing content',\n })\n this.defineCategory({\n name: 'about',\n label: 'About',\n description: 'About InPageEdit',\n index: 99,\n })\n\n this.registerCustomConfig(\n 'about',\n Schema.object({\n about: Schema.const(\n <div className=\"prose\">\n <h2>✏️ InPageEdit NEXT</h2>\n <i>v{this.ctx.version}</i>\n <h2>Portals</h2>\n <div style=\"display: flex; flex-direction: column; gap: 1rem\">\n <a\n href={this.ctx.Endpoints.HOME_URL}\n target=\"_blank\"\n style={{ display: 'block', width: '100%' }}\n >\n Official Website & Help Center\n </a>\n <ActionButton\n href={`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version}`}\n style={{ display: 'block', width: '100%' }}\n >\n Update Logs\n </ActionButton>\n </div>\n <h2>Join us</h2>\n <ul>\n <li>\n <strong>GitHub</strong>:{' '}\n <a href={this.ctx.Endpoints.GITHUB_URL} target=\"_blank\">\n inpageedit/inpageedit-next\n </a>\n </li>\n <li>\n <strong>QQ Group</strong>: 1026023666\n </li>\n </ul>\n <hr />\n <p>🚀 Modular, Extensible Supercharged Plugin for MediaWiki.</p>\n <p>InPageEdit-NEXT Copyright © 2025-present dragon-fish</p>\n </div>\n ).role('raw-html'),\n }).description(''),\n 'about',\n {}\n )\n\n import('./ui/index').then((module) => {\n const fork = this.ctx.plugin(module.PluginPreferencesUI)\n this.addDisposeHandler(() => {\n fork.dispose()\n })\n })\n }\n\n async get<T = any>(key: string, fallback?: ComputeAble<T>): Promise<T | null> {\n fallback ??= () => {\n const defaultValue = this.getDefaultValue(key)\n this.logger.debug(key, `(fallback value: ${defaultValue})`)\n return defaultValue as T\n }\n const value = (await this.db.get(key, undefined)) as T | null\n return value !== null ? value : ((await computeFallback(fallback)) as T)\n }\n\n getDefaultValue(key: string): unknown {\n return (this._defaultPreferences[key] ??= this.loadDefaultConfigs()[key])\n }\n\n set<T = any>(key: string, value: T): Promise<IPEStorageItem<T> | void> {\n const defaultValue = this.getDefaultValue(key)\n if (value === defaultValue) {\n return this.db.delete(key)\n } else {\n return this.db.set(key, value)\n }\n }\n\n async getAll() {\n const data = this.loadDefaultConfigs()\n await this.db.iterate((value: IPEStorageItem, key: string) => {\n data[key] = value\n })\n return data\n }\n\n private loadDefaultConfigs() {\n const data = {} as Record<string, any>\n this.getConfigRegistries().forEach((item) => {\n // 首先读取 schema 上的默认值\n try {\n const defaultValues = item.schema({}) as any\n Object.entries(defaultValues).forEach(([key, val]) => {\n data[key] = val\n })\n } catch {}\n\n // 然后读取注册时定义的默认值\n item.defaults &&\n Object.entries(item.defaults).forEach(([key, val]) => {\n data[key] = val\n })\n })\n\n Object.entries(data).forEach(([key, val]) => {\n this._defaultPreferences[key] = val\n })\n\n return data\n }\n\n registerCustomConfig(\n name: string,\n schema: Schema,\n category: string,\n defaults: Record<string, any>\n ) {\n this.customRegistries.push({\n name,\n schema,\n category,\n defaults,\n })\n return this\n }\n\n getConfigRegistries(category?: string): InPageEditPreferenceUIRegistryItem[] {\n return Array.from(this.ctx.registry.entries())\n .map<{\n name: string\n schema: Schema\n defaults: Record<string, any>\n }>(([plugin, fork]) => {\n if (plugin === null) {\n return {\n name: '@root',\n schema: (InPageEdit as any)?.PreferencesSchema || null,\n defaults: (InPageEdit as any)?.PreferencesDefaults || {},\n }\n } else {\n return {\n name: plugin.name,\n schema: (plugin as any)?.PreferencesSchema || null,\n defaults: (plugin as any)?.PreferencesDefaults || {},\n }\n }\n })\n .filter((item) => item.schema !== null)\n .map((item) => {\n return {\n ...item,\n category: item.schema.meta.category || 'general',\n }\n })\n .concat(this.customRegistries)\n .filter((item) => !category || item.category === category)\n }\n\n defineCategory(category: InPageEditPreferenceUICategory) {\n const index = this.categoryDefinitions.findIndex((tab) => tab.name === category.name)\n if (index < 0) {\n this.categoryDefinitions.push(category)\n } else {\n this.categoryDefinitions[index] = category\n }\n this.categoryDefinitions.sort((a, b) => {\n return (a.index ?? 0) - (b.index ?? 0)\n })\n return this\n }\n\n getConfigCategories() {\n return this.categoryDefinitions\n }\n}\n"],"names":["isFunction","value","computeFallback","_PluginPreferences_decorators","_init","_a","Inject","PluginPreferences","BasePlugin","ctx","Schema","jsxs","jsx","ActionButton","module","fork","key","fallback","defaultValue","data","item","defaultValues","val","name","schema","category","defaults","plugin","InPageEdit","index","tab","a","b","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;AACA,MAAMA,IAAa,CAACC,MAAkC,OAAOA,KAAU;AACvE,eAAsBC,EAAmBD,GAAmC;AAC1E,SAAID,EAAWC,CAAK,IACX,MAAMA,EAAA,IAENA;AAEX;;;;;;;;;;;;GCRAE,GAAAC,GAAAC;AAwBAF,IAAA,CAACG,EAAO,CAAC,YAAY,SAAS,CAAC,CAAA;AACxB,MAAMC,WAA0BF,IAAAG,GAAW;AAAA,EAMhD,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,aAAa,GADX,KAAA,MAAAA,GALnB,KAAQ,KAAR,QACA,KAAO,mBAAyD,CAAA,GAChE,KAAO,sBAAwD,CAAA,GAC/D,KAAQ,sBAA2C,CAAA,GAIjD,KAAK,KAAKA,EAAI,QAAQ,cAAmB,eAAe,KAAQ,GAChE,KAAK,IAAI,IAAI,eAAe,IAAI;AAAA,EAClC;AAAA,EAEA,MAAM,QAAQ;AACZ,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IAAA,CACd,GACD,KAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IAAA,CACd,GACD,KAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR,GAED,KAAK;AAAA,MACH;AAAA,MACAC,EAAO,OAAO;AAAA,QACZ,OAAOA,EAAO;AAAA,UACZC,gBAAAA,EAAC,OAAA,EAAI,WAAU,SACb,UAAA;AAAA,YAAA,gBAAAC,EAAC,QAAG,UAAA,qBAAA,CAAkB;AAAA,8BACrB,KAAA,EAAE,UAAA;AAAA,cAAA;AAAA,cAAE,KAAK,I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AAQA,EAAI,SAASL,EAAS,IAAI;AACpF,WAAII,IAAQ,IACV,KAAK,oBAAoB,KAAKJ,CAAQ,IAEtC,KAAK,oBAAoBI,CAAK,IAAIJ,GAEpC,KAAK,oBAAoB,KAAK,CAACM,GAAGC,OACxBD,EAAE,SAAS,MAAMC,EAAE,SAAS,EACrC,GACM;AAAA,EACT;AAAA,EAEA,sBAAsB;AACpB,WAAO,KAAK;AAAA,EACd;AACF;AA1MO5B,IAAA6B,EAAA5B,CAAA;AAAME,IAAN2B,6BADP/B,GACaI,CAAA;AAAN4B,EAAA/B,GAAA,GAAMG,CAAA;"}
|
package/dist/index-e7eyr1FL.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { j as s, F as q, P as j } from "./index-CvhkVj_L.js";
|
|
2
|
-
import { B as y, a as S } from "./index-DNQjqBV-.js";
|
|
3
|
-
var E = Object.create, _ = Object.defineProperty, F = Object.getOwnPropertyDescriptor, k = (t, i) => (i = Symbol[t]) ? i : Symbol.for("Symbol." + t), x = (t) => {
|
|
4
|
-
throw TypeError(t);
|
|
5
|
-
}, O = (t, i, r) => i in t ? _(t, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[i] = r, Q = (t, i) => _(t, "name", { value: i, configurable: !0 }), T = (t) => [, , , E(t?.[k("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], f = (t) => t !== void 0 && typeof t != "function" ? x("Function expected") : t, B = (t, i, r, a, e) => ({ kind: z[t], name: i, metadata: a, addInitializer: (c) => r._ ? x("Already initialized") : e.push(f(c || null)) }), C = (t, i) => O(i, k("metadata"), t[3]), I = (t, i, r, a) => {
|
|
6
|
-
for (var e = 0, c = t[i >> 1], n = c && c.length; e < n; e++) c[e].call(r);
|
|
7
|
-
return a;
|
|
8
|
-
}, D = (t, i, r, a, e, c) => {
|
|
9
|
-
var n, o, u, l = i & 7, w = !1, P = 0, m = t[P] || (t[P] = []), d = l && (e = e.prototype, l < 5 && (l > 3 || !w) && F(e, r));
|
|
10
|
-
Q(e, r);
|
|
11
|
-
for (var v = a.length - 1; v >= 0; v--)
|
|
12
|
-
u = B(l, r, o = {}, t[3], m), n = (0, a[v])(e, u), o._ = 1, f(n) && (e = n);
|
|
13
|
-
return C(t, e), d && _(e, r, d), w ? l ^ 4 ? c : d : e;
|
|
14
|
-
}, g, h, b;
|
|
15
|
-
g = [S(["api", "wikiPage", "modal"])];
|
|
16
|
-
class p extends (b = y) {
|
|
17
|
-
constructor(i) {
|
|
18
|
-
super(i, {}, "quickPreview"), this.ctx = i;
|
|
19
|
-
}
|
|
20
|
-
start() {
|
|
21
|
-
this.ctx.set("quickPreview", this.quickPreview.bind(this)), this.ctx.on("quick-edit/wiki-page", this.injectQuickEdit.bind(this));
|
|
22
|
-
}
|
|
23
|
-
stop() {
|
|
24
|
-
this.ctx.off("quick-edit/wiki-page", this.injectQuickEdit.bind(this));
|
|
25
|
-
}
|
|
26
|
-
injectQuickEdit({ ctx: i, modal: r, wikiPage: a }) {
|
|
27
|
-
let e;
|
|
28
|
-
r.addButton(
|
|
29
|
-
{
|
|
30
|
-
label: "Preview",
|
|
31
|
-
side: "left",
|
|
32
|
-
className: "btn btn-secondary",
|
|
33
|
-
method: () => {
|
|
34
|
-
e = this.quickPreview(
|
|
35
|
-
r.get$content().querySelector('textarea[name="text"]')?.value || "",
|
|
36
|
-
void 0,
|
|
37
|
-
a,
|
|
38
|
-
e
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
2
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
quickPreview(i, r, a, e) {
|
|
46
|
-
return a ||= this.ctx.wikiPage.newBlankPage({
|
|
47
|
-
title: "API"
|
|
48
|
-
}), (!e || e.isDestroyed) && (e = this.ctx.modal.createObject({
|
|
49
|
-
className: "in-page-edit ipe-quickPreview",
|
|
50
|
-
sizeClass: "large",
|
|
51
|
-
backdrop: !1,
|
|
52
|
-
draggable: !0
|
|
53
|
-
}).init()), e.show(), e.setTitle("Preview - Loading..."), e.setContent(/* @__PURE__ */ s(j, {})), e.bringToFront(), this.ctx.emit("quick-preview/show-modal", {
|
|
54
|
-
ctx: this.ctx,
|
|
55
|
-
text: i,
|
|
56
|
-
modal: e,
|
|
57
|
-
wikiPage: a
|
|
58
|
-
}), a.preview(i, r).then((c) => {
|
|
59
|
-
const {
|
|
60
|
-
data: { parse: n }
|
|
61
|
-
} = c;
|
|
62
|
-
e.setTitle(`Preview - ${n.title}`);
|
|
63
|
-
let o = null;
|
|
64
|
-
e.setContent(
|
|
65
|
-
/* @__PURE__ */ s("section", { children: /* @__PURE__ */ s(
|
|
66
|
-
"div",
|
|
67
|
-
{
|
|
68
|
-
ref: (u) => o = u,
|
|
69
|
-
className: "mw-parser-output",
|
|
70
|
-
innerHTML: n.text
|
|
71
|
-
}
|
|
72
|
-
) })
|
|
73
|
-
), window.mw?.hook("wikipage.content").fire($(o)), this.ctx.emit("quick-preview/loaded", {
|
|
74
|
-
ctx: this.ctx,
|
|
75
|
-
modal: e,
|
|
76
|
-
wikiPage: a,
|
|
77
|
-
text: i,
|
|
78
|
-
parseData: n
|
|
79
|
-
});
|
|
80
|
-
}).catch((c) => {
|
|
81
|
-
e.setTitle("Preview - Failed"), e.setContent(
|
|
82
|
-
/* @__PURE__ */ s(q, { children: [
|
|
83
|
-
/* @__PURE__ */ s("p", { children: "Failed to preview" }),
|
|
84
|
-
/* @__PURE__ */ s("p", { children: c instanceof Error ? c.message : String(c) })
|
|
85
|
-
] })
|
|
86
|
-
);
|
|
87
|
-
}), e;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
h = T(b);
|
|
91
|
-
p = D(h, 0, "PluginQuickPreview", g, p);
|
|
92
|
-
I(h, 1, p);
|
|
93
|
-
export {
|
|
94
|
-
p as PluginQuickPreview
|
|
95
|
-
};
|
|
96
|
-
//# sourceMappingURL=index-e7eyr1FL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-e7eyr1FL.js","sources":["../src/plugins/quick-preview/index.tsx"],"sourcesContent":["import { Inject, InPageEdit } from '@/InPageEdit'\nimport { type QuickEditInitPayload } from '@/plugins/quick-edit'\nimport { WikiPage } from '@/models/WikiPage'\nimport { MwApiParams } from 'wiki-saikou'\nimport { PageParseData } from '@/models/WikiPage/types/PageParseData'\nimport { IPEModal } from '@/services/ModalService/IPEModal.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickPreview: PluginQuickPreview['quickPreview']\n }\n interface Events {\n 'quick-preview/show-modal'(payload: {\n ctx: InPageEdit\n text: string\n modal: IPEModal\n wikiPage: WikiPage\n }): void\n 'quick-preview/loaded'(payload: {\n ctx: InPageEdit\n modal: IPEModal\n wikiPage: WikiPage\n text: string\n parseData: PageParseData\n }): void\n }\n}\n\n@Inject(['api', 'wikiPage', 'modal'])\nexport class PluginQuickPreview extends BasePlugin {\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quickPreview')\n }\n\n protected start(): Promise<void> | void {\n this.ctx.set('quickPreview', this.quickPreview.bind(this))\n this.ctx.on('quick-edit/wiki-page', this.injectQuickEdit.bind(this))\n }\n\n protected stop(): Promise<void> | void {\n this.ctx.off('quick-edit/wiki-page', this.injectQuickEdit.bind(this))\n }\n\n private injectQuickEdit({ ctx, modal, wikiPage }: QuickEditInitPayload) {\n let latestPreviewModal: IPEModal | undefined = undefined\n modal.addButton(\n {\n label: 'Preview',\n side: 'left',\n className: 'btn btn-secondary',\n method: () => {\n latestPreviewModal = this.quickPreview(\n (modal.get$content().querySelector<HTMLTextAreaElement>('textarea[name=\"text\"]')\n ?.value as string) || '',\n undefined,\n wikiPage,\n latestPreviewModal\n )\n },\n },\n 2\n )\n }\n\n quickPreview(text: string, params?: MwApiParams, wikiPage?: WikiPage, modal?: IPEModal) {\n wikiPage ||= this.ctx.wikiPage.newBlankPage({\n title: 'API',\n })\n\n if (!modal || modal.isDestroyed) {\n modal = this.ctx.modal\n .createObject({\n className: 'in-page-edit ipe-quickPreview',\n sizeClass: 'large',\n backdrop: false,\n draggable: true,\n })\n .init()\n }\n\n modal.show()\n modal.setTitle('Preview - Loading...')\n modal.setContent(<ProgressBar />)\n modal.bringToFront()\n this.ctx.emit('quick-preview/show-modal', {\n ctx: this.ctx,\n text,\n modal,\n wikiPage,\n })\n\n wikiPage\n .preview(text, params)\n .then((ret) => {\n const {\n data: { parse },\n } = ret\n modal.setTitle(`Preview - ${parse.title}`)\n let outputRef: HTMLElement | null = null\n modal.setContent(\n (\n <section>\n <div\n ref={(el) => (outputRef = el)}\n className=\"mw-parser-output\"\n innerHTML={parse.text}\n ></div>\n </section>\n ) as HTMLElement\n )\n window.mw?.hook('wikipage.content').fire($(outputRef!))\n this.ctx.emit('quick-preview/loaded', {\n ctx: this.ctx,\n modal,\n wikiPage,\n text,\n parseData: parse,\n })\n })\n .catch((error) => {\n modal.setTitle('Preview - Failed')\n modal.setContent(\n <>\n <p>Failed to preview</p>\n <p>{error instanceof Error ? error.message : String(error)}</p>\n </>\n )\n })\n\n return modal\n }\n}\n"],"names":["_PluginQuickPreview_decorators","_init","_a","Inject","PluginQuickPreview","BasePlugin","ctx","modal","wikiPage","latestPreviewModal","text","params","jsx","ProgressBar","ret","parse","outputRef","el","error","jsxs","Fragment","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AA4BAF,IAAA,CAACG,EAAO,CAAC,OAAO,YAAY,OAAO,CAAC,CAAA;AAC7B,MAAMC,WAA2BF,IAAAG,GAAW;AAAA,EACjD,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,cAAc,GADZ,KAAA,MAAAA;AAAA,EAEnB;AAAA,EAEU,QAA8B;AACtC,SAAK,IAAI,IAAI,gBAAgB,KAAK,aAAa,KAAK,IAAI,CAAC,GACzD,KAAK,IAAI,GAAG,wBAAwB,KAAK,gBAAgB,KAAK,IAAI,CAAC;AAAA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AAAT,EAAM;AAAA,0BAED,WAAA,EACC,UAAA,gBAAAK;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAK,CAACK,MAAQD,IAAYC;AAAA,YAC1B,WAAU;AAAA,YACV,WAAWF,EAAM;AAAA,UAAA;AAAA,QAAA,EAClB,CACH;AAAA,MAAA,GAGJ,OAAO,IAAI,KAAK,kBAAkB,EAAE,KAAK,EAAEC,CAAU,CAAC,GACtD,KAAK,IAAI,KAAK,wBAAwB;AAAA,QACpC,KAAK,KAAK;AAAA,QACV,OAAAT;AAAA,QACA,UAAAC;AAAA,QACA,MAAAE;AAAA,QACA,WAAWK;AAAA,MAAA,CACZ;AAAA,IACH,CAAC,EACA,MAAM,CAACG,MAAU;AAChB,MAAAX,EAAM,SAAS,kBAAkB,GACjCA,EAAM;AAAA,QACJY,gBAAAA,EAAAC,GAAA,EACE,UAAA;AAAA,UAAA,gBAAAR,EAAC,OAAE,UAAA,oBAAA,CAAiB;AAAA,UACpB,gBAAAA,EAAC,OAAG,UAAAM,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,EAAA,CAAE;AAAA,QAAA,EAAA,CAC7D;AAAA,MAAA;AAAA,IAEJ,CAAC,GAEIX;AAAA,EACT;AACF;AAtGON,IAAAoB,EAAAnB,CAAA;AAAME,IAANkB,8BADPtB,GACaI,CAAA;AAANmB,EAAAtB,GAAA,GAAMG,CAAA;"}
|
package/dist/index-rMDuLpcz.js
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { j as s, F as S, P as D } from "./index-CvhkVj_L.js";
|
|
2
|
-
import { B as I, a as C, S as m, W as g } from "./index-DNQjqBV-.js";
|
|
3
|
-
import { R as L } from "./Preferences-Bg3J5Ur9.js";
|
|
4
|
-
import { R as U, M as E } from "./RadioBox-CaA8VgLu.js";
|
|
5
|
-
import { I as z, C as P } from "./InputBox-FIzJ-rPN.js";
|
|
6
|
-
var Q = Object.create, _ = Object.defineProperty, W = Object.getOwnPropertyDescriptor, M = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), O = (t) => {
|
|
7
|
-
throw TypeError(t);
|
|
8
|
-
}, Y = (t, e, o) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, H = (t, e) => _(t, "name", { value: e, configurable: !0 }), K = (t) => [, , , Q(t?.[M("metadata")] ?? null)], G = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], $ = (t) => t !== void 0 && typeof t != "function" ? O("Function expected") : t, X = (t, e, o, c, i) => ({ kind: G[t], name: e, metadata: c, addInitializer: (a) => o._ ? O("Already initialized") : i.push($(a || null)) }), J = (t, e) => Y(e, M("metadata"), t[3]), V = (t, e, o, c) => {
|
|
9
|
-
for (var i = 0, a = t[e >> 1], r = a && a.length; i < r; i++) a[i].call(o);
|
|
10
|
-
return c;
|
|
11
|
-
}, Z = (t, e, o, c, i, a) => {
|
|
12
|
-
var r, n, l, u = e & 7, p = !1, v = 0, d = t[v] || (t[v] = []), h = u && (i = i.prototype, u < 5 && (u > 3 || !p) && W(i, o));
|
|
13
|
-
H(i, o);
|
|
14
|
-
for (var f = c.length - 1; f >= 0; f--)
|
|
15
|
-
l = X(u, o, n = {}, t[3], d), r = (0, c[f])(i, l), n._ = 1, $(r) && (i = r);
|
|
16
|
-
return J(t, i), h && _(i, o, h), p ? u ^ 4 ? a : h : i;
|
|
17
|
-
}, q, x, N;
|
|
18
|
-
q = [C(["sitemeta", "quickEdit"]), L(
|
|
19
|
-
m.object({
|
|
20
|
-
redLinkEdit: m.boolean().description("Show quick edit entry after red links").default(!0)
|
|
21
|
-
}).description("In-article quick edit links"),
|
|
22
|
-
{
|
|
23
|
-
redLinkEdit: !0
|
|
24
|
-
}
|
|
25
|
-
)];
|
|
26
|
-
class w extends (N = I) {
|
|
27
|
-
constructor(e) {
|
|
28
|
-
const o = e.sitemeta.mwConfig, c = o.wgArticlePath.replace("$1", ""), i = `${location.protocol}//${o.wgServer.split("//")[1]}`;
|
|
29
|
-
super(
|
|
30
|
-
e,
|
|
31
|
-
{
|
|
32
|
-
wikiBaseUrl: i,
|
|
33
|
-
wikiArticlePath: c,
|
|
34
|
-
wikiArticleBaseUrl: `${i}${c}`,
|
|
35
|
-
wikiScriptBaseUrl: `${i}${o.wgScriptPath}`,
|
|
36
|
-
linkClassName: "ipe-quickEdit__in-article-link"
|
|
37
|
-
},
|
|
38
|
-
"QuickEditInArticleLinks"
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
async start() {
|
|
42
|
-
mw.hook("wikipage.content").add((e) => {
|
|
43
|
-
e.find("a[href]").toArray().forEach((c) => {
|
|
44
|
-
const i = this.checkEditAnchor(c);
|
|
45
|
-
if (!i || c.dataset.ipeQuickEditLink)
|
|
46
|
-
return;
|
|
47
|
-
const a = /* @__PURE__ */ s(
|
|
48
|
-
"a",
|
|
49
|
-
{
|
|
50
|
-
href: `#/IPE/quickEdit/${i.title}`,
|
|
51
|
-
className: this.config.linkClassName,
|
|
52
|
-
style: {
|
|
53
|
-
userSelect: "none",
|
|
54
|
-
marginLeft: "0.2em",
|
|
55
|
-
verticalAlign: "middle"
|
|
56
|
-
},
|
|
57
|
-
onClick: (r) => {
|
|
58
|
-
r.preventDefault(), this.ctx.quickEdit.showModal(i);
|
|
59
|
-
},
|
|
60
|
-
children: /* @__PURE__ */ s(
|
|
61
|
-
"svg",
|
|
62
|
-
{
|
|
63
|
-
style: "width: 1em; height: 1em",
|
|
64
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
-
width: "24",
|
|
66
|
-
height: "24",
|
|
67
|
-
viewBox: "0 0 24 24",
|
|
68
|
-
fill: "none",
|
|
69
|
-
stroke: "currentColor",
|
|
70
|
-
"stroke-width": "2",
|
|
71
|
-
"stroke-linecap": "round",
|
|
72
|
-
"stroke-linejoin": "round",
|
|
73
|
-
class: "icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt",
|
|
74
|
-
children: [
|
|
75
|
-
/* @__PURE__ */ s("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
76
|
-
/* @__PURE__ */ s("path", { d: "M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" }),
|
|
77
|
-
/* @__PURE__ */ s("path", { d: "M13.5 6.5l4 4" }),
|
|
78
|
-
/* @__PURE__ */ s("path", { d: "M19 16l-2 3h4l-2 3" })
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
c.insertAdjacentElement("afterend", a), c.dataset.ipeQuickEditLink = "true";
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
stop() {
|
|
89
|
-
document.querySelectorAll(`.${this.config.linkClassName}`).forEach((e) => e.remove());
|
|
90
|
-
}
|
|
91
|
-
checkEditAnchor(e) {
|
|
92
|
-
if (!(e instanceof HTMLAnchorElement))
|
|
93
|
-
return null;
|
|
94
|
-
const o = e.href || "";
|
|
95
|
-
if (!o.startsWith(this.config.wikiArticleBaseUrl) && !o.startsWith(this.config.wikiScriptBaseUrl))
|
|
96
|
-
return null;
|
|
97
|
-
const c = new URL(o), i = c.searchParams, a = i.get("action") || "view", r = i.get("title") || decodeURI(c.pathname.substring(this.config.wikiArticlePath.length)) || "", n = i.get("section")?.replace(/^T-/, "") || void 0, l = i.get("oldid");
|
|
98
|
-
if (
|
|
99
|
-
// 不合法的 title
|
|
100
|
-
!r || r.endsWith(".php") || // 不是 edit 相关操作
|
|
101
|
-
!["edit", "editsource", "editredlink", "submit"].includes(a) || // 暂时未兼容 undo
|
|
102
|
-
i.get("undo") || // 暂时未兼容 preload
|
|
103
|
-
i.get("preload")
|
|
104
|
-
)
|
|
105
|
-
return null;
|
|
106
|
-
let u;
|
|
107
|
-
return n === "new" ? u = "new" : n && /^\d+$/.test(n) && (u = parseInt(n, 10)), {
|
|
108
|
-
title: r,
|
|
109
|
-
section: u,
|
|
110
|
-
revision: parseInt("" + l, 10) || 0,
|
|
111
|
-
createOnly: !!i.get("redlink")
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
x = K(N);
|
|
116
|
-
w = Z(x, 0, "PluginQuickEditInArticleLinks", q, w);
|
|
117
|
-
V(x, 1, w);
|
|
118
|
-
const ee = Symbol("@@apply"), te = Symbol("@@ctor");
|
|
119
|
-
function ie(t, e) {
|
|
120
|
-
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
121
|
-
throw new TypeError("instance is not an object");
|
|
122
|
-
const o = (...a) => {
|
|
123
|
-
const r = t[e];
|
|
124
|
-
if (typeof r != "function")
|
|
125
|
-
throw new TypeError(`Property "${String(e)}" is not a function`);
|
|
126
|
-
return r.apply(t, a);
|
|
127
|
-
};
|
|
128
|
-
o[ee] = o, o[te] = t;
|
|
129
|
-
const c = t?.constructor?.name;
|
|
130
|
-
return c && (o[Symbol.toStringTag] = c), new Proxy(o, {
|
|
131
|
-
get(a, r, n) {
|
|
132
|
-
return r === "prototype" ? Reflect.get(o, r, n) : Reflect.get(t, r, t);
|
|
133
|
-
},
|
|
134
|
-
set(a, r, n) {
|
|
135
|
-
return Reflect.set(t, r, n);
|
|
136
|
-
},
|
|
137
|
-
has(a, r) {
|
|
138
|
-
return Reflect.has(t, r);
|
|
139
|
-
},
|
|
140
|
-
deleteProperty(a, r) {
|
|
141
|
-
return Reflect.deleteProperty(t, r);
|
|
142
|
-
},
|
|
143
|
-
ownKeys() {
|
|
144
|
-
return Reflect.ownKeys(t);
|
|
145
|
-
},
|
|
146
|
-
getOwnPropertyDescriptor(a, r) {
|
|
147
|
-
return Object.getOwnPropertyDescriptor(t, r);
|
|
148
|
-
},
|
|
149
|
-
defineProperty(a, r, n) {
|
|
150
|
-
return Object.defineProperty(t, r, n);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
const A = () => {
|
|
155
|
-
}, re = (t = 0) => new Promise((e) => setTimeout(e, t));
|
|
156
|
-
var oe = Object.create, b = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, B = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), T = (t) => {
|
|
157
|
-
throw TypeError(t);
|
|
158
|
-
}, se = (t, e, o) => e in t ? b(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, ce = (t, e) => b(t, "name", { value: e, configurable: !0 }), ae = (t) => [, , , oe(t?.[B("metadata")] ?? null)], le = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], j = (t) => t !== void 0 && typeof t != "function" ? T("Function expected") : t, de = (t, e, o, c, i) => ({ kind: le[t], name: e, metadata: c, addInitializer: (a) => o._ ? T("Already initialized") : i.push(j(a || null)) }), ue = (t, e) => se(e, B("metadata"), t[3]), he = (t, e, o, c) => {
|
|
159
|
-
for (var i = 0, a = t[e >> 1], r = a && a.length; i < r; i++) a[i].call(o);
|
|
160
|
-
return c;
|
|
161
|
-
}, me = (t, e, o, c, i, a) => {
|
|
162
|
-
var r, n, l, u = e & 7, p = !1, v = 0, d = t[v] || (t[v] = []), h = u && (i = i.prototype, u < 5 && (u > 3 || !p) && ne(i, o));
|
|
163
|
-
ce(i, o);
|
|
164
|
-
for (var f = c.length - 1; f >= 0; f--)
|
|
165
|
-
l = de(u, o, n = {}, t[3], d), r = (0, c[f])(i, l), n._ = 1, j(r) && (i = r);
|
|
166
|
-
return ue(t, i), h && b(i, o, h), p ? u ^ 4 ? a : h : i;
|
|
167
|
-
}, R, y, F;
|
|
168
|
-
R = [C(["api", "wikiPage", "modal", "preferences"]), L(
|
|
169
|
-
m.object({
|
|
170
|
-
editSummary: m.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),
|
|
171
|
-
editMinor: m.boolean().description("Whether to mark the edit as minor").default(!1),
|
|
172
|
-
outSideClose: m.boolean().description("Whether to close the modal outside").default(!0),
|
|
173
|
-
watchList: m.union([
|
|
174
|
-
m.const(g.preferences).description("Follow my preferences"),
|
|
175
|
-
m.const(g.nochange).description("Keep the current watchlist status"),
|
|
176
|
-
m.const(g.watch).description("Add the page to watchlist"),
|
|
177
|
-
m.const(g.unwatch).description("Remove the page from watchlist")
|
|
178
|
-
]).description("Watchlist options").default(g.preferences)
|
|
179
|
-
}).description("Quick edit options").extra("category", "edit")
|
|
180
|
-
)];
|
|
181
|
-
class k extends (F = I) {
|
|
182
|
-
constructor(e) {
|
|
183
|
-
super(e, {}, "quick-edit"), this.ctx = e, this.DEFAULT_OPTIONS = {
|
|
184
|
-
title: "",
|
|
185
|
-
pageId: 0,
|
|
186
|
-
revision: 0,
|
|
187
|
-
section: void 0,
|
|
188
|
-
editMinor: !1,
|
|
189
|
-
editSummary: "",
|
|
190
|
-
createOnly: !1,
|
|
191
|
-
reloadAfterSave: !0
|
|
192
|
-
}, this.ctx.root.set("quickEdit", ie(this, "showModal"));
|
|
193
|
-
}
|
|
194
|
-
start() {
|
|
195
|
-
this.ctx.inject(["toolbox"], (e) => {
|
|
196
|
-
this.injectToolbox(e), e.on("dispose", () => {
|
|
197
|
-
this.removeToolbox(e);
|
|
198
|
-
});
|
|
199
|
-
}), this.ctx.plugin(w);
|
|
200
|
-
}
|
|
201
|
-
async showModal(e) {
|
|
202
|
-
typeof e > "u" ? e = {} : typeof e == "string" && (e = {
|
|
203
|
-
title: e
|
|
204
|
-
}), e?.page && (e.title = e.page, delete e.page), !e.title && !e.pageId && !e.revision && (this.logger.warn("None of the title, pageId or revision provided. Using defaults."), e = {
|
|
205
|
-
...e,
|
|
206
|
-
title: mw.config.get("wgPageName"),
|
|
207
|
-
pageId: mw.config.get("wgArticleId"),
|
|
208
|
-
revision: mw.config.get("wgRevisionId")
|
|
209
|
-
});
|
|
210
|
-
const o = await this.ctx.preferences.get("outSideClose"), c = await this.ctx.preferences.get("watchList"), i = typeof e.editSummary == "string" ? e.editSummary : await this.ctx.preferences.get("editSummary"), a = typeof e.editMinor == "boolean" ? e.editMinor : await this.ctx.preferences.get("editMinor"), r = {
|
|
211
|
-
...this.DEFAULT_OPTIONS,
|
|
212
|
-
editSummary: i,
|
|
213
|
-
editMinor: a,
|
|
214
|
-
...e
|
|
215
|
-
};
|
|
216
|
-
r.editSummary || (r.editSummary = await this.ctx.preferences.get("editSummary") || ""), r || this.ctx.emit("quick-edit/init-options", { ctx: this.ctx, options: r });
|
|
217
|
-
const n = this.ctx.modal.createObject({
|
|
218
|
-
className: "ipe-quickEdit",
|
|
219
|
-
sizeClass: "large",
|
|
220
|
-
// backdrop: false,
|
|
221
|
-
// draggable: true,
|
|
222
|
-
center: !1,
|
|
223
|
-
outSideClose: o
|
|
224
|
-
}).init();
|
|
225
|
-
n.setTitle(
|
|
226
|
-
/* @__PURE__ */ s(S, { children: [
|
|
227
|
-
"Loading: ",
|
|
228
|
-
/* @__PURE__ */ s("u", { children: r.title })
|
|
229
|
-
] })
|
|
230
|
-
), n.setContent(
|
|
231
|
-
/* @__PURE__ */ s(
|
|
232
|
-
"section",
|
|
233
|
-
{
|
|
234
|
-
className: "ipe-quickEdit-loading",
|
|
235
|
-
style: {
|
|
236
|
-
height: "70vh",
|
|
237
|
-
display: "flex",
|
|
238
|
-
flexDirection: "column",
|
|
239
|
-
justifyContent: "center",
|
|
240
|
-
alignItems: "center"
|
|
241
|
-
},
|
|
242
|
-
children: /* @__PURE__ */ s(D, {})
|
|
243
|
-
}
|
|
244
|
-
)
|
|
245
|
-
), n.addButton({
|
|
246
|
-
side: "right",
|
|
247
|
-
type: "button",
|
|
248
|
-
className: "is-danger is-ghost",
|
|
249
|
-
label: "Cancel",
|
|
250
|
-
method() {
|
|
251
|
-
n.close();
|
|
252
|
-
}
|
|
253
|
-
}), n.show(), this.ctx.emit("quick-edit/show-modal", { ctx: this.ctx, modal: n, options: r });
|
|
254
|
-
let l;
|
|
255
|
-
try {
|
|
256
|
-
if (l = await this.getWikiPageFromPayload(r), l.pageInfo.special)
|
|
257
|
-
throw new Error("Special page is not editable");
|
|
258
|
-
} catch (d) {
|
|
259
|
-
n.off(n.Event.Close), n.close(), this.ctx.modal.notify("error", {
|
|
260
|
-
content: d instanceof Error ? d.message : String(d)
|
|
261
|
-
});
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
n.setTitle(
|
|
265
|
-
/* @__PURE__ */ s(S, { children: [
|
|
266
|
-
"Quick ",
|
|
267
|
-
l.pageInfo.pageid === 0 ? "Create" : "Edit",
|
|
268
|
-
":",
|
|
269
|
-
" ",
|
|
270
|
-
/* @__PURE__ */ s("u", { children: l.pageInfo.title })
|
|
271
|
-
] })
|
|
272
|
-
);
|
|
273
|
-
const u = [];
|
|
274
|
-
l.pageInfo.pageid === 0 && u.push(
|
|
275
|
-
/* @__PURE__ */ s(E, { title: "Attention", type: "important", children: /* @__PURE__ */ s("p", { children: "This page does not exist." }) })
|
|
276
|
-
), l.pageInfo.pageid && l.pageInfo.lastrevid !== l.revisions[0]?.revid && u.push(
|
|
277
|
-
/* @__PURE__ */ s(E, { title: "Attention", type: "warning", children: /* @__PURE__ */ s("p", { children: "You are editing a revision that is not the latest." }) })
|
|
278
|
-
), this.ctx.emit("quick-edit/edit-notice", {
|
|
279
|
-
ctx: this.ctx,
|
|
280
|
-
options: r,
|
|
281
|
-
modal: n,
|
|
282
|
-
wikiPage: l,
|
|
283
|
-
editNotices: u
|
|
284
|
-
});
|
|
285
|
-
const p = /* @__PURE__ */ s("form", { className: "ipe-quickEdit__form", children: [
|
|
286
|
-
/* @__PURE__ */ s("div", { className: "ipe-quickEdit__notices", children: u }),
|
|
287
|
-
/* @__PURE__ */ s("div", { className: "ipe-quickEdit__content", children: /* @__PURE__ */ s("textarea", { className: "ipe-quickEdit__textarea", name: "text", id: "wpTextbox1", children: l.revisions[0]?.content || "" }) }),
|
|
288
|
-
/* @__PURE__ */ s(
|
|
289
|
-
"div",
|
|
290
|
-
{
|
|
291
|
-
class: "ipe-quickEdit__options",
|
|
292
|
-
style: {
|
|
293
|
-
display: "flex",
|
|
294
|
-
flexDirection: "column",
|
|
295
|
-
gap: "1rem",
|
|
296
|
-
marginTop: "1rem"
|
|
297
|
-
},
|
|
298
|
-
children: [
|
|
299
|
-
/* @__PURE__ */ s(z, { label: "Summary", id: "summary", name: "summary", value: r.editSummary }),
|
|
300
|
-
/* @__PURE__ */ s("div", { className: "ipe-input-box", children: [
|
|
301
|
-
/* @__PURE__ */ s("label", { htmlFor: "watchlist", style: { display: "block" }, children: "Watchlist" }),
|
|
302
|
-
/* @__PURE__ */ s("div", { style: { display: "flex", gap: "1rem" }, children: [
|
|
303
|
-
g.preferences,
|
|
304
|
-
g.nochange,
|
|
305
|
-
g.watch,
|
|
306
|
-
g.unwatch
|
|
307
|
-
].map((d) => /* @__PURE__ */ s(
|
|
308
|
-
U,
|
|
309
|
-
{
|
|
310
|
-
name: "watchlist",
|
|
311
|
-
value: d,
|
|
312
|
-
inputProps: { checked: c === d },
|
|
313
|
-
children: d
|
|
314
|
-
},
|
|
315
|
-
d
|
|
316
|
-
)) })
|
|
317
|
-
] }),
|
|
318
|
-
/* @__PURE__ */ s("div", { style: { display: "flex", gap: "1rem" }, children: [
|
|
319
|
-
/* @__PURE__ */ s(P, { name: "minor", id: "minor", checked: r.editMinor, children: "Minor edit" }),
|
|
320
|
-
/* @__PURE__ */ s(P, { name: "reloadAfterSave", id: "reloadAfterSave", checked: r.reloadAfterSave, children: "Reload after save" })
|
|
321
|
-
] })
|
|
322
|
-
]
|
|
323
|
-
}
|
|
324
|
-
),
|
|
325
|
-
!1
|
|
326
|
-
] });
|
|
327
|
-
n.setContent(p), n.addButton(
|
|
328
|
-
{
|
|
329
|
-
side: "left",
|
|
330
|
-
className: "is-primary submit-btn",
|
|
331
|
-
label: "Submit",
|
|
332
|
-
method: () => {
|
|
333
|
-
const d = new FormData(p);
|
|
334
|
-
n.setLoadingState(!0), this.handleSubmit({
|
|
335
|
-
wikiPage: l,
|
|
336
|
-
text: d.get("text"),
|
|
337
|
-
summary: d.get("summary"),
|
|
338
|
-
minor: d.get("minor") === "on",
|
|
339
|
-
section: r.section,
|
|
340
|
-
createonly: l.pageid === 0,
|
|
341
|
-
watchlist: c
|
|
342
|
-
}).then(async () => {
|
|
343
|
-
n.setOptions({
|
|
344
|
-
beforeClose: A
|
|
345
|
-
}), n.close(), this.ctx.modal.notify("success", {
|
|
346
|
-
title: "Submission Successful",
|
|
347
|
-
content: "Your changes have been saved."
|
|
348
|
-
}), d.get("reloadAfterSave") && (await re(500), location.reload());
|
|
349
|
-
}).catch((h) => {
|
|
350
|
-
this.ctx.modal.notify("error", {
|
|
351
|
-
title: "Submission Error",
|
|
352
|
-
content: h instanceof Error ? h.message : String(h)
|
|
353
|
-
}), n.setLoadingState(!1);
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
0
|
|
358
|
-
), n.setOptions({
|
|
359
|
-
beforeClose: () => {
|
|
360
|
-
const d = l.revisions[0]?.content || "";
|
|
361
|
-
return (p.querySelector("textarea")?.value || "") === d ? !0 : (this.ctx.modal.confirm(
|
|
362
|
-
{
|
|
363
|
-
className: "is-primary",
|
|
364
|
-
title: "Unsaved Changes",
|
|
365
|
-
content: "All edit contents will be lost after closing the modal. Are you sure you want to close?",
|
|
366
|
-
center: !0,
|
|
367
|
-
okBtn: {
|
|
368
|
-
label: "Give Up",
|
|
369
|
-
className: "is-danger is-ghost"
|
|
370
|
-
},
|
|
371
|
-
cancelBtn: {
|
|
372
|
-
label: "Continue Editing",
|
|
373
|
-
className: "is-primary is-ghost"
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
(f) => (f && (n.setOptions({
|
|
377
|
-
beforeClose: A
|
|
378
|
-
}), n.close()), !0)
|
|
379
|
-
), !1);
|
|
380
|
-
}
|
|
381
|
-
}), this.ctx.emit("quick-edit/wiki-page", {
|
|
382
|
-
ctx: this.ctx,
|
|
383
|
-
options: r,
|
|
384
|
-
modal: n,
|
|
385
|
-
wikiPage: l
|
|
386
|
-
});
|
|
387
|
-
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?");
|
|
388
|
-
window.addEventListener("beforeunload", v), n.on(n.Event.Close, () => {
|
|
389
|
-
window.removeEventListener("beforeunload", v);
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
async handleSubmit(e) {
|
|
393
|
-
const o = e.wikiPage, c = e.summary || "", i = e.text || "", a = e.minor, r = e.createonly, n = e.watchlist, l = e.section;
|
|
394
|
-
return o.edit(
|
|
395
|
-
{
|
|
396
|
-
summary: c,
|
|
397
|
-
text: i,
|
|
398
|
-
watchlist: n,
|
|
399
|
-
section: l
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
minor: a,
|
|
403
|
-
createonly: r
|
|
404
|
-
}
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
async getWikiPageFromPayload(e) {
|
|
408
|
-
if (e.revision)
|
|
409
|
-
return this.ctx.wikiPage.newFromRevision(e.revision, e.section);
|
|
410
|
-
if (e.pageId)
|
|
411
|
-
return this.ctx.wikiPage.newFromPageId(e.pageId, e.section);
|
|
412
|
-
if (e.title)
|
|
413
|
-
return this.ctx.wikiPage.newFromTitle(e.title, !1, e.section);
|
|
414
|
-
throw new Error("Invalid payload");
|
|
415
|
-
}
|
|
416
|
-
injectToolbox(e) {
|
|
417
|
-
e.toolbox.addButton({
|
|
418
|
-
id: "quick-edit",
|
|
419
|
-
group: "group1",
|
|
420
|
-
index: 0,
|
|
421
|
-
icon: /* @__PURE__ */ s(
|
|
422
|
-
"svg",
|
|
423
|
-
{
|
|
424
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
425
|
-
width: "24",
|
|
426
|
-
height: "24",
|
|
427
|
-
viewBox: "0 0 24 24",
|
|
428
|
-
fill: "none",
|
|
429
|
-
stroke: "currentColor",
|
|
430
|
-
"stroke-width": "2",
|
|
431
|
-
"stroke-linecap": "round",
|
|
432
|
-
"stroke-linejoin": "round",
|
|
433
|
-
class: "icon icon-tabler icons-tabler-outline icon-tabler-edit",
|
|
434
|
-
children: [
|
|
435
|
-
/* @__PURE__ */ s("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
436
|
-
/* @__PURE__ */ s("path", { d: "M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" }),
|
|
437
|
-
/* @__PURE__ */ s("path", { d: "M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" }),
|
|
438
|
-
/* @__PURE__ */ s("path", { d: "M16 5l3 3" })
|
|
439
|
-
]
|
|
440
|
-
}
|
|
441
|
-
),
|
|
442
|
-
tooltip: "Edit this page quickly",
|
|
443
|
-
onClick: () => this.showModal({
|
|
444
|
-
revision: mw.config.get("wgRevisionId")
|
|
445
|
-
})
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
removeToolbox(e) {
|
|
449
|
-
e.toolbox.removeButton("quick-edit");
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
y = ae(F);
|
|
453
|
-
k = me(y, 0, "PluginQuickEdit", R, k);
|
|
454
|
-
he(y, 1, k);
|
|
455
|
-
export {
|
|
456
|
-
k as PluginQuickEdit
|
|
457
|
-
};
|
|
458
|
-
//# sourceMappingURL=index-rMDuLpcz.js.map
|