TextUpdateEvent: text property
Limited availability
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.
Thuộc tính chỉ đọc TextUpdateEvent.text chứa văn bản đã được chèn vào trong phạm vi đã cập nhật của sự kiện textupdate của EditContext.
Giá trị
Một String chứa văn bản thay thế văn bản nằm giữa các chỉ số updateRangeStart và updateRangeEnd.
Ví dụ
>Sử dụng textupdate để hiển thị văn bản đã chèn và vị trí
html
<div id="editor"></div>
js
const editorEl = document.getElementById("editor");
const editContext = new EditContext();
editorEl.editContext = editContext;
editContext.addEventListener("textupdate", (e) => {
console.log(
`The user inserted the text "${e.text}" at index ${e.updateRangeStart}.`,
);
});
Thông số kỹ thuật
| Specification |
|---|
| EditContext API> # dom-textupdateevent-text> |