? ? Success

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
25 Oct 2016

Pull Request for Issue #12555

XTD-Buttons will NOT work if more than one (and different) editors are rendered on the page

Steps to reproduce

Make sure that the default editor is tinyMCE

Edit administrator/components/com_content/models/forms/article.xml and add after

    <fieldset addfieldpath="/administrator/components/com_categories/models/fields" >

this:

        <field
                name="test2"
                label ="Test Field"
                type="editor"
                width="300"
                filter="safehtml"
                editor="none"
                buttons="true"/>
        <field
                name="test3"
                label ="Test Field"
                type="editor"
                width="300"
                filter="safehtml"
                editor="codemirror"
                buttons="true"/>

Edit administrator/components/com_content/views/article/tmpl/edit.php and add after

                <fieldset class="adminform">
                    <?php echo $this->form->getInput('articletext'); ?>
                </fieldset>

this:

                <fieldset class="adminform">
                    <?php echo $this->form->getInput('test2'); ?>
                </fieldset>
                <fieldset class="adminform">
                    <?php echo $this->form->getInput('test3'); ?>
                </fieldset>

Then try to use the buttons to insert some images, contacts, etc. Oops it's broken for all except the last one.

Summary of Changes

Introducing a simple API which is just some setters and some getters.
This is more informative:

// An object to hold each editor instance on page, only define if not defined.
Joomla.editors.instances = Joomla.editors.instances || {
        /**
         * Editors MUST register, per instance, the following:
         *
         * getValue         Type  Function
         *          Should return the complete data from the editor
         *          Example: function () { return this.element.value; }
         * setValue         Type  Function
         *          Should replace the complete data of the editor
         *          Example: function (text) { return this.element.value = text; }
         * replaceSelection  Type  Function
         *          Should replace the selected text of the editor
         *          If nothing selected, will insert the data at the cursor
         *          Example: function (text) { return insertAtCursor(this.element, text); }
         *
         * USAGE (jform_articletext is the editor id)
         * getValue:
         *      Joomla.editors.instances['jform_articletext'].getValue();
         * setValue:
         *      Joomla.editors.instances['jform_articletext'].setValue('Joomla! rocks');
         * replaceSelection:
         *      Joomla.editors.instances['jform_articletext'].replaceSelection('Joomla! rocks')
         *
         * *********************************************************
         * ANY INTERACTION WITH THE EDITORS SHOULD USE THE ABOVE API
         * *********************************************************
         */
    };

Testing Instructions

Apply this patch
Go to back end and edit/create an article
On purpose there are all the editors in that page
Try the buttons in all of them. Cool eh?

Documentation Changes Required

The comment above comes from core.js but needs to be published also in the form->editor page.

TL;DR

Some images then:
screen shot 2016-10-26 at 01 13 16

screen shot 2016-10-26 at 01 14 23

Calling @Fedik @andrepereiradasilva @ggppdk @mbabker


This change is Reviewable

avatar dgt41 dgt41 - open - 25 Oct 2016
avatar dgt41 dgt41 - change - 25 Oct 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Oct 2016
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 25 Oct 2016
Category Administration Components JavaScript Front End Plugins
avatar dgt41
dgt41 - comment - 25 Oct 2016

@okonomiyaki3000 can you check the changes I did in codemirror here?

avatar dgt41 dgt41 - change - 25 Oct 2016
Title
Allow multiple editors in one page
Allow multiple (different) editors in one page
avatar dgt41 dgt41 - change - 25 Oct 2016
Title
Allow multiple editors in one page
Allow multiple (different) editors in one page
avatar dgt41 dgt41 - edited - 25 Oct 2016
avatar okonomiyaki3000
okonomiyaki3000 - comment - 26 Oct 2016

I'm not sure what this media/system/js/editor-codemirror.js is about but I don't like it.

avatar dgt41
dgt41 - comment - 26 Oct 2016

it's just the initiator script, this way there is no inline script at all

avatar okonomiyaki3000
okonomiyaki3000 - comment - 26 Oct 2016

I don't think there's anything wrong with inline script. The problem with this is that it seems to be part of Joomla core instead of the CodeMirror plugin and it can't be overridden like the current version can (via layouts).

avatar dgt41
dgt41 - comment - 26 Oct 2016

@okonomiyaki3000 not quite true, you can still use the layouts although a tiny script will be missing (the one that comes from code mirror.php). But if it breaks B/C I can revert it and redo this in J4

