大网数据广告活动
Web 标准与前端开发

EditContext

· 52CE 我爱测

The **`EditContext`** interface represents the text edit context of an element that was made editable by using the EditContext API.

EditContext API

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.

Constructor

  • EditContext.EditContext
    • : Returns a new EditContext instance.

Instance properties

  • EditContext.text
    • : The editable content of the element.
  • EditContext.selectionStart
    • : The offset, within the editable text content, of the start of the current selection.
  • EditContext.selectionEnd
    • : The offset, within the editable text content, of the end of the current selection.
  • EditContext.characterBoundsRangeStart
    • : The offset, within the editable text content, where the last IME composition started.

Instance methods

EditContext is based on the EventTarget interface, and includes its methods.

  • EditContext.attachedElements()
    • : An Array containing one HTMLElement object which is the element that's associated with the EditContext object.
  • EditContext.characterBounds()
    • : The list of bounding rectangles for the characters in the EditContext object.
  • EditContext.updateText()
    • : Updates the internal text content of the EditContext object.
  • EditContext.updateSelection()
    • : Updates the internal state of the selection within the editable text context.
  • EditContext.updateControlBounds()
    • : Informs the operating system about the position and size of the editable text region.
  • EditContext.updateSelectionBounds()
    • : Informs the operating system about the position and size of the selection within the editable text region.
  • EditContext.updateCharacterBounds()
    • : Informs the operating system about the position and size of the characters in the EditContext object.

Events

  • EditContext.textupdate_event
    • : Fired when the user has made changes to the text or selection.
  • EditContext.textformatupdate_event
    • : 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.
  • EditContext.characterboundsupdate_event
    • : 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.
  • EditContext.compositionstart_event
    • : Fired when composition using an IME window is starting.
  • EditContext.compositionend_event
    • : Fired when composition using an IME window is ending.

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。