@tsdraw/react 0.5.0 → 0.6.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/dist/index.cjs +305 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +306 -92
- package/dist/index.js.map +1 -1
- package/dist/tsdraw.css +43 -22
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { ToolId, Editor, ColorStyle, DashStyle, SizeStyle,
|
|
3
|
+
import { ToolId, Editor, ColorStyle, DashStyle, SizeStyle, ToolDefinition } from '@tsdraw/core';
|
|
4
4
|
|
|
5
5
|
interface TsdrawCursorContext {
|
|
6
6
|
currentTool: ToolId;
|
|
@@ -25,6 +25,10 @@ interface TsdrawMountApi {
|
|
|
25
25
|
canvas: HTMLCanvasElement;
|
|
26
26
|
setTool: (tool: ToolId) => void;
|
|
27
27
|
getCurrentTool: () => ToolId;
|
|
28
|
+
undo: () => boolean;
|
|
29
|
+
redo: () => boolean;
|
|
30
|
+
canUndo: () => boolean;
|
|
31
|
+
canRedo: () => boolean;
|
|
28
32
|
applyDrawStyle: (partial: Partial<{
|
|
29
33
|
color: ColorStyle;
|
|
30
34
|
dash: DashStyle;
|
|
@@ -43,7 +47,8 @@ interface TsdrawCustomTool {
|
|
|
43
47
|
definition: ToolDefinition;
|
|
44
48
|
showStylePanel?: boolean;
|
|
45
49
|
}
|
|
46
|
-
type
|
|
50
|
+
type TsdrawToolbarBuiltInAction = 'undo' | 'redo';
|
|
51
|
+
type ToolbarPartItem = ToolId | TsdrawToolbarBuiltInAction;
|
|
47
52
|
interface TsdrawUiPlacement {
|
|
48
53
|
anchor?: UiAnchor;
|
|
49
54
|
offsetX?: number;
|
|
@@ -53,6 +58,7 @@ interface TsdrawUiPlacement {
|
|
|
53
58
|
interface TsdrawUiOptions {
|
|
54
59
|
toolbar?: {
|
|
55
60
|
placement?: TsdrawUiPlacement;
|
|
61
|
+
parts?: ToolbarPartItem[][];
|
|
56
62
|
};
|
|
57
63
|
stylePanel?: {
|
|
58
64
|
placement?: TsdrawUiPlacement;
|
|
@@ -90,7 +96,7 @@ interface TsdrawProps {
|
|
|
90
96
|
style?: CSSProperties;
|
|
91
97
|
theme?: 'light' | 'dark' | 'system';
|
|
92
98
|
persistenceKey?: string;
|
|
93
|
-
|
|
99
|
+
customTools?: TsdrawCustomTool[];
|
|
94
100
|
initialToolId?: ToolId;
|
|
95
101
|
uiOptions?: TsdrawUiOptions;
|
|
96
102
|
onMount?: (api: TsdrawMountApi) => void | (() => void);
|
|
@@ -99,11 +105,24 @@ type TsdrawCanvasProps = TsdrawProps;
|
|
|
99
105
|
declare function Tsdraw(props: TsdrawProps): react_jsx_runtime.JSX.Element;
|
|
100
106
|
declare function TsdrawCanvas(props: TsdrawCanvasProps): react_jsx_runtime.JSX.Element;
|
|
101
107
|
|
|
102
|
-
interface
|
|
108
|
+
interface ToolbarToolItem {
|
|
109
|
+
type: 'tool';
|
|
103
110
|
id: ToolId;
|
|
104
111
|
label: string;
|
|
105
112
|
icon: ReactNode | ((isActive: boolean) => ReactNode);
|
|
106
113
|
}
|
|
114
|
+
interface ToolbarActionItem {
|
|
115
|
+
type: 'action';
|
|
116
|
+
id: 'undo' | 'redo';
|
|
117
|
+
label: string;
|
|
118
|
+
disabled: boolean;
|
|
119
|
+
onSelect: () => void;
|
|
120
|
+
}
|
|
121
|
+
type ToolbarRenderItem = ToolbarToolItem | ToolbarActionItem;
|
|
122
|
+
interface ToolbarPart {
|
|
123
|
+
id: string;
|
|
124
|
+
items: ToolbarRenderItem[];
|
|
125
|
+
}
|
|
107
126
|
declare function getDefaultToolbarIcon(toolId: ToolId, isActive: boolean): ReactNode;
|
|
108
127
|
|
|
109
|
-
export { type
|
|
128
|
+
export { type ToolbarActionItem, type ToolbarPart, type ToolbarPartItem, type ToolbarRenderItem, type ToolbarToolItem, Tsdraw, TsdrawCanvas, type TsdrawCanvasProps, type TsdrawCursorContext, type TsdrawCustomElement, type TsdrawCustomElementRenderArgs, type TsdrawCustomTool, type TsdrawMountApi, type TsdrawProps, type TsdrawToolOverlayState, type TsdrawToolbarBuiltInAction, type TsdrawUiOptions, type TsdrawUiPlacement, type UiAnchor, getDefaultToolbarIcon };
|