This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The EditContext interface represents the text edit context of an element that was made editable by using the EditContext API.
The EditContext API can be used to build rich text editors on the web that support advanced text input experiences, such as Input Method Editor (IME) composition, emoji picker, or any other platform-specific editing-related UI surfaces.
EditContext() Experimental
Returns a new EditContext instance.
EditContext.text Read only Experimental
The editable content of the element.
EditContext.selectionStart Read only Experimental
The offset, within the editable text content, of the start of the current selection.
EditContext.selectionEnd Read only Experimental
The offset, within the editable text content, of the end of the current selection.
EditContext.characterBoundsRangeStart Read only Experimental
The offset, within the editable text content, where the last IME composition started.
EditContext is based on the EventTarget interface, and includes its methods.
EditContext.attachedElements() Experimental
An Array containing one HTMLElement object which is the element that's associated with the EditContext object.
EditContext.characterBounds() Experimental
The list of bounding rectangles for the characters in the EditContext object.
EditContext.updateText() Experimental
Updates the internal text content of the EditContext object.
EditContext.updateSelection() Experimental
Updates the internal state of the selection within the editable text context.
EditContext.updateControlBounds() Experimental
Informs the operating system about the position and size of the editable text region.
EditContext.updateSelectionBounds() Experimental
Informs the operating system about the position and size of the selection within the editable text region.
EditContext.updateCharacterBounds() Experimental
Informs the operating system about the position and size of the characters in the EditContext object.
textupdate Experimental
Fired when the user has made changes to the text or selection.
textformatupdate Experimental
Fired when composition using an Input Method Editor (IME) window is happening and the IME decides that certain parts of the text being composed should be formatted differently to indicate the composition state.
characterboundsupdate Experimental
Fired when the operating system needs to know the size and position of certain characters within the editable text region of the EditContext object, in order to display an IME window.
compositionstart Experimental
Fired when composition using an IME window is starting.
compositionend Experimental
Fired when composition using an IME window is ending.
| Specification |
|---|
| EditContext API> # dom-editcontext> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
EditContext |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
EditContext |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
attachedElements |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
characterBounds |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
characterBoundsRangeStart |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
characterboundsupdate_event |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
compositionend_event |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
compositionstart_event |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
selectionEnd |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
selectionStart |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
text |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
textformatupdate_event |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
textupdate_event |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
updateCharacterBounds |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
updateControlBounds |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
updateSelection |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
updateSelectionBounds |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
updateText |
121 | 121 | No | 107 | No | 121 | No | 81 | No | 25.0 | 121 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/EditContext