avatar dgt41 dgt41 - edited - 26 Oct 2016
avatar dgt41 dgt41 - edited - 27 Oct 2016
avatar okonomiyaki3000
okonomiyaki3000 - comment - 31 Oct 2016

Sorry, I can't get behind putting files used by the editors in media/system/js/. They just don't belong there. The editors should be thought of as optional plugins, decoupled from the Joomla core.

avatar dgt41
dgt41 - comment - 31 Oct 2016

@okonomiyaki3000 I will revert that part, but this PR is NOT about the initialisation of the editors, it solves a very fundamentally wrong architectural concept that limits joomla to only one editor per page...

avatar okonomiyaki3000
okonomiyaki3000 - comment - 31 Oct 2016

@dgt41 Yes, I'm aware of the limitation. It limits Joomla to only one type of editor per page. You may still have multiple instances of the same type. It's quite a glaring flaw and I'm glad you're fixing it but we must first do no harm.

avatar dgt41
dgt41 - comment - 1 Nov 2016

@ggppdk can you test this one?

avatar ggppdk
ggppdk - comment - 1 Nov 2016

@dgt41

will do tomorrow, thanks for the work on this one

avatar dgt41
dgt41 - comment - 1 Nov 2016

@okonomiyaki3000 I've restored the inline initialisation script for codemirror...

avatar okonomiyaki3000
okonomiyaki3000 - comment - 2 Nov 2016

I don't know, I'm still seeing media/system/js/editor-codemirror.js. What about other editors?

avatar dgt41
dgt41 - comment - 2 Nov 2016

What about other editors?

Other editors also using static scripts in media/editors/whatever/js. Also code mirror should move to static script in J4

avatar okonomiyaki3000
okonomiyaki3000 - comment - 2 Nov 2016

Isn't media/editors/whatever/js just the editor's distro code? Is Joomla-specific code meant to go in there too?

avatar dgt41
dgt41 - comment - 2 Nov 2016

