microsoft / microsoft/playwright

[Feature] IME support

Open
#5,777 25 comments 39 reactions 1 assignee View on GitHub

@dgozman is already working on this.

Since Mar 18, 2022.

P3-collecting-feedback
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

Right now our IME support is limited. We insert text, but do not allow for testing complicated scenarios with composition events.

The Web api: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
The Mac api: https://developer.apple.com/documentation/appkit/nstextinputclient?language=objc
The Chromium mojo api: https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/public/mojom/input/input_handler.mojom

This request comes from @trueadm on twitter: https://twitter.com/trueadm/status/1369332999242792967

My initial api proposal:

await page.keyboard.startComposition(start, end); // optional start and end
await page.keyboard.updateComposition('foo');
await page.keyboard.updateComposition('bar');
await page.keyboard.press('A'); // what should this do? Send keyboard events without generating text?
await page.keyboard.endComposition('baz'); // optional ending text

The only time I've seen composition events used in the wild is in CodeMirror to draw a synthetic composition highlight. It would be helpful to have some better use cases here to make sure that the api handles them without growing too large.

  • Does the composition state need to be inspected, or just controlled? That is, do we need keyboard.compositionRange()?
  • Do we instead need a high level composition api. Like keyboard.typeWithComposition("è") types AltGr+` followed by e?
  • Do we need be able to trigger composition via keys. Right now our keyboard api largely ignores dead keys that would start composition.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.