From 9e19a41795292b7f08d91a2092b4ce74eebf9dd4 Mon Sep 17 00:00:00 2001 From: DaniBitZesty <84323332+DaniBitZesty@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:02:35 +0100 Subject: [PATCH] Remove CKEditor paste event listeners --- .../ckeditor/plugins/wordcount/plugin.js | 93 ------------------- .../international_trade_step1.rb | 2 +- public/ckeditor/plugins/wordcount/plugin.js | 93 ------------------- 3 files changed, 1 insertion(+), 187 deletions(-) diff --git a/app/assets/javascripts/ckeditor/plugins/wordcount/plugin.js b/app/assets/javascripts/ckeditor/plugins/wordcount/plugin.js index 79c4632820..911036acee 100644 --- a/app/assets/javascripts/ckeditor/plugins/wordcount/plugin.js +++ b/app/assets/javascripts/ckeditor/plugins/wordcount/plugin.js @@ -293,52 +293,6 @@ CKEDITOR.plugins.add("wordcount", { return true; } - //If the limit is already over, allow the deletion of characters/words. Otherwise, - //the user would have to delete at one go the number of offending characters - var deltaWord = wordCount - lastWordCount; - var deltaChar = charCount - lastCharCount; - - lastWordCount = wordCount; - lastCharCount = charCount; - - if (lastWordCount == -1) { - lastWordCount = wordCount; - } - if (lastCharCount == -1) { - lastCharCount = charCount; - } - - // Check for word limit and/or char limit - if ((config.maxWordCount > -1 && wordCount > maxWordCountWithBuffer(config.maxWordCount) && deltaWord > 0) || - (config.maxCharCount > -1 && charCount > config.maxCharCount && deltaChar > 0)) { - - limitReached(editorInstance, limitReachedNotified); - } else if ((config.maxWordCount == -1 || wordCount <= maxWordCountWithBuffer(config.maxWordCount)) && - (config.maxCharCount == -1 || charCount <= config.maxCharCount)) { - - limitRestored(editorInstance); - } else { - snapShot = editorInstance.getSnapshot(); - } - - // Fire Custom Events - if (config.charCountGreaterThanMaxLengthEvent && config.charCountLessThanMaxLengthEvent) { - if (charCount > config.maxCharCount && config.maxCharCount > -1) { - config.charCountGreaterThanMaxLengthEvent(charCount, config.maxCharCount); - } else { - config.charCountLessThanMaxLengthEvent(charCount, config.maxCharCount); - } - } - - if (config.wordCountGreaterThanMaxLengthEvent && config.wordCountLessThanMaxLengthEvent) { - if (wordCount > maxWordCountWithBuffer(config.maxWordCount) && config.maxWordCount > -1) { - config.wordCountGreaterThanMaxLengthEvent(wordCount, config.maxWordCount); - - } else { - config.wordCountLessThanMaxLengthEvent(wordCount, config.maxWordCount); - } - } - return true; } @@ -381,53 +335,6 @@ CKEDITOR.plugins.add("wordcount", { updateCounter(event.editor); }, editor, null, 100); - editor.on("paste", function(event) { - if (config.maxWordCount > 0 || config.maxCharCount > 0) { - - // Check if pasted content is above the limits - var wordCount = -1, - charCount = -1, - text = event.editor.getData() + event.data.dataValue; - - - if (config.showCharCount) { - charCount = countCharacters(text, event.editor); - } - - if (config.showWordCount) { - wordCount = countWords(text); - } - - - // Instantiate the notification when needed and only have one instance - if(notification === null) { - notification = new CKEDITOR.plugins.notification(event.editor, { - message: event.editor.lang.wordcount.pasteWarning, - type: 'warning', - duration: config.pasteWarningDuration - }); - } - - if (config.maxCharCount > 0 && charCount > config.maxCharCount && config.hardLimit) { - if(!notification.isVisible()) { - notification.show(); - } - event.cancel(); - } - - if (config.maxWordCount > 0 && wordCount > maxWordCountWithBuffer(config.maxWordCount) && config.hardLimit) { - if(!notification.isVisible()) { - notification.show(); - } - event.cancel(); - } - } - }, editor, null, 100); - - editor.on("afterPaste", function (event) { - updateCounter(event.editor); - }, editor, null, 100); - editor.on("blur", function () { if (intervalId) { window.clearInterval(intervalId); diff --git a/forms/award_years/v2025/international_trade/international_trade_step1.rb b/forms/award_years/v2025/international_trade/international_trade_step1.rb index 31d76214c5..236833e4e8 100644 --- a/forms/award_years/v2025/international_trade/international_trade_step1.rb +++ b/forms/award_years/v2025/international_trade/international_trade_step1.rb @@ -186,7 +186,7 @@ def trade_step1 textarea :major_issues_overcome, "Please explain any major issues that you have overcome in recent years and the remedial steps you have taken." do ref "A 2.2" - classes "sub-question" + classes "sub-question text-words-max" required context %(

For example, what steps did you take following a major Health and Safety incident.

diff --git a/public/ckeditor/plugins/wordcount/plugin.js b/public/ckeditor/plugins/wordcount/plugin.js index 79c4632820..911036acee 100644 --- a/public/ckeditor/plugins/wordcount/plugin.js +++ b/public/ckeditor/plugins/wordcount/plugin.js @@ -293,52 +293,6 @@ CKEDITOR.plugins.add("wordcount", { return true; } - //If the limit is already over, allow the deletion of characters/words. Otherwise, - //the user would have to delete at one go the number of offending characters - var deltaWord = wordCount - lastWordCount; - var deltaChar = charCount - lastCharCount; - - lastWordCount = wordCount; - lastCharCount = charCount; - - if (lastWordCount == -1) { - lastWordCount = wordCount; - } - if (lastCharCount == -1) { - lastCharCount = charCount; - } - - // Check for word limit and/or char limit - if ((config.maxWordCount > -1 && wordCount > maxWordCountWithBuffer(config.maxWordCount) && deltaWord > 0) || - (config.maxCharCount > -1 && charCount > config.maxCharCount && deltaChar > 0)) { - - limitReached(editorInstance, limitReachedNotified); - } else if ((config.maxWordCount == -1 || wordCount <= maxWordCountWithBuffer(config.maxWordCount)) && - (config.maxCharCount == -1 || charCount <= config.maxCharCount)) { - - limitRestored(editorInstance); - } else { - snapShot = editorInstance.getSnapshot(); - } - - // Fire Custom Events - if (config.charCountGreaterThanMaxLengthEvent && config.charCountLessThanMaxLengthEvent) { - if (charCount > config.maxCharCount && config.maxCharCount > -1) { - config.charCountGreaterThanMaxLengthEvent(charCount, config.maxCharCount); - } else { - config.charCountLessThanMaxLengthEvent(charCount, config.maxCharCount); - } - } - - if (config.wordCountGreaterThanMaxLengthEvent && config.wordCountLessThanMaxLengthEvent) { - if (wordCount > maxWordCountWithBuffer(config.maxWordCount) && config.maxWordCount > -1) { - config.wordCountGreaterThanMaxLengthEvent(wordCount, config.maxWordCount); - - } else { - config.wordCountLessThanMaxLengthEvent(wordCount, config.maxWordCount); - } - } - return true; } @@ -381,53 +335,6 @@ CKEDITOR.plugins.add("wordcount", { updateCounter(event.editor); }, editor, null, 100); - editor.on("paste", function(event) { - if (config.maxWordCount > 0 || config.maxCharCount > 0) { - - // Check if pasted content is above the limits - var wordCount = -1, - charCount = -1, - text = event.editor.getData() + event.data.dataValue; - - - if (config.showCharCount) { - charCount = countCharacters(text, event.editor); - } - - if (config.showWordCount) { - wordCount = countWords(text); - } - - - // Instantiate the notification when needed and only have one instance - if(notification === null) { - notification = new CKEDITOR.plugins.notification(event.editor, { - message: event.editor.lang.wordcount.pasteWarning, - type: 'warning', - duration: config.pasteWarningDuration - }); - } - - if (config.maxCharCount > 0 && charCount > config.maxCharCount && config.hardLimit) { - if(!notification.isVisible()) { - notification.show(); - } - event.cancel(); - } - - if (config.maxWordCount > 0 && wordCount > maxWordCountWithBuffer(config.maxWordCount) && config.hardLimit) { - if(!notification.isVisible()) { - notification.show(); - } - event.cancel(); - } - } - }, editor, null, 100); - - editor.on("afterPaste", function (event) { - updateCounter(event.editor); - }, editor, null, 100); - editor.on("blur", function () { if (intervalId) { window.clearInterval(intervalId);