From ea51e758c9861f2b0b5ef5c282d6188929f7285f Mon Sep 17 00:00:00 2001
From: Paal Joergensen <pal.jorgensen@gmail.com>
Date: Thu, 10 Jun 2021 20:40:03 +0200
Subject: [PATCH] Fix bring back missing custom plugins

---
 .../plugins/customCodeHighlighter/plugin.js   | 43 +++++++++++++++++++
 .../plugins/removeRedundantNBSP/plugin.js     | 29 +++++++++++++
 2 files changed, 72 insertions(+)
 create mode 100644 ckeditor/plugins/customCodeHighlighter/plugin.js
 create mode 100644 ckeditor/plugins/removeRedundantNBSP/plugin.js

diff --git a/ckeditor/plugins/customCodeHighlighter/plugin.js b/ckeditor/plugins/customCodeHighlighter/plugin.js
new file mode 100644
index 00000000..2f191ee5
--- /dev/null
+++ b/ckeditor/plugins/customCodeHighlighter/plugin.js
@@ -0,0 +1,43 @@
+// Create a new plugin which registers a custom code highlighter
+CKEDITOR.plugins.add('customCodeHighlighter', {
+  afterInit: function (editor) {
+    var highlighter = new CKEDITOR.plugins.codesnippet.highlighter({
+      languages: {
+        apache: 'Apache',
+        bash: 'Bash',
+        coffeescript: 'CoffeeScript',
+        cpp: 'C++',
+        cs: 'C#',
+        css: 'CSS',
+        diff: 'Diff',
+        html: 'HTML',
+        http: 'HTTP',
+        ini: 'INI',
+        java: 'Java',
+        javascript: 'JavaScript',
+        json: 'JSON',
+        makefile: 'Makefile',
+        markdown: 'Markdown',
+        nginx: 'Nginx',
+        objectivec: 'Objective-C',
+        perl: 'Perl',
+        php: 'PHP',
+        python: 'Python',
+        ruby: 'Ruby',
+        sql: 'SQL',
+        vbscript: 'VBScript',
+        xhtml: 'XHTML',
+        xml: 'XML'
+      },
+      init: function (ready) {
+        // Here we should load any required resources
+        ready();
+      },
+      highlighter: function (code, language, callback) {
+        // Here we are highlighting the code and returning it.
+        callback(code);
+      }
+    });
+    editor.plugins.codesnippet.setHighlighter(highlighter);
+  }
+});
diff --git a/ckeditor/plugins/removeRedundantNBSP/plugin.js b/ckeditor/plugins/removeRedundantNBSP/plugin.js
new file mode 100644
index 00000000..e71076b7
--- /dev/null
+++ b/ckeditor/plugins/removeRedundantNBSP/plugin.js
@@ -0,0 +1,29 @@
+/*
+ * Remove &nbsp; entities which were inserted ie. when removing a space and
+ * immediately inputting a space.
+ *
+ * NB: We could also set config.basicEntities to false, but this is stongly
+ * adviced against since this also does not turn ie. < into &lt;.
+ * @link http://stackoverflow.com/a/16468264/328272
+ *
+ * Based on StackOverflow answer.
+ * @link http://stackoverflow.com/a/14549010/328272
+ */
+CKEDITOR.plugins.add('removeRedundantNBSP', {
+  afterInit: function(editor) {
+    var config = editor.config,
+      dataProcessor = editor.dataProcessor,
+      htmlFilter = dataProcessor && dataProcessor.htmlFilter;
+
+    if (htmlFilter) {
+      htmlFilter.addRules({
+        text: function(text) {
+          return text.replace(/(\w)&nbsp;/gi, '$1 ');
+        }
+      }, {
+        applyToAll: true,
+        excludeNestedEditable: true
+      });
+    }
+  }
+});
\ No newline at end of file
-- 
GitLab