Skip to content

build: patch vditor to bind click instead of touchstart on iPhone - #1296

Open
JonasGao wants to merge 1 commit into
blinkospace:mainfrom
JonasGao:build/patch-vditor-click-event
Open

JonasGao wants to merge 1 commit into
blinkospace:mainfrom
JonasGao:build/patch-vditor-click-event

Conversation

@JonasGao

Copy link
Copy Markdown

Summary

vditor's getEventName() returns "touchstart" for iPhone user agents, a workaround for the 300ms click delay. Blinko ships a user-scalable=no viewport, where click fires with no delay, so the branch only means that every toolbar action fires on finger-down, with no pressed feedback.

Blinko pins vditor@3.11.2 and the latest release (4.0.1) still has the branch, so it is patched in place:

 // node_modules/vditor/src/ts/util/compatibility.ts
 export const getEventName = () => {
-    if (navigator.userAgent.indexOf("iPhone") > -1) {
-        return "touchstart";
-    } else {
-        return "click";
-    }
+    return "click";
 };
 package.json
+  "patchedDependencies": {
+    "vditor@3.11.2": "patches/vditor@3.11.2.patch"
+  }

Evidence

iPhone user agent, editor open, main vs this branch (bun 1.2.8, clean install). Run once with each event:

const btn = document.querySelector('.vditor-toolbar__item [data-type="emoji"]');
const isOpen = () => getComputedStyle(btn.parentElement.querySelector('.vditor-panel')).display !== 'none';
btn.dispatchEvent(new TouchEvent('touchstart', { bubbles: true, cancelable: true }));   // or: new MouseEvent('click', …)
console.log(isOpen());
touchstart click
Before true false
After false true

bun install --frozen-lockfile passes with bun 1.2.8 (the Dockerfile and the release workflows) and with 1.3.10. bun.lock only gains the patchedDependencies entry.

Merge Danger

Door: two-way

Delete the patchedDependencies entry and the patch file.

Blast Radius: Dependency

  • This is the repo's first patchedDependencies entry. It needs a bun that supports it; 1.2.8 does.
  • Only iPhones change behaviour. Every other platform already got click.
  • The entry is keyed to vditor@3.11.2. A vditor bump that leaves the key behind installs vditor unpatched, and bun 1.2.8 does not warn about it.

🤖 Generated with Claude Code

vditor's getEventName() returns "touchstart" for iPhone user agents, a
workaround for the long-gone 300ms click delay. With it every toolbar
action fires on finger-down, with no pressed feedback.

The app ships a user-scalable=no viewport, so click fires with no delay;
make vditor always use it. The latest vditor release (4.0.1) still has
the touchstart branch, so the change is applied as a bun
patchedDependencies patch against the pinned 3.11.2.

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant