Skip to content

Commit

Permalink
Merge pull request danielearwicker#49 from creately/revert-48-bug/hyp…
Browse files Browse the repository at this point in the history
…erlink-index-error

Revert "Added null check for ignore issue when delete the hyperlink text and the toolbar is visible"
  • Loading branch information
Buwy1 authored Nov 5, 2019
2 parents 19124b2 + 46bdefa commit 399e9d5
Showing 1 changed file with 31 additions and 39 deletions.
70 changes: 31 additions & 39 deletions src/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
},
Expand Down

0 comments on commit 399e9d5

Please sign in to comment.