EditContext
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
TheEditContext interface represents the text edit context of an element that was made editable by using theEditContext API.
TheEditContext API can be used to build rich text editors on the web that support advanced text input experiences, such asInput Method Editor (IME) composition, emoji picker, or any other platform-specific editing-related UI surfaces.
In this article
Constructor
EditContext()ExperimentalReturns a new
EditContextinstance.
Instance properties
EditContext.textRead onlyExperimentalThe editable content of the element.
EditContext.selectionStartRead onlyExperimentalThe offset, within the editable text content, of the start of the current selection.
EditContext.selectionEndRead onlyExperimentalThe offset, within the editable text content, of the end of the current selection.
EditContext.characterBoundsRangeStartRead onlyExperimentalThe offset, within the editable text content, where the last IME composition started.
Instance methods
EditContext is based on theEventTarget interface, and includes its methods.
EditContext.attachedElements()ExperimentalAn
Arraycontaining oneHTMLElementobject which is the element that's associated with theEditContextobject.EditContext.characterBounds()ExperimentalThe list of bounding rectangles for the characters in the
EditContextobject.EditContext.updateText()ExperimentalUpdates the internal text content of the
EditContextobject.EditContext.updateSelection()ExperimentalUpdates the internal state of the selection within the editable text context.
EditContext.updateControlBounds()ExperimentalInforms the operating system about the position and size of the editable text region.
EditContext.updateSelectionBounds()ExperimentalInforms the operating system about the position and size of the selection within the editable text region.
EditContext.updateCharacterBounds()ExperimentalInforms the operating system about the position and size of the characters in the
EditContextobject.
Events
textupdateExperimentalFired when the user has made changes to the text or selection.
textformatupdateExperimentalFired when composition using anInput 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.
characterboundsupdateExperimentalFired when the operating system needs to know the size and position of certain characters within the editable text region of the
EditContextobject, in order to display an IME window.compositionstartExperimentalFired when composition using an IME window is starting.
compositionendExperimentalFired when composition using an IME window is ending.
Specifications
| Specification |
|---|
| EditContext API> # dom-editcontext> |