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
package/Utils/Logger.js
CHANGED
|
@@ -4,86 +4,62 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.Logger = void 0;
|
|
7
|
-
|
|
7
|
+
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); }
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var Logger = /*#__PURE__*/function () {
|
|
9
|
+
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); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
+
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); }
|
|
14
|
+
var Logger = exports.Logger = /*#__PURE__*/function () {
|
|
17
15
|
function Logger() {
|
|
18
16
|
var _this = this;
|
|
19
|
-
|
|
20
17
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
21
|
-
|
|
22
18
|
_classCallCheck(this, Logger);
|
|
23
|
-
|
|
24
19
|
_defineProperty(this, "name", '');
|
|
25
|
-
|
|
26
20
|
_defineProperty(this, "log", function () {
|
|
27
21
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
22
|
args[_key] = arguments[_key];
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
return _this.callLog.apply(_this, ['log'].concat(args));
|
|
32
25
|
});
|
|
33
|
-
|
|
34
26
|
_defineProperty(this, "info", function () {
|
|
35
27
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
36
28
|
args[_key2] = arguments[_key2];
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
return _this.callLog.apply(_this, ['info'].concat(args));
|
|
40
31
|
});
|
|
41
|
-
|
|
42
32
|
_defineProperty(this, "warn", function () {
|
|
43
33
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
44
34
|
args[_key3] = arguments[_key3];
|
|
45
35
|
}
|
|
46
|
-
|
|
47
36
|
return _this.callLog.apply(_this, ['warn'].concat(args));
|
|
48
37
|
});
|
|
49
|
-
|
|
50
38
|
_defineProperty(this, "error", function () {
|
|
51
39
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
52
40
|
args[_key4] = arguments[_key4];
|
|
53
41
|
}
|
|
54
|
-
|
|
55
42
|
return _this.callLog.apply(_this, ['error'].concat(args));
|
|
56
43
|
});
|
|
57
|
-
|
|
58
44
|
this.name = name;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
46
|
_createClass(Logger, [{
|
|
62
47
|
key: "callLog",
|
|
63
48
|
value: function callLog(fn) {
|
|
64
49
|
var _ref;
|
|
65
|
-
|
|
66
50
|
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
67
51
|
args[_key5 - 1] = arguments[_key5];
|
|
68
52
|
}
|
|
69
|
-
|
|
70
53
|
Logger.Levels[fn] && (_ref = Logger.loggerObject)[fn].apply(_ref, ["[".concat(this.name, "]")].concat(args));
|
|
71
54
|
}
|
|
72
55
|
}]);
|
|
73
|
-
|
|
74
56
|
return Logger;
|
|
75
57
|
}();
|
|
76
|
-
|
|
77
|
-
exports.Logger = Logger;
|
|
78
|
-
|
|
79
58
|
_defineProperty(Logger, "Levels", {
|
|
80
59
|
log: true,
|
|
81
60
|
info: true,
|
|
82
61
|
warn: true,
|
|
83
62
|
error: true
|
|
84
63
|
});
|
|
85
|
-
|
|
86
64
|
_defineProperty(Logger, "loggerObject", console);
|
|
87
|
-
|
|
88
|
-
var _default = Logger;
|
|
89
|
-
exports["default"] = _default;
|
|
65
|
+
var _default = exports["default"] = Logger;
|
package/Utils/Range.js
CHANGED
|
@@ -3,19 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectNodes = selectNodes;
|
|
7
|
-
exports.isFirefox = isFirefox;
|
|
8
6
|
exports.getNodesInRange = getNodesInRange;
|
|
7
|
+
exports.isFirefox = isFirefox;
|
|
9
8
|
exports.selectAll = selectAll;
|
|
10
|
-
|
|
9
|
+
exports.selectNodes = selectNodes;
|
|
11
10
|
var _DOM = require("./DOM");
|
|
12
|
-
|
|
13
11
|
var _Logger = _interopRequireDefault(require("./Logger"));
|
|
14
|
-
|
|
15
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
-
|
|
17
13
|
var logger = new _Logger["default"]('Range');
|
|
18
|
-
|
|
19
14
|
function selectNodes(nodes) {
|
|
20
15
|
if (nodes.length > 0) {
|
|
21
16
|
// update selected range
|
|
@@ -28,27 +23,23 @@ function selectNodes(nodes) {
|
|
|
28
23
|
selection.addRange(newRange);
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
function isFirefox() {
|
|
33
27
|
var userAgent = navigator.userAgent.toLowerCase();
|
|
34
28
|
return userAgent.indexOf('firefox') > -1;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
function getNodesInRange(range) {
|
|
38
31
|
var updateRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
39
32
|
var startContainer = range.startContainer,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
endContainer = range.endContainer,
|
|
34
|
+
commonAncestorContainer = range.commonAncestorContainer,
|
|
35
|
+
startOffset = range.startOffset,
|
|
36
|
+
endOffset = range.endOffset;
|
|
44
37
|
var nodes = [];
|
|
45
38
|
var lastNode = isFirefox() ? (0, _DOM.getLastEndNode)(endContainer) : (0, _DOM.getFirstEndNode)(endContainer);
|
|
46
39
|
var firstNode = (0, _DOM.getFirstEndNode)(startContainer);
|
|
47
40
|
var node = firstNode;
|
|
48
|
-
|
|
49
41
|
while (node) {
|
|
50
42
|
var currentNodeRef = node;
|
|
51
|
-
|
|
52
43
|
if (node.parentNode.nodeName === 'SPAN' && node.parentNode.textContent === node.textContent && (node !== firstNode && node !== lastNode || node === firstNode && node !== lastNode && startOffset === 0 || node === lastNode && node !== firstNode && endOffset === node.textContent.length || firstNode === lastNode && startOffset === 0 && endOffset === node.textContent.length || (startContainer.nodeType !== Node.TEXT_NODE || endContainer.nodeType !== Node.TEXT_NODE) && startOffset === 0 && endOffset === 1)) {
|
|
53
44
|
nodes.push(node.parentNode);
|
|
54
45
|
currentNodeRef = node.parentNode;
|
|
@@ -56,11 +47,9 @@ function getNodesInRange(range) {
|
|
|
56
47
|
var left = node.textContent.substring(0, startOffset);
|
|
57
48
|
var middle = node === lastNode ? node.textContent.substring(startOffset, endOffset) : node.textContent.substring(startOffset);
|
|
58
49
|
var right = node === lastNode ? node.textContent.substring(endOffset) : '';
|
|
59
|
-
|
|
60
50
|
if (left) {
|
|
61
51
|
node.parentNode.insertBefore(document.createTextNode(left), node);
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
if (middle) {
|
|
65
54
|
var wrapper = document.createElement('span');
|
|
66
55
|
wrapper.innerText = middle;
|
|
@@ -70,59 +59,44 @@ function getNodesInRange(range) {
|
|
|
70
59
|
} else {
|
|
71
60
|
currentNodeRef = node.parentNode;
|
|
72
61
|
}
|
|
73
|
-
|
|
74
62
|
if (right) {
|
|
75
63
|
node.parentNode.insertBefore(document.createTextNode(right), node);
|
|
76
64
|
}
|
|
77
|
-
|
|
78
65
|
node.parentNode.removeChild(node);
|
|
79
66
|
} else if (node === lastNode) {
|
|
80
67
|
if (node.textContent.length) {
|
|
81
68
|
var _middle = node.textContent.substring(0, endOffset);
|
|
82
|
-
|
|
83
69
|
var _right = node.textContent.substring(endOffset);
|
|
84
|
-
|
|
85
70
|
var _wrapper = document.createElement('span');
|
|
86
|
-
|
|
87
71
|
_wrapper.innerText = _middle;
|
|
88
72
|
node.parentNode.insertBefore(_wrapper, node);
|
|
89
|
-
|
|
90
73
|
if (_right) {
|
|
91
74
|
node.parentNode.insertBefore(document.createTextNode(_right), node);
|
|
92
75
|
}
|
|
93
|
-
|
|
94
76
|
node.parentNode.removeChild(node);
|
|
95
77
|
nodes.push(_wrapper);
|
|
96
78
|
currentNodeRef = _wrapper;
|
|
97
79
|
}
|
|
98
80
|
} else if (node.nodeType === Node.TEXT_NODE) {
|
|
99
81
|
var _wrapper2 = document.createElement('span');
|
|
100
|
-
|
|
101
82
|
node.parentNode.insertBefore(_wrapper2, node);
|
|
102
|
-
|
|
103
83
|
_wrapper2.appendChild(node);
|
|
104
|
-
|
|
105
84
|
nodes.push(_wrapper2);
|
|
106
85
|
currentNodeRef = _wrapper2;
|
|
107
86
|
} else {
|
|
108
87
|
logger.warn('Unhandled node', node);
|
|
109
88
|
}
|
|
110
|
-
|
|
111
89
|
if (node === lastNode) {
|
|
112
90
|
break;
|
|
113
91
|
}
|
|
114
|
-
|
|
115
92
|
node = (0, _DOM.getNextNode)(currentNodeRef, commonAncestorContainer);
|
|
116
93
|
}
|
|
117
|
-
|
|
118
94
|
updateRange && selectNodes(nodes);
|
|
119
95
|
return nodes;
|
|
120
96
|
}
|
|
121
|
-
|
|
122
97
|
function selectAll(rootNode) {
|
|
123
98
|
var firstNode = (0, _DOM.getFirstEndNode)(rootNode);
|
|
124
99
|
var lastNode = (0, _DOM.getLastEndNode)(rootNode);
|
|
125
|
-
|
|
126
100
|
if (firstNode && lastNode) {
|
|
127
101
|
var range = document.createRange();
|
|
128
102
|
range.selectNodeContents(rootNode);
|
|
@@ -130,6 +104,5 @@ function selectAll(rootNode) {
|
|
|
130
104
|
range.setEnd(lastNode, lastNode.textContent.length);
|
|
131
105
|
return range;
|
|
132
106
|
}
|
|
133
|
-
|
|
134
107
|
return false;
|
|
135
108
|
}
|
package/Utils/String.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.parseObjectSafe = parseObjectSafe;
|
|
6
7
|
exports.stringJoin = stringJoin;
|
|
7
|
-
exports.xc = xc;
|
|
8
8
|
exports.trimChar = trimChar;
|
|
9
9
|
exports.trimQuotes = trimQuotes;
|
|
10
|
-
exports.
|
|
11
|
-
|
|
10
|
+
exports.xc = xc;
|
|
12
11
|
function stringJoin(valArr) {
|
|
13
12
|
var glue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
14
13
|
var filterFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (o) {
|
|
@@ -16,23 +15,18 @@ function stringJoin(valArr) {
|
|
|
16
15
|
};
|
|
17
16
|
return valArr.filter(filterFn).join(glue);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
function xc() {
|
|
21
19
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
20
|
args[_key] = arguments[_key];
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
return stringJoin(args, ' ');
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
function trimChar(str, charToTrim) {
|
|
29
25
|
return str.replace(new RegExp("^[".concat(charToTrim, "]+(.+)[").concat(charToTrim, "]+$")), '$1');
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
function trimQuotes(str) {
|
|
33
28
|
return trimChar(str, '"');
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
function parseObjectSafe(str) {
|
|
37
31
|
try {
|
|
38
32
|
return JSON.parse(str);
|
package/Utils/UnitConversion.js
CHANGED
|
@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.pixelsToMms = exports.mmsToPixels = void 0;
|
|
7
7
|
var ONE_INCH_IN_MMS = 25.4;
|
|
8
|
-
|
|
9
|
-
var mmsToPixels = function mmsToPixels(mms) {
|
|
8
|
+
var mmsToPixels = exports.mmsToPixels = function mmsToPixels(mms) {
|
|
10
9
|
var dpi = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
|
|
11
10
|
return Math.ceil(mms / ONE_INCH_IN_MMS * dpi);
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
exports.mmsToPixels = mmsToPixels;
|
|
15
|
-
|
|
16
|
-
var pixelsToMms = function pixelsToMms(pixels) {
|
|
12
|
+
var pixelsToMms = exports.pixelsToMms = function pixelsToMms(pixels) {
|
|
17
13
|
var dpi = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
|
|
18
14
|
return Math.floor(pixels / dpi * ONE_INCH_IN_MMS);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.pixelsToMms = pixelsToMms;
|
|
15
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _Calc2D = require("../Calc2D");
|
|
4
|
-
|
|
5
4
|
describe('distanceFromOrigin', function () {
|
|
6
5
|
test('returns the correct value', function () {
|
|
7
6
|
expect((0, _Calc2D.distanceFromOrigin)(0, 0, 0, 0)).toEqual(0);
|
|
@@ -15,13 +14,12 @@ describe('distanceFromOrigin', function () {
|
|
|
15
14
|
describe('transformPoint', function () {
|
|
16
15
|
var roundPoint = function roundPoint(_ref) {
|
|
17
16
|
var x = _ref.x,
|
|
18
|
-
|
|
17
|
+
y = _ref.y;
|
|
19
18
|
return {
|
|
20
19
|
x: Math.round(x * 1000 + Number.EPSILON) / 1000,
|
|
21
20
|
y: Math.round(y * 1000 + Number.EPSILON) / 1000
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
|
-
|
|
25
23
|
test('returns the correct value', function () {
|
|
26
24
|
expect((0, _Calc2D.transformPoint)(5, 5)).toEqual({
|
|
27
25
|
x: 5,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _DOM = require("../DOM");
|
|
4
|
-
|
|
5
4
|
// creates a simple tree to test the dom manipulation functions
|
|
6
5
|
//
|
|
7
6
|
// root(div)
|
|
@@ -33,11 +32,9 @@ function buildSimpleTree() {
|
|
|
33
32
|
text2: text2
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
describe('isElement', function () {
|
|
38
36
|
var _buildSimpleTree = buildSimpleTree(),
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
root = _buildSimpleTree.root;
|
|
41
38
|
test('string => false', function () {
|
|
42
39
|
expect((0, _DOM.isElement)('str')).toEqual(false);
|
|
43
40
|
});
|
|
@@ -50,9 +47,8 @@ describe('isElement', function () {
|
|
|
50
47
|
});
|
|
51
48
|
describe('getFirstEndNode', function () {
|
|
52
49
|
var _buildSimpleTree2 = buildSimpleTree(),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
root = _buildSimpleTree2.root,
|
|
51
|
+
text1 = _buildSimpleTree2.text1;
|
|
56
52
|
test('not node input => throw error', function () {
|
|
57
53
|
expect(function () {
|
|
58
54
|
return (0, _DOM.getFirstEndNode)();
|
|
@@ -67,10 +63,9 @@ describe('getFirstEndNode', function () {
|
|
|
67
63
|
});
|
|
68
64
|
describe('getLastEndNode', function () {
|
|
69
65
|
var _buildSimpleTree3 = buildSimpleTree(),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
root = _buildSimpleTree3.root,
|
|
67
|
+
text1 = _buildSimpleTree3.text1,
|
|
68
|
+
text2 = _buildSimpleTree3.text2;
|
|
74
69
|
test('not node input => throw error', function () {
|
|
75
70
|
expect(function () {
|
|
76
71
|
return (0, _DOM.getLastEndNode)();
|
|
@@ -85,10 +80,9 @@ describe('getLastEndNode', function () {
|
|
|
85
80
|
});
|
|
86
81
|
describe('getNextNode', function () {
|
|
87
82
|
var _buildSimpleTree4 = buildSimpleTree(),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
root = _buildSimpleTree4.root,
|
|
84
|
+
text1 = _buildSimpleTree4.text1,
|
|
85
|
+
text2 = _buildSimpleTree4.text2;
|
|
92
86
|
test('not node input => throw error', function () {
|
|
93
87
|
expect(function () {
|
|
94
88
|
return (0, _DOM.getNextNode)();
|
|
@@ -103,12 +97,11 @@ describe('getNextNode', function () {
|
|
|
103
97
|
});
|
|
104
98
|
describe('getMostOuterContainer', function () {
|
|
105
99
|
var _buildSimpleTree5 = buildSimpleTree(),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
root = _buildSimpleTree5.root,
|
|
101
|
+
span1 = _buildSimpleTree5.span1,
|
|
102
|
+
span2 = _buildSimpleTree5.span2,
|
|
103
|
+
text1 = _buildSimpleTree5.text1,
|
|
104
|
+
text2 = _buildSimpleTree5.text2;
|
|
112
105
|
test('not node input => throw error', function () {
|
|
113
106
|
expect(function () {
|
|
114
107
|
return (0, _DOM.getMostOuterContainer)();
|
|
@@ -126,10 +119,9 @@ describe('getMostOuterContainer', function () {
|
|
|
126
119
|
});
|
|
127
120
|
describe('unwrap', function () {
|
|
128
121
|
var _buildSimpleTree6 = buildSimpleTree(),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
root = _buildSimpleTree6.root,
|
|
123
|
+
span1 = _buildSimpleTree6.span1,
|
|
124
|
+
text1 = _buildSimpleTree6.text1;
|
|
133
125
|
test('not node input => throw error', function () {
|
|
134
126
|
expect(function () {
|
|
135
127
|
return (0, _DOM.unwrap)();
|
|
@@ -1,91 +1,60 @@
|
|
|
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
|
-
var _reactHotLoader = require("react-hot-loader");
|
|
13
|
-
|
|
14
8
|
var _PaperJs = require("../../CanvasAdapters/PaperJs");
|
|
15
|
-
|
|
16
9
|
var _Editor = _interopRequireDefault(require("../../Components/Editor/Editor"));
|
|
17
|
-
|
|
18
10
|
var _CanvasProvider = require("../../CanvasInterface/CanvasProvider");
|
|
19
|
-
|
|
20
11
|
var _SelectionToolbox = _interopRequireDefault(require("../../Components/SelectionToolbox/SelectionToolbox"));
|
|
21
|
-
|
|
22
12
|
var _TextEditorStateProvider = require("../../Components/TextEditor/TextEditorStateProvider");
|
|
23
|
-
|
|
24
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
-
|
|
14
|
+
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); }
|
|
26
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
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); }
|
|
33
|
-
|
|
34
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
-
|
|
16
|
+
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); } }
|
|
17
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
+
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); }
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
36
20
|
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); }; }
|
|
37
|
-
|
|
38
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
39
|
-
|
|
21
|
+
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); }
|
|
40
22
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
-
|
|
42
23
|
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; } }
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
24
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
+
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; }
|
|
26
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
27
|
+
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); }
|
|
48
28
|
var canvas = new _PaperJs.Canvas();
|
|
49
|
-
|
|
50
29
|
var App = /*#__PURE__*/function (_React$Component) {
|
|
51
30
|
_inherits(App, _React$Component);
|
|
52
|
-
|
|
53
31
|
var _super = _createSuper(App);
|
|
54
|
-
|
|
55
32
|
function App() {
|
|
56
33
|
var _this;
|
|
57
|
-
|
|
58
34
|
_classCallCheck(this, App);
|
|
59
|
-
|
|
60
35
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
61
36
|
args[_key] = arguments[_key];
|
|
62
37
|
}
|
|
63
|
-
|
|
64
38
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
65
|
-
|
|
66
39
|
_defineProperty(_assertThisInitialized(_this), "mockUploadFunction", function (files) {
|
|
67
40
|
return new Promise(function (resolve, reject) {
|
|
68
41
|
var reader = new FileReader();
|
|
69
|
-
|
|
70
42
|
reader.onload = function () {
|
|
71
43
|
var dataURL = reader.result;
|
|
72
44
|
resolve([{
|
|
73
45
|
src: dataURL
|
|
74
46
|
}]);
|
|
75
47
|
};
|
|
76
|
-
|
|
77
48
|
reader.onerror = reject;
|
|
78
49
|
reader.readAsDataURL(files[0]);
|
|
79
50
|
});
|
|
80
51
|
});
|
|
81
|
-
|
|
82
52
|
return _this;
|
|
83
53
|
}
|
|
84
|
-
|
|
85
54
|
_createClass(App, [{
|
|
86
55
|
key: "render",
|
|
87
56
|
value: function render() {
|
|
88
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
57
|
+
return /*#__PURE__*/_react["default"].createElement(_CanvasProvider.CanvasProvider, {
|
|
89
58
|
canvas: canvas
|
|
90
59
|
}, /*#__PURE__*/_react["default"].createElement(_TextEditorStateProvider.TextEditorStateProvider, {
|
|
91
60
|
defaultStyle: {
|
|
@@ -118,13 +87,9 @@ var App = /*#__PURE__*/function (_React$Component) {
|
|
|
118
87
|
}
|
|
119
88
|
}, /*#__PURE__*/_react["default"].createElement(_CanvasProvider.CanvasStateProvider, {
|
|
120
89
|
canvas: canvas
|
|
121
|
-
}, /*#__PURE__*/_react["default"].createElement(_SelectionToolbox["default"], null)))))
|
|
90
|
+
}, /*#__PURE__*/_react["default"].createElement(_SelectionToolbox["default"], null)))));
|
|
122
91
|
}
|
|
123
92
|
}]);
|
|
124
|
-
|
|
125
93
|
return App;
|
|
126
94
|
}(_react["default"].Component);
|
|
127
|
-
|
|
128
|
-
var _default = (0, _reactHotLoader.hot)(module)(App);
|
|
129
|
-
|
|
130
|
-
exports["default"] = _default;
|
|
95
|
+
var _default = exports["default"] = App;
|