-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.1] Tiny source code syntax highlighting #35647
Conversation
build/media_source/plg_editors_tinymce/js/plugins/highlighter/plugin.es5.js
Show resolved
Hide resolved
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.es5.js
Show resolved
Hide resolved
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.es5.js
Show resolved
Hide resolved
This is getting complicated due to the fact that the output is an HTML page and we don't want the sources in the media folder. I would just concatenate the source script and CSS in the HTML directly (non minified, it's not that much code anyway) and delete the js and css sources. |
hint? |
Delete the extra files |
oh - didnt realise thats what you meant |
Txs @dgrammatiko for your plugin and txs @brianteeman for implementing this PR! If I may, I have two suggestions: 1. making the popup (almost) fullscreen?At present the size of the popup is (only) 800x550, which is quite small especially to work comfortably with html code.
But it would probably be nicer to have it natively. Alternatively, if it is possible to implement the "fullscreen shortcut" (F10) (which works when selecting CodeMirror editor itself, even if there is a positioning issue bc the first lines are hidden behind the Save buttons bar), that could also solve the issue of the popup being "too small". 2. using the options of CodeMirror Plugin?The popup with Syntax Highliting uses CodeMirror, but does not seem to use the Options set in the CodeMirror Plugin (it uses the default I guess). |
I am looking at both those points |
This has weird implications as it will make ALL the tinyMCE dialogs almost fullscreen. There's another way for this
Since I didn't wanted to create a Joomla plugin I left this with some defaults but it is possible to have the options exposed in the tinyMCE's configuration. Basically all it's needed is:
// CodeMirror settings
const CMsettings = {
path: '../../../../vendor/codemirror',
indentOnInit: true,
// start remove
config: {
mode: 'htmlmixed',
theme: 'default',
lineNumbers: true,
lineWrapping: true,
indentUnit: 2,
tabSize: 2,
indentWithTabs: true,
matchBrackets: true,
saveCursorPosition: true,
styleActiveLine: true,
},
// end remove
jsFiles: [// Default JS files
'lib/codemirror.min.js',
'addon/edit/matchbrackets.min.js',
'mode/xml/xml.min.js',
'mode/javascript/javascript.min.js',
'mode/css/css.min.js',
'mode/htmlmixed/htmlmixed.min.js',
'addon/dialog/dialog.min.js',
'addon/search/searchcursor.min.js',
'addon/search/search.min.js',
'addon/selection/active-line.min.js',
],
cssFiles: [// Default CSS files
'lib/codemirror.css',
'addon/dialog/dialog.css',
],
};
$scriptOptions['codemirror'] = [
'settings' => [
'indentOnInit' => true, // the true should be $levelParams->get('codemirroe_settings_indentoninit'); which is a toogle in the settings form
]
] |
yeah I know ;) |
About the maximised modal, this should do it: const rects = document.body.getBoundingClientRect();
const config = {
title: 'HTML source code',
url: url + '/source.html',
width: rects.width - 5,
height: rects.height - 150,
resizable: true,
maximizable: true,
fullScreen: true,
saveCursorPosition: false,
buttons: buttonsConfig
} |
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.es5.js
Outdated
Show resolved
Hide resolved
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.es5.js
Outdated
Show resolved
Hide resolved
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.es5.js
Outdated
Show resolved
Hide resolved
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.es5.js
Outdated
Show resolved
Hide resolved
Should this really be 4.0 or is 4.1 the target? If later, would be happy to include it. |
Well, it is not up to me to say but I hope we won't have to wait until 4.1 for Syntax Highlighting :) |
@Fedik please could you review and check the changes you requested |
conflicts resolved |
Tested on a fresh installation of 4.1. dev on a new database. Applied Patch, run npm ci.. @brianteeman could you please remove the testing instruction here: The result: Did I miss something? |
@brianteeman check brianteeman#131 |
* Revert the change for scripts/styles Whenever we append a script tag using JS the script is loading ASYNC and most probably will break the order of execution * Give the dog a bone
Txs to all for this PR |
I have tested this item ✅ successfully on e283301 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35647. |
Can we test now or is it better waiting changes in the window? |
I have tested this item ✅ successfully on e283301 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35647. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35647. |
THX This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35647. |
Very cool feature, thank you! |
thanks |
For TinyMCE, such features would also be relevant (in the form of plugins, maybe)... For example, along with Quantum (as a media manager), I have to use JCE for projects (a shell for TinyMCE as a component of a visual editor for jumla) only because of a few things: 1) working with the source code, i.e. with the code is convenient — there is a cool search with autocorrect; 2) auto-insertion is clearly worked out directly into the text of the video article, when just a short YouTube url is immediately transformed into a video insertion code with a frame, plus inserts from social networks (Twitter, Facebook, etc.) work similarly.; 3) in the visual editor mode, the text format is displayed there — a paragraph or divas, for example, which is very convenient. |
Not really sure I understand what you are asking for here but afaict everything is already present in joomla 4 and tinymce |
joomla/joomla-cms#30522 + joomla/joomla-cms#32223 + joomla/joomla-cms#31675 + joomla/joomla-cms#35378 + joomla/joomla-cms#35612 + joomla/joomla-cms#35715 + joomla/joomla-cms#35610 + joomla/joomla-cms#35607 + joomla/joomla-cms#35788 + joomla/joomla-cms#35647 + joomla/joomla-cms#35143 + joomla/joomla-cms#36135 + joomla/joomla-cms#35998 + joomla/joomla-cms#36173 + joomla/joomla-cms#36212 + joomla/joomla-cms#36208 + joomla/joomla-cms#36206 + joomla/joomla-cms#36205 + joomla/joomla-cms#36203 + joomla/joomla-cms#36192 + joomla/joomla-cms#36191 + joomla/joomla-cms#36228 + joomla/joomla-cms#36211 + joomla/joomla-cms#36271 + joomla/joomla-cms#36270 + joomla/joomla-cms#36245 + joomla/joomla-cms#36294 + joomla/joomla-cms#36244 + joomla/joomla-cms#36242 + joomla/joomla-cms#36296 + joomla/joomla-cms#36190 + joomla/joomla-cms#36474 + joomla/joomla-cms#36297 + joomla/joomla-cms#36480 + joomla/joomla-cms#36479 + joomla/joomla-cms#36551 + joomla/joomla-cms#36366 + joomla/joomla-cms#36589 + joomla/joomla-cms#36583 + joomla/joomla-cms#36328 + joomla/joomla-cms#36515 + joomla/joomla-cms#36555 + joomla/joomla-cms#36653 + joomla/joomla-cms#36660 + joomla/joomla-cms#36657 + joomla/joomla-cms#36637 + joomla/joomla-cms#35983 + joomla/joomla-cms#36704 + joomla/joomla-cms#36708 + joomla/joomla-cms#36700 +
This PR
changes the source code view of tinymce from raw text to a rich syntax highlighted area using codemirror.
It is enabled by default but there is an option in the plugin to disable it - can't imagine why someone would want though.
There are no additional tinymce strings to translate as I have reused existing strings.
As the code plugin is enabled by default in set 0 for super users you can activate the view either from the tools menu or the
<>
icon. If it is not enabled in your configuration then you will need to drag and drop the icon to your toolbar in the tinymce pluginBefore
After
As you can see you now also have search and replace etc.
Testing
Apply the pr and run npm ci
AND copy the file
build/media_source/plg_editors_tinymce/js/plugins/highlighter/source.html
to `media/plg_editors_tinymce/js/plugins/highlighter/source.htmlWhy this is a draft
I need help building the source.html file with our build scripts. I am guessing it will be built similar to the error pages
Thanks to @woluweb and @dgrammatiko