@react-fabric/draw 1.0.0-beta.9 → 1.0.2
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/dist/cjs/index.js +32 -0
- package/dist/esm/index.js +31 -0
- package/dist/types/index.d.ts +26 -1
- package/package.json +15 -17
- package/src/index.ts +21 -18
- package/dist/cjs/_virtual/_commonjsHelpers.js +0 -7
- package/dist/cjs/_virtual/dom-to-image.js +0 -5
- package/dist/cjs/node_modules/dom-to-image/src/dom-to-image.js +0 -777
- package/dist/cjs/packages/draw/src/canvas/DrawCanvas.js +0 -326
- package/dist/cjs/packages/draw/src/canvas/DrawContext.js +0 -22
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/AvatarShapeTool.js +0 -271
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/IdleState.js +0 -59
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/PointingState.js +0 -84
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/type.js +0 -36
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/AudioShape.js +0 -152
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/CardShape.js +0 -115
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/FileShape.js +0 -128
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/ImageShape.js +0 -137
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/VideoShape.js +0 -160
- package/dist/cjs/packages/draw/src/index.js +0 -7
- package/dist/esm/_virtual/_commonjsHelpers.js +0 -7
- package/dist/esm/_virtual/dom-to-image.js +0 -5
- package/dist/esm/node_modules/dom-to-image/src/dom-to-image.js +0 -777
- package/dist/esm/packages/draw/src/canvas/DrawCanvas.js +0 -325
- package/dist/esm/packages/draw/src/canvas/DrawContext.js +0 -21
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/AvatarShapeTool.js +0 -270
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/IdleState.js +0 -59
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/PointingState.js +0 -84
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/type.js +0 -36
- package/dist/esm/packages/draw/src/canvas/shapes/custom/AudioShape.js +0 -152
- package/dist/esm/packages/draw/src/canvas/shapes/custom/CardShape.js +0 -115
- package/dist/esm/packages/draw/src/canvas/shapes/custom/FileShape.js +0 -128
- package/dist/esm/packages/draw/src/canvas/shapes/custom/ImageShape.js +0 -137
- package/dist/esm/packages/draw/src/canvas/shapes/custom/VideoShape.js +0 -160
- package/dist/esm/packages/draw/src/index.js +0 -3
- package/dist/types/canvas/DrawCanvas.d.ts +0 -13
- package/dist/types/canvas/DrawContext.d.ts +0 -6
- package/dist/types/canvas/shapes/avatar/AvatarShapeTool.d.ts +0 -37
- package/dist/types/canvas/shapes/avatar/IdleState.d.ts +0 -8
- package/dist/types/canvas/shapes/avatar/PointingState.d.ts +0 -13
- package/dist/types/canvas/shapes/avatar/type.d.ts +0 -9
- package/dist/types/canvas/shapes/custom/AudioShape.d.ts +0 -18
- package/dist/types/canvas/shapes/custom/CardShape.d.ts +0 -23
- package/dist/types/canvas/shapes/custom/FileShape.d.ts +0 -18
- package/dist/types/canvas/shapes/custom/ImageShape.d.ts +0 -29
- package/dist/types/canvas/shapes/custom/VideoShape.d.ts +0 -32
- package/src/canvas/DrawCanvas.tsx +0 -291
- package/src/canvas/DrawContext.tsx +0 -36
- package/src/canvas/shapes/avatar/AvatarShapeTool.tsx +0 -234
- package/src/canvas/shapes/avatar/IdleState.ts +0 -61
- package/src/canvas/shapes/avatar/PointingState.ts +0 -97
- package/src/canvas/shapes/avatar/type.ts +0 -41
- package/src/canvas/shapes/custom/AudioShape.tsx +0 -134
- package/src/canvas/shapes/custom/CardShape.tsx +0 -106
- package/src/canvas/shapes/custom/FileShape.tsx +0 -101
- package/src/canvas/shapes/custom/ImageShape.tsx +0 -138
- package/src/canvas/shapes/custom/VideoShape.tsx +0 -170
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
4
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
5
|
-
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
6
|
-
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
7
|
-
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
8
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
9
|
-
var editor = require('@tldraw/editor');
|
|
10
|
-
var tldraw = require('@tldraw/tldraw');
|
|
11
|
-
|
|
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; }
|
|
14
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
15
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
-
var Pointing = /*#__PURE__*/function (_StateNode) {
|
|
17
|
-
function Pointing() {
|
|
18
|
-
var _this;
|
|
19
|
-
_classCallCheck(this, Pointing);
|
|
20
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
-
args[_key] = arguments[_key];
|
|
22
|
-
}
|
|
23
|
-
_this = _callSuper(this, Pointing, [].concat(args));
|
|
24
|
-
_defineProperty(_this, "markId", "");
|
|
25
|
-
_defineProperty(_this, "onPointerUp", function () {
|
|
26
|
-
_this.cancel();
|
|
27
|
-
});
|
|
28
|
-
_defineProperty(_this, "onCancel", function () {
|
|
29
|
-
_this.cancel();
|
|
30
|
-
});
|
|
31
|
-
_defineProperty(_this, "onComplete", function () {
|
|
32
|
-
_this.cancel();
|
|
33
|
-
});
|
|
34
|
-
_defineProperty(_this, "onInterrupt", function () {
|
|
35
|
-
_this.cancel();
|
|
36
|
-
});
|
|
37
|
-
_defineProperty(_this, "onPointerMove", function (info) {
|
|
38
|
-
if (_this.editor.inputs.isDragging) {
|
|
39
|
-
var originPagePoint = _this.editor.inputs.originPagePoint;
|
|
40
|
-
var id = tldraw.createShapeId();
|
|
41
|
-
_this.markId = "creating:".concat(id);
|
|
42
|
-
_this.editor.mark(_this.markId);
|
|
43
|
-
_this.editor.createShapes([{
|
|
44
|
-
id: id,
|
|
45
|
-
type: "avatar",
|
|
46
|
-
x: originPagePoint.x,
|
|
47
|
-
y: originPagePoint.y,
|
|
48
|
-
props: {
|
|
49
|
-
color: "black",
|
|
50
|
-
fill: "none",
|
|
51
|
-
size: "m",
|
|
52
|
-
font: "draw",
|
|
53
|
-
text: "person"
|
|
54
|
-
}
|
|
55
|
-
}]).select(id).setCurrentTool("select.resizing", _objectSpread(_objectSpread({}, info), {}, {
|
|
56
|
-
target: "selection",
|
|
57
|
-
handle: "bottom_right",
|
|
58
|
-
isCreating: true,
|
|
59
|
-
creationCursorOffset: {
|
|
60
|
-
x: 1,
|
|
61
|
-
y: 1
|
|
62
|
-
},
|
|
63
|
-
onInteractionEnd: "avatar"
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return _this;
|
|
68
|
-
}
|
|
69
|
-
_inherits(Pointing, _StateNode);
|
|
70
|
-
return _createClass(Pointing, [{
|
|
71
|
-
key: "cancel",
|
|
72
|
-
value: function cancel() {
|
|
73
|
-
if (this.shape) {
|
|
74
|
-
// the arrow might not have been created yet!
|
|
75
|
-
this.editor.bailToMark(this.markId);
|
|
76
|
-
}
|
|
77
|
-
this.editor.setHintingShapes([]);
|
|
78
|
-
this.parent.transition("idle", {});
|
|
79
|
-
}
|
|
80
|
-
}]);
|
|
81
|
-
}(editor.StateNode);
|
|
82
|
-
_defineProperty(Pointing, "id", "pointing");
|
|
83
|
-
|
|
84
|
-
exports.Pointing = Pointing;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tldraw = require('@tldraw/tldraw');
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* React Fabric
|
|
7
|
-
* @version: 1.0.0
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
14
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
15
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
16
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
17
|
-
* subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
20
|
-
* portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
23
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
24
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
25
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
var AvatarShapeProps = {
|
|
29
|
-
color: tldraw.DefaultColorStyle,
|
|
30
|
-
fill: tldraw.DefaultFillStyle,
|
|
31
|
-
size: tldraw.DefaultSizeStyle,
|
|
32
|
-
font: tldraw.DefaultFontStyle,
|
|
33
|
-
text: tldraw.T.string
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.AvatarShapeProps = AvatarShapeProps;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
4
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
5
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
6
|
-
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
7
|
-
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
8
|
-
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
9
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
11
|
-
var utilities = require('@react-fabric/utilities');
|
|
12
|
-
var tldraw = require('@tldraw/tldraw');
|
|
13
|
-
var domToImage = require('../../../../../../node_modules/dom-to-image/src/dom-to-image.js');
|
|
14
|
-
var react = require('react');
|
|
15
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
-
|
|
17
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
18
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
-
var AudioShapeUtil = /*#__PURE__*/function (_ShapeUtil) {
|
|
20
|
-
function AudioShapeUtil() {
|
|
21
|
-
var _this;
|
|
22
|
-
_classCallCheck(this, AudioShapeUtil);
|
|
23
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
-
args[_key] = arguments[_key];
|
|
25
|
-
}
|
|
26
|
-
_this = _callSuper(this, AudioShapeUtil, [].concat(args));
|
|
27
|
-
_defineProperty(_this, "canResize", function () {
|
|
28
|
-
return false;
|
|
29
|
-
});
|
|
30
|
-
return _this;
|
|
31
|
-
}
|
|
32
|
-
_inherits(AudioShapeUtil, _ShapeUtil);
|
|
33
|
-
return _createClass(AudioShapeUtil, [{
|
|
34
|
-
key: "getDefaultProps",
|
|
35
|
-
value: function getDefaultProps() {
|
|
36
|
-
return {
|
|
37
|
-
src: "",
|
|
38
|
-
poster: "",
|
|
39
|
-
fileName: "",
|
|
40
|
-
fileSize: 0
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: "getGeometry",
|
|
45
|
-
value: function getGeometry(shape) {
|
|
46
|
-
return new tldraw.Rectangle2d({
|
|
47
|
-
width: 320,
|
|
48
|
-
height: 96,
|
|
49
|
-
isFilled: true
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "component",
|
|
54
|
-
value: function component(shape) {
|
|
55
|
-
var _shape$props$fileSize;
|
|
56
|
-
var audioRef = react.useRef(null);
|
|
57
|
-
react.useEffect(function () {
|
|
58
|
-
var _audioRef$current2;
|
|
59
|
-
var handler = function handler() {
|
|
60
|
-
var _audioRef$current;
|
|
61
|
-
(_audioRef$current = audioRef.current) === null || _audioRef$current === void 0 || (_audioRef$current = _audioRef$current.closest(".tl-container")) === null || _audioRef$current === void 0 || _audioRef$current.querySelectorAll("video,audio").forEach(function (el) {
|
|
62
|
-
if (el !== audioRef.current) el.pause();
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
(_audioRef$current2 = audioRef.current) === null || _audioRef$current2 === void 0 || _audioRef$current2.addEventListener("play", handler);
|
|
66
|
-
}, []);
|
|
67
|
-
return /*#__PURE__*/jsxRuntime.jsx(tldraw.HTMLContainer, {
|
|
68
|
-
className: "relative grid",
|
|
69
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
70
|
-
"data-shape-id": shape.id,
|
|
71
|
-
className: "bg-zinc-900 relative p-1 flex flex-col overflow-hidden",
|
|
72
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("audio", {
|
|
73
|
-
controls: true,
|
|
74
|
-
ref: audioRef,
|
|
75
|
-
src: shape.props.src,
|
|
76
|
-
className: "object-contain flex-1 w-full pointer-events-auto overflow-hidden"
|
|
77
|
-
}), /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
78
|
-
alt: shape.props.fileName,
|
|
79
|
-
src: shape.props.poster,
|
|
80
|
-
className: "object-fill flex-1 pointer-events-auto overflow-hidden hidden"
|
|
81
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
82
|
-
className: "bg-zinc-800/80 text-white items-center py-1 px-2 flex gap-1 text-sm",
|
|
83
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("svg", {
|
|
84
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
85
|
-
viewBox: "0 0 24 24",
|
|
86
|
-
width: 16,
|
|
87
|
-
height: 16,
|
|
88
|
-
children: /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
89
|
-
d: "M12,2A3,3 0 0,1 15,5V11A3,3 0 0,1 12,14A3,3 0 0,1 9,11V5A3,3 0 0,1 12,2M19,11C19,14.53 16.39,17.44 13,17.93V21H11V17.93C7.61,17.44 5,14.53 5,11H7A5,5 0 0,0 12,16A5,5 0 0,0 17,11H19Z"
|
|
90
|
-
})
|
|
91
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
92
|
-
className: "truncate flex-1",
|
|
93
|
-
children: shape.props.fileName
|
|
94
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
95
|
-
children: utilities.Format.bytes((_shape$props$fileSize = shape.props.fileSize) !== null && _shape$props$fileSize !== void 0 ? _shape$props$fileSize : 0)
|
|
96
|
-
})]
|
|
97
|
-
})]
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "indicator",
|
|
103
|
-
value: function indicator(shape) {
|
|
104
|
-
return /*#__PURE__*/jsxRuntime.jsx("rect", {});
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "toSvg",
|
|
108
|
-
value: function () {
|
|
109
|
-
var _toSvg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(shape) {
|
|
110
|
-
var el;
|
|
111
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
112
|
-
while (1) switch (_context.prev = _context.next) {
|
|
113
|
-
case 0:
|
|
114
|
-
el = document.querySelector("div[data-shape-id=\"".concat(shape.id, "\"]"));
|
|
115
|
-
if (el) {
|
|
116
|
-
_context.next = 3;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
return _context.abrupt("return", /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
120
|
-
src: "",
|
|
121
|
-
alt: "svg"
|
|
122
|
-
}));
|
|
123
|
-
case 3:
|
|
124
|
-
el.childNodes.item(0).style.display = "none";
|
|
125
|
-
el.childNodes.item(1).style.display = "block";
|
|
126
|
-
_context.next = 7;
|
|
127
|
-
return domToImage.toPng(el).then(function (dataUrl) {
|
|
128
|
-
el.childNodes.item(0).style.display = "block";
|
|
129
|
-
el.childNodes.item(1).style.display = "none";
|
|
130
|
-
return /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
131
|
-
src: dataUrl,
|
|
132
|
-
alt: "svg"
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
case 7:
|
|
136
|
-
return _context.abrupt("return", _context.sent);
|
|
137
|
-
case 8:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context.stop();
|
|
140
|
-
}
|
|
141
|
-
}, _callee);
|
|
142
|
-
}));
|
|
143
|
-
function toSvg(_x) {
|
|
144
|
-
return _toSvg.apply(this, arguments);
|
|
145
|
-
}
|
|
146
|
-
return toSvg;
|
|
147
|
-
}()
|
|
148
|
-
}]);
|
|
149
|
-
}(tldraw.ShapeUtil);
|
|
150
|
-
_defineProperty(AudioShapeUtil, "type", "audio-card");
|
|
151
|
-
|
|
152
|
-
exports.AudioShapeUtil = AudioShapeUtil;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
4
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
5
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
6
|
-
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
7
|
-
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
8
|
-
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
9
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
11
|
-
var tldraw = require('@tldraw/tldraw');
|
|
12
|
-
var domToImage = require('../../../../../../node_modules/dom-to-image/src/dom-to-image.js');
|
|
13
|
-
var DrawContext = require('../../DrawContext.js');
|
|
14
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
17
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
-
var CardShapeUtil = /*#__PURE__*/function (_ShapeUtil) {
|
|
19
|
-
function CardShapeUtil() {
|
|
20
|
-
_classCallCheck(this, CardShapeUtil);
|
|
21
|
-
return _callSuper(this, CardShapeUtil, arguments);
|
|
22
|
-
}
|
|
23
|
-
_inherits(CardShapeUtil, _ShapeUtil);
|
|
24
|
-
return _createClass(CardShapeUtil, [{
|
|
25
|
-
key: "onResize",
|
|
26
|
-
value: function onResize(shape, info) {
|
|
27
|
-
return {
|
|
28
|
-
props: {
|
|
29
|
-
w: Math.max(Math.min(info.initialBounds.w * info.scaleX, 1024), 128),
|
|
30
|
-
h: Math.max(Math.min(info.initialBounds.h * info.scaleY, 768), 128)
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
key: "getDefaultProps",
|
|
36
|
-
value: function getDefaultProps() {
|
|
37
|
-
return {
|
|
38
|
-
w: 300,
|
|
39
|
-
h: 200
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "getGeometry",
|
|
44
|
-
value: function getGeometry(shape) {
|
|
45
|
-
return new tldraw.Rectangle2d({
|
|
46
|
-
width: shape.props.w,
|
|
47
|
-
height: shape.props.h,
|
|
48
|
-
isFilled: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: "component",
|
|
53
|
-
value: function component(shape) {
|
|
54
|
-
var _useDrawContext = DrawContext.useDrawContext(),
|
|
55
|
-
renderer = _useDrawContext.renderer;
|
|
56
|
-
return /*#__PURE__*/jsxRuntime.jsx(tldraw.HTMLContainer, {
|
|
57
|
-
className: "relative grid",
|
|
58
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
59
|
-
className: "relative grid",
|
|
60
|
-
"data-shape-id": shape.id,
|
|
61
|
-
children: renderer === null || renderer === void 0 ? void 0 : renderer(shape.props)
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "indicator",
|
|
67
|
-
value: function indicator(shape) {
|
|
68
|
-
return /*#__PURE__*/jsxRuntime.jsx("rect", {
|
|
69
|
-
width: shape.props.w,
|
|
70
|
-
height: shape.props.h
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "toSvg",
|
|
75
|
-
value: function () {
|
|
76
|
-
var _toSvg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(shape) {
|
|
77
|
-
var el;
|
|
78
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
79
|
-
while (1) switch (_context.prev = _context.next) {
|
|
80
|
-
case 0:
|
|
81
|
-
el = document.querySelector("div[data-shape-id=\"".concat(shape.id, "\"]"));
|
|
82
|
-
if (el) {
|
|
83
|
-
_context.next = 3;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
return _context.abrupt("return", /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
87
|
-
src: "",
|
|
88
|
-
alt: "svg"
|
|
89
|
-
}));
|
|
90
|
-
case 3:
|
|
91
|
-
_context.next = 5;
|
|
92
|
-
return domToImage.toPng(el).then(function (dataUrl) {
|
|
93
|
-
return /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
94
|
-
src: dataUrl,
|
|
95
|
-
alt: "svg"
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
case 5:
|
|
99
|
-
return _context.abrupt("return", _context.sent);
|
|
100
|
-
case 6:
|
|
101
|
-
case "end":
|
|
102
|
-
return _context.stop();
|
|
103
|
-
}
|
|
104
|
-
}, _callee);
|
|
105
|
-
}));
|
|
106
|
-
function toSvg(_x) {
|
|
107
|
-
return _toSvg.apply(this, arguments);
|
|
108
|
-
}
|
|
109
|
-
return toSvg;
|
|
110
|
-
}()
|
|
111
|
-
}]);
|
|
112
|
-
}(tldraw.ShapeUtil);
|
|
113
|
-
_defineProperty(CardShapeUtil, "type", "data-card");
|
|
114
|
-
|
|
115
|
-
exports.CardShapeUtil = CardShapeUtil;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
4
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
5
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
6
|
-
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
7
|
-
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
8
|
-
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
9
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
11
|
-
var utilities = require('@react-fabric/utilities');
|
|
12
|
-
var tldraw = require('@tldraw/tldraw');
|
|
13
|
-
var domToImage = require('../../../../../../node_modules/dom-to-image/src/dom-to-image.js');
|
|
14
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
17
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
-
var FileShapeUtil = /*#__PURE__*/function (_ShapeUtil) {
|
|
19
|
-
function FileShapeUtil() {
|
|
20
|
-
var _this;
|
|
21
|
-
_classCallCheck(this, FileShapeUtil);
|
|
22
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
-
args[_key] = arguments[_key];
|
|
24
|
-
}
|
|
25
|
-
_this = _callSuper(this, FileShapeUtil, [].concat(args));
|
|
26
|
-
_defineProperty(_this, "canResize", function () {
|
|
27
|
-
return false;
|
|
28
|
-
});
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
_inherits(FileShapeUtil, _ShapeUtil);
|
|
32
|
-
return _createClass(FileShapeUtil, [{
|
|
33
|
-
key: "getDefaultProps",
|
|
34
|
-
value: function getDefaultProps() {
|
|
35
|
-
return {
|
|
36
|
-
icon: "",
|
|
37
|
-
fileType: "",
|
|
38
|
-
fileName: "",
|
|
39
|
-
fileSize: 0
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "getGeometry",
|
|
44
|
-
value: function getGeometry(shape) {
|
|
45
|
-
return new tldraw.Rectangle2d({
|
|
46
|
-
width: 320,
|
|
47
|
-
height: 72,
|
|
48
|
-
isFilled: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: "component",
|
|
53
|
-
value: function component(shape) {
|
|
54
|
-
var _shape$props$fileSize;
|
|
55
|
-
return /*#__PURE__*/jsxRuntime.jsx(tldraw.HTMLContainer, {
|
|
56
|
-
className: "relative grid",
|
|
57
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
58
|
-
"data-shape-id": shape.id,
|
|
59
|
-
className: "relative p-1 flex border rounded m-1 overflow-hidden",
|
|
60
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("img", {
|
|
61
|
-
src: shape.props.icon,
|
|
62
|
-
alt: shape.props.fileType,
|
|
63
|
-
className: "object-contain pointer-events-none overflow-hidden w-12 h-12"
|
|
64
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
65
|
-
className: "flex-1 overflow-hidden text-sm py-1 px-2",
|
|
66
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
67
|
-
className: "items-center flex gap-1",
|
|
68
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
69
|
-
className: "truncate flex-1",
|
|
70
|
-
children: shape.props.fileName
|
|
71
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
72
|
-
children: utilities.Format.bytes((_shape$props$fileSize = shape.props.fileSize) !== null && _shape$props$fileSize !== void 0 ? _shape$props$fileSize : 0)
|
|
73
|
-
})]
|
|
74
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
75
|
-
children: shape.props.fileType
|
|
76
|
-
})]
|
|
77
|
-
})]
|
|
78
|
-
})
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "indicator",
|
|
83
|
-
value: function indicator(shape) {
|
|
84
|
-
return /*#__PURE__*/jsxRuntime.jsx("rect", {});
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
|
-
key: "toSvg",
|
|
88
|
-
value: function () {
|
|
89
|
-
var _toSvg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(shape) {
|
|
90
|
-
var el;
|
|
91
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
92
|
-
while (1) switch (_context.prev = _context.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
el = document.querySelector("div[data-shape-id=\"".concat(shape.id, "\"]"));
|
|
95
|
-
if (el) {
|
|
96
|
-
_context.next = 3;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
return _context.abrupt("return", /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
100
|
-
src: "",
|
|
101
|
-
alt: "svg"
|
|
102
|
-
}));
|
|
103
|
-
case 3:
|
|
104
|
-
_context.next = 5;
|
|
105
|
-
return domToImage.toPng(el).then(function (dataUrl) {
|
|
106
|
-
return /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
107
|
-
src: dataUrl,
|
|
108
|
-
alt: "svg"
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
case 5:
|
|
112
|
-
return _context.abrupt("return", _context.sent);
|
|
113
|
-
case 6:
|
|
114
|
-
case "end":
|
|
115
|
-
return _context.stop();
|
|
116
|
-
}
|
|
117
|
-
}, _callee);
|
|
118
|
-
}));
|
|
119
|
-
function toSvg(_x) {
|
|
120
|
-
return _toSvg.apply(this, arguments);
|
|
121
|
-
}
|
|
122
|
-
return toSvg;
|
|
123
|
-
}()
|
|
124
|
-
}]);
|
|
125
|
-
}(tldraw.ShapeUtil);
|
|
126
|
-
_defineProperty(FileShapeUtil, "type", "file-card");
|
|
127
|
-
|
|
128
|
-
exports.FileShapeUtil = FileShapeUtil;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
4
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
5
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
6
|
-
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
7
|
-
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
8
|
-
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
9
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
11
|
-
var utilities = require('@react-fabric/utilities');
|
|
12
|
-
var tldraw = require('@tldraw/tldraw');
|
|
13
|
-
var domToImage = require('../../../../../../node_modules/dom-to-image/src/dom-to-image.js');
|
|
14
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
17
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
-
var ImageShapeUtil = /*#__PURE__*/function (_ShapeUtil) {
|
|
19
|
-
function ImageShapeUtil() {
|
|
20
|
-
_classCallCheck(this, ImageShapeUtil);
|
|
21
|
-
return _callSuper(this, ImageShapeUtil, arguments);
|
|
22
|
-
}
|
|
23
|
-
_inherits(ImageShapeUtil, _ShapeUtil);
|
|
24
|
-
return _createClass(ImageShapeUtil, [{
|
|
25
|
-
key: "onResize",
|
|
26
|
-
value: function onResize(shape, info) {
|
|
27
|
-
return {
|
|
28
|
-
props: {
|
|
29
|
-
w: Math.max(Math.min(info.initialBounds.w * info.scaleX, 1024), 128),
|
|
30
|
-
h: Math.max(Math.min(info.initialBounds.h * info.scaleY, 768), 128)
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
key: "getDefaultProps",
|
|
36
|
-
value: function getDefaultProps() {
|
|
37
|
-
return {
|
|
38
|
-
src: "",
|
|
39
|
-
fileName: "",
|
|
40
|
-
fileSize: 0,
|
|
41
|
-
w: 400,
|
|
42
|
-
h: 300
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "getGeometry",
|
|
47
|
-
value: function getGeometry(shape) {
|
|
48
|
-
return new tldraw.Rectangle2d({
|
|
49
|
-
width: shape.props.w,
|
|
50
|
-
height: shape.props.h,
|
|
51
|
-
isFilled: true
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "component",
|
|
56
|
-
value: function component(shape) {
|
|
57
|
-
var _shape$props$fileSize;
|
|
58
|
-
return /*#__PURE__*/jsxRuntime.jsx(tldraw.HTMLContainer, {
|
|
59
|
-
className: "relative grid",
|
|
60
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
61
|
-
"data-shape-id": shape.id,
|
|
62
|
-
className: "bg-zinc-900 relative p-1 flex flex-col overflow-hidden",
|
|
63
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("img", {
|
|
64
|
-
src: shape.props.src,
|
|
65
|
-
alt: shape.props.fileName,
|
|
66
|
-
className: "object-contain flex-1 pointer-events-none overflow-hidden"
|
|
67
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
68
|
-
className: "bg-zinc-800/80 text-white items-center py-1 px-2 flex gap-1 text-sm",
|
|
69
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("svg", {
|
|
70
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
71
|
-
viewBox: "0 0 24 24",
|
|
72
|
-
width: 16,
|
|
73
|
-
height: 16,
|
|
74
|
-
children: /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
75
|
-
d: "M4,4H7L9,2H15L17,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4M12,7A5,5 0 0,0 7,12A5,5 0 0,0 12,17A5,5 0 0,0 17,12A5,5 0 0,0 12,7M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9Z"
|
|
76
|
-
})
|
|
77
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
78
|
-
className: "truncate flex-1",
|
|
79
|
-
children: shape.props.fileName
|
|
80
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
81
|
-
children: utilities.Format.bytes((_shape$props$fileSize = shape.props.fileSize) !== null && _shape$props$fileSize !== void 0 ? _shape$props$fileSize : 0)
|
|
82
|
-
})]
|
|
83
|
-
})]
|
|
84
|
-
})
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "indicator",
|
|
89
|
-
value: function indicator(shape) {
|
|
90
|
-
return /*#__PURE__*/jsxRuntime.jsx("rect", {
|
|
91
|
-
width: shape.props.w,
|
|
92
|
-
height: shape.props.h
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "toSvg",
|
|
97
|
-
value: function () {
|
|
98
|
-
var _toSvg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(shape) {
|
|
99
|
-
var el;
|
|
100
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
101
|
-
while (1) switch (_context.prev = _context.next) {
|
|
102
|
-
case 0:
|
|
103
|
-
el = document.querySelector("div[data-shape-id=\"".concat(shape.id, "\"]"));
|
|
104
|
-
if (el) {
|
|
105
|
-
_context.next = 3;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
return _context.abrupt("return", /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
109
|
-
src: "",
|
|
110
|
-
alt: "svg"
|
|
111
|
-
}));
|
|
112
|
-
case 3:
|
|
113
|
-
_context.next = 5;
|
|
114
|
-
return domToImage.toPng(el).then(function (dataUrl) {
|
|
115
|
-
return /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
116
|
-
src: dataUrl,
|
|
117
|
-
alt: "svg"
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
case 5:
|
|
121
|
-
return _context.abrupt("return", _context.sent);
|
|
122
|
-
case 6:
|
|
123
|
-
case "end":
|
|
124
|
-
return _context.stop();
|
|
125
|
-
}
|
|
126
|
-
}, _callee);
|
|
127
|
-
}));
|
|
128
|
-
function toSvg(_x) {
|
|
129
|
-
return _toSvg.apply(this, arguments);
|
|
130
|
-
}
|
|
131
|
-
return toSvg;
|
|
132
|
-
}()
|
|
133
|
-
}]);
|
|
134
|
-
}(tldraw.ShapeUtil);
|
|
135
|
-
_defineProperty(ImageShapeUtil, "type", "image-card");
|
|
136
|
-
|
|
137
|
-
exports.ImageShapeUtil = ImageShapeUtil;
|