 README.txt                                         |    5 ++++-
 js/createjs/editingWidgets/drupalckeditorwidget.js |   20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/README.txt b/README.txt
index 25e6325..d10908a 100644
--- a/README.txt
+++ b/README.txt
@@ -18,7 +18,10 @@ In-place WYSIWYG editing using CKEditor
    Note that *only* the CKEditor module is supported, not any other module, like
    the "Wysiwyg" module (http://drupal.org/project/wysiwyg).
 2. Go to http://ckeditor.com/download and download the Standard or Full package.
-3. Extract the dowwnloaded package to sites/all/libraries/ckeditor. For maximum
+   If you use the "Source" button, then you go to http://ckeditor.com/builder,
+   select Standard or Full, add the "Source Dialog" plugin and then download
+   a custom build.
+3. Extract the downloaded package to sites/all/libraries/ckeditor. For maximum
    security, it is recommended to delete the included "samples" directory at
    sites/all/libraries/ckeditor/samples.
 4. Go to admin/config/content/ckeditor/, enable one of the CKEditor profiles for
diff --git a/js/createjs/editingWidgets/drupalckeditorwidget.js b/js/createjs/editingWidgets/drupalckeditorwidget.js
index ddc5105..14a9efb 100644
--- a/js/createjs/editingWidgets/drupalckeditorwidget.js
+++ b/js/createjs/editingWidgets/drupalckeditorwidget.js
@@ -161,11 +161,31 @@ jQuery.widget('DrupalEditEditor.ckeditor', jQuery.DrupalEditEditor.direct, {
     // toolbar at all. (CKEditor doesn't need a floated toolbar.)
     if (mainToolbarId) {
       var settingsOverride = {
+        extraPlugins: 'sharedspace',
         removePlugins: 'floatingspace,elementspath',
         sharedSpaces: {
           top: mainToolbarId
         }
       };
+
+      // Find the "Source" button, if any, and replace it with "Sourcedialog".
+      // (The 'sourcearea' plugin only works in CKEditor's iframe mode.)
+      var sourceButtonFound = false;
+      for (var i = 0; !sourceButtonFound && i < settings.toolbar.length; i++) {
+        if (settings.toolbar[i] !== '/') {
+          for (var j = 0; !sourceButtonFound && j < settings.toolbar[i].length; j++) {
+            if (settings.toolbar[i][j] === 'Source') {
+              sourceButtonFound = true;
+              // Swap sourcearea's "Source" button for sourcedialog's.
+              settings.toolbar[i][j] = 'Sourcedialog';
+              settingsOverride.extraPlugins += ',sourcedialog';
+              settingsOverride.removePlugins += ',sourcearea';
+            }
+          }
+        }
+      }
+
+      settings.extraPlugins += ',' + settingsOverride.extraPlugins;
       settings.removePlugins += ',' + settingsOverride.removePlugins;
       settings.sharedSpaces = settingsOverride.sharedSpaces;
     }
