@inpageedit/core 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +27 -0
- package/dist/IconQuickEdit-YVn1ANbm.js.map +1 -0
- package/dist/InPageEdit.d.ts +7 -5
- 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 +1 -1
- 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.map +1 -1
- package/dist/index--xn9BebC.js +1257 -0
- package/dist/{index-5zB57uWM.js.map → index--xn9BebC.js.map} +1 -1
- package/dist/{index-SDBp__LY.js → index-BT1mN_St.js} +68 -65
- package/dist/{index-SDBp__LY.js.map → index-BT1mN_St.js.map} +1 -1
- package/dist/index-Bh70Udzi.js.map +1 -1
- package/dist/index-C0V2s48o.js +122 -0
- package/dist/index-C0V2s48o.js.map +1 -0
- package/dist/index-CvhkVj_L.js.map +1 -1
- package/dist/{index-clwjxJi5.js → index-DDWds9Jg.js} +77 -74
- package/dist/index-DDWds9Jg.js.map +1 -0
- package/dist/index-DDef1ojx.js +166 -0
- package/dist/index-DDef1ojx.js.map +1 -0
- package/dist/{index-BqqQgaGG.js → index-DTA86mHU.js} +5 -4
- package/dist/index-DTA86mHU.js.map +1 -0
- package/dist/{index-CPCQc37I.js → index-DlgTb4XY.js} +4 -4
- package/dist/index-DlgTb4XY.js.map +1 -0
- package/dist/{index-BnRuHI16.js → index-DpLwTw4C.js} +1967 -1693
- package/dist/index-DpLwTw4C.js.map +1 -0
- package/dist/{index-ClYojws9.js → index-TzKe6Ebm.js} +8 -7
- package/dist/index-TzKe6Ebm.js.map +1 -0
- package/dist/index-VzP81S7B.js +139 -0
- package/dist/index-VzP81S7B.js.map +1 -0
- package/dist/index-lZkYoUca.js.map +1 -1
- package/dist/index-loWqosf7.js +331 -0
- package/dist/index-loWqosf7.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
- package/dist/models/WikiPage/index.d.ts +42 -47
- package/dist/models/WikiTitle/index.d.ts +3 -2
- package/dist/noop-ClDc6zv4.js.map +1 -1
- package/dist/plugins/in-article-links/index.d.ts +5 -17
- package/dist/plugins/quick-delete/index.d.ts +7 -5
- package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +2 -0
- package/dist/plugins/quick-diff/components/DiffTable.d.ts +17 -0
- package/dist/plugins/quick-edit/index.d.ts +12 -10
- package/dist/plugins/quick-move/index.d.ts +3 -1
- package/dist/plugins/quick-preview/index.d.ts +13 -16
- package/dist/plugins/quick-redirect/index.d.ts +3 -1
- package/dist/plugins/toolbox/index.d.ts +7 -2
- package/dist/services/ApiService.d.ts +2 -2
- package/dist/services/ModalService/IPEModal.d.ts +1 -1
- package/dist/services/WikiMetadataService.d.ts +108 -0
- package/dist/services/WikiPageService.d.ts +8 -7
- package/dist/services/WikiTitleService.d.ts +43 -3
- package/dist/style.css +1 -1
- package/dist/types/{SiteMetadata.d.ts → WikiMetadata.d.ts} +17 -17
- 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 +11 -2
- package/dist/index-5zB57uWM.js +0 -1142
- package/dist/index-B7Ok-t-3.js +0 -128
- package/dist/index-B7Ok-t-3.js.map +0 -1
- package/dist/index-BHruEVsx.js +0 -319
- package/dist/index-BHruEVsx.js.map +0 -1
- package/dist/index-BnRuHI16.js.map +0 -1
- package/dist/index-BqqQgaGG.js.map +0 -1
- package/dist/index-Bs5MFAHs.js +0 -110
- package/dist/index-Bs5MFAHs.js.map +0 -1
- package/dist/index-C9QOZJ8o.js +0 -167
- package/dist/index-C9QOZJ8o.js.map +0 -1
- package/dist/index-CPCQc37I.js.map +0 -1
- package/dist/index-ClYojws9.js.map +0 -1
- package/dist/index-clwjxJi5.js.map +0 -1
- package/dist/services/SiteMetadataService.d.ts +0 -58
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { j as i, P as y } from "./index-CvhkVj_L.js";
|
|
2
|
-
import { B as S, I as q } from "./index-
|
|
2
|
+
import { B as S, I as q } from "./index-DpLwTw4C.js";
|
|
3
3
|
import { T as F } from "./index-Bh70Udzi.js";
|
|
4
4
|
import { C as u } from "./CheckBox-D3rHnX7I.js";
|
|
5
5
|
import { I as j } from "./InputBox-BV4m05Xs.js";
|
|
6
|
-
var E = Object.create, h = Object.defineProperty, I = Object.getOwnPropertyDescriptor,
|
|
6
|
+
var E = Object.create, h = Object.defineProperty, I = Object.getOwnPropertyDescriptor, k = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), b = (t) => {
|
|
7
7
|
throw TypeError(t);
|
|
8
|
-
}, B = (t, e, o) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, T = (t, e) => h(t, "name", { value: e, configurable: !0 }), C = (t) => [, , , E(t?.[
|
|
8
|
+
}, B = (t, e, o) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, T = (t, e) => h(t, "name", { value: e, configurable: !0 }), C = (t) => [, , , E(t?.[k("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], _ = (t) => t !== void 0 && typeof t != "function" ? b("Function expected") : t, D = (t, e, o, a, r) => ({ kind: z[t], name: e, metadata: a, addInitializer: (n) => o._ ? b("Already initialized") : r.push(_(n || null)) }), O = (t, e) => B(e, k("metadata"), t[3]), N = (t, e, o, a) => {
|
|
9
9
|
for (var r = 0, n = t[e >> 1], s = n && n.length; r < s; r++) n[r].call(o);
|
|
10
10
|
return a;
|
|
11
11
|
}, Q = (t, e, o, a, r, n) => {
|
|
12
|
-
var s, c, g, l = e & 7, f = !1,
|
|
12
|
+
var s, c, g, l = e & 7, f = !1, w = 0, P = t[w] || (t[w] = []), d = l && (r = r.prototype, l < 5 && (l > 3 || !f) && I(r, o));
|
|
13
13
|
T(r, o);
|
|
14
14
|
for (var m = a.length - 1; m >= 0; m--)
|
|
15
15
|
g = D(l, o, c = {}, t[3], P), s = (0, a[m])(r, g), c._ = 1, _(s) && (r = s);
|
|
16
16
|
return O(t, r), d && h(r, o, d), f ? l ^ 4 ? n : d : r;
|
|
17
17
|
}, M, p, x;
|
|
18
|
-
M = [q(["modal", "
|
|
18
|
+
M = [q(["modal", "wiki"])];
|
|
19
19
|
class v extends (x = S) {
|
|
20
20
|
constructor(e) {
|
|
21
21
|
super(e, {}, "quick-move"), this.ctx = e, e.set("quickMove", this.quickMove.bind(this)), e.set("movePage", this.movePage.bind(this));
|
|
@@ -55,6 +55,7 @@ class v extends (x = S) {
|
|
|
55
55
|
),
|
|
56
56
|
tooltip: "Quick Move",
|
|
57
57
|
group: "group1",
|
|
58
|
+
index: 1,
|
|
58
59
|
onClick: () => {
|
|
59
60
|
this.quickMove(
|
|
60
61
|
a ? {
|
|
@@ -133,7 +134,7 @@ class v extends (x = S) {
|
|
|
133
134
|
),
|
|
134
135
|
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(u, { name: "movetalk", id: "movetalk", checked: e?.movetalk, children: "Move talk page" }) }),
|
|
135
136
|
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(u, { name: "movesubpages", id: "movesubpages", checked: e?.movesubpages, children: "Move subpage(s) (up to 100)" }) }),
|
|
136
|
-
this.ctx.
|
|
137
|
+
this.ctx.wiki.hasRight("suppressredirect") && /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(u, { name: "noredirect", id: "noredirect", checked: e?.noredirect, children: "Move without leaving a redirect" }) }),
|
|
137
138
|
/* @__PURE__ */ i(j, { label: "Reason", id: "reason", name: "reason", value: e?.reason })
|
|
138
139
|
]
|
|
139
140
|
}
|
|
@@ -163,4 +164,4 @@ N(p, 1, v);
|
|
|
163
164
|
export {
|
|
164
165
|
v as PluginQuickMove
|
|
165
166
|
};
|
|
166
|
-
//# sourceMappingURL=index-
|
|
167
|
+
//# sourceMappingURL=index-TzKe6Ebm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-TzKe6Ebm.js","sources":["../src/plugins/quick-move/index.tsx"],"sourcesContent":["import { Inject, InPageEdit } from '@/InPageEdit'\r\n\r\ndeclare module '@/InPageEdit' {\r\n interface InPageEdit {\r\n quickMove: PluginQuickMove['quickMove']\r\n movePage: PluginQuickMove['movePage']\r\n }\r\n}\r\n\r\nexport interface MovePageOptions {\r\n from: string\r\n to: string\r\n reason?: string\r\n movetalk?: boolean\r\n movesubpages?: boolean\r\n noredirect?: boolean\r\n}\r\nexport interface QuickMoveOptions extends Partial<MovePageOptions> {\r\n lockFromField?: boolean\r\n lockToField?: boolean\r\n}\r\n\r\n@Inject(['modal', 'wiki'])\r\nexport class PluginQuickMove extends BasePlugin {\r\n constructor(public ctx: InPageEdit) {\r\n super(ctx, {}, 'quick-move')\r\n ctx.set('quickMove', this.quickMove.bind(this))\r\n ctx.set('movePage', this.movePage.bind(this))\r\n }\r\n\r\n protected start(): Promise<void> | void {\r\n this.ctx.inject(['toolbox'], (ctx) => {\r\n this.injectToolbox(ctx)\r\n })\r\n }\r\n\r\n private injectToolbox(ctx: InPageEdit) {\r\n const curPageName = window.mw?.config.get('wgPageName') || ''\r\n const canEdit = window.mw?.config.get('wgIsProbablyEditable')\r\n ctx.toolbox.addButton({\r\n id: 'quick-move',\r\n icon: (\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n width=\"24\"\r\n height=\"24\"\r\n viewBox=\"0 0 24 24\"\r\n fill=\"none\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-forms\"\r\n >\r\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\r\n <path d=\"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3\" />\r\n <path d=\"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3\" />\r\n <path d=\"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7\" />\r\n <path d=\"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1\" />\r\n <path d=\"M17 12h.01\" />\r\n <path d=\"M13 12h.01\" />\r\n </svg>\r\n ),\r\n tooltip: 'Quick Move',\r\n group: 'group1',\r\n index: 1,\r\n onClick: () => {\r\n this.quickMove(\r\n canEdit\r\n ? {\r\n lockFromField: true,\r\n from: curPageName,\r\n }\r\n : {}\r\n )\r\n },\r\n })\r\n }\r\n\r\n quickMove(options?: Partial<QuickMoveOptions>) {\r\n const modal = this.ctx.modal\r\n .createObject({\r\n title: 'Quick Move',\r\n content: (<ProgressBar />) as HTMLElement,\r\n className: 'quick-move compact-buttons',\r\n sizeClass: 'smallToMedium',\r\n center: true,\r\n })\r\n .init()\r\n\r\n let formRef: HTMLFormElement | null = null\r\n modal.setContent(\r\n (\r\n <form\r\n ref={(el) => (formRef = el)}\r\n style={{\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem',\r\n }}\r\n onSubmit={(e) => {\r\n e.preventDefault()\r\n formRef?.checkValidity()\r\n if (!formRef?.reportValidity()) {\r\n return\r\n }\r\n const formData = new FormData(formRef!)\r\n const options = {\r\n from: formData.get('from')?.toString().trim()!,\r\n to: formData.get('to')?.toString().trim()!,\r\n reason: (formData.get('reason') as string) || '',\r\n movetalk: formData.get('movetalk') === 'on',\r\n movesubpages: formData.get('movesubpages') === 'on',\r\n noredirect: formData.get('noredirect') === 'on',\r\n }\r\n if (!options.from || !options.to) {\r\n this.ctx.modal.notify('error', {\r\n title: 'Failed to move',\r\n content: 'From and to are required.',\r\n })\r\n return\r\n }\r\n modal.setLoadingState(true)\r\n this.movePage(options)\r\n .then(() => {\r\n location.reload()\r\n })\r\n .catch((error) => {\r\n modal.setLoadingState(false)\r\n this.ctx.modal.notify('error', {\r\n title: 'Failed to move',\r\n content: error instanceof Error ? error.message : String(error),\r\n })\r\n })\r\n }}\r\n >\r\n <TwinSwapInput\r\n inputs={[\r\n {\r\n label: 'Move from',\r\n name: 'from',\r\n value: options?.from,\r\n required: true,\r\n },\r\n {\r\n label: 'Move to',\r\n name: 'to',\r\n value: options?.to,\r\n required: true,\r\n },\r\n ]}\r\n />\r\n <div>\r\n <CheckBox name=\"movetalk\" id=\"movetalk\" checked={options?.movetalk}>\r\n Move talk page\r\n </CheckBox>\r\n </div>\r\n <div>\r\n <CheckBox name=\"movesubpages\" id=\"movesubpages\" checked={options?.movesubpages}>\r\n Move subpage(s) (up to 100)\r\n </CheckBox>\r\n </div>\r\n {this.ctx.wiki.hasRight('suppressredirect') && (\r\n <div>\r\n <CheckBox name=\"noredirect\" id=\"noredirect\" checked={options?.noredirect}>\r\n Move without leaving a redirect\r\n </CheckBox>\r\n </div>\r\n )}\r\n <InputBox label=\"Reason\" id=\"reason\" name=\"reason\" value={options?.reason} />\r\n </form>\r\n ) as HTMLElement\r\n )\r\n\r\n modal.setButtons([\r\n {\r\n label: 'Move',\r\n className: 'is-primary is-ghost',\r\n method: () => {\r\n formRef?.dispatchEvent(new Event('submit'))\r\n },\r\n },\r\n ])\r\n\r\n return modal.show()\r\n }\r\n\r\n async movePage(options: MovePageOptions) {\r\n const { from, to, reason = '', ...rest } = options\r\n\r\n if (!from || !to) {\r\n throw new Error('From and to titles are required.')\r\n }\r\n if (from === to) {\r\n throw new Error('From and to titles cannot be the same.')\r\n }\r\n\r\n const wikiPage = await this.ctx.wikiPage.newFromTitle(from)\r\n return wikiPage.moveTo(to, reason, rest)\r\n }\r\n}\r\n"],"names":["_PluginQuickMove_decorators","_init","_a","Inject","PluginQuickMove","BasePlugin","ctx","curPageName","canEdit","jsxs","jsx","options","modal","ProgressBar","formRef","el","e","formData","error","TwinSwapInput","CheckBox","InputBox","from","to","reason","rest","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAsBAF,IAAA,CAACG,EAAO,CAAC,SAAS,MAAM,CAAC,CAAA;AAClB,MAAMC,WAAwBF,IAAAG,GAAW;AAAA,EAC9C,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,YAAY,GADV,KAAA,MAAAA,GAEjBA,EAAI,IAAI,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC,GAC9CA,EAAI,IAAI,YAAY,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA,EAEU,QAA8B;AACtC,SAAK,IAAI,OAAO,CAAC,SAAS,GAAG,CAACA,MAAQ;AACpC,WAAK,cAAcA,CAAG;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEQ,cAAcA,GAAiB;AACrC,UAAMC,IAAc,OAAO,IAAI,OAAO,IAAI,YAAY,KAAK,IACrDC,IAAU,OAAO,IAAI,OAAO,IAAI,sBAAsB;AAC5D,IAAAF,EAAI,QAAQ,UAAU;AAAA,MACpB,IAAI;AAAA,MACJ,MACEG,gBAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,QAAO;AAAA,UACP,gBAAa;AAAA,UACb,kBAAe;AAAA,UACf,mBAAgB;AAAA,UAChB,OAAM;AAAA,UAEN,UAAA;AAAA,YAAA,gBAAAC,EAAC,UAAK,QAAO,QAAO,GAAE,iBAAgB,MAAK,QAAO;AAAA,YAClD,gBAA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U,GAAA,EAAS,MAAK,gBAAe,IAAG,gBAAe,SAAST,GAAS,cAAc,UAAA,8BAAA,CAEhF,GACF;AAAA,YACC,KAAK,IAAI,KAAK,SAAS,kBAAkB,uBACvC,OAAA,EACC,UAAA,gBAAAD,EAACU,GAAA,EAAS,MAAK,cAAa,IAAG,cAAa,SAAST,GAAS,YAAY,6CAE1E,GACF;AAAA,YAEF,gBAAAD,EAACW,GAAA,EAAS,OAAM,UAAS,IAAG,UAAS,MAAK,UAAS,OAAOV,GAAS,OAAA,CAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAC7E,GAIJC,EAAM,WAAW;AAAA,MACf;AAAA,QACE,OAAO;AAAA,QACP,WAAW;AAAA,QACX,QAAQ,MAAM;AACZ,UAAAE,GAAS,cAAc,IAAI,MAAM,QAAQ,CAAC;AAAA,QAC5C;AAAA,MAAA;AAAA,IACF,CACD,GAEMF,EAAM,KAAA;AAAA,EACf;AAAA,EAEA,MAAM,SAASD,GAA0B;AACvC,UAAM,EAAE,MAAAW,GAAM,IAAAC,GAAI,QAAAC,IAAS,IAAI,GAAGC,MAASd;AAE3C,QAAI,CAACW,KAAQ,CAACC;AACZ,YAAM,IAAI,MAAM,kCAAkC;AAEpD,QAAID,MAASC;AACX,YAAM,IAAI,MAAM,wCAAwC;AAI1D,YADiB,MAAM,KAAK,IAAI,SAAS,aAAaD,CAAI,GAC1C,OAAOC,GAAIC,GAAQC,CAAI;AAAA,EACzC;AACF;AAjLOxB,IAAAyB,EAAAxB,CAAA;AAAME,IAANuB,2BADP3B,GACaI,CAAA;AAANwB,EAAA3B,GAAA,GAAMG,CAAA;"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { j as a } from "./index-CvhkVj_L.js";
|
|
2
|
+
import { b as D, I as C, S as m } from "./index-DpLwTw4C.js";
|
|
3
|
+
import { R as T } from "./Preferences-Bg3J5Ur9.js";
|
|
4
|
+
var E = Object.create, x = Object.defineProperty, q = Object.getOwnPropertyDescriptor, y = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), _ = (e) => {
|
|
5
|
+
throw TypeError(e);
|
|
6
|
+
}, I = (e, t, o) => t in e ? x(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, $ = (e, t) => x(e, "name", { value: t, configurable: !0 }), z = (e) => [, , , E(e?.[y("metadata")] ?? null)], j = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], w = (e) => e !== void 0 && typeof e != "function" ? _("Function expected") : e, A = (e, t, o, n, r) => ({ kind: j[e], name: t, metadata: n, addInitializer: (i) => o._ ? _("Already initialized") : r.push(w(i || null)) }), M = (e, t) => I(t, y("metadata"), e[3]), O = (e, t, o, n) => {
|
|
7
|
+
for (var r = 0, i = e[t >> 1], c = i && i.length; r < c; r++) i[r].call(o);
|
|
8
|
+
return n;
|
|
9
|
+
}, k = (e, t, o, n, r, i) => {
|
|
10
|
+
var c, d, g, l = t & 7, b = !1, s = 0, u = e[s] || (e[s] = []), h = l && (r = r.prototype, l < 5 && (l > 3 || !b) && q(r, o));
|
|
11
|
+
$(r, o);
|
|
12
|
+
for (var p = n.length - 1; p >= 0; p--)
|
|
13
|
+
g = A(l, o, d = {}, e[3], u), c = (0, n[p])(r, g), d._ = 1, w(c) && (r = c);
|
|
14
|
+
return M(e, r), h && x(r, o, h), b ? l ^ 4 ? i : h : r;
|
|
15
|
+
}, S, f, P;
|
|
16
|
+
S = [T(
|
|
17
|
+
m.object({
|
|
18
|
+
toolboxAlwaysShow: m.boolean().description("Make the toolbox opened by default").default(!1)
|
|
19
|
+
}).description("Toolbox preferences")
|
|
20
|
+
), C(["preferences"])];
|
|
21
|
+
class v extends (P = D) {
|
|
22
|
+
constructor(t) {
|
|
23
|
+
super(t, "toolbox", !1), this.ctx = t, this.container = void 0;
|
|
24
|
+
}
|
|
25
|
+
async start() {
|
|
26
|
+
this.container = this.createToolbox(), this.ctx.preferences.get("toolboxAlwaysShow").then((t) => {
|
|
27
|
+
t && this.container.classList.add("is-persistent");
|
|
28
|
+
}), this.setupHoverLogic(), document.body.appendChild(this.container), this.updateButtonDelays();
|
|
29
|
+
}
|
|
30
|
+
stop() {
|
|
31
|
+
this.container?.remove();
|
|
32
|
+
}
|
|
33
|
+
get isPersistent() {
|
|
34
|
+
return this.container.classList.contains("is-persistent");
|
|
35
|
+
}
|
|
36
|
+
setupHoverLogic() {
|
|
37
|
+
let t = null;
|
|
38
|
+
this.container.addEventListener("mouseenter", () => {
|
|
39
|
+
t && (clearTimeout(t), t = null), this.isPersistent || this.container.classList.add("is-hovered");
|
|
40
|
+
}), this.container.addEventListener("mouseleave", () => {
|
|
41
|
+
this.isPersistent || (t = window.setTimeout(() => {
|
|
42
|
+
this.container.classList.remove("is-hovered");
|
|
43
|
+
}, 150));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 计算按钮动画延迟
|
|
48
|
+
* @param index 按钮索引(从0开始)
|
|
49
|
+
* @param totalCount 总按钮数量
|
|
50
|
+
* @returns 延迟时间(秒)
|
|
51
|
+
*/
|
|
52
|
+
calculateButtonDelay(t, o) {
|
|
53
|
+
if (o <= 1) return 0;
|
|
54
|
+
const n = 0.15, r = t / (o - 1), i = n * Math.sqrt(r);
|
|
55
|
+
return Math.round(i * 1e3) / 1e3;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 更新按钮组的动画延迟
|
|
59
|
+
*/
|
|
60
|
+
updateButtonDelays() {
|
|
61
|
+
this.container.querySelectorAll(".btn-group").forEach((o) => {
|
|
62
|
+
const n = o.querySelectorAll(".btn-tip-group"), r = n.length;
|
|
63
|
+
n.forEach((i, c) => {
|
|
64
|
+
const d = this.calculateButtonDelay(c, r);
|
|
65
|
+
i.style.setProperty("--transition-delay", `${d}s`), i.style.setProperty("--max-transition-delay", "0.15s");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
createToolbox() {
|
|
70
|
+
return /* @__PURE__ */ a("div", { id: "ipe-edit-toolbox", children: [
|
|
71
|
+
/* @__PURE__ */ a("ul", { className: "btn-group group1", style: { display: "flex", flexDirection: "column" } }),
|
|
72
|
+
/* @__PURE__ */ a("ul", { className: "btn-group group2", style: { display: "flex", flexDirection: "row" } }),
|
|
73
|
+
/* @__PURE__ */ a(
|
|
74
|
+
"button",
|
|
75
|
+
{
|
|
76
|
+
className: "ipe-toolbox-btn",
|
|
77
|
+
id: "toolbox-toggler",
|
|
78
|
+
onClick: () => {
|
|
79
|
+
this.toggle();
|
|
80
|
+
},
|
|
81
|
+
children: /* @__PURE__ */ a("svg", { xmlns: "http://www.w3.org/2000/svg", width: "448", height: "512", viewBox: "0 0 448 512", children: [
|
|
82
|
+
/* @__PURE__ */ a("rect", { width: "448", height: "512", fill: "none" }),
|
|
83
|
+
/* @__PURE__ */ a(
|
|
84
|
+
"path",
|
|
85
|
+
{
|
|
86
|
+
fill: "currentColor",
|
|
87
|
+
d: "M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] })
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
normalizeButtonId(t) {
|
|
96
|
+
return t || (t = Math.random().toString(36).substring(2, 8)), `ipe-toolbox__${t.trim()}`.replace(/\s\.#/g, "-");
|
|
97
|
+
}
|
|
98
|
+
addButton(t) {
|
|
99
|
+
let { id: o, group: n, icon: r, tooltip: i, itemProps: c, buttonProps: d, onClick: g, index: l } = t;
|
|
100
|
+
o = this.normalizeButtonId(o);
|
|
101
|
+
const b = this.container.querySelector(`#${o}`);
|
|
102
|
+
b && (this.ctx.logger("toolbox").warn(`Button with id ${o} already exists, replacing it.`), b.remove());
|
|
103
|
+
let s = null;
|
|
104
|
+
if (typeof n > "u" || n === "auto") {
|
|
105
|
+
const h = this.container.querySelector(".btn-group.group1"), p = this.container.querySelector(".btn-group.group2"), B = h?.children.length || 0, L = p?.children.length || 0;
|
|
106
|
+
s = B <= L ? h : p;
|
|
107
|
+
} else
|
|
108
|
+
s = this.container.querySelector(`.btn-group.${n}`);
|
|
109
|
+
if (!s) throw new Error(`Button group ${n} not found`);
|
|
110
|
+
const u = /* @__PURE__ */ a("li", { class: "btn-tip-group", id: o, onClick: g, ...c, children: [
|
|
111
|
+
/* @__PURE__ */ a("div", { class: "btn-tip", children: i }),
|
|
112
|
+
/* @__PURE__ */ a("button", { id: `${o}-btn`, class: "ipe-toolbox-btn", ...d, children: r })
|
|
113
|
+
] });
|
|
114
|
+
return typeof l == "number" ? l <= 0 ? s.prepend(u) : l >= s.children.length ? s.appendChild(u) : s.children[l]?.before(u) : s.appendChild(u), this.ctx.emit("toolbox/button-added", {
|
|
115
|
+
ctx: this.ctx,
|
|
116
|
+
button: u
|
|
117
|
+
}), this.updateButtonDelays(), u;
|
|
118
|
+
}
|
|
119
|
+
removeButton(t) {
|
|
120
|
+
this.container.querySelector(`.ipe-toolbox-btn#${t}`)?.remove(), this.ctx.emit("toolbox/button-removed", { ctx: this.ctx, id: t }), this.updateButtonDelays();
|
|
121
|
+
}
|
|
122
|
+
getContainer() {
|
|
123
|
+
return this.container;
|
|
124
|
+
}
|
|
125
|
+
get isOpened() {
|
|
126
|
+
return this.container.classList.contains("is-persistent") || this.container.classList.contains("is-hovered");
|
|
127
|
+
}
|
|
128
|
+
toggle(t) {
|
|
129
|
+
const o = this.isPersistent, n = typeof t == "boolean" ? t : !o;
|
|
130
|
+
this.container.classList.toggle("is-persistent", n), this.container.classList.remove("is-hovered"), this.ctx.preferences.set("toolboxAlwaysShow", n);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
f = z(P);
|
|
134
|
+
v = k(f, 0, "PluginToolbox", S, v);
|
|
135
|
+
O(f, 1, v);
|
|
136
|
+
export {
|
|
137
|
+
v as PluginToolbox
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=index-VzP81S7B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-VzP81S7B.js","sources":["../src/plugins/toolbox/index.tsx"],"sourcesContent":["import { Inject, InPageEdit, Schema, Service } from '@/InPageEdit'\r\nimport { JSX, ReactElement } from 'jsx-dom'\r\nimport './styles.scss'\r\n\r\ndeclare module '@/InPageEdit' {\r\n interface InPageEdit {\r\n toolbox: PluginToolbox\r\n }\r\n interface Events {\r\n 'toolbox/button-added'(payload: { ctx: InPageEdit; button: HTMLElement }): void\r\n 'toolbox/button-removed'(payload: { ctx: InPageEdit; id: string }): void\r\n }\r\n}\r\n\r\n@RegisterPreferences(\r\n Schema.object({\r\n toolboxAlwaysShow: Schema.boolean()\r\n .description('Make the toolbox opened by default')\r\n .default(false),\r\n }).description('Toolbox preferences')\r\n)\r\n@Inject(['preferences'])\r\nexport class PluginToolbox extends Service {\r\n container!: HTMLElement\r\n\r\n constructor(public ctx: InPageEdit) {\r\n super(ctx, 'toolbox', false)\r\n }\r\n\r\n protected async start(): Promise<void> {\r\n this.container = this.createToolbox()\r\n this.ctx.preferences.get('toolboxAlwaysShow').then((val) => {\r\n if (val) {\r\n this.container.classList.add('is-persistent')\r\n }\r\n })\r\n this.setupHoverLogic()\r\n document.body.appendChild(this.container)\r\n\r\n // 初始化时更新按钮延迟\r\n this.updateButtonDelays()\r\n }\r\n\r\n protected stop(): void | Promise<void> {\r\n this.container?.remove()\r\n }\r\n\r\n private get isPersistent() {\r\n return this.container.classList.contains('is-persistent')\r\n }\r\n\r\n private setupHoverLogic() {\r\n let hoverTimeout: number | null = null\r\n\r\n // 鼠标进入时暂时展开\r\n this.container.addEventListener('mouseenter', () => {\r\n if (hoverTimeout) {\r\n clearTimeout(hoverTimeout)\r\n hoverTimeout = null\r\n }\r\n\r\n // 如果不在持久化状态,则添加hover展开效果\r\n if (!this.isPersistent) {\r\n this.container.classList.add('is-hovered')\r\n }\r\n })\r\n\r\n // 鼠标离开时收起(如果不是持久化状态)\r\n this.container.addEventListener('mouseleave', () => {\r\n if (!this.isPersistent) {\r\n hoverTimeout = window.setTimeout(() => {\r\n this.container.classList.remove('is-hovered')\r\n }, 150) // 延迟150ms收起,避免快速移动鼠标时闪烁\r\n }\r\n })\r\n }\r\n\r\n /**\r\n * 计算按钮动画延迟\r\n * @param index 按钮索引(从0开始)\r\n * @param totalCount 总按钮数量\r\n * @returns 延迟时间(秒)\r\n */\r\n private calculateButtonDelay(index: number, totalCount: number): number {\r\n if (totalCount <= 1) return 0\r\n\r\n // 总动画时长150ms = 0.15s\r\n const totalDuration = 0.15\r\n // 使用平方根函数创建非线性延迟,差值逐渐缩小\r\n const normalizedIndex = index / (totalCount - 1)\r\n const delay = totalDuration * Math.sqrt(normalizedIndex)\r\n\r\n return Math.round(delay * 1000) / 1000 // 保留3位小数\r\n }\r\n\r\n /**\r\n * 更新按钮组的动画延迟\r\n */\r\n private updateButtonDelays() {\r\n const btnGroups = this.container.querySelectorAll('.btn-group')\r\n\r\n btnGroups.forEach((group) => {\r\n const buttons = group.querySelectorAll('.btn-tip-group')\r\n const totalCount = buttons.length\r\n\r\n buttons.forEach((button, index) => {\r\n const delay = this.calculateButtonDelay(index, totalCount)\r\n ;(button as HTMLElement).style.setProperty('--transition-delay', `${delay}s`)\r\n ;(button as HTMLElement).style.setProperty('--max-transition-delay', '0.15s')\r\n })\r\n })\r\n }\r\n\r\n private createToolbox() {\r\n const toggler = (\r\n <button\r\n className=\"ipe-toolbox-btn\"\r\n id=\"toolbox-toggler\"\r\n onClick={() => {\r\n this.toggle()\r\n }}\r\n >\r\n {/* Font Awesome 5 Solid: Plus */}\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"448\" height=\"512\" viewBox=\"0 0 448 512\">\r\n <rect width=\"448\" height=\"512\" fill=\"none\" />\r\n <path\r\n fill=\"currentColor\"\r\n d=\"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32\"\r\n />\r\n </svg>\r\n </button>\r\n )\r\n const element = (\r\n <div id=\"ipe-edit-toolbox\">\r\n <ul className=\"btn-group group1\" style={{ display: 'flex', flexDirection: 'column' }}></ul>\r\n <ul className=\"btn-group group2\" style={{ display: 'flex', flexDirection: 'row' }}></ul>\r\n {toggler}\r\n </div>\r\n )\r\n\r\n return element as HTMLElement\r\n }\r\n\r\n private normalizeButtonId(id: string) {\r\n if (!id) {\r\n id = Math.random().toString(36).substring(2, 8)\r\n }\r\n return `ipe-toolbox__${id.trim()}`.replace(/\\s\\.#/g, '-')\r\n }\r\n\r\n addButton(payload: {\r\n id: string\r\n group?: 'auto' | 'group1' | 'group2'\r\n icon: string | HTMLElement | SVGElement | ReactElement\r\n tooltip?: string | HTMLElement\r\n itemProps?: JSX.IntrinsicElements['li']\r\n buttonProps?: JSX.IntrinsicElements['button']\r\n onClick?: (event: MouseEvent) => void\r\n index?: number\r\n }) {\r\n let { id, group, icon, tooltip, itemProps, buttonProps, onClick, index } = payload\r\n id = this.normalizeButtonId(id)\r\n\r\n const existingButton = this.container.querySelector(`#${id}`)\r\n if (existingButton) {\r\n this.ctx.logger('toolbox').warn(`Button with id ${id} already exists, replacing it.`)\r\n existingButton.remove()\r\n }\r\n\r\n let groupEl: HTMLElement | null = null\r\n if (typeof group === 'undefined' || group === 'auto') {\r\n // 选择按钮最少的那一组,一样多就选第一组\r\n const group1 = this.container.querySelector('.btn-group.group1') as HTMLElement\r\n const group2 = this.container.querySelector('.btn-group.group2') as HTMLElement\r\n const group1Count = group1?.children.length || 0\r\n const group2Count = group2?.children.length || 0\r\n groupEl = group1Count <= group2Count ? group1 : group2\r\n } else {\r\n groupEl = this.container.querySelector(`.btn-group.${group}`)\r\n }\r\n if (!groupEl) throw new Error(`Button group ${group} not found`)\r\n\r\n const button = (\r\n <li class=\"btn-tip-group\" id={id} onClick={onClick} {...itemProps}>\r\n <div class=\"btn-tip\">{tooltip}</div>\r\n <button id={`${id}-btn`} class=\"ipe-toolbox-btn\" {...buttonProps}>\r\n {icon}\r\n </button>\r\n </li>\r\n )\r\n\r\n if (typeof index === 'number') {\r\n if (index <= 0) {\r\n groupEl.prepend(button)\r\n } else if (index >= groupEl.children.length) {\r\n groupEl.appendChild(button)\r\n } else {\r\n groupEl.children[index]?.before(button)\r\n }\r\n } else {\r\n groupEl.appendChild(button)\r\n }\r\n\r\n this.ctx.emit('toolbox/button-added', {\r\n ctx: this.ctx,\r\n button: button as HTMLElement,\r\n })\r\n\r\n // 更新按钮延迟\r\n this.updateButtonDelays()\r\n\r\n return button as HTMLElement\r\n }\r\n\r\n removeButton(id: string) {\r\n const button = this.container.querySelector(`.ipe-toolbox-btn#${id}`)\r\n button?.remove()\r\n this.ctx.emit('toolbox/button-removed', { ctx: this.ctx, id })\r\n\r\n // 更新按钮延迟\r\n this.updateButtonDelays()\r\n }\r\n\r\n getContainer() {\r\n return this.container\r\n }\r\n\r\n get isOpened() {\r\n return (\r\n this.container.classList.contains('is-persistent') ||\r\n this.container.classList.contains('is-hovered')\r\n )\r\n }\r\n\r\n toggle(force?: boolean) {\r\n const isPersistent = this.isPersistent\r\n const newPersistent = typeof force === 'boolean' ? force : !isPersistent\r\n this.container.classList.toggle('is-persistent', newPersistent)\r\n this.container.classList.remove('is-hovered')\r\n this.ctx.preferences.set('toolboxAlwaysShow', newPersistent)\r\n }\r\n}\r\n"],"names":["_PluginToolbox_decorators","_init","_a","RegisterPreferences","Schema","Inject","PluginToolbox","Service","ctx","val","hoverTimeout","index","totalCount","totalDuration","normalizedIndex","delay","group","buttons","button","jsxs","jsx","id","payload","icon","tooltip","itemProps","buttonProps","onClick","existingButton","groupEl","group1","group2","group1Count","group2Count","force","isPersistent","newPersistent","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAcAF,IAAA,CAACG;AAAA,EACCC,EAAO,OAAO;AAAA,IACZ,mBAAmBA,EAAO,QAAA,EACvB,YAAY,oCAAoC,EAChD,QAAQ,EAAK;AAAA,EAAA,CACjB,EAAE,YAAY,qBAAqB;AACtC,GACCC,EAAO,CAAC,aAAa,CAAC,CAAA;AAChB,MAAMC,WAAsBJ,IAAAK,GAAQ;AAAA,EAGzC,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,WAAW,EAAK,GADV,KAAA,MAAAA,GAFnB,KAAA,YAAA;AAAA,EAIA;AAAA,EAEA,MAAgB,QAAuB;AACrC,SAAK,YAAY,KAAK,cAAA,GACtB,KAAK,IAAI,YAAY,IAAI,mBAAmB,EAAE,KAAK,CAACC,MAAQ;AAC1D,MAAIA,KACF,KAAK,UAAU,UAAU,IAAI,eAAe;AAAA,IAEhD,CAAC,GACD,KAAK,gBAAA,GACL,SAAS,KAAK,YAAY,KAAK,SAAS,GAGxC,KAAK,mBAAA;AAAA,EACP;AAAA,EAEU,OAA6B;AACrC,SAAK,WAAW,OAAA;AAAA,EAClB;AAAA,EAEA,IAAY,eAAe;AACzB,WAAO,KAAK,UAAU,UAAU,SAAS,eAAe;AAAA,EAC1D;AAAA,EAEQ,kBAAkB;AACxB,QAAIC,IAA8B;AAGlC,SAAK,UAAU,iBAAiB,cAAc,MAAM;AAClD,MAAIA,MACF,aAAaA,CAAY,GACzBA,IAAe,OAIZ,KAAK,gBACR,KAAK,UAAU,UAAU,IAAI,YAAY;AAAA,IAE7C,CAAC,GAGD,KAAK,UAAU,iBAAiB,cAAc,MAAM;AAClD,MAAK,KAAK,iBACRA,IAAe,OAAO,WAAW,MAAM;AACrC,aAAK,UAAU,UAAU,OAAO,YAAY;AAAA,MAC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AANiC,EAAAtC,GAAA,GAAMK,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
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","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AAA,EAAE,SAASN,GAAO,WAAW,kBAAkBK,EAAO,KAAK,IAAI,UAAA,IAAA,CAEhE;AAAA,EAAA,GAEJ;AAEF,SAAAJ,EAAI,QAAQD,GACLC;AACT;"}
|
|
1
|
+
{"version":3,"file":"index-lZkYoUca.js","sources":["../src/components/MBox/index.tsx"],"sourcesContent":["import { ReactNode } from 'jsx-dom'\r\nimport { JSX } from 'jsx-dom/jsx-runtime'\r\nimport styles from './styles.module.sass'\r\n\r\nexport type MBoxProps = {\r\n type?:\r\n | ''\r\n | 'default'\r\n | 'note'\r\n | 'info'\r\n | 'tip'\r\n | 'success'\r\n | 'important'\r\n | 'done'\r\n | 'warning'\r\n | 'caution'\r\n | 'error'\r\n title?: ReactNode\r\n content?: ReactNode\r\n closeable?: boolean\r\n titleProps?: JSX.IntrinsicElements['div']\r\n contentProps?: JSX.IntrinsicElements['div']\r\n} & JSX.IntrinsicElements['div']\r\n\r\nexport type MBoxElement = HTMLElement & {\r\n close: () => Promise<void>\r\n}\r\n\r\nexport const MBox = (props: MBoxProps) => {\r\n const {\r\n type = 'default',\r\n title,\r\n content,\r\n closeable = true,\r\n titleProps,\r\n contentProps,\r\n children,\r\n ...rest\r\n } = props\r\n let titleContent = title\r\n if (typeof title === 'undefined' && type !== 'default') {\r\n titleContent = type[0].toUpperCase() + type.slice(1).toLowerCase()\r\n }\r\n\r\n const close = async () => {\r\n if (!box) {\r\n return Promise.resolve()\r\n }\r\n const { promise, resolve } = Promise.withResolvers<void>()\r\n\r\n const animation = box.animate(\r\n [\r\n { opacity: '1', height: box.clientHeight + 'px' },\r\n { opacity: '0', height: '0px', margin: '0px' },\r\n ],\r\n {\r\n duration: 300,\r\n easing: 'ease',\r\n }\r\n )\r\n\r\n animation.addEventListener('finish', () => {\r\n box.remove()\r\n resolve()\r\n })\r\n\r\n return promise\r\n }\r\n\r\n const box = (\r\n <div className={`theme-ipe ipe-mbox mbox-type-${type || 'default'} ${styles.mbox}`} {...rest}>\r\n {titleContent && (\r\n <div className={`ipe-mbox-title ${styles.title}`} {...titleProps}>\r\n {titleContent}\r\n </div>\r\n )}\r\n <div className={`ipe-mbox-content ${styles.content}`} {...contentProps}>\r\n {children || content}\r\n </div>\r\n {closeable && (\r\n <a onClick={close} className={`ipe-mbox-close ${styles.close}`}>\r\n ×\r\n </a>\r\n )}\r\n </div>\r\n ) as MBoxElement\r\n box.close = close\r\n return box\r\n}\r\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,IACDR;AACJ,MAAIS,IAAeP;AACnB,EAAI,OAAOA,IAAU,OAAeD,MAAS,cAC3CQ,IAAeR,EAAK,CAAC,EAAE,YAAA,IAAgBA,EAAK,MAAM,CAAC,EAAE,YAAA;AAGvD,QAAMS,IAAQ,YAAY;AACxB,QAAI,CAACC;AACH,aAAO,QAAQ,QAAA;AAEjB,UAAM,EAAE,SAAAC,GAAS,SAAAC,MAAY,QAAQ,cAAA;AAarC,WAXkBF,EAAI;AAAA,MACpB;AAAA,QACE,EAAE,SAAS,KAAK,QAAQA,EAAI,eAAe,KAAA;AAAA,QAC3C,EAAE,SAAS,KAAK,QAAQ,OAAO,QAAQ,MAAA;AAAA,MAAM;AAAA,MAE/C;AAAA,QACE,UAAU;AAAA,QACV,QAAQ;AAAA,MAAA;AAAA,IACV,EAGQ,iBAAiB,UAAU,MAAM;AACzC,MAAAA,EAAI,OAAA,GACJE,EAAA;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMD,IACJG,gBAAAA,EAAC,OAAA,EAAI,WAAW,gCAAgCb,KAAQ,SAAS,IAAIc,EAAO,IAAI,IAAK,GAAGP,GACrF,UAAA;AAAA,IAAAC,KACC,gBAAAO,EAAC,SAAI,WAAW,kBAAkBD,EAAO,KAAK,IAAK,GAAGV,GACnD,UAAAI,EAAA,CACH;AAAA,IAEF,gBAAAO,EAAC,OAAA,EAAI,WAAW,oBAAoBD,EAAO,OAAO,IAAK,GAAGT,GACvD,UAAAC,KAAYJ,EAAA,CACf;AAAA,IACCC,KACC,gBAAAY,EAAC,KAAA,EAAE,SAASN,GAAO,WAAW,kBAAkBK,EAAO,KAAK,IAAI,UAAA,IAAA,CAEhE;AAAA,EAAA,GAEJ;AAEF,SAAAJ,EAAI,QAAQD,GACLC;AACT;"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { j as i, F as b, P as T } from "./index-CvhkVj_L.js";
|
|
2
|
+
import { B as C, W as m, I as M, S as h } from "./index-DpLwTw4C.js";
|
|
3
|
+
import { m as A } from "./makeCallable-LDU0xZMJ.js";
|
|
4
|
+
import { R as B } from "./Preferences-Bg3J5Ur9.js";
|
|
5
|
+
import { M as S } from "./index-lZkYoUca.js";
|
|
6
|
+
import { I as F } from "./InputBox-BV4m05Xs.js";
|
|
7
|
+
import { R as O } from "./RadioBox-nJqWsxW2.js";
|
|
8
|
+
import { C as _ } from "./CheckBox-D3rHnX7I.js";
|
|
9
|
+
import { n as E } from "./noop-ClDc6zv4.js";
|
|
10
|
+
const j = (t = 0) => new Promise((e) => setTimeout(e, t));
|
|
11
|
+
var L = Object.create, x = Object.defineProperty, D = Object.getOwnPropertyDescriptor, y = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), P = (t) => {
|
|
12
|
+
throw TypeError(t);
|
|
13
|
+
}, R = (t, e, c) => e in t ? x(t, e, { enumerable: !0, configurable: !0, writable: !0, value: c }) : t[e] = c, U = (t, e) => x(t, "name", { value: e, configurable: !0 }), W = (t) => [, , , L(t?.[y("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], q = (t) => t !== void 0 && typeof t != "function" ? P("Function expected") : t, Q = (t, e, c, l, s) => ({ kind: z[t], name: e, metadata: l, addInitializer: (d) => c._ ? P("Already initialized") : s.push(q(d || null)) }), Y = (t, e) => R(e, y("metadata"), t[3]), K = (t, e, c, l) => {
|
|
14
|
+
for (var s = 0, d = t[e >> 1], n = d && d.length; s < n; s++) d[s].call(c);
|
|
15
|
+
return l;
|
|
16
|
+
}, G = (t, e, c, l, s, d) => {
|
|
17
|
+
var n, r, a, u = e & 7, p = !1, g = 0, o = t[g] || (t[g] = []), f = u && (s = s.prototype, u < 5 && (u > 3 || !p) && D(s, c));
|
|
18
|
+
U(s, c);
|
|
19
|
+
for (var v = l.length - 1; v >= 0; v--)
|
|
20
|
+
a = Q(u, c, r = {}, t[3], o), n = (0, l[v])(s, a), r._ = 1, q(n) && (s = n);
|
|
21
|
+
return Y(t, s), f && x(s, c, f), p ? u ^ 4 ? d : f : s;
|
|
22
|
+
}, I, k, N;
|
|
23
|
+
I = [M(["api", "wikiPage", "wikiTitle", "wiki", "modal", "preferences"]), B(
|
|
24
|
+
h.object({
|
|
25
|
+
"quickEdit.editSummary": h.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),
|
|
26
|
+
"quickEdit.editMinor": h.boolean().description("Whether to mark the edit as minor").default(!1),
|
|
27
|
+
"quickEdit.outSideClose": h.boolean().description("Whether to close the modal outside").default(!0),
|
|
28
|
+
"quickEdit.watchList": h.union([
|
|
29
|
+
h.const(m.preferences).description("Follow my preferences"),
|
|
30
|
+
h.const(m.nochange).description("Keep the current watchlist status"),
|
|
31
|
+
h.const(m.watch).description("Add the page to watchlist"),
|
|
32
|
+
h.const(m.unwatch).description("Remove the page from watchlist")
|
|
33
|
+
]).description("Watchlist options").default(m.preferences),
|
|
34
|
+
"quickEdit.keyshortcut.save": h.string().default("ctrl-s").description("save button key shortcut (blank to disable)")
|
|
35
|
+
}).description("Quick edit options").extra("category", "edit")
|
|
36
|
+
)];
|
|
37
|
+
class w extends (N = C) {
|
|
38
|
+
constructor(e) {
|
|
39
|
+
super(e, {}, "quick-edit"), this.ctx = e, this.DEFAULT_OPTIONS = {
|
|
40
|
+
title: "",
|
|
41
|
+
pageId: 0,
|
|
42
|
+
revision: 0,
|
|
43
|
+
section: void 0,
|
|
44
|
+
editMinor: !1,
|
|
45
|
+
editSummary: "",
|
|
46
|
+
createOnly: !1,
|
|
47
|
+
reloadAfterSave: !0
|
|
48
|
+
}, this.ctx.root.set("quickEdit", A(this, "showModal"));
|
|
49
|
+
}
|
|
50
|
+
start() {
|
|
51
|
+
this.ctx.inject(["toolbox"], (e) => {
|
|
52
|
+
this.injectToolbox(e), e.on("dispose", () => {
|
|
53
|
+
this.removeToolbox(e);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async showModal(e) {
|
|
58
|
+
if (typeof e > "u" ? e = {} : typeof e == "string" && (e = {
|
|
59
|
+
title: e
|
|
60
|
+
}), e?.page && (e.title = e.page, delete e.page), !e.title && !e.pageId && !e.revision) {
|
|
61
|
+
this.logger.warn("None of the title, pageId or revision provided. Using defaults.");
|
|
62
|
+
const o = new URLSearchParams(window.location.search);
|
|
63
|
+
e = {
|
|
64
|
+
...e,
|
|
65
|
+
title: this.ctx.wikiTitle.currentTitle.getPrefixedDBKey(),
|
|
66
|
+
revision: o.has("oldid") ? Number(o.get("oldid")) : void 0,
|
|
67
|
+
pageId: o.has("curid") ? Number(o.get("curid")) : void 0
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const c = await this.ctx.preferences.get("quickEdit.outSideClose"), l = await this.ctx.preferences.get("quickEdit.watchList"), s = typeof e.editSummary == "string" ? e.editSummary : await this.ctx.preferences.get("quickEdit.editSummary"), d = typeof e.editMinor == "boolean" ? e.editMinor : await this.ctx.preferences.get("quickEdit.editMinor"), n = {
|
|
71
|
+
...this.DEFAULT_OPTIONS,
|
|
72
|
+
editSummary: s,
|
|
73
|
+
editMinor: d,
|
|
74
|
+
...e
|
|
75
|
+
};
|
|
76
|
+
n.editSummary || (n.editSummary = await this.ctx.preferences.get("quickEdit.editSummary") || ""), n || this.ctx.emit("quick-edit/init-options", { ctx: this.ctx, options: n });
|
|
77
|
+
const r = this.ctx.modal.createObject({
|
|
78
|
+
className: "ipe-quickEdit",
|
|
79
|
+
sizeClass: "large",
|
|
80
|
+
// backdrop: false,
|
|
81
|
+
// draggable: true,
|
|
82
|
+
center: !1,
|
|
83
|
+
outSideClose: c
|
|
84
|
+
}).init();
|
|
85
|
+
r.setTitle(
|
|
86
|
+
/* @__PURE__ */ i(b, { children: [
|
|
87
|
+
"Loading: ",
|
|
88
|
+
/* @__PURE__ */ i("u", { children: n.title })
|
|
89
|
+
] })
|
|
90
|
+
), r.setContent(
|
|
91
|
+
/* @__PURE__ */ i(
|
|
92
|
+
"section",
|
|
93
|
+
{
|
|
94
|
+
className: "ipe-quickEdit-loading",
|
|
95
|
+
style: {
|
|
96
|
+
height: "70vh",
|
|
97
|
+
display: "flex",
|
|
98
|
+
flexDirection: "column",
|
|
99
|
+
justifyContent: "center",
|
|
100
|
+
alignItems: "center"
|
|
101
|
+
},
|
|
102
|
+
children: /* @__PURE__ */ i(T, {})
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
), r.addButton({
|
|
106
|
+
side: "right",
|
|
107
|
+
type: "button",
|
|
108
|
+
className: "is-danger is-ghost",
|
|
109
|
+
label: "Cancel",
|
|
110
|
+
method() {
|
|
111
|
+
r.close();
|
|
112
|
+
}
|
|
113
|
+
}), r.show(), this.ctx.emit("quick-edit/show-modal", { ctx: this.ctx, modal: r, options: n });
|
|
114
|
+
let a;
|
|
115
|
+
try {
|
|
116
|
+
if (a = await this.getWikiPageFromPayload(n), a.pageInfo.special)
|
|
117
|
+
throw new Error("Special page is not editable");
|
|
118
|
+
} catch (o) {
|
|
119
|
+
r.off(r.Event.Close), r.close(), this.ctx.modal.notify("error", {
|
|
120
|
+
content: o instanceof Error ? o.message : String(o)
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
r.setTitle(
|
|
125
|
+
/* @__PURE__ */ i(b, { children: [
|
|
126
|
+
"Quick ",
|
|
127
|
+
a.pageInfo.pageid === 0 ? "Create" : "Edit",
|
|
128
|
+
":",
|
|
129
|
+
" ",
|
|
130
|
+
/* @__PURE__ */ i("u", { children: a.pageInfo.title })
|
|
131
|
+
] })
|
|
132
|
+
);
|
|
133
|
+
const u = [];
|
|
134
|
+
a.pageInfo.pageid === 0 && u.push(
|
|
135
|
+
/* @__PURE__ */ i(S, { title: "Attention", type: "important", children: /* @__PURE__ */ i("p", { children: "This page does not exist." }) })
|
|
136
|
+
), a.pageInfo.pageid && a.pageInfo.lastrevid !== a.revisions[0]?.revid && u.push(
|
|
137
|
+
/* @__PURE__ */ i(S, { title: "Attention", type: "warning", children: /* @__PURE__ */ i("p", { children: [
|
|
138
|
+
"You are editing a ",
|
|
139
|
+
/* @__PURE__ */ i("em", { children: "historical version" }),
|
|
140
|
+
"; the content is not the latest!"
|
|
141
|
+
] }) })
|
|
142
|
+
), this.ctx.emit("quick-edit/edit-notice", {
|
|
143
|
+
ctx: this.ctx,
|
|
144
|
+
options: n,
|
|
145
|
+
modal: r,
|
|
146
|
+
wikiPage: a,
|
|
147
|
+
editNotices: u
|
|
148
|
+
});
|
|
149
|
+
const p = /* @__PURE__ */ i("form", { className: "ipe-quickEdit__form", children: [
|
|
150
|
+
/* @__PURE__ */ i("div", { className: "ipe-quickEdit__notices", children: u }),
|
|
151
|
+
/* @__PURE__ */ i("div", { className: "ipe-quickEdit__content", children: /* @__PURE__ */ i("textarea", { className: "ipe-quickEdit__textarea", name: "text", id: "wpTextbox1", children: a.revisions[0]?.content || "" }) }),
|
|
152
|
+
/* @__PURE__ */ i(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
class: "ipe-quickEdit__options",
|
|
156
|
+
style: {
|
|
157
|
+
display: "flex",
|
|
158
|
+
flexDirection: "column",
|
|
159
|
+
gap: "1rem",
|
|
160
|
+
marginTop: "1rem"
|
|
161
|
+
},
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ i(F, { label: "Summary", id: "summary", name: "summary", value: n.editSummary }),
|
|
164
|
+
/* @__PURE__ */ i("div", { className: "ipe-input-box", children: [
|
|
165
|
+
/* @__PURE__ */ i("label", { htmlFor: "watchlist", style: { display: "block" }, children: "Watchlist" }),
|
|
166
|
+
/* @__PURE__ */ i("div", { style: { display: "flex", gap: "1rem" }, children: [
|
|
167
|
+
m.preferences,
|
|
168
|
+
m.nochange,
|
|
169
|
+
m.watch,
|
|
170
|
+
m.unwatch
|
|
171
|
+
].map((o) => /* @__PURE__ */ i(
|
|
172
|
+
O,
|
|
173
|
+
{
|
|
174
|
+
name: "watchlist",
|
|
175
|
+
value: o,
|
|
176
|
+
inputProps: { checked: l === o },
|
|
177
|
+
children: o
|
|
178
|
+
},
|
|
179
|
+
o
|
|
180
|
+
)) })
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ i("div", { style: { display: "flex", gap: "1rem" }, children: [
|
|
183
|
+
/* @__PURE__ */ i(_, { name: "minor", id: "minor", checked: n.editMinor, children: "Minor edit" }),
|
|
184
|
+
/* @__PURE__ */ i(_, { name: "reloadAfterSave", id: "reloadAfterSave", checked: n.reloadAfterSave, children: "Reload after save" })
|
|
185
|
+
] })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
!1
|
|
190
|
+
] });
|
|
191
|
+
r.setContent(p), r.addButton(
|
|
192
|
+
{
|
|
193
|
+
side: "left",
|
|
194
|
+
className: "is-primary submit-btn",
|
|
195
|
+
label: "Submit",
|
|
196
|
+
keyPress: await this.ctx.preferences.get("quickEdit.keyshortcut.save") || void 0,
|
|
197
|
+
method: () => {
|
|
198
|
+
const o = new FormData(p);
|
|
199
|
+
r.setLoadingState(!0), this.handleSubmit({
|
|
200
|
+
wikiPage: a,
|
|
201
|
+
text: o.get("text"),
|
|
202
|
+
summary: o.get("summary"),
|
|
203
|
+
minor: o.get("minor") === "on",
|
|
204
|
+
section: n.section,
|
|
205
|
+
createonly: a.pageid === 0,
|
|
206
|
+
watchlist: l
|
|
207
|
+
}).then(async () => {
|
|
208
|
+
r.setOptions({
|
|
209
|
+
beforeClose: E
|
|
210
|
+
}), r.close(), this.ctx.modal.notify("success", {
|
|
211
|
+
title: "Submission Successful",
|
|
212
|
+
content: "Your changes have been saved."
|
|
213
|
+
}), o.get("reloadAfterSave") && (await j(500), location.reload());
|
|
214
|
+
}).catch((f) => {
|
|
215
|
+
this.ctx.modal.notify("error", {
|
|
216
|
+
title: "Submission Error",
|
|
217
|
+
content: f instanceof Error ? f.message : String(f)
|
|
218
|
+
}), r.setLoadingState(!1);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
0
|
|
223
|
+
), r.setOptions({
|
|
224
|
+
beforeClose: () => {
|
|
225
|
+
const o = a.revisions[0]?.content || "";
|
|
226
|
+
return (p.querySelector("textarea")?.value || "") === o ? !0 : (this.ctx.modal.confirm(
|
|
227
|
+
{
|
|
228
|
+
className: "is-primary",
|
|
229
|
+
title: "Unsaved Changes",
|
|
230
|
+
content: "All edit contents will be lost after closing the modal. Are you sure you want to close?",
|
|
231
|
+
center: !0,
|
|
232
|
+
okBtn: {
|
|
233
|
+
label: "Give Up",
|
|
234
|
+
className: "is-danger is-ghost"
|
|
235
|
+
},
|
|
236
|
+
cancelBtn: {
|
|
237
|
+
label: "Continue Editing",
|
|
238
|
+
className: "is-primary is-ghost"
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
(v) => (v && (r.setOptions({
|
|
242
|
+
beforeClose: E
|
|
243
|
+
}), r.close()), !0)
|
|
244
|
+
), !1);
|
|
245
|
+
}
|
|
246
|
+
}), this.ctx.emit("quick-edit/wiki-page", {
|
|
247
|
+
ctx: this.ctx,
|
|
248
|
+
options: n,
|
|
249
|
+
modal: r,
|
|
250
|
+
wikiPage: a
|
|
251
|
+
});
|
|
252
|
+
const g = (o) => p.querySelector("textarea")?.value === a.revisions[0]?.content ? !0 : (o.preventDefault(), "You have unsaved changes. Are you sure you want to leave?");
|
|
253
|
+
window.addEventListener("beforeunload", g), r.on(r.Event.Close, () => {
|
|
254
|
+
window.removeEventListener("beforeunload", g);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async handleSubmit(e) {
|
|
258
|
+
const c = e.wikiPage, l = e.summary || "", s = e.text || "", d = e.minor, n = e.createonly, r = e.watchlist, a = e.section;
|
|
259
|
+
return c.edit(
|
|
260
|
+
{
|
|
261
|
+
summary: l,
|
|
262
|
+
text: s,
|
|
263
|
+
watchlist: r,
|
|
264
|
+
section: a
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
minor: d,
|
|
268
|
+
createonly: n
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
async getWikiPageFromPayload(e) {
|
|
273
|
+
if (e.revision)
|
|
274
|
+
return this.ctx.wikiPage.newFromRevision(e.revision, e.section);
|
|
275
|
+
if (e.pageId)
|
|
276
|
+
return this.ctx.wikiPage.newFromPageId(e.pageId, e.section);
|
|
277
|
+
if (e.title)
|
|
278
|
+
return this.ctx.wikiPage.newFromTitle(e.title, !1, e.section);
|
|
279
|
+
throw new Error("Invalid payload");
|
|
280
|
+
}
|
|
281
|
+
injectToolbox(e) {
|
|
282
|
+
const c = this.ctx.wikiTitle.currentTitle, l = this.ctx.wiki.hasRight("edit") && c.getNamespaceId() >= 0;
|
|
283
|
+
e.toolbox.addButton({
|
|
284
|
+
id: "quick-edit",
|
|
285
|
+
group: "group1",
|
|
286
|
+
index: 0,
|
|
287
|
+
icon: /* @__PURE__ */ i(
|
|
288
|
+
"svg",
|
|
289
|
+
{
|
|
290
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
291
|
+
width: "24",
|
|
292
|
+
height: "24",
|
|
293
|
+
viewBox: "0 0 24 24",
|
|
294
|
+
fill: "none",
|
|
295
|
+
stroke: "currentColor",
|
|
296
|
+
"stroke-width": "2",
|
|
297
|
+
"stroke-linecap": "round",
|
|
298
|
+
"stroke-linejoin": "round",
|
|
299
|
+
class: "icon icon-tabler icons-tabler-outline icon-tabler-edit",
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ i("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
302
|
+
/* @__PURE__ */ i("path", { d: "M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" }),
|
|
303
|
+
/* @__PURE__ */ i("path", { d: "M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" }),
|
|
304
|
+
/* @__PURE__ */ i("path", { d: "M16 5l3 3" })
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
),
|
|
308
|
+
buttonProps: {
|
|
309
|
+
disabled: !l
|
|
310
|
+
},
|
|
311
|
+
tooltip: l ? "Quick Edit" : "Not editable",
|
|
312
|
+
onClick: () => {
|
|
313
|
+
const s = new URLSearchParams(window.location.search).get("oldid");
|
|
314
|
+
this.showModal({
|
|
315
|
+
title: c.getPrefixedText(),
|
|
316
|
+
revision: s ? Number(s) : void 0
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
removeToolbox(e) {
|
|
322
|
+
e.toolbox.removeButton("quick-edit");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
k = W(N);
|
|
326
|
+
w = G(k, 0, "PluginQuickEdit", I, w);
|
|
327
|
+
K(k, 1, w);
|
|
328
|
+
export {
|
|
329
|
+
w as PluginQuickEdit
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=index-loWqosf7.js.map
|