From 23276cef59e0cd5e3bcdf2ca33014d3b257ee7b8 Mon Sep 17 00:00:00 2001
From: Matteo Pozzani <m.phobos@gmail.com>
Date: Fri, 25 Feb 2022 10:58:26 +0100
Subject: [PATCH 1/5] added language, startView, minViewMode, maxViewMode
 properties to BootstrapDatePicker

---
 src/bootstrapdatepicker.js | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/bootstrapdatepicker.js b/src/bootstrapdatepicker.js
index 1df1c969..0ea802a9 100644
--- a/src/bootstrapdatepicker.js
+++ b/src/bootstrapdatepicker.js
@@ -45,6 +45,12 @@ function init(Survey, $) {
           category: "general",
           default: "mm/dd/yyyy",
         },
+        {
+          // Can take a string
+          name: "language",
+          category: "general",
+          default: "en",
+        },
         {
           // Can take a Date or a string
           // https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#options
@@ -69,6 +75,21 @@ function init(Survey, $) {
           category: "general",
           default: 0,
         },
+        {
+          name: "startView:number",
+          category: "general",
+          default: 0,
+        },
+        {
+          name: "minViewMode:number",
+          category: "general",
+          default: 0,
+        },
+        {
+          name: "maxViewMode:number",
+          category: "general",
+          default: 4,
+        },
         {
           name: "clearBtn:boolean",
           category: "general",
@@ -103,8 +124,12 @@ function init(Survey, $) {
       const options = {
         enableOnReadonly: false,
         format: question.dateFormat,
+        language: question.language,
         todayHighlight: question.todayHighlight,
         weekStart: question.weekStart,
+        startView: question.startView,
+        minViewMode: question.minViewMode,
+        maxViewMode: question.maxViewMode,
         clearBtn: question.clearBtn,
         autoclose: question.autoClose,
         daysOfWeekDisabled: question.daysOfWeekDisabled,

From 397e2a6df2c672cde668a84947c68bcfeb3bc1e9 Mon Sep 17 00:00:00 2001
From: Matteo Pozzani <m.phobos@gmail.com>
Date: Thu, 5 May 2022 09:43:25 +0200
Subject: [PATCH 2/5] CK editor properties

---
 src/ck-editor.js | 57 +++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 6 deletions(-)

diff --git a/src/ck-editor.js b/src/ck-editor.js
index ce3c15b6..1f92d902 100644
--- a/src/ck-editor.js
+++ b/src/ck-editor.js
@@ -15,18 +15,63 @@ function init(Survey) {
       "<textarea rows='10' cols='80' style: {width:'100%'}></textarea>",
     activatedByChanged: function (activatedBy) {
       Survey.JsonObject.metaData.addClass("editor", [], null, "empty");
-      Survey.JsonObject.metaData.addProperty("editor", {
-        name: "height",
-        default: 300,
-        category: "general",
-      });
+      Survey.JsonObject.metaData.addProperties("editor",[ 
+        {
+          name: "height",
+          default: 300,
+          category: "general",
+        },
+        {
+          name: "language",
+          default: "en",
+          category: "general"
+        },
+        {
+          name: "defaultLanguage",
+          default: "en",
+          category: "general"
+        }
+      ]);
     },
     afterRender: function (question, el) {
       var name = question.inputId;
       CKEDITOR.editorConfig = function (config) {
-        config.language = "es";
+        config.defaultLanguage = question.language;
+        config.language = question.language;
         config.height = question.height;
         config.toolbarCanCollapse = true;
+
+        // Define changes to default configuration here.
+        // For complete reference see:
+        // https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html
+
+        // The toolbar groups arrangement, optimized for two toolbar rows.
+        config.toolbarGroups = [
+          { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
+          // { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
+          // { name: 'links' },
+          // { name: 'insert' },
+          // { name: 'forms' },
+          { name: 'tools' },
+          // { name: 'document',	   groups: [ 'mode', 'document', 'doctools' ] },
+          // { name: 'others' },
+          '/',
+          { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
+          { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
+          { name: 'styles' },
+          { name: 'colors' }
+          // { name: 'about' }
+        ];
+
+        // Remove some buttons provided by the standard plugins, which are
+        // not needed in the Standard(s) toolbar.
+        config.removeButtons = 'Underline,Subscript,Superscript';
+
+        // Set the most common block elements.
+        config.format_tags = 'p;h1;h2;h3;pre';
+
+        // Simplify the dialog windows.
+        config.removeDialogTabs = 'image:advanced;link:advanced';
       };
       el.name = name;
 

From 445189ae52842f67f2183f05b57ad066d094be7d Mon Sep 17 00:00:00 2001
From: Matteo Pozzani <m.phobos@gmail.com>
Date: Thu, 5 May 2022 09:43:52 +0200
Subject: [PATCH 3/5] iCheck default values

---
 src/icheck.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/icheck.js b/src/icheck.js
index c5c49b6b..ab7282f0 100644
--- a/src/icheck.js
+++ b/src/icheck.js
@@ -8,9 +8,9 @@ function escValue(val) {
 function init(Survey, $) {
   $ = $ || window.$;
   var widget = {
-    className: "iradio_square-blue",
-    checkboxClass: "iradio_square-blue",
-    radioClass: "iradio_square-blue",
+    className: "iradio_flat-green",
+    checkboxClass: "icheckbox_flat-green",
+    radioClass: "iradio_flat-green",
     name: "icheck",
     widgetIsLoaded: function () {
       return typeof $ == "function" && !!$.fn.iCheck;

From 1749f420450fd6b0a1cefc3b3cf4cc6dcc4caf0f Mon Sep 17 00:00:00 2001
From: Matteo Pozzani <m.phobos@gmail.com>
Date: Thu, 5 May 2022 09:44:26 +0200
Subject: [PATCH 4/5] Summernote fix value set

---
 src/summernote.js | 147 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 147 insertions(+)
 create mode 100644 src/summernote.js

diff --git a/src/summernote.js b/src/summernote.js
new file mode 100644
index 00000000..da42be15
--- /dev/null
+++ b/src/summernote.js
@@ -0,0 +1,147 @@
+function init(Survey) {
+  const iconId = "icon-editor";
+  Survey.SvgRegistry && Survey.SvgRegistry.registerIconFromSvg(iconId, require('svg-inline-loader!./images/editor.svg'), "");
+  var widget = {
+    name: "summernote",
+    title: "Editor",
+    iconName: iconId,
+    widgetIsLoaded: function () {
+      return typeof $ == "function" && !!$.fn.summernote;
+    },
+    isFit: function (question) {
+      return question.getType() === "summernote";
+    },
+    htmlTemplate:
+      '<textarea class="form-control widget-summernote" rows="10" cols="80" style: {width:"100%"}></textarea>',
+    activatedByChanged: function (activatedBy) {
+      Survey.JsonObject.metaData.addClass("summernote", [], null, "text");
+      Survey.JsonObject.metaData.addProperties("summernote",[ 
+        // {
+        //   name: "height",
+        //   default: 300,
+        //   category: "general",
+        // },
+        {
+          name: "lang",
+          default: "en",
+          category: "general"
+        },
+        {
+          name: "placeholder",
+          default: "",
+          category: "general"
+        },
+        {
+          name: "toolbar",
+          default: [
+            ['style', ['bold', 'italic', 'underline', 'clear']],
+            ['para', ['ul', 'ol', 'paragraph']]
+          ],
+          category:"general"
+        },
+        {
+          name:"hint",
+          default: {},
+          category:"general"
+        },
+        {
+          name: "disableDragAndDrop:boolean",
+          default: true,
+          category:"general"
+        },        
+        {
+          name: "shortcuts:boolean",
+          default: false,
+          category:"general"
+        },
+        {
+          name: "codeviewFilter:boolean",
+          default: true,
+          category:"general"
+        },
+        {
+          name: "codeviewIFrameFilter:boolean",
+          default: true,
+          category:"general"
+        }
+      ]);
+    },
+    afterRender: function (question, el) {
+      var $el = $(el).is('.widget-summernote') 
+        ? $(el) 
+        : $(el).find('.widget-summernote');
+      const options = {
+        lang: question.language,
+        placeholder: question.placeholder,
+        toolbar: [['style', ['bold', 'italic', 'underline', 'clear']],
+        ['para', ['ul', 'ol', 'paragraph']]]
+      };
+      const summernoteWidget = $el.summernote(options).on("summernote.change", function (we, contents, $editable) {
+        if (question.value != contents) {
+          question.value = contents;
+        }
+      });
+
+      question.valueChangedCallback = function () {
+        var oldValue = summernoteWidget.summernote('code');
+        if(oldValue != question.value)
+         summernoteWidget.summernote(
+           "code",
+           !!question.value ? question.value : ""
+         );
+      };
+      question.valueChangedCallback();
+      question.readOnlyChangedCallback = function () {
+        if (question.isReadOnly) {
+          summernoteWidget.summernote('disable');
+        } else {
+          summernoteWidget.summernote('enable');
+        }
+      };
+      question.readOnlyChangedCallback();
+
+    },
+    willUnmount: function (question, el) {
+      var $el = $(el).is(".widget-summernote")
+        ? $(el)
+        : $(el).find(".widget-summernote");
+      $el.summernote("destroy");
+      question.valueChangedCallback = null;
+      question.readOnlyChangedCallback = null;
+    },
+    pdfQuestionType: "text",
+    // pdfRender: function (survey, options) {
+    //   if (options.question.getType() === "editor") {
+    //     const loc = new Survey.LocalizableString(survey, true);
+    //     loc.text = options.question.value || options.question.defaultValue;
+    //     options.question["locHtml"] = loc;
+    //     if (
+    //       options.question.renderAs === "standard" ||
+    //       options.question.renderAs === "image"
+    //     ) {
+    //       options.question["renderAs"] = options.question.renderAs;
+    //     } else options.question["renderAs"] = "auto";
+    //     const flatHtml = options.repository.create(
+    //       survey,
+    //       options.question,
+    //       options.controller,
+    //       "html"
+    //     );
+    //     return new Promise(function (resolve) {
+    //       flatHtml.generateFlats(options.point).then(function (htmlBricks) {
+    //         options.bricks = htmlBricks;
+    //         resolve();
+    //       });
+    //     });
+    //   }
+    // },
+  };
+
+  Survey.CustomWidgetCollection.Instance.addCustomWidget(widget, "customtype");
+}
+
+if (typeof Survey !== "undefined") {
+  init(Survey);
+}
+
+export default init;

From e2706f7d69f10270e02c30405ef9dd66189d1394 Mon Sep 17 00:00:00 2001
From: Matteo Pozzani <m.phobos@gmail.com>
Date: Thu, 5 May 2022 09:48:05 +0200
Subject: [PATCH 5/5] disabled microphone widget

---
 src/surveyjs-widgets.js | 1 +
 webpack.config.js       | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/surveyjs-widgets.js b/src/surveyjs-widgets.js
index 3caa7ffa..7bd6f9b6 100644
--- a/src/surveyjs-widgets.js
+++ b/src/surveyjs-widgets.js
@@ -13,3 +13,4 @@ export { default as bootstrapslider } from "./bootstrap-slider.js";
 export { default as microphone } from "./microphone.js";
 export { default as emotionsratings } from "./emotionsratings.js";
 export { default as bootstrapdatepicker } from "./bootstrapdatepicker.js";
+export { default as summernote } from "./summernote.js";
diff --git a/webpack.config.js b/webpack.config.js
index 1240e8a3..6b1a1633 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -36,8 +36,9 @@ var widgets = [
   "easy-autocomplete",
   "pretty-checkbox",
   "bootstrap-slider",
-  "microphone",
-  "emotionsratings"
+ // "microphone",
+  "emotionsratings",
+  "summernote"
 ];
 
 var dependencies = {