This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new a2c0657 [OPENMEETINGS-2024] fabric is updated alpha is fixed
a2c0657 is described below
commit a2c0657b142ad760230ff6c8ef59d9e47da03e21
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Tue Mar 5 17:47:07 2019 +0700
[OPENMEETINGS-2024] fabric is updated alpha is fixed
---
.../org/apache/openmeetings/web/room/wb/fabric.js | 117 +++++++++++++++++----
.../openmeetings/web/room/wb/raw-tool-math.js | 5 +-
2 files changed, 99 insertions(+), 23 deletions(-)
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js
index 179a3d3..363d401 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js
@@ -2,7 +2,7 @@
/* build: `node build.js modules=ALL exclude=gestures,accessors requirejs
minifier=uglifyjs` */
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
-var fabric = fabric || { version: '2.6.0' };
+var fabric = fabric || { version: '2.7.0' };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
@@ -12,7 +12,10 @@ else if (typeof define === 'function' && define.amd) {
}
/* _AMD_END_ */
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
- fabric.document = document;
+ if (document instanceof HTMLDocument)
+ fabric.document = document;
+ else
+ fabric.document = document.implementation.createHTMLDocument("");
fabric.window = window;
}
else {
@@ -57,7 +60,7 @@ fabric.SHARED_ATTRIBUTES = [
'stroke', 'stroke-dasharray', 'stroke-linecap', 'stroke-dashoffset',
'stroke-linejoin', 'stroke-miterlimit',
'stroke-opacity', 'stroke-width',
- 'id', 'paint-order',
+ 'id', 'paint-order', 'vector-effect',
'instantiated_by_use', 'clip-path'
];
/* _FROM_SVG_END_ */
@@ -3412,6 +3415,7 @@ if (typeof console !== 'undefined') {
opacity: 'opacity',
'clip-path': 'clipPath',
'clip-rule': 'clipRule',
+ 'vector-effect': 'strokeUniform'
},
colorAttributes = {
@@ -3443,6 +3447,9 @@ if (typeof console !== 'undefined') {
if ((attr === 'fill' || attr === 'stroke') && value === 'none') {
value = '';
}
+ else if (attr === 'vector-effect') {
+ value = value === 'non-scaling-stroke';
+ }
else if (attr === 'strokeDashArray') {
if (value === 'none') {
value = null;
@@ -9850,8 +9857,12 @@ fabric.PatternBrush =
fabric.util.createClass(fabric.PencilBrush, /** @lends fab
/**
* @private
+ * @param {Boolean} alreadySelected true if target is already selected
+ * @param {String} corner a string representing the corner ml, mr, tl ...
+ * @param {Event} e Event object
+ * @param {fabric.Object} [target] inserted back to help overriding. Unused
*/
- _getActionFromCorner: function(alreadySelected, corner, e) {
+ _getActionFromCorner: function(alreadySelected, corner, e /* target */) {
if (!corner || !alreadySelected) {
return 'drag';
}
@@ -9882,7 +9893,7 @@ fabric.PatternBrush =
fabric.util.createClass(fabric.PencilBrush, /** @lends fab
var pointer = this.getPointer(e),
corner = target._findTargetCorner(this.getPointer(e, true)),
- action = this._getActionFromCorner(alreadySelected, corner, e),
+ action = this._getActionFromCorner(alreadySelected, corner, e,
target),
origin = this._getOriginFromCorner(target, corner);
this._currentTransform = {
@@ -12959,6 +12970,18 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
noScaleCache: true,
/**
+ * When `false`, the stoke width will scale with the object.
+ * When `true`, the stroke will always match the exact pixel size entered
for stroke width.
+ * default to false
+ * @since 2.6.0
+ * @type Boolean
+ * @default false
+ * @type Boolean
+ * @default false
+ */
+ strokeUniform: false,
+
+ /**
* When set to `true`, object's cache will be rerendered next render call.
* since 1.7.0
* @type Boolean
@@ -12993,7 +13016,7 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
'top left width height scaleX scaleY flipX flipY originX originY
transformMatrix ' +
'stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset
strokeLineJoin strokeMiterLimit ' +
'angle opacity fill globalCompositeOperation shadow clipTo visible
backgroundColor ' +
- 'skewX skewY fillRule paintFirst clipPath'
+ 'skewX skewY fillRule paintFirst clipPath strokeUniform'
).split(' '),
/**
@@ -13004,7 +13027,7 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
* @type Array
*/
cacheProperties: (
- 'fill stroke strokeWidth strokeDashArray width height paintFirst' +
+ 'fill stroke strokeWidth strokeDashArray width height paintFirst
strokeUniform' +
' strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit
backgroundColor clipPath'
).split(' '),
@@ -13725,6 +13748,9 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
else {
alternative && alternative(ctx);
}
+ if (this.strokeUniform) {
+ ctx.setLineDash(ctx.getLineDash().map(function(value) { return value *
ctx.lineWidth; }));
+ }
},
/**
@@ -13862,6 +13888,9 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
}
ctx.save();
+ if (this.strokeUniform) {
+ ctx.scale(1 / this.scaleX, 1 / this.scaleY);
+ }
this._setLineDash(ctx, this.strokeDashArray, this._renderDashedStroke);
this._applyPatternGradientTransform(ctx, this.stroke);
ctx.stroke();
@@ -15221,12 +15250,25 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
if (typeof skewY === 'undefined') {
skewY = this.skewY;
}
- var dimensions = this._getNonTransformedDimensions();
- if (skewX === 0 && skewY === 0) {
- return { x: dimensions.x * this.scaleX, y: dimensions.y * this.scaleY
};
+ var dimensions = this._getNonTransformedDimensions(), dimX, dimY,
+ noSkew = skewX === 0 && skewY === 0;
+
+ if (this.strokeUniform) {
+ dimX = this.width;
+ dimY = this.height;
}
- var dimX = dimensions.x / 2, dimY = dimensions.y / 2,
- points = [
+ else {
+ dimX = dimensions.x;
+ dimY = dimensions.y;
+ }
+ if (noSkew) {
+ return this._finalizeDiemensions(dimX * this.scaleX, dimY *
this.scaleY);
+ }
+ else {
+ dimX /= 2;
+ dimY /= 2;
+ }
+ var points = [
{
x: -dimX,
y: -dimY
@@ -15249,10 +15291,24 @@
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
points[i] = fabric.util.transformPoint(points[i], transformMatrix);
}
bbox = fabric.util.makeBoundingBoxFromPoints(points);
- return { x: bbox.width, y: bbox.height };
+ return this._finalizeDiemensions(bbox.width, bbox.height);
},
/*
+ * Calculate object bounding boxdimensions from its properties scale, skew.
+ * @param Number width width of the bbox
+ * @param Number height height of the bbox
+ * @private
+ * @return {Object} .x finalized width dimension
+ * @return {Object} .y finalized height dimension
+ */
+ _finalizeDiemensions: function(width, height) {
+ return this.strokeUniform ?
+ { x: width + this.strokeWidth, y: height + this.strokeWidth }
+ :
+ { x: width, y: height };
+ },
+ /*
* Calculate object dimensions for controls. include padding and canvas
zoom
* private
*/
@@ -15564,6 +15620,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
styleInfo = noStyle ? '' : 'style="' + this.getSvgStyles() + '" ',
shadowInfo = withShadow ? 'style="' + this.getSvgFilter() + '" ' :
'',
clipPath = this.clipPath,
+ vectorEffect = this.strokeUniform ?
'vector-effect="non-scaling-stroke" ' : '',
absoluteClipPath = this.clipPath && this.clipPath.absolutePositioned,
commonPieces, markup = [], clipPathMarkup,
// insert commons in the markup, style and svgCommons
@@ -15588,6 +15645,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
);
commonPieces = [
styleInfo,
+ vectorEffect,
noStyle ? '' : this.addPaintOrder(), ' ',
additionalTransform ? 'transform="' + additionalTransform + '" ' : '',
].join('');
@@ -16821,7 +16879,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
'<path d="M ' + startX + ' ' + startY,
' A ' + this.radius + ' ' + this.radius,
' 0 ', +largeFlag + ' 1', ' ' + endX + ' ' + endY,
- '"', 'COMMON_PARTS', ' />\n'
+ '" ', 'COMMON_PARTS', ' />\n'
];
}
return svgString;
@@ -19481,6 +19539,15 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
strokeWidth: 0,
/**
+ * When calling {@link fabric.Image.getSrc}, return value from element src
with `element.getAttribute('src')`.
+ * This allows for relative urls as image src.
+ * @since 2.7.0
+ * @type Boolean
+ * @default
+ */
+ srcFromAttribute: false,
+
+ /**
* private
* contains last value of scaleX to detect
* if the Image got resized after the last Render
@@ -19528,7 +19595,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
/**
* key used to retrieve the texture representing this image
- * since 2.0.0
+ * @since 2.0.0
* @type String
* @default
*/
@@ -19536,7 +19603,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
/**
* Image crop in pixels from original image size.
- * since 2.0.0
+ * @since 2.0.0
* @type Number
* @default
*/
@@ -19544,7 +19611,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
/**
* Image crop in pixels from original image size.
- * since 2.0.0
+ * @since 2.0.0
* @type Number
* @default
*/
@@ -19784,7 +19851,13 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
if (element.toDataURL) {
return element.toDataURL();
}
- return element.src;
+
+ if (this.srcFromAttribute) {
+ return element.getAttribute('src');
+ }
+ else {
+ return element.src;
+ }
}
else {
return this.src || '';
@@ -19803,7 +19876,7 @@ fabric.util.object.extend(fabric.Object.prototype, /**
@lends fabric.Object.prot
fabric.util.loadImage(src, function(img) {
this.setElement(img, options);
this._setWidthHeight();
- callback(this);
+ callback && callback(this);
}, this, options && options.crossOrigin);
return this;
},
@@ -28664,7 +28737,7 @@ fabric.util.object.extend(fabric.IText.prototype, /**
@lends fabric.IText.protot
* Use this regular expression to split strings in breakable lines
* @private
*/
- _wordJoiners: /[ \t\r\u200B\u200C]/,
+ _wordJoiners: /[ \t\r]/,
/**
* Use this boolean property in order to split strings that have no white
space concept.
@@ -28723,7 +28796,7 @@ fabric.util.object.extend(fabric.IText.prototype, /**
@lends fabric.IText.protot
charCount++;
realLineCount++;
}
- else if (this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&
i > 0) {
+ else if (!this.graphemeSplit &&
this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) && i > 0) {
// this case deals with space's that are removed from end of lines
when wrapping
realLineCharCount++;
charCount++;
@@ -28945,7 +29018,7 @@ fabric.util.object.extend(fabric.IText.prototype, /**
@lends fabric.IText.protot
lineWidth += additionalSpace;
}
- if (!lineJustStarted) {
+ if (!lineJustStarted && !splitByGrapheme) {
line.push(infix);
}
line = line.concat(word);
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-math.js
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-math.js
index 3e8db7a..ecca514 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-math.js
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-math.js
@@ -24,7 +24,10 @@ var StaticTMath = (function() {
function create(o, canvas, callback, errCallback) {
tex2svg(o.formula, function(svg) {
fabric.loadSVGFromString(svg, function(objects,
options) {
- const obj =
fabric.util.groupSVGElements(objects, $.extend({}, o, options));
+ const opts = $.extend({}, o, options)
+ , obj = objects.length === 1
+ ? new fabric.Group(objects,
opts)
+ :
fabric.util.groupSVGElements(objects, opts);
obj.selectable = canvas.selection;
obj.type = 'group';
if (typeof(callback) === 'function') {