From 0759ef4f3b78462fd0aacfc181f257fc7915af20 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Tue, 6 Oct 2020 14:24:54 +0100 Subject: [PATCH 01/17] [4.0] language of parts --- build/build-modules-js/init.es6.js | 18 ++++++++++++++++ .../javascript/minify-vendor.es6.js | 1 + build/build-modules-js/settings.json | 21 +++++++++++++++++++ package-lock.json | 5 +++++ package.json | 1 + plugins/editors/tinymce/forms/setoptions.xml | 11 ++++++++++ plugins/editors/tinymce/tinymce.php | 11 +++++++++- 7 files changed, 67 insertions(+), 1 deletion(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index a2c610b43bbf5..a3374217a56e9 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -2,6 +2,7 @@ const Copydir = require('copy-dir'); const Fs = require('fs'); const FsExtra = require('fs-extra'); const Path = require('path'); +const { plugin } = require('postcss'); const RootPath = process.cwd(); const xmlVersionStr = /()(.+)(<\/version>)/; @@ -232,6 +233,23 @@ const copyFiles = (options) => { let tinyWrongMap = Fs.readFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, { encoding: 'UTF-8' }); tinyWrongMap = tinyWrongMap.replace('/*# sourceMappingURL=skin.min.css.map */', ''); Fs.writeFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, tinyWrongMap, { encoding: 'UTF-8' }); + } else if (packageName === 'tinymce-language-selector') { + // const itemvendorPath = Path.join(RootPath, `media/vendor/${packageName}`); + + // if (!FsExtra.existsSync(itemvendorPath)) { + // FsExtra.mkdirSync(itemvendorPath); + // FsExtra.mkdirSync(Path.join(itemvendorPath, 'tinymce-language-selector')); + // } + // eslint-disable-next-line no-console + console.log('################################################################'); + concatFiles( + [ + 'media/vendor/tinymce-language-selector/js/constants.js', + 'media/vendor/tinymce-language-selector/js/plugin.js', + + ], + 'media/vendor/tinymce-language-selector/plugin.js', + ); } else { ['js', 'css', 'filesExtra'].forEach((type) => { if (!vendor[type]) return; diff --git a/build/build-modules-js/javascript/minify-vendor.es6.js b/build/build-modules-js/javascript/minify-vendor.es6.js index 0d54a05642dcf..d134a2793f635 100644 --- a/build/build-modules-js/javascript/minify-vendor.es6.js +++ b/build/build-modules-js/javascript/minify-vendor.es6.js @@ -14,6 +14,7 @@ module.exports.compile = () => { const folders = [ Path.join(RootPath, 'media/vendor/codemirror'), Path.join(RootPath, 'media/vendor/punycode/js'), + Path.join(RootPath, 'media/vendor/tinymce-language-selector/js'), Path.join(RootPath, 'media/vendor/webcomponentsjs'), ]; diff --git a/build/build-modules-js/settings.json b/build/build-modules-js/settings.json index 276c31954dd8f..3c7e932243720 100644 --- a/build/build-modules-js/settings.json +++ b/build/build-modules-js/settings.json @@ -97,6 +97,27 @@ "dependencies": [], "licenseFilename": "LICENSE" }, + "@edx/tinymce-language-selector": { + "name": "tinymce-language-selector", + "js": { + "tinymce-language-selector/constants.js": "js/constants.js", + "tinymce-language-selector/plugin.js": "js/plugin.js" + }, + "provideAssets": [ + { + "name": "constants", + "type": "script", + "uri": "constants.js" + }, + { + "name": "plugin", + "type": "script", + "uri": "plugin.js" + } + ], + "dependencies": [], + "licenseFilename": "LICENSE" + }, "cropperjs": { "name": "cropperjs", "js": { diff --git a/package-lock.json b/package-lock.json index 665f72c5849b8..d7cb4f056498d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2584,6 +2584,11 @@ "resolved": "https://registry.npmjs.org/@claviska/jquery-minicolors/-/jquery-minicolors-2.3.5.tgz", "integrity": "sha512-LpiN8hyqRPYB2tEzFD4lI54GxKHQXhzrJMnKnsumElYxjkjbdAPmiIm+1k/Mkfn92HepL7t9uaK5iQSFP/19aw==" }, + "@edx/tinymce-language-selector": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@edx/tinymce-language-selector/-/tinymce-language-selector-1.1.0.tgz", + "integrity": "sha512-yw+JVsq8vRMsTeSY8xjDIlV8xHh9HweZzz1AXPgMtrcS7gEAIYE0G0899ULICV/slBCWdYnTp1oDnDH9DanQ9w==" + }, "@fortawesome/fontawesome-free": { "version": "5.14.0", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.14.0.tgz", diff --git a/package.json b/package.json index 29c3c794f19a4..535e2d78fb772 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ ], "dependencies": { "@claviska/jquery-minicolors": "^2.3.5", + "@edx/tinymce-language-selector": "^1.1.0", "@webcomponents/webcomponentsjs": "^2.4.4", "accessibility": "^3.0.10", "awesomplete": "1.1.5", diff --git a/plugins/editors/tinymce/forms/setoptions.xml b/plugins/editors/tinymce/forms/setoptions.xml index 671f0e5f065ed..46fda7eb16bae 100644 --- a/plugins/editors/tinymce/forms/setoptions.xml +++ b/plugins/editors/tinymce/forms/setoptions.xml @@ -35,6 +35,17 @@ hide_none="true" /> + + + + + get('language', 1); + + if ($jlangparts) + { + $externalPlugins['language'] = HTMLHelper::_('script', 'plg_editors_tinymce/plugins/language/plugin.min.js', ['relative' => true, 'version' => 'auto', 'pathOnly' => true]); + } + // Convert pt to px in dropdown $scriptOptions['fontsize_formats'] = '8px 10px 12px 14px 18px 24px 36px'; @@ -980,6 +988,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), + 'language' => array('label' => 'Language', 'plugin' => 'language'), ]; return $buttons; @@ -1041,7 +1050,7 @@ public static function getToolbarPreset() 'fullscreen', '|', 'table', '|', 'subscript', 'superscript', '|', - 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', '|', + 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', 'language', '|', 'cut', 'copy', 'paste', 'pastetext', '|', 'visualchars', 'visualblocks', 'nonbreaking', 'blockquote', 'template', '|', 'print', 'preview', 'codesample', 'insertdatetime', 'removeformat', 'jxtdbuttons' From 80a16159f2cf06fb93fd4407f87ec924ac95e3ac Mon Sep 17 00:00:00 2001 From: brian teeman Date: Tue, 6 Oct 2020 14:27:49 +0100 Subject: [PATCH 02/17] oops --- build/build-modules-js/init.es6.js | 1 - 1 file changed, 1 deletion(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index a3374217a56e9..9e4363cecdb63 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -2,7 +2,6 @@ const Copydir = require('copy-dir'); const Fs = require('fs'); const FsExtra = require('fs-extra'); const Path = require('path'); -const { plugin } = require('postcss'); const RootPath = process.cwd(); const xmlVersionStr = /()(.+)(<\/version>)/; From ec46f703fffd951b3525ba90f070cb0a7fe3f3ac Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 10:24:24 +0100 Subject: [PATCH 03/17] wip --- build/build-modules-js/compilejs.es6.js | 2 ++ build/build-modules-js/init.es6.js | 32 +++++++++++--------- build/build-modules-js/settings.json | 16 ---------- plugins/editors/tinymce/forms/setoptions.xml | 11 ------- plugins/editors/tinymce/tinymce.php | 9 ++---- 5 files changed, 21 insertions(+), 49 deletions(-) diff --git a/build/build-modules-js/compilejs.es6.js b/build/build-modules-js/compilejs.es6.js index e4cf2c3bd6581..03645f9b7bc22 100644 --- a/build/build-modules-js/compilejs.es6.js +++ b/build/build-modules-js/compilejs.es6.js @@ -55,6 +55,8 @@ module.exports.compileJS = (options, path) => { }, ); }); + // hack, needs a bundler + HandleFile.run('media/plg_editors_tinymce/js/plugins/tinymce-language-selector/plugin.es6.js'); }) // Handle errors diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index 9e4363cecdb63..0885fca1bdd78 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -232,23 +232,25 @@ const copyFiles = (options) => { let tinyWrongMap = Fs.readFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, { encoding: 'UTF-8' }); tinyWrongMap = tinyWrongMap.replace('/*# sourceMappingURL=skin.min.css.map */', ''); Fs.writeFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, tinyWrongMap, { encoding: 'UTF-8' }); - } else if (packageName === 'tinymce-language-selector') { - // const itemvendorPath = Path.join(RootPath, `media/vendor/${packageName}`); + } else if (packageName === '@edx/tinymce-language-selector') { + // This whole section actually needs a bundler like rollup + let finalPluginCode = ''; + if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { + let constants = ''; + if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { + constants = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/constants.js'), { encoding: 'utf8' }); + } + if (constants) { + finalPluginCode = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'), { encoding: 'utf8' }); + finalPluginCode = finalPluginCode.replace('import { BROWSER_DEFAULT, languages } from \'./constants\';', constants); - // if (!FsExtra.existsSync(itemvendorPath)) { - // FsExtra.mkdirSync(itemvendorPath); - // FsExtra.mkdirSync(Path.join(itemvendorPath, 'tinymce-language-selector')); - // } - // eslint-disable-next-line no-console - console.log('################################################################'); - concatFiles( - [ - 'media/vendor/tinymce-language-selector/js/constants.js', - 'media/vendor/tinymce-language-selector/js/plugin.js', + FsExtra.mkdirpSync('media/plg_editors_tinymce/js/plugins/tinymce-language-selector'); - ], - 'media/vendor/tinymce-language-selector/plugin.js', - ); + Fs.writeFileSync('media/plg_editors_tinymce/js/plugins/tinymce-language-selector/plugin.es6.js', finalPluginCode, { encoding: 'utf8' }); + + FsExtra.mkdirpSync('media/vendor/tinymce-language-selector/js'); + } + } } else { ['js', 'css', 'filesExtra'].forEach((type) => { if (!vendor[type]) return; diff --git a/build/build-modules-js/settings.json b/build/build-modules-js/settings.json index 3c7e932243720..5babe1c39257a 100644 --- a/build/build-modules-js/settings.json +++ b/build/build-modules-js/settings.json @@ -99,22 +99,6 @@ }, "@edx/tinymce-language-selector": { "name": "tinymce-language-selector", - "js": { - "tinymce-language-selector/constants.js": "js/constants.js", - "tinymce-language-selector/plugin.js": "js/plugin.js" - }, - "provideAssets": [ - { - "name": "constants", - "type": "script", - "uri": "constants.js" - }, - { - "name": "plugin", - "type": "script", - "uri": "plugin.js" - } - ], "dependencies": [], "licenseFilename": "LICENSE" }, diff --git a/plugins/editors/tinymce/forms/setoptions.xml b/plugins/editors/tinymce/forms/setoptions.xml index 46fda7eb16bae..671f0e5f065ed 100644 --- a/plugins/editors/tinymce/forms/setoptions.xml +++ b/plugins/editors/tinymce/forms/setoptions.xml @@ -35,17 +35,6 @@ hide_none="true" /> - - - - - get('language', 1); - - if ($jlangparts) - { - $externalPlugins['language'] = HTMLHelper::_('script', 'plg_editors_tinymce/plugins/language/plugin.min.js', ['relative' => true, 'version' => 'auto', 'pathOnly' => true]); - } + $externalPlugins['language'] = HTMLHelper::_('script', 'plg_editors_tinymce/plugins/tinymce-language-selector/plugin.min.js', ['relative' => true, 'version' => 'auto', 'pathOnly' => true]); // Convert pt to px in dropdown $scriptOptions['fontsize_formats'] = '8px 10px 12px 14px 18px 24px 36px'; @@ -988,7 +983,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'language'), + 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), ]; return $buttons; From 57de2c74deeae9ec3023594f76a8e9a2180f0716 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 13:45:50 +0100 Subject: [PATCH 04/17] otherwise it tries to load the plugin a second time from a different location - weird --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 94956b0fdfc61..350c53de19af8 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -983,7 +983,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), + 'language' => array('label' => 'Language'), ]; return $buttons; From 5a4fa04f59663cb46366fdef40cf642653b2cba3 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 15:41:57 +0100 Subject: [PATCH 05/17] .revert --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 350c53de19af8..a5cb9c80cfc8c 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -983,7 +983,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language'), + 'language' => array('label' => 'Language', 'plugin' => 'language'), ]; return $buttons; From 6dba15067052c1597df8b17340ca0fb4b39a30ff Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 15:42:44 +0100 Subject: [PATCH 06/17] cs --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index a5cb9c80cfc8c..5b30207a8cbbd 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -983,7 +983,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'language'), + 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), ]; return $buttons; From 5b6d13ca0d19e23c4f00f3255276712d809e92b3 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Mon, 12 Oct 2020 22:07:50 +0100 Subject: [PATCH 07/17] update js --- build/build-modules-js/init.es6.js | 1 + plugins/editors/tinymce/tinymce.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index 0885fca1bdd78..b3797af94b8fa 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -239,6 +239,7 @@ const copyFiles = (options) => { let constants = ''; if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { constants = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/constants.js'), { encoding: 'utf8' }); + constants = constants.replace('export { BROWSER_DEFAULT, languages }', ''); } if (constants) { finalPluginCode = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'), { encoding: 'utf8' }); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 5b30207a8cbbd..41f7bce61ee3e 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -983,7 +983,6 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), ]; return $buttons; From 219f29301ac1cc928d5b7369fa709e678a0a205a Mon Sep 17 00:00:00 2001 From: brian teeman Date: Tue, 20 Oct 2020 20:59:50 +0100 Subject: [PATCH 08/17] regex --- build/build-modules-js/init.es6.js | 2 +- plugins/editors/tinymce/tinymce.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index b3797af94b8fa..6ae975761f0db 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -239,7 +239,7 @@ const copyFiles = (options) => { let constants = ''; if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { constants = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/constants.js'), { encoding: 'utf8' }); - constants = constants.replace('export { BROWSER_DEFAULT, languages }', ''); + constants = constants.replace('export {\n BROWSER_DEFAULT,\n languages\n}', ''); } if (constants) { finalPluginCode = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'), { encoding: 'utf8' }); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 41f7bce61ee3e..824c3ebe847cd 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -982,6 +982,7 @@ public static function getKnownButtons() 'template' => array('label' => 'Insert template', 'plugin' => 'template'), 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), + 'Language' => array('label' => 'Language', 'plugin' => 'language'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), ]; @@ -1044,7 +1045,7 @@ public static function getToolbarPreset() 'fullscreen', '|', 'table', '|', 'subscript', 'superscript', '|', - 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', 'language', '|', + 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', 'Language', '|', 'cut', 'copy', 'paste', 'pastetext', '|', 'visualchars', 'visualblocks', 'nonbreaking', 'blockquote', 'template', '|', 'print', 'preview', 'codesample', 'insertdatetime', 'removeformat', 'jxtdbuttons' From e6a23ac3fff1bdc4444f047ff6dd96ba76895210 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Tue, 6 Oct 2020 14:24:54 +0100 Subject: [PATCH 09/17] [4.0] language of parts --- build/build-modules-js/init.es6.js | 18 ++++++++++++++++ .../javascript/minify-vendor.es6.js | 1 + build/build-modules-js/settings.json | 21 +++++++++++++++++++ plugins/editors/tinymce/forms/setoptions.xml | 11 ++++++++++ plugins/editors/tinymce/tinymce.php | 11 +++++++++- 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index ff3d6c6436253..690e393e98d54 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -2,6 +2,7 @@ const Copydir = require('copy-dir'); const Fs = require('fs'); const FsExtra = require('fs-extra'); const Path = require('path'); +const { plugin } = require('postcss'); const RootPath = process.cwd(); const xmlVersionStr = /()(.+)(<\/version>)/; @@ -232,6 +233,23 @@ const copyFiles = (options) => { let tinyWrongMap = Fs.readFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, { encoding: 'UTF-8' }); tinyWrongMap = tinyWrongMap.replace('/*# sourceMappingURL=skin.min.css.map */', ''); Fs.writeFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, tinyWrongMap, { encoding: 'UTF-8' }); + } else if (packageName === 'tinymce-language-selector') { + // const itemvendorPath = Path.join(RootPath, `media/vendor/${packageName}`); + + // if (!FsExtra.existsSync(itemvendorPath)) { + // FsExtra.mkdirSync(itemvendorPath); + // FsExtra.mkdirSync(Path.join(itemvendorPath, 'tinymce-language-selector')); + // } + // eslint-disable-next-line no-console + console.log('################################################################'); + concatFiles( + [ + 'media/vendor/tinymce-language-selector/js/constants.js', + 'media/vendor/tinymce-language-selector/js/plugin.js', + + ], + 'media/vendor/tinymce-language-selector/plugin.js', + ); } else { ['js', 'css', 'filesExtra'].forEach((type) => { if (!vendor[type]) return; diff --git a/build/build-modules-js/javascript/minify-vendor.es6.js b/build/build-modules-js/javascript/minify-vendor.es6.js index 0d54a05642dcf..d134a2793f635 100644 --- a/build/build-modules-js/javascript/minify-vendor.es6.js +++ b/build/build-modules-js/javascript/minify-vendor.es6.js @@ -14,6 +14,7 @@ module.exports.compile = () => { const folders = [ Path.join(RootPath, 'media/vendor/codemirror'), Path.join(RootPath, 'media/vendor/punycode/js'), + Path.join(RootPath, 'media/vendor/tinymce-language-selector/js'), Path.join(RootPath, 'media/vendor/webcomponentsjs'), ]; diff --git a/build/build-modules-js/settings.json b/build/build-modules-js/settings.json index 276c31954dd8f..3c7e932243720 100644 --- a/build/build-modules-js/settings.json +++ b/build/build-modules-js/settings.json @@ -97,6 +97,27 @@ "dependencies": [], "licenseFilename": "LICENSE" }, + "@edx/tinymce-language-selector": { + "name": "tinymce-language-selector", + "js": { + "tinymce-language-selector/constants.js": "js/constants.js", + "tinymce-language-selector/plugin.js": "js/plugin.js" + }, + "provideAssets": [ + { + "name": "constants", + "type": "script", + "uri": "constants.js" + }, + { + "name": "plugin", + "type": "script", + "uri": "plugin.js" + } + ], + "dependencies": [], + "licenseFilename": "LICENSE" + }, "cropperjs": { "name": "cropperjs", "js": { diff --git a/plugins/editors/tinymce/forms/setoptions.xml b/plugins/editors/tinymce/forms/setoptions.xml index 671f0e5f065ed..46fda7eb16bae 100644 --- a/plugins/editors/tinymce/forms/setoptions.xml +++ b/plugins/editors/tinymce/forms/setoptions.xml @@ -35,6 +35,17 @@ hide_none="true" /> + + + + + get('language', 1); + + if ($jlangparts) + { + $externalPlugins['language'] = HTMLHelper::_('script', 'plg_editors_tinymce/plugins/language/plugin.min.js', ['relative' => true, 'version' => 'auto', 'pathOnly' => true]); + } + // Convert pt to px in dropdown $scriptOptions['fontsize_formats'] = '8px 10px 12px 14px 18px 24px 36px'; @@ -984,6 +992,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), + 'language' => array('label' => 'Language', 'plugin' => 'language'), ]; return $buttons; @@ -1046,7 +1055,7 @@ public static function getToolbarPreset() 'fullscreen', '|', 'table', '|', 'subscript', 'superscript', '|', - 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', '|', + 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', 'language', '|', 'cut', 'copy', 'paste', 'pastetext', '|', 'visualchars', 'visualblocks', 'nonbreaking', 'blockquote', 'template', '|', 'print', 'preview', 'codesample', 'insertdatetime', 'removeformat', 'jxtdbuttons' From 734097b2b7b4fa189e381e3f9fb03a1151717a9c Mon Sep 17 00:00:00 2001 From: brian teeman Date: Tue, 6 Oct 2020 14:27:49 +0100 Subject: [PATCH 10/17] oops --- build/build-modules-js/init.es6.js | 1 - 1 file changed, 1 deletion(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index 690e393e98d54..40da5ea421354 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -2,7 +2,6 @@ const Copydir = require('copy-dir'); const Fs = require('fs'); const FsExtra = require('fs-extra'); const Path = require('path'); -const { plugin } = require('postcss'); const RootPath = process.cwd(); const xmlVersionStr = /()(.+)(<\/version>)/; From 27baa7104e2711811b566ed471429e0075b50721 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 10:24:24 +0100 Subject: [PATCH 11/17] wip --- build/build-modules-js/compilejs.es6.js | 2 ++ build/build-modules-js/init.es6.js | 32 +++++++++++--------- build/build-modules-js/settings.json | 16 ---------- plugins/editors/tinymce/forms/setoptions.xml | 11 ------- plugins/editors/tinymce/tinymce.php | 9 ++---- 5 files changed, 21 insertions(+), 49 deletions(-) diff --git a/build/build-modules-js/compilejs.es6.js b/build/build-modules-js/compilejs.es6.js index e4cf2c3bd6581..03645f9b7bc22 100644 --- a/build/build-modules-js/compilejs.es6.js +++ b/build/build-modules-js/compilejs.es6.js @@ -55,6 +55,8 @@ module.exports.compileJS = (options, path) => { }, ); }); + // hack, needs a bundler + HandleFile.run('media/plg_editors_tinymce/js/plugins/tinymce-language-selector/plugin.es6.js'); }) // Handle errors diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index 40da5ea421354..145ed239ab6ca 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -232,23 +232,25 @@ const copyFiles = (options) => { let tinyWrongMap = Fs.readFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, { encoding: 'UTF-8' }); tinyWrongMap = tinyWrongMap.replace('/*# sourceMappingURL=skin.min.css.map */', ''); Fs.writeFileSync(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, tinyWrongMap, { encoding: 'UTF-8' }); - } else if (packageName === 'tinymce-language-selector') { - // const itemvendorPath = Path.join(RootPath, `media/vendor/${packageName}`); + } else if (packageName === '@edx/tinymce-language-selector') { + // This whole section actually needs a bundler like rollup + let finalPluginCode = ''; + if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { + let constants = ''; + if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { + constants = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/constants.js'), { encoding: 'utf8' }); + } + if (constants) { + finalPluginCode = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'), { encoding: 'utf8' }); + finalPluginCode = finalPluginCode.replace('import { BROWSER_DEFAULT, languages } from \'./constants\';', constants); - // if (!FsExtra.existsSync(itemvendorPath)) { - // FsExtra.mkdirSync(itemvendorPath); - // FsExtra.mkdirSync(Path.join(itemvendorPath, 'tinymce-language-selector')); - // } - // eslint-disable-next-line no-console - console.log('################################################################'); - concatFiles( - [ - 'media/vendor/tinymce-language-selector/js/constants.js', - 'media/vendor/tinymce-language-selector/js/plugin.js', + FsExtra.mkdirpSync('media/plg_editors_tinymce/js/plugins/tinymce-language-selector'); - ], - 'media/vendor/tinymce-language-selector/plugin.js', - ); + Fs.writeFileSync('media/plg_editors_tinymce/js/plugins/tinymce-language-selector/plugin.es6.js', finalPluginCode, { encoding: 'utf8' }); + + FsExtra.mkdirpSync('media/vendor/tinymce-language-selector/js'); + } + } } else { ['js', 'css', 'filesExtra'].forEach((type) => { if (!vendor[type]) return; diff --git a/build/build-modules-js/settings.json b/build/build-modules-js/settings.json index 3c7e932243720..5babe1c39257a 100644 --- a/build/build-modules-js/settings.json +++ b/build/build-modules-js/settings.json @@ -99,22 +99,6 @@ }, "@edx/tinymce-language-selector": { "name": "tinymce-language-selector", - "js": { - "tinymce-language-selector/constants.js": "js/constants.js", - "tinymce-language-selector/plugin.js": "js/plugin.js" - }, - "provideAssets": [ - { - "name": "constants", - "type": "script", - "uri": "constants.js" - }, - { - "name": "plugin", - "type": "script", - "uri": "plugin.js" - } - ], "dependencies": [], "licenseFilename": "LICENSE" }, diff --git a/plugins/editors/tinymce/forms/setoptions.xml b/plugins/editors/tinymce/forms/setoptions.xml index 46fda7eb16bae..671f0e5f065ed 100644 --- a/plugins/editors/tinymce/forms/setoptions.xml +++ b/plugins/editors/tinymce/forms/setoptions.xml @@ -35,17 +35,6 @@ hide_none="true" /> - - - - - get('language', 1); - - if ($jlangparts) - { - $externalPlugins['language'] = HTMLHelper::_('script', 'plg_editors_tinymce/plugins/language/plugin.min.js', ['relative' => true, 'version' => 'auto', 'pathOnly' => true]); - } + $externalPlugins['language'] = HTMLHelper::_('script', 'plg_editors_tinymce/plugins/tinymce-language-selector/plugin.min.js', ['relative' => true, 'version' => 'auto', 'pathOnly' => true]); // Convert pt to px in dropdown $scriptOptions['fontsize_formats'] = '8px 10px 12px 14px 18px 24px 36px'; @@ -992,7 +987,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'language'), + 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), ]; return $buttons; From 519a92e8291c60dbd396dd34c5e47cd36fa77c1c Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 13:45:50 +0100 Subject: [PATCH 12/17] otherwise it tries to load the plugin a second time from a different location - weird --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 801e0e2207d59..6e3d3f2d418da 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -987,7 +987,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), + 'language' => array('label' => 'Language'), ]; return $buttons; From 854ba25e808b4a8454456a06c9a7f83702633133 Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 15:41:57 +0100 Subject: [PATCH 13/17] .revert --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 6e3d3f2d418da..3666996b0cf05 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -987,7 +987,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language'), + 'language' => array('label' => 'Language', 'plugin' => 'language'), ]; return $buttons; From 090c95dec071d0bdd0f85a796874aef8156f1fbd Mon Sep 17 00:00:00 2001 From: brian teeman Date: Wed, 7 Oct 2020 15:42:44 +0100 Subject: [PATCH 14/17] cs --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 3666996b0cf05..c8ff8fca8a602 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -987,7 +987,7 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'language'), + 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), ]; return $buttons; From c56bc0243bf8f194c23f3199211567cacdd690fe Mon Sep 17 00:00:00 2001 From: brian teeman Date: Mon, 12 Oct 2020 22:07:50 +0100 Subject: [PATCH 15/17] update js --- build/build-modules-js/init.es6.js | 1 + plugins/editors/tinymce/tinymce.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index 145ed239ab6ca..f07a62f677fc2 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -239,6 +239,7 @@ const copyFiles = (options) => { let constants = ''; if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { constants = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/constants.js'), { encoding: 'utf8' }); + constants = constants.replace('export { BROWSER_DEFAULT, languages }', ''); } if (constants) { finalPluginCode = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'), { encoding: 'utf8' }); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index c8ff8fca8a602..a04687aef2ac1 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -987,7 +987,6 @@ public static function getKnownButtons() 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), - 'language' => array('label' => 'Language', 'plugin' => 'tinymce-language-selector'), ]; return $buttons; From ed463720aaac146045af57ebe3ac34c71af3642f Mon Sep 17 00:00:00 2001 From: brian teeman Date: Tue, 20 Oct 2020 20:59:50 +0100 Subject: [PATCH 16/17] regex --- build/build-modules-js/init.es6.js | 2 +- plugins/editors/tinymce/tinymce.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/build-modules-js/init.es6.js b/build/build-modules-js/init.es6.js index f07a62f677fc2..85b320020ed4b 100644 --- a/build/build-modules-js/init.es6.js +++ b/build/build-modules-js/init.es6.js @@ -239,7 +239,7 @@ const copyFiles = (options) => { let constants = ''; if (Fs.existsSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'))) { constants = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/constants.js'), { encoding: 'utf8' }); - constants = constants.replace('export { BROWSER_DEFAULT, languages }', ''); + constants = constants.replace('export {\n BROWSER_DEFAULT,\n languages\n}', ''); } if (constants) { finalPluginCode = Fs.readFileSync(Path.join(modulePathRoot, 'tinymce-language-selector/plugin.js'), { encoding: 'utf8' }); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index a04687aef2ac1..2264507fd8395 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -986,6 +986,7 @@ public static function getKnownButtons() 'template' => array('label' => 'Insert template', 'plugin' => 'template'), 'searchreplace' => array('label' => 'Find and replace', 'plugin' => 'searchreplace'), 'insertdatetime' => array('label' => 'Insert date/time', 'plugin' => 'insertdatetime'), + 'Language' => array('label' => 'Language', 'plugin' => 'language'), // 'spellchecker' => array('label' => 'Spellcheck', 'plugin' => 'spellchecker'), ]; @@ -1049,7 +1050,7 @@ public static function getToolbarPreset() 'fullscreen', '|', 'table', '|', 'subscript', 'superscript', '|', - 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', 'language', '|', + 'charmap', 'emoticons', 'media', 'hr', 'ltr', 'rtl', 'Language', '|', 'cut', 'copy', 'paste', 'pastetext', '|', 'visualchars', 'visualblocks', 'nonbreaking', 'blockquote', 'template', '|', 'print', 'preview', 'codesample', 'insertdatetime', 'removeformat', 'jxtdbuttons' From f20f48d0a99beb5aaaa498d17bc139e327aef2fd Mon Sep 17 00:00:00 2001 From: brian teeman Date: Sun, 15 Nov 2020 14:51:31 +0000 Subject: [PATCH 17/17] final fix? --- package-lock.json | 37 +++++++++++++++++++++++++++++++++++-- package.json | 3 +-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index c85ae351595fe..d57162ec9a838 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1216,6 +1216,11 @@ "resolved": "https://registry.npmjs.org/@claviska/jquery-minicolors/-/jquery-minicolors-2.3.5.tgz", "integrity": "sha512-LpiN8hyqRPYB2tEzFD4lI54GxKHQXhzrJMnKnsumElYxjkjbdAPmiIm+1k/Mkfn92HepL7t9uaK5iQSFP/19aw==" }, + "@edx/tinymce-language-selector": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@edx/tinymce-language-selector/-/tinymce-language-selector-1.1.0.tgz", + "integrity": "sha512-yw+JVsq8vRMsTeSY8xjDIlV8xHh9HweZzz1AXPgMtrcS7gEAIYE0G0899ULICV/slBCWdYnTp1oDnDH9DanQ9w==" + }, "@eslint/eslintrc": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.1.tgz", @@ -2620,6 +2625,16 @@ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bl": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", @@ -5530,6 +5545,13 @@ "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.2.tgz", "integrity": "sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw==" }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -6600,7 +6622,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -8207,6 +8229,13 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, + "nan": { + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", + "dev": true, + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -12787,7 +12816,11 @@ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "dev": true, - "optional": true + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } }, "glob-parent": { "version": "3.1.0", diff --git a/package.json b/package.json index 052dfb497a480..8b81a441c3445 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,8 @@ ], "dependencies": { "@claviska/jquery-minicolors": "^2.3.5", - "@webcomponents/webcomponentsjs": "^2.5.0", - "@edx/tinymce-language-selector": "^1.1.0", "@webcomponents/webcomponentsjs": "^2.4.4", + "@edx/tinymce-language-selector": "^1.1.0", "accessibility": "^3.0.10", "awesomplete": "1.1.5", "bootstrap": "^4.5.3",