From 46bdefaae83afb85e22b7647b3b143afed9e8eac Mon Sep 17 00:00:00 2001 From: Buwy1 <54263552+Buwy1@users.noreply.github.com> Date: Tue, 5 Nov 2019 12:20:55 +0530 Subject: [PATCH] Revert "Added null check for ignore issue when delete the hyperlink text and the toolbar is visible" --- src/doc.js | 70 ++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/src/doc.js b/src/doc.js index 0699337..d58244f 100644 --- a/src/doc.js +++ b/src/doc.js @@ -345,19 +345,17 @@ var prototype = node.derive({ runs: function(emit, range) { var startDetails = this.wordContainingOrdinal(Math.max(0, range.start)), endDetails = this.wordContainingOrdinal(Math.min(range.end, this.frame.length - 1)); - if (startDetails && endDetails) { - if (startDetails.index === endDetails.index) { - startDetails.word.runs(emit, { - start: startDetails.offset, - end: endDetails.offset - }); - } else { - startDetails.word.runs(emit, { start: startDetails.offset }); - for (var n = startDetails.index + 1; n < endDetails.index; n++) { - this.words[n].runs(emit); - } - endDetails.word.runs(emit, { end: endDetails.offset }); + if (startDetails.index === endDetails.index) { + startDetails.word.runs(emit, { + start: startDetails.offset, + end: endDetails.offset + }); + } else { + startDetails.word.runs(emit, { start: startDetails.offset }); + for (var n = startDetails.index + 1; n < endDetails.index; n++) { + this.words[n].runs(emit); } + endDetails.word.runs(emit, { end: endDetails.offset }); } }, spliceWordsWithRuns: function(wordIndex, count, runs, takeFocus) { @@ -441,44 +439,38 @@ var prototype = node.derive({ endWord = this.wordContainingOrdinal(end); var prefix; - if(startWord) { - if (start === startWord.ordinal) { - if (startWord.index > 0 && !isBreaker(this.words[startWord.index - 1])) { - startWord.index--; - var previousWord = this.words[startWord.index]; - prefix = per({}).per(previousWord.runs, previousWord).all(); - } else { - prefix = []; - } + if (start === startWord.ordinal) { + if (startWord.index > 0 && !isBreaker(this.words[startWord.index - 1])) { + startWord.index--; + var previousWord = this.words[startWord.index]; + prefix = per({}).per(previousWord.runs, previousWord).all(); } else { - prefix = per({ end: startWord.offset }) - .per(startWord.word.runs, startWord.word) - .all(); + prefix = []; } + } else { + prefix = per({ end: startWord.offset }) + .per(startWord.word.runs, startWord.word) + .all(); } var suffix; - if(endWord) { - if (end === endWord.ordinal) { - if ((end === this.frame.length - 1) || isBreaker(endWord.word)) { - suffix = []; - endWord.index--; - } else { - suffix = per({}).per(endWord.word.runs, endWord.word).all(); - } + if (end === endWord.ordinal) { + if ((end === this.frame.length - 1) || isBreaker(endWord.word)) { + suffix = []; + endWord.index--; } else { - suffix = per({ start: endWord.offset }) - .per(endWord.word.runs, endWord.word) - .all(); + suffix = per({}).per(endWord.word.runs, endWord.word).all(); } + } else { + suffix = per({ start: endWord.offset }) + .per(endWord.word.runs, endWord.word) + .all(); } var oldLength = this.frame.length; - if(startWord && endWord) { - this.spliceWordsWithRuns(startWord.index, (endWord.index - startWord.index) + 1, - per(prefix).concat(text).concat(suffix).per(runs.consolidate( this.defaultFormatting )).all(), takeFocus); - } + this.spliceWordsWithRuns(startWord.index, (endWord.index - startWord.index) + 1, + per(prefix).concat(text).concat(suffix).per(runs.consolidate( this.defaultFormatting )).all(), takeFocus); return this.frame ? (this.frame.length - oldLength) : 0; },