striven-editor

Maintained and contributed to an open source WYSIWYG editor as an internship project that made it to production and was adopted by the company I was working at.
git clone https://unitehenry.com/git/striven-editor.git
Log | Files | Refs | README | LICENSE

commit 1040de1ee80c4a7052d4585f33561ab921ebe37d
parent 2d3b2130c51ba979ed11af4b2de1cf02d09b7bf3
Author: Henry Unite <unitehenry@gmail.com>
Date:   Tue,  8 Sep 2020 08:44:30 -0400

fire change on fullscreen swap

Diffstat:
Mdemo/src/App.vue | 5+++++
Msrc/striveneditor.js | 5+++++
Msrc/vue-striveneditor.vue | 3++-
3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/demo/src/App.vue b/demo/src/App.vue @@ -14,6 +14,7 @@ :on-enter="submitOnEnter" :on-paste="onPaste" :after-paste="afterPaste" + :change="onChange" ></striven-editor> <!-- TESTING --> @@ -80,6 +81,10 @@ export default { this.editor = this.$refs.editor.editor; }, methods: { + onChange() { + this.editor.body.style.backgroundColor = 'green'; + setTimeout(() => this.editor.body.style.backgroundColor = null, 200); + }, afterPaste() { setTimeout(() => { [...this.editor.body.querySelectorAll('.striven-mention')] diff --git a/src/striveneditor.js b/src/striveneditor.js @@ -2805,6 +2805,10 @@ export default class StrivenEditor { if(!se.editor.oncollapse) { se.editor.oncollapse = () => { + if(opt.original !== se.body.innerHTML && se.options.change) { + se.options.change(); + } + opt.innerHTML = ''; opt.append(createSVG(EXPANDICON)); @@ -2819,6 +2823,7 @@ export default class StrivenEditor { se.editor.collapse && se.editor.collapse(); } else { blowUpElement(se.editor, '#fff', e => { + opt.original = se.body.innerHTML; opt.innerHTML = ''; opt.append(createSVG(COLLAPSEICON)); diff --git a/src/vue-striveneditor.vue b/src/vue-striveneditor.vue @@ -25,7 +25,8 @@ export default { value: String, toolbarTemplate: Function, onPaste: Function, - afterPaste: Function + afterPaste: Function, + change: Function }, mounted() { let vm = this;