define(['Dom/Util'], function(DomUtil) {
"use strict";
+ var _isValidSelection = function(editorElement) {
+ var element = window.getSelection().anchorNode;
+ while (element) {
+ if (element === editorElement) {
+ return true;
+ }
+
+ element = element.parentNode;
+ }
+
+ return false;
+ };
+
/**
* @exports WoltLabSuite/Core/Ui/Redactor/Format
*/
return;
}
+ if (!_isValidSelection(editorElement)) {
+ console.error("Invalid selection, range exists outside of the editor:", selection.anchorNode);
+ return;
+ }
+
var range = selection.getRangeAt(0);
var markerStart = null, markerEnd = null, tmpElement = null;
if (range.collapsed) {
* @param {string} property CSS property that should be removed
*/
removeFormat: function(editorElement, property) {
+ var selection = window.getSelection();
+ if (!selection.rangeCount) {
+ return;
+ }
+ else if (!_isValidSelection(editorElement)) {
+ console.error("Invalid selection, range exists outside of the editor:", selection.anchorNode);
+ return;
+ }
+
var strikeElements = elByTag('strike', editorElement);
// remove any <strike> element first, all though there shouldn't be any at all