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
|
@@ -4,79 +4,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _cssElementQueries = require("css-element-queries");
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
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); }
|
|
21
|
-
|
|
12
|
+
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); }
|
|
13
|
+
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); }
|
|
22
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
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); }
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
-
|
|
15
|
+
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); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
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); }
|
|
18
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
32
19
|
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); }; }
|
|
33
|
-
|
|
34
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
35
|
-
|
|
20
|
+
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); }
|
|
36
21
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
22
|
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; } }
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
var ResizeDetect = /*#__PURE__*/function (_React$Component) {
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
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; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
26
|
+
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); }
|
|
27
|
+
var ResizeDetect = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
45
28
|
_inherits(ResizeDetect, _React$Component);
|
|
46
|
-
|
|
47
29
|
var _super = _createSuper(ResizeDetect);
|
|
48
|
-
|
|
49
30
|
function ResizeDetect() {
|
|
50
31
|
var _this;
|
|
51
|
-
|
|
52
32
|
_classCallCheck(this, ResizeDetect);
|
|
53
|
-
|
|
54
33
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
55
34
|
args[_key] = arguments[_key];
|
|
56
35
|
}
|
|
57
|
-
|
|
58
36
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
59
|
-
|
|
60
37
|
_defineProperty(_assertThisInitialized(_this), "onSizeChange", function () {
|
|
61
38
|
if (_this.props.onSizeChange) {
|
|
62
39
|
var container = _this.containerRef.current;
|
|
63
|
-
|
|
64
40
|
var _container$getBoundin = container.getBoundingClientRect(),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
width = _container$getBoundin.width,
|
|
42
|
+
height = _container$getBoundin.height;
|
|
68
43
|
_this.props.onSizeChange({
|
|
69
44
|
width: Math.floor(width),
|
|
70
45
|
height: Math.floor(height)
|
|
71
46
|
});
|
|
72
47
|
}
|
|
73
48
|
});
|
|
74
|
-
|
|
75
49
|
_defineProperty(_assertThisInitialized(_this), "containerRef", /*#__PURE__*/_react["default"].createRef());
|
|
76
|
-
|
|
77
50
|
return _this;
|
|
78
51
|
}
|
|
79
|
-
|
|
80
52
|
_createClass(ResizeDetect, [{
|
|
81
53
|
key: "componentDidMount",
|
|
82
54
|
value: function componentDidMount() {
|
|
@@ -84,7 +56,6 @@ var ResizeDetect = /*#__PURE__*/function (_React$Component) {
|
|
|
84
56
|
new _cssElementQueries.ResizeSensor(container, this.onSizeChange);
|
|
85
57
|
this.onSizeChange();
|
|
86
58
|
var innerRef = this.props.innerRef;
|
|
87
|
-
|
|
88
59
|
if (typeof innerRef === 'function') {
|
|
89
60
|
innerRef(this.containerRef.current);
|
|
90
61
|
} else if (_typeof(innerRef) === 'object') {
|
|
@@ -105,12 +76,8 @@ var ResizeDetect = /*#__PURE__*/function (_React$Component) {
|
|
|
105
76
|
}));
|
|
106
77
|
}
|
|
107
78
|
}]);
|
|
108
|
-
|
|
109
79
|
return ResizeDetect;
|
|
110
80
|
}(_react["default"].Component);
|
|
111
|
-
|
|
112
|
-
exports["default"] = ResizeDetect;
|
|
113
|
-
|
|
114
81
|
_defineProperty(ResizeDetect, "propTypes", {
|
|
115
82
|
onSizeChange: _propTypes["default"].func,
|
|
116
83
|
innerRef: _propTypes["default"].any
|
|
@@ -1,46 +1,29 @@
|
|
|
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"] = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
9
|
var _withStyles = _interopRequireDefault(require("@material-ui/core/styles/withStyles"));
|
|
15
|
-
|
|
16
10
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
17
|
-
|
|
18
11
|
var _EditorContainer = require("../Editor/EditorContainer");
|
|
19
|
-
|
|
20
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
13
|
+
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); }
|
|
22
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
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); }
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
-
|
|
15
|
+
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); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
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); }
|
|
18
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
32
19
|
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); }; }
|
|
33
|
-
|
|
34
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
35
|
-
|
|
20
|
+
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); }
|
|
36
21
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
22
|
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; } }
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
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; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
26
|
+
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); }
|
|
44
27
|
var TYPE_TOP = 'top';
|
|
45
28
|
var TYPE_RIGHT = 'right';
|
|
46
29
|
var TYPE_BOTTOM = 'bottom';
|
|
@@ -48,50 +31,37 @@ var TYPE_LEFT = 'left';
|
|
|
48
31
|
var LINE_TYPE_1 = 'LINE_TYPE_1';
|
|
49
32
|
var LINE_TYPE_2 = 'LINE_TYPE_2';
|
|
50
33
|
var LINE_TYPE_3 = 'LINE_TYPE_3';
|
|
51
|
-
|
|
52
34
|
var Ruler = /*#__PURE__*/function (_React$Component) {
|
|
53
35
|
_inherits(Ruler, _React$Component);
|
|
54
|
-
|
|
55
36
|
var _super = _createSuper(Ruler);
|
|
56
|
-
|
|
57
37
|
function Ruler(props) {
|
|
58
38
|
var _this;
|
|
59
|
-
|
|
60
39
|
_classCallCheck(this, Ruler);
|
|
61
|
-
|
|
62
40
|
_this = _super.call(this, props);
|
|
63
|
-
|
|
64
41
|
_defineProperty(_assertThisInitialized(_this), "getMmInPixel", function (totalWidthMm, totalWidthPx, alignRight, mm) {
|
|
65
42
|
var result = Math.round(mm / totalWidthMm * totalWidthPx);
|
|
66
43
|
return alignRight ? totalWidthPx - result : result;
|
|
67
44
|
});
|
|
68
|
-
|
|
69
45
|
_defineProperty(_assertThisInitialized(_this), "drawUnitLine", function (ctx, widthMm, widthPx, heightPx, alignRight, mm, lineType) {
|
|
70
46
|
var lineHeight = heightPx;
|
|
71
|
-
|
|
72
47
|
if (lineType === LINE_TYPE_1) {
|
|
73
48
|
lineHeight = Math.round(heightPx / 3);
|
|
74
49
|
} else if (lineType === LINE_TYPE_2) {
|
|
75
50
|
lineHeight = Math.round(heightPx / 2);
|
|
76
51
|
}
|
|
77
|
-
|
|
78
52
|
var x = _this.getMmInPixel(widthMm, widthPx, alignRight, mm);
|
|
79
|
-
|
|
80
53
|
x += 0.5 * (alignRight ? 1 : -1);
|
|
81
54
|
ctx.moveTo(x, heightPx);
|
|
82
55
|
ctx.lineTo(x, heightPx - lineHeight);
|
|
83
56
|
ctx.stroke();
|
|
84
57
|
});
|
|
85
|
-
|
|
86
58
|
_defineProperty(_assertThisInitialized(_this), "drawUnitText", function (ctx, widthMm, widthPx, heightPx, alignRight, rotate, mm) {
|
|
87
59
|
var fontSize = 10;
|
|
88
60
|
var paddingTop = 2;
|
|
89
61
|
var paddingSide = 2;
|
|
90
62
|
ctx.font = "".concat(fontSize, "px Arial");
|
|
91
63
|
ctx.fillStyle = '#000';
|
|
92
|
-
|
|
93
64
|
var x = _this.getMmInPixel(widthMm, widthPx, alignRight, mm);
|
|
94
|
-
|
|
95
65
|
if (rotate) {
|
|
96
66
|
ctx.save();
|
|
97
67
|
ctx.translate(0, heightPx);
|
|
@@ -106,30 +76,25 @@ var Ruler = /*#__PURE__*/function (_React$Component) {
|
|
|
106
76
|
ctx.fillText("".concat(mm, " mm"), x + paddingSide * (alignRight ? 1 : -1), paddingTop);
|
|
107
77
|
}
|
|
108
78
|
});
|
|
109
|
-
|
|
110
79
|
_defineProperty(_assertThisInitialized(_this), "updateCanvas", function () {
|
|
111
80
|
var prevProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
112
81
|
var _this$props = _this.props,
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
type = _this$props.type,
|
|
83
|
+
widthMm = _this$props.width;
|
|
115
84
|
var alignRight = !!_this.props.alignRight;
|
|
116
85
|
var canvas = _this.canvas.current;
|
|
117
|
-
|
|
118
86
|
var _canvas$getBoundingCl = canvas.getBoundingClientRect(),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
87
|
+
canvasWidthPx = _canvas$getBoundingCl.width,
|
|
88
|
+
canvasHeightPx = _canvas$getBoundingCl.height;
|
|
122
89
|
if (prevProps.type === type && widthMm === prevProps.width && canvas.width === canvasWidthPx && canvas.height === canvasHeightPx) {
|
|
123
90
|
return;
|
|
124
91
|
}
|
|
125
|
-
|
|
126
92
|
canvas.width = canvasWidthPx;
|
|
127
93
|
canvas.height = canvasHeightPx;
|
|
128
94
|
var ctx = canvas.getContext('2d');
|
|
129
95
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
130
96
|
var widthPx = type === TYPE_RIGHT || type === TYPE_LEFT ? canvasHeightPx : canvasWidthPx;
|
|
131
97
|
var heightPx = type === TYPE_RIGHT || type === TYPE_LEFT ? canvasWidthPx : canvasHeightPx;
|
|
132
|
-
|
|
133
98
|
if (type === TYPE_RIGHT) {
|
|
134
99
|
ctx.rotate(90 * (Math.PI / 180));
|
|
135
100
|
ctx.translate(0, heightPx * -1);
|
|
@@ -140,32 +105,26 @@ var Ruler = /*#__PURE__*/function (_React$Component) {
|
|
|
140
105
|
ctx.rotate(270 * (Math.PI / 180));
|
|
141
106
|
ctx.translate(widthPx * -1, 0);
|
|
142
107
|
}
|
|
108
|
+
ctx.strokeStyle = '#999';
|
|
143
109
|
|
|
144
|
-
|
|
145
|
-
|
|
110
|
+
// Steps should be at least 10 pixels wide
|
|
146
111
|
var step = Math.ceil(widthMm * (10 / widthPx));
|
|
147
|
-
|
|
148
112
|
for (var i = 0; i <= widthMm; i += step) {
|
|
149
113
|
var lineType = LINE_TYPE_1;
|
|
150
|
-
|
|
151
114
|
if (i % (step * 10) === 0) {
|
|
152
115
|
lineType = LINE_TYPE_3;
|
|
153
116
|
} else if (i % (step * 5) === 0) {
|
|
154
117
|
lineType = LINE_TYPE_2;
|
|
155
118
|
}
|
|
156
|
-
|
|
157
119
|
_this.drawUnitLine(ctx, widthMm, widthPx, heightPx, alignRight, i, lineType);
|
|
158
|
-
|
|
159
120
|
if (i % (step * 10) === 0) {
|
|
160
121
|
_this.drawUnitText(ctx, widthMm, widthPx, heightPx, alignRight, type === TYPE_BOTTOM, i);
|
|
161
122
|
}
|
|
162
123
|
}
|
|
163
124
|
});
|
|
164
|
-
|
|
165
125
|
_this.canvas = /*#__PURE__*/_react["default"].createRef();
|
|
166
126
|
return _this;
|
|
167
127
|
}
|
|
168
|
-
|
|
169
128
|
_createClass(Ruler, [{
|
|
170
129
|
key: "componentDidMount",
|
|
171
130
|
value: function componentDidMount() {
|
|
@@ -180,10 +139,9 @@ var Ruler = /*#__PURE__*/function (_React$Component) {
|
|
|
180
139
|
key: "render",
|
|
181
140
|
value: function render() {
|
|
182
141
|
var _classMap;
|
|
183
|
-
|
|
184
142
|
var _this$props2 = this.props,
|
|
185
|
-
|
|
186
|
-
|
|
143
|
+
classes = _this$props2.classes,
|
|
144
|
+
type = _this$props2.type;
|
|
187
145
|
var classMap = (_classMap = {}, _defineProperty(_classMap, TYPE_TOP, "".concat(classes.ruler, " ").concat(classes.rulerTop)), _defineProperty(_classMap, TYPE_RIGHT, "".concat(classes.ruler, " ").concat(classes.rulerRight)), _defineProperty(_classMap, TYPE_BOTTOM, "".concat(classes.ruler, " ").concat(classes.rulerBottom)), _defineProperty(_classMap, TYPE_LEFT, "".concat(classes.ruler, " ").concat(classes.rulerLeft)), _classMap);
|
|
188
146
|
return /*#__PURE__*/_react["default"].createElement("canvas", {
|
|
189
147
|
ref: this.canvas,
|
|
@@ -191,23 +149,17 @@ var Ruler = /*#__PURE__*/function (_React$Component) {
|
|
|
191
149
|
});
|
|
192
150
|
}
|
|
193
151
|
}]);
|
|
194
|
-
|
|
195
152
|
return Ruler;
|
|
196
153
|
}(_react["default"].Component);
|
|
197
|
-
|
|
198
154
|
_defineProperty(Ruler, "propTypes", {
|
|
199
155
|
classes: _propTypes["default"].object.isRequired,
|
|
200
156
|
width: _propTypes["default"].number.isRequired,
|
|
201
157
|
type: _propTypes["default"].oneOf([TYPE_TOP, TYPE_RIGHT, TYPE_BOTTOM, TYPE_LEFT]).isRequired,
|
|
202
158
|
alignRight: _propTypes["default"].bool
|
|
203
159
|
});
|
|
204
|
-
|
|
205
160
|
_defineProperty(Ruler, "defaultProps", {
|
|
206
161
|
alignRight: false
|
|
207
162
|
});
|
|
208
|
-
|
|
209
|
-
var _default = (0, _withStyles["default"])(_styles["default"], {
|
|
163
|
+
var _default = exports["default"] = (0, _withStyles["default"])(_styles["default"], {
|
|
210
164
|
name: 'Designer-Ruler'
|
|
211
|
-
})((0, _EditorContainer.withCanvasPosition)(Ruler));
|
|
212
|
-
|
|
213
|
-
exports["default"] = _default;
|
|
165
|
+
})((0, _EditorContainer.withCanvasPosition)(Ruler));
|
|
@@ -1,75 +1,48 @@
|
|
|
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"] = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
9
|
var _withStyles = _interopRequireDefault(require("@material-ui/core/styles/withStyles"));
|
|
15
|
-
|
|
16
10
|
var _CanvasProvider = require("../../CanvasInterface/CanvasProvider");
|
|
17
|
-
|
|
18
11
|
var _Canvas = require("../../CanvasInterface/Canvas");
|
|
19
|
-
|
|
20
12
|
var _Logger = _interopRequireDefault(require("../../Utils/Logger"));
|
|
21
|
-
|
|
22
13
|
var _Ruler = _interopRequireDefault(require("./Ruler"));
|
|
23
|
-
|
|
24
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
25
|
-
|
|
26
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
-
|
|
16
|
+
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); }
|
|
28
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
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); }
|
|
35
|
-
|
|
36
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
-
|
|
18
|
+
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); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
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); }
|
|
21
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
38
22
|
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); }; }
|
|
39
|
-
|
|
40
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
41
|
-
|
|
23
|
+
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); }
|
|
42
24
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
-
|
|
44
25
|
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; } }
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
function
|
|
49
|
-
|
|
26
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
+
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; }
|
|
28
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
29
|
+
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); }
|
|
50
30
|
var logger = new _Logger["default"]('Rulers');
|
|
51
|
-
|
|
52
31
|
var Rulers = /*#__PURE__*/function (_React$Component) {
|
|
53
32
|
_inherits(Rulers, _React$Component);
|
|
54
|
-
|
|
55
33
|
var _super = _createSuper(Rulers);
|
|
56
|
-
|
|
57
34
|
function Rulers() {
|
|
58
35
|
_classCallCheck(this, Rulers);
|
|
59
|
-
|
|
60
36
|
return _super.apply(this, arguments);
|
|
61
37
|
}
|
|
62
|
-
|
|
63
38
|
_createClass(Rulers, [{
|
|
64
39
|
key: "render",
|
|
65
40
|
value: function render() {
|
|
66
41
|
logger.log('render Rulers');
|
|
67
42
|
var canvas = this.props.canvas;
|
|
68
|
-
|
|
69
43
|
var _canvas$getSizeMetric = canvas.getSizeMetric(),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
44
|
+
metricWidth = _canvas$getSizeMetric.width,
|
|
45
|
+
metricHeight = _canvas$getSizeMetric.height;
|
|
73
46
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Ruler["default"], {
|
|
74
47
|
width: metricWidth,
|
|
75
48
|
type: "bottom",
|
|
@@ -80,17 +53,12 @@ var Rulers = /*#__PURE__*/function (_React$Component) {
|
|
|
80
53
|
}));
|
|
81
54
|
}
|
|
82
55
|
}]);
|
|
83
|
-
|
|
84
56
|
return Rulers;
|
|
85
57
|
}(_react["default"].Component);
|
|
86
|
-
|
|
87
58
|
_defineProperty(Rulers, "propTypes", {
|
|
88
59
|
canvas: _propTypes["default"].instanceOf(_Canvas.AbstractCanvas).isRequired,
|
|
89
60
|
classes: _propTypes["default"].object.isRequired
|
|
90
61
|
});
|
|
91
|
-
|
|
92
|
-
var _default = (0, _withStyles["default"])(_styles["default"], {
|
|
62
|
+
var _default = exports["default"] = (0, _withStyles["default"])(_styles["default"], {
|
|
93
63
|
name: 'Designer-Rulers'
|
|
94
|
-
})((0, _CanvasProvider.withCanvas)((0, _CanvasProvider.withCanvasState)(Rulers)));
|
|
95
|
-
|
|
96
|
-
exports["default"] = _default;
|
|
64
|
+
})((0, _CanvasProvider.withCanvas)((0, _CanvasProvider.withCanvasState)(Rulers)));
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _default = {
|
|
7
|
+
var _default = exports["default"] = {
|
|
8
8
|
ruler: {
|
|
9
9
|
position: 'absolute',
|
|
10
10
|
background: 'transparent !important'
|
|
@@ -33,5 +33,4 @@ var _default = {
|
|
|
33
33
|
width: 20,
|
|
34
34
|
height: '100%'
|
|
35
35
|
}
|
|
36
|
-
};
|
|
37
|
-
exports["default"] = _default;
|
|
36
|
+
};
|