Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] language of parts [a11y] #30939

Closed
wants to merge 18 commits into from
2 changes: 2 additions & 0 deletions build/build-modules-js/compilejs.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions build/build-modules-js/init.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,26 @@ 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 === '@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' });
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' });
finalPluginCode = finalPluginCode.replace('import { BROWSER_DEFAULT, languages } from \'./constants\';', constants);

FsExtra.mkdirpSync('media/plg_editors_tinymce/js/plugins/tinymce-language-selector');

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;
Expand Down
1 change: 1 addition & 0 deletions build/build-modules-js/javascript/minify-vendor.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
];

Expand Down
5 changes: 5 additions & 0 deletions build/build-modules-js/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
"dependencies": [],
"licenseFilename": "LICENSE"
},
"@edx/tinymce-language-selector": {
"name": "tinymce-language-selector",
"dependencies": [],
"licenseFilename": "LICENSE"
},
"cropperjs": {
"name": "cropperjs",
"js": {
Expand Down
37 changes: 35 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
],
"dependencies": {
"@claviska/jquery-minicolors": "^2.3.5",
"@webcomponents/webcomponentsjs": "^2.5.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",
Expand Down
6 changes: 5 additions & 1 deletion plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ public function onDisplay(
$scriptOptions['comMediaAdapter'] = 'local-0:';
}

// Language of parts plugin
$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';

Expand Down Expand Up @@ -983,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'),
];

Expand Down Expand Up @@ -1046,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'
Expand Down