diff --git a/app/assets/javascripts/helpers/markdown_editor.js b/app/assets/javascripts/helpers/markdown_editor.js index 6286434375f4fafc0a9887539594d4c1ff31a9f9..5da96bbf022003953ca8c8830d2e5499a2b42dcd 100644 --- a/app/assets/javascripts/helpers/markdown_editor.js +++ b/app/assets/javascripts/helpers/markdown_editor.js @@ -9,7 +9,8 @@ Diaspora.MarkdownEditor.prototype = { this.options = { resize: "none", onHidePreview: $.noop, - onPostPreview: $.noop + onPostPreview: $.noop, + onChange: function(e) { autosize.update(e.$textarea); } }; $.extend(this.options, opts); diff --git a/spec/javascripts/helpers/markdown_editor_spec.js b/spec/javascripts/helpers/markdown_editor_spec.js index 73c0047badd9c9b535489ccf437e5edab5732490..55bc68942d12a5a4263fcf9cb57e85af06e6999d 100644 --- a/spec/javascripts/helpers/markdown_editor_spec.js +++ b/spec/javascripts/helpers/markdown_editor_spec.js @@ -31,6 +31,7 @@ describe("Diaspora.MarkdownEditor", function() { it("call $.fn.markdown with correct default options", function() { spyOn($.fn, "markdown"); + spyOn(autosize, "update"); this.target.initialize(this.$el, {}); expect($.fn.markdown).toHaveBeenCalled(); var args = $.fn.markdown.calls.mostRecent().args[0]; @@ -40,6 +41,9 @@ describe("Diaspora.MarkdownEditor", function() { expect(args.onPostPreview).toBe($.noop); expect(args.fullscreen).toEqual({enable: false, icons: {}}); expect(args.hiddenButtons).toEqual(["cmdPreview"]); + + args.onChange({$textarea: "el"}); + expect(autosize.update).toHaveBeenCalledWith("el"); }); it("overrides fullscreen, hiddenButtons, language and onShow options", function() {