Skip to content

Commit

Permalink
summernote#348 onChange callback added.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed May 1, 2014
1 parent b323ab2 commit 2bad01b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
15 changes: 13 additions & 2 deletions dist/summernote.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright 2013 Alan Hong. and outher contributors
* summernote may be freely distributed under the MIT license./
*
* Date: 2014-04-26T04:47Z
* Date: 2014-05-01T09:25Z
*/
(function (factory) {
/* global define */
Expand Down Expand Up @@ -2635,18 +2635,29 @@
if (event.keyCode === key.ENTER) { options.onenter(event); }
});
}

if (options.onfocus) { oLayoutInfo.editable.focus(options.onfocus); }
if (options.onblur) { oLayoutInfo.editable.blur(options.onblur); }
if (options.onkeyup) { oLayoutInfo.editable.keyup(options.onkeyup); }
if (options.onkeydown) { oLayoutInfo.editable.keydown(options.onkeydown); }
if (options.onpaste) { oLayoutInfo.editable.on('paste', options.onpaste); }
if (options.onToolbarClick) { oLayoutInfo.toolbar.click(options.onToolbarClick); }
if (options.onChange) {
var handler = function () {
options.onChange(oLayoutInfo.editable, oLayoutInfo.editable.html());
};

if (agent.bMSIE) {
oLayoutInfo.editable.on('DOMCharacterDataModified, DOMSubtreeModified, DOMNodeInserted', handler);
} else {
oLayoutInfo.editable.on('input', handler);
}
}

// callbacks for advanced features (camel)
// All editor status will be saved on editable with jquery's data
// for support multiple editor with singleton object.
oLayoutInfo.editable.data('callbacks', {
onChange: options.onChange,
onAutoSave: options.onAutoSave,
onImageUpload: options.onImageUpload,
onImageUploadError: options.onImageUploadError,
Expand Down
2 changes: 1 addition & 1 deletion dist/summernote.min.js

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ <h4>Lately library
<span class="label label-success">font-awesome v4.0.3</span>
<span class="label label-danger">CodeMirror v3.20.0</span>
</h4>
<div class="summernote">
<!-- mockup for table-feature
<table class="table table-bordered">
<tbody>
<tr><td>1x1</td><td>1x2</td></tr>
<tr><td>2x1</td><td>2x2</td></tr>
</tbody>
</table>
-->
</div>
<div class="summernote"></div>
</div>
<script type="text/javascript">
less = {
Expand Down
13 changes: 12 additions & 1 deletion src/js/EventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,29 @@ define([
if (event.keyCode === key.ENTER) { options.onenter(event); }
});
}

if (options.onfocus) { oLayoutInfo.editable.focus(options.onfocus); }
if (options.onblur) { oLayoutInfo.editable.blur(options.onblur); }
if (options.onkeyup) { oLayoutInfo.editable.keyup(options.onkeyup); }
if (options.onkeydown) { oLayoutInfo.editable.keydown(options.onkeydown); }
if (options.onpaste) { oLayoutInfo.editable.on('paste', options.onpaste); }
if (options.onToolbarClick) { oLayoutInfo.toolbar.click(options.onToolbarClick); }
if (options.onChange) {
var handler = function () {
options.onChange(oLayoutInfo.editable, oLayoutInfo.editable.html());
};

if (agent.bMSIE) {
oLayoutInfo.editable.on('DOMCharacterDataModified, DOMSubtreeModified, DOMNodeInserted', handler);
} else {
oLayoutInfo.editable.on('input', handler);
}
}

// callbacks for advanced features (camel)
// All editor status will be saved on editable with jquery's data
// for support multiple editor with singleton object.
oLayoutInfo.editable.data('callbacks', {
onChange: options.onChange,
onAutoSave: options.onAutoSave,
onImageUpload: options.onImageUpload,
onImageUploadError: options.onImageUploadError,
Expand Down

0 comments on commit 2bad01b

Please sign in to comment.