@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.cjs
CHANGED
|
@@ -911,6 +911,11 @@ function getHandlePagePoint(bounds, handle) {
|
|
|
911
911
|
return { x: bounds.maxX, y: bounds.maxY };
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
|
+
function resolveAutoShapeOption(input) {
|
|
915
|
+
if (input === false) return { enabled: false };
|
|
916
|
+
if (input === true || input == null) return { enabled: true };
|
|
917
|
+
return { enabled: input.enabled ?? true, ...input };
|
|
918
|
+
}
|
|
914
919
|
var ZOOM_WHEEL_CAP = 10;
|
|
915
920
|
var VIEW_ONLY_TOOLS = /* @__PURE__ */ new Set(["select", "hand"]);
|
|
916
921
|
function useTsdrawCanvasController(options = {}) {
|
|
@@ -922,6 +927,7 @@ function useTsdrawCanvasController(options = {}) {
|
|
|
922
927
|
const touchOptionsRef = react.useRef(options.touchOptions);
|
|
923
928
|
const keyboardShortcutsRef = react.useRef(options.keyboardShortcuts);
|
|
924
929
|
const penOptionsRef = react.useRef(options.penOptions);
|
|
930
|
+
const autoShapeRef = react.useRef(options.autoShape);
|
|
925
931
|
const backgroundRef = react.useRef(options.background);
|
|
926
932
|
const readOnlyRef = react.useRef(options.readOnly ?? false);
|
|
927
933
|
const containerRef = react.useRef(null);
|
|
@@ -1004,6 +1010,11 @@ function useTsdrawCanvasController(options = {}) {
|
|
|
1004
1010
|
react.useEffect(() => {
|
|
1005
1011
|
penOptionsRef.current = options.penOptions;
|
|
1006
1012
|
}, [options.penOptions]);
|
|
1013
|
+
react.useEffect(() => {
|
|
1014
|
+
autoShapeRef.current = options.autoShape;
|
|
1015
|
+
const editor = editorRef.current;
|
|
1016
|
+
if (editor) editor.setAutoShape(resolveAutoShapeOption(options.autoShape));
|
|
1017
|
+
}, [options.autoShape]);
|
|
1007
1018
|
react.useEffect(() => {
|
|
1008
1019
|
backgroundRef.current = options.background;
|
|
1009
1020
|
}, [options.background]);
|
|
@@ -1142,7 +1153,8 @@ function useTsdrawCanvasController(options = {}) {
|
|
|
1142
1153
|
const editor = new core.Editor({
|
|
1143
1154
|
toolDefinitions: options.toolDefinitions,
|
|
1144
1155
|
initialToolId: initialTool,
|
|
1145
|
-
zoomRange: cameraOpts?.zoomRange
|
|
1156
|
+
zoomRange: cameraOpts?.zoomRange,
|
|
1157
|
+
autoShape: resolveAutoShapeOption(autoShapeRef.current)
|
|
1146
1158
|
});
|
|
1147
1159
|
editor.renderer.setTheme(options.theme ?? "light");
|
|
1148
1160
|
if (!editor.tools.hasTool(initialTool)) {
|
|
@@ -2117,6 +2129,7 @@ function Tsdraw(props) {
|
|
|
2117
2129
|
touchOptions: props.touchOptions,
|
|
2118
2130
|
keyboardShortcuts: props.keyboardShortcuts,
|
|
2119
2131
|
penOptions: props.penOptions,
|
|
2132
|
+
autoShape: props.autoShape,
|
|
2120
2133
|
background: props.background,
|
|
2121
2134
|
readOnly: props.readOnly,
|
|
2122
2135
|
autoFocus: props.autoFocus,
|