Skip to content

Commit

Permalink
update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumppex committed Oct 25, 2024
2 parents d3dd8f5 + a548e0d commit 2a63edc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

### 3.1.1rc: 2024-10-25

* Add tinyMCE plugin that adds helper class to elements (T-17631)

### 3.1.0: 2024-10-10

* Add "Flush all caches" to admin bar (T-19416)
Expand Down
18 changes: 18 additions & 0 deletions assets/js/plugin-tinymce-add-class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable no-undef, no-unused-vars */
(function addClassToWysiwygElements() {
tinymce.create('tinymce.plugins.addClass', {
init(editor, url) {
editor.on('NodeChange', () => {
const elements = editor.dom.select('ul, ol, blockquote');

elements.forEach((element) => {
if (!editor.dom.hasClass(element, 'wysiwyg')) {
editor.dom.addClass(element, 'wysiwyg');
}
});
});
},
});

tinymce.PluginManager.add('addClass', tinymce.plugins.addClass);
}());
14 changes: 14 additions & 0 deletions inc/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@ function air_helper_tinymce_remove_formats( $init ) {
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;';
return $init;
} // end air_helper_tinymce_remove_formats

/**
* Add helper class to specific elements in TinyMCE
*/
function add_tinymce_plugin( $plugin_array ) {
$plugin_array['addClass'] = air_helper_base_url() . '/assets/js/plugin-tinymce-add-class.js';
return $plugin_array;
}

function tinymce_plugin() {
add_filter( 'mce_external_plugins', 'add_tinymce_plugin' );
}

add_action( 'admin_head', 'tinymce_plugin' );

0 comments on commit 2a63edc

Please sign in to comment.