Skip to content

Code Mirror plugin improvements#5863

Merged
wilsonge merged 6 commits intojoomla:stagingfrom
okonomiyaki3000:CodeMirrorPlusPlus
Nov 7, 2015
Merged

Code Mirror plugin improvements#5863
wilsonge merged 6 commits intojoomla:stagingfrom
okonomiyaki3000:CodeMirrorPlusPlus

Conversation

@okonomiyaki3000
Copy link
Copy Markdown
Contributor

This PR makes quite a few changes to the CodeMirror plugin (not the javascript library itself).

  • The plugin file is cleaned up a lot by making use of layouts
  • Layouts are used, not just for HTML but for generating js and css code (there are a lot of nice things about this)
  • There is (has always been) an init function which is run once per page for some global CodeMirror setup and and instantiation function which is called once per instance of CM (usually there is only one per page but anyway...). The instantiation function has been simplified down to practically nothing and most its work is now done in the init function.
  • There's a new (optional) toolbar that gives gui access to a few of CodeMirror's features such as full screen mode and auto indent. It's pretty basic at the moment but maybe more capabilities can be added later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you're wondering what this is all about, it lets your text editor know that the following code is javascript (instead of html) but output buffering captures the tag and throws it away because we don't actually want it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you'd add similar comment above this code, so others inspecting the code will know what is it for.

But I must say I'm not comfortable with it, any editor allows mode switching, and while it's not comfortable to switch between js an php, IMHO this executed code just should not be there.

@dgrammatiko
Copy link
Copy Markdown
Contributor

I get two notices:
Notice: Undefined variable: cols in /plugins/editors/codemirror/codemirror.php on line 259
Notice: Undefined variable: rows in /plugins/editors/codemirror/codemirror.php on line 260

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

Thanks!

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

The build fails because of PHPCS problems in a layout file. The Joomla! phpcs rules are not suitable for writing layout or template files.

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

... or you know maybe I could just cut that extra line at the end of the file.

@brianteeman
Copy link
Copy Markdown
Contributor

Not a huge fan of the wording used in the new language strings but they
follow the style guide for punctuation and capitalisation etc so are ok for
now. Maybe they can be improved in the future.

@bluezeyes-zz
Copy link
Copy Markdown

Maybe is it possible, that the use of CodeWarrior in the Template Manager are based on Global / User editor settings? As at moment (J! 3.3.6) it is not the case ..

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@brianteeman I'm happy to change those strings if anyone has a suggestion.

@bluezeyes CodeWarrior... なつかしい... Uh, I'll need to look into the template manager issue. It should be based on global settings. What else would it be based on?

@brianteeman
Copy link
Copy Markdown
Contributor

@okonomiyaki3000 they are OK for now. They can be reviewed at a later date when we do a general review of all strings.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@bluezeyes-zz
Copy link
Copy Markdown

@okonomiyaki3000 Well, it just tried out this CM+Emmet extension: http://extensions.joomla.org/extension/edition/editors/codemirror-plus-emmet-editor
I could select it in the settings, but it wont work in the template manager.. only in custom Html Module
And i think, its hard coded there .. that was the answer of the developer of this extension..

@infograf768
Copy link
Copy Markdown
Member

they are OK for now. They can be reviewed at a later date when we do a general review of all strings.

Please make new string perfect now. You complained that many strings are not OK in en-GB, thus creating a lot of language PRs. Changing these new strings later on will —again— force TTs to do a useless work.
A little respect for the work of others is strongly desired...

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@bluezeyes I think I get it. When you install this extension, do you get the option for a new editor? So that, in your user settings, you can select either 'CodeMirror' or 'CodeMirror + Emmet'?

@infograf768 I agree.

@brianteeman
Copy link
Copy Markdown
Contributor

The language strings are OK - they follow the style guides. They are just
written in a slightly different voice to many of the other strings.

As agreed with the PLT a complete review of all the strings for this sort
of stuff should be done after the release of 3.4 as they will effect
translations.

But if you are desperate for them I can rewrite these tonight but I can not
guarantee that when all the strings are reviewed they might not be changed
again.

On 22 January 2015 at 09:15, Elijah Madden notifications@github.com wrote:

@bluezeyes https://github.com/bluezeyes I think I get it. When you
install this extension, do you get the option for a new editor? So that, in
your user settings, you can select either 'CodeMirror' or 'CodeMirror +
Emmet'?

@infograf768 https://github.com/infograf768 I agree.


Reply to this email directly or view it on GitHub
#5863 (comment).

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

@bluezeyes-zz
Copy link
Copy Markdown

@okonomiyaki3000 Correct.

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@bluezeyes Then the reason is that the jform xml file for the template pages does not simply use your configured editor, it uses 'codemirror' explicitly. It must do this because, otherwise, a wysiwyg might be used. This is a weak point of the 'editor' field type. It would be best if users could select their content editor and code editor independent of one another but that is not a possibility right now.

Alternatively, we could just start including Emmet. It would be absolutely trivial to add this functionality. The only possible issue that Emmet is separate distribution from CodeMirror and created by a different developer. Is there any issue with adding it to Joomla? Licensing or anything like that?

@brianteeman
Copy link
Copy Markdown
Contributor

Do you mean https://github.com/emmetio/emmet/blob/master/LICENSE

If so then there is no problem with the licence - I will leave it to others
to comment about including it

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@brianteeman Yes, that's the one. No problem to add this if it's something people want.

@bluezeyes-zz
Copy link
Copy Markdown

