fixes mainly for fabric on canvas: fix insertNewlineStyleObject, check if currentChar lineIndex exists; fix shiftLineStyles, delete previous lines after shifting

This commit is contained in:
Milan Wanielik 2015-05-11 18:46:44 +02:00
parent c71a1c2049
commit c824c8a8da

View file

@ -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