From f52542a90750a92204141fb1cce6675ebeafe418 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:21:12 +0000 Subject: [PATCH 1/2] feat(edit-any-page): autofocus input and confirm on Enter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 Co-authored-by: 机智的小鱼君 <44761872+dragon-fish@users.noreply.github.com> --- packages/edit-any-page/src/index.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/edit-any-page/src/index.ts b/packages/edit-any-page/src/index.ts index 8f92a0c..a535da8 100644 --- a/packages/edit-any-page/src/index.ts +++ b/packages/edit-any-page/src/index.ts @@ -22,7 +22,15 @@ export default defineIPEPlugin({ input.value = mw.config.get('wgPageName') input.style.width = '100%' form.appendChild(input) - ctx.modal.confirm( + const submit = () => { + const pageName = input.value.trim() + if (!pageName) return false + ctx.quickEdit({ + title: pageName, + }) + return true + } + const modal: any = ctx.modal.confirm( { title: 'Edit any page', content: form, @@ -31,14 +39,21 @@ export default defineIPEPlugin({ }, (result) => { if (!result) return true - const pageName = input.value.trim() - if (!pageName) return false - ctx.quickEdit({ - title: pageName, - }) - return true + return submit() } ) + // Press Enter to confirm + form.addEventListener('submit', (e) => { + e.preventDefault() + if (submit()) { + modal?.close?.() + } + }) + // Auto focus and select all once the modal is mounted + requestAnimationFrame(() => { + input.focus() + input.select() + }) }, }) From 61e8fc5ba7561eb0bbd402d4dbc4ad24d24b67f1 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:43:57 +0000 Subject: [PATCH 2/2] refactor(edit-any-page): use typed modal and drop optional close guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 机智的小鱼君 <44761872+dragon-fish@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 --- packages/edit-any-page/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/edit-any-page/src/index.ts b/packages/edit-any-page/src/index.ts index a535da8..b0ae4ff 100644 --- a/packages/edit-any-page/src/index.ts +++ b/packages/edit-any-page/src/index.ts @@ -30,7 +30,7 @@ export default defineIPEPlugin({ }) return true } - const modal: any = ctx.modal.confirm( + const modal = ctx.modal.confirm( { title: 'Edit any page', content: form, @@ -46,7 +46,7 @@ export default defineIPEPlugin({ form.addEventListener('submit', (e) => { e.preventDefault() if (submit()) { - modal?.close?.() + modal.close() } }) // Auto focus and select all once the modal is mounted