@okonomiyaki3000 Well I tried it with vanilla Joomla 3.3.6 Template Isis No changes except installing CM+E . #Edith:# Arrgh ... I should get rest.. overseen your jForm notice
But if the integration of Emmet is possible that would be great. :)

@brianteeman Yes that is the original one.

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@bluezeyes Yeah, as it currently works, since CM+E is a different editor from just 'CodeMirror' (as far as Joomla is concerned) and the form on the template editor is explicitly selecting 'CodeMirror' (despite any system or user-level settings), CM+E will never be used there. So, I'll look into adding support for it in the basic installation. I'll put it in a different PR though, in case it's controversial. If it gets in, CM+E will basically be obsolete.

@brianteeman
Copy link
Copy Markdown
Contributor

@okonomiyaki3000 Elijah you have three PR

  1. to change color to colour
  2. to change On/Off to Show/Hide
  3. to change the tooltips to match Show/Hide

Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this a little. Maybe it's a big more palatable now.

@brianteeman
Copy link
Copy Markdown
Contributor

Thanks for accepting those fixes.

All tested good from me


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@bluezeyes here you go #5874

@anibalsanchez
Copy link
Copy Markdown
Contributor

@test ok


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@dgrammatiko
Copy link
Copy Markdown
Contributor

@test OK

@joomla-cms-bot
Copy link
Copy Markdown

This PR has received new commits.

CC: @acjunior01, @anibalsanchez, @brianteeman, @DGT41, @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

I rebased this because it had become a mess somehow without a whole set of commits being doubled. There's still a commit that adds the toolbar and then a subsequent one that removes it. Finally, there is no toolbar but, instead, CodeMirror can now be extended with additional plugins. I think this is a much better way to go.

@zero-24 zero-24 added this to the Joomla! 3.5.0 milestone Nov 4, 2015
@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Nov 4, 2015

Code Mirror works good here. Just two mirror we lose the code colors and on the text box above code mirror in the template manger see:

Without the patch
screen shot 2015-11-04 at 02 51 46
With the patch
screen shot 2015-11-04 at 02 51 50


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@joomla-cms-bot
Copy link
Copy Markdown

This PR has received new commits.

CC: @acjunior01, @anibalsanchez, @brianteeman, @DGT41, @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

@zero-24 Thanks for catching that. It's a simple fix but it brings up a question. I have put two hidden parameters in the plugin config. One is the path to Codemirror itself, the other is the path format for for mode files. By putting these values in the config, it makes it possible for someone to modify them (they are hidden so you'd have to first write a plugin that modifies the JForm). This would allow you to use a different version or your own custom package of the CodeMirror js and css files.

OK, that's really quite an unusual thing for someone to want to do. Of course, I know that.

Anyway, I need to prepend JUri::root() too whatever the value is so that it finds the media folder. This means that, if you wanted to use an absolute url that points to codemirror files hosted somwhere else, you can't really do it. Well, you can but now you also have to override the layout file. Which is fine, I suppose. If someone really wants to do all this crazy stuff then overriding a layout file isn't too much to ask. Yeah, this should be fine.

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Nov 6, 2015

@okonomiyaki3000 what do you think about.

$modeURL = $modePath . $extJS;

if (!file_exists($modeURL))
{
$modeURL = JUri::root(true) . '/' . $modePath . $extJS;
}

^^ in the PHP Block of the init lauout

cm.modeURL = <?php echo json_encode($modeURL); ?>;

^^ in the JS part of the layout. So both should work i guess ;)

@okonomiyaki3000
Copy link
Copy Markdown
Contributor Author

That's not how it works. $modeURL is really just a url pattern. CodeMirror will use it to find whichever mode it needs.

@roland-d
Copy link
Copy Markdown
Contributor

roland-d commented Nov 6, 2015

So, all is OK now and we just need to test it right?

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Nov 6, 2015

I have tested this item 🔴 unsuccessfully on 657b77d

@okonomiyaki3000 the colors are still broken for me. It looks like the fix don't work?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Nov 6, 2015

I have tested this item ✅ successfully on 657b77d

@okonomiyaki3000 oops i know it is late. Code mirror is ok you just need to wait one or two secconds more. Than the colors are there. Sorry for the false report :(


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@anibalsanchez
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 657b77d

Test OK


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@roland-d roland-d modified the milestones: Joomla! 3.6.0, Joomla! 3.5.0 Nov 7, 2015
@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Nov 7, 2015

RTC thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Nov 7, 2015
@bluezeyes-zz
Copy link
Copy Markdown

Yeah! ☺

Von meinem Samsung Gerät gesendet.

-------- Ursprüngliche Nachricht --------
Von: zero-24 notifications@github.com
Datum: 07.11.2015 10:54 (GMT+01:00)
An: joomla/joomla-cms joomla-cms@noreply.github.com
Cc: Jörn-Ingo Weigert jiweigert@gmail.com
Betreff: Re: [joomla-cms] Code Mirror plugin improvements (#5863)

RTC thanksThis comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5863.


Reply to this email directly or view it on GitHub.

wilsonge added a commit that referenced this pull request Nov 7, 2015
@wilsonge wilsonge merged commit 2c0c8ed into joomla:staging Nov 7, 2015
@okonomiyaki3000 okonomiyaki3000 deleted the CodeMirrorPlusPlus branch November 9, 2015 00:14
@wilsonge wilsonge removed the RTC This Pull Request is Ready To Commit label Jan 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.