mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
packaged 2.2.0 (#4785)
This commit is contained in:
parent
abbeb91763
commit
a7f62f564d
5 changed files with 103 additions and 60 deletions
|
|
@ -1,7 +1,14 @@
|
|||
**Version 2.2.0**
|
||||
- Fixed: super/sub script svg export [#4780](https://github.com/kangax/fabric.js/pull/4780)
|
||||
- Added: Text superScript and subScript support [#4765](https://github.com/kangax/fabric.js/pull/4765)
|
||||
- Fixed: negative kerning support (Pacifico font) [#4772](https://github.com/kangax/fabric.js/pull/4772)
|
||||
- Fixed: removing text on mousedown should be safe now [#4774](https://github.com/kangax/fabric.js/pull/4774)
|
||||
- Improved: pass to inner functions the parameter calculate coords in isOnscreen [#4763](https://github.com/kangax/fabric.js/pull/4763)
|
||||
|
||||
**Version 2.1.0**
|
||||
- Added: Added: Drag and drop event binding [#4421](https://github.com/kangax/fabric.js/pull/4421)
|
||||
- Fixed: isEmptyStyle implementation for TextBox [#4762](https://github.com/kangax/fabric.js/pull/4762)
|
||||
|
||||
|
||||
**Version 2.0.3**
|
||||
- Fix: now sub target check can work with subclasses of fabric.Group [#4753](https://github.com/kangax/fabric.js/pull/4753)
|
||||
- Improvement: PencilBrush is now compexity 1 instead of complexity N during draw [#4743](https://github.com/kangax/fabric.js/pull/4743)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: '2.1.0' };
|
||||
var fabric = fabric || { version: '2.2.0' };
|
||||
if (typeof exports !== 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
}
|
||||
|
|
|
|||
148
dist/fabric.js
vendored
148
dist/fabric.js
vendored
|
|
@ -1,5 +1,5 @@
|
|||
var fabric = fabric || {
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
};
|
||||
|
||||
if (typeof exports !== "undefined") {
|
||||
|
|
@ -7181,14 +7181,14 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (this.intersectsWithRect(pointTL, pointBR, true)) {
|
||||
if (this.intersectsWithRect(pointTL, pointBR, true, calculate)) {
|
||||
return true;
|
||||
}
|
||||
var centerPoint = {
|
||||
x: (pointTL.x + pointBR.x) / 2,
|
||||
y: (pointTL.y + pointBR.y) / 2
|
||||
};
|
||||
if (this.containsPoint(centerPoint, null, true)) {
|
||||
if (this.containsPoint(centerPoint, null, true, calculate)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -7502,11 +7502,11 @@ fabric.util.object.extend(fabric.Object.prototype, {
|
|||
return [ stroke, "stroke-width: ", strokeWidth, "; ", "stroke-dasharray: ", strokeDashArray, "; ", "stroke-linecap: ", strokeLineCap, "; ", "stroke-linejoin: ", strokeLineJoin, "; ", "stroke-miterlimit: ", strokeMiterLimit, "; ", fill, "fill-rule: ", fillRule, "; ", "opacity: ", opacity, ";", filter, visibility ].join("");
|
||||
},
|
||||
getSvgSpanStyles: function(style, useWhiteSpace) {
|
||||
var term = "; ", strokeWidth = style.strokeWidth ? "stroke-width: " + style.strokeWidth + term : "", fontFamily = style.fontFamily ? "font-family: " + style.fontFamily.replace(/"/g, "'") + term : "", fontSize = style.fontSize ? "font-size: " + style.fontSize + "px" + term : "", fontStyle = style.fontStyle ? "font-style: " + style.fontStyle + term : "", fontWeight = style.fontWeight ? "font-weight: " + style.fontWeight + term : "", fill = style.fill ? getSvgColorString("fill", style.fill) : "", stroke = style.stroke ? getSvgColorString("stroke", style.stroke) : "", textDecoration = this.getSvgTextDecoration(style);
|
||||
var term = "; ", strokeWidth = style.strokeWidth ? "stroke-width: " + style.strokeWidth + term : "", fontFamily = style.fontFamily ? "font-family: " + style.fontFamily.replace(/"/g, "'") + term : "", fontSize = style.fontSize ? "font-size: " + style.fontSize + "px" + term : "", fontStyle = style.fontStyle ? "font-style: " + style.fontStyle + term : "", fontWeight = style.fontWeight ? "font-weight: " + style.fontWeight + term : "", fill = style.fill ? getSvgColorString("fill", style.fill) : "", stroke = style.stroke ? getSvgColorString("stroke", style.stroke) : "", textDecoration = this.getSvgTextDecoration(style), deltaY = style.deltaY ? "baseline-shift: " + -style.deltaY + "; " : "";
|
||||
if (textDecoration) {
|
||||
textDecoration = "text-decoration: " + textDecoration + term;
|
||||
}
|
||||
return [ stroke, strokeWidth, fontFamily, fontSize, fontStyle, fontWeight, textDecoration, fill, useWhiteSpace ? "white-space: pre; " : "" ].join("");
|
||||
return [ stroke, strokeWidth, fontFamily, fontSize, fontStyle, fontWeight, textDecoration, fill, deltaY, useWhiteSpace ? "white-space: pre; " : "" ].join("");
|
||||
},
|
||||
getSvgTextDecoration: function(style) {
|
||||
if ("overline" in style || "underline" in style || "linethrough" in style) {
|
||||
|
|
@ -11456,7 +11456,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
|
||||
(function(global) {
|
||||
"use strict";
|
||||
var fabric = global.fabric || (global.fabric = {}), clone = fabric.util.object.clone, MIN_TEXT_WIDTH = 2, CACHE_FONT_SIZE = 200;
|
||||
var fabric = global.fabric || (global.fabric = {}), clone = fabric.util.object.clone;
|
||||
if (fabric.Text) {
|
||||
fabric.warn("fabric.Text is already defined");
|
||||
return;
|
||||
|
|
@ -11477,6 +11477,14 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
textAlign: "left",
|
||||
fontStyle: "normal",
|
||||
lineHeight: 1.16,
|
||||
superscript: {
|
||||
size: .6,
|
||||
baseline: -.35
|
||||
},
|
||||
subscript: {
|
||||
size: .6,
|
||||
baseline: .11
|
||||
},
|
||||
textBackgroundColor: "",
|
||||
stateProperties: fabric.Object.prototype.stateProperties.concat("fontFamily", "fontWeight", "fontSize", "text", "underline", "overline", "linethrough", "textAlign", "fontStyle", "lineHeight", "textBackgroundColor", "charSpacing", "styles"),
|
||||
cacheProperties: fabric.Object.prototype.cacheProperties.concat("fontFamily", "fontWeight", "fontSize", "text", "underline", "overline", "linethrough", "textAlign", "fontStyle", "lineHeight", "textBackgroundColor", "charSpacing", "styles"),
|
||||
|
|
@ -11492,8 +11500,11 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
charSpacing: 0,
|
||||
styles: null,
|
||||
_measuringContext: null,
|
||||
_styleProperties: [ "stroke", "strokeWidth", "fill", "fontFamily", "fontSize", "fontWeight", "fontStyle", "underline", "overline", "linethrough", "textBackgroundColor" ],
|
||||
deltaY: 0,
|
||||
_styleProperties: [ "stroke", "strokeWidth", "fill", "fontFamily", "fontSize", "fontWeight", "fontStyle", "underline", "overline", "linethrough", "deltaY", "textBackgroundColor" ],
|
||||
__charBounds: [],
|
||||
CACHE_FONT_SIZE: 400,
|
||||
MIN_TEXT_WIDTH: 2,
|
||||
initialize: function(text, options) {
|
||||
this.styles = options ? options.styles || {} : {};
|
||||
this.text = text;
|
||||
|
|
@ -11526,7 +11537,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
}
|
||||
this._splitText();
|
||||
this._clearCache();
|
||||
this.width = this.calcTextWidth() || this.cursorWidth || MIN_TEXT_WIDTH;
|
||||
this.width = this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;
|
||||
if (this.textAlign.indexOf("justify") !== -1) {
|
||||
this.enlargeSpaces();
|
||||
}
|
||||
|
|
@ -11663,7 +11674,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
ctx.font = this._getFontDeclaration(styleDeclaration);
|
||||
},
|
||||
_measureChar: function(_char, charStyle, previousChar, prevCharStyle) {
|
||||
var fontCache = this.getFontCache(charStyle), fontDeclaration = this._getFontDeclaration(charStyle), previousFontDeclaration = this._getFontDeclaration(prevCharStyle), couple = previousChar + _char, stylesAreEqual = fontDeclaration === previousFontDeclaration, width, coupleWidth, previousWidth, fontMultiplier = charStyle.fontSize / CACHE_FONT_SIZE, kernedWidth;
|
||||
var fontCache = this.getFontCache(charStyle), fontDeclaration = this._getFontDeclaration(charStyle), previousFontDeclaration = this._getFontDeclaration(prevCharStyle), couple = previousChar + _char, stylesAreEqual = fontDeclaration === previousFontDeclaration, width, coupleWidth, previousWidth, fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE, kernedWidth;
|
||||
if (previousChar && fontCache[previousChar]) {
|
||||
previousWidth = fontCache[previousChar];
|
||||
}
|
||||
|
|
@ -11690,20 +11701,14 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
coupleWidth = ctx.measureText(couple).width;
|
||||
fontCache[couple] = coupleWidth;
|
||||
kernedWidth = coupleWidth - previousWidth;
|
||||
if (kernedWidth > width) {
|
||||
var diff = kernedWidth - width;
|
||||
fontCache[_char] = kernedWidth;
|
||||
fontCache[couple] += diff;
|
||||
width = kernedWidth;
|
||||
}
|
||||
}
|
||||
return {
|
||||
width: width * fontMultiplier,
|
||||
kernedWidth: kernedWidth * fontMultiplier
|
||||
};
|
||||
},
|
||||
getHeightOfChar: function(l, c) {
|
||||
return this.getValueOfPropertyAt(l, c, "fontSize");
|
||||
getHeightOfChar: function(line, char) {
|
||||
return this.getValueOfPropertyAt(line, char, "fontSize");
|
||||
},
|
||||
measureLine: function(lineIndex) {
|
||||
var lineInfo = this._measureLine(lineIndex);
|
||||
|
|
@ -11736,8 +11741,8 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
numOfSpaces: numOfSpaces
|
||||
};
|
||||
},
|
||||
_getGraphemeBox: function(grapheme, lineIndex, charIndex, previousGrapheme, skipLeft) {
|
||||
var charStyle = this.getCompleteStyleDeclaration(lineIndex, charIndex), prevCharStyle = previousGrapheme ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1) : {}, info = this._measureChar(grapheme, charStyle, previousGrapheme, prevCharStyle), kernedWidth = info.kernedWidth, width = info.width;
|
||||
_getGraphemeBox: function(grapheme, lineIndex, charIndex, prevGrapheme, skipLeft) {
|
||||
var style = this.getCompleteStyleDeclaration(lineIndex, charIndex), prevStyle = prevGrapheme ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1) : {}, info = this._measureChar(grapheme, style, prevGrapheme, prevStyle), kernedWidth = info.kernedWidth, width = info.width;
|
||||
if (this.charSpacing !== 0) {
|
||||
width += this._getWidthOfCharSpacing();
|
||||
kernedWidth += this._getWidthOfCharSpacing();
|
||||
|
|
@ -11745,8 +11750,9 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
var box = {
|
||||
width: width,
|
||||
left: 0,
|
||||
height: charStyle.fontSize,
|
||||
kernedWidth: kernedWidth
|
||||
height: style.fontSize,
|
||||
kernedWidth: kernedWidth,
|
||||
deltaY: style.deltaY
|
||||
};
|
||||
if (charIndex > 0 && !skipLeft) {
|
||||
var previousBox = this.__charBounds[lineIndex][charIndex - 1];
|
||||
|
|
@ -11758,15 +11764,11 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
if (this.__lineHeights[lineIndex]) {
|
||||
return this.__lineHeights[lineIndex];
|
||||
}
|
||||
var line = this._textLines[lineIndex], maxHeight = this.getHeightOfChar(lineIndex, 0);
|
||||
for (var i = 1, len = line.length; i < len; i++) {
|
||||
var currentCharHeight = this.getHeightOfChar(lineIndex, i);
|
||||
if (currentCharHeight > maxHeight) {
|
||||
maxHeight = currentCharHeight;
|
||||
}
|
||||
var line = this._textLines[lineIndex], maxHeight = 0;
|
||||
for (var i = 0, len = line.length; i < len; i++) {
|
||||
maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);
|
||||
}
|
||||
this.__lineHeights[lineIndex] = maxHeight * this.lineHeight * this._fontSizeMult;
|
||||
return this.__lineHeights[lineIndex];
|
||||
return this.__lineHeights[lineIndex] = maxHeight * this.lineHeight * this._fontSizeMult;
|
||||
},
|
||||
calcTextHeight: function() {
|
||||
var lineHeight, height = 0;
|
||||
|
|
@ -11861,12 +11863,29 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
if (decl && decl.textBackgroundColor) {
|
||||
this._removeShadow(ctx);
|
||||
}
|
||||
if (decl && decl.deltaY) {
|
||||
top += decl.deltaY;
|
||||
}
|
||||
shouldFill && ctx.fillText(_char, left, top);
|
||||
shouldStroke && ctx.strokeText(_char, left, top);
|
||||
decl && ctx.restore();
|
||||
},
|
||||
setSuperscript: function(start, end) {
|
||||
return this._setScript(start, end, this.superscript);
|
||||
},
|
||||
setSubscript: function(start, end) {
|
||||
return this._setScript(start, end, this.subscript);
|
||||
},
|
||||
_setScript: function(start, end, schema) {
|
||||
var loc = this.get2DCursorLocation(start, true), fontSize = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, "fontSize"), dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, "deltaY"), style = {
|
||||
fontSize: fontSize * schema.size,
|
||||
deltaY: dy + fontSize * schema.baseline
|
||||
};
|
||||
this.setSelectionStyles(style, start, end);
|
||||
return this;
|
||||
},
|
||||
_hasStyleChanged: function(prevStyle, thisStyle) {
|
||||
return prevStyle.fill !== thisStyle.fill || prevStyle.stroke !== thisStyle.stroke || prevStyle.strokeWidth !== thisStyle.strokeWidth || prevStyle.fontSize !== thisStyle.fontSize || prevStyle.fontFamily !== thisStyle.fontFamily || prevStyle.fontWeight !== thisStyle.fontWeight || prevStyle.fontStyle !== thisStyle.fontStyle;
|
||||
return prevStyle.fill !== thisStyle.fill || prevStyle.stroke !== thisStyle.stroke || prevStyle.strokeWidth !== thisStyle.strokeWidth || prevStyle.fontSize !== thisStyle.fontSize || prevStyle.fontFamily !== thisStyle.fontFamily || prevStyle.fontWeight !== thisStyle.fontWeight || prevStyle.fontStyle !== thisStyle.fontStyle || prevStyle.deltaY !== thisStyle.deltaY;
|
||||
},
|
||||
_hasStyleChangedForSvg: function(prevStyle, thisStyle) {
|
||||
return this._hasStyleChanged(prevStyle, thisStyle) || prevStyle.overline !== thisStyle.overline || prevStyle.underline !== thisStyle.underline || prevStyle.linethrough !== thisStyle.linethrough;
|
||||
|
|
@ -11922,14 +11941,17 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
return 0;
|
||||
},
|
||||
getValueOfPropertyAt: function(lineIndex, charIndex, property) {
|
||||
var charStyle = this._getStyleDeclaration(lineIndex, charIndex), styleDecoration = charStyle && typeof charStyle[property] !== "undefined";
|
||||
return styleDecoration ? charStyle[property] : this[property];
|
||||
var charStyle = this._getStyleDeclaration(lineIndex, charIndex);
|
||||
if (charStyle && typeof charStyle[property] !== "undefined") {
|
||||
return charStyle[property];
|
||||
}
|
||||
return this[property];
|
||||
},
|
||||
_renderTextDecoration: function(ctx, type) {
|
||||
if (!this[type] && !this.styleHas(type)) {
|
||||
return;
|
||||
}
|
||||
var heightOfLine, lineLeftOffset, line, lastDecoration, leftOffset = this._getLeftOffset(), topOffset = this._getTopOffset(), boxStart, boxWidth, charBox, currentDecoration, maxHeight, currentFill, lastFill;
|
||||
var heightOfLine, size, _size, lineLeftOffset, dy, _dy, line, lastDecoration, leftOffset = this._getLeftOffset(), topOffset = this._getTopOffset(), top, boxStart, boxWidth, charBox, currentDecoration, maxHeight, currentFill, lastFill;
|
||||
for (var i = 0, len = this._textLines.length; i < len; i++) {
|
||||
heightOfLine = this.getHeightOfLine(i);
|
||||
if (!this[type] && !this.styleHas(type, i)) {
|
||||
|
|
@ -11943,30 +11965,37 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
boxWidth = 0;
|
||||
lastDecoration = this.getValueOfPropertyAt(i, 0, type);
|
||||
lastFill = this.getValueOfPropertyAt(i, 0, "fill");
|
||||
top = topOffset + maxHeight * (1 - this._fontSizeFraction);
|
||||
size = this.getHeightOfChar(i, 0);
|
||||
dy = this.getValueOfPropertyAt(i, 0, "deltaY");
|
||||
for (var j = 0, jlen = line.length; j < jlen; j++) {
|
||||
charBox = this.__charBounds[i][j];
|
||||
currentDecoration = this.getValueOfPropertyAt(i, j, type);
|
||||
currentFill = this.getValueOfPropertyAt(i, j, "fill");
|
||||
if ((currentDecoration !== lastDecoration || currentFill !== lastFill) && boxWidth > 0) {
|
||||
_size = this.getHeightOfChar(i, j);
|
||||
_dy = this.getValueOfPropertyAt(i, j, "deltaY");
|
||||
if ((currentDecoration !== lastDecoration || currentFill !== lastFill || _size !== size || _dy !== dy) && boxWidth > 0) {
|
||||
ctx.fillStyle = lastFill;
|
||||
lastDecoration && lastFill && ctx.fillRect(leftOffset + lineLeftOffset + boxStart, topOffset + maxHeight * (1 - this._fontSizeFraction) + this.offsets[type] * this.fontSize, boxWidth, this.fontSize / 15);
|
||||
lastDecoration && lastFill && ctx.fillRect(leftOffset + lineLeftOffset + boxStart, top + this.offsets[type] * size + dy, boxWidth, this.fontSize / 15);
|
||||
boxStart = charBox.left;
|
||||
boxWidth = charBox.width;
|
||||
lastDecoration = currentDecoration;
|
||||
lastFill = currentFill;
|
||||
size = _size;
|
||||
dy = _dy;
|
||||
} else {
|
||||
boxWidth += charBox.kernedWidth;
|
||||
}
|
||||
}
|
||||
ctx.fillStyle = currentFill;
|
||||
currentDecoration && currentFill && ctx.fillRect(leftOffset + lineLeftOffset + boxStart, topOffset + maxHeight * (1 - this._fontSizeFraction) + this.offsets[type] * this.fontSize, boxWidth, this.fontSize / 15);
|
||||
currentDecoration && currentFill && ctx.fillRect(leftOffset + lineLeftOffset + boxStart, top + this.offsets[type] * size + dy, boxWidth, this.fontSize / 15);
|
||||
topOffset += heightOfLine;
|
||||
}
|
||||
this._removeShadow(ctx);
|
||||
},
|
||||
_getFontDeclaration: function(styleObject, forMeasuring) {
|
||||
var style = styleObject || this;
|
||||
return [ fabric.isLikelyNode ? style.fontWeight : style.fontStyle, fabric.isLikelyNode ? style.fontStyle : style.fontWeight, forMeasuring ? CACHE_FONT_SIZE + "px" : style.fontSize + "px", fabric.isLikelyNode ? '"' + style.fontFamily + '"' : style.fontFamily ].join(" ");
|
||||
return [ fabric.isLikelyNode ? style.fontWeight : style.fontStyle, fabric.isLikelyNode ? style.fontStyle : style.fontWeight, forMeasuring ? this.CACHE_FONT_SIZE + "px" : style.fontSize + "px", fabric.isLikelyNode ? '"' + style.fontFamily + '"' : style.fontFamily ].join(" ");
|
||||
},
|
||||
render: function(ctx) {
|
||||
if (!this.visible) {
|
||||
|
|
@ -12411,14 +12440,14 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
|
|||
return this.cursorOffsetCache;
|
||||
},
|
||||
renderCursor: function(boundaries, ctx) {
|
||||
var cursorLocation = this.get2DCursorLocation(), lineIndex = cursorLocation.lineIndex, charIndex = cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0, charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, "fontSize"), multiplier = this.scaleX * this.canvas.getZoom(), cursorWidth = this.cursorWidth / multiplier, topOffset = boundaries.topOffset;
|
||||
var cursorLocation = this.get2DCursorLocation(), lineIndex = cursorLocation.lineIndex, charIndex = cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0, charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, "fontSize"), multiplier = this.scaleX * this.canvas.getZoom(), cursorWidth = this.cursorWidth / multiplier, topOffset = boundaries.topOffset, dy = this.getValueOfPropertyAt(lineIndex, charIndex, "deltaY");
|
||||
topOffset += (1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex) / this.lineHeight - charHeight * (1 - this._fontSizeFraction);
|
||||
if (this.inCompositionMode) {
|
||||
this.renderSelection(boundaries, ctx);
|
||||
}
|
||||
ctx.fillStyle = this.getValueOfPropertyAt(lineIndex, charIndex, "fill");
|
||||
ctx.globalAlpha = this.__isMousedown ? 1 : this._currentCursorOpacity;
|
||||
ctx.fillRect(boundaries.left + boundaries.leftOffset - cursorWidth / 2, topOffset + boundaries.top, cursorWidth, charHeight);
|
||||
ctx.fillRect(boundaries.left + boundaries.leftOffset - cursorWidth / 2, topOffset + boundaries.top + dy, cursorWidth, charHeight);
|
||||
},
|
||||
renderSelection: function(boundaries, ctx) {
|
||||
var selectionStart = this.inCompositionMode ? this.hiddenTextarea.selectionStart : this.selectionStart, selectionEnd = this.inCompositionMode ? this.hiddenTextarea.selectionEnd : this.selectionEnd, isJustify = this.textAlign.indexOf("justify") !== -1, start = this.get2DCursorLocation(selectionStart), end = this.get2DCursorLocation(selectionEnd), startLine = start.lineIndex, endLine = end.lineIndex, startChar = start.charIndex < 0 ? 0 : start.charIndex, endChar = end.charIndex < 0 ? 0 : end.charIndex;
|
||||
|
|
@ -13112,9 +13141,12 @@ fabric.util.object.extend(fabric.IText.prototype, {
|
|||
this.on("mousedown", this.onMouseDown.bind(this));
|
||||
},
|
||||
onMouseDown: function(options) {
|
||||
if (!this.canvas) {
|
||||
return;
|
||||
}
|
||||
this.__newClickTime = +new Date();
|
||||
var newPointer = this.canvas.getPointer(options.e);
|
||||
if (this.isTripleClick(newPointer, options.e)) {
|
||||
if (this.isTripleClick(newPointer)) {
|
||||
this.fire("tripleclick", options);
|
||||
this._stopEvent(options.e);
|
||||
}
|
||||
|
|
@ -13171,21 +13203,22 @@ fabric.util.object.extend(fabric.IText.prototype, {
|
|||
return this.__mousedownX !== pointer.x || this.__mousedownY !== pointer.y;
|
||||
},
|
||||
initMouseupHandler: function() {
|
||||
this.on("mouseup", function(options) {
|
||||
this.__isMousedown = false;
|
||||
if (!this.editable || this._isObjectMoved(options.e) || options.e.button && options.e.button !== 1) {
|
||||
return;
|
||||
this.on("mouseup", this.mouseUpHandler);
|
||||
},
|
||||
mouseUpHandler: function(options) {
|
||||
this.__isMousedown = false;
|
||||
if (!this.editable || this._isObjectMoved(options.e) || options.e.button && options.e.button !== 1) {
|
||||
return;
|
||||
}
|
||||
if (this.__lastSelected && !this.__corner) {
|
||||
this.enterEditing(options.e);
|
||||
if (this.selectionStart === this.selectionEnd) {
|
||||
this.initDelayedCursor(true);
|
||||
} else {
|
||||
this.renderCursorOrSelection();
|
||||
}
|
||||
if (this.__lastSelected && !this.__corner) {
|
||||
this.enterEditing(options.e);
|
||||
if (this.selectionStart === this.selectionEnd) {
|
||||
this.initDelayedCursor(true);
|
||||
} else {
|
||||
this.renderCursorOrSelection();
|
||||
}
|
||||
}
|
||||
this.selected = true;
|
||||
});
|
||||
}
|
||||
this.selected = true;
|
||||
},
|
||||
setCursorByClick: function(e) {
|
||||
var newSelection = this.getSelectionStartFromPointer(e), start = this.selectionStart, end = this.selectionEnd;
|
||||
|
|
@ -13649,8 +13682,11 @@ fabric.util.object.extend(fabric.IText.prototype, {
|
|||
};
|
||||
},
|
||||
_createTextCharSpan: function(_char, styleDecl, left, top) {
|
||||
var styleProps = this.getSvgSpanStyles(styleDecl, _char !== _char.trim()), fillStyles = styleProps ? 'style="' + styleProps + '"' : "", NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
|
||||
return [ '<tspan x="', toFixed(left, NUM_FRACTION_DIGITS), '" y="', toFixed(top, NUM_FRACTION_DIGITS), '" ', fillStyles, ">", fabric.util.string.escapeXml(_char), "</tspan>" ].join("");
|
||||
var styleProps = this.getSvgSpanStyles(styleDecl, _char !== _char.trim()), fillStyles = styleProps ? 'style="' + styleProps + '"' : "", dy = styleDecl.deltaY, dySpan = "", NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
|
||||
if (dy) {
|
||||
dySpan = ' dy="' + toFixed(dy, NUM_FRACTION_DIGITS) + '" ';
|
||||
}
|
||||
return [ '<tspan x="', toFixed(left, NUM_FRACTION_DIGITS), '" y="', toFixed(top, NUM_FRACTION_DIGITS), '" ', dySpan, fillStyles, ">", fabric.util.string.escapeXml(_char), "</tspan>" ].join("");
|
||||
},
|
||||
_setSVGTextLineText: function(textSpans, lineIndex, textLeftOffset, textTopOffset) {
|
||||
var lineHeight = this.getHeightOfLine(lineIndex), isJustify = this.textAlign.indexOf("justify") !== -1, actualStyle, nextStyle, charsToRender = "", charBox, style, boxWidth = 0, line = this._textLines[lineIndex], timeToRender;
|
||||
|
|
|
|||
2
dist/fabric.min.js
vendored
2
dist/fabric.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -2,7 +2,7 @@
|
|||
"name": "fabric",
|
||||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
||||
"homepage": "http://fabricjs.com/",
|
||||
"version": "2.1.0",
|
||||
"version": "2.2.0",
|
||||
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue