Skip to content
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.0] TinyMCE does not save if 'save' selected when html editor toggled #26579

Closed
Scrabble96 opened this issue Oct 13, 2019 · 16 comments
Closed

Comments

@Scrabble96
Copy link
Contributor

Steps to reproduce the issue

Create an article
Toggle to html editor and add some code, e.g.

<div style="border: 1px solid red; padding: 10px;">
    <div style="border: 1px solid blue; padding: 10px;">Some text here</div>
</div>

(Without toggling Editor) Click/tap 'Save'

Expected result

New code should be saved and, if appropriate, displayed

Actual result

Code disappears.

System information (as much as possible)

J4 Nightly from 13/10/2019

Additional comments

If, however, you toggle the Editor back to WYSIWYG before saving, the code is saved.
I have tested this in J3 and it works as expected.

@brianteeman
Copy link
Contributor

I have tested this in J3 and it works as expected.

It is a completely different version of tinymce

@Scrabble96
Copy link
Contributor Author

It is a completely different version of tinymce

None-the-less, it is a problem in J4x.

@schnuti
Copy link
Contributor

schnuti commented Oct 14, 2019

Can't confirm the issue.
@Scrabble96 Did you test with another browser? Is it a large text you edit? Very fast page reload? The Javascript should "save" the text back to the editor before closing the page and reloading..

@schnuti
Copy link
Contributor

schnuti commented Oct 14, 2019

By the way - I removed this toggle button with a layout override for my own component to only use tiny's built in "code" button.

@Scrabble96
Copy link
Contributor Author

Ok. Brand new installation of J4 Dev 12 nightly full package from last night (14 Oct). Using Firefox but it does the same on Chrome:

tinyMCE-20191014

@brianteeman
Copy link
Contributor

I can confirm this behaviour

@schnuti
Copy link
Contributor

schnuti commented Oct 14, 2019

I can now confirm it.
My alpha 12 installation was a bit old. Something has obviously happened in between. Now installed the nightly build from today 14/10.

@schnuti
Copy link
Contributor

schnuti commented Oct 14, 2019

The problem should come from a change in Joomla code somewhere.
I copied tiny's vendor directory from the new alpha 12 installation to an older alpha 12 instance. To save the text as described then still works.

@dgrammatiko
Copy link
Contributor

dgrammatiko commented May 30, 2020

The problem should come from a change in Joomla code somewhere.

So I spend quite some time on this one today. The problem is that version 5 of tinyMCE break compatibility with version 4 in this part. There are 2 solutions here:

  • destroy the instance when we go out of tiny and recreate the instance when re switching
  • drop the button bellow and use the build in html view

None of them is ideal but not my decision here

@HLeithner
Copy link
Member

Destroying and recreate seams the more consistent way also for other editors what's the drawback if we do this?

@dgrammatiko
Copy link
Contributor

@HLeithner destroying and recreating the instance should be avoided, it should be the last resort not the first option. IIRC both me and @Fedik have avoided this pattern so far in J4. The obvious reason, especially with scripts that have very well documented API on their lifecycle, is that devs might do something on after initialisation of the script. If the instance is destroyed on recreation their code will be ignored and (depending if their using event or not) might not re execute. Let me raise a question on their tracker, it might be an easier (undocumented) way to do this.

@HLeithner
Copy link
Member

I don't say it'S a good method but it's the better then removing the button and since that's the only 2 options you gave me I had to choose ;-)

But just for clarification to trigger this problem:

  • you switch the editor off
  • write something in it
  • press the save button
  • joomla activates the editor again (which is right)
  • joomla execute the submit button but transmit the old content

right?

@dgrammatiko
Copy link
Contributor

Yes, the steps are correct. If you follow my issue upstream you’ll find out that the problem is only on the submit event. I guess they can flip some part of their code so if there is an attach functionality on that event that will happen before they push their existing data. I’m quite confident that this will be solved on their side

@Fedik
Copy link
Member

Fedik commented Jun 1, 2020

I would just trash that button, this function should belong to the editor instance itself.
Just a legacy, maybe from 1.0, in reason no one can explain.

@dgrammatiko
Copy link
Contributor

@Fedik people are familiar with it also the fix turns out to be super easy (if you knew deeply their API, of course I didn’t but I asked). check my pr...

@HLeithner
Copy link
Member

I'm closing this since we have a PR #29351 thank @dgrammatiko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants