From e095369e1a410d5a0bd11e3f2a7af33ba83e2aaa Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 29 Mar 2020 20:06:13 +0100 Subject: [PATCH] Desktop: WYSIWYG: Prevent scripts from loading multiple times --- ElectronClient/gui/editors/TinyMCE.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ElectronClient/gui/editors/TinyMCE.tsx b/ElectronClient/gui/editors/TinyMCE.tsx index 6225542a51..ce7e8d0217 100644 --- a/ElectronClient/gui/editors/TinyMCE.tsx +++ b/ElectronClient/gui/editors/TinyMCE.tsx @@ -388,13 +388,17 @@ const TinyMCE = (props:TinyMCEProps, ref:any) => { // ----------------------------------------------------------------------------------------- const loadDocumentAssets = (editor:any, pluginAssets:any[]) => { - const cssFiles = ['css/fork-awesome.min.css'].concat(pluginAssets - .filter((a:any) => a.mime === 'text/css' && !loadedAssetFiles_.includes(a.path)) - .map((a:any) => a.path)); + const cssFiles = ['css/fork-awesome.min.css'].concat( + pluginAssets + .filter((a:any) => a.mime === 'text/css') + .map((a:any) => a.path) + ).filter((path:string) => !loadedAssetFiles_.includes(path)); - const jsFiles = ['gui/editors/TinyMCE/content_script.js'].concat(pluginAssets - .filter((a:any) => a.mime === 'application/javascript' && !loadedAssetFiles_.includes(a.path)) - .map((a:any) => a.path)); + const jsFiles = ['gui/editors/TinyMCE/content_script.js'].concat( + pluginAssets + .filter((a:any) => a.mime === 'application/javascript') + .map((a:any) => a.path) + ).filter((path:string) => !loadedAssetFiles_.includes(path)); for (const cssFile of cssFiles) loadedAssetFiles_.push(cssFile); for (const jsFile of jsFiles) loadedAssetFiles_.push(jsFile);