Skip to content

Commit

Permalink
[4.2] codemirror full screen (#38863)
Browse files Browse the repository at this point in the history
* [4.2] codemirror full screen

In com_templates if you display the original file as well as the override then you have two instances of codemirror with the original file as readonly. Both have the message "Press xx to toggle Full Screen editing"  which not only doesnt make sense on a readonly instance of the editor and not surprisingly doesnt work.

This PR removes the message and associated options from the codemirror layout if the editor is defined as readonly in the xml

* caps
  • Loading branch information
brianteeman committed Oct 7, 2022
1 parent 54a82bc commit faeebba
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions plugins/editors/codemirror/layouts/editors/codemirror/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
$editor = 'editor="' . ltrim(HTMLHelper::_('script', $basePath . 'lib/codemirror' . $extJS, ['version' => 'auto', 'pathOnly' => true]), '/') . '?' . $mediaVersion . '"';
$addons = 'addons="' . ltrim(HTMLHelper::_('script', $basePath . 'lib/addons' . $extJS, ['version' => 'auto', 'pathOnly' => true]), '/') . '?' . $mediaVersion . '"';

// Remove the fullscreen message and option if readonly not null.
if ($options->readOnly !== null) {
$fsCombo = '';
}

Factory::getDocument()->getWebAssetManager()
->registerAndUseStyle('codemirror.lib.main', $basePath . 'lib/codemirror.css')
->registerAndUseStyle('codemirror.lib.addons', $basePath . 'lib/addons.css', [], [], ['codemirror.lib.main'])
Expand All @@ -57,8 +62,10 @@
?>
<joomla-editor-codemirror <?php echo $editor . ' ' . $addons . ' ' . $modPath . ' ' . $fsCombo . ' ' . $option; ?>>
<?php echo '<textarea name="', $name, '" id="', $id, '" cols="', $cols, '" rows="', $rows, '">', $content, '</textarea>'; ?>
<p class="small float-end">
<?php echo Text::sprintf('PLG_CODEMIRROR_TOGGLE_FULL_SCREEN', $fullScreenCombo); ?>
</p>
<?php if ($fsCombo !== '') { ?>
<p class="small float-end">
<?php echo Text::sprintf('PLG_CODEMIRROR_TOGGLE_FULL_SCREEN', $fullScreenCombo); ?>
</p>
<?php }; ?>
</joomla-editor-codemirror>
<?php echo $displayData->buttons; ?>

0 comments on commit faeebba

Please sign in to comment.