Skip to content

Commit

Permalink
Updated to rc2 (#4498)
Browse files Browse the repository at this point in the history
* update to rc2

* updated build
  • Loading branch information
asturur authored Nov 24, 2017
1 parent 71b36f6 commit 2361248
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 90 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
**Version 2.0.0**
- rc2
- Fixed a transform matrix memoize missing width/height [#4491](https://github.com/kangax/fabric.js/pull/4491)
- Fix pattern drawing a point [#4492](https://github.com/kangax/fabric.js/pull/4492)
- Fixed Text.removeChars [#4495](https://github.com/kangax/fabric.js/pull/4495)
- Added back 2 node-canvas methods [#4497](https://github.com/kangax/fabric.js/pull/4497)
- Fix a typo not restoring hoverCursor correctly.
- rc1
- Remove node specific code [#4470](https://github.com/kangax/fabric.js/pull/4470)
- Improved Canvas.dispose code to leak less memory [#4471](https://github.com/kangax/fabric.js/pull/4471)
Expand Down
2 changes: 1 addition & 1 deletion HEADER.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

var fabric = fabric || { version: '2.0.0-rc.1' };
var fabric = fabric || { version: '2.0.0-rc.2' };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down
80 changes: 28 additions & 52 deletions dist/fabric.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* build: `node build.js modules=ALL exclude=gestures,accessors minifier=uglifyjs` */
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

var fabric = fabric || { version: '2.0.0-rc.1' };
var fabric = fabric || { version: '2.0.0-rc.2' };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand All @@ -19,6 +19,7 @@ else {
FetchExternalResources: ['img']
}
});
fabric.jsdomImplForWrapper = require('jsdom/lib/jsdom/living/generated/utils').implForWrapper;
fabric.window = fabric.document.defaultView;
DOMParser = require('xmldom').DOMParser;
}
Expand Down Expand Up @@ -8040,6 +8041,16 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
*/
fabric.StaticCanvas.prototype.toJSON = fabric.StaticCanvas.prototype.toObject;

if (fabric.isLikelyNode) {
fabric.StaticCanvas.prototype.createPNGStream = function() {
var impl = fabric.jsdomImplForWrapper(this.lowerCanvasEl);
return impl && impl.createPNGStream();
};
fabric.StaticCanvas.prototype.createJPEGStream = function(opts) {
var impl = fabric.jsdomImplForWrapper(this.lowerCanvasEl);
return impl && impl.createJPEGStream(opts);
};
}
})();


Expand Down Expand Up @@ -8306,7 +8317,7 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype
var path = [], i, width = this.width / 1000,
p1 = new fabric.Point(points[0].x, points[0].y),
p2 = new fabric.Point(points[1].x, points[1].y),
len = points.length, multSignX, multSignY, manyPoints = len > 2;
len = points.length, multSignX = 1, multSignY = 1, manyPoints = len > 2;

if (manyPoints) {
multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;
Expand Down Expand Up @@ -14344,7 +14355,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
prefix = this.group.transformMatrixKey(skipGroup) + sep;
};
return prefix + this.top + sep + this.left + sep + this.scaleX + sep + this.scaleY +
sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.flipX + sep + this.flipY;
sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.flipX + sep + this.flipY +
sep + this.width + sep + this.height;
},

/**
Expand Down Expand Up @@ -18659,12 +18671,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
return;
}

var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push(
'cropX',
'cropY'
);

/**
* Image class
* @class fabric.Image
Expand Down Expand Up @@ -18741,7 +18747,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* as well as for history (undo/redo) purposes
* @type Array
*/
stateProperties: stateProperties,
stateProperties: fabric.Object.prototype.stateProperties.concat('cropX', 'cropY'),

/**
* When `true`, object is cached on an additional canvas.
Expand Down Expand Up @@ -26188,7 +26194,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
return;
}

this.hoverCursor = this._savedProps.overCursor;
this.hoverCursor = this._savedProps.hoverCursor;
this.hasControls = this._savedProps.hasControls;
this.borderColor = this._savedProps.borderColor;
this.lockMovementX = this._savedProps.lockMovementX;
Expand Down Expand Up @@ -27332,57 +27338,27 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
},

/**
* Removes characters selected by selection
* @param {Event} e Event object
* Removes characters from start/end
* start/end ar per grapheme position in _text array.
*
* @param {Number} start
* @param {Number} end default to start + 1
*/
removeChars: function(e) {
if (this.selectionStart === this.selectionEnd) {
this._removeCharsNearCursor(e);
}
else {
this._removeCharsFromTo(this.selectionStart, this.selectionEnd);
removeChars: function(start, end) {
if (typeof end === 'undefined') {
end = start + 1;
}

this.removeStyleFromTo(start, end);
this._text.splice(start, end - start);
this.text = this._text.join('');
this.set('dirty', true);
this.setSelectionEnd(this.selectionStart);

this._removeExtraneousStyles();
if (this._shouldClearDimensionCache()) {
this.initDimensions();
this.setCoords();
}
this.canvas && this.canvas.requestRenderAll();
this.fire('changed');
this.canvas && this.canvas.fire('text:changed', { target: this });
},

/**
* @private
* @param {Event} e Event object
*/
_removeCharsNearCursor: function(e) {
if (this.selectionStart === 0) {
return;
}
if (e.metaKey) {
// remove all till the start of current line
var leftLineBoundary = this.findLineBoundaryLeft(this.selectionStart);

this._removeCharsFromTo(leftLineBoundary, this.selectionStart);
this.setSelectionStart(leftLineBoundary);
}
else if (e.altKey) {
// remove all till the start of current word
var leftWordBoundary = this.findWordBoundaryLeft(this.selectionStart);

this._removeCharsFromTo(leftWordBoundary, this.selectionStart);
this.setSelectionStart(leftWordBoundary);
}
else {
this._removeSingleCharAndStyle(this.selectionStart);
this.setSelectionStart(this.selectionStart - 1);
}
}
});


Expand Down
2 changes: 1 addition & 1 deletion dist/fabric.min.js

Large diffs are not rendered by default.

Binary file modified dist/fabric.min.js.gz
Binary file not shown.
57 changes: 22 additions & 35 deletions dist/fabric.require.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fabric = fabric || {
version: "2.0.0-rc.1"
version: "2.0.0-rc.2"
};

if (typeof exports !== "undefined") {
Expand All @@ -15,6 +15,7 @@ if (typeof document !== "undefined" && typeof window !== "undefined") {
FetchExternalResources: [ "img" ]
}
});
fabric.jsdomImplForWrapper = require("jsdom/lib/jsdom/living/generated/utils").implForWrapper;
fabric.window = fabric.document.defaultView;
DOMParser = require("xmldom").DOMParser;
}
Expand Down Expand Up @@ -4127,6 +4128,16 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
}
});
fabric.StaticCanvas.prototype.toJSON = fabric.StaticCanvas.prototype.toObject;
if (fabric.isLikelyNode) {
fabric.StaticCanvas.prototype.createPNGStream = function() {
var impl = fabric.jsdomImplForWrapper(this.lowerCanvasEl);
return impl && impl.createPNGStream();
};
fabric.StaticCanvas.prototype.createJPEGStream = function(opts) {
var impl = fabric.jsdomImplForWrapper(this.lowerCanvasEl);
return impl && impl.createJPEGStream(opts);
};
}
})();

