@inpageedit/core 0.13.0-alpha.0 → 0.13.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/dist/BasePlugin-Bf2UuIHF.js.map +1 -1
- package/dist/IconQuickEdit-CMCQncyj.js.map +1 -1
- package/dist/InputBox-nQKtiWtZ.js.map +1 -1
- package/dist/Preferences-DS4-CFWe.js.map +1 -1
- package/dist/WatchlistAction-BbNAyryN.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/endpoints-DgyuoRZd.js.map +1 -1
- package/dist/{index-BCdABp0e.js → index-B7c6jL9x.js} +3 -2
- package/dist/index-B7c6jL9x.js.map +1 -0
- package/dist/index-CCRMmnwk.js.map +1 -1
- package/dist/index-CG38LlAh.js.map +1 -1
- package/dist/index-CM_6yF2v.js.map +1 -1
- package/dist/{index-DdTiZqwt.js → index-C_BIsubQ.js} +3 -3
- package/dist/index-C_BIsubQ.js.map +1 -0
- package/dist/index-CyG7_IYz.js.map +1 -1
- package/dist/index-DD5CVCfD.js.map +1 -1
- package/dist/index.d.ts +45 -26
- package/dist/index.js +2 -2
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
- package/dist/models/index.js.map +1 -1
- package/dist/noop-ClDc6zv4.js.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/services/index.js +1 -1
- package/dist/vueHooks-l04s8cIl.js.map +1 -1
- package/lib/index.umd.js +2 -2
- package/lib/index.umd.js.map +1 -1
- package/package.json +6 -10
- package/dist/index-BCdABp0e.js.map +0 -1
- package/dist/index-DdTiZqwt.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-CyG7_IYz.js","sources":["../src/utils/sleep.ts","../src/plugins/quick-edit/index.tsx"],"sourcesContent":["export const sleep = (ms: number = 0) =>\n new Promise((resolve) => setTimeout(resolve, ms))\n","import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { IWikiPage } from '@/models/WikiPage'\nimport { WatchlistAction } from '@/models/WikiPage/types/WatchlistAction'\nimport { IPEModal } from '@inpageedit/modal'\nimport { ReactNode } from 'jsx-dom'\nimport { makeCallable } from '@/utils/makeCallable.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickEdit: PluginQuickEdit & {\n (...args: Parameters<PluginQuickEdit['showModal']>): ReturnType<PluginQuickEdit['showModal']>\n }\n }\n interface Events {\n 'quick-edit/init-options'(payload: Omit<QuickEditEventPayload, 'modal' | 'wikiPage'>): void\n 'quick-edit/show-modal'(payload: Omit<QuickEditEventPayload, 'wikiPage'>): void\n 'quick-edit/wiki-page'(payload: QuickEditEventPayload): void\n 'quick-edit/edit-notice'(payload: QuickEditEventPayload & { editNotices: ReactNode[] }): void\n 'quick-edit/submit'(payload: QuickEditSubmitPayload & { ctx: InPageEdit }): void\n }\n interface PreferencesMap {\n 'quickEdit.editSummary': string\n 'quickEdit.editMinor': boolean\n 'quickEdit.outSideClose': boolean\n 'quickEdit.watchList': WatchlistAction\n 'quickEdit.keyshortcut.save': string\n 'quickEdit.editFont': string\n }\n}\n\nexport interface QuickEditOptions {\n title: string\n pageId: number\n revision: number\n /**\n * - `undefined` for full article edit\n * - `0` for the first section\n * - `\"new\"` for a new section\n */\n section: number | 'new' | undefined\n editMinor: boolean\n editSummary: string\n createOnly: boolean\n reloadAfterSave: boolean\n}\n\nexport interface QuickEditEventPayload {\n ctx: InPageEdit\n options: QuickEditOptions\n modal: IPEModal\n wikiPage: IWikiPage\n}\n\nexport interface QuickEditSubmitPayload {\n wikiPage: IWikiPage\n text?: string\n summary?: string\n section?: number | 'new' | undefined\n minor?: boolean\n createonly?: boolean\n watchlist?: WatchlistAction\n}\n\n@Inject(['api', 'wikiPage', 'wikiTitle', 'currentPage', 'wiki', 'modal', 'preferences'])\n@RegisterPreferences(\n Schema.object({\n 'quickEdit.editSummary': Schema.string()\n .description('Default edit summary for quick edits')\n .default('[IPE-NEXT] Quick edit'),\n 'quickEdit.editMinor': Schema.boolean()\n .description('Default to checking \"minor edit\" option')\n .default(false),\n 'quickEdit.outSideClose': Schema.boolean()\n .description('Close editor modal by clicking outside')\n .default(true),\n 'quickEdit.watchList': Schema.union([\n Schema.const(WatchlistAction.preferences).description('Follow MW preferences'),\n Schema.const(WatchlistAction.nochange).description('Keep the current watchlist status'),\n Schema.const(WatchlistAction.watch).description('Add the page to watchlist'),\n Schema.const(WatchlistAction.unwatch).description('Remove the page from watchlist'),\n ])\n .description('Watchlist options')\n .default(WatchlistAction.preferences),\n 'quickEdit.keyshortcut.save': Schema.string()\n .default('ctrl-s')\n .description('save button key shortcut (blank to disable)'),\n 'quickEdit.editFont': Schema.union([\n Schema.const('preferences').description('Follow MW preferences'),\n Schema.const('monospace').description('Monospace'),\n Schema.const('sans-serif').description('Sans-serif'),\n Schema.const('serif').description('Serif'),\n Schema.string().description('Custom font (same as CSS `font-family` property)').default(''),\n ])\n .description(\"Font to use in quick edit's textarea\")\n .default('preferences'),\n })\n .description('Quick edit options')\n .extra('category', 'editor')\n)\nexport class PluginQuickEdit extends BasePlugin {\n private readonly DEFAULT_OPTIONS: QuickEditOptions = {\n title: '',\n pageId: 0,\n revision: 0,\n section: undefined,\n editMinor: false,\n editSummary: '',\n createOnly: false,\n reloadAfterSave: true,\n }\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quick-edit')\n this.ctx.root.set('quickEdit', makeCallable(this, 'showModal'))\n }\n\n protected start(): Promise<void> | void {\n this.ctx.inject(['toolbox'], (ctx) => {\n this.injectToolbox(ctx)\n ctx.on('dispose', () => {\n this.removeToolbox(ctx)\n })\n })\n }\n\n async showModal(payload?: string | Partial<QuickEditOptions>) {\n if (typeof payload === 'undefined') {\n payload = {}\n } else if (typeof payload === 'string') {\n payload = {\n title: payload,\n } as Partial<QuickEditOptions>\n }\n\n // @ts-expect-error legacy `page` option\n if (payload?.page) {\n // @ts-expect-error\n payload.title = payload.page\n // @ts-expect-error\n delete payload.page\n }\n\n if (!payload.title && !payload.pageId && !payload.revision) {\n this.logger.warn('None of the title, pageId or revision provided. Using defaults.')\n const searchParams = new URLSearchParams(window.location.search)\n const title = this.ctx.currentPage.wikiTitle\n payload = {\n ...payload,\n title: title?.getPrefixedDBKey(),\n revision: searchParams.has('oldid') ? Number(searchParams.get('oldid')) : undefined,\n pageId: searchParams.has('curid') ? Number(searchParams.get('curid')) : undefined,\n }\n }\n\n if (!payload.revision && !payload.pageId && payload.title) {\n const realTarget = this.ctx.wikiTitle.resolveSpecialPageTarget(payload.title)\n if (realTarget && realTarget.title.getNamespaceId() >= 0) {\n payload.title = realTarget.title.getPrefixedDBKey()\n payload.section ??= realTarget.section\n }\n }\n\n const outSideClose = (await this.ctx.preferences.get('quickEdit.outSideClose'))!\n const watchList = (await this.ctx.preferences.get('quickEdit.watchList'))!\n const editSummary =\n typeof payload.editSummary === 'string'\n ? payload.editSummary\n : (await this.ctx.preferences.get('quickEdit.editSummary'))!\n const editMinor =\n typeof payload.editMinor === 'boolean'\n ? payload.editMinor\n : (await this.ctx.preferences.get('quickEdit.editMinor'))!\n const fontOptions = await this.getEditFontOptions()\n\n const options: QuickEditOptions = {\n ...this.DEFAULT_OPTIONS,\n editSummary,\n editMinor,\n ...payload,\n }\n if (!options.editSummary) {\n options.editSummary = (await this.ctx.preferences.get('quickEdit.editSummary')) || ''\n }\n this.ctx.emit('quick-edit/init-options', { ctx: this.ctx, options })\n\n const modal = this.ctx.modal\n .createObject({\n className: 'ipe-quickEdit',\n sizeClass: 'large',\n // backdrop: false,\n // draggable: true,\n center: false,\n outSideClose,\n })\n .init()\n modal.setTitle(\n (\n <>\n Loading: <u>{options.title}</u>\n </>\n ) as HTMLElement\n )\n modal.setContent(\n (\n <section\n className=\"ipe-quickEdit-loading\"\n style={{\n height: '70vh',\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n >\n <ProgressBar />\n </section>\n ) as HTMLElement\n )\n modal.addButton({\n side: 'right',\n type: 'button',\n className: 'is-danger is-ghost',\n label: 'Cancel',\n method() {\n modal.close()\n },\n })\n modal.show()\n this.ctx.emit('quick-edit/show-modal', { ctx: this.ctx, modal, options })\n\n let wikiPage: IWikiPage\n try {\n wikiPage = await this.getWikiPageFromPayload(options)\n if (wikiPage.pageInfo.special) {\n throw new Error('Special page is not editable')\n }\n } catch (e) {\n modal.off(modal.Event.Close)\n modal.close()\n this.ctx.modal.notify('error', {\n content: e instanceof Error ? e.message : String(e),\n })\n return\n }\n\n const edittingContent = options.section === 'new' ? '' : wikiPage.revisions[0]?.content || ''\n const edittingRevId = wikiPage.revisions[0]?.revid\n const isEdittingOld = edittingRevId && edittingRevId !== wikiPage.lastrevid\n const isCreatingNewSection = options.section === 'new'\n const isCreatingNewPage = wikiPage.pageid === 0\n\n modal.setTitle(\n (\n <>\n {isCreatingNewSection ? 'New section' : `Quick ${isCreatingNewPage ? 'Create' : 'Edit'}`}:{' '}\n <u>{wikiPage.pageInfo.title}</u>\n {isEdittingOld ? ` (Revision ${edittingRevId})` : ''}\n </>\n ) as HTMLElement\n )\n\n const editNotices = [] as ReactNode[]\n // Page not exists\n if (isCreatingNewPage) {\n editNotices.push(\n <MBox title=\"Attention\" type=\"important\">\n <p>This page does not exist.</p>\n </MBox>\n )\n }\n // Edit based on old revision\n if (isEdittingOld) {\n editNotices.push(\n <MBox title=\"Attention\" type=\"warning\">\n <p>\n You are editing a <em>historical version</em>; the content is not the latest!\n </p>\n </MBox>\n )\n }\n this.ctx.emit('quick-edit/edit-notice', {\n ctx: this.ctx,\n options,\n modal,\n wikiPage,\n editNotices,\n })\n\n const editForm = (\n <form className=\"ipe-quickEdit__form\">\n <div className=\"ipe-quickEdit__notices\">{editNotices}</div>\n <div\n className=\"ipe-quickEdit__content\"\n style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}\n >\n {options.section === 'new' && (\n <>\n <InputBox\n label=\"Section title\"\n id=\"summary\"\n name=\"summary\"\n value={''}\n inputProps={{ placeholder: 'Topic for new section, this will be the h2 heading' }}\n />\n </>\n )}\n <textarea\n className={`ipe-quickEdit__textarea ${fontOptions.className}`}\n style={{ fontFamily: fontOptions.fontFamily }}\n name=\"text\"\n id=\"wpTextbox1\"\n >\n {edittingContent}\n </textarea>\n </div>\n <div\n class=\"ipe-quickEdit__options\"\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '1rem',\n marginTop: '1rem',\n }}\n >\n {!isCreatingNewSection && (\n <InputBox label=\"Summary\" id=\"summary\" name=\"summary\" value={options.editSummary} />\n )}\n <div className=\"ipe-input-box\">\n <label htmlFor=\"watchlist\" style={{ display: 'block' }}>\n Watchlist\n </label>\n <div style={{ display: 'flex', gap: '1rem' }}>\n {[\n WatchlistAction.preferences,\n WatchlistAction.nochange,\n WatchlistAction.watch,\n WatchlistAction.unwatch,\n ].map((action) => (\n <RadioBox\n key={action}\n name=\"watchlist\"\n value={action}\n inputProps={{ checked: watchList === action }}\n >\n {action}\n </RadioBox>\n ))}\n </div>\n </div>\n <div style={{ display: 'flex', gap: '1rem' }}>\n <CheckBox name=\"minor\" id=\"minor\" checked={options.editMinor}>\n Minor edit\n </CheckBox>\n <CheckBox name=\"reloadAfterSave\" id=\"reloadAfterSave\" checked={options.reloadAfterSave}>\n Reload after save\n </CheckBox>\n </div>\n </div>\n {/* Debug Info */}\n {import.meta.env.DEV && (\n <div className=\"debug\" style={{ marginTop: '1rem' }}>\n <details>\n <pre>{JSON.stringify(wikiPage.pageInfo, null, 2)}</pre>\n </details>\n </div>\n )}\n </form>\n ) as HTMLFormElement\n modal.setContent(editForm)\n // shamefully fix: make sure the submit button is always the first\n modal.addButton(\n {\n side: 'left',\n className: 'is-primary submit-btn',\n label: 'Submit',\n keyPress: (await this.ctx.preferences.get('quickEdit.keyshortcut.save')) || undefined,\n method: () => {\n const formData = new FormData(editForm)\n console.info(wikiPage, editForm, {\n text: formData.get('text') as string,\n summary: formData.get('summary') as string,\n minor: formData.get('minor') === 'on',\n })\n modal.setLoadingState(true)\n this.handleSubmit({\n wikiPage,\n text: formData.get('text') as string,\n summary: formData.get('summary') as string,\n minor: formData.get('minor') === 'on',\n section: options.section,\n createonly: wikiPage.pageid === 0,\n watchlist: watchList,\n })\n .then(async () => {\n modal.setOptions({\n beforeClose: noop,\n })\n modal.close()\n this.ctx.modal.notify('success', {\n title: 'Submission Successful',\n content: 'Your changes have been saved.',\n })\n if (formData.get('reloadAfterSave')) {\n await sleep(500)\n location.reload()\n }\n })\n .catch((error) => {\n this.ctx.modal.notify('error', {\n title: 'Submission Error',\n content: error instanceof Error ? error.message : String(error),\n })\n modal.setLoadingState(false)\n })\n },\n },\n 0\n )\n modal.setOptions({\n beforeClose: () => {\n const oldStr = wikiPage.revisions[0]?.content || ''\n const newStr = editForm.querySelector('textarea')?.value || ''\n if (newStr === oldStr) {\n return true\n } else {\n this.ctx.modal.confirm(\n {\n className: 'is-primary',\n title: 'Unsaved Changes',\n content:\n 'All edit contents will be lost after closing the modal. Are you sure you want to close?',\n center: true,\n okBtn: {\n label: 'Give Up',\n className: 'is-danger is-ghost',\n },\n cancelBtn: {\n label: 'Continue Editing',\n className: 'is-primary is-ghost',\n },\n },\n (confirmed) => {\n if (confirmed) {\n modal.setOptions({\n beforeClose: noop,\n })\n modal.close()\n }\n return true\n }\n )\n return false\n }\n },\n })\n this.ctx.emit('quick-edit/wiki-page', {\n ctx: this.ctx,\n options,\n modal,\n wikiPage,\n })\n\n const beforeUnload = (e: BeforeUnloadEvent) => {\n if (editForm.querySelector('textarea')?.value === edittingContent) {\n return true\n }\n e.preventDefault()\n return 'You have unsaved changes. Are you sure you want to leave?'\n }\n window.addEventListener('beforeunload', beforeUnload)\n modal.on(modal.Event.Close, () => {\n window.removeEventListener('beforeunload', beforeUnload)\n })\n }\n\n async handleSubmit(payload: QuickEditSubmitPayload) {\n const wikiPage = payload.wikiPage\n const summary = payload.summary || ''\n const text = payload.text || ''\n const minor = payload.minor\n const createonly = payload.createonly\n const watchlist = payload.watchlist\n const section = payload.section\n\n this.ctx.emit('quick-edit/submit', {\n ctx: this.ctx,\n wikiPage,\n summary,\n text,\n minor,\n createonly,\n watchlist,\n })\n\n return wikiPage.edit(\n {\n summary,\n text,\n watchlist,\n section,\n },\n {\n minor,\n createonly,\n }\n )\n }\n\n static readonly BUILT_IN_FONT_OPTIONS = ['preferences', 'monospace', 'sans-serif', 'serif']\n async getEditFontOptions() {\n const prefEditFont = (await this.ctx.preferences.get('quickEdit.editFont'))!\n if (PluginQuickEdit.BUILT_IN_FONT_OPTIONS.includes(prefEditFont)) {\n const editfont =\n prefEditFont === 'preferences'\n ? this.ctx.wiki.userOptions?.editfont || 'monospace'\n : prefEditFont\n return {\n className: `mw-editfont-${editfont}`,\n fontFamily: '',\n }\n } else {\n return {\n className: 'mw-editfont-custom',\n fontFamily: prefEditFont,\n }\n }\n }\n\n async getWikiPageFromPayload(payload: Partial<QuickEditOptions>) {\n if (payload.revision) {\n return this.ctx.wikiPage.newFromRevision(payload.revision, payload.section)\n } else if (payload.pageId) {\n return this.ctx.wikiPage.newFromPageId(payload.pageId, payload.section)\n } else if (payload.title) {\n return this.ctx.wikiPage.newFromTitle(payload.title, false, payload.section)\n }\n throw new Error('Invalid payload')\n }\n\n private async injectToolbox(ctx: InPageEdit) {\n const title = this.ctx.currentPage.wikiTitle\n const canEdit = this.ctx.wiki.hasRight('edit') && title && title.getNamespaceId() >= 0\n ctx.toolbox.addButton({\n id: 'quick-edit',\n group: 'group1',\n index: 0,\n icon: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-edit\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1\" />\n <path d=\"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z\" />\n <path d=\"M16 5l3 3\" />\n </svg>\n ) as HTMLElement,\n buttonProps: {\n disabled: !canEdit,\n },\n tooltip: canEdit ? 'Quick Edit' : 'Not editable',\n onClick: () => {\n const revision = new URLSearchParams(window.location.search).get('oldid')\n this.showModal({\n title: title?.getPrefixedText(),\n revision: revision ? Number(revision) : undefined,\n })\n },\n })\n }\n\n protected removeToolbox(ctx: InPageEdit) {\n ctx.toolbox.removeButton('quick-edit')\n }\n}\n"],"names":["sleep","ms","resolve","_PluginQuickEdit_decorators","_init","_a","Inject","RegisterPreferences","Schema","WatchlistAction","_PluginQuickEdit","BasePlugin","ctx","makeCallable","payload","searchParams","title","realTarget","outSideClose","watchList","editSummary","editMinor","fontOptions","options","modal","jsxs","Fragment","jsx","ProgressBar","wikiPage","e","edittingContent","edittingRevId","isEdittingOld","isCreatingNewSection","isCreatingNewPage","editNotices","MBox","editForm","InputBox","action","RadioBox","CheckBox","formData","noop","error","oldStr","confirmed","beforeUnload","summary","text","minor","createonly","watchlist","section","prefEditFont","canEdit","revision","__decoratorStart","__decorateElement","__runInitializers","PluginQuickEdit"],"mappings":";;;;;;;;;;AAAO,MAAMA,IAAQ,CAACC,IAAa,MACjC,IAAI,QAAQ,CAACC,MAAY,WAAWA,GAASD,CAAE,CAAC;;;;;;;;;;;;GCDlDE,GAAAC,GAAAC;AA+DAF,IAAA,CAACG,EAAO,CAAC,OAAO,YAAY,aAAa,eAAe,QAAQ,SAAS,aAAa,CAAC,GACtFC;AAAA,EACCC,EAAO,OAAO;AAAA,IACZ,yBAAyBA,EAAO,OAAA,EAC7B,YAAY,sCAAsC,EAClD,QAAQ,uBAAuB;AAAA,IAClC,uBAAuBA,EAAO,QAAA,EAC3B,YAAY,yCAAyC,EACrD,QAAQ,EAAK;AAAA,IAChB,0BAA0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AK,GAAE,0EAAyE;AAAA,YACjF,gBAAAA,EAAC,QAAA,EAAK,GAAE,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAGxB,aAAa;AAAA,QACX,UAAU,CAAC6B;AAAA,MAAA;AAAA,MAEb,SAASA,IAAU,eAAe;AAAA,MAClC,SAAS,MAAM;AACb,cAAMC,IAAW,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,OAAO;AACxE,aAAK,UAAU;AAAA,UACb,OAAOzC,GAAO,gBAAA;AAAA,UACd,UAAUyC,IAAW,OAAOA,CAAQ,IAAI;AAAA,QAAA,CACzC;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACH;AAAA,EAEU,cAAc7C,GAAiB;AACvC,IAAAA,EAAI,QAAQ,aAAa,YAAY;AAAA,EACvC;AACF;AAneOR,IAAAsD,EAAArD,CAAA;AAAMK,IAANiD,4BApCPxD,GAoCaO,CAAA;AAANkD,EAAAxD,GAAA,GAAMM,CAAA;AAAN,IAAMmD,KAANnD;"}
|
|
1
|
+
{"version":3,"file":"index-CyG7_IYz.js","sources":["../src/utils/sleep.ts","../src/plugins/quick-edit/index.tsx"],"sourcesContent":["export const sleep = (ms: number = 0) =>\r\n new Promise((resolve) => setTimeout(resolve, ms))\r\n","import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { IWikiPage } from '@/models/WikiPage'\nimport { WatchlistAction } from '@/models/WikiPage/types/WatchlistAction'\nimport { IPEModal } from '@inpageedit/modal'\nimport { ReactNode } from 'jsx-dom'\nimport { makeCallable } from '@/utils/makeCallable.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickEdit: PluginQuickEdit & {\n (...args: Parameters<PluginQuickEdit['showModal']>): ReturnType<PluginQuickEdit['showModal']>\n }\n }\n interface Events {\n 'quick-edit/init-options'(payload: Omit<QuickEditEventPayload, 'modal' | 'wikiPage'>): void\n 'quick-edit/show-modal'(payload: Omit<QuickEditEventPayload, 'wikiPage'>): void\n 'quick-edit/wiki-page'(payload: QuickEditEventPayload): void\n 'quick-edit/edit-notice'(payload: QuickEditEventPayload & { editNotices: ReactNode[] }): void\n 'quick-edit/submit'(payload: QuickEditSubmitPayload & { ctx: InPageEdit }): void\n }\n interface PreferencesMap {\n 'quickEdit.editSummary': string\n 'quickEdit.editMinor': boolean\n 'quickEdit.outSideClose': boolean\n 'quickEdit.watchList': WatchlistAction\n 'quickEdit.keyshortcut.save': string\n 'quickEdit.editFont': string\n }\n}\n\nexport interface QuickEditOptions {\n title: string\n pageId: number\n revision: number\n /**\n * - `undefined` for full article edit\n * - `0` for the first section\n * - `\"new\"` for a new section\n */\n section: number | 'new' | undefined\n editMinor: boolean\n editSummary: string\n createOnly: boolean\n reloadAfterSave: boolean\n}\n\nexport interface QuickEditEventPayload {\n ctx: InPageEdit\n options: QuickEditOptions\n modal: IPEModal\n wikiPage: IWikiPage\n}\n\nexport interface QuickEditSubmitPayload {\n wikiPage: IWikiPage\n text?: string\n summary?: string\n section?: number | 'new' | undefined\n minor?: boolean\n createonly?: boolean\n watchlist?: WatchlistAction\n}\n\n@Inject(['api', 'wikiPage', 'wikiTitle', 'currentPage', 'wiki', 'modal', 'preferences'])\n@RegisterPreferences(\n Schema.object({\n 'quickEdit.editSummary': Schema.string()\n .description('Default edit summary for quick edits')\n .default('[IPE-NEXT] Quick edit'),\n 'quickEdit.editMinor': Schema.boolean()\n .description('Default to checking \"minor edit\" option')\n .default(false),\n 'quickEdit.outSideClose': Schema.boolean()\n .description('Close editor modal by clicking outside')\n .default(true),\n 'quickEdit.watchList': Schema.union([\n Schema.const(WatchlistAction.preferences).description('Follow MW preferences'),\n Schema.const(WatchlistAction.nochange).description('Keep the current watchlist status'),\n Schema.const(WatchlistAction.watch).description('Add the page to watchlist'),\n Schema.const(WatchlistAction.unwatch).description('Remove the page from watchlist'),\n ])\n .description('Watchlist options')\n .default(WatchlistAction.preferences),\n 'quickEdit.keyshortcut.save': Schema.string()\n .default('ctrl-s')\n .description('save button key shortcut (blank to disable)'),\n 'quickEdit.editFont': Schema.union([\n Schema.const('preferences').description('Follow MW preferences'),\n Schema.const('monospace').description('Monospace'),\n Schema.const('sans-serif').description('Sans-serif'),\n Schema.const('serif').description('Serif'),\n Schema.string().description('Custom font (same as CSS `font-family` property)').default(''),\n ])\n .description(\"Font to use in quick edit's textarea\")\n .default('preferences'),\n })\n .description('Quick edit options')\n .extra('category', 'editor')\n)\nexport class PluginQuickEdit extends BasePlugin {\n private readonly DEFAULT_OPTIONS: QuickEditOptions = {\n title: '',\n pageId: 0,\n revision: 0,\n section: undefined,\n editMinor: false,\n editSummary: '',\n createOnly: false,\n reloadAfterSave: true,\n }\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quick-edit')\n this.ctx.root.set('quickEdit', makeCallable(this, 'showModal'))\n }\n\n protected start(): Promise<void> | void {\n this.ctx.inject(['toolbox'], (ctx) => {\n this.injectToolbox(ctx)\n ctx.on('dispose', () => {\n this.removeToolbox(ctx)\n })\n })\n }\n\n async showModal(payload?: string | Partial<QuickEditOptions>) {\n if (typeof payload === 'undefined') {\n payload = {}\n } else if (typeof payload === 'string') {\n payload = {\n title: payload,\n } as Partial<QuickEditOptions>\n }\n\n // @ts-expect-error legacy `page` option\n if (payload?.page) {\n // @ts-expect-error\n payload.title = payload.page\n // @ts-expect-error\n delete payload.page\n }\n\n if (!payload.title && !payload.pageId && !payload.revision) {\n this.logger.warn('None of the title, pageId or revision provided. Using defaults.')\n const searchParams = new URLSearchParams(window.location.search)\n const title = this.ctx.currentPage.wikiTitle\n payload = {\n ...payload,\n title: title?.getPrefixedDBKey(),\n revision: searchParams.has('oldid') ? Number(searchParams.get('oldid')) : undefined,\n pageId: searchParams.has('curid') ? Number(searchParams.get('curid')) : undefined,\n }\n }\n\n if (!payload.revision && !payload.pageId && payload.title) {\n const realTarget = this.ctx.wikiTitle.resolveSpecialPageTarget(payload.title)\n if (realTarget && realTarget.title.getNamespaceId() >= 0) {\n payload.title = realTarget.title.getPrefixedDBKey()\n payload.section ??= realTarget.section\n }\n }\n\n const outSideClose = (await this.ctx.preferences.get('quickEdit.outSideClose'))!\n const watchList = (await this.ctx.preferences.get('quickEdit.watchList'))!\n const editSummary =\n typeof payload.editSummary === 'string'\n ? payload.editSummary\n : (await this.ctx.preferences.get('quickEdit.editSummary'))!\n const editMinor =\n typeof payload.editMinor === 'boolean'\n ? payload.editMinor\n : (await this.ctx.preferences.get('quickEdit.editMinor'))!\n const fontOptions = await this.getEditFontOptions()\n\n const options: QuickEditOptions = {\n ...this.DEFAULT_OPTIONS,\n editSummary,\n editMinor,\n ...payload,\n }\n if (!options.editSummary) {\n options.editSummary = (await this.ctx.preferences.get('quickEdit.editSummary')) || ''\n }\n this.ctx.emit('quick-edit/init-options', { ctx: this.ctx, options })\n\n const modal = this.ctx.modal\n .createObject({\n className: 'ipe-quickEdit',\n sizeClass: 'large',\n // backdrop: false,\n // draggable: true,\n center: false,\n outSideClose,\n })\n .init()\n modal.setTitle(\n (\n <>\n Loading: <u>{options.title}</u>\n </>\n ) as HTMLElement\n )\n modal.setContent(\n (\n <section\n className=\"ipe-quickEdit-loading\"\n style={{\n height: '70vh',\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n >\n <ProgressBar />\n </section>\n ) as HTMLElement\n )\n modal.addButton({\n side: 'right',\n type: 'button',\n className: 'is-danger is-ghost',\n label: 'Cancel',\n method() {\n modal.close()\n },\n })\n modal.show()\n this.ctx.emit('quick-edit/show-modal', { ctx: this.ctx, modal, options })\n\n let wikiPage: IWikiPage\n try {\n wikiPage = await this.getWikiPageFromPayload(options)\n if (wikiPage.pageInfo.special) {\n throw new Error('Special page is not editable')\n }\n } catch (e) {\n modal.off(modal.Event.Close)\n modal.close()\n this.ctx.modal.notify('error', {\n content: e instanceof Error ? e.message : String(e),\n })\n return\n }\n\n const edittingContent = options.section === 'new' ? '' : wikiPage.revisions[0]?.content || ''\n const edittingRevId = wikiPage.revisions[0]?.revid\n const isEdittingOld = edittingRevId && edittingRevId !== wikiPage.lastrevid\n const isCreatingNewSection = options.section === 'new'\n const isCreatingNewPage = wikiPage.pageid === 0\n\n modal.setTitle(\n (\n <>\n {isCreatingNewSection ? 'New section' : `Quick ${isCreatingNewPage ? 'Create' : 'Edit'}`}:{' '}\n <u>{wikiPage.pageInfo.title}</u>\n {isEdittingOld ? ` (Revision ${edittingRevId})` : ''}\n </>\n ) as HTMLElement\n )\n\n const editNotices = [] as ReactNode[]\n // Page not exists\n if (isCreatingNewPage) {\n editNotices.push(\n <MBox title=\"Attention\" type=\"important\">\n <p>This page does not exist.</p>\n </MBox>\n )\n }\n // Edit based on old revision\n if (isEdittingOld) {\n editNotices.push(\n <MBox title=\"Attention\" type=\"warning\">\n <p>\n You are editing a <em>historical version</em>; the content is not the latest!\n </p>\n </MBox>\n )\n }\n this.ctx.emit('quick-edit/edit-notice', {\n ctx: this.ctx,\n options,\n modal,\n wikiPage,\n editNotices,\n })\n\n const editForm = (\n <form className=\"ipe-quickEdit__form\">\n <div className=\"ipe-quickEdit__notices\">{editNotices}</div>\n <div\n className=\"ipe-quickEdit__content\"\n style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}\n >\n {options.section === 'new' && (\n <>\n <InputBox\n label=\"Section title\"\n id=\"summary\"\n name=\"summary\"\n value={''}\n inputProps={{ placeholder: 'Topic for new section, this will be the h2 heading' }}\n />\n </>\n )}\n <textarea\n className={`ipe-quickEdit__textarea ${fontOptions.className}`}\n style={{ fontFamily: fontOptions.fontFamily }}\n name=\"text\"\n id=\"wpTextbox1\"\n >\n {edittingContent}\n </textarea>\n </div>\n <div\n class=\"ipe-quickEdit__options\"\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '1rem',\n marginTop: '1rem',\n }}\n >\n {!isCreatingNewSection && (\n <InputBox label=\"Summary\" id=\"summary\" name=\"summary\" value={options.editSummary} />\n )}\n <div className=\"ipe-input-box\">\n <label htmlFor=\"watchlist\" style={{ display: 'block' }}>\n Watchlist\n </label>\n <div style={{ display: 'flex', gap: '1rem' }}>\n {[\n WatchlistAction.preferences,\n WatchlistAction.nochange,\n WatchlistAction.watch,\n WatchlistAction.unwatch,\n ].map((action) => (\n <RadioBox\n key={action}\n name=\"watchlist\"\n value={action}\n inputProps={{ checked: watchList === action }}\n >\n {action}\n </RadioBox>\n ))}\n </div>\n </div>\n <div style={{ display: 'flex', gap: '1rem' }}>\n <CheckBox name=\"minor\" id=\"minor\" checked={options.editMinor}>\n Minor edit\n </CheckBox>\n <CheckBox name=\"reloadAfterSave\" id=\"reloadAfterSave\" checked={options.reloadAfterSave}>\n Reload after save\n </CheckBox>\n </div>\n </div>\n {/* Debug Info */}\n {import.meta.env.DEV && (\n <div className=\"debug\" style={{ marginTop: '1rem' }}>\n <details>\n <pre>{JSON.stringify(wikiPage.pageInfo, null, 2)}</pre>\n </details>\n </div>\n )}\n </form>\n ) as HTMLFormElement\n modal.setContent(editForm)\n // shamefully fix: make sure the submit button is always the first\n modal.addButton(\n {\n side: 'left',\n className: 'is-primary submit-btn',\n label: 'Submit',\n keyPress: (await this.ctx.preferences.get('quickEdit.keyshortcut.save')) || undefined,\n method: () => {\n const formData = new FormData(editForm)\n console.info(wikiPage, editForm, {\n text: formData.get('text') as string,\n summary: formData.get('summary') as string,\n minor: formData.get('minor') === 'on',\n })\n modal.setLoadingState(true)\n this.handleSubmit({\n wikiPage,\n text: formData.get('text') as string,\n summary: formData.get('summary') as string,\n minor: formData.get('minor') === 'on',\n section: options.section,\n createonly: wikiPage.pageid === 0,\n watchlist: watchList,\n })\n .then(async () => {\n modal.setOptions({\n beforeClose: noop,\n })\n modal.close()\n this.ctx.modal.notify('success', {\n title: 'Submission Successful',\n content: 'Your changes have been saved.',\n })\n if (formData.get('reloadAfterSave')) {\n await sleep(500)\n location.reload()\n }\n })\n .catch((error) => {\n this.ctx.modal.notify('error', {\n title: 'Submission Error',\n content: error instanceof Error ? error.message : String(error),\n })\n modal.setLoadingState(false)\n })\n },\n },\n 0\n )\n modal.setOptions({\n beforeClose: () => {\n const oldStr = wikiPage.revisions[0]?.content || ''\n const newStr = editForm.querySelector('textarea')?.value || ''\n if (newStr === oldStr) {\n return true\n } else {\n this.ctx.modal.confirm(\n {\n className: 'is-primary',\n title: 'Unsaved Changes',\n content:\n 'All edit contents will be lost after closing the modal. Are you sure you want to close?',\n center: true,\n okBtn: {\n label: 'Give Up',\n className: 'is-danger is-ghost',\n },\n cancelBtn: {\n label: 'Continue Editing',\n className: 'is-primary is-ghost',\n },\n },\n (confirmed) => {\n if (confirmed) {\n modal.setOptions({\n beforeClose: noop,\n })\n modal.close()\n }\n return true\n }\n )\n return false\n }\n },\n })\n this.ctx.emit('quick-edit/wiki-page', {\n ctx: this.ctx,\n options,\n modal,\n wikiPage,\n })\n\n const beforeUnload = (e: BeforeUnloadEvent) => {\n if (editForm.querySelector('textarea')?.value === edittingContent) {\n return true\n }\n e.preventDefault()\n return 'You have unsaved changes. Are you sure you want to leave?'\n }\n window.addEventListener('beforeunload', beforeUnload)\n modal.on(modal.Event.Close, () => {\n window.removeEventListener('beforeunload', beforeUnload)\n })\n }\n\n async handleSubmit(payload: QuickEditSubmitPayload) {\n const wikiPage = payload.wikiPage\n const summary = payload.summary || ''\n const text = payload.text || ''\n const minor = payload.minor\n const createonly = payload.createonly\n const watchlist = payload.watchlist\n const section = payload.section\n\n this.ctx.emit('quick-edit/submit', {\n ctx: this.ctx,\n wikiPage,\n summary,\n text,\n minor,\n createonly,\n watchlist,\n })\n\n return wikiPage.edit(\n {\n summary,\n text,\n watchlist,\n section,\n },\n {\n minor,\n createonly,\n }\n )\n }\n\n static readonly BUILT_IN_FONT_OPTIONS = ['preferences', 'monospace', 'sans-serif', 'serif']\n async getEditFontOptions() {\n const prefEditFont = (await this.ctx.preferences.get('quickEdit.editFont'))!\n if (PluginQuickEdit.BUILT_IN_FONT_OPTIONS.includes(prefEditFont)) {\n const editfont =\n prefEditFont === 'preferences'\n ? this.ctx.wiki.userOptions?.editfont || 'monospace'\n : prefEditFont\n return {\n className: `mw-editfont-${editfont}`,\n fontFamily: '',\n }\n } else {\n return {\n className: 'mw-editfont-custom',\n fontFamily: prefEditFont,\n }\n }\n }\n\n async getWikiPageFromPayload(payload: Partial<QuickEditOptions>) {\n if (payload.revision) {\n return this.ctx.wikiPage.newFromRevision(payload.revision, payload.section)\n } else if (payload.pageId) {\n return this.ctx.wikiPage.newFromPageId(payload.pageId, payload.section)\n } else if (payload.title) {\n return this.ctx.wikiPage.newFromTitle(payload.title, false, payload.section)\n }\n throw new Error('Invalid payload')\n }\n\n private async injectToolbox(ctx: InPageEdit) {\n const title = this.ctx.currentPage.wikiTitle\n const canEdit = this.ctx.wiki.hasRight('edit') && title && title.getNamespaceId() >= 0\n ctx.toolbox.addButton({\n id: 'quick-edit',\n group: 'group1',\n index: 0,\n icon: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-edit\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1\" />\n <path d=\"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z\" />\n <path d=\"M16 5l3 3\" />\n </svg>\n ) as HTMLElement,\n buttonProps: {\n disabled: !canEdit,\n },\n tooltip: canEdit ? 'Quick Edit' : 'Not editable',\n onClick: () => {\n const revision = new URLSearchParams(window.location.search).get('oldid')\n this.showModal({\n title: title?.getPrefixedText(),\n revision: revision ? Number(revision) : undefined,\n })\n },\n })\n }\n\n protected removeToolbox(ctx: InPageEdit) {\n ctx.toolbox.removeButton('quick-edit')\n }\n}\n"],"names":["sleep","ms","resolve","_PluginQuickEdit_decorators","_init","_a","Inject","RegisterPreferences","Schema","WatchlistAction","_PluginQuickEdit","BasePlugin","ctx","makeCallable","payload","searchParams","title","realTarget","outSideClose","watchList","editSummary","editMinor","fontOptions","options","modal","jsxs","Fragment","jsx","ProgressBar","wikiPage","e","edittingContent","edittingRevId","isEdittingOld","isCreatingNewSection","isCreatingNewPage","editNotices","MBox","editForm","InputBox","action","RadioBox","CheckBox","formData","noop","error","oldStr","confirmed","beforeUnload","summary","text","minor","createonly","watchlist","section","prefEditFont","canEdit","revision","__decoratorStart","__decorateElement","__runInitializers","PluginQuickEdit"],"mappings":";;;;;;;;;;AAAO,MAAMA,IAAQ,CAACC,IAAa,MACjC,IAAI,QAAQ,CAACC,MAAY,WAAWA,GAASD,CAAE,CAAC;;;;;;;;;;;;GCDlDE,GAAAC,GAAAC;AA+DAF,IAAA,CAACG,EAAO,CAAC,OAAO,YAAY,aAAa,eAAe,QAAQ,SAAS,aAAa,CAAC,GACtFC;AAAA,EACCC,EAAO,OAAO;AAAA,IACZ,yBAAyBA,EAAO,OAAA,EAC7B,YAAY,sCAAsC,EAClD,QAAQ,uBAAuB;AAAA,IAClC,uBAAuBA,EAAO,QAAA,EAC3B,YAAY,yCAAyC,EACrD,QAAQ,EAAK;AAAA,IAChB,0BAA0BA,EAAO,QAAA,EAC9B,YAAY,wCAAwC,EACpD,QAAQ,EAAI;AAAA,IACf,uBAAuBA,EAAO,MAAM;AAAA,MAClCA,EAAO,MAAMC,EAAgB,WAAW,EAAE,YAAY,uBAAuB;AAAA,MAC7ED,EAAO,MAAMC,EAAgB,QAAQ,EAAE,YAAY,mCAAmC;AAAA,MACtFD,EAAO,MAAMC,EAAgB,KAAK,EAAE,YAAY,2BAA2B;AAAA,MAC3ED,EAAO,MAAMC,EAAgB,OAAO,EAAE,YAAY,gCAAgC;AAAA,IAAA,CACnF,EACE,YAAY,mBAAmB,EAC/B,QAAQA,EAAgB,WA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zC;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACH;AAAA,EAEU,cAAc7C,GAAiB;AACvC,IAAAA,EAAI,QAAQ,aAAa,YAAY;AAAA,EACvC;AACF;AAneOR,IAAAsD,EAAArD,CAAA;AAAMK,IAANiD,4BApCPxD,GAoCaO,CAAA;AAANkD,EAAAxD,GAAA,GAAMM,CAAA;AAAN,IAAMmD,KAANnD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-DD5CVCfD.js","sources":["../src/components/TwinSwapInput/index.tsx"],"sourcesContent":["import { JSX } from 'jsx-dom/jsx-runtime'\nimport styles from './styles.module.sass'\n\nexport type TwinSwapInputProps = {\n inputs: [TwinSwapInputInput, TwinSwapInputInput]\n enableSwap?: boolean\n} & JSX.IntrinsicElements['div']\n\nexport interface TwinSwapInputInput {\n label?: string\n id?: string\n name: string\n value?: string\n disabled?: boolean\n required?: boolean\n inputProps?: Omit<JSX.IntrinsicElements['input'], 'name' | 'value'>\n}\n\nexport type TwinSwapElement = HTMLDivElement & {\n swap: () => void\n toggleEnableSwap: (enable?: boolean) => void\n}\n\nexport const TwinSwapInput = (props: TwinSwapInputProps) => {\n const { inputs, enableSwap = true, ...rest } = props\n\n const normalizedInputs =\n inputs?.length === 2\n ? inputs\n : ([inputs?.[0] ?? {}, inputs?.[1] ?? {}] as [TwinSwapInputInput, TwinSwapInputInput])\n\n // 内部稳定引用\n const inputRefs: [HTMLInputElement | null, HTMLInputElement | null] = [null, null]\n\n let swapCount = 0\n let swapBtnRef: HTMLButtonElement | null = null\n let svgRef: SVGElement | null = null\n\n const checkIfInputDisabled = () => inputRefs.some((el) => el && el.disabled)\n\n const swap = () => {\n if (!inputRefs[0] || !inputRefs[1]) return\n if (checkIfInputDisabled()) return\n\n const a = inputRefs[0]\n const b = inputRefs[1]\n const va = a.value\n const vb = b.value\n a.value = vb\n b.value = va\n\n // 与原实现一致:派发 change(不冒泡)\n a.dispatchEvent(new Event('change'))\n b.dispatchEvent(new Event('change'))\n\n swapCount++\n if (svgRef) {\n svgRef.style.transform = `rotateY(${swapCount * -180}deg)`\n svgRef.style.transition = 'transform 200ms ease'\n }\n }\n\n const toggleEnableSwap = (enable?: boolean) => {\n if (!swapBtnRef) return\n const next = enable ?? !swapBtnRef.disabled\n swapBtnRef.disabled = !next\n if (next) {\n // 与原实现一致:开启时把 inputs 解禁\n inputRefs.forEach((el) => {\n if (el) el.disabled = false\n })\n }\n }\n\n const swapButton = (\n <button\n type=\"button\"\n aria-label=\"Swap values\"\n onClick={swap}\n disabled={checkIfInputDisabled() || !enableSwap}\n ref={(el) => (swapBtnRef = el as HTMLButtonElement)}\n >\n <svg\n ref={(el) => (svgRef = el as unknown as SVGElement)}\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon-tabler icons-tabler-outline icon-tabler-transfer\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M20 10h-16l5.5 -6\" />\n <path d=\"M4 14h16l-5.5 6\" />\n </svg>\n </button>\n ) as HTMLButtonElement\n\n const container = (\n <div className={`twin-swap-input ${styles.twinSwapInput}`} {...rest}>\n {normalizedInputs.map((input, index) => {\n const { label, id, name, value, disabled, required, inputProps } = input\n const isLeft = index === 0\n const inputId = id || name\n\n return (\n <div\n className={`${styles.inputWrapper} ${isLeft ? styles.inputLeft : styles.inputRight}`}\n >\n {label && <label htmlFor={inputId}>{label}</label>}\n <input\n ref={(el) => (inputRefs[index] = el as HTMLInputElement)}\n type=\"text\"\n id={inputId}\n name={name}\n value={value}\n disabled={disabled}\n required={required}\n {...inputProps}\n />\n </div>\n )\n })}\n\n <div className={styles.swapButton}>{swapButton}</div>\n </div>\n ) as TwinSwapElement\n\n container.swap = swap\n container.toggleEnableSwap = toggleEnableSwap\n\n return container\n}\n"],"names":["TwinSwapInput","props","inputs","enableSwap","rest","normalizedInputs","inputRefs","swapCount","swapBtnRef","svgRef","checkIfInputDisabled","el","swap","a","b","va","vb","toggleEnableSwap","enable","next","swapButton","jsx","jsxs","container","styles","input","index","label","id","name","value","disabled","required","inputProps","isLeft","inputId"],"mappings":";;;;;;;GAuBaA,IAAgB,CAACC,MAA8B;AAC1D,QAAM,EAAE,QAAAC,GAAQ,YAAAC,IAAa,IAAM,GAAGC,MAASH,GAEzCI,IACJH,GAAQ,WAAW,IACfA,IACC,CAACA,IAAS,CAAC,KAAK,CAAA,GAAIA,IAAS,CAAC,KAAK,CAAA,CAAE,GAGtCI,IAAgE,CAAC,MAAM,IAAI;AAEjF,MAAIC,IAAY,GACZC,IAAuC,MACvCC,IAA4B;AAEhC,QAAMC,IAAuB,MAAMJ,EAAU,KAAK,CAACK,MAAOA,KAAMA,EAAG,QAAQ,GAErEC,IAAO,MAAM;AAEjB,QADI,CAACN,EAAU,CAAC,KAAK,CAACA,EAAU,CAAC,KAC7BI,IAAwB;AAE5B,UAAMG,IAAIP,EAAU,CAAC,GACfQ,IAAIR,EAAU,CAAC,GACfS,IAAKF,EAAE,OACPG,IAAKF,EAAE;AACb,IAAAD,EAAE,QAAQG,GACVF,EAAE,QAAQC,GAGVF,EAAE,cAAc,IAAI,MAAM,QAAQ,CAAC,GACnCC,EAAE,cAAc,IAAI,MAAM,QAAQ,CAAC,GAEnCP,KACIE,MACFA,EAAO,MAAM,YAAY,WAAWF,IAAY,IAAI,QACpDE,EAAO,MAAM,aAAa;AAAA,EAE9B,GAEMQ,IAAmB,CAACC,MAAqB;AAC7C,QAAI,CAACV,EAAY;AACjB,UAAMW,IAAOD,KAAU,CAACV,EAAW;AACnC,IAAAA,EAAW,WAAW,CAACW,GACnBA,KAEFb,EAAU,QAAQ,CAACK,MAAO;AACxB,MAAIA,QAAO,WAAW;AAAA,IACxB,CAAC;AAAA,EAEL,GAEMS,IACJ,gBAAAC;A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gBACC,KAAK,CAACV,MAAQL,EAAUoB,CAAK,IAAIf;AAAA,gBACjC,MAAK;AAAA,gBACL,IAAIwB;AAAA,gBACJ,MAAAN;AAAA,gBACA,OAAAC;AAAA,gBACA,UAAAC;AAAA,gBACA,UAAAC;AAAA,gBACC,GAAGC;AAAA,cAAA;AAAA,YAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN,CAAC;AAAA,IAED,gBAAAZ,EAAC,OAAA,EAAI,WAAWG,EAAO,YAAa,UAAAJ,EAAA,CAAW;AAAA,EAAA,GACjD;AAGF,SAAAG,EAAU,OAAOX,GACjBW,EAAU,mBAAmBN,GAEtBM;AACT;"}
|
|
1
|
+
{"version":3,"file":"index-DD5CVCfD.js","sources":["../src/components/TwinSwapInput/index.tsx"],"sourcesContent":["import { JSX } from 'jsx-dom/jsx-runtime'\r\nimport styles from './styles.module.sass'\r\n\r\nexport type TwinSwapInputProps = {\r\n inputs: [TwinSwapInputInput, TwinSwapInputInput]\r\n enableSwap?: boolean\r\n} & JSX.IntrinsicElements['div']\r\n\r\nexport interface TwinSwapInputInput {\r\n label?: string\r\n id?: string\r\n name: string\r\n value?: string\r\n disabled?: boolean\r\n required?: boolean\r\n inputProps?: Omit<JSX.IntrinsicElements['input'], 'name' | 'value'>\r\n}\r\n\r\nexport type TwinSwapElement = HTMLDivElement & {\r\n swap: () => void\r\n toggleEnableSwap: (enable?: boolean) => void\r\n}\r\n\r\nexport const TwinSwapInput = (props: TwinSwapInputProps) => {\r\n const { inputs, enableSwap = true, ...rest } = props\r\n\r\n const normalizedInputs =\r\n inputs?.length === 2\r\n ? inputs\r\n : ([inputs?.[0] ?? {}, inputs?.[1] ?? {}] as [TwinSwapInputInput, TwinSwapInputInput])\r\n\r\n // 内部稳定引用\r\n const inputRefs: [HTMLInputElement | null, HTMLInputElement | null] = [null, null]\r\n\r\n let swapCount = 0\r\n let swapBtnRef: HTMLButtonElement | null = null\r\n let svgRef: SVGElement | null = null\r\n\r\n const checkIfInputDisabled = () => inputRefs.some((el) => el && el.disabled)\r\n\r\n const swap = () => {\r\n if (!inputRefs[0] || !inputRefs[1]) return\r\n if (checkIfInputDisabled()) return\r\n\r\n const a = inputRefs[0]\r\n const b = inputRefs[1]\r\n const va = a.value\r\n const vb = b.value\r\n a.value = vb\r\n b.value = va\r\n\r\n // 与原实现一致:派发 change(不冒泡)\r\n a.dispatchEvent(new Event('change'))\r\n b.dispatchEvent(new Event('change'))\r\n\r\n swapCount++\r\n if (svgRef) {\r\n svgRef.style.transform = `rotateY(${swapCount * -180}deg)`\r\n svgRef.style.transition = 'transform 200ms ease'\r\n }\r\n }\r\n\r\n const toggleEnableSwap = (enable?: boolean) => {\r\n if (!swapBtnRef) return\r\n const next = enable ?? !swapBtnRef.disabled\r\n swapBtnRef.disabled = !next\r\n if (next) {\r\n // 与原实现一致:开启时把 inputs 解禁\r\n inputRefs.forEach((el) => {\r\n if (el) el.disabled = false\r\n })\r\n }\r\n }\r\n\r\n const swapButton = (\r\n <button\r\n type=\"button\"\r\n aria-label=\"Swap values\"\r\n onClick={swap}\r\n disabled={checkIfInputDisabled() || !enableSwap}\r\n ref={(el) => (swapBtnRef = el as HTMLButtonElement)}\r\n >\r\n <svg\r\n ref={(el) => (svgRef = el as unknown as SVGElement)}\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-tabler icons-tabler-outline icon-tabler-transfer\"\r\n >\r\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\r\n <path d=\"M20 10h-16l5.5 -6\" />\r\n <path d=\"M4 14h16l-5.5 6\" />\r\n </svg>\r\n </button>\r\n ) as HTMLButtonElement\r\n\r\n const container = (\r\n <div className={`twin-swap-input ${styles.twinSwapInput}`} {...rest}>\r\n {normalizedInputs.map((input, index) => {\r\n const { label, id, name, value, disabled, required, inputProps } = input\r\n const isLeft = index === 0\r\n const inputId = id || name\r\n\r\n return (\r\n <div\r\n className={`${styles.inputWrapper} ${isLeft ? styles.inputLeft : styles.inputRight}`}\r\n >\r\n {label && <label htmlFor={inputId}>{label}</label>}\r\n <input\r\n ref={(el) => (inputRefs[index] = el as HTMLInputElement)}\r\n type=\"text\"\r\n id={inputId}\r\n name={name}\r\n value={value}\r\n disabled={disabled}\r\n required={required}\r\n {...inputProps}\r\n />\r\n </div>\r\n )\r\n })}\r\n\r\n <div className={styles.swapButton}>{swapButton}</div>\r\n </div>\r\n ) as TwinSwapElement\r\n\r\n container.swap = swap\r\n container.toggleEnableSwap = toggleEnableSwap\r\n\r\n return container\r\n}\r\n"],"names":["TwinSwapInput","props","inputs","enableSwap","rest","normalizedInputs","inputRefs","swapCount","swapBtnRef","svgRef","checkIfInputDisabled","el","swap","a","b","va","vb","toggleEnableSwap","enable","next","swapButton","jsx","jsxs","container","styles","input","index","label","id","name","value","disabled","required","inputProps","isLeft","inputId"],"mappings":";;;;;;;GAuBaA,IAAgB,CAACC,MAA8B;AAC1D,QAAM,EAAE,QAAAC,GAAQ,YAAAC,IAAa,IAAM,GAAGC,MAASH,GAEzCI,IACJH,GAAQ,WAAW,IACfA,IACC,CAACA,IAAS,CAAC,KAAK,CAAA,GAAIA,IAAS,CAAC,KAAK,CAAA,CAAE,GAGtCI,IAAgE,CAAC,MAAM,IAAI;AAEjF,MAAIC,IAAY,GACZC,IAAuC,MACvCC,IAA4B;AAEhC,QAAMC,IAAuB,MAAMJ,EAAU,KAAK,CAACK,MAAOA,KAAMA,EAAG,QAAQ,GAErEC,IAAO,MAAM;AAEjB,QADI,CAACN,EAAU,CAAC,KAAK,CAACA,EAAU,CAAC,KAC7BI,IAAwB;AAE5B,UAAMG,IAAIP,EAAU,CAAC,GACfQ,IAAIR,EAAU,CAAC,GACfS,IAAKF,EAAE,OACPG,IAAKF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,GAC5D,UAAA;AAAA,IAAAC,EAAiB,IAAI,CAACoB,GAAOC,MAAU;AACtC,YAAM,EAAE,OAAAC,GAAO,IAAAC,GAAI,MAAAC,GAAM,OAAAC,GAAO,UAAAC,GAAU,UAAAC,GAAU,YAAAC,MAAeR,GAC7DS,IAASR,MAAU,GACnBS,IAAUP,KAAMC;AAEtB,aACEP,gBAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,GAAGE,EAAO,YAAY,IAAIU,IAASV,EAAO,YAAYA,EAAO,UAAU;AAAA,UAEjF,UAAA;AAAA,YAAAG,KAAS,gBAAAN,EAAC,SAAA,EAAM,SAASc,GAAU,UAAAR,GAAM;AAAA,YAC1C,gBAAAN;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAK,CAACV,MAAQL,EAAUoB,CAAK,IAAIf;AAAA,gBACjC,MAAK;AAAA,gBACL,IAAIwB;AAAA,gBACJ,MAAAN;AAAA,gBACA,OAAAC;AAAA,gBACA,UAAAC;AAAA,gBACA,UAAAC;AAAA,gBACC,GAAGC;AAAA,cAAA;AAAA,YAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN,CAAC;AAAA,IAED,gBAAAZ,EAAC,OAAA,EAAI,WAAWG,EAAO,YAAa,UAAAJ,EAAA,CAAW;AAAA,EAAA,GACjD;AAGF,SAAAG,EAAU,OAAOX,GACjBW,EAAU,mBAAmBN,GAEtBM;AACT;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Events as Events$1, ForkScope, Inject, Inject as Inject$1, Service } from "@cordisjs/core";
|
|
2
2
|
import * as _inpageedit_logger0 from "@inpageedit/logger";
|
|
3
3
|
import { Logger } from "@inpageedit/logger";
|
|
4
|
-
import * as
|
|
4
|
+
import * as wiki_saikou1 from "wiki-saikou";
|
|
5
5
|
import { FexiosConfigs, MwApiParams } from "wiki-saikou";
|
|
6
6
|
import { FexiosFinalContext, MediaWikiApi, MwApi, MwApiParams as MwApiParams$1, MwApiResponse } from "wiki-saikou/browser";
|
|
7
7
|
import { IPEModal, IPEModalEvent, IPEModalOptions } from "@inpageedit/modal";
|
|
@@ -23,7 +23,8 @@ export * from "@inpageedit/modal";
|
|
|
23
23
|
//#region rolldown:runtime
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/services/ApiService.d.ts
|
|
26
|
-
|
|
26
|
+
// ↓ '@/InPageEdit'
|
|
27
|
+
declare module '.' {
|
|
27
28
|
interface InPageEdit {
|
|
28
29
|
api: MwApi;
|
|
29
30
|
}
|
|
@@ -257,7 +258,8 @@ interface WikiTitleConstructor {
|
|
|
257
258
|
declare function createWikiTitleModel(metadata: WikiSiteInfo): WikiTitleConstructor;
|
|
258
259
|
//#endregion
|
|
259
260
|
//#region src/services/CurrentPageService.d.ts
|
|
260
|
-
|
|
261
|
+
// ↓ '@/InPageEdit.js'
|
|
262
|
+
declare module '.' {
|
|
261
263
|
interface InPageEdit {
|
|
262
264
|
/**
|
|
263
265
|
* Basic information of the current web page
|
|
@@ -285,7 +287,8 @@ declare class CurrentPageService extends Service {
|
|
|
285
287
|
}
|
|
286
288
|
//#endregion
|
|
287
289
|
//#region src/services/ResourceLoaderService.d.ts
|
|
288
|
-
|
|
290
|
+
// ↓ '@/InPageEdit'
|
|
291
|
+
declare module '.' {
|
|
289
292
|
interface InPageEdit {
|
|
290
293
|
resourceLoader: ResourceLoaderService;
|
|
291
294
|
}
|
|
@@ -303,7 +306,8 @@ declare class ResourceLoaderService extends Service {
|
|
|
303
306
|
}
|
|
304
307
|
//#endregion
|
|
305
308
|
//#region src/services/ModalService.d.ts
|
|
306
|
-
|
|
309
|
+
// ↓ '@/InPageEdit'
|
|
310
|
+
declare module '.' {
|
|
307
311
|
interface InPageEdit {
|
|
308
312
|
modal: ModalService;
|
|
309
313
|
}
|
|
@@ -385,7 +389,8 @@ declare class IDBStorageManager<T = unknown> implements AbstractIPEStorageManage
|
|
|
385
389
|
}
|
|
386
390
|
//#endregion
|
|
387
391
|
//#region src/services/storage/index.d.ts
|
|
388
|
-
|
|
392
|
+
// ↓ '@/InPageEdit'
|
|
393
|
+
declare module '.' {
|
|
389
394
|
interface InPageEdit {
|
|
390
395
|
storage: StorageService;
|
|
391
396
|
}
|
|
@@ -424,7 +429,8 @@ interface AbstractIPEStorageManager<T = unknown> {
|
|
|
424
429
|
}
|
|
425
430
|
//#endregion
|
|
426
431
|
//#region src/services/WikiMetadataService.d.ts
|
|
427
|
-
|
|
432
|
+
// ↓ '@/InPageEdit'
|
|
433
|
+
declare module '.' {
|
|
428
434
|
interface InPageEdit {
|
|
429
435
|
wiki: WikiMetadataService;
|
|
430
436
|
getUrl: WikiMetadataService['getUrl'];
|
|
@@ -692,7 +698,8 @@ interface WikiPageConstructor {
|
|
|
692
698
|
declare function createWikiPageModel(api: MediaWikiApi): WikiPageConstructor;
|
|
693
699
|
//#endregion
|
|
694
700
|
//#region src/services/WikiPageService.d.ts
|
|
695
|
-
|
|
701
|
+
// ↓ '@/InPageEdit'
|
|
702
|
+
declare module '.' {
|
|
696
703
|
interface InPageEdit {
|
|
697
704
|
wikiPage: WikiPageService;
|
|
698
705
|
}
|
|
@@ -710,7 +717,8 @@ declare class WikiPageService extends Service {
|
|
|
710
717
|
}
|
|
711
718
|
//#endregion
|
|
712
719
|
//#region src/services/WikiTitleService.d.ts
|
|
713
|
-
|
|
720
|
+
// ↓ '@/InPageEdit'
|
|
721
|
+
declare module '.' {
|
|
714
722
|
interface InPageEdit {
|
|
715
723
|
wikiTitle: WikiTitleService;
|
|
716
724
|
}
|
|
@@ -783,7 +791,8 @@ declare class WikiTitleService extends Service {
|
|
|
783
791
|
type ComputeAble<T> = (() => T | Promise<T>) | T;
|
|
784
792
|
//#endregion
|
|
785
793
|
//#region src/services/PreferencesService.d.ts
|
|
786
|
-
|
|
794
|
+
// ↓ '@/InPageEdit'
|
|
795
|
+
declare module '.' {
|
|
787
796
|
interface InPageEdit {
|
|
788
797
|
preferences: PreferencesService;
|
|
789
798
|
prefs: PreferencesService;
|
|
@@ -922,7 +931,7 @@ declare enum Endpoints {
|
|
|
922
931
|
interface DisposeHandler {
|
|
923
932
|
(ctx: InPageEdit): Promise<void> | void;
|
|
924
933
|
}
|
|
925
|
-
declare class BasePlugin
|
|
934
|
+
declare class BasePlugin<ConfigType extends unknown = any> {
|
|
926
935
|
#private;
|
|
927
936
|
ctx: InPageEdit;
|
|
928
937
|
config: ConfigType;
|
|
@@ -1110,7 +1119,8 @@ declare class MemoryStorage implements Storage {
|
|
|
1110
1119
|
declare const useMemoryStorage: () => MemoryStorage;
|
|
1111
1120
|
//#endregion
|
|
1112
1121
|
//#region src/plugins/analytics/index.d.ts
|
|
1113
|
-
|
|
1122
|
+
// ↓ '@/InPageEdit'
|
|
1123
|
+
declare module '.' {
|
|
1114
1124
|
interface InPageEdit {
|
|
1115
1125
|
analytics: PluginAnalytics;
|
|
1116
1126
|
}
|
|
@@ -1152,7 +1162,8 @@ declare class PluginAnalytics extends BasePlugin {
|
|
|
1152
1162
|
}
|
|
1153
1163
|
//#endregion
|
|
1154
1164
|
//#region src/plugins/in-article-links/index.d.ts
|
|
1155
|
-
|
|
1165
|
+
// ↓ '@/InPageEdit'
|
|
1166
|
+
declare module '.' {
|
|
1156
1167
|
interface InPageEdit {
|
|
1157
1168
|
inArticleLinks: PluginInArticleLinks;
|
|
1158
1169
|
}
|
|
@@ -1237,7 +1248,8 @@ declare namespace PluginStoreSchemas {
|
|
|
1237
1248
|
}
|
|
1238
1249
|
//#endregion
|
|
1239
1250
|
//#region src/plugins/plugin-store/index.d.ts
|
|
1240
|
-
|
|
1251
|
+
// ↓ '@/InPageEdit'
|
|
1252
|
+
declare module '.' {
|
|
1241
1253
|
interface InPageEdit {
|
|
1242
1254
|
store: PluginPluginStore;
|
|
1243
1255
|
}
|
|
@@ -1292,7 +1304,8 @@ declare class PluginPluginStore extends BasePlugin {
|
|
|
1292
1304
|
}
|
|
1293
1305
|
//#endregion
|
|
1294
1306
|
//#region src/plugins/preferences-ui/index.d.ts
|
|
1295
|
-
|
|
1307
|
+
// ↓ '@/InPageEdit'
|
|
1308
|
+
declare module '.' {
|
|
1296
1309
|
interface InPageEdit {
|
|
1297
1310
|
preferencesUI: PluginPreferencesUI;
|
|
1298
1311
|
}
|
|
@@ -1338,7 +1351,8 @@ declare class PluginPreferencesUI extends BasePlugin {
|
|
|
1338
1351
|
}
|
|
1339
1352
|
//#endregion
|
|
1340
1353
|
//#region src/plugins/quick-diff/index.d.ts
|
|
1341
|
-
|
|
1354
|
+
// ↓ '@/InPageEdit'
|
|
1355
|
+
declare module '.' {
|
|
1342
1356
|
interface InPageEdit {
|
|
1343
1357
|
quickDiff: PluginQuickDiff;
|
|
1344
1358
|
}
|
|
@@ -1422,7 +1436,8 @@ declare class PluginQuickDiff extends BasePlugin {
|
|
|
1422
1436
|
}
|
|
1423
1437
|
//#endregion
|
|
1424
1438
|
//#region src/plugins/quick-edit/index.d.ts
|
|
1425
|
-
|
|
1439
|
+
// ↓ '@/InPageEdit'
|
|
1440
|
+
declare module '.' {
|
|
1426
1441
|
interface InPageEdit {
|
|
1427
1442
|
quickEdit: PluginQuickEdit & {
|
|
1428
1443
|
(...args: Parameters<PluginQuickEdit['showModal']>): ReturnType<PluginQuickEdit['showModal']>;
|
|
@@ -1484,7 +1499,7 @@ declare class PluginQuickEdit extends BasePlugin {
|
|
|
1484
1499
|
constructor(ctx: InPageEdit);
|
|
1485
1500
|
protected start(): Promise<void> | void;
|
|
1486
1501
|
showModal(payload?: string | Partial<QuickEditOptions>): Promise<void>;
|
|
1487
|
-
handleSubmit(payload: QuickEditSubmitPayload): Promise<Required<
|
|
1502
|
+
handleSubmit(payload: QuickEditSubmitPayload): Promise<Required<wiki_saikou1.FexiosContext<wiki_saikou1.MwApiResponse<{
|
|
1488
1503
|
success: boolean;
|
|
1489
1504
|
}>>>>;
|
|
1490
1505
|
static readonly BUILT_IN_FONT_OPTIONS: string[];
|
|
@@ -1498,7 +1513,8 @@ declare class PluginQuickEdit extends BasePlugin {
|
|
|
1498
1513
|
}
|
|
1499
1514
|
//#endregion
|
|
1500
1515
|
//#region src/plugins/quick-move/index.d.ts
|
|
1501
|
-
|
|
1516
|
+
// ↓ '@/InPageEdit'
|
|
1517
|
+
declare module '.' {
|
|
1502
1518
|
interface InPageEdit {
|
|
1503
1519
|
quickMove: PluginQuickMove;
|
|
1504
1520
|
}
|
|
@@ -1539,7 +1555,7 @@ declare class PluginQuickMove extends BasePlugin {
|
|
|
1539
1555
|
protected start(): Promise<void> | void;
|
|
1540
1556
|
private injectToolbox;
|
|
1541
1557
|
showModal(options?: Partial<QuickMoveOptions>): Promise<CustomIPEModal>;
|
|
1542
|
-
movePage(options: MovePageOptions): Promise<Required<
|
|
1558
|
+
movePage(options: MovePageOptions): Promise<Required<wiki_saikou1.FexiosContext<wiki_saikou1.MwApiResponse<{
|
|
1543
1559
|
success: boolean;
|
|
1544
1560
|
}>>>>;
|
|
1545
1561
|
}
|
|
@@ -1552,7 +1568,8 @@ interface QuickPreviewEventPayload {
|
|
|
1552
1568
|
text: string;
|
|
1553
1569
|
parseData: PageParseData;
|
|
1554
1570
|
}
|
|
1555
|
-
|
|
1571
|
+
// ↓ '@/InPageEdit'
|
|
1572
|
+
declare module '.' {
|
|
1556
1573
|
interface InPageEdit {
|
|
1557
1574
|
quickPreview: PluginQuickPreview & {
|
|
1558
1575
|
(...args: Parameters<PluginQuickPreview['previewWikitext']>): ReturnType<PluginQuickPreview['previewWikitext']>;
|
|
@@ -1577,7 +1594,8 @@ declare class PluginQuickPreview extends BasePlugin {
|
|
|
1577
1594
|
}
|
|
1578
1595
|
//#endregion
|
|
1579
1596
|
//#region src/plugins/quick-redirect/index.d.ts
|
|
1580
|
-
|
|
1597
|
+
// ↓ '@/InPageEdit'
|
|
1598
|
+
declare module '.' {
|
|
1581
1599
|
interface InPageEdit {
|
|
1582
1600
|
quickRedirect: PluginQuickRedirect;
|
|
1583
1601
|
}
|
|
@@ -1618,13 +1636,14 @@ declare class PluginQuickRedirect extends BasePlugin {
|
|
|
1618
1636
|
protected start(): Promise<void> | void;
|
|
1619
1637
|
protected stop(): Promise<void> | void;
|
|
1620
1638
|
showModal(options?: Partial<QuickRedirectOptions>): Promise<CustomIPEModal>;
|
|
1621
|
-
redirectPage(options: RedirectPageOptions): Promise<Required<
|
|
1639
|
+
redirectPage(options: RedirectPageOptions): Promise<Required<wiki_saikou1.FexiosContext<wiki_saikou1.MwApiResponse<{
|
|
1622
1640
|
success: boolean;
|
|
1623
1641
|
}>>>>;
|
|
1624
1642
|
}
|
|
1625
1643
|
//#endregion
|
|
1626
1644
|
//#region src/plugins/toolbox/index.d.ts
|
|
1627
|
-
|
|
1645
|
+
// ↓ '@/InPageEdit'
|
|
1646
|
+
declare module '.' {
|
|
1628
1647
|
interface InPageEdit {
|
|
1629
1648
|
toolbox: PluginToolbox;
|
|
1630
1649
|
}
|
|
@@ -1691,7 +1710,7 @@ declare namespace index_d_exports$1 {
|
|
|
1691
1710
|
export { AbstractIPEStorageManager, ApiService, ApiServiceOptions, CurrentPageService, CustomIPEModal, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, ModalService, PreferencesService, ResourceLoaderService, StorageService, StorageServiceConfig, TypedStorageEntry, WikiLinkMetadata, WikiMetadataService, WikiPageService, WikiTitleService };
|
|
1692
1711
|
}
|
|
1693
1712
|
declare namespace index_d_exports {
|
|
1694
|
-
export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin
|
|
1713
|
+
export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin, CheckBox, CheckBoxProps, CompareApiRequestOptions, CompareApiResponse, ContentModelMap, CurrentPageService, CustomIPEModal, Endpoints, Events, IPEBeaconPayload, IPEBeaconUsage, IWikiPage, IWikiTitle, InArticleWikiAnchorMetadata, InPageEdit, InPageEditCoreConfig, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, Inject, InputBox, InputBoxProps, MBox, MBoxElement, MBoxProps, MemoryStorage, ModalService, MovePageOptions, PageInfo, PageParseData, PluginAnalytics, PluginInArticleLinks, PluginPluginStore, PluginPreferencesUI, PluginQuickDiff, PluginQuickEdit, PluginQuickMove, PluginQuickPreview, PluginQuickRedirect, PluginStoreRegistrySource, PluginToolbox, PreferencesMap, PreferencesService, ProgressBar, QuickEditEventPayload, QuickEditOptions, QuickEditSubmitPayload, QuickMoveOptions, QuickRedirectOptions, RadioBox, RadioBoxProps, RedirectPageOptions, RegisterPreferences, ResourceLoaderService, Schema, Service, StorageService, StorageServiceConfig, TabContent, TabLabel, TabView, TabViewLabelOptions, TwinSwapElement, TwinSwapInput, TwinSwapInputInput, TwinSwapInputProps, TypedStorageEntry, WatchlistAction, WikiLinkMetadata, WikiMagicWord, WikiMetadataService, WikiNameSpaceAlias, WikiNamespace, WikiPageConstructor, WikiPageEditPayload, WikiPageService, WikiSiteGeneralInfo, WikiSiteInfo, WikiSpecialPageAlias, WikiTitleConstructor, WikiTitleService, WikiUserBlockInfo, WikiUserInfo, WikiUserOptions, createWikiPageModel, createWikiTitleModel, useMemoryStorage };
|
|
1695
1714
|
}
|
|
1696
1715
|
declare global {
|
|
1697
1716
|
const ipe: InPageEdit;
|
|
@@ -1727,4 +1746,4 @@ declare global {
|
|
|
1727
1746
|
}
|
|
1728
1747
|
}
|
|
1729
1748
|
//#endregion
|
|
1730
|
-
export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin
|
|
1749
|
+
export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin, CheckBox, CheckBoxProps, CompareApiRequestOptions, CompareApiResponse, ContentModelMap, CurrentPageService, CustomIPEModal, Endpoints, Events, IPEBeaconPayload, IPEBeaconUsage, IWikiPage, IWikiTitle, InArticleWikiAnchorMetadata, InPageEdit, InPageEditCoreConfig, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, Inject, InputBox, InputBoxProps, MBox, MBoxElement, MBoxProps, MemoryStorage, ModalService, MovePageOptions, PageInfo, PageParseData, PluginAnalytics, PluginInArticleLinks, PluginPluginStore, PluginPreferencesUI, PluginQuickDiff, PluginQuickEdit, PluginQuickMove, PluginQuickPreview, PluginQuickRedirect, PluginStoreRegistrySource, PluginToolbox, PreferencesMap, PreferencesService, ProgressBar, QuickEditEventPayload, QuickEditOptions, QuickEditSubmitPayload, QuickMoveOptions, QuickRedirectOptions, RadioBox, RadioBoxProps, RedirectPageOptions, RegisterPreferences, ResourceLoaderService, Schema, Service, StorageService, StorageServiceConfig, TabContent, TabLabel, TabView, TabViewLabelOptions, TwinSwapElement, TwinSwapInput, TwinSwapInputInput, TwinSwapInputProps, TypedStorageEntry, WatchlistAction, WikiLinkMetadata, WikiMagicWord, WikiMetadataService, WikiNameSpaceAlias, WikiNamespace, WikiPageConstructor, WikiPageEditPayload, WikiPageService, WikiSiteGeneralInfo, WikiSiteInfo, WikiSpecialPageAlias, WikiTitleConstructor, WikiTitleService, WikiUserBlockInfo, WikiUserInfo, WikiUserOptions, createWikiPageModel, createWikiTitleModel, useMemoryStorage };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as s } from "./index-
|
|
2
|
-
import { m as l, $ as g, S as m } from "./index-
|
|
1
|
+
import { I as s } from "./index-C_BIsubQ.js";
|
|
2
|
+
import { m as l, $ as g, S as m } from "./index-C_BIsubQ.js";
|
|
3
3
|
import { E as r } from "./endpoints-DgyuoRZd.js";
|
|
4
4
|
import { I as L, S as P, a as U } from "./endpoints-DgyuoRZd.js";
|
|
5
5
|
import { B as S } from "./BasePlugin-Bf2UuIHF.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeCallable-LDU0xZMJ.js","sources":["../src/utils/makeCallable.ts"],"sourcesContent":["export const CALLABLE_APPLY_SYMBOL = Symbol('@@apply')\nexport const CALLABLE_CTOR_SYMBOL = Symbol('@@ctor')\nexport function makeCallable<C extends object, M extends keyof C>(\n instance: C,\n method: M\n): C &\n ((\n ...args: C[M] extends (...a: infer P) => any ? P : never\n ) => C[M] extends (...a: any[]) => infer R ? R : never) {\n if (typeof instance !== 'object' || instance === null || Array.isArray(instance)) {\n throw new TypeError('instance is not an object')\n }\n\n const apply: any = (...args: any[]) => {\n const fn = (instance as any)[method]\n if (typeof fn !== 'function') {\n throw new TypeError(`Property \"${String(method)}\" is not a function`)\n }\n return fn.apply(instance, args)\n }\n apply[CALLABLE_APPLY_SYMBOL] = apply\n apply[CALLABLE_CTOR_SYMBOL] = instance\n\n const ctorName = (instance as any)?.constructor?.name\n if (ctorName) (apply as any)[Symbol.toStringTag] = ctorName\n\n const proxy = new Proxy(apply, {\n get(_, p, receiver) {\n if (p === 'prototype') return Reflect.get(apply, p, receiver)\n return Reflect.get(instance as any, p, instance)\n },\n set(_, p, v) {\n return Reflect.set(instance as any, p, v)\n },\n has(_, p) {\n return Reflect.has(instance as any, p)\n },\n deleteProperty(_, p) {\n return Reflect.deleteProperty(instance as any, p)\n },\n ownKeys() {\n return Reflect.ownKeys(instance as any)\n },\n getOwnPropertyDescriptor(_, p) {\n return Object.getOwnPropertyDescriptor(instance as any, p)\n },\n defineProperty(_, p, desc) {\n return Object.defineProperty(instance as any, p, desc)\n },\n })\n\n return proxy as unknown as any\n}\n"],"names":["CALLABLE_APPLY_SYMBOL","CALLABLE_CTOR_SYMBOL","makeCallable","instance","method","apply","args","fn","ctorName","_","p","receiver","v","desc"],"mappings":"AAAO,MAAMA,IAAwB,OAAO,SAAS,GACxCC,IAAuB,OAAO,QAAQ;AAC5C,SAASC,EACdC,GACAC,GAIwD;AACxD,MAAI,OAAOD,KAAa,YAAYA,MAAa,QAAQ,MAAM,QAAQA,CAAQ;AAC7E,UAAM,IAAI,UAAU,2BAA2B;AAGjD,QAAME,IAAa,IAAIC,MAAgB;AACrC,UAAMC,IAAMJ,EAAiBC,CAAM;AACnC,QAAI,OAAOG,KAAO;AAChB,YAAM,IAAI,UAAU,aAAa,OAAOH,CAAM,CAAC,qBAAqB;AAEtE,WAAOG,EAAG,MAAMJ,GAAUG,CAAI;AAAA,EAChC;AACA,EAAAD,EAAML,CAAqB,IAAIK,GAC/BA,EAAMJ,CAAoB,IAAIE;AAE9B,QAAMK,IAAYL,GAAkB,aAAa;AACjD,SAAIK,MAAWH,EAAc,OAAO,WAAW,IAAIG,IAErC,IAAI,MAAMH,GAAO;AAAA,IAC7B,IAAII,GAAGC,GAAGC,GAAU;AAClB,aAAID,MAAM,cAAoB,QAAQ,IAAIL,GAAOK,GAAGC,CAAQ,IACrD,QAAQ,IAAIR,GAAiBO,GAAGP,CAAQ;AAAA,IACjD;AAAA,IACA,IAAIM,GAAGC,GAAGE,GAAG;AACX,aAAO,QAAQ,IAAIT,GAAiBO,GAAGE,CAAC;AAAA,IAC1C;AAAA,IACA,IAAIH,GAAGC,GAAG;AACR,aAAO,QAAQ,IAAIP,GAAiBO,CAAC;AAAA,IACvC;AAAA,IACA,eAAeD,GAAGC,GAAG;AACnB,aAAO,QAAQ,eAAeP,GAAiBO,CAAC;AAAA,IAClD;AAAA,IACA,UAAU;AACR,aAAO,QAAQ,QAAQP,CAAe;AAAA,IACxC;AAAA,IACA,yBAAyBM,GAAGC,GAAG;AAC7B,aAAO,OAAO,yBAAyBP,GAAiBO,CAAC;AAAA,IAC3D;AAAA,IACA,eAAeD,GAAGC,GAAGG,GAAM;AACzB,aAAO,OAAO,eAAeV,GAAiBO,GAAGG,CAAI;AAAA,IACvD;AAAA,EAAA,CACD;AAGH;"}
|
|
1
|
+
{"version":3,"file":"makeCallable-LDU0xZMJ.js","sources":["../src/utils/makeCallable.ts"],"sourcesContent":["export const CALLABLE_APPLY_SYMBOL = Symbol('@@apply')\r\nexport const CALLABLE_CTOR_SYMBOL = Symbol('@@ctor')\r\nexport function makeCallable<C extends object, M extends keyof C>(\r\n instance: C,\r\n method: M\r\n): C &\r\n ((\r\n ...args: C[M] extends (...a: infer P) => any ? P : never\r\n ) => C[M] extends (...a: any[]) => infer R ? R : never) {\r\n if (typeof instance !== 'object' || instance === null || Array.isArray(instance)) {\r\n throw new TypeError('instance is not an object')\r\n }\r\n\r\n const apply: any = (...args: any[]) => {\r\n const fn = (instance as any)[method]\r\n if (typeof fn !== 'function') {\r\n throw new TypeError(`Property \"${String(method)}\" is not a function`)\r\n }\r\n return fn.apply(instance, args)\r\n }\r\n apply[CALLABLE_APPLY_SYMBOL] = apply\r\n apply[CALLABLE_CTOR_SYMBOL] = instance\r\n\r\n const ctorName = (instance as any)?.constructor?.name\r\n if (ctorName) (apply as any)[Symbol.toStringTag] = ctorName\r\n\r\n const proxy = new Proxy(apply, {\r\n get(_, p, receiver) {\r\n if (p === 'prototype') return Reflect.get(apply, p, receiver)\r\n return Reflect.get(instance as any, p, instance)\r\n },\r\n set(_, p, v) {\r\n return Reflect.set(instance as any, p, v)\r\n },\r\n has(_, p) {\r\n return Reflect.has(instance as any, p)\r\n },\r\n deleteProperty(_, p) {\r\n return Reflect.deleteProperty(instance as any, p)\r\n },\r\n ownKeys() {\r\n return Reflect.ownKeys(instance as any)\r\n },\r\n getOwnPropertyDescriptor(_, p) {\r\n return Object.getOwnPropertyDescriptor(instance as any, p)\r\n },\r\n defineProperty(_, p, desc) {\r\n return Object.defineProperty(instance as any, p, desc)\r\n },\r\n })\r\n\r\n return proxy as unknown as any\r\n}\r\n"],"names":["CALLABLE_APPLY_SYMBOL","CALLABLE_CTOR_SYMBOL","makeCallable","instance","method","apply","args","fn","ctorName","_","p","receiver","v","desc"],"mappings":"AAAO,MAAMA,IAAwB,OAAO,SAAS,GACxCC,IAAuB,OAAO,QAAQ;AAC5C,SAASC,EACdC,GACAC,GAIwD;AACxD,MAAI,OAAOD,KAAa,YAAYA,MAAa,QAAQ,MAAM,QAAQA,CAAQ;AAC7E,UAAM,IAAI,UAAU,2BAA2B;AAGjD,QAAME,IAAa,IAAIC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