diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7ff7179..6e86c9b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ X-editable changelog Version 1.4.2 wip ---------------------------- +[bug #81] wysihtml5: fix inserting image (vitalets) [bug] remove $.browser from wysihtml5 input to support jQuery 1.9 (vitalets) [bug #142] editable poshytip jquery 1.9+ compatibility (spiderpug) [enh #126] Update bootstrap datepicker library and add minViewMode to options (kev360) diff --git a/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.js b/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.js index a76b3b1..695d264 100644 --- a/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.js +++ b/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.js @@ -1,111 +1,129 @@ !function($, wysi) { "use strict"; - var templates = function(key, locale) { + var tpl = { + "font-styles": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return ""; + }, - var tpl = { - "font-styles": - "", + "emphasis": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "
    " + + "" + locale.emphasis.bold + "" + + "" + locale.emphasis.italic + "" + + "" + locale.emphasis.underline + "" + + "
    " + + "
  • "; + }, - "emphasis": - "
  • " + - "
    " + - "" + locale.emphasis.bold + "" + - "" + locale.emphasis.italic + "" + - "" + locale.emphasis.underline + "" + - "
    " + - "
  • ", + "lists": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "
    " + + "" + + "" + + "" + + "" + + "
    " + + "
  • "; + }, - "lists": - "
  • " + - "
    " + - "" + - "" + - "" + - "" + - "
    " + - "
  • ", + "link": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "" + + "" + + "
  • "; + }, - "link": - "
  • " + - "" + - "" + - "
  • ", + "image": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "" + + "" + + "
  • "; + }, - "image": - "
  • " + - "" + - "" + - "
  • ", + "html": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "
    " + + "" + + "
    " + + "
  • "; + }, - "html": - "
  • " + - "
    " + - "" + - "
    " + - "
  • ", + "color": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return ""; + } + }; - "color": - "" - }; - return tpl[key]; + var templates = function(key, locale, options) { + return tpl[key](locale, options); }; var Wysihtml5 = function(el, options) { this.el = el; - this.toolbar = this.createToolbar(el, options || defaultOptions); + var toolbarOpts = options || defaultOptions; + for(var t in toolbarOpts.customTemplates) { + tpl[t] = toolbarOpts.customTemplates[t]; + } + this.toolbar = this.createToolbar(el, toolbarOpts); this.editor = this.createEditor(options); window.editor = this.editor; @@ -125,6 +143,10 @@ createEditor: function(options) { options = options || {}; + + // Add the toolbar to a clone of the options object so multiple instances + // of the WYISYWG don't break because "toolbar" is already defined + options = $.extend(true, {}, options); options.toolbar = this.toolbar[0]; var editor = new wysi.Editor(this.el[0], options); @@ -156,7 +178,7 @@ } if(value === true) { - toolbar.append(templates(key, locale[culture])); + toolbar.append(templates(key, locale[culture], options)); if(key === "html") { this.initHtml(toolbar); @@ -208,10 +230,16 @@ var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url'); var insertButton = insertImageModal.find('a.btn-primary'); var initialValue = urlInput.val(); + var caretBookmark; var insertImage = function() { var url = urlInput.val(); urlInput.val(initialValue); + self.editor.currentView.element.focus(); + if (caretBookmark) { + self.editor.composer.selection.setBookmark(caretBookmark); + caretBookmark = null; + } self.editor.composer.commands.exec("insertImage", url); }; @@ -236,7 +264,9 @@ var activeButton = $(this).hasClass("wysihtml5-command-active"); if (!activeButton) { - insertImageModal.modal('show'); + self.editor.currentView.element.focus(false); + caretBookmark = self.editor.composer.selection.getBookmark(); + insertImageModal.appendTo('body').modal('show'); insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) { e.stopPropagation(); }); @@ -254,10 +284,16 @@ var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url'); var insertButton = insertLinkModal.find('a.btn-primary'); var initialValue = urlInput.val(); + var caretBookmark; var insertLink = function() { var url = urlInput.val(); urlInput.val(initialValue); + self.editor.currentView.element.focus(); + if (caretBookmark) { + self.editor.composer.selection.setBookmark(caretBookmark); + caretBookmark = null; + } self.editor.composer.commands.exec("createLink", { href: url, target: "_blank", @@ -287,6 +323,8 @@ var activeButton = $(this).hasClass("wysihtml5-command-active"); if (!activeButton) { + self.editor.currentView.element.focus(false); + caretBookmark = self.editor.composer.selection.getBookmark(); insertLinkModal.appendTo('body').modal('show'); insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) { e.stopPropagation(); @@ -366,7 +404,7 @@ "wysiwyg-color-blue" : 1, "wysiwyg-color-teal" : 1, "wysiwyg-color-aqua" : 1, - "wysiwyg-color-orange" : 1, + "wysiwyg-color-orange" : 1 }, tags: { "b": {}, @@ -398,7 +436,10 @@ } }, "span": 1, - "div": 1 + "div": 1, + // to allow save and edit files with code tag hacks + "code": 1, + "pre": 1 } }, stylesheets: ["./lib/css/wysiwyg-color.css"], // (path_to_project/lib/css/wysiwyg-color.css) diff --git a/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js b/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js index bfdf3b6..59d2961 100644 --- a/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js +++ b/src/inputs-ext/wysihtml5/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js @@ -1 +1 @@ -!function(a,b){"use strict";var c=function(a,b){var c={"font-styles":"",emphasis:"
  • "+b.emphasis.bold+""+""+b.emphasis.italic+""+""+b.emphasis.underline+""+"
    "+"
  • ",lists:"
  • "+""+""+""+"
    "+"
  • ",link:"
  • "+""+"
  • ",image:"
  • "+""+"
  • ",html:"
  • "+"
    "+"
  • ",color:""};return c[a]},d=function(b,c){this.el=b,this.toolbar=this.createToolbar(b,c||f),this.editor=this.createEditor(c),window.editor=this.editor,a("iframe.wysihtml5-sandbox").each(function(b,c){a(c.contentWindow).off("focus.wysihtml5").on({"focus.wysihtml5":function(){a("li.dropdown").removeClass("open")}})})};d.prototype={constructor:d,createEditor:function(a){a=a||{},a.toolbar=this.toolbar[0];var c=new b.Editor(this.el[0],a);if(a&&a.events)for(var d in a.events)c.on(d,a.events[d]);return c},createToolbar:function(b,d){var e=this,h=a("