lilium-text
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -18,6 +18,17 @@ class LiliumTextCommand { | ||
el.addEventListener('click', (ev) => { | ||
el.addEventListener('mousedown', ev => { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
return false; | ||
}); | ||
el.addEventListener('mouseup', (ev) => { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
editor.log('Executed command ' + this.webName + (this.param ? (" with parameter '" + this.param + "'") : '')); | ||
editor.fire('command', this.webName); | ||
this.execute(ev, this, editor); | ||
return false; | ||
}); | ||
@@ -40,2 +51,14 @@ | ||
highlightNode(node) { | ||
const selection = this.editor.restoreSelection(); | ||
const range = document.createRange(); | ||
this.editor.log("Highlighting node " + node.nodeName + " from Web Command"); | ||
range.selectNode(node); | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
this.editor.storeRange(range); | ||
} | ||
executeText() { | ||
@@ -92,2 +115,4 @@ const selection = this.editor.restoreSelection(); | ||
selection.getRangeAt(0).insertNode(newElem); | ||
this.highlightNode(newElem); | ||
} else if (!leftExistWrap != !rightExistWrap) { | ||
@@ -744,11 +769,15 @@ // Apparently there is no XOR in Javascript, so here's a syntax monstrosity | ||
storeRange() { | ||
const tempSelection = window.getSelection(); | ||
storeRange(maybeRange) { | ||
if (maybeRange) { | ||
this._tempRange = maybeRange; | ||
} else { | ||
const tempSelection = window.getSelection(); | ||
if (tempSelection.type == "None" || !tempSelection.focusNode) { | ||
const range = document.createRange(); | ||
range.setStart(this.contentel, 0); | ||
this._tempRange = range; | ||
} else { | ||
this._tempRange = tempSelection.getRangeAt(0).cloneRange(); | ||
if (tempSelection.type == "None" || !tempSelection.focusNode) { | ||
const range = document.createRange(); | ||
range.setStart(this.contentel, 0); | ||
this._tempRange = range; | ||
} else { | ||
this._tempRange = tempSelection.getRangeAt(0).cloneRange(); | ||
} | ||
} | ||
@@ -755,0 +784,0 @@ |
{ | ||
"name": "lilium-text", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Web rich text editor. Ready to be used in a test environment.", | ||
@@ -5,0 +5,0 @@ "main": "build/liliumtext.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1383529
2022