mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-09 22:34:43 +00:00
CS
This commit is contained in:
parent
0cf09986ee
commit
7b581b4753
3 changed files with 19 additions and 18 deletions
|
|
@ -45,7 +45,7 @@
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
_removeExtraneousStyles: function() {
|
||||
_removeExtraneousStyles: function () {
|
||||
//for (var prop in this._styleMap) {
|
||||
// if (!this._textLines[prop]) {
|
||||
// delete this.styles[this._styleMap[prop].line];
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
* @param {Number} charIndex Index of a char
|
||||
* @param {Object} [style] Style object to insert, if given
|
||||
*/
|
||||
insertCharStyleObject: function(lineIndex, charIndex, style) {
|
||||
insertCharStyleObject: function (lineIndex, charIndex, style) {
|
||||
// adjust lineIndex and charIndex
|
||||
var map = this._styleMap[lineIndex];
|
||||
lineIndex = map.line;
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
* @param {Number} charIndex Index of a char
|
||||
* @param {Boolean} isEndOfLine True if it's end of line
|
||||
*/
|
||||
insertNewlineStyleObject: function(lineIndex, charIndex, isEndOfLine) {
|
||||
insertNewlineStyleObject: function (lineIndex, charIndex, isEndOfLine) {
|
||||
// adjust lineIndex and charIndex
|
||||
var map = this._styleMap[lineIndex];
|
||||
lineIndex = map.line;
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
* @param {Number} lineIndex Index of a line
|
||||
* @param {Number} offset Can be -1 or +1
|
||||
*/
|
||||
shiftLineStyles: function(lineIndex, offset) {
|
||||
shiftLineStyles: function (lineIndex, offset) {
|
||||
// shift all line styles by 1 upward
|
||||
var clonedStyles = clone(this.styles);
|
||||
|
||||
|
|
@ -119,10 +119,10 @@
|
|||
* @returns {String}
|
||||
* @private
|
||||
*/
|
||||
_getTextOnPreviousLine: function(lineIndex) {
|
||||
_getTextOnPreviousLine: function (lineIndex) {
|
||||
var textOnPreviousLine = this._textLines[lineIndex - 1];
|
||||
|
||||
while(this._styleMap[lineIndex - 2] && this._styleMap[lineIndex - 2].line === this._styleMap[lineIndex - 1].line) {
|
||||
while (this._styleMap[lineIndex - 2] && this._styleMap[lineIndex - 2].line === this._styleMap[lineIndex - 1].line) {
|
||||
textOnPreviousLine = this._textLines[lineIndex - 2] + textOnPreviousLine;
|
||||
|
||||
lineIndex--;
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
* @param {Boolean} isBeginningOfLine True if cursor is at the beginning of line
|
||||
* @param {Number} [index] Optional index. When not given, current selectionStart is used.
|
||||
*/
|
||||
removeStyleObject: function(isBeginningOfLine, index) {
|
||||
removeStyleObject: function (isBeginningOfLine, index) {
|
||||
|
||||
var cursorLocation = this.get2DCursorLocation(index),
|
||||
map = this._styleMap[cursorLocation.lineIndex],
|
||||
|
|
@ -148,7 +148,7 @@
|
|||
newCharIndexOnPrevLine = textOnPreviousLine ? textOnPreviousLine.length : 0;
|
||||
|
||||
if (!this.styles[lineIndex - 1]) {
|
||||
this.styles[lineIndex - 1] = { };
|
||||
this.styles[lineIndex - 1] = {};
|
||||
}
|
||||
|
||||
for (charIndex in this.styles[lineIndex]) {
|
||||
|
|
|
|||
|
|
@ -259,8 +259,9 @@
|
|||
return styles;
|
||||
}
|
||||
|
||||
var loc = this.get2DCursorLocation(startIndex);
|
||||
var style = this._getStyleDeclaration(loc.lineIndex, loc.charIndex);
|
||||
var loc = this.get2DCursorLocation(startIndex),
|
||||
style = this._getStyleDeclaration(loc.lineIndex, loc.charIndex);
|
||||
|
||||
return style || {};
|
||||
},
|
||||
|
||||
|
|
@ -917,7 +918,7 @@
|
|||
* @private
|
||||
*/
|
||||
_getStyleDeclaration: function(lineIndex, charIndex, returnCloneOrEmpty) {
|
||||
if(returnCloneOrEmpty) {
|
||||
if (returnCloneOrEmpty) {
|
||||
return (this.styles[lineIndex] && this.styles[lineIndex][charIndex])
|
||||
? clone(this.styles[lineIndex][charIndex])
|
||||
: { };
|
||||
|
|
|
|||
|
|
@ -76,19 +76,19 @@
|
|||
},
|
||||
|
||||
_generateStyleMap: function() {
|
||||
var realLineCount = 0;
|
||||
var realLineCharCount = 0;
|
||||
var charCount = 0;
|
||||
var map = {};
|
||||
var realLineCount = 0,
|
||||
realLineCharCount = 0,
|
||||
charCount = 0,
|
||||
map = {};
|
||||
|
||||
for(var i = 0; i < this._textLines.length; i++) {
|
||||
if(this.text[charCount] === '\n') {
|
||||
for (var i = 0; i < this._textLines.length; i++) {
|
||||
if (this.text[charCount] === '\n') {
|
||||
realLineCharCount = 0;
|
||||
charCount++;
|
||||
realLineCount++;
|
||||
}
|
||||
|
||||
map[i] = {line: realLineCount, offset: realLineCharCount};
|
||||
map[i] = { line: realLineCount, offset: realLineCharCount };
|
||||
|
||||
charCount += this._textLines[i].length;
|
||||
realLineCharCount += this._textLines[i].length;
|
||||
|
|
|
|||
Loading…
Reference in a new issue