From 09141b760a4432cfeadfbc4d602935d5c65c3734 Mon Sep 17 00:00:00 2001
From: Steven H Johnson <shjohnson.pi@gmail.com>
Date: Thu, 23 Jun 2016 22:38:29 -0400
Subject: [PATCH] Add tab key shortcuts for indent/outdent in ckeditor

---
 django_usta/settings.py                         |  2 +-
 .../ckeditor/plugins/tabindent/plugin.js        | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 static/ckeditor/ckeditor/plugins/tabindent/plugin.js

diff --git a/django_usta/settings.py b/django_usta/settings.py
index 32fe1fe..2eee424 100644
--- a/django_usta/settings.py
+++ b/django_usta/settings.py
@@ -293,7 +293,7 @@ CKEDITOR_CONFIGS = {
             ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
             ['Link', 'Unlink', 'NodeLink'],
         ],
-        'extraPlugins': 'youtube,nodelink,tickets,hotels',
+        'extraPlugins': 'youtube,nodelink,tickets,hotels,tabindent',
         'removePlugins': 'iframe',
         'stylesSet': [
             {'name': 'Boys 16', 'element': 'span', 'attributes': {
diff --git a/static/ckeditor/ckeditor/plugins/tabindent/plugin.js b/static/ckeditor/ckeditor/plugins/tabindent/plugin.js
new file mode 100644
index 0000000..666ff99
--- /dev/null
+++ b/static/ckeditor/ckeditor/plugins/tabindent/plugin.js
@@ -0,0 +1,17 @@
+/**
+ * Created by Steven H Johnson - June 23, 2016
+ *
+ * Sets TAB and SHIFT + TAB keys to Indent and OutDent respectively.
+ */
+CKEDITOR.plugins.add('tabindent', {
+    requires: 'indent',
+    init: function(editor) {
+        editor.on('key', function(ev) {
+            // keyCode 9 = TAB
+            if (ev.data.keyCode == 9 && editor.execCommand('indent') ||
+                ev.data.keyCode == (CKEDITOR.SHIFT + 9) && editor.execCommand('outdent')) {
+                ev.cancel();
+            }
+        });
+    }
+});
-- 
GitLab