-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.0] Fix Codemirror as a custom elements #20684
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
Conversation
| 'Esc': that.closeFullScreen, | ||
| }; | ||
|
|
||
| editor.addKeyMap(map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 14 spaces but found 7 tabs indent
Unexpected tab character no-tabs
| "Ctrl-Q": that.toggleFullScreen, | ||
| [that.getAttribute('fs-combo')]: that.toggleFullScreen, | ||
| 'Esc': that.closeFullScreen, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 14 spaces but found 7 tabs indent
Unexpected tab character no-tabs
| const map = { | ||
| "Ctrl-Q": that.toggleFullScreen, | ||
| [that.getAttribute('fs-combo')]: that.toggleFullScreen, | ||
| 'Esc': that.closeFullScreen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 16 spaces but found 8 tabs indent
Unexpected tab character no-tabs
Unnecessarily quoted property 'Esc' found quote-props
|
|
||
| const map = { | ||
| "Ctrl-Q": that.toggleFullScreen, | ||
| [that.getAttribute('fs-combo')]: that.toggleFullScreen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 16 spaces but found 8 tabs indent
Unexpected tab character no-tabs
| } | ||
|
|
||
| const map = { | ||
| "Ctrl-Q": that.toggleFullScreen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 16 spaces but found 8 tabs indent
Unexpected tab character no-tabs
Strings must use singlequote quotes
| case 'options': | ||
| if (oldValue && newValue !== oldValue) { | ||
| this.refresh(this.element); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 8 spaces but found 3 tabs indent
Unexpected tab character no-tabs
| switch (attr) { | ||
| case 'options': | ||
| if (oldValue && newValue !== oldValue) { | ||
| this.refresh(this.element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 10 spaces but found 4 tabs indent
Unexpected tab character no-tabs
| attributeChangedCallback(attr, oldValue, newValue) { | ||
| switch (attr) { | ||
| case 'options': | ||
| if (oldValue && newValue !== oldValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 8 spaces but found 3 tabs indent
Unexpected tab character no-tabs
|
|
||
| attributeChangedCallback(attr, oldValue, newValue) { | ||
| switch (attr) { | ||
| case 'options': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 6 spaces but found 3 tabs indent
Unexpected tab character no-tabs
| set options(value) { this.setAttribute('options', value); } | ||
|
|
||
| attributeChangedCallback(attr, oldValue, newValue) { | ||
| switch (attr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 4 spaces but found 2 tabs indent
Unexpected tab character no-tabs
Expected a default case default-case
brianteeman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
language string approved
| this.instance.setOption('fullScreen', false); | ||
| } | ||
|
|
||
| makeMarker() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 'this' to be used by class method 'makeMarker' class-methods-use-this
| } | ||
| } else { | ||
| while (typeof window[string1] !== 'function') { | ||
| await this.rafAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected await inside a loop no-await-in-loop
| async checkElement(string1, string2) { | ||
| if (string2) { | ||
| while (typeof window[string1][string2] !== 'function') { | ||
| await this.rafAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected await inside a loop no-await-in-loop
| } | ||
|
|
||
| rafAsync() { | ||
| return new Promise(resolve => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected parentheses around arrow function argument having a body with curly braces arrow-parens
| this.instance = window.CodeMirror.fromTextArea(element, this.options); | ||
| } | ||
|
|
||
| rafAsync() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 'this' to be used by class method 'rafAsync' class-methods-use-this
| } | ||
| } else { | ||
| while (typeof window[string1] !== 'function') { | ||
| await this.rafAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected await inside a loop no-await-in-loop
| async checkElement(string1, string2) { | ||
| if (string2) { | ||
| while (typeof window[string1][string2] !== 'function') { | ||
| await this.rafAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected await inside a loop no-await-in-loop
| this.instance = window.CodeMirror.fromTextArea(element, this.options); | ||
| } | ||
|
|
||
| rafAsync() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 'this' to be used by class method 'rafAsync' class-methods-use-this
|
@dgrammatiko Please take a look in the code I have done some changes. |
|
And, also on eslint codestyle issue . Thanks |
|
I have tested this item ✅ successfully on c8da110 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20684. |
|
I saw no error in console and the language string is changed like explained. I would only suggest to change the language string into something like this: If more than one editor is in write mode (no read only) on the page, the F10 key opens the editor where the cursor is currently located. |
|
Can you also have a look on the remaining three hound issues? |
|
@laoneo Done! |
|
@okonomiyaki3000 can you please test this pr as you are the code mirror expert? Thanks. |
|
@brianteeman Can you please check language string? Thanks |
|
I already have :) |
|
A few problems still:
|
|
Ah, and it's a little out of date. The appearance options tab should show a preview of what the editor will look like with the current settings. |
|
Oh and why not just remove that silly fullscreen message? I added it in the first place because I was changing the fullscreen hotkey from ctrl-q (seriously, who thought that was a good idea?) to something configurable but I figured that after a while we could remove it. People must have adjusted to the change by now, right? |
|
You may like to see #20746 for a way to fix my third point above. |
|
@Anu1601CS can you have a look on the two first issues from @okonomiyaki3000. Thanks. |
|
@laoneo I will take a look on it. |
@okonomiyaki3000 Can you please share the testing instruction? And, what you want to do in fullscreen message ? |
|
The theme selector is in the plugin settings in the appearance tab. It's just a list of themes. If you run the editor with ever having saved any options, it works. When you open the plugin settings and then save, all pages with codemirror on them will have errors. To see the syntax highlighting issue, just open any php file with code mirror. For the fullscreen message, I just think we don't need it at all. It doesn't make much sense. If we need to put instructions for using CodeMirror there, we should have a lot more than just that one item but why should we? We don't list instructions for other things. |
|
@okonomiyaki3000 As you suggested #20746 to fix mode, it works fine and syntax highlight is also good. But, one problem is still present, if two codemirror editor is present in a same page, then we are only able to toggle last codemirror to fullscreen ( only one codemirror makes toggle) . |
|
@okonomiyaki3000 Seems like i found solution of fullscreen. |
|
I'm not really the one to ask. I never liked the message at all. I'm sure someone must have asked me to put it there but it was so long ago... So, personally, I'd love to see it gone. If nobody else objects... |
|
I have tested this item ✅ successfully on f663276 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20684. |
|
I saw no error in console. I saw no full screen message. I like it, that there is no full screen message. I think it is confusing if there is more than one editor on a page. If people see the text "click F10 to open full-screen" more than one time, they will be wondering which editor will be opened. If more than one editor is in write mode (no read only) on the page, the F10 key opens still the editor where the cursor is currently located. I think this is OK, because so people who know this feature from the past, can still use it. |
|
I have tested this item ✅ successfully on f663276 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20684. |
|
Thanks @dgrammatiko |
|
Ready to Commit after two successful tests. |
|
Nice one, thanks all involved. |
Pull Request for Issue #20679
Summary of Changes
As @okonomiyaki3000 Suggested to remove the fullscreen message. I removed it.
Testing Instructions
Set default editor to codemirror in global configuration.
Open com_content and start creating an article. See, that there are no errors in web console.
Open the file
administrator/components/com_content/forms/article.xmland the textafter the field with the name articletext
4 . Open file
/administrator/components/com_content/tmpl/article/edit.phpand add the text
<?php echo $this->form->getInput('articletext2'); ?>after the text
<?php echo $this->form->getInput('articletext'); ?>Expected result
No error in console.
Fix codemirror as a customelements .
Credit goes to @dgrammatiko #20679 (comment)
Actual result
/media/vendor/codemirror/mode/text/html/text/html.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)