From b7c9f69c5bf8e78923d1237b2c540e68c3898cb5 Mon Sep 17 00:00:00 2001
From: Lily Yan <lily.yan@uwaterloo.ca>
Date: Thu, 7 Jan 2021 15:48:23 -0500
Subject: [PATCH] ISTWCMS-4210 Add mathjax plugin

---
 src/Plugin/CKEditorPlugin/MathJaxPlugin.php | 65 +++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 src/Plugin/CKEditorPlugin/MathJaxPlugin.php

diff --git a/src/Plugin/CKEditorPlugin/MathJaxPlugin.php b/src/Plugin/CKEditorPlugin/MathJaxPlugin.php
new file mode 100644
index 00000000..bdfd952b
--- /dev/null
+++ b/src/Plugin/CKEditorPlugin/MathJaxPlugin.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Drupal\uw_cfg_common\Plugin\CKEditorPlugin;
+
+use Drupal\ckeditor\CKEditorPluginBase;
+use Drupal\editor\Entity\Editor;
+
+/**
+ * Defines the "mathjax" plugin.
+ *
+ * @CKEditorPlugin(
+ *   id = "mathjax",
+ *   label = @Translation("Mathjax")
+ * )
+ */
+class MathJaxPlugin extends CKEditorPluginBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDependencies(Editor $editor) {
+    return [
+      'clipboard',
+      'dialog',
+      'lineutils',
+      'widget',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLibraries(Editor $editor) {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfig(Editor $editor) {
+    return [
+      'mathJaxLib' => '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getButtons() {
+    return [
+      'Mathjax' => [
+        'label' => $this->t('Math'),
+        'image' => drupal_get_path('profile', 'uw_base_profile') . '/libraries/ckeditor-mathjax/icons/mathjax.png',
+      ],
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFile() {
+    return drupal_get_path('profile', 'uw_base_profile') . '/libraries/ckeditor-mathjax/plugin.js';
+  }
+
+}
-- 
GitLab