Skip to content

fix(editor): preserve inline boundary typing sessions#514

Open
murongg wants to merge 4 commits into
mainfrom
fix/webview-mark-input-affinity
Open

fix(editor): preserve inline boundary typing sessions#514
murongg wants to merge 4 commits into
mainfrom
fix/webview-mark-input-affinity

Conversation

@murongg

@murongg murongg commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • retain explicit inside/outside affinity when desktop WebViews overwrite the ProseMirror boundary selection
  • preserve inside affinity across consecutive characters while remapping and revalidating live Markdown ranges
  • restore the captured selection and stored marks before native IME composition starts
  • leave intermediate IME composition text under native ProseMirror/WebView control and apply only the final commit
  • clear stale affinity when arrows cross delimiters or live syntax becomes invalid
  • take over only cancelable, non-composing insertText events and keep native RTL/bidi navigation
  • cover finalized and live **, ***, ~~, inline-code, and IME boundary cases with English synthetic tests

Why

This is a follow-up to #419 and #510. Real macOS WebKit and Windows WebView2 can restore a DOM selection after ProseMirror has assigned mark affinity, causing boundary input to intermittently move outside the wrapper, change sides after the first character, or start native IME composition on the wrong side. Handling intermediate composition text directly can also duplicate phonetic input and lose the caret.

Validation

  • pnpm --filter @markra/app test — 116 files and 1807 tests passed
  • pnpm --filter @markra/editor build — passed
  • pnpm --filter @markra/app build — passed
  • pnpm --filter @markra/desktop build — passed, including vendor chunk verification
  • git diff --check — passed

Risk

  • Only composition that starts with a captured formatted-boundary intent receives the corrected selection and marks; intermediate IME text remains native.
  • Non-cancelable input and RTL/bidi arrow navigation intentionally fall back to native ProseMirror/WebView behavior.
  • Manual macOS and Windows WebView QA is still required because jsdom cannot reproduce native candidate UI, DOM mutation timing, caret restoration, or every selection event ordering.

Refs #419

murongg added 2 commits July 10, 2026 15:47
Resolve WebView target ambiguity for live and finalized Markdown marks, and preserve mark affinity across keyboard navigation.

Closes #419
Track explicit inside and outside affinity through WebView selection overwrites and consecutive input at finalized and live Markdown edges.

Refs #419
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markra-web Ready Ready Preview, Comment Jul 11, 2026 12:09pm

Keep intermediate IME text under ProseMirror and WebView composition control, then apply only the final committed text at the formatted boundary.
Restore the captured inline boundary selection and stored marks before ProseMirror starts native IME composition. This keeps committed Chinese text on the intended side while leaving intermediate composition text under WebView control.
@murongg

murongg commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this follow-up because native macOS and Windows WebView testing still reproduces the boundary and Chinese IME failures. The merged #510 changes are being reverted in #518.

@murongg murongg closed this Jul 11, 2026
@murongg murongg reopened this Jul 11, 2026
@murongg

murongg commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Reopened per clarification: keep this PR available for continued investigation. Only the previously merged #510 changes were reverted from main by #518; this PR and its branch remain intact.

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