Skip to content

Commit

Permalink
Fix callbacks (#3082)
Browse files Browse the repository at this point in the history
* Add editable as an argument for onChange callback
* Reorder and add omitted callbacks
  • Loading branch information
lqez committed Dec 12, 2018
1 parent 144ca12 commit 1d95dc8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/js/base/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class Context {
this.layoutInfo.editable.html(html);
}
this.$note.val(html);
this.triggerEvent('change', html);
this.triggerEvent('change', html, this.layoutInfo.editable);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/js/base/module/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default class Editor {
this.$editable.html(dom.html(this.$note) || dom.emptyPara);

this.$editable.on(env.inputEventName, func.debounce(() => {
this.context.triggerEvent('change', this.$editable.html());
this.context.triggerEvent('change', this.$editable.html(), this.$editable);
}, 10));

this.$editor.on('focusin', (event) => {
Expand Down Expand Up @@ -539,7 +539,7 @@ export default class Editor {
undo() {
this.context.triggerEvent('before.command', this.$editable.html());
this.history.undo();
this.context.triggerEvent('change', this.$editable.html());
this.context.triggerEvent('change', this.$editable.html(), this.$editable);
}

/*
Expand All @@ -548,7 +548,7 @@ export default class Editor {
commit() {
this.context.triggerEvent('before.command', this.$editable.html());
this.history.commit();
this.context.triggerEvent('change', this.$editable.html());
this.context.triggerEvent('change', this.$editable.html(), this.$editable);
}

/**
Expand All @@ -557,7 +557,7 @@ export default class Editor {
redo() {
this.context.triggerEvent('before.command', this.$editable.html());
this.history.redo();
this.context.triggerEvent('change', this.$editable.html());
this.context.triggerEvent('change', this.$editable.html(), this.$editable);
}

/**
Expand All @@ -577,7 +577,7 @@ export default class Editor {
this.normalizeContent();
this.history.recordUndo();
if (!isPreventTrigger) {
this.context.triggerEvent('change', this.$editable.html());
this.context.triggerEvent('change', this.$editable.html(), this.$editable);
}
}

Expand Down
17 changes: 12 additions & 5 deletions src/js/base/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,23 @@ $.summernote = $.extend($.summernote, {
maximumImageFileSize: null,

callbacks: {
onInit: null,
onFocus: null,
onBeforeCommand: null,
onBlur: null,
onBlurCodeview: null,
onChange: null,
onDialogShown: null,
onEnter: null,
onKeyup: null,
onKeydown: null,
onFocus: null,
onImageLinkInsert: null,
onImageUpload: null,
onImageUploadError: null,
onImageLinkInsert: null,
onInit: null,
onKeydown: null,
onKeyup: null,
onMousedown: null,
onMouseup: null,
onPaste: null,
onScroll: null,
},

codemirror: {
Expand Down

0 comments on commit 1d95dc8

Please sign in to comment.