Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 1.7.9 #3804

Merged
merged 4 commits into from
Mar 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
**Version 1.7.9**

- Fix: Avoid textarea wrapping from chome v57+ [#3804](https://github.com/kangax/fabric.js/pull/3804)
- Fix: double click needed to move cursor when enterEditing is called programatically [#3804](https://github.com/kangax/fabric.js/pull/3804)
- Fix: Style regression when inputing new style objects [#3804](https://github.com/kangax/fabric.js/pull/3804)
- Add: try to support crossOrigin for svg image tags [#3804](https://github.com/kangax/fabric.js/pull/3804)

**Version 1.7.8**

- Fix: Fix dirty flag propagation [#3782](https://github.com/kangax/fabric.js/pull/3782)
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: "1.7.8" };
var fabric = fabric || { version: "1.7.9" };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down
56 changes: 34 additions & 22 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=json,gestures minifier=uglifyjs` */
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

var fabric = fabric || { version: "1.7.8" };
var fabric = fabric || { version: "1.7.9" };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down Expand Up @@ -3803,8 +3803,10 @@ if (typeof console !== 'undefined') {
* @param {Function} callback Callback to call when parsing is finished;
* It's being passed an array of elements (parsed from a document).
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
* @param {Object} [parsingOptions] options for parsing document
* @param {String} [parsingOptions.crossOrigin] crossOrigin settings
*/
fabric.parseSVGDocument = function(doc, callback, reviver) {
fabric.parseSVGDocument = function(doc, callback, reviver, parsingOptions) {
if (!doc) {
return;
}
Expand All @@ -3814,7 +3816,7 @@ if (typeof console !== 'undefined') {
var svgUid = fabric.Object.__uid++,
options = applyViewboxTransform(doc),
descendants = fabric.util.toArray(doc.getElementsByTagName('*'));

options.crossOrigin = parsingOptions && parsingOptions.crossOrigin;
options.svgUid = svgUid;

if (descendants.length === 0 && fabric.isLikelyNode) {
Expand Down Expand Up @@ -3846,7 +3848,7 @@ if (typeof console !== 'undefined') {
if (callback) {
callback(instances, options);
}
}, clone(options), reviver);
}, clone(options), reviver, parsingOptions);
};

var reFontDeclaration = new RegExp(
Expand Down Expand Up @@ -3998,8 +4000,8 @@ if (typeof console !== 'undefined') {
* @param {Object} [options] Options object
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
*/
parseElements: function(elements, callback, options, reviver) {
new fabric.ElementsParser(elements, callback, options, reviver).parse();
parseElements: function(elements, callback, options, reviver, parsingOptions) {
new fabric.ElementsParser(elements, callback, options, reviver, parsingOptions).parse();
},

/**
Expand Down Expand Up @@ -4125,8 +4127,10 @@ if (typeof console !== 'undefined') {
* @param {String} url
* @param {Function} callback
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
* @param {Object} [options] Object containing options for parsing
* @param {String} [options.crossOrigin] crossOrigin crossOrigin setting to use for external resources
*/
loadSVGFromURL: function(url, callback, reviver) {
loadSVGFromURL: function(url, callback, reviver, options) {

url = url.replace(/^\n\s*/, '').trim();
new fabric.util.request(url, {
Expand All @@ -4147,9 +4151,9 @@ if (typeof console !== 'undefined') {
callback && callback(null);
}

fabric.parseSVGDocument(xml.documentElement, function (results, options) {
callback && callback(results, options);
}, reviver);
fabric.parseSVGDocument(xml.documentElement, function (results, _options) {
callback && callback(results, _options);
}, reviver, options);
}
},

Expand All @@ -4159,8 +4163,10 @@ if (typeof console !== 'undefined') {
* @param {String} string
* @param {Function} callback
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
* @param {Object} [options] Object containing options for parsing
* @param {String} [options.crossOrigin] crossOrigin crossOrigin setting to use for external resources
*/
loadSVGFromString: function(string, callback, reviver) {
loadSVGFromString: function(string, callback, reviver, options) {
string = string.trim();
var doc;
if (typeof DOMParser !== 'undefined') {
Expand All @@ -4176,21 +4182,22 @@ if (typeof console !== 'undefined') {
doc.loadXML(string.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i, ''));
}

fabric.parseSVGDocument(doc.documentElement, function (results, options) {
callback(results, options);
}, reviver);
fabric.parseSVGDocument(doc.documentElement, function (results, _options) {
callback(results, _options);
}, reviver, options);
}
});

})(typeof exports !== 'undefined' ? exports : this);


fabric.ElementsParser = function(elements, callback, options, reviver) {
fabric.ElementsParser = function(elements, callback, options, reviver, parsingOptions) {
this.elements = elements;
this.callback = callback;
this.options = options;
this.reviver = reviver;
this.svgUid = (options && options.svgUid) || 0;
this.parsingOptions = parsingOptions;
};

fabric.ElementsParser.prototype.parse = function() {
Expand Down Expand Up @@ -19222,7 +19229,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}
*/
fabric.Image.ATTRIBUTE_NAMES =
fabric.SHARED_ATTRIBUTES.concat('x y width height preserveAspectRatio xlink:href'.split(' '));
fabric.SHARED_ATTRIBUTES.concat('x y width height preserveAspectRatio xlink:href crossOrigin'.split(' '));

/**
* Returns {@link fabric.Image} instance from an SVG element
Expand Down Expand Up @@ -24209,7 +24216,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
}

this.isEditing = true;

this.selected = true;
this.initHiddenTextarea(e);
this.hiddenTextarea.focus();
this._updateTextarea();
Expand Down Expand Up @@ -24594,7 +24601,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
}
}
}
var newStyle = style || currentLineStyles[charIndex - 1];
var newStyle = style || clone(currentLineStyles[charIndex - 1]);
newStyle && (this.styles[lineIndex][charIndex] = newStyle);
this._forceClearCache = true;
},
Expand Down Expand Up @@ -24630,8 +24637,14 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
* @param {Number} offset Can be -1 or +1
*/
shiftLineStyles: function(lineIndex, offset) {
// shift all line styles by 1 upward
// shift all line styles by 1 upward or downward
var clonedStyles = clone(this.styles);
for (var line in clonedStyles) {
var numericLine = parseInt(line, 10);
if (numericLine <= lineIndex) {
delete clonedStyles[numericLine];
}
}
for (var line in this.styles) {
var numericLine = parseInt(line, 10);
if (numericLine > lineIndex) {
Expand Down Expand Up @@ -24846,7 +24859,6 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
return;
}
var pointer = this.canvas.getPointer(options.e);

this.__mousedownX = pointer.x;
this.__mousedownY = pointer.y;
this.__isMousedown = true;
Expand Down Expand Up @@ -25003,8 +25015,8 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
this.hiddenTextarea = fabric.document.createElement('textarea');
this.hiddenTextarea.setAttribute('autocapitalize', 'off');
var style = this._calcTextareaPosition();
this.hiddenTextarea.style.cssText = 'position: absolute; top: ' + style.top + '; left: ' + style.left + ';'
+ ' opacity: 0; width: 0px; height: 0px; z-index: -999;';
this.hiddenTextarea.style.cssText = 'white-space: nowrap; position: absolute; top: ' + style.top +
'; left: ' + style.left + '; opacity: 0; width: 1px; height: 1px; z-index: -999;';
fabric.document.body.appendChild(this.hiddenTextarea);

fabric.util.addListener(this.hiddenTextarea, 'keydown', this.onKeyDown.bind(this));
Expand Down
18 changes: 9 additions & 9 deletions dist/fabric.min.js

Large diffs are not rendered by default.

Binary file modified dist/fabric.min.js.gz
Binary file not shown.
43 changes: 26 additions & 17 deletions dist/fabric.require.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fabric = fabric || {
version: "1.7.8"
version: "1.7.9"
};

if (typeof exports !== "undefined") {
Expand Down Expand Up @@ -2089,12 +2089,13 @@ if (typeof console !== "undefined") {
}
return false;
}
fabric.parseSVGDocument = function(doc, callback, reviver) {
fabric.parseSVGDocument = function(doc, callback, reviver, parsingOptions) {
if (!doc) {
return;
}
parseUseDirectives(doc);
var svgUid = fabric.Object.__uid++, options = applyViewboxTransform(doc), descendants = fabric.util.toArray(doc.getElementsByTagName("*"));
options.crossOrigin = parsingOptions && parsingOptions.crossOrigin;
options.svgUid = svgUid;
if (descendants.length === 0 && fabric.isLikelyNode) {
descendants = doc.selectNodes('//*[name(.)!="svg"]');
Expand All @@ -2118,7 +2119,7 @@ if (typeof console !== "undefined") {
if (callback) {
callback(instances, options);
}
}, clone(options), reviver);
}, clone(options), reviver, parsingOptions);
};
var reFontDeclaration = new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*" + "(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(" + fabric.reNum + "(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|" + fabric.reNum + "))?\\s+(.*)");
extend(fabric, {
Expand Down Expand Up @@ -2197,8 +2198,8 @@ if (typeof console !== "undefined") {
var mergedAttrs = extend(parentAttributes, normalizedStyle);
return reAllowedParents.test(element.nodeName) ? mergedAttrs : _setStrokeFillOpacity(mergedAttrs);
},
parseElements: function(elements, callback, options, reviver) {
new fabric.ElementsParser(elements, callback, options, reviver).parse();
parseElements: function(elements, callback, options, reviver, parsingOptions) {
new fabric.ElementsParser(elements, callback, options, reviver, parsingOptions).parse();
},
parseStyleAttribute: function(element) {
var oStyle = {}, style = element.getAttribute("style");
Expand Down Expand Up @@ -2263,7 +2264,7 @@ if (typeof console !== "undefined") {
}
return allRules;
},
loadSVGFromURL: function(url, callback, reviver) {
loadSVGFromURL: function(url, callback, reviver, options) {
url = url.replace(/^\n\s*/, "").trim();
new fabric.util.request(url, {
method: "get",
Expand All @@ -2279,12 +2280,12 @@ if (typeof console !== "undefined") {
if (!xml || !xml.documentElement) {
callback && callback(null);
}
fabric.parseSVGDocument(xml.documentElement, function(results, options) {
callback && callback(results, options);
}, reviver);
fabric.parseSVGDocument(xml.documentElement, function(results, _options) {
callback && callback(results, _options);
}, reviver, options);
}
},
loadSVGFromString: function(string, callback, reviver) {
loadSVGFromString: function(string, callback, reviver, options) {
string = string.trim();
var doc;
if (typeof DOMParser !== "undefined") {
Expand All @@ -2297,19 +2298,20 @@ if (typeof console !== "undefined") {
doc.async = "false";
doc.loadXML(string.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i, ""));
}
fabric.parseSVGDocument(doc.documentElement, function(results, options) {
callback(results, options);
}, reviver);
fabric.parseSVGDocument(doc.documentElement, function(results, _options) {
callback(results, _options);
}, reviver, options);
}
});
})(typeof exports !== "undefined" ? exports : this);

fabric.ElementsParser = function(elements, callback, options, reviver) {
fabric.ElementsParser = function(elements, callback, options, reviver, parsingOptions) {
this.elements = elements;
this.callback = callback;
this.options = options;
this.reviver = reviver;
this.svgUid = options && options.svgUid || 0;
this.parsingOptions = parsingOptions;
};

fabric.ElementsParser.prototype.parse = function() {
Expand Down Expand Up @@ -9285,7 +9287,7 @@ fabric.util.object.extend(fabric.Object.prototype, {
callback && callback(new fabric.Image(img, imgOptions));
}, null, imgOptions && imgOptions.crossOrigin);
};
fabric.Image.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href".split(" "));
fabric.Image.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin".split(" "));
fabric.Image.fromElement = function(element, callback, options) {
var parsedAttributes = fabric.parseAttributes(element, fabric.Image.ATTRIBUTE_NAMES), preserveAR;
if (parsedAttributes.preserveAspectRatio) {
Expand Down Expand Up @@ -11421,6 +11423,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
this.exitEditingOnOthers(this.canvas);
}
this.isEditing = true;
this.selected = true;
this.initHiddenTextarea(e);
this.hiddenTextarea.focus();
this._updateTextarea();
Expand Down Expand Up @@ -11685,7 +11688,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
}
}
}
var newStyle = style || currentLineStyles[charIndex - 1];
var newStyle = style || clone(currentLineStyles[charIndex - 1]);
newStyle && (this.styles[lineIndex][charIndex] = newStyle);
this._forceClearCache = true;
},
Expand All @@ -11702,6 +11705,12 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
},
shiftLineStyles: function(lineIndex, offset) {
var clonedStyles = clone(this.styles);
for (var line in clonedStyles) {
var numericLine = parseInt(line, 10);
if (numericLine <= lineIndex) {
delete clonedStyles[numericLine];
}
}
for (var line in this.styles) {
var numericLine = parseInt(line, 10);
if (numericLine > lineIndex) {
Expand Down Expand Up @@ -11930,7 +11939,7 @@ fabric.util.object.extend(fabric.IText.prototype, {
this.hiddenTextarea = fabric.document.createElement("textarea");
this.hiddenTextarea.setAttribute("autocapitalize", "off");
var style = this._calcTextareaPosition();
this.hiddenTextarea.style.cssText = "position: absolute; top: " + style.top + "; left: " + style.left + ";" + " opacity: 0; width: 0px; height: 0px; z-index: -999;";
this.hiddenTextarea.style.cssText = "white-space: nowrap; position: absolute; top: " + style.top + "; left: " + style.left + "; opacity: 0; width: 1px; height: 1px; z-index: -999;";
fabric.document.body.appendChild(this.hiddenTextarea);
fabric.util.addListener(this.hiddenTextarea, "keydown", this.onKeyDown.bind(this));
fabric.util.addListener(this.hiddenTextarea, "keyup", this.onKeyUp.bind(this));
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": "1.7.8",
"version": "1.7.9",
"author": "Juriy Zaytsev <[email protected]>",
"contributors": [
{
Expand Down
3 changes: 2 additions & 1 deletion src/elements_parser.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
fabric.ElementsParser = function(elements, callback, options, reviver) {
fabric.ElementsParser = function(elements, callback, options, reviver, parsingOptions) {
this.elements = elements;
this.callback = callback;
this.options = options;
this.reviver = reviver;
this.svgUid = (options && options.svgUid) || 0;
this.parsingOptions = parsingOptions;
};

fabric.ElementsParser.prototype.parse = function() {
Expand Down
12 changes: 9 additions & 3 deletions src/mixins/itext_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
}

this.isEditing = true;

this.selected = true;
this.initHiddenTextarea(e);
this.hiddenTextarea.focus();
this._updateTextarea();
Expand Down Expand Up @@ -730,7 +730,7 @@
}
}
}
var newStyle = style || currentLineStyles[charIndex - 1];
var newStyle = style || clone(currentLineStyles[charIndex - 1]);
newStyle && (this.styles[lineIndex][charIndex] = newStyle);
this._forceClearCache = true;
},
Expand Down Expand Up @@ -766,8 +766,14 @@
* @param {Number} offset Can be -1 or +1
*/
shiftLineStyles: function(lineIndex, offset) {
// shift all line styles by 1 upward
// shift all line styles by 1 upward or downward
var clonedStyles = clone(this.styles);
for (var line in clonedStyles) {
var numericLine = parseInt(line, 10);
if (numericLine <= lineIndex) {
delete clonedStyles[numericLine];
}
}
for (var line in this.styles) {
var numericLine = parseInt(line, 10);
if (numericLine > lineIndex) {
Expand Down
1 change: 0 additions & 1 deletion src/mixins/itext_click_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
return;
}
var pointer = this.canvas.getPointer(options.e);

this.__mousedownX = pointer.x;
this.__mousedownY = pointer.y;
this.__isMousedown = true;
Expand Down
Loading