From 635e0f269ea40951b7d405b21527be8e7881af63 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 24 Nov 2023 10:54:38 +0100 Subject: [PATCH 1/2] Extract Tinymce setup scripts into partial --- .../alchemy/admin/tinymce/_setup.html.erb | 18 ++++++++++++++++++ app/views/layouts/alchemy/admin.html.erb | 17 +---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 app/views/alchemy/admin/tinymce/_setup.html.erb diff --git a/app/views/alchemy/admin/tinymce/_setup.html.erb b/app/views/alchemy/admin/tinymce/_setup.html.erb new file mode 100644 index 0000000000..f56fa5cb6e --- /dev/null +++ b/app/views/alchemy/admin/tinymce/_setup.html.erb @@ -0,0 +1,18 @@ + diff --git a/app/views/layouts/alchemy/admin.html.erb b/app/views/layouts/alchemy/admin.html.erb index 58080fa3f5..00073c74a5 100644 --- a/app/views/layouts/alchemy/admin.html.erb +++ b/app/views/layouts/alchemy/admin.html.erb @@ -13,25 +13,10 @@ + <%= render 'alchemy/admin/tinymce/setup' %> <%= render 'alchemy/admin/partials/routes' %> <%= javascript_include_tag('alchemy/admin/all', 'data-turbo-track' => true) %> <%= javascript_importmap_tags("alchemy_admin", importmap: Alchemy.importmap) %> From bd50facd4b6c3a25d4cb12ca67d80cbcf204435d Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 23 Nov 2023 21:25:34 +0100 Subject: [PATCH 2/2] Preload tinymce assets Tinymce loads the editor content css and its plugins on initialize. Since we init tinymce only when its visible it takes long to init the editor. Using browser preload features to make sure the assets are already loaded. --- .../alchemy/admin/tinymce/_setup.html.erb | 11 ++++ lib/alchemy/tinymce.rb | 8 ++- spec/features/admin/tinymce_feature_spec.rb | 52 +++++++++++++++++++ spec/libraries/tinymce_spec.rb | 12 +++++ 4 files changed, 82 insertions(+), 1 deletion(-) diff --git a/app/views/alchemy/admin/tinymce/_setup.html.erb b/app/views/alchemy/admin/tinymce/_setup.html.erb index f56fa5cb6e..d3a387f431 100644 --- a/app/views/alchemy/admin/tinymce/_setup.html.erb +++ b/app/views/alchemy/admin/tinymce/_setup.html.erb @@ -1,3 +1,14 @@ +<% asset_host = ActionController::Base.config.asset_host %> + + + +<% if Alchemy::Tinymce.init[:content_css] %> + +<% end %> +<% Alchemy::Tinymce.preloadable_plugins.each do |plugin| %> + +<% end %> +