Events
text-change
Emitted when the contents of Quill have changed. Details of the change, representation of the editor contents before the change, along with the source of the change are provided. The source will be "user" if it originates from the users. For example:
- User types into the editor
- User formats text using the toolbar
- User uses a hotkey to undo
- User uses OS spelling correction
Changes may occur through an API but as long as they originate from the user, the provided source should still be "user". For example, when a user clicks on the toolbar, technically the toolbar module calls a Quill API to effect the change. But source is still "user" since the origin of the change was the user’s click.
APIs causing text to change may also be called with a "silent" source, in which case text-change will not be emitted. This is not recommended as it will likely break the undo stack and other functions that rely on a full record of text changes.
Changes to text may cause changes to the selection (ex. typing advances the cursor), however during the text-change handler, the selection is not yet updated, and native browser behavior may place it in an inconsistent state. Use selection-change or editor-change for reliable selection updates.
Callback Signature
handler(delta: Delta, oldContents: Delta, source: String)
Examples
quill.on('text-change', function(delta, oldDelta, source) {
if (source == 'api') {
console.log("An API call triggered this change.");
} else if (source == 'user') {
console.log("A user action triggered this change.");
}
});
'React 실습 > 관련 개념 정리' 카테고리의 다른 글
[React] 자식이 부모에게 - 콜백 이용 - (2) (0) | 2023.07.17 |
---|---|
[React] 자식이 부모에게 - 콜백 이용 (0) | 2022.11.22 |
리덕스 개념정리 - redux-actions (0) | 2022.11.22 |
리덕스사가 - takeLatest, takeEvery, all (0) | 2022.11.22 |
리덕스사가 - Generator, redux-saga, combineReducers (0) | 2022.11.22 |