AbanteCart Community

AbanteCart Development => AbanteCart v2.0 => Topic started by: dhigz on March 29, 2020, 03:42:03 PM

Title: Correct Problem With More Than One Instance of 'texteditor' on Page.
Post by: dhigz on March 29, 2020, 03:42:03 PM
There is an inherent problem in AbanteCart with having more than one tinymce editor loaded on a single page. I have an extension where I need to have multiple instances of tinymce loaded. There may be other developers with the same issue.

In the admin/view/template/form/text_editor.tpl file which loads the instance tinymce for each texteditor form field type, the first command in the javascript portion is to remove all existing instances of tinymce on the page. This is correct in the creation of the custom tinymce editor used in AbanteCart. However, when the second instance is added it also removes the first, third removes the first and second, etc. While the editor looks and works right for the HTML/Text portion, the Visual portion will only work on the last instance added.

The solution is to remove the specific instance being loaded. Instead of tinymce.remove(), replace with tinymce.remove('textarea#text_editor_<?php echo $id ?>').

Now all instances of tinymce will work correctly. Please make this change in the next release.
Title: Re: Correct Problem With More Than One Instance of 'texteditor' on Page.
Post by: Basara on March 30, 2020, 04:30:53 AM
Thank you for suggestion
Title: Re: Correct Problem With More Than One Instance of 'texteditor' on Page.
Post by: Basara on March 31, 2020, 03:00:17 AM
Hello, dhigz
Solution was implemented in https://github.com/abantecart/abantecart-src/issues/1321
Could you please try solution on your end https://github.com/abantecart/abantecart-src/commit/454c6c6ea7ca9e439f7deac04319b8caaf9be2f7?w=1
Title: Re: Correct Problem With More Than One Instance of 'texteditor' on Page.
Post by: dhigz on April 11, 2020, 11:11:02 PM
Thanks Basara,

I pretty much came up with the same solution of changing the
value = tinyMCE.activeEditor.getContent();
to
value = tinymce.get('text_editor_<?php echo $id ?>').getContent()

I also changed it in the else statement
} else {
            $('#'+newtab_id+ ' textarea')
                  .val(textarea.val())
                  .removeAttr('disabled');
            if(tinyMCE.activeEditor != null) {
               value = textarea.val();
               value = html2visual(value);
               tinyMCE.activeEditor.setContent( value );
            }

Thanks for making the change.