diff --git a/build/files/HEADER.js b/build/files/HEADER.js index a69e069d99..8f151875d2 100644 --- a/build/files/HEADER.js +++ b/build/files/HEADER.js @@ -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; } @@ -18,6 +18,7 @@ else { FetchExternalResources: ['img'] } }); + fabric.jsdomImplForWrapper = require('jsdom/lib/jsdom/living/generated/utils').implForWrapper; fabric.window = fabric.document.defaultView; DOMParser = require('xmldom').DOMParser; } diff --git a/build/files/src/mixins/itext_behavior.mixin.js b/build/files/src/mixins/itext_behavior.mixin.js index 30601f8f3c..bbbeec85e9 100644 --- a/build/files/src/mixins/itext_behavior.mixin.js +++ b/build/files/src/mixins/itext_behavior.mixin.js @@ -572,7 +572,7 @@ 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; diff --git a/build/files/src/mixins/itext_key_behavior.mixin.js b/build/files/src/mixins/itext_key_behavior.mixin.js index 86e7de57d8..fb1496e620 100644 --- a/build/files/src/mixins/itext_key_behavior.mixin.js +++ b/build/files/src/mixins/itext_key_behavior.mixin.js @@ -591,55 +591,25 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot }, /** - * Removes characters selected by selection - * @param {Event} e Event object - */ - removeChars: function(e) { - if (this.selectionStart === this.selectionEnd) { - this._removeCharsNearCursor(e); - } - else { - this._removeCharsFromTo(this.selectionStart, this.selectionEnd); - } - + * 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(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); - } - } }); diff --git a/build/files/src/static_canvas.class.js b/build/files/src/static_canvas.class.js index 334bb0343f..a472933b27 100644 --- a/build/files/src/static_canvas.class.js +++ b/build/files/src/static_canvas.class.js @@ -1759,4 +1759,14 @@ */ 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); + }; + } })(); diff --git a/build/index.html b/build/index.html index a1bed36c1b..e15877ba9b 100644 --- a/build/index.html +++ b/build/index.html @@ -21,7 +21,7 @@ } -
fromLeft