From c824c8a8da59a17a30e5e54bdc56437bc4d8f62a Mon Sep 17 00:00:00 2001 From: Milan Wanielik Date: Mon, 11 May 2015 18:46:44 +0200 Subject: [PATCH] fixes mainly for fabric on canvas: fix insertNewlineStyleObject, check if currentChar lineIndex exists; fix shiftLineStyles, delete previous lines after shifting --- src/mixins/itext_behavior.mixin.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mixins/itext_behavior.mixin.js b/src/mixins/itext_behavior.mixin.js index 6850349e..a8e74932 100644 --- a/src/mixins/itext_behavior.mixin.js +++ b/src/mixins/itext_behavior.mixin.js @@ -557,9 +557,13 @@ this.styles[lineIndex + 1] = { }; } - var currentCharStyle = this.styles[lineIndex][charIndex - 1], + var currentCharStyle = { }, newLineStyles = { }; + if(this.styles[lineIndex] && this.styles[lineIndex][charIndex - 1]) { + currentCharStyle = this.styles[lineIndex][charIndex - 1]; + } + // if there's nothing after cursor, // we clone current char style onto the next (otherwise empty) line if (isEndOfLine) { @@ -668,6 +672,9 @@ var numericLine = parseInt(line, 10); if (numericLine > lineIndex) { this.styles[numericLine + offset] = clonedStyles[numericLine]; + if(!clonedStyles[numericLine - offset]) { + delete this.styles[numericLine]; + } } } //TODO: evaluate if delete old style lines with offset -1