redhotmagma-graphics-editor 1.41.1 → 1.42.1

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.
Files changed (82) hide show
  1. package/App.js +90 -165
  2. package/CanvasAdapters/Mock/Canvas.js +71 -125
  3. package/CanvasAdapters/Mock/Objects/CanvasObject.js +23 -40
  4. package/CanvasAdapters/Mock/Objects/Group.js +15 -46
  5. package/CanvasAdapters/Mock/Objects/Image.js +15 -46
  6. package/CanvasAdapters/Mock/Objects/Text.js +15 -51
  7. package/CanvasAdapters/Mock/index.js +0 -1
  8. package/CanvasAdapters/PaperJs/Canvas.js +268 -398
  9. package/CanvasAdapters/PaperJs/CanvasRepository.js +6 -23
  10. package/CanvasAdapters/PaperJs/Modifiers/FontSizeMin.js +2 -5
  11. package/CanvasAdapters/PaperJs/Objects/CanvasObject.js +33 -65
  12. package/CanvasAdapters/PaperJs/Objects/Group.js +14 -48
  13. package/CanvasAdapters/PaperJs/Objects/Image.js +58 -114
  14. package/CanvasAdapters/PaperJs/Objects/Text.js +43 -99
  15. package/CanvasAdapters/PaperJs/Utils/HTML2Paper.js +57 -108
  16. package/CanvasAdapters/PaperJs/Utils/SVGfix.js +9 -30
  17. package/CanvasAdapters/PaperJs/Utils/StyleParams.js +10 -21
  18. package/CanvasAdapters/PaperJs/Utils/TextToSVGRepository.js +53 -86
  19. package/CanvasAdapters/PaperJs/Utils/TextToSVGUtils.js +4 -14
  20. package/CanvasAdapters/PaperJs/Utils/UTF8Base64.js +3 -24
  21. package/CanvasAdapters/PaperJs/Utils/UseColorLayer.js +58 -0
  22. package/CanvasAdapters/PaperJs/Utils/UseMask.js +183 -279
  23. package/CanvasAdapters/PaperJs/Utils/__tests__/SVGfix.test.js +0 -1
  24. package/CanvasAdapters/PaperJs/Utils/__tests__/TextToSVGUtils.test.js +0 -1
  25. package/CanvasAdapters/PaperJs/Utils/__tests__/updateFontStyle.test.js +0 -1
  26. package/CanvasAdapters/PaperJs/Utils/updateFontStyle.js +5 -11
  27. package/CanvasAdapters/PaperJs/index.js +0 -1
  28. package/CanvasInterface/Canvas.js +145 -235
  29. package/CanvasInterface/CanvasProvider.js +25 -75
  30. package/CanvasInterface/Objects/CanvasObject.js +68 -148
  31. package/CanvasInterface/Objects/index.js +0 -1
  32. package/CanvasInterface/Observable.js +10 -29
  33. package/CanvasInterface/canvasConnect.js +12 -44
  34. package/CanvasInterface/index.js +1 -7
  35. package/Components/Canvas/Canvas.js +14 -41
  36. package/Components/Canvas/CanvasContainer.js +5 -18
  37. package/Components/Canvas/styles.js +2 -3
  38. package/Components/DelayedContainer.js +14 -39
  39. package/Components/Editor/Editor.js +47 -102
  40. package/Components/Editor/EditorContainer.js +47 -131
  41. package/Components/Editor/styles.js +2 -3
  42. package/Components/InlineToolbox/InlineToolbox.js +49 -142
  43. package/Components/InlineToolbox/InlineToolboxButton.js +9 -19
  44. package/Components/InlineToolbox/styles.js +2 -3
  45. package/Components/ManipulableContainer.js +15 -41
  46. package/Components/ResizeDetect/ResizeDetect.js +14 -47
  47. package/Components/Rulers/Ruler.js +20 -68
  48. package/Components/Rulers/Rulers.js +14 -46
  49. package/Components/Rulers/styles.js +2 -3
  50. package/Components/SelectionToolbox/ColorPalette.js +25 -73
  51. package/Components/SelectionToolbox/SelectionToolbox.js +39 -101
  52. package/Components/SelectionToolbox/TextTools.js +81 -157
  53. package/Components/SelectionToolbox/styles.js +2 -3
  54. package/Components/StandardToolbox/StandardToolbox.js +81 -144
  55. package/Components/TextEditor/TextEditor.js +67 -182
  56. package/Components/TextEditor/TextEditorStateProvider.js +20 -56
  57. package/Components/Toolbox/ToolboxContainer.js +5 -18
  58. package/Components/Toolbox/ToolboxRow.js +4 -16
  59. package/Components/Toolbox/styles.js +2 -3
  60. package/Utils/Calc2D.js +3 -9
  61. package/Utils/DOM.js +22 -80
  62. package/Utils/Device.js +2 -6
  63. package/Utils/Image.js +17 -11
  64. package/Utils/Logger.js +8 -32
  65. package/Utils/Range.js +6 -33
  66. package/Utils/String.js +2 -8
  67. package/Utils/UnitConversion.js +3 -9
  68. package/Utils/__tests__/Calc2D.test.js +1 -3
  69. package/Utils/__tests__/DOM.test.js +17 -25
  70. package/Utils/__tests__/Range.test.js +0 -1
  71. package/_demos/UsingExternalControls/App.js +13 -48
  72. package/_demos/UsingRenderProps/App.js +15 -54
  73. package/index.js +2 -6
  74. package/package.json +5 -7
  75. package/src/App.js +35 -38
  76. package/src/CanvasAdapters/PaperJs/Canvas.ts +11 -0
  77. package/src/CanvasAdapters/PaperJs/Utils/UseColorLayer.js +56 -0
  78. package/src/Components/InlineToolbox/InlineToolbox.js +2 -2
  79. package/src/Components/SelectionToolbox/TextTools.js +1 -1
  80. package/src/_demos/UsingExternalControls/App.js +25 -28
  81. package/src/_demos/UsingRenderProps/App.js +16 -19
  82. package/src/index.js +2 -2
