Skip to content

Commit b509ec0

Browse files
authored
DOC-3390: Add editor.on('change') example to events page (#4054)
Add content change callback example using setup option and editor.on('change') to address Context7 benchmark Q4 (30/100).
1 parent 5c316e0 commit b509ec0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

modules/ROOT/pages/events.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ tinymce.init({
9797
});
9898
----
9999

100+
=== Example: content change callback
101+
102+
To run a callback when the editor content changes, use the `+Change+` event with `+editor.on()+` inside the `+setup+` option:
103+
104+
[source,js]
105+
----
106+
tinymce.init({
107+
selector: 'textarea',
108+
setup: (editor) => {
109+
editor.on('change', () => {
110+
console.log('Content was modified.');
111+
});
112+
}
113+
});
114+
----
115+
116+
The `+Change+` event fires when content changes are committed, such as when moving focus away from the editor. For real-time updates as the user types, use the `+input+` event instead.
117+
100118
[[browser-native-events]]
101119
== Supported browser-native events
102120

0 commit comments

Comments
 (0)