Skip to content

Commit

Permalink
Fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrammatiko committed May 31, 2020
1 parent 15674ee commit b1f9734
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
26 changes: 25 additions & 1 deletion build/media_source/plg_editors_tinymce/js/tinymce.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@

editors.forEach((editor) => {
const currentEditor = editor.querySelector('textarea');

// Setup the editor
Joomla.JoomlaTinyMCE.setupEditor(currentEditor, pluginOptions);

// Setup the toggle button
const toggleEditor = function toggleEditor() {
if (Joomla.editors.instances[currentEditor.id].instance.isHidden()) {
Joomla.editors.instances[currentEditor.id].instance.show();
} else {
Joomla.editors.instances[currentEditor.id].instance.hide();
}
};

const toggleButton = editor.querySelector('.js-tiny-toggler-button');

if (toggleButton) {
toggleButton.addEventListener('click', toggleEditor);
}
});
},

Expand Down Expand Up @@ -118,6 +135,9 @@
};
}

// We'll take over the onSubmit event
options.add_form_submit_trigger = false;

// Create a new instance
// eslint-disable-next-line no-undef
const ed = new tinyMCE.Editor(element.id, options, tinymce.EditorManager);
Expand All @@ -135,7 +155,11 @@
// Some extra instance dependent
id: element.id,
instance: ed,
onSave: () => { if (Joomla.editors.instances[element.id].instance.isHidden()) { Joomla.editors.instances[element.id].instance.show(); } return ''; },
onSave: () => {
if (Joomla.editors.instances[element.id].instance.isHidden()) {
Joomla.editors.instances[element.id].instance.show();
}
},
};

/** On save * */
Expand Down
7 changes: 1 addition & 6 deletions layouts/joomla/tinymce/togglebutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@
defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

$name = $displayData;

?>
<div class="toggle-editor btn-toolbar float-right clearfix mt-3">
<div class="btn-group">
<button type="button" class="btn btn-secondary" href="#"
onclick="tinyMCE.execCommand('mceToggleEditor', false, '<?php echo $name; ?>');return false;"
>
<button type="button" class="btn btn-secondary js-tiny-toggler-button">
<span class="fas fa-eye" aria-hidden="true"></span>
<?php echo Text::_('PLG_TINY_BUTTON_TOGGLE_EDITOR'); ?>
</button>
Expand Down

0 comments on commit b1f9734

Please sign in to comment.