No Code Attached Yet
avatar OctavianC
OctavianC
4 May 2021

Steps to reproduce the issue

Run the following code:

$editor = 'codemirror';
$instance = new \Joomla\CMS\Editor\Editor($editor);

$params = array('syntax' => 'php');
echo $instance->display('test1', htmlspecialchars('<?php echo "test";'), '100%', 300, 75, 20, false, null, null, null, $params);

$params = array('syntax' => 'html');
echo $instance->display('test2', htmlspecialchars('<h1>test</h1>'), '100%', 300, 75, 20, false, null, null, null, $params);

Expected result

Two editors (one configured for PHP syntax highlighting, the other one for HTML) and no errors in the browser console.

Actual result

Editors work correctly, however there's a 404 request in the console:
GET http://localhost/j40/media/vendor/codemirror/mode/text/html/text/html.js

System information (as much as possible)

Latest nightly 4.0.0-beta8-dev

Additional comments

This is happening due to the second CodeMirror instance. I've traced this to this line:
https://github.com/joomla/joomla-cms/blob/4.0-dev/build/media_source/plg_editors_codemirror/js/joomla-editor-codemirror.w-c.es6.js#L60

It's requesting mode.mime which is text/html and thus it looks for /mode/text/html/text/html.js. For example, for PHP it's /mode/php/php.js
However, the correct variable in my opinion would be mode.mode, which is htmlmixed and thus it will look for /mode/htmlmixed/htmlmixed.js, which exists.
Don't know why it's mode.mime in there instead of mode.mode and why there's a separate handling for the php mode.

Perhaps somebody can share some light into why this is.

avatar OctavianC OctavianC - open - 4 May 2021
avatar joomla-cms-bot joomla-cms-bot - change - 4 May 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 4 May 2021
avatar Fedik
Fedik - comment - 4 May 2021

it something from #32315

avatar PhilETaylor
PhilETaylor - comment - 5 May 2021

Was reported by me last year #29767 and @dgrammatiko fixed it in #32315 ... or not :)

avatar brianteeman
brianteeman - comment - 15 May 2021

also see #33229

avatar micker
micker - comment - 10 Nov 2021

hello no news about this ?

avatar richard67 richard67 - change - 23 Nov 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-11-23 19:50:19
Closed_By richard67
Labels Added: No Code Attached Yet
Removed: ?
avatar richard67 richard67 - close - 23 Nov 2022
avatar richard67
richard67 - comment - 23 Nov 2022

Closing as having a pull request. See #39295 .

Add a Comment

Login with GitHub to post a comment