nathancox / silverstripe-codeeditorfield

A field for editing code in the SilverStripe CMS using Ace Editor (http://ace.c9.io/)
25 stars 13 forks source link

Incompatible with Silverstripe 3.3? #6

Open Friksel opened 8 years ago

Friksel commented 8 years ago

Hello @nathancox, I'm a happy user of the codeeditorfield module. Until now it survived every Silverstripe 3-upgrade. But since I upgraded to Silverstripe 3.3 there are some weird things going on here with the codeeditorfield. At the moment I'm debugging my code.

This is the behaviour I get after the ss3.3 upgrade: The visible cursor is off-sync with the 'real' position in the text (so selections/edits happen on the wrong place in the text). The font of the codeeditorfield also changed from the Arial-like font into a Times-like font.

To be honoust, I'm getting a littlebit clueless by now on where to look, so just to be sure: should this module be compatible with Silverstripe 3.3? Thanks in advance

nathancox commented 8 years ago

Hi,

So far I can't reproduce this problem. What browser are you using?

Friksel commented 8 years ago

Hi @nathancox ,

Thanks for your reaction. I did some further testing and the problem only occurs in Chrome and Opera browsers (webkit), it's still working fine in IE11, Edge and Firefox.

Both Chrome and Opera throw these messages in the console when the codeeditor opens from tinyMCE:

The first message only happens when the codeditor-plugin is added to tinyMCE. The second console message is also generated when the codeditor plugin is not added.

When I don't add the codeditor plugin to tinyMCE, the editor works as expected (and with the original font too, as seen before and still in other browsers).

Perhaps this happened after Silverstripe upgrading tinyMCE to version 4? https://github.com/silverstripe/silverstripe-cms/pull/1394

If the problem is the KeyLocation, like the consolemessage says, it makes sense. The problem IS a cursorproblem: when I move the cursor, the cursor sometimes is in the middle of a character, and when I select a piece of text and press delete, somewhere else in the text some characters will be removed. Chrome/Opera say it will be removed at 'around April 2016', so that could explain why I haven't seen this problem before, 'cause it's just April now. That doesn't explain the change in font though.

btw, this is my config:

$htmlEditorConfig = HtmlEditorConfig::get('cms');
HtmlEditorConfig::get('cms')->enablePlugins(array(
    'aceeditor' => sprintf('codeeditorfield/javascript/tinymce/editor_plugin_src.js')
));
HtmlEditorConfig::get('cms')->insertButtonsBefore('fullscreen', 'aceeditor');
HtmlEditorConfig::get('cms')->removeButtons('code');

Screenshots: chrome (http://pasteboard.co/1HWeB1K.jpg) opera (http://pasteboard.co/1I5SV4j.jpg) firefox (http://pasteboard.co/1HZTSky.jpg), edge (http://pasteboard.co/1I1PmIk.jpg), ie11 (http://pasteboard.co/1I38cLl.jpg)

nathancox commented 8 years ago

How did you get your copy of SilverStripe? I was using 3.3.1 specifically but it doesn't have the TinyMCE upgrade. I switched to running the master branch (dev-master in composer.json) which has the new TinyMCE and it has it's own problems with codeeditorfield (like $allowed_actions needs to be changed to private) but I still can't reproduce the cursor issue or the console message about it. I do get the "Automatically scrolling cursor into view ..." message several times though.

Friksel commented 8 years ago

I think you're right, I did an assumption after finding the news about the TinyMCE upgrade that SS3.3.1 was using the TinyMCE upgrade already. But the TinyMCE upgrade will probably only be available from SS version 4.

I'm using the latest stable Silverstripe version (3.3.1) too. Before this version I had all other Silverstripe versions from 3.1 up, without this problem.

Strange that it's only happening (going wrong) in webkit-browsers. And that it seems to work on your side. I'm wondering what's different in my setup. I use other modules too, but none of them, as far as I can think of, is changing the html editor behaviour.

mmm...

nathancox commented 8 years ago

Hi, just want to say I'm sorry for the lack of responsiveness on this. I'm completely snowed under right now and I'm having trouble finding the time to really look in to it.

Friksel commented 8 years ago

Thanks for your response @nathancox . No problem at all. I'm not in a hurry. Take your time