Open lekoala opened 4 years ago
So since i had the bug again and found my own issues back (yeahh!)... but this time, i have a proper bug report @emteknetnz
When navigating from a model admin list to a record with an html editor field, the html editor field fails to load It works fine if you reload the page with the edit form
I tracked down the issue to
I guess entwine may fire before the ondemand headers are processed. entwine needs to call onadd after ondemand headers are processed
I can’t reproduce this with the above steps 😅 even when I delete the assets/_tinymce
directory to force it to regenerate. The x-include-js
header includes /assets/_tinymce/tinymce-cms-de12f05075.js
, and that loads correctly & the TinyMCE instance works as expected.
Chrome 88.0.4324.192 on MacOS by the way, perhaps it’s a browser issue?
@kinglozzer how odd! this is what happens for me (i didn't try on a "fresh" project but i don't see why it would do that in my current project)
I can fix it by loading beforehand the combined file /assets/_tinymce/tinymce-cms-7a426e1942.js in a LeftAndMainExtension
// This needs to be loaded after #assetadmin because it depends on InsertMediaModal to be defined
$cmsConfig = HTMLEditorConfig::get('cms');
$generator = Injector::inst()->get(TinyMCECombinedGenerator::class);
Requirements::javascript($generator->getScriptURL($cmsConfig));
I can try on another project to see if I get the same error
@kinglozzer ok if i simplify my code to just return the html editor field, it works... so i guess it's somewhere in my fields that there is something causing the issue. I haven't found so far but at least there is no need for you to check further. If I find why it's doing that i will update the issue.
@kinglozzer ahah found it ! that was a nasty one
Let me update my bug report -:)
You can try for instance a field needing
Requirements::javascript("https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.6/flatpickr.js");
Yep, that does trigger it! Thanks for investigating @lekoala
@kinglozzer you are welcome!
and since i'm really curious, it seems the difference is that:
knowing that, in the meantime, either external ressources should be avoided, or tinymce loaded up front.
Hi, I also experience this issue from time to in while editing pages.
I am also experiencing the same issue when I try to edit pages.
So I got it to work by loading early tinymce globally in the admin. I still get a really ugly FOUC with the icons being displayed unstyled, so it's better than the thing crashing but not ideal anyway.
@lekoala thanks for sharing your solution. For me, the problem was not having the right permission for public/assets
directory.
Also have the same issue with SS 4.9.0
Can I ask @kevinreynolds what was the right permission to have on the public/assets directory? And @lekoala please could you give specific steps on how to get tinymce to load early globally in the admin?
Many thanks everyone
@jpbroadwater you can do something along these lines in a LeftAndMain extension
Hi, thanks very much for replying. If I've understood you correctly, I need to use composer to require lekoala/silverstripe-base. But attempting that, with SS 4.9.0 results in "InvalidArgumentException - could not find a matching version of package lekoala/silverstripe-base". Can you advise on this.
And then assuming I can eventually install the base, does the specific code you mentioned automatically come with it?
@jpbroadwater you don't have to install my module, you can simply create your own leftandmain extension and copy the specific lines i've mentionned
public static function forceTinyMCELoad()
{
// This needs to be loaded after #assetadmin because it depends on InsertMediaModal to be defined
$cmsConfig = HTMLEditorConfig::get('cms');
$generator = Injector::inst()->get(TinyMCECombinedGenerator::class);
$link = $generator->getScriptURL($cmsConfig);
Requirements::javascript($link);
}
Thanks so much for being patient with me and I'm really excited at the prospect of getting this working, but I'm not very familiar with all this - could you give me another pointer?
So far within /app/src I've created a new file named tinymceExtension.php and the code is:
<?php
namespace {
use SilverStripe\ORM\DataExtension;
class tinymceExtension extends DataExtension
{
public static function forceTinyMCELoad() {
$cmsConfig = HTMLEditorConfig::get('cms');
$generator = Injector::inst()->get(TinyMCECombinedGenerator::class);
$link = $generator->getScriptURL($cmsConfig);
Requirements::javascript($link);
}
}
}
and within /app/_config.php I've written:
// To add tinymce extension to all classes
SilverStripe\Security\Member::add_extension(tinymceExtension::class);
But it produces a server error. What am I doing wrong please?
@jpbroadwater i'm sorry, but it seems you need to get more understanding of the inner mechanics of SilverStripe in order to apply the code yourself. Feel free to contact me directly if you need support on this issue.
Have emailed you just now, thanks
Any time I have custom scripts that require something like tinymce
I just make sure my script is deferred. I imagine the same would work for CDN scripts.
@lekoala
I have faced the same issue related to TinyMCE I didn't understand what I do? Can you please guide me
@lekoala
@ritesh845 the best way i've found so far is to load the editor upfront through a leftandmain extension. see my comment above
public static function forceTinyMCELoad()
{
// This needs to be loaded after #assetadmin because it depends on InsertMediaModal to be defined
$cmsConfig = HTMLEditorConfig::get('cms');
$generator = Injector::inst()->get(TinyMCECombinedGenerator::class);
$link = $generator->getScriptURL($cmsConfig);
Requirements::javascript($link);
}
please note this is not a place for support, the goal here is to report (and hopefuly fix one day) the issue
Also present in 2.0.0-beta1
.
In my case it is a warning message in yellow background not in red. Easy to replicate in Google Chrome by adjusting the connection speed in the Network tab to 3G and then clear any cache.
How to reproduce in CWP/CMS 4.12 (clean install)
composer create-project silverstripe/recipe-ccl ./vanilla ^2
cd vanilla
composer require silverstripe/recipe-cms
Load up the blank site in Chrome incognito, log into the CMS as admin, edit the home page, apply some text formatting, hit save and publish. Browser console shows this JavaScript error.
@lekoala unfortunately your fix doesn't resolve the JavaScript error.
I'm hitting the following issue on the latest stable version. I'm also using fluent (not that i know if it makes any difference). It mostly happens in a ModelAdmin when creating new records. Refreshing the page works fine, it's when I create a record from the list.
I suspect there is some issues in terms of loading order. I can see that /assets/_tinymce/tinymce-cms-a311274ba0.js is being loaded fine, but probably some code is calling it in bundle.js before it's loaded when doing the ajax load.
culprit seem to be in these lines
how can bundle.js be sure that everything is indeed loaded? i'm also loading a couple of other js files that seem to happen before loading tinymce-cms which may explain why in my case that loading order matters