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.
- 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,79 +1,52 @@
|
|
|
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.withTextEditorState = exports.TextEditorStateProvider = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
8
|
var _Logger = _interopRequireDefault(require("../../Utils/Logger"));
|
|
13
|
-
|
|
14
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function _extends() { _extends = Object.assign
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
10
|
+
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); }
|
|
11
|
+
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); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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 logger = new _Logger["default"]('TextEditorStateProvider');
|
|
45
|
-
|
|
46
28
|
var TextEditorContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
47
|
-
|
|
48
|
-
var TextEditorStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
29
|
+
var TextEditorStateProvider = exports.TextEditorStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
49
30
|
_inherits(TextEditorStateProvider, _React$Component);
|
|
50
|
-
|
|
51
31
|
var _super = _createSuper(TextEditorStateProvider);
|
|
52
|
-
|
|
53
32
|
function TextEditorStateProvider() {
|
|
54
33
|
var _this;
|
|
55
|
-
|
|
56
34
|
_classCallCheck(this, TextEditorStateProvider);
|
|
57
|
-
|
|
58
35
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
36
|
args[_key] = arguments[_key];
|
|
60
37
|
}
|
|
61
|
-
|
|
62
38
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
63
|
-
|
|
64
39
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
65
40
|
currentStyle: _this.props.defaultStyle || {},
|
|
66
41
|
defaultStyle: _this.props.defaultStyle || {},
|
|
67
42
|
formatDoc: function formatDoc() {},
|
|
68
43
|
getStyleValues: function getStyleValues() {
|
|
69
44
|
var _this$state = _this.state,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
45
|
+
currentStyle = _this$state.currentStyle,
|
|
46
|
+
defaultStyle = _this$state.defaultStyle;
|
|
73
47
|
var _ref = currentStyle || defaultStyle || {},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
fontWeight = _ref.fontWeight,
|
|
49
|
+
fontStyle = _ref.fontStyle;
|
|
77
50
|
return _objectSpread(_objectSpread({}, currentStyle), {}, {
|
|
78
51
|
isBold: !!fontWeight && /^bold|700$/.test(fontWeight || ''),
|
|
79
52
|
isItalic: !!fontStyle && fontStyle === 'italic'
|
|
@@ -104,15 +77,12 @@ var TextEditorStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
104
77
|
return _this.state.updateDefaultStyle(_this.props.defaultStyle);
|
|
105
78
|
}
|
|
106
79
|
});
|
|
107
|
-
|
|
108
80
|
return _this;
|
|
109
81
|
}
|
|
110
|
-
|
|
111
82
|
_createClass(TextEditorStateProvider, [{
|
|
112
83
|
key: "componentDidUpdate",
|
|
113
84
|
value: function componentDidUpdate(prevProps) {
|
|
114
85
|
var defaultStyle = this.props.defaultStyle;
|
|
115
|
-
|
|
116
86
|
if (defaultStyle !== prevProps.defaultStyle) {
|
|
117
87
|
this.setState({
|
|
118
88
|
defaultStyle: defaultStyle
|
|
@@ -127,13 +97,9 @@ var TextEditorStateProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
127
97
|
}, this.props.children);
|
|
128
98
|
}
|
|
129
99
|
}]);
|
|
130
|
-
|
|
131
100
|
return TextEditorStateProvider;
|
|
132
101
|
}(_react["default"].Component);
|
|
133
|
-
|
|
134
|
-
exports.TextEditorStateProvider = TextEditorStateProvider;
|
|
135
|
-
|
|
136
|
-
var withTextEditorState = function withTextEditorState(Component) {
|
|
102
|
+
var withTextEditorState = exports.withTextEditorState = function withTextEditorState(Component) {
|
|
137
103
|
return /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
138
104
|
return /*#__PURE__*/_react["default"].createElement(TextEditorContext.Consumer, null, function (state) {
|
|
139
105
|
return state ? /*#__PURE__*/_react["default"].createElement(Component, _extends({
|
|
@@ -142,6 +108,4 @@ var withTextEditorState = function withTextEditorState(Component) {
|
|
|
142
108
|
}, props)) : logger.warn("No text editor state provided! The following component will not be rendered: ".concat(Component.name));
|
|
143
109
|
});
|
|
144
110
|
});
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
exports.withTextEditorState = withTextEditorState;
|
|
111
|
+
};
|
|
@@ -4,36 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.ToolboxContainer = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _withStyles = _interopRequireDefault(require("@material-ui/core/styles/withStyles"));
|
|
11
|
-
|
|
12
9
|
var _String = require("../../Utils/String");
|
|
13
|
-
|
|
14
10
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
|
-
|
|
16
11
|
var _excluded = ["classes", "className"];
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _extends() { _extends = Object.assign || 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); }
|
|
21
|
-
|
|
13
|
+
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); }
|
|
22
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
23
|
-
|
|
24
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
-
|
|
26
|
-
var ToolboxContainer = (0, _withStyles["default"])(_styles["default"], {
|
|
16
|
+
var ToolboxContainer = exports.ToolboxContainer = (0, _withStyles["default"])(_styles["default"], {
|
|
27
17
|
name: 'Designer-ToolboxContainer'
|
|
28
18
|
})(function (_ref) {
|
|
29
19
|
var classes = _ref.classes,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
className = _ref.className,
|
|
21
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
22
|
return /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
34
23
|
className: (0, _String.xc)(classes.toolboxContainer, className)
|
|
35
24
|
}, otherProps));
|
|
36
25
|
});
|
|
37
|
-
exports
|
|
38
|
-
var _default = ToolboxContainer;
|
|
39
|
-
exports["default"] = _default;
|
|
26
|
+
var _default = exports["default"] = ToolboxContainer;
|
|
@@ -4,33 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.ToolboxRow = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _withStyles = _interopRequireDefault(require("@material-ui/core/styles/withStyles"));
|
|
11
|
-
|
|
12
9
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
|
-
|
|
14
10
|
var _excluded = ["classes"];
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function _extends() { _extends = Object.assign || 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); }
|
|
19
|
-
|
|
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); }
|
|
20
13
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
-
|
|
22
14
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
|
-
|
|
24
|
-
var ToolboxRow = (0, _withStyles["default"])(_styles["default"], {
|
|
15
|
+
var ToolboxRow = exports.ToolboxRow = (0, _withStyles["default"])(_styles["default"], {
|
|
25
16
|
name: 'Designer-ToolboxRow'
|
|
26
17
|
})(function (_ref) {
|
|
27
18
|
var classes = _ref.classes,
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
30
20
|
return /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
31
21
|
className: classes.toolboxRow
|
|
32
22
|
}, otherProps));
|
|
33
23
|
});
|
|
34
|
-
exports
|
|
35
|
-
var _default = ToolboxRow;
|
|
36
|
-
exports["default"] = _default;
|
|
24
|
+
var _default = exports["default"] = ToolboxRow;
|
|
@@ -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
|
toolboxContainer: {
|
|
9
9
|
fontSize: '1rem',
|
|
10
10
|
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
@@ -17,5 +17,4 @@ var _default = {
|
|
|
17
17
|
alignItems: 'center'
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
};
|
|
21
|
-
exports["default"] = _default;
|
|
20
|
+
};
|
package/Utils/Calc2D.js
CHANGED
|
@@ -4,14 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformPoint = exports.distanceFromOrigin = void 0;
|
|
7
|
-
|
|
8
|
-
var distanceFromOrigin = function distanceFromOrigin(x, y, originX, originY) {
|
|
7
|
+
var distanceFromOrigin = exports.distanceFromOrigin = function distanceFromOrigin(x, y, originX, originY) {
|
|
9
8
|
return Math.sqrt(Math.pow(x - originX, 2) + Math.pow(y - originY, 2));
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.distanceFromOrigin = distanceFromOrigin;
|
|
13
|
-
|
|
14
|
-
var transformPoint = function transformPoint(x, y) {
|
|
10
|
+
var transformPoint = exports.transformPoint = function transformPoint(x, y) {
|
|
15
11
|
var originX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
16
12
|
var originY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
17
13
|
var angleDeg = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
@@ -20,6 +16,4 @@ var transformPoint = function transformPoint(x, y) {
|
|
|
20
16
|
x: (x - originX) * Math.cos(a) - (y - originY) * Math.sin(a) + originX,
|
|
21
17
|
y: (x - originX) * Math.sin(a) + (y - originY) * Math.cos(a) + originY
|
|
22
18
|
};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.transformPoint = transformPoint;
|
|
19
|
+
};
|
package/Utils/DOM.js
CHANGED
|
@@ -3,146 +3,112 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.unwrap = unwrap;
|
|
6
|
+
exports.fixContentEditableDOM = fixContentEditableDOM;
|
|
7
|
+
exports.getClosestAttribute = void 0;
|
|
9
8
|
exports.getFirstEndNode = getFirstEndNode;
|
|
10
9
|
exports.getLastEndNode = getLastEndNode;
|
|
10
|
+
exports.getMostOuterContainer = getMostOuterContainer;
|
|
11
11
|
exports.getNextNode = getNextNode;
|
|
12
|
-
exports.
|
|
13
|
-
exports.traverse = exports.
|
|
14
|
-
|
|
12
|
+
exports.isElement = isElement;
|
|
13
|
+
exports.traverse = exports.removeLinebreaks = exports.placeCaretAtEnd = void 0;
|
|
14
|
+
exports.unwrap = unwrap;
|
|
15
|
+
exports.updateTextWrapper = exports.updatePastedTextNode = void 0;
|
|
15
16
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
16
|
-
|
|
17
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
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); }
|
|
22
|
-
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
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); }
|
|
23
20
|
function isElement(o) {
|
|
24
21
|
return (typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement)) === 'object' ? o instanceof HTMLElement : o && _typeof(o) === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string';
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function getMostOuterContainer(node, rootElement) {
|
|
28
24
|
if (!(node instanceof Node) || !(rootElement instanceof Node)) {
|
|
29
25
|
throw new Error('The given argument must be an instance of Node!');
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
if (node.parentNode && node.parentNode !== rootElement) {
|
|
33
28
|
return getMostOuterContainer(node.parentNode, rootElement);
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
return node;
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
function unwrap(node) {
|
|
40
33
|
if (!(node instanceof Node)) {
|
|
41
34
|
throw new Error('The given argument must be an instance of Node!');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
}
|
|
36
|
+
// get the element's parent node
|
|
45
37
|
var parent = node.parentNode;
|
|
46
|
-
|
|
47
38
|
if (parent) {
|
|
48
39
|
// move all children out of the element
|
|
49
40
|
while (node.firstChild) {
|
|
50
41
|
parent.insertBefore(node.firstChild, node);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
}
|
|
43
|
+
// remove the empty element
|
|
54
44
|
parent.removeChild(node);
|
|
55
45
|
return true;
|
|
56
46
|
}
|
|
57
|
-
|
|
58
47
|
return false;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
49
|
function getFirstEndNode(node) {
|
|
62
50
|
if (!(node instanceof Node)) {
|
|
63
51
|
throw new Error('The given argument must be an instance of Node!');
|
|
64
52
|
}
|
|
65
|
-
|
|
66
53
|
return node.childNodes.length > 0 ? getFirstEndNode(node.childNodes[0]) : node;
|
|
67
54
|
}
|
|
68
|
-
|
|
69
55
|
function getLastEndNode(node) {
|
|
70
56
|
if (!(node instanceof Node)) {
|
|
71
57
|
throw new Error('The given argument must be an instance of Node!');
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
var lastChild = node.lastChild;
|
|
75
60
|
return lastChild ? getLastEndNode(lastChild) : node;
|
|
76
61
|
}
|
|
77
|
-
|
|
78
62
|
function getNextNode(node, rootNode) {
|
|
79
63
|
if (!(node instanceof Node) || !(rootNode instanceof Node)) {
|
|
80
64
|
throw new Error('The given argument must be an instance of Node!');
|
|
81
65
|
}
|
|
82
|
-
|
|
83
66
|
if (!node || node === rootNode) {
|
|
84
67
|
return false;
|
|
85
68
|
}
|
|
86
|
-
|
|
87
69
|
if (node.nextSibling) {
|
|
88
70
|
return getFirstEndNode(node.nextSibling);
|
|
89
71
|
}
|
|
90
|
-
|
|
91
72
|
if (node.parentNode) {
|
|
92
73
|
return getNextNode(node.parentNode, rootNode);
|
|
93
74
|
}
|
|
94
|
-
|
|
95
75
|
return false;
|
|
96
76
|
}
|
|
97
|
-
|
|
98
|
-
var getClosestAttribute = function getClosestAttribute(node, attributeName) {
|
|
77
|
+
var getClosestAttribute = exports.getClosestAttribute = function getClosestAttribute(node, attributeName) {
|
|
99
78
|
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
100
79
|
return node.hasAttribute(attributeName) ? node.getAttribute(attributeName) : node.parentNode ? getClosestAttribute(node.parentNode, attributeName) : defaultValue;
|
|
101
80
|
};
|
|
102
|
-
|
|
103
|
-
exports.getClosestAttribute = getClosestAttribute;
|
|
104
|
-
|
|
105
|
-
var placeCaretAtEnd = function placeCaretAtEnd(el) {
|
|
81
|
+
var placeCaretAtEnd = exports.placeCaretAtEnd = function placeCaretAtEnd(el) {
|
|
106
82
|
el.focus();
|
|
107
|
-
|
|
108
83
|
if (typeof window.getSelection !== 'undefined' && typeof document.createRange !== 'undefined') {
|
|
109
84
|
var range = document.createRange();
|
|
110
85
|
range.selectNodeContents(el);
|
|
111
86
|
range.collapse(false);
|
|
112
87
|
var sel = window.getSelection();
|
|
113
|
-
|
|
114
88
|
if (sel) {
|
|
115
89
|
sel.removeAllRanges();
|
|
116
90
|
sel.addRange(range);
|
|
117
91
|
}
|
|
118
92
|
}
|
|
119
93
|
};
|
|
120
|
-
|
|
121
|
-
exports.placeCaretAtEnd = placeCaretAtEnd;
|
|
122
|
-
|
|
123
|
-
var updatePastedTextNode = function updatePastedTextNode(rootNode, disableLinebreaks) {
|
|
94
|
+
var updatePastedTextNode = exports.updatePastedTextNode = function updatePastedTextNode(rootNode, disableLinebreaks) {
|
|
124
95
|
var divs = rootNode.childNodes;
|
|
125
|
-
|
|
126
96
|
if (disableLinebreaks) {
|
|
127
97
|
removeLinebreaks(rootNode);
|
|
128
98
|
} else {
|
|
129
99
|
var _iterator = _createForOfIteratorHelper(divs),
|
|
130
|
-
|
|
131
|
-
|
|
100
|
+
_step;
|
|
132
101
|
try {
|
|
133
102
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
134
103
|
var child = _step.value;
|
|
135
104
|
// get the text nodes and wrap it in Div and span in order to apply styles
|
|
136
105
|
var text = child.textContent || '';
|
|
137
|
-
|
|
138
106
|
if (child.nodeType === Node.TEXT_NODE) {
|
|
139
107
|
if ((text.match(/\n/g) || []).length) {
|
|
140
108
|
// To support multi line
|
|
141
109
|
var textElements = text.split('\n');
|
|
142
|
-
|
|
143
110
|
var _iterator2 = _createForOfIteratorHelper(textElements),
|
|
144
|
-
|
|
145
|
-
|
|
111
|
+
_step2;
|
|
146
112
|
try {
|
|
147
113
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
148
114
|
var element = _step2.value;
|
|
@@ -170,10 +136,7 @@ var updatePastedTextNode = function updatePastedTextNode(rootNode, disableLinebr
|
|
|
170
136
|
}
|
|
171
137
|
}
|
|
172
138
|
};
|
|
173
|
-
|
|
174
|
-
exports.updatePastedTextNode = updatePastedTextNode;
|
|
175
|
-
|
|
176
|
-
var removeLinebreaks = function removeLinebreaks(rootNode) {
|
|
139
|
+
var removeLinebreaks = exports.removeLinebreaks = function removeLinebreaks(rootNode) {
|
|
177
140
|
var divs = rootNode.childNodes;
|
|
178
141
|
divs.forEach(function (child, key) {
|
|
179
142
|
if (key !== 0) {
|
|
@@ -182,19 +145,14 @@ var removeLinebreaks = function removeLinebreaks(rootNode) {
|
|
|
182
145
|
var childText = child.textContent || '';
|
|
183
146
|
rootNode.firstChild.textContent = "".concat(parentText, " ").concat(childText);
|
|
184
147
|
}
|
|
185
|
-
|
|
186
148
|
rootNode.removeChild(child);
|
|
187
149
|
}
|
|
188
150
|
});
|
|
189
|
-
|
|
190
151
|
if (rootNode && rootNode.textContent) {
|
|
191
152
|
rootNode.textContent = rootNode.textContent.split('\n').join(' ');
|
|
192
153
|
}
|
|
193
154
|
};
|
|
194
|
-
|
|
195
|
-
exports.removeLinebreaks = removeLinebreaks;
|
|
196
|
-
|
|
197
|
-
var updateTextWrapper = function updateTextWrapper(child) {
|
|
155
|
+
var updateTextWrapper = exports.updateTextWrapper = function updateTextWrapper(child) {
|
|
198
156
|
var textWrapper = document.createElement('span');
|
|
199
157
|
var wrapperDiv = document.createElement('div');
|
|
200
158
|
textWrapper.innerText = child.textContent ? child.textContent.trim() : '';
|
|
@@ -202,57 +160,41 @@ var updateTextWrapper = function updateTextWrapper(child) {
|
|
|
202
160
|
child.replaceWith(wrapperDiv);
|
|
203
161
|
placeCaretAtEnd(wrapperDiv);
|
|
204
162
|
};
|
|
205
|
-
|
|
206
|
-
exports.updateTextWrapper = updateTextWrapper;
|
|
207
|
-
|
|
208
|
-
var traverse = function traverse(node, cb) {
|
|
163
|
+
var traverse = exports.traverse = function traverse(node, cb) {
|
|
209
164
|
cb(node);
|
|
210
|
-
|
|
211
165
|
for (var i = 0; i < node.childNodes.length; i++) {
|
|
212
166
|
traverse(node.childNodes[i], cb);
|
|
213
167
|
}
|
|
214
168
|
};
|
|
215
|
-
|
|
216
|
-
exports.traverse = traverse;
|
|
217
|
-
|
|
218
169
|
function fixContentEditableDOM(rootElement, node) {
|
|
219
170
|
var currentNode = node || rootElement;
|
|
220
|
-
|
|
221
171
|
if (!(currentNode instanceof HTMLElement) || !(rootElement instanceof HTMLElement)) {
|
|
222
172
|
throw new Error('The given argument must be an instance of HTMLElement!');
|
|
223
173
|
}
|
|
224
|
-
|
|
225
174
|
var _iterator3 = _createForOfIteratorHelper(currentNode.children),
|
|
226
|
-
|
|
227
|
-
|
|
175
|
+
_step3;
|
|
228
176
|
try {
|
|
229
177
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
230
178
|
var child = _step3.value;
|
|
231
|
-
|
|
232
179
|
if (!(child instanceof HTMLElement)) {
|
|
233
180
|
continue;
|
|
234
181
|
}
|
|
235
|
-
|
|
236
182
|
if (child.nodeName === 'SPAN') {
|
|
237
183
|
if (child.style.fontSize === '1rem') {
|
|
238
184
|
child.style.fontSize = '';
|
|
239
|
-
|
|
240
185
|
if (child.style.length === 0) {
|
|
241
186
|
unwrap(child);
|
|
242
187
|
}
|
|
243
188
|
}
|
|
244
189
|
}
|
|
245
|
-
|
|
246
190
|
if (rootElement.childElementCount === 1 && rootElement.firstChild && rootElement.firstChild.nodeName === 'DIV' && rootElement.firstChild.textContent === '') {
|
|
247
191
|
rootElement.firstChild.remove();
|
|
248
192
|
}
|
|
249
|
-
|
|
250
193
|
if (child.parentNode !== rootElement) {
|
|
251
194
|
if (child.nodeName === 'DIV' && child.style.length === 0) {
|
|
252
195
|
unwrap(child);
|
|
253
196
|
}
|
|
254
197
|
}
|
|
255
|
-
|
|
256
198
|
fixContentEditableDOM(rootElement, child);
|
|
257
199
|
}
|
|
258
200
|
} catch (err) {
|
package/Utils/Device.js
CHANGED
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getScreenDPI = void 0;
|
|
7
|
-
|
|
8
7
|
var _once = _interopRequireDefault(require("lodash/once"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
var getScreenDPI = (0, _once["default"])(function () {
|
|
9
|
+
var getScreenDPI = exports.getScreenDPI = (0, _once["default"])(function () {
|
|
13
10
|
var d = document.createElement('div');
|
|
14
11
|
d.style.width = '1cm';
|
|
15
12
|
document.body.appendChild(d);
|
|
16
13
|
var r = d.getBoundingClientRect().width;
|
|
17
14
|
document.body.removeChild(d);
|
|
18
15
|
return r;
|
|
19
|
-
});
|
|
20
|
-
exports.getScreenDPI = getScreenDPI;
|
|
16
|
+
});
|
package/Utils/Image.js
CHANGED
|
@@ -4,44 +4,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.copyImageResampled = copyImageResampled;
|
|
7
|
-
|
|
8
7
|
function copyImageResampled(img, ctx, dx, dy, dWidth, dHeight) {
|
|
9
8
|
var cpyCanvas = document.createElement('canvas');
|
|
10
|
-
var cpyCtx = cpyCanvas.getContext('2d');
|
|
9
|
+
var cpyCtx = cpyCanvas.getContext('2d');
|
|
11
10
|
|
|
11
|
+
// the tmpCanvas is used for storing the last image since the copy canvas should be cleared first (alpha values..)
|
|
12
12
|
var tmpCanvas = document.createElement('canvas');
|
|
13
|
-
var tmpCtx = tmpCanvas.getContext('2d');
|
|
13
|
+
var tmpCtx = tmpCanvas.getContext('2d');
|
|
14
14
|
|
|
15
|
+
// start with original image size
|
|
15
16
|
cpyCanvas.width = img.width;
|
|
16
|
-
cpyCanvas.height = img.height;
|
|
17
|
+
cpyCanvas.height = img.height;
|
|
17
18
|
|
|
19
|
+
// the tmpCanvas should have the maximum size of the half of the original
|
|
18
20
|
tmpCanvas.width = Math.floor(img.width * 0.5);
|
|
19
|
-
tmpCanvas.height = Math.floor(img.height * 0.5);
|
|
21
|
+
tmpCanvas.height = Math.floor(img.height * 0.5);
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
// draw the original image on the copy canvas, this will be the initial state
|
|
24
|
+
cpyCtx.drawImage(img, 0, 0, cpyCanvas.width, cpyCanvas.height);
|
|
22
25
|
|
|
26
|
+
// the size should be stored to make it reducible
|
|
23
27
|
var size = {
|
|
24
28
|
width: Math.floor(img.width),
|
|
25
29
|
height: Math.floor(img.height)
|
|
26
30
|
};
|
|
27
|
-
var lastSize = size;
|
|
31
|
+
var lastSize = size;
|
|
32
|
+
|
|
33
|
+
// Reduce the size by 50% each time in few iterations until the size is less then
|
|
28
34
|
// 2x time the target size - the motivation for it, is to reduce the aliasing that would have been
|
|
29
35
|
// created with direct reduction of very big image to small image
|
|
30
|
-
|
|
31
36
|
while (size.width * 0.5 > dWidth) {
|
|
32
37
|
// reduce the size by the half
|
|
33
38
|
size = {
|
|
34
39
|
width: Math.floor(size.width * 0.5),
|
|
35
40
|
height: Math.floor(size.height * 0.5)
|
|
36
|
-
};
|
|
41
|
+
};
|
|
37
42
|
|
|
43
|
+
// clear the area on the tmp canvas, and copy the image from the last state
|
|
38
44
|
tmpCtx.clearRect(0, 0, lastSize.width + 1, lastSize.height + 1);
|
|
39
|
-
tmpCtx.drawImage(cpyCanvas, 0, 0, lastSize.width, lastSize.height, 0, 0, size.width, size.height);
|
|
45
|
+
tmpCtx.drawImage(cpyCanvas, 0, 0, lastSize.width, lastSize.height, 0, 0, size.width, size.height);
|
|
40
46
|
|
|
47
|
+
// clear the area on the copy canvas, and copy the temp data on it
|
|
41
48
|
cpyCtx.clearRect(0, 0, size.width + 1, size.height + 1);
|
|
42
49
|
cpyCtx.drawImage(tmpCanvas, 0, 0, size.width, size.height, 0, 0, size.width, size.height);
|
|
43
50
|
lastSize = size;
|
|
44
51
|
}
|
|
45
|
-
|
|
46
52
|
ctx.drawImage(cpyCanvas, 0, 0, size.width, size.height, dx, dy, dWidth, dHeight);
|
|
47
53
|
}
|