@react-fabric/draw 1.0.0-beta.11
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/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/cjs/_virtual/_commonjsHelpers.js +7 -0
- package/dist/cjs/_virtual/dom-to-image.js +5 -0
- package/dist/cjs/node_modules/dom-to-image/src/dom-to-image.js +777 -0
- package/dist/cjs/packages/draw/src/canvas/DrawCanvas.js +326 -0
- package/dist/cjs/packages/draw/src/canvas/DrawContext.js +22 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/AvatarShapeTool.js +271 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/IdleState.js +59 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/PointingState.js +84 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/avatar/type.js +36 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/AudioShape.js +152 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/CardShape.js +115 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/FileShape.js +128 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/ImageShape.js +137 -0
- package/dist/cjs/packages/draw/src/canvas/shapes/custom/VideoShape.js +160 -0
- package/dist/cjs/packages/draw/src/index.js +7 -0
- package/dist/esm/_virtual/_commonjsHelpers.js +7 -0
- package/dist/esm/_virtual/dom-to-image.js +5 -0
- package/dist/esm/node_modules/dom-to-image/src/dom-to-image.js +777 -0
- package/dist/esm/packages/draw/src/canvas/DrawCanvas.js +325 -0
- package/dist/esm/packages/draw/src/canvas/DrawContext.js +21 -0
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/AvatarShapeTool.js +270 -0
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/IdleState.js +59 -0
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/PointingState.js +84 -0
- package/dist/esm/packages/draw/src/canvas/shapes/avatar/type.js +36 -0
- package/dist/esm/packages/draw/src/canvas/shapes/custom/AudioShape.js +152 -0
- package/dist/esm/packages/draw/src/canvas/shapes/custom/CardShape.js +115 -0
- package/dist/esm/packages/draw/src/canvas/shapes/custom/FileShape.js +128 -0
- package/dist/esm/packages/draw/src/canvas/shapes/custom/ImageShape.js +137 -0
- package/dist/esm/packages/draw/src/canvas/shapes/custom/VideoShape.js +160 -0
- package/dist/esm/packages/draw/src/index.js +3 -0
- package/dist/types/canvas/DrawCanvas.d.ts +13 -0
- package/dist/types/canvas/DrawContext.d.ts +6 -0
- package/dist/types/canvas/shapes/avatar/AvatarShapeTool.d.ts +37 -0
- package/dist/types/canvas/shapes/avatar/IdleState.d.ts +8 -0
- package/dist/types/canvas/shapes/avatar/PointingState.d.ts +13 -0
- package/dist/types/canvas/shapes/avatar/type.d.ts +9 -0
- package/dist/types/canvas/shapes/custom/AudioShape.d.ts +18 -0
- package/dist/types/canvas/shapes/custom/CardShape.d.ts +23 -0
- package/dist/types/canvas/shapes/custom/FileShape.d.ts +18 -0
- package/dist/types/canvas/shapes/custom/ImageShape.d.ts +29 -0
- package/dist/types/canvas/shapes/custom/VideoShape.d.ts +32 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +54 -0
- package/src/canvas/DrawCanvas.tsx +291 -0
- package/src/canvas/DrawContext.tsx +36 -0
- package/src/canvas/shapes/avatar/AvatarShapeTool.tsx +234 -0
- package/src/canvas/shapes/avatar/IdleState.ts +61 -0
- package/src/canvas/shapes/avatar/PointingState.ts +97 -0
- package/src/canvas/shapes/avatar/type.ts +41 -0
- package/src/canvas/shapes/custom/AudioShape.tsx +134 -0
- package/src/canvas/shapes/custom/CardShape.tsx +106 -0
- package/src/canvas/shapes/custom/FileShape.tsx +101 -0
- package/src/canvas/shapes/custom/ImageShape.tsx +138 -0
- package/src/canvas/shapes/custom/VideoShape.tsx +170 -0
- package/src/index.ts +24 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
5
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
6
|
+
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
7
|
+
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
8
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
9
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
11
|
+
import { Format } from '@react-fabric/utilities';
|
|
12
|
+
import { Rectangle2d, HTMLContainer, ShapeUtil } from '@tldraw/tldraw';
|
|
13
|
+
import domtoimage from '../../../../../../node_modules/dom-to-image/src/dom-to-image.js';
|
|
14
|
+
import { useRef, useEffect } from 'react';
|
|
15
|
+
import { jsx, jsxs } from '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 VideoShapeUtil = /*#__PURE__*/function (_ShapeUtil) {
|
|
20
|
+
function VideoShapeUtil() {
|
|
21
|
+
_classCallCheck(this, VideoShapeUtil);
|
|
22
|
+
return _callSuper(this, VideoShapeUtil, arguments);
|
|
23
|
+
}
|
|
24
|
+
_inherits(VideoShapeUtil, _ShapeUtil);
|
|
25
|
+
return _createClass(VideoShapeUtil, [{
|
|
26
|
+
key: "onResize",
|
|
27
|
+
value: function onResize(shape, info) {
|
|
28
|
+
return {
|
|
29
|
+
props: {
|
|
30
|
+
w: Math.max(Math.min(info.initialBounds.w * info.scaleX, 1024), 128),
|
|
31
|
+
h: Math.max(Math.min(info.initialBounds.h * info.scaleY, 768), 128)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "getDefaultProps",
|
|
37
|
+
value: function getDefaultProps() {
|
|
38
|
+
return {
|
|
39
|
+
src: "",
|
|
40
|
+
poster: "",
|
|
41
|
+
fileName: "",
|
|
42
|
+
fileSize: 0,
|
|
43
|
+
w: 400,
|
|
44
|
+
h: 300
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "getGeometry",
|
|
49
|
+
value: function getGeometry(shape) {
|
|
50
|
+
return new Rectangle2d({
|
|
51
|
+
width: shape.props.w,
|
|
52
|
+
height: shape.props.h,
|
|
53
|
+
isFilled: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "component",
|
|
58
|
+
value: function component(shape) {
|
|
59
|
+
var _shape$props$fileSize;
|
|
60
|
+
var videoRef = useRef(null);
|
|
61
|
+
useEffect(function () {
|
|
62
|
+
var _videoRef$current2;
|
|
63
|
+
var handler = function handler() {
|
|
64
|
+
var _videoRef$current;
|
|
65
|
+
(_videoRef$current = videoRef.current) === null || _videoRef$current === void 0 || (_videoRef$current = _videoRef$current.closest(".tl-container")) === null || _videoRef$current === void 0 || _videoRef$current.querySelectorAll("video,audio").forEach(function (el) {
|
|
66
|
+
if (el !== videoRef.current) el.pause();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
(_videoRef$current2 = videoRef.current) === null || _videoRef$current2 === void 0 || _videoRef$current2.addEventListener("play", handler);
|
|
70
|
+
}, []);
|
|
71
|
+
return /*#__PURE__*/jsx(HTMLContainer, {
|
|
72
|
+
className: "relative grid",
|
|
73
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
74
|
+
"data-shape-id": shape.id,
|
|
75
|
+
className: "bg-zinc-900 relative p-1 flex flex-col overflow-hidden",
|
|
76
|
+
children: [/*#__PURE__*/jsx("video", {
|
|
77
|
+
controls: true,
|
|
78
|
+
ref: videoRef,
|
|
79
|
+
src: shape.props.src,
|
|
80
|
+
poster: shape.props.poster,
|
|
81
|
+
className: "object-contain flex-1 pointer-events-auto overflow-hidden"
|
|
82
|
+
}), /*#__PURE__*/jsx("img", {
|
|
83
|
+
src: shape.props.poster,
|
|
84
|
+
alt: shape.props.fileName,
|
|
85
|
+
className: "object-contain flex-1 pointer-events-auto overflow-hidden hidden"
|
|
86
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
87
|
+
className: "bg-zinc-800/80 text-white items-center py-1 px-2 flex gap-1 text-sm",
|
|
88
|
+
children: [/*#__PURE__*/jsx("svg", {
|
|
89
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
90
|
+
viewBox: "0 0 24 24",
|
|
91
|
+
width: 16,
|
|
92
|
+
height: 16,
|
|
93
|
+
children: /*#__PURE__*/jsx("path", {
|
|
94
|
+
d: "M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z"
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/jsx("div", {
|
|
97
|
+
className: "truncate flex-1",
|
|
98
|
+
children: shape.props.fileName
|
|
99
|
+
}), /*#__PURE__*/jsx("div", {
|
|
100
|
+
children: Format.bytes((_shape$props$fileSize = shape.props.fileSize) !== null && _shape$props$fileSize !== void 0 ? _shape$props$fileSize : 0)
|
|
101
|
+
})]
|
|
102
|
+
})]
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "indicator",
|
|
108
|
+
value: function indicator(shape) {
|
|
109
|
+
return /*#__PURE__*/jsx("rect", {
|
|
110
|
+
width: shape.props.w,
|
|
111
|
+
height: shape.props.h
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "toSvg",
|
|
116
|
+
value: function () {
|
|
117
|
+
var _toSvg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(shape) {
|
|
118
|
+
var el;
|
|
119
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
120
|
+
while (1) switch (_context.prev = _context.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
el = document.querySelector("div[data-shape-id=\"".concat(shape.id, "\"]"));
|
|
123
|
+
if (el) {
|
|
124
|
+
_context.next = 3;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return _context.abrupt("return", /*#__PURE__*/jsx("img", {
|
|
128
|
+
src: "",
|
|
129
|
+
alt: "svg"
|
|
130
|
+
}));
|
|
131
|
+
case 3:
|
|
132
|
+
el.childNodes.item(0).style.display = "none";
|
|
133
|
+
el.childNodes.item(1).style.display = "block";
|
|
134
|
+
_context.next = 7;
|
|
135
|
+
return domtoimage.toPng(el).then(function (dataUrl) {
|
|
136
|
+
el.childNodes.item(0).style.display = "block";
|
|
137
|
+
el.childNodes.item(1).style.display = "none";
|
|
138
|
+
return /*#__PURE__*/jsx("img", {
|
|
139
|
+
src: dataUrl,
|
|
140
|
+
alt: "svg"
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
case 7:
|
|
144
|
+
return _context.abrupt("return", _context.sent);
|
|
145
|
+
case 8:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee);
|
|
150
|
+
}));
|
|
151
|
+
function toSvg(_x) {
|
|
152
|
+
return _toSvg.apply(this, arguments);
|
|
153
|
+
}
|
|
154
|
+
return toSvg;
|
|
155
|
+
}()
|
|
156
|
+
}]);
|
|
157
|
+
}(ShapeUtil);
|
|
158
|
+
_defineProperty(VideoShapeUtil, "type", "video-card");
|
|
159
|
+
|
|
160
|
+
export { VideoShapeUtil };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type TLEditorSnapshot } from "@tldraw/tldraw";
|
|
2
|
+
import "@tldraw/tldraw/tldraw.css";
|
|
3
|
+
import { type FC, type RefObject } from "react";
|
|
4
|
+
export declare function getSvgAsDataUrl(svg: SVGElement): Promise<string>;
|
|
5
|
+
export interface DrawProps {
|
|
6
|
+
snapshot?: TLEditorSnapshot;
|
|
7
|
+
onUpdate?: (snapshot: TLEditorSnapshot) => void;
|
|
8
|
+
renderer?: (props: KeyValue) => AnyObject;
|
|
9
|
+
canvasRef?: RefObject<{
|
|
10
|
+
exportPages: () => Promise<KeyValue[]>;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare const DrawCanvas: FC<DrawProps>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StateNode } from "@tldraw/editor";
|
|
2
|
+
import { Rectangle2d, ShapeUtil, type Editor } from "@tldraw/tldraw";
|
|
3
|
+
import { Idle } from "./IdleState";
|
|
4
|
+
import { Pointing } from "./PointingState";
|
|
5
|
+
import { type AvatarShape } from "./type";
|
|
6
|
+
/** @public */
|
|
7
|
+
export declare class AvatarShapeTool extends StateNode {
|
|
8
|
+
static id: string;
|
|
9
|
+
static initial: string;
|
|
10
|
+
static children: () => (typeof Idle | typeof Pointing)[];
|
|
11
|
+
shapeType: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class AvatarShapeUtil extends ShapeUtil<AvatarShape> {
|
|
14
|
+
static type: "avatar";
|
|
15
|
+
static props: {
|
|
16
|
+
color: import("@tldraw/tlschema").EnumStyleProp<"black" | "blue" | "green" | "grey" | "light-blue" | "light-green" | "light-red" | "light-violet" | "orange" | "red" | "violet" | "white" | "yellow">;
|
|
17
|
+
fill: import("@tldraw/tlschema").EnumStyleProp<"fill" | "none" | "pattern" | "semi" | "solid">;
|
|
18
|
+
size: import("@tldraw/tlschema").EnumStyleProp<"l" | "m" | "s" | "xl">;
|
|
19
|
+
font: import("@tldraw/tlschema").EnumStyleProp<"draw" | "mono" | "sans" | "serif">;
|
|
20
|
+
text: import("@tldraw/validate").Validator<string>;
|
|
21
|
+
};
|
|
22
|
+
el: HTMLDivElement;
|
|
23
|
+
canEdit: () => boolean;
|
|
24
|
+
canResize: () => boolean;
|
|
25
|
+
hideRotateHandle: () => boolean;
|
|
26
|
+
getDefaultProps(): AvatarShape["props"];
|
|
27
|
+
constructor(editor: Editor);
|
|
28
|
+
getSize(shape: AvatarShape): {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
getGeometry(shape: AvatarShape): Rectangle2d;
|
|
33
|
+
indicator(shape: AvatarShape): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
onChange: (shape: AvatarShape, newText: string) => void;
|
|
35
|
+
component(shape: AvatarShape): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
toSvg(shape: AvatarShape): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StateNode, type TLEventHandlers } from "@tldraw/editor";
|
|
2
|
+
export declare class Idle extends StateNode {
|
|
3
|
+
static id: string;
|
|
4
|
+
onPointerDown: TLEventHandlers["onPointerDown"];
|
|
5
|
+
onEnter: () => void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
onKeyUp: TLEventHandlers["onKeyUp"];
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StateNode, type TLEventHandlers } from "@tldraw/editor";
|
|
2
|
+
import { type AvatarShape } from "./type";
|
|
3
|
+
export declare class Pointing extends StateNode {
|
|
4
|
+
static id: string;
|
|
5
|
+
shape?: AvatarShape;
|
|
6
|
+
markId: string;
|
|
7
|
+
onPointerUp: TLEventHandlers["onPointerUp"];
|
|
8
|
+
onCancel: TLEventHandlers["onCancel"];
|
|
9
|
+
onComplete: TLEventHandlers["onComplete"];
|
|
10
|
+
onInterrupt: TLEventHandlers["onInterrupt"];
|
|
11
|
+
onPointerMove: TLEventHandlers["onPointerMove"];
|
|
12
|
+
cancel(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { T, type TLBaseShape } from "@tldraw/tldraw";
|
|
2
|
+
export declare const AvatarShapeProps: {
|
|
3
|
+
color: import("@tldraw/tlschema").EnumStyleProp<"black" | "blue" | "green" | "grey" | "light-blue" | "light-green" | "light-red" | "light-violet" | "orange" | "red" | "violet" | "white" | "yellow">;
|
|
4
|
+
fill: import("@tldraw/tlschema").EnumStyleProp<"fill" | "none" | "pattern" | "semi" | "solid">;
|
|
5
|
+
size: import("@tldraw/tlschema").EnumStyleProp<"l" | "m" | "s" | "xl">;
|
|
6
|
+
font: import("@tldraw/tlschema").EnumStyleProp<"draw" | "mono" | "sans" | "serif">;
|
|
7
|
+
text: T.Validator<string>;
|
|
8
|
+
};
|
|
9
|
+
export type AvatarShape = TLBaseShape<"avatar", typeof AvatarShapeProps>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Rectangle2d, ShapeUtil, type TLBaseShape } from "@tldraw/tldraw";
|
|
2
|
+
type AudioShape = TLBaseShape<"audio-card", {
|
|
3
|
+
src: string;
|
|
4
|
+
poster: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
fileSize: number;
|
|
7
|
+
}>;
|
|
8
|
+
export declare class AudioShapeUtil extends ShapeUtil<AudioShape> {
|
|
9
|
+
static type: "audio-card";
|
|
10
|
+
containerRef?: HTMLElement;
|
|
11
|
+
canResize: () => boolean;
|
|
12
|
+
getDefaultProps(): AudioShape["props"];
|
|
13
|
+
getGeometry(shape: AudioShape): Rectangle2d;
|
|
14
|
+
component(shape: AudioShape): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
indicator(shape: AudioShape): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
toSvg(shape: AudioShape): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type JsonObject, Rectangle2d, ShapeUtil, type TLBaseShape, type TLResizeInfo, type TLShapeId } from "@tldraw/tldraw";
|
|
2
|
+
type CardShape = TLBaseShape<"data-card", {
|
|
3
|
+
w: number;
|
|
4
|
+
h: number;
|
|
5
|
+
} & KeyValue>;
|
|
6
|
+
export declare class CardShapeUtil extends ShapeUtil<CardShape> {
|
|
7
|
+
static type: "data-card";
|
|
8
|
+
onResize(shape: CardShape, info: TLResizeInfo<CardShape>): Omit<{
|
|
9
|
+
id: TLShapeId;
|
|
10
|
+
meta?: Partial<JsonObject> | undefined;
|
|
11
|
+
props?: Partial<{
|
|
12
|
+
w: number;
|
|
13
|
+
h: number;
|
|
14
|
+
} & KeyValue<any>> | undefined;
|
|
15
|
+
type: "data-card";
|
|
16
|
+
} & Partial<Omit<CardShape, "props" | "type" | "id" | "meta">>, "type" | "id"> | undefined;
|
|
17
|
+
getDefaultProps(): CardShape["props"];
|
|
18
|
+
getGeometry(shape: CardShape): Rectangle2d;
|
|
19
|
+
component(shape: CardShape): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
indicator(shape: CardShape): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
toSvg(shape: CardShape): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Rectangle2d, ShapeUtil, type TLBaseShape } from "@tldraw/tldraw";
|
|
2
|
+
type FileShape = TLBaseShape<"file-card", {
|
|
3
|
+
icon: string;
|
|
4
|
+
fileType: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
fileSize: number;
|
|
7
|
+
}>;
|
|
8
|
+
export declare class FileShapeUtil extends ShapeUtil<FileShape> {
|
|
9
|
+
static type: "file-card";
|
|
10
|
+
containerRef?: HTMLElement;
|
|
11
|
+
canResize: () => boolean;
|
|
12
|
+
getDefaultProps(): FileShape["props"];
|
|
13
|
+
getGeometry(shape: FileShape): Rectangle2d;
|
|
14
|
+
component(shape: FileShape): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
indicator(shape: FileShape): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
toSvg(shape: FileShape): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type JsonObject, Rectangle2d, ShapeUtil, type TLBaseShape, type TLResizeInfo, type TLShapeId } from "@tldraw/tldraw";
|
|
2
|
+
type ImageShape = TLBaseShape<"image-card", {
|
|
3
|
+
w: number;
|
|
4
|
+
h: number;
|
|
5
|
+
src: string;
|
|
6
|
+
fileName: string;
|
|
7
|
+
fileSize: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class ImageShapeUtil extends ShapeUtil<ImageShape> {
|
|
10
|
+
static type: "image-card";
|
|
11
|
+
onResize(shape: ImageShape, info: TLResizeInfo<ImageShape>): Omit<{
|
|
12
|
+
id: TLShapeId;
|
|
13
|
+
meta?: Partial<JsonObject> | undefined;
|
|
14
|
+
props?: Partial<{
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
src: string;
|
|
18
|
+
fileName: string;
|
|
19
|
+
fileSize: number;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
type: "image-card";
|
|
22
|
+
} & Partial<Omit<ImageShape, "props" | "type" | "id" | "meta">>, "type" | "id"> | undefined;
|
|
23
|
+
getDefaultProps(): ImageShape["props"];
|
|
24
|
+
getGeometry(shape: ImageShape): Rectangle2d;
|
|
25
|
+
component(shape: ImageShape): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
indicator(shape: ImageShape): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
toSvg(shape: ImageShape): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type JsonObject, Rectangle2d, ShapeUtil, type TLBaseShape, type TLResizeInfo, type TLShapeId } from "@tldraw/tldraw";
|
|
2
|
+
type VideoShape = TLBaseShape<"video-card", {
|
|
3
|
+
w: number;
|
|
4
|
+
h: number;
|
|
5
|
+
src: string;
|
|
6
|
+
poster: string;
|
|
7
|
+
fileName: string;
|
|
8
|
+
fileSize: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class VideoShapeUtil extends ShapeUtil<VideoShape> {
|
|
11
|
+
static type: "video-card";
|
|
12
|
+
containerRef?: HTMLElement;
|
|
13
|
+
onResize(shape: VideoShape, info: TLResizeInfo<VideoShape>): Omit<{
|
|
14
|
+
id: TLShapeId;
|
|
15
|
+
meta?: Partial<JsonObject> | undefined;
|
|
16
|
+
props?: Partial<{
|
|
17
|
+
w: number;
|
|
18
|
+
h: number;
|
|
19
|
+
src: string;
|
|
20
|
+
poster: string;
|
|
21
|
+
fileName: string;
|
|
22
|
+
fileSize: number;
|
|
23
|
+
}> | undefined;
|
|
24
|
+
type: "video-card";
|
|
25
|
+
} & Partial<Omit<VideoShape, "props" | "type" | "id" | "meta">>, "type" | "id"> | undefined;
|
|
26
|
+
getDefaultProps(): VideoShape["props"];
|
|
27
|
+
getGeometry(shape: VideoShape): Rectangle2d;
|
|
28
|
+
component(shape: VideoShape): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
indicator(shape: VideoShape): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
toSvg(shape: VideoShape): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DrawCanvas } from "./canvas/DrawCanvas";
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-fabric/draw",
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
|
+
"description": "RUF: TLDraw canvas",
|
|
5
|
+
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": "https://github.com/adarshpastakia/react-ui-framework/tree/main/packages/draw",
|
|
8
|
+
"source": "src/index.ts",
|
|
9
|
+
"main": "dist/cjs/index.js",
|
|
10
|
+
"module": "dist/esm/index.js",
|
|
11
|
+
"types": "dist/types/index.d.ts",
|
|
12
|
+
"directories": {
|
|
13
|
+
"src": "src",
|
|
14
|
+
"test": "tests"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"makelink": "yarn link",
|
|
26
|
+
"removelink": "yarn unlink",
|
|
27
|
+
"prebuild": "rm -rf ./dist",
|
|
28
|
+
"build:dts": "tsc -p ./tsconfig.build.json",
|
|
29
|
+
"build:rollup": "rollup -c ../../rollup.config.mjs",
|
|
30
|
+
"build": "npm-run-all -p build:rollup build:dts",
|
|
31
|
+
"watch:dts": "tsc -w -p ./tsconfig.build.json",
|
|
32
|
+
"watch:rollup": "rollup -w -c ../../rollup.config.mjs",
|
|
33
|
+
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@react-fabric/core": "^1.0.0-beta.11",
|
|
37
|
+
"@react-fabric/utilities": "^1.0.0-beta.11",
|
|
38
|
+
"@tldraw/assets": "^3.3.1",
|
|
39
|
+
"@tldraw/editor": "^3.3.1",
|
|
40
|
+
"@tldraw/tldraw": "^3.3.1",
|
|
41
|
+
"classnames": "^2.5.1"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"i18next": "^23.15.1",
|
|
45
|
+
"react": ">=18.0.0 <20.0.0",
|
|
46
|
+
"react-dom": ">=18.0.0 <20.0.0",
|
|
47
|
+
"react-i18next": "^15.0.2"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18.12.0",
|
|
51
|
+
"npm": ">=8.19.0"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "c113890832384265335f0572bfad9438e811917f"
|
|
54
|
+
}
|