@@ -1,72 +1,45 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports["default"] = exports.StandardToolbox = void 0;
9
-
10
7
  var _react = _interopRequireDefault(require("react"));
11
-
12
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
9
  var _ToolboxContainer = _interopRequireDefault(require("../Toolbox/ToolboxContainer"));
15
-
16
10
  var _ToolboxRow = _interopRequireDefault(require("../Toolbox/ToolboxRow"));
17
-
18
11
  var _Logger = _interopRequireDefault(require("../../Utils/Logger"));
19
-
20
12
  var _CanvasProvider = require("../../CanvasInterface/CanvasProvider");
21
-
22
13
  var _Canvas = require("../../CanvasInterface/Canvas");
23
-
24
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
-
15
+ 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); }
16
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
26
17
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
27
-
28
18
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
29
-
30
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
-
32
- 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, descriptor.key, descriptor); } }
33
-
34
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
35
-
36
- 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); }
37
-
38
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
39
-
20
+ 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); } }
21
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
22
+ 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); }
23
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
40
24
  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); }; }
41
-
42
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
43
-
25
+ 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); }
44
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
45
-
46
27
  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; } }
47
-
48
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
-
50
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
51
-
28
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
29
+ 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; }
30
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
31
+ 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); }
52
32
  var logger = new _Logger["default"]('StandardToolbox');