Right now the folders `media/editor/whatever are maintained/manipulated by joomla, in J4 the aim is that foreign code should live in media/vendor/ folder and there should be an automated way to manage the updates (code is already written for that).
So here is a glimpse from the future (j4):
screen shot 2016-10-31 at 09 28 58

avatar okonomiyaki3000
okonomiyaki3000 - comment - 2 Nov 2016

I see, that makes sense I guess. Does that mean that the libraries under vendor must be used as distributed? What if we prefer custom builds?

avatar dgt41
dgt41 - comment - 2 Nov 2016

@okonomiyaki3000 I guess this will manage only the joomla distributed code, I have no clue if this will be extended somehow for 3rd PD (my guess is no, 3rd PD could provide their custom code in their own directory). Or you can manipulate or override the grunt script and get whatever you want, with the added step to re-run the script every time joomla updates these assets...

avatar infograf768
infograf768 - comment - 2 Nov 2016

Conflicts

avatar yvesh
yvesh - comment - 2 Nov 2016

@dgt41 Would be nice to have some javascript tests too. ? Ping @Ruchiranga

avatar dgt41
dgt41 - comment - 2 Nov 2016

@yvesh you are right, now that all these are not inline some tests could be written, any help is welcome ?

avatar Ruchiranga
Ruchiranga - comment - 2 Nov 2016

Bit busy this month. I'll see what I can do when I get some free time ?

avatar ggppdk
ggppdk - comment - 3 Nov 2016

Is this ready for testing ?

In Joomla article form , if i use tinymce editor, i am getting (firefox console):

SyntaxError: expected expression, got '<'[Learn more]index.php:1

avatar joomla-cms-bot joomla-cms-bot - change - 3 Nov 2016
Category Administration Components JavaScript Front End Plugins Administration Components JavaScript External Library
avatar dgt41
dgt41 - comment - 3 Nov 2016

Sorry @ggppdk I've moved some files around and forgot to fix the paths, now should be fine

avatar dgt41 dgt41 - close - 14 Nov 2016
avatar dgt41 dgt41 - change - 14 Nov 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-11-14 11:42:49
Closed_By dgt41
avatar dgt41 dgt41 - close - 14 Nov 2016
avatar joomla-cms-bot joomla-cms-bot - change - 14 Nov 2016
Category Administration Components JavaScript External Library Administration com_contact com_content com_menus com_modules JavaScript External Library Components
avatar ggppdk
ggppdk - comment - 14 Nov 2016

@dgt41

please re-open
after your latest changes, i had re-tested but i was still getting

SyntaxError: expected expression, got '<'[Learn more]index.php:1

Some attempt to get JS code actually returns html code, i was going to look more to it, and find for which URL it is happening

avatar dgt41 dgt41 - change - 14 Nov 2016
Status Closed New
Closed_Date 2016-11-14 11:42:49
Closed_By dgt41
avatar dgt41 dgt41 - change - 14 Nov 2016
Status New Pending
avatar dgt41 dgt41 - reopen - 14 Nov 2016
avatar dgt41 dgt41 - reopen - 14 Nov 2016
avatar ggppdk
ggppdk - comment - 14 Nov 2016

Thanks,

i will post back, with the URL, that is causing this

I had found the URL, but i had not find the PHP file that was adding it

avatar dgt41
dgt41 - comment - 14 Nov 2016

@ggppdk let me know what's the URL so I could test that

avatar ggppdk
ggppdk - comment - 15 Nov 2016

Tested, looks good, but can you rebase this PR ?

there have been changes to e.g. addStyleSheet, etc functions

avatar dgt41
dgt41 - comment - 15 Nov 2016

@ggppdk I just pressed that shiny button update branch. Hopefully everything still ok ?

avatar jeckodevelopment
jeckodevelopment - comment - 17 Nov 2016

@dgt41 can you please fix conflicts here?

media/system/js/tinymce-init.js
media/system/js/tinymce-init.min.js

avatar dgt41
dgt41 - comment - 17 Nov 2016
avatar dgt41 dgt41 - change - 5 Dec 2016
The description was changed
Labels Removed: ?
avatar dgt41 dgt41 - edited - 5 Dec 2016
avatar dgt41
dgt41 - comment - 19 Dec 2016

Any interest to get this merged or should I close it?

avatar ggppdk
ggppdk - comment - 20 Dec 2016

I ll test after you re-fix conflicts, and re-test after that if needed )

avatar ggppdk
ggppdk - comment - 30 Dec 2016

It works, but

  • new configuration that allows tinyMCE configurations per per access level added by recent PR is not used
  • the editor always start in OFF state i have to click "toggle editor" to show it

I think we need to wait for this PR to be tested:
#13387

and then update / test this one ?

avatar anibalsanchez
anibalsanchez - comment - 3 Jan 2017

I have tested this item ? unsuccessfully on 40ba81f

In the testing steps, there is no tmpl/default.php... so I guess it has to be tmpl/edit.php

Buttons only work in the last editor.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12561.
avatar anibalsanchez anibalsanchez - test_item - 3 Jan 2017 - Tested unsuccessfully
avatar dgt41 dgt41 - change - 4 Jan 2017
The description was changed
avatar dgt41 dgt41 - edited - 4 Jan 2017
avatar dgt41
dgt41 - comment - 4 Jan 2017

@ggppdk yes that needs to be pulled as well
@anibalsanchez I just tested it again and works fine here, I also updated the description and the steps required to test this..

Anyways let's wait for the #13387 to be merged and then I will re update this one

avatar ggppdk
ggppdk - comment - 5 Jan 2017

@dgt41
PR #13387 that also deal with tinyMCE was merged,
this PR can be updated

avatar rvbgnu
rvbgnu - comment - 8 Jan 2017

Great one to test, once updated ;-)

avatar dgt41
dgt41 - comment - 8 Jan 2017

@ggppdk @rvbgnu @anibalsanchez re synced the repo, can you give it a go?

avatar rvbgnu
rvbgnu - comment - 8 Jan 2017

I have tested this item βœ… successfully on 125eeda

Thanks Dimitri!

Just a precision, as I am not sure to be able to reproduce the issue, compare to your images: I don't have the any content in the two additional editors when I open an existing article. As I understand a bit the two code changes to get them, I supposed it is normal. I may suggest to edit your test instruction to remove the confusion.

Otherwise, I have the buttons working properly in the other two editors. So I marked this test successful (Please remove it if I'm wrong).


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12561.
avatar rvbgnu rvbgnu - test_item - 8 Jan 2017 - Tested successfully
avatar dgt41
dgt41 - comment - 8 Jan 2017

As I understand a bit the two code changes to get them, I supposed it is normal

Yes, you are right, the extra editors are dummies, so any data you've put into them will be lost after save (there is no code to manipulate it and save it in the database).
Thanks you for testing this, really appreciated! ?

avatar ggppdk
ggppdk - comment - 8 Jan 2017

@dgt41

Thanks for your works, i will make a detailed test at end of week, now little time

0ab0eeb 12 Jan 2017 avatar dgrammatiko rfc
a0060f0 12 Jan 2017 avatar dgrammatiko CS
9131a5f 12 Jan 2017 avatar dgrammatiko CS
9e75d6b 12 Jan 2017 avatar dgrammatiko Ooops
ab4decf 12 Jan 2017 avatar dgrammatiko cs
690fa4d 12 Jan 2017 avatar dgrammatiko oops
3db07d6 12 Jan 2017 avatar dgrammatiko fixes
2f3f3a5 12 Jan 2017 avatar dgrammatiko CS
avatar anibalsanchez
anibalsanchez - comment - 14 Jan 2017

I have tested this item βœ… successfully on 3550213

Test OK


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

avatar anibalsanchez anibalsanchez - test_item - 14 Jan 2017 - Tested successfully
avatar dgt41
dgt41 - comment - 15 Jan 2017

@ggppdk @rvbgnu @infograf768 can we have one more test here, so we can RTC this?

avatar rvbgnu
rvbgnu - comment - 5 Feb 2017

So nobody for this test ?

Or should I re-test it (changes since 08/01/2017)??


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

avatar dgt41
dgt41 - comment - 5 Feb 2017

@rvbgnu if you can re-test this, will be great

avatar rvbgnu
rvbgnu - comment - 5 Feb 2017

So I've tried, but it doesn't change before or after the patch. The TinyMCe also had an update. I have to reset with repository copy and re-install I think...


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

avatar dgt41
dgt41 - comment - 11 Feb 2017

but it doesn't change before or after the patch

@rvbgnu the article form doesn't have the extra editors anymore. That needs to be done by editing the xml and the view files. The initial approach had those extra editors as a way to make testing easier...

avatar laoneo laoneo - test_item - 21 Feb 2017 - Tested successfully
avatar laoneo
laoneo - comment - 21 Feb 2017

I have tested this item βœ… successfully on 3550213

If this is in, then we can offer the different editors attributes on com_fields.


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

avatar dgt41 dgt41 - change - 21 Feb 2017
Status Pending Ready to Commit
avatar dgt41
dgt41 - comment - 21 Feb 2017

RTC


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

avatar dgt41
dgt41 - comment - 21 Feb 2017

Note to whomever might merge this: please ping to update the documentation for the editor input field, etc

avatar rdeutz rdeutz - change - 22 Feb 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-02-22 16:59:39
Closed_By rdeutz
Labels Added: ? ?
avatar rdeutz rdeutz - close - 22 Feb 2017
avatar rdeutz rdeutz - merge - 22 Feb 2017
avatar zero-24
zero-24 - comment - 22 Feb 2017

Note to whomever might merge this: please ping to update the documentation for the editor input field, etc

@dgt41 ping :P

avatar svenbluege
svenbluege - comment - 22 Feb 2017

I just grabbed the latest build and run into an issue with having multiple editors on the same page. Seems like only one of them gets initialized. I have three of them in my example. The Joomla.editors.instances object contains just the first editor instance. The tinyMCE.editors shows one as well. If I click the "toggle editor" button, this field shows up in tinyMCE.editors.

image

This can also be reproduced by changing some form elements of the com_content/forms/article.xml to type editor:

image

avatar dgt41
dgt41 - comment - 22 Feb 2017

I just grabbed the latest build and run into an issue with having multiple editors on the same page.

That's impossible (each tinyMCE or code mirror or none has it's own instance) according to the code: https://github.com/joomla/joomla-cms/blob/staging/media/editors/tinymce/js/tinymce.js#L65-L79
Can you type Joomla.editors and press enter in your browsers console? Do you have all the instances there?

avatar dgt41
dgt41 - comment - 22 Feb 2017

@svenbluege actually there is a bug, but here is the fix: #14194

Thanks for testing!

avatar svenbluege
svenbluege - comment - 23 Feb 2017

@dgt41 works for me. Thanks!

avatar infograf768
infograf768 - comment - 25 Mar 2017

It looks like this has broken inserting menu item urls
#14890

Please look @dgt41

avatar dgt41
dgt41 - comment - 25 Mar 2017

Add a Comment

Login with GitHub to post a comment