@tsdraw/react 0.9.3 → 0.9.4
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 +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { ZoomRange, ToolId, ColorStyle, DashStyle, FillStyle, SizeStyle, Editor, ToolDefinition, TsdrawBackgroundOptions, TsdrawEditorSnapshot, TsdrawDocumentSnapshot, Viewport } from '@tsdraw/core';
|
|
4
|
-
export { TsdrawBackgroundCustom, TsdrawBackgroundOptions, TsdrawBackgroundPreset, TsdrawBackgroundType } from '@tsdraw/core';
|
|
3
|
+
import { ZoomRange, ToolId, ColorStyle, DashStyle, FillStyle, SizeStyle, Editor, ToolDefinition, AutoShapeOptions, TsdrawBackgroundOptions, TsdrawEditorSnapshot, TsdrawDocumentSnapshot, Viewport } from '@tsdraw/core';
|
|
4
|
+
export { AutoShapeKind, AutoShapeOptions, AutoShapeThresholds, TsdrawBackgroundCustom, TsdrawBackgroundOptions, TsdrawBackgroundPreset, TsdrawBackgroundType } from '@tsdraw/core';
|
|
5
5
|
|
|
6
6
|
interface TsdrawCameraOptions {
|
|
7
7
|
panSpeed?: number;
|
|
@@ -156,6 +156,7 @@ interface TsdrawProps {
|
|
|
156
156
|
touchOptions?: TsdrawTouchOptions;
|
|
157
157
|
keyboardShortcuts?: TsdrawKeyboardShortcutOptions;
|
|
158
158
|
penOptions?: TsdrawPenOptions;
|
|
159
|
+
autoShape?: boolean | AutoShapeOptions;
|
|
159
160
|
background?: TsdrawBackgroundOptions;
|
|
160
161
|
readOnly?: boolean;
|
|
161
162
|
autoFocus?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { ZoomRange, ToolId, ColorStyle, DashStyle, FillStyle, SizeStyle, Editor, ToolDefinition, TsdrawBackgroundOptions, TsdrawEditorSnapshot, TsdrawDocumentSnapshot, Viewport } from '@tsdraw/core';
|
|
4
|
-
export { TsdrawBackgroundCustom, TsdrawBackgroundOptions, TsdrawBackgroundPreset, TsdrawBackgroundType } from '@tsdraw/core';
|
|
3
|
+
import { ZoomRange, ToolId, ColorStyle, DashStyle, FillStyle, SizeStyle, Editor, ToolDefinition, AutoShapeOptions, TsdrawBackgroundOptions, TsdrawEditorSnapshot, TsdrawDocumentSnapshot, Viewport } from '@tsdraw/core';
|
|
4
|
+
export { AutoShapeKind, AutoShapeOptions, AutoShapeThresholds, TsdrawBackgroundCustom, TsdrawBackgroundOptions, TsdrawBackgroundPreset, TsdrawBackgroundType } from '@tsdraw/core';
|
|
5
5
|
|
|
6
6
|
interface TsdrawCameraOptions {
|
|
7
7
|
panSpeed?: number;
|
|
@@ -156,6 +156,7 @@ interface TsdrawProps {
|
|
|
156
156
|
touchOptions?: TsdrawTouchOptions;
|
|
157
157
|
keyboardShortcuts?: TsdrawKeyboardShortcutOptions;
|
|
158
158
|
penOptions?: TsdrawPenOptions;
|
|
159
|
+
autoShape?: boolean | AutoShapeOptions;
|
|
159
160
|
background?: TsdrawBackgroundOptions;
|
|
160
161
|
readOnly?: boolean;
|
|
161
162
|
autoFocus?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -909,6 +909,11 @@ function getHandlePagePoint(bounds, handle) {
|
|
|
909
909
|
return { x: bounds.maxX, y: bounds.maxY };
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
|
+
function resolveAutoShapeOption(input) {
|
|
913
|
+
if (input === false) return { enabled: false };
|
|
914
|
+
if (input === true || input == null) return { enabled: true };
|
|
915
|
+
return { enabled: input.enabled ?? true, ...input };
|
|
916
|
+
}
|
|
912
917
|
var ZOOM_WHEEL_CAP = 10;
|
|
913
918
|
var VIEW_ONLY_TOOLS = /* @__PURE__ */ new Set(["select", "hand"]);
|
|
914
919
|
function useTsdrawCanvasController(options = {}) {
|
|
@@ -920,6 +925,7 @@ function useTsdrawCanvasController(options = {}) {
|
|
|
920
925
|
const touchOptionsRef = useRef(options.touchOptions);
|
|
921
926
|
const keyboardShortcutsRef = useRef(options.keyboardShortcuts);
|
|
922
927
|
const penOptionsRef = useRef(options.penOptions);
|
|
928
|
+
const autoShapeRef = useRef(options.autoShape);
|
|
923
929
|
const backgroundRef = useRef(options.background);
|
|
924
930
|
const readOnlyRef = useRef(options.readOnly ?? false);
|
|
925
931
|
const containerRef = useRef(null);
|
|
@@ -1002,6 +1008,11 @@ function useTsdrawCanvasController(options = {}) {
|
|
|
1002
1008
|
useEffect(() => {
|
|
1003
1009
|
penOptionsRef.current = options.penOptions;
|
|
1004
1010
|
}, [options.penOptions]);
|
|
1011
|
+
useEffect(() => {
|
|
1012
|
+
autoShapeRef.current = options.autoShape;
|
|
1013
|
+
const editor = editorRef.current;
|
|
1014
|
+
if (editor) editor.setAutoShape(resolveAutoShapeOption(options.autoShape));
|
|
1015
|
+
}, [options.autoShape]);
|
|
1005
1016
|
useEffect(() => {
|
|
1006
1017
|
backgroundRef.current = options.background;
|
|
1007
1018
|
}, [options.background]);
|
|
@@ -1140,7 +1151,8 @@ function useTsdrawCanvasController(options = {}) {
|
|
|
1140
1151
|
const editor = new Editor({
|
|
1141
1152
|
toolDefinitions: options.toolDefinitions,
|
|
1142
1153
|
initialToolId: initialTool,
|
|
1143
|
-
zoomRange: cameraOpts?.zoomRange
|
|
1154
|
+
zoomRange: cameraOpts?.zoomRange,
|
|
1155
|
+
autoShape: resolveAutoShapeOption(autoShapeRef.current)
|
|
1144
1156
|
});
|
|
1145
1157
|
editor.renderer.setTheme(options.theme ?? "light");
|
|
1146
1158
|
if (!editor.tools.hasTool(initialTool)) {
|
|
@@ -2115,6 +2127,7 @@ function Tsdraw(props) {
|
|
|
2115
2127
|
touchOptions: props.touchOptions,
|
|
2116
2128
|
keyboardShortcuts: props.keyboardShortcuts,
|
|
2117
2129
|
penOptions: props.penOptions,
|
|
2130
|
+
autoShape: props.autoShape,
|
|
2118
2131
|
background: props.background,
|
|
2119
2132
|
readOnly: props.readOnly,
|
|
2120
2133
|
autoFocus: props.autoFocus,
|