Skip to content

Commit

Permalink
fix: change extra places where spellchecker language not defaulting t…
Browse files Browse the repository at this point in the history
…o en_GB VOL-5907 (#532)
  • Loading branch information
ilindsay authored Jan 3, 2025
1 parent bc869e2 commit 34e2c7f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
89 changes: 43 additions & 46 deletions app/cdn/assets/_js/components/wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,82 @@ var OLCS = OLCS || {};
* formatting/code it spews out
*/

OLCS.wysiwyg = (function(document, $, undefined) {

'use strict';
OLCS.wysiwyg = (function (document, $, undefined) {
"use strict";

return function init() {

OLCS.eventEmitter.on('render', function() {

if (typeof(tinymce) === 'undefined') {
OLCS.eventEmitter.on("render", function () {
if (typeof tinymce === "undefined") {
return;
}

$('.tinymce').each(function() {
$(".tinymce").each(function () {
$(this).tinymce({
menubar : false,
statusbar : false,
document_base_url: '../tinymce/',
spellchecker_languages : '+English=en',
spellchecker_language : 'en',
spellchecker_rpc_url: 'index.php',
spellchecker_report_misspellings : true,
menubar: false,
statusbar: false,
document_base_url: "../tinymce/",
spellchecker_languages: "+English=en_GB",
spellchecker_language: "en_GB",
spellchecker_rpc_url: "index.php",
spellchecker_report_misspellings: true,
forced_root_blocks: false,
height : 260,
content_css : '../tinymce/skins/lightgray/custom.css',
height: 260,
content_css: "../tinymce/skins/lightgray/custom.css",
style_formats: [
{title: 'Header 1', format: 'h1'},
{title: 'Header 2', format: 'h2'},
{title: 'Header 3', format: 'h3'}
],
plugins: [
'lists charmap',
'searchreplace',
'paste spellchecker'
{ title: "Header 1", format: "h1" },
{ title: "Header 2", format: "h2" },
{ title: "Header 3", format: "h3" },
],
paste_postprocess: function(plugin, args){
var elements = args.node.getElementsByTagName('*');
for(var i = 0; i < elements.length; i ++){
elements[i].className = '';
plugins: ["lists charmap", "searchreplace", "paste spellchecker"],
paste_postprocess: function (plugin, args) {
var elements = args.node.getElementsByTagName("*");
for (var i = 0; i < elements.length; i++) {
elements[i].className = "";
}
},
paste_as_text: false,
toolbar: 'styleselect | bold italic underline | bullist numlist | indent outdent | spellchecker',
init_instance_callback: function() {
toolbar: "styleselect | bold italic underline | bullist numlist | indent outdent | spellchecker",
init_instance_callback: function () {
lockActions();
},
setup: function(editor) {
editor.on('keyup', function() {
if (tinymce.activeEditor.getContent()) {// jshint ignore:line
setup: function (editor) {
editor.on("keyup", function () {
if (tinymce.activeEditor.getContent()) {
// jshint ignore:line
unlockActions();
} else {
lockActions();
}
});
}
},
});

// If the editor was initialised in a modal, we need to remove it
// when the modal closes
OLCS.eventEmitter.on('hide:modal', function() {
OLCS.eventEmitter.on("hide:modal", function () {
tinymce.EditorManager.editors = []; // jshint ignore:line
});
});

// Upon init, we need to lock submit buttons until something actually
// gets written into tinymce editor, to prevent issues with validation
function lockActions() {
$('.modal').find('.govuk-button-group')
.children().first() // the save/submit button
.addClass('govuk-button--disabled').prop('disabled', true);
$(".modal")
.find(".govuk-button-group")
.children()
.first() // the save/submit button
.addClass("govuk-button--disabled")
.prop("disabled", true);
}

function unlockActions() {
$('.modal').find('.govuk-button-group')
.children().first() // the save/submit button
.removeClass('govuk-button--disabled').prop('disabled', false);
$(".modal")
.find(".govuk-button-group")
.children()
.first() // the save/submit button
.removeClass("govuk-button--disabled")
.prop("disabled", false);
}

});

};

}(document, window.jQuery));
})(document, window.jQuery);
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function processRequest($tinymceSpellcheckerConfig) {
header("Pragma: no-cache");

$method = self::getParam("method", "spellcheck");
$lang = self::getParam("lang", "en_US");
$lang = self::getParam("lang", "en_GB");
$text = self::getParam("text");

if ($method == "spellcheck") {
Expand Down Expand Up @@ -165,4 +165,4 @@ public static function getWords($text) {
}
}

?>
?>

0 comments on commit 34e2c7f

Please sign in to comment.