diff --git a/lang/en_utf8/tinymce.php b/lang/en_utf8/tinymce.php
index 6c71704..3aaed65 100644
--- a/lang/en_utf8/tinymce.php
+++ b/lang/en_utf8/tinymce.php
@@ -729,6 +729,31 @@ $string['plugins/moodleimage_dlg:title']='Insert Image';
 $string['plugins/moodleimage_dlg:missing_alt']='Are you sure you want to continue without including an Alternate Text? Without it the image may not be accessible to some users with disabilities, or to those using a text browser, or browsing the Web with images turned off.';
 $string['plugins/moodlelink_dlg:title']='Choose file to link';
 $string['plugins/moodlenolink:desc']='Prevent automatic linking';
+$string['plugins/paintweb:toolbarButton']='Edit the selected image in PaintWeb';
+$string['plugins/paintweb:overlayButton']='Edit';
+$string['plugins/paintweb:contextMenuEdit']='Edit the image in PaintWeb';
+$string['plugins/paintweb:loading']='PaintWeb is loading...';
+$string['plugins/paintweb:statusImageEditing']='You are editing an image from TinyMCE.';
+$string['plugins/paintweb:imageSaveButton']='Save';
+$string['plugins/paintweb:cancelButton']='Cancel';
+$string['plugins/paintweb:statusEditingDataURI']='You are editing a local data URI.';
+$string['plugins/paintweb:imageSaveButtonTitle']='Save the image and return to TinyMCE.';
+$string['plugins/paintweb:cancelButtonTitle']='Cancel image edits and return to TinyMCE.';
+$string['plugins/paintweb:overlayLoading']='PaintWeb is loading...';
+$string['plugins/paintweb:statusEditingDataURL']='You are editing a local data URL.';
+$string['plugins/paintweb:statusSavingDataURL']='Saving image data URL...';
+$string['plugins/paintweb:statusSavingImage']='Saving image changes...';
+$string['plugins/paintweb:statusImageSaved']='Image save completed successfully!';
+$string['plugins/paintweb:statusImageSaveFailed']='Image save failed!';
+$string['plugins/paintweb:dlg_delta_width']='0,';
+$string['plugins/paintweb:dlg_delta_height']='0';
+$string['plugins/paintweb_dlg:dlg_title']='Create a new image';
+$string['plugins/paintweb_dlg:widthLabel']='Width: ';
+$string['plugins/paintweb_dlg:heightLabel']='Height: ';
+$string['plugins/paintweb_dlg:bgrColorLabel']='Background color: ';
+$string['plugins/paintweb_dlg:imgTitleLabel']='Title: ';
+$string['plugins/paintweb_dlg:altTextLabel']='Alternate text: ';
+$string['plugins/paintweb_dlg:altTextTitle']='This text is displayed when the image cannot render.';
 $string['plugins/example:desc']='This is just a template button';
 $string['plugins/example_dlg:title']='This is just a example title';
 $string['plugins/moodlenolink:desc']='Prevent automatic linking';
diff --git a/lib/editor/tinymce.js.php b/lib/editor/tinymce.js.php
index 6bca7a2..ce73fff 100644
--- a/lib/editor/tinymce.js.php
+++ b/lib/editor/tinymce.js.php
@@ -21,6 +21,29 @@ if (empty($CFG->tinymcehidebuttons)) {
     $CFG->tinymcehidebuttons = '';
 }
 
+if (@$CFG->tinymcePaintWeb) {
+  $paintwebButton = ',paintwebEdit';
+  $paintwebPlugin = ',paintweb';
+  $paintwebConfig = 'paintweb_config: {
+    configFile: "../ext/moodle/config.json",
+    lang: "moodle",
+    tinymce: {
+      paintwebFolder: "' . $CFG->wwwroot . '/lib/paintweb/build/",
+      imageSaveDataURL: false,
+      imageDataURLfilter: "' . $CFG->wwwroot . '/lib/paintweb/ext/moodle/imagesave.php",
+      overlayButton: true,
+      contextMenuItem: true,
+      dblclickHandler: true,
+      pluginBar: true
+    }
+},';
+
+} else {
+  $paintwebButton = '';
+  $paintwebPlugin = '';
+  $paintwebConfig = '';
+}
+
 $editorhidebuttons = str_replace(' ', ',', $CFG->tinymcehidebuttons);
 
 $editorhidebuttons1 = $editorhidebuttons . ',visualaid,styleselect';
@@ -180,7 +203,7 @@ echo <<<EOF
         entity_encoding: "raw",
         language: "$editorlanguage",
         directionality: "$directionality",
-        plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,directionality,fullscreen,moodleimage,moodlenolink,dragmath,nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
+        plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,directionality,fullscreen,moodleimage,moodlenolink,dragmath,nonbreaking,contextmenu$paintwebPlugin,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
         plugin_insertdate_dateFormat : "$strdate",
         plugin_insertdate_timeFormat : "$strtime",
         theme_advanced_font_sizes: "1,2,3,4,5,6,7",
@@ -190,7 +213,7 @@ echo <<<EOF
         theme_advanced_buttons1_add: "|,undo,redo,|,search,spellchecker",
         theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull",
         theme_advanced_buttons2_add: "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
-        theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emoticons,image,,dragmath,advhr,nonbreaking,charmap",
+        theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emoticons,image$paintwebButton,,dragmath,advhr,nonbreaking,charmap",
         theme_advanced_buttons3_add: "|,table,insertlayer,styleprops,visualchars,|,code,preview",
         theme_advanced_fonts: "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 
         theme_advanced_resize_horizontal: true,
@@ -198,6 +221,7 @@ echo <<<EOF
         theme_advanced_toolbar_location : "top",
         theme_advanced_statusbar_location : "bottom",
         file_browser_callback : "mce_moodlefilemanager",
+        $paintwebConfig
 
 EOF;
 // the xhtml ruleset must be the last one - no comma at the end of the file
diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css
index e19c146..fcfa67e 100644
--- a/theme/standard/styles_layout.css
+++ b/theme/standard/styles_layout.css
@@ -579,9 +579,6 @@ fieldset.fdate_selector label {
   text-align:right;
 }
 
-.mform input, .mform select {
-  width: auto;
-}
 .mform .ftextarea #id_alltext {
     width: 100%;
 }
