mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-23 20:55:47 +00:00
removed some duplicate code
This commit is contained in:
parent
49b876a704
commit
b020b243e9
1 changed files with 12 additions and 12 deletions
|
|
@ -703,35 +703,35 @@
|
|||
lineIndex = cursorLocation.lineIndex,
|
||||
charIndex = cursorLocation.charIndex;
|
||||
|
||||
if (isBeginningOfLine) {
|
||||
this._removeStyleObject(isBeginningOfLine, cursorLocation, lineIndex, charIndex);
|
||||
},
|
||||
|
||||
var textOnPreviousLine = this._textLines[lineIndex - 1],
|
||||
newCharIndexOnPrevLine = textOnPreviousLine
|
||||
? textOnPreviousLine.length
|
||||
: 0;
|
||||
_getTextOnPreviousLine: function(lIndex) {
|
||||
return this._textLines[lIndex - 1];
|
||||
},
|
||||
|
||||
_removeStyleObject: function(isBeginningOfLine, cursorLocation, lineIndex, charIndex) {
|
||||
|
||||
if (isBeginningOfLine) {
|
||||
var textOnPreviousLine = this._getTextOnPreviousLine(cursorLocation.lineIndex),
|
||||
newCharIndexOnPrevLine = textOnPreviousLine ? textOnPreviousLine.length : 0;
|
||||
|
||||
if (!this.styles[lineIndex - 1]) {
|
||||
this.styles[lineIndex - 1] = {};
|
||||
}
|
||||
|
||||
for (charIndex in this.styles[lineIndex]) {
|
||||
this.styles[lineIndex - 1][parseInt(charIndex, 10) + newCharIndexOnPrevLine]
|
||||
= this.styles[lineIndex][charIndex];
|
||||
}
|
||||
|
||||
this.shiftLineStyles(lineIndex, -1);
|
||||
|
||||
this.shiftLineStyles(cursorLocation.lineIndex, -1);
|
||||
}
|
||||
else {
|
||||
var currentLineStyles = this.styles[lineIndex];
|
||||
|
||||
if (currentLineStyles) {
|
||||
delete currentLineStyles[charIndex];
|
||||
//console.log('deleting', lineIndex, charIndex + offset);
|
||||
}
|
||||
|
||||
var currentLineStylesCloned = clone(currentLineStyles);
|
||||
|
||||
// shift all styles by 1 backwards
|
||||
for (var i in currentLineStylesCloned) {
|
||||
var numericIndex = parseInt(i, 10);
|
||||
|
|
|
|||
Loading…
Reference in a new issue