redhotmagma-graphics-editor 1.41.1 → 1.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +90 -165
- package/CanvasAdapters/Mock/Canvas.js +71 -125
- package/CanvasAdapters/Mock/Objects/CanvasObject.js +23 -40
- package/CanvasAdapters/Mock/Objects/Group.js +15 -46
- package/CanvasAdapters/Mock/Objects/Image.js +15 -46
- package/CanvasAdapters/Mock/Objects/Text.js +15 -51
- package/CanvasAdapters/Mock/index.js +0 -1
- package/CanvasAdapters/PaperJs/Canvas.js +268 -398
- package/CanvasAdapters/PaperJs/CanvasRepository.js +6 -23
- package/CanvasAdapters/PaperJs/Modifiers/FontSizeMin.js +2 -5
- package/CanvasAdapters/PaperJs/Objects/CanvasObject.js +33 -65
- package/CanvasAdapters/PaperJs/Objects/Group.js +14 -48
- package/CanvasAdapters/PaperJs/Objects/Image.js +58 -114
- package/CanvasAdapters/PaperJs/Objects/Text.js +43 -99
- package/CanvasAdapters/PaperJs/Utils/HTML2Paper.js +57 -108
- package/CanvasAdapters/PaperJs/Utils/SVGfix.js +9 -30
- package/CanvasAdapters/PaperJs/Utils/StyleParams.js +10 -21
- package/CanvasAdapters/PaperJs/Utils/TextToSVGRepository.js +53 -86
- package/CanvasAdapters/PaperJs/Utils/TextToSVGUtils.js +4 -14
- package/CanvasAdapters/PaperJs/Utils/UTF8Base64.js +3 -24
- package/CanvasAdapters/PaperJs/Utils/UseColorLayer.js +58 -0
- package/CanvasAdapters/PaperJs/Utils/UseMask.js +183 -279
- package/CanvasAdapters/PaperJs/Utils/__tests__/SVGfix.test.js +0 -1
- package/CanvasAdapters/PaperJs/Utils/__tests__/TextToSVGUtils.test.js +0 -1
- package/CanvasAdapters/PaperJs/Utils/__tests__/updateFontStyle.test.js +0 -1
- package/CanvasAdapters/PaperJs/Utils/updateFontStyle.js +5 -11
- package/CanvasAdapters/PaperJs/index.js +0 -1
- package/CanvasInterface/Canvas.js +145 -235
- package/CanvasInterface/CanvasProvider.js +25 -75
- package/CanvasInterface/Objects/CanvasObject.js +68 -148
- package/CanvasInterface/Objects/index.js +0 -1
- package/CanvasInterface/Observable.js +10 -29
- package/CanvasInterface/canvasConnect.js +12 -44
- package/CanvasInterface/index.js +1 -7
- package/Components/Canvas/Canvas.js +14 -41
- package/Components/Canvas/CanvasContainer.js +5 -18
- package/Components/Canvas/styles.js +2 -3
- package/Components/DelayedContainer.js +14 -39
- package/Components/Editor/Editor.js +47 -102
- package/Components/Editor/EditorContainer.js +47 -131
- package/Components/Editor/styles.js +2 -3
- package/Components/InlineToolbox/InlineToolbox.js +49 -142
- package/Components/InlineToolbox/InlineToolboxButton.js +9 -19
- package/Components/InlineToolbox/styles.js +2 -3
- package/Components/ManipulableContainer.js +15 -41
- package/Components/ResizeDetect/ResizeDetect.js +14 -47
- package/Components/Rulers/Ruler.js +20 -68
- package/Components/Rulers/Rulers.js +14 -46
- package/Components/Rulers/styles.js +2 -3
- package/Components/SelectionToolbox/ColorPalette.js +25 -73
- package/Components/SelectionToolbox/SelectionToolbox.js +39 -101
- package/Components/SelectionToolbox/TextTools.js +81 -157
- package/Components/SelectionToolbox/styles.js +2 -3
- package/Components/StandardToolbox/StandardToolbox.js +81 -144
- package/Components/TextEditor/TextEditor.js +67 -182
- package/Components/TextEditor/TextEditorStateProvider.js +20 -56
- package/Components/Toolbox/ToolboxContainer.js +5 -18
- package/Components/Toolbox/ToolboxRow.js +4 -16
- package/Components/Toolbox/styles.js +2 -3
- package/Utils/Calc2D.js +3 -9
- package/Utils/DOM.js +22 -80
- package/Utils/Device.js +2 -6
- package/Utils/Image.js +17 -11
- package/Utils/Logger.js +8 -32
- package/Utils/Range.js +6 -33
- package/Utils/String.js +2 -8
- package/Utils/UnitConversion.js +3 -9
- package/Utils/__tests__/Calc2D.test.js +1 -3
- package/Utils/__tests__/DOM.test.js +17 -25
- package/Utils/__tests__/Range.test.js +0 -1
- package/_demos/UsingExternalControls/App.js +13 -48
- package/_demos/UsingRenderProps/App.js +15 -54
- package/index.js +2 -6
- package/package.json +5 -7
- package/src/App.js +35 -38
- package/src/CanvasAdapters/PaperJs/Canvas.ts +11 -0
- package/src/CanvasAdapters/PaperJs/Utils/UseColorLayer.js +56 -0
- package/src/Components/InlineToolbox/InlineToolbox.js +2 -2
- package/src/Components/SelectionToolbox/TextTools.js +1 -1
- package/src/_demos/UsingExternalControls/App.js +25 -28
- package/src/_demos/UsingRenderProps/App.js +16 -19
- package/src/index.js +2 -2
|
@@ -1,61 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.withCanvasState = exports.
|
|
9
|
-
|
|
7
|
+
exports.withCanvasState = exports.withCanvas = exports.CanvasStateProvider = exports.CanvasStateContext = exports.CanvasProvider = exports.CanvasContext = void 0;
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
15
|
-
|
|
16
11
|
var _Canvas = require("./Canvas");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
30
18
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
19
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
34
20
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
21
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var CanvasContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
45
|
-
|
|
46
|
-
exports.CanvasContext = CanvasContext;
|
|
47
|
-
|
|
48
|
-
var CanvasProvider = function CanvasProvider(_ref) {
|
|
22
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
25
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
26
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
|
+
var CanvasContext = exports.CanvasContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
28
|
+
var CanvasProvider = exports.CanvasProvider = function CanvasProvider(_ref) {
|
|
49
29
|
var canvas = _ref.canvas,
|
|
50
|
-
|
|
30
|
+
children = _ref.children;
|
|
51
31
|
return /*#__PURE__*/_react["default"].createElement(CanvasContext.Provider, {
|
|
52
32
|
value: canvas
|
|
53
33
|
}, children);
|
|
54
34
|
};
|
|
55
|
-
|
|
56
|
-
exports.CanvasProvider = CanvasProvider;
|
|
57
|
-
|
|
58
|
-
var withCanvas = function withCanvas(Component) {
|
|
35
|
+
var withCanvas = exports.withCanvas = function withCanvas(Component) {
|
|
59
36
|
return function (props) {
|
|
60
37
|
return /*#__PURE__*/_react["default"].createElement(CanvasContext.Consumer, null, function (canvas) {
|
|
61
38
|
return canvas && /*#__PURE__*/_react["default"].createElement(Component, _extends({
|
|
@@ -64,58 +41,40 @@ var withCanvas = function withCanvas(Component) {
|
|
|
64
41
|
});
|
|
65
42
|
};
|
|
66
43
|
};
|
|
67
|
-
|
|
68
|
-
exports.
|
|
69
|
-
|
|
70
|
-
var CanvasStateContext = /*#__PURE__*/_react["default"].createContext({});
|
|
71
|
-
|
|
72
|
-
exports.CanvasStateContext = CanvasStateContext;
|
|
73
|
-
|
|
74
|
-
var CanvasStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
44
|
+
var CanvasStateContext = exports.CanvasStateContext = /*#__PURE__*/_react["default"].createContext({});
|
|
45
|
+
var CanvasStateProvider = exports.CanvasStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
75
46
|
_inherits(CanvasStateProvider, _React$Component);
|
|
76
|
-
|
|
77
47
|
var _super = _createSuper(CanvasStateProvider);
|
|
78
|
-
|
|
79
48
|
function CanvasStateProvider() {
|
|
80
49
|
var _this;
|
|
81
|
-
|
|
82
50
|
_classCallCheck(this, CanvasStateProvider);
|
|
83
|
-
|
|
84
51
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
85
52
|
args[_key] = arguments[_key];
|
|
86
53
|
}
|
|
87
|
-
|
|
88
54
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
89
|
-
|
|
55
|
+
// get the initial state of the canvas
|
|
90
56
|
_defineProperty(_assertThisInitialized(_this), "state", _this.props.canvas ? _this.props.canvas.getState() : {});
|
|
91
|
-
|
|
92
57
|
_defineProperty(_assertThisInitialized(_this), "onChange", function (canvas) {
|
|
93
58
|
if (!canvas) {
|
|
94
59
|
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
60
|
+
}
|
|
61
|
+
// for the first change event the state should be updated immediately
|
|
98
62
|
if (!_this._firstChangeDone) {
|
|
99
63
|
_this._firstChangeDone = true;
|
|
100
|
-
|
|
101
64
|
_this.setState(canvas.getState());
|
|
102
65
|
} else {
|
|
103
66
|
// the other updates should be debounced to avoid performance problems of frequent re-rendering
|
|
104
67
|
_this.onChangeDebounced(canvas);
|
|
105
68
|
}
|
|
106
69
|
});
|
|
107
|
-
|
|
108
70
|
_defineProperty(_assertThisInitialized(_this), "onChangeDebounced", (0, _debounce["default"])(function (canvas) {
|
|
109
71
|
_this.setState(canvas.getState());
|
|
110
72
|
}, 10));
|
|
111
|
-
|
|
112
73
|
_defineProperty(_assertThisInitialized(_this), "resetFirstChange", (0, _debounce["default"])(function () {
|
|
113
74
|
_this._firstChangeDone = false;
|
|
114
75
|
}, 100));
|
|
115
|
-
|
|
116
76
|
return _this;
|
|
117
77
|
}
|
|
118
|
-
|
|
119
78
|
_createClass(CanvasStateProvider, [{
|
|
120
79
|
key: "componentDidMount",
|
|
121
80
|
value: function componentDidMount() {
|
|
@@ -127,14 +86,13 @@ var CanvasStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
127
86
|
value: function componentDidUpdate(prevProps) {
|
|
128
87
|
var prevCanvas = prevProps.canvas;
|
|
129
88
|
var canvas = this.props.canvas;
|
|
130
|
-
|
|
131
89
|
if (prevCanvas !== canvas) {
|
|
132
90
|
this.removeEvents(prevCanvas);
|
|
133
91
|
this.onChange(canvas);
|
|
134
92
|
this.initEvents(canvas);
|
|
135
|
-
}
|
|
136
|
-
|
|
93
|
+
}
|
|
137
94
|
|
|
95
|
+
// after a state update the _firstChangeDone should be reset
|
|
138
96
|
if (this._firstChangeDone) {
|
|
139
97
|
this.resetFirstChange();
|
|
140
98
|
}
|
|
@@ -171,26 +129,18 @@ var CanvasStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
171
129
|
}, this.props.children);
|
|
172
130
|
}
|
|
173
131
|
}]);
|
|
174
|
-
|
|
175
132
|
return CanvasStateProvider;
|
|
176
133
|
}(_react["default"].Component);
|
|
177
|
-
|
|
178
|
-
exports.CanvasStateProvider = CanvasStateProvider;
|
|
179
|
-
|
|
180
134
|
_defineProperty(CanvasStateProvider, "propTypes", {
|
|
181
135
|
canvas: _propTypes["default"].instanceOf(_Canvas.AbstractCanvas)
|
|
182
136
|
});
|
|
183
|
-
|
|
184
137
|
_defineProperty(CanvasStateProvider, "defaultProps", {
|
|
185
138
|
canvas: null
|
|
186
139
|
});
|
|
187
|
-
|
|
188
|
-
var withCanvasState = function withCanvasState(Component) {
|
|
140
|
+
var withCanvasState = exports.withCanvasState = function withCanvasState(Component) {
|
|
189
141
|
return function (props) {
|
|
190
142
|
return /*#__PURE__*/_react["default"].createElement(CanvasStateContext.Consumer, null, function (state) {
|
|
191
143
|
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, state, props));
|
|
192
144
|
});
|
|
193
145
|
};
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
exports.withCanvasState = withCanvasState;
|
|
146
|
+
};
|