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 fe5a3ab43c8dd8313f33a215e8ebc9e444a470dc
parent 14d827418f88c17d8e6e2f9ff172fbdde49354c3
Author: Henry Unite <unitehenry@gmail.com>
Date:   Tue,  8 Sep 2020 08:56:12 -0400

Merge branch 'dev'

Diffstat:
Mdemo/src/App.vue | 5+++++
Mpackage.json | 2+-
Msrc/striveneditor.css | 6------
Msrc/striveneditor.js | 14++++++++++++++
Msrc/vue-striveneditor.vue | 3++-
5 files changed, 22 insertions(+), 8 deletions(-)

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/package.json b/package.json @@ -1,7 +1,7 @@ { "name": "@striven-erp/striven-editor", "private": false, - "version": "3.6.4", + "version": "3.6.5", "description": "The editor used for the Striven ERP system.", "main": "./dist", "scripts": { diff --git a/src/striveneditor.css b/src/striveneditor.css @@ -228,12 +228,6 @@ background-color: transparent; } -@media (max-width: 500px) { - .striven-editor .se-toolbar .se-toolbar-selection { - display: none; - } -} - /* .striven-editor .se-toolbar .se-toolbar-selection .se-toolbar-option { border: 1px solid #ddd; diff --git a/src/striveneditor.js b/src/striveneditor.js @@ -1858,6 +1858,15 @@ export default class StrivenEditor { } }); + [...that.toolbar.getElementsByClassName('se-toolbar-selection')] + .forEach(sl => { + sl.style.display = isResponsive ? 'none' : null; + const { nextElementSibling } = sl; + if(nextElementSibling.classList.contains('se-divider-section')) { + nextElementSibling.style.display = isResponsive ? 'none' : null; + } + }) + } function setResponsive() { @@ -2809,6 +2818,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)); @@ -2823,6 +2836,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;