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 b57263fa0359a0bec274562fd2cd03c4b888a3af
parent cee53f23684f3d76ceda2a25147fe8a9a0a11edc
Author: unitehenry <unitehenry@gmail.com>
Date:   Fri, 23 Oct 2020 17:48:13 -0400

quality assurance

Diffstat:
Msrc/striveneditor.css | 2+-
Msrc/striveneditor.js | 22+++++++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/striveneditor.css b/src/striveneditor.css @@ -46,7 +46,7 @@ position: absolute; left: 0; top: 100%; - padding: 2px 5px; + padding: 7px; background-color: #fff; min-width: max-content; border: 1px solid #ddd; diff --git a/src/striveneditor.js b/src/striveneditor.js @@ -1444,16 +1444,17 @@ export default class StrivenEditor { const windowRow = linkMenuForm.cloneNode(true); const windowRowLabel = windowRow.querySelector('.se-form-label'); const windowRowInput = windowRow.querySelector('.se-form-input'); - + if (windowRow) { windowRow.setAttribute( 'style', - 'justify-content: flex-end; align-items: center;', + 'justify-content: flex-end; align-items: center; flex-direction: row-reverse', ); } if (windowRowLabel) { - windowRowLabel.innerText = 'Open in new window?'; + windowRowLabel.innerText = 'Open in new window'; + windowRowLabel.style.marginLeft = '5px'; } if (windowRowInput) { @@ -2131,6 +2132,11 @@ export default class StrivenEditor { const se = this; const body = se.pruneScripts(se.body); + + // Remove contenteditable tags for body + [...body.querySelectorAll('[contenteditable="true"]')] + .forEach(ce => ce.removeAttribute('contenteditable')); + const text = body.textContent; if (text || se.body.getElementsByTagName('img').length) { @@ -2376,6 +2382,9 @@ export default class StrivenEditor { se.linkMenu.submitEvt = submitEvt; window.addEventListener('keyup', se.linkMenu.submitEvt); + + + } /** @@ -2948,11 +2957,13 @@ export default class StrivenEditor { link.classList.add('se-link-to-edit'); se.openLinkMenu(); - + const linkInputs = se.linkMenu.querySelectorAll('input'); linkInputs[0]['value'] = link.getAttribute('href'); linkInputs[1]['value'] = link.textContent; linkInputs[2]['checked'] = (link.getAttribute('target') === '_blank'); + + setTimeout(() => linkInputs[0].select(), 100); } linkOptions.append(changeOption); @@ -3113,6 +3124,7 @@ export default class StrivenEditor { if (opt.getAttribute('data-fullscreen')) { se.editor.collapse && se.editor.collapse(); + se.options.onFullscreenCollapse() && se.options.onFullscreenCollapse(); } else { blowUpElement(se.editor, '#fff', e => { opt.original = se.body.innerHTML; @@ -3345,8 +3357,8 @@ export default class StrivenEditor { const selection = se.linkMenu.querySelector( 'input[placeholder="Text content"]', ); + selection && (selection.value = document.getSelection().toString()); - se.linkMenu.querySelector('input').select(); }, 100);