Skip to content

Commit 18bfd4a

Browse files
authored
Merge pull request #118 from WordPress/tinymce-logger
Add logger to TinyMCE to test, learn and debug.
2 parents 858ae54 + cd0cc4d commit 18bfd4a

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

shared/tinymce/logger.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// For testing, learning and debugging. Feel free to add.
2+
// See https://www.tinymce.com/docs/advanced/events/
3+
window.tinymce.PluginManager.add( 'logger', function( editor ) {
4+
var types = {
5+
selectionChange: 'fires when the selection changes.',
6+
nodeChange: 'fires when the selection and the node changes. Use `event.element`.',
7+
beforePastePreProcess: 'gives raw paste content before processing.',
8+
pastePostProcess: 'gives paste content after processing. Use `event.node.innerHTML`.',
9+
beforeSetContent: 'fires before content is set in the editor. Can be used for manipulation.',
10+
setContent: 'fires after content is set in the editor.',
11+
beforeExecCommand: 'fires before commands are executed.',
12+
execCommand: 'fires after commands are executed.'
13+
};
14+
15+
window.tinymce.each( types, function( info, type ) {
16+
editor.on( type, function( event ) {
17+
console.log( type, info, event );
18+
} );
19+
} );
20+
} );

tinymce/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<p>Many entrepreneurs idolize Steve Jobs. He’s such a <a href="">perfectionist</a>, they say. Nothing leaves the doors of 1 Infinite Loop in Cupertino without a polish and finish that makes geeks everywhere drool. No compromise!</p>
1212
</section>
1313
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.3/tinymce.min.js"></script>
14+
<script src="../shared/tinymce/logger.js"></script>
1415
<script src="tinymce-config.js"></script>
1516
</body>
1617
</html>

tinymce/tinymce-config.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ window.tinymce.init( {
77
keep_styles: false,
88
menubar: false,
99
object_resizing: false,
10+
plugins: [ 'logger', 'paste' ],
1011
schema: 'html5-strict',
1112
selector: 'section',
1213
theme: false,

0 commit comments

Comments
 (0)