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 aeffed9f6bfdb3525d76b4082647377bcd00ed06
parent dd8f77e334d6bfee66e5b4ffa532cd23c29e2d77
Author: unitehenry <unitehenry@gmail.com>
Date:   Wed, 18 Mar 2020 15:17:00 -0400

editor change event

Diffstat:
Mpackage.json | 2+-
Msrc/striveneditor.css | 19++++++++++---------
Msrc/striveneditor.js | 41++++++++++++++++++++++++++++++++---------
3 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/package.json b/package.json @@ -1,7 +1,7 @@ { "name": "@striven-erp/striven-editor", "private": false, - "version": "3.1.1", + "version": "3.1.4", "description": "The lightweight zero-dependency Striven WYSIWYG editor.", "main": "./dist", "scripts": { diff --git a/src/striveneditor.css b/src/striveneditor.css @@ -29,19 +29,20 @@ word-break: break-word; } +.striven-editor .se-body h1, +.striven-editor .se-body h2, +.striven-editor .se-body h3, +.striven-editor .se-body h4, +.striven-editor .se-body h5, +.striven-editor .se-body h6 { + color: #000; +} + .striven-editor .se-body:empty::after { content: attr(data-placeholder); color: #777; } -.striven-editor .se-body table { - width: 100%; -} - -.striven-editor .se-body td { - border: 1px solid #ddd; -} - .striven-editor .se-body .se-file-drop-dropzone { height: 90%; width: 95%; @@ -128,7 +129,7 @@ } .striven-editor .se-toolbar-group[data-open='true'] { - z-index: 500; + z-index: 1000; } /* diff --git a/src/striveneditor.js b/src/striveneditor.js @@ -33,8 +33,10 @@ export default class StrivenEditor { el.data_orig = el.innerHTML; }); el.addEventListener('blur', function() { - if (el.innerHTML != el.data_orig) se.options.change(se.getContent()); - delete el.data_orig; + setTimeout(() => { + if (el.innerHTML != el.data_orig && (document.activeElement != se.body)) se.options.change(se.getContent()); + delete el.data_orig; + }, 100); }); } @@ -557,13 +559,34 @@ export default class StrivenEditor { const menu = initMenu('fontFormat'); const formats = [ - {command: 'H1', option: '<h1 style="margin: 0; color: #000;">Heading 1</h1>'}, - {command: 'H2', option: '<h2 style="margin: 0; color: #000;">Heading 2</h2>'}, - {command: 'H3', option: '<h3 style="margin: 0; color: #000;">Heading 3</h4>'}, - {command: 'H4', option: '<h4 style="margin: 0; color: #000;">Heading 4</h4>'}, - {command: 'H5', option: '<h5 style="margin: 0; color: #000;">Heading 5</h5>'}, - {command: 'H6', option: '<h6 style="margin: 0; color: #000;">Heading 6</h6>'}, - {command: 'P', option: '<p style="margin: 0; color: #000;">Paragraph</p>'}, + { + command: 'H1', + option: '<h1 style="margin: 0; color: #000;">Heading 1</h1>', + }, + { + command: 'H2', + option: '<h2 style="margin: 0; color: #000;">Heading 2</h2>', + }, + { + command: 'H3', + option: '<h3 style="margin: 0; color: #000;">Heading 3</h4>', + }, + { + command: 'H4', + option: '<h4 style="margin: 0; color: #000;">Heading 4</h4>', + }, + { + command: 'H5', + option: '<h5 style="margin: 0; color: #000;">Heading 5</h5>', + }, + { + command: 'H6', + option: '<h6 style="margin: 0; color: #000;">Heading 6</h6>', + }, + { + command: 'P', + option: '<p style="margin: 0; color: #000;">Paragraph</p>', + }, ]; formats.forEach(s => {