fabric.BaseBrush = fabric.util.createClass({
Expand Down Expand Up @@ -4233,7 +4244,7 @@ fabric.BaseBrush = fabric.util.createClass({
ctx.restore();
},
convertPointsToSVGPath: function(points) {
var path = [], i, width = this.width / 1e3, p1 = new fabric.Point(points[0].x, points[0].y), p2 = new fabric.Point(points[1].x, points[1].y), len = points.length, multSignX, multSignY, manyPoints = len > 2;
var path = [], i, width = this.width / 1e3, p1 = new fabric.Point(points[0].x, points[0].y), p2 = new fabric.Point(points[1].x, points[1].y), len = points.length, multSignX = 1, multSignY = 1, manyPoints = len > 2;
if (manyPoints) {
multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;
multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;
Expand Down Expand Up @@ -7163,7 +7174,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
if (!skipGroup && this.group) {
prefix = this.group.transformMatrixKey(skipGroup) + sep;
}
return prefix + this.top + sep + this.left + sep + this.scaleX + sep + this.scaleY + sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.flipX + sep + this.flipY;
return prefix + this.top + sep + this.left + sep + this.scaleX + sep + this.scaleY + sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.flipX + sep + this.flipY + sep + this.width + sep + this.height;
},
calcTransformMatrix: function(skipGroup) {
if (skipGroup) {
Expand Down Expand Up @@ -9223,8 +9234,6 @@ fabric.util.object.extend(fabric.Object.prototype, {
fabric.warn("fabric.Image is already defined.");
return;
}
var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push("cropX", "cropY");
fabric.Image = fabric.util.createClass(fabric.Object, {
type: "image",
crossOrigin: "",
Expand All @@ -9234,7 +9243,7 @@ fabric.util.object.extend(fabric.Object.prototype, {
_filterScalingX: 1,
_filterScalingY: 1,
minimumScaleTrigger: .5,
stateProperties: stateProperties,
stateProperties: fabric.Object.prototype.stateProperties.concat("cropX", "cropY"),
objectCaching: false,
cacheKey: "",
cropX: 0,
Expand Down Expand Up @@ -12654,7 +12663,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
if (!this._savedProps) {
return;
}
this.hoverCursor = this._savedProps.overCursor;
this.hoverCursor = this._savedProps.hoverCursor;
this.hasControls = this._savedProps.hasControls;
this.borderColor = this._savedProps.borderColor;
this.lockMovementX = this._savedProps.lockMovementX;
Expand Down Expand Up @@ -13367,41 +13376,19 @@ fabric.util.object.extend(fabric.IText.prototype, {
}
return changed;
},
removeChars: function(e) {
if (this.selectionStart === this.selectionEnd) {
this._removeCharsNearCursor(e);
} else {
this._removeCharsFromTo(this.selectionStart, this.selectionEnd);
removeChars: function(start, end) {
if (typeof end === "undefined") {
end = start + 1;
}
this.removeStyleFromTo(start, end);
this._text.splice(start, end - start);
this.text = this._text.join("");
this.set("dirty", true);
this.setSelectionEnd(this.selectionStart);
this._removeExtraneousStyles();
if (this._shouldClearDimensionCache()) {
this.initDimensions();
this.setCoords();
}
this.canvas && this.canvas.requestRenderAll();
this.fire("changed");
this.canvas && this.canvas.fire("text:changed", {
target: this
});
},
_removeCharsNearCursor: function(e) {
if (this.selectionStart === 0) {
return;
}
if (e.metaKey) {
var leftLineBoundary = this.findLineBoundaryLeft(this.selectionStart);
this._removeCharsFromTo(leftLineBoundary, this.selectionStart);
this.setSelectionStart(leftLineBoundary);
} else if (e.altKey) {
var leftWordBoundary = this.findWordBoundaryLeft(this.selectionStart);
this._removeCharsFromTo(leftWordBoundary, this.selectionStart);
this.setSelectionStart(leftWordBoundary);
} else {
this._removeSingleCharAndStyle(this.selectionStart);
this.setSelectionStart(this.selectionStart - 1);
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.0-rc.1",
"version": "2.0.0-rc.2",
"author": "Juriy Zaytsev <[email protected]>",
"contributors": [
{
Expand Down

0 comments on commit 2361248

Please sign in to comment.