53
-
54
- var StandardToolbox = /*#__PURE__*/function (_React$Component) {
33
+ var StandardToolbox = exports.StandardToolbox = /*#__PURE__*/function (_React$Component) {
55
34
  _inherits(StandardToolbox, _React$Component);
56
-
57
35
  var _super = _createSuper(StandardToolbox);
58
-
59
36
  function StandardToolbox() {
60
37
  var _this;
61
-
62
38
  _classCallCheck(this, StandardToolbox);
63
-
64
39
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
65
40
  args[_key] = arguments[_key];
66
41
  }
67
-
68
42
  _this = _super.call.apply(_super, [this].concat(args));
69
-
70
43
  _defineProperty(_assertThisInitialized(_this), "onAddTextClick", function () {
71
44
  var canvas = _this.props.canvas;
72
45
  canvas.addText({
@@ -74,123 +47,95 @@ var StandardToolbox = /*#__PURE__*/function (_React$Component) {
74
47
  fontSizeMin: 10
75
48
  }).alignTo('center', 'center');
76
49
  });
77
-
78
50
  _defineProperty(_assertThisInitialized(_this), "onImageFileSelected", /*#__PURE__*/function () {
79
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(evt) {
51
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(evt) {
80
52
  var _this$props, upload, canvas, files, results, i, file, result, group, image;
81
-
82
- return regeneratorRuntime.wrap(function _callee$(_context) {
83
- while (1) {
84
- switch (_context.prev = _context.next) {
85
- case 0:
86
- _this$props = _this.props, upload = _this$props.upload, canvas = _this$props.canvas;
87
-
88
- if (!upload) {
89
- _context.next = 38;
90
- break;
91
- }
92
-
93
- files = evt.target.files;
94
- _context.next = 5;
95
- return upload(files);
96
-
97
- case 5:
98
- results = _context.sent;
99
-
100
- if (!results) {
101
- _context.next = 38;
102
- break;
103
- }
104
-
105
- i = 0;
106
-
107
- case 8:
108
- if (!(i < files.length)) {
109
- _context.next = 38;
110
- break;
111
- }
112
-
113
- file = files[i];
114
- result = results[i];
115
-
116
- if (!result) {
117
- _context.next = 34;
118
- break;
119
- }
120
-
121
- _context.prev = 12;
122
- _context.t0 = file.type;
123
- _context.next = _context.t0 === 'image/svg+xml' ? 16 : _context.t0 === 'image/png' ? 21 : _context.t0 === 'image/jpeg' ? 21 : _context.t0 === 'image/gif' ? 21 : 26;
53
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
54
+ while (1) switch (_context.prev = _context.next) {
55
+ case 0:
56
+ _this$props = _this.props, upload = _this$props.upload, canvas = _this$props.canvas;
57
+ if (!upload) {
58
+ _context.next = 38;
124
59
  break;
125
-
126
- case 16:
127
- _context.next = 18;
128
- return canvas.addGroup(result);
129
-
130
- case 18:
131
- group = _context.sent;
132
- group.fitCanvas();
133
- return _context.abrupt("break", 27);
134
-
135
- case 21:
136
- _context.next = 23;
137
- return canvas.addImage(result);
138
-
139
- case 23:
140
- image = _context.sent;
141
- image.fitCanvas();
142
- return _context.abrupt("break", 27);
143
-
144
- case 26:
145
- logger.error("Unhandled mime type: ".concat(file.type));
146
-
147
- case 27:
148
- _context.next = 32;
60
+ }
61
+ files = evt.target.files;
62
+ _context.next = 5;
63
+ return upload(files);
64
+ case 5:
65
+ results = _context.sent;
66
+ if (!results) {
67
+ _context.next = 38;
149
68
  break;
150
-
151
- case 29:
152
- _context.prev = 29;
153
- _context.t1 = _context["catch"](12);
154
- logger.error('File cannot be added.', _context.t1);
155
-
156
- case 32:
157
- _context.next = 35;
69
+ }
70
+ i = 0;
71
+ case 8:
72
+ if (!(i < files.length)) {
73
+ _context.next = 38;
158
74
  break;
159
-
160
- case 34:
161
- logger.warn('No result for the following file:', file);
162
-
163
- case 35:
164
- i++;
165
- _context.next = 8;
75
+ }
76
+ file = files[i];
77
+ result = results[i];
78
+ if (!result) {
79
+ _context.next = 34;
166
80
  break;
167
-
168
- case 38:
169
- case "end":
170
- return _context.stop();
171
- }
81
+ }
82
+ _context.prev = 12;
83
+ _context.t0 = file.type;
84
+ _context.next = _context.t0 === 'image/svg+xml' ? 16 : _context.t0 === 'image/png' ? 21 : _context.t0 === 'image/jpeg' ? 21 : _context.t0 === 'image/gif' ? 21 : 26;
85
+ break;
86
+ case 16:
87
+ _context.next = 18;
88
+ return canvas.addGroup(result);
89
+ case 18:
90
+ group = _context.sent;
91
+ group.fitCanvas();
92
+ return _context.abrupt("break", 27);
93
+ case 21:
94
+ _context.next = 23;
95
+ return canvas.addImage(result);
96
+ case 23:
97
+ image = _context.sent;
98
+ image.fitCanvas();
99
+ return _context.abrupt("break", 27);
100
+ case 26:
101
+ logger.error("Unhandled mime type: ".concat(file.type));
102
+ case 27:
103
+ _context.next = 32;
104
+ break;
105
+ case 29:
106
+ _context.prev = 29;
107
+ _context.t1 = _context["catch"](12);
108
+ logger.error('File cannot be added.', _context.t1);
109
+ case 32:
110
+ _context.next = 35;
111
+ break;
112
+ case 34:
113
+ logger.warn('No result for the following file:', file);
114
+ case 35:
115
+ i++;
116
+ _context.next = 8;
117
+ break;
118
+ case 38:
119
+ case "end":
120
+ return _context.stop();
172
121
  }
173
122
  }, _callee, null, [[12, 29]]);
174
123
  }));
175
-
176
124
  return function (_x) {
177
125
  return _ref.apply(this, arguments);
178
126
  };
179
127
  }());
180
-
181
128
  return _this;
182
129
  }
183
-
184
130
  _createClass(StandardToolbox, [{
185
131
  key: "render",
186
132
  value: function render() {
187
133
  logger.log('render StandardToolbox');
188
134
  var props = this.props,
189
- onAddTextClick = this.onAddTextClick,
190
- onImageFileSelected = this.onImageFileSelected;
135
+ onAddTextClick = this.onAddTextClick,
136
+ onImageFileSelected = this.onImageFileSelected;
191
137
  var children = props.children,
192
- canvas = props.canvas;
193
-
138
+ canvas = props.canvas;
194
139
  if (typeof children === 'function') {
195
140
  return children({
196
141
  onAddTextClick: onAddTextClick,
@@ -202,7 +147,6 @@ var StandardToolbox = /*#__PURE__*/function (_React$Component) {
202
147
  }
203
148
  });
204
149
  }
205
-
206
150
  return /*#__PURE__*/_react["default"].createElement(_ToolboxContainer["default"], {
207
151
  style: {
208
152
  position: 'fixed',
@@ -217,18 +161,11 @@ var StandardToolbox = /*#__PURE__*/function (_React$Component) {
217
161
  })));
218
162
  }
219
163
  }]);
220
-
221
164
  return StandardToolbox;
222
165
  }(_react["default"].Component);
223
-
224
- exports.StandardToolbox = StandardToolbox;
225
-
226
166
  _defineProperty(StandardToolbox, "propTypes", {
227
167
  children: _propTypes["default"].func,
228
168
  upload: _propTypes["default"].func,
229
169
  canvas: _propTypes["default"].instanceOf(_Canvas.AbstractCanvas).isRequired
230
170
  });
231
-
232
- var _default = (0, _CanvasProvider.withCanvas)(StandardToolbox);
233
-
234
- exports["default"] = _default;
171
+ var _default = exports["default"] = (0, _CanvasProvider.withCanvas)(StandardToolbox);