@olenbetong/synergi-react 4.2.0 → 4.2.3
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/es/components/ImageEditor/ImageEditor.d.ts +5 -0
- package/es/components/ImageEditor/ImageEditor.js +2 -2
- package/es/components/ImageEditor/useActiveTool.d.ts +2 -2
- package/es/components/ImageEditor/useActiveTool.js +3 -3
- package/package.json +6 -6
- package/src/components/ImageEditor/ImageEditor.tsx +7 -2
- package/src/components/ImageEditor/useActiveTool.ts +3 -3
|
@@ -25,6 +25,11 @@ interface Props {
|
|
|
25
25
|
plugins: Plugin[];
|
|
26
26
|
/** Optional view plugin (e.g. zoom/pan) that wraps the canvas and contributes top-bar controls. */
|
|
27
27
|
viewPlugin?: ViewPlugin;
|
|
28
|
+
/**
|
|
29
|
+
* Id of a tool plugin (e.g. `"crop"`) to open as soon as the editor mounts, instead of the
|
|
30
|
+
* plain image. Cancelling the tool returns to the plain image as usual.
|
|
31
|
+
*/
|
|
32
|
+
initialTool?: string;
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* Full-screen image editor shell.
|
|
@@ -14,10 +14,10 @@ import { getLocalizedString } from "../../i18n.js";
|
|
|
14
14
|
* Tool plugins contribute an overlay and toolbar; action plugins execute immediately.
|
|
15
15
|
* Supports undo/redo: each applied transformation is recorded with its EditAction list.
|
|
16
16
|
*/
|
|
17
|
-
export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm, onCancel, plugins, viewPlugin }, ref) {
|
|
17
|
+
export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm, onCancel, plugins, viewPlugin, initialTool }, ref) {
|
|
18
18
|
let registry = useMemo(() => buildActionRegistry(plugins), [plugins]);
|
|
19
19
|
let history = useImageHistory(imageUrl, registry);
|
|
20
|
-
let { activePlugin, activateTool, deactivateTool } = useActiveTool(plugins);
|
|
20
|
+
let { activePlugin, activateTool, deactivateTool } = useActiveTool(plugins, initialTool ?? null);
|
|
21
21
|
let [busy, setBusy] = useState(false);
|
|
22
22
|
let disabled = busy || history.replaying;
|
|
23
23
|
let isSmall = useIsSmall();
|
|
@@ -4,6 +4,6 @@ interface UseActiveToolResult {
|
|
|
4
4
|
activateTool: (id: string) => void;
|
|
5
5
|
deactivateTool: () => void;
|
|
6
6
|
}
|
|
7
|
-
/** Manages which tool plugin is currently active. */
|
|
8
|
-
export declare function useActiveTool(plugins: Plugin[]): UseActiveToolResult;
|
|
7
|
+
/** Manages which tool plugin is currently active. `initialTool` names the tool to start in. */
|
|
8
|
+
export declare function useActiveTool(plugins: Plugin[], initialTool?: string | null): UseActiveToolResult;
|
|
9
9
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
/** Manages which tool plugin is currently active. */
|
|
3
|
-
export function useActiveTool(plugins) {
|
|
4
|
-
let [activeId, setActiveId] = useState(
|
|
2
|
+
/** Manages which tool plugin is currently active. `initialTool` names the tool to start in. */
|
|
3
|
+
export function useActiveTool(plugins, initialTool = null) {
|
|
4
|
+
let [activeId, setActiveId] = useState(initialTool);
|
|
5
5
|
let activePlugin = (plugins.find((p) => p.type === "tool" && p.id === activeId) ?? null);
|
|
6
6
|
return {
|
|
7
7
|
activePlugin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
4
4
|
"description": "Standalone React component for SynergiWeb and Partner Portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@emotion/styled": "^11.14.1",
|
|
40
40
|
"@mui/icons-material": "9.4.0",
|
|
41
41
|
"@mui/material": "9.4.0",
|
|
42
|
-
"@olenbetong/appframe-core": "2.
|
|
43
|
-
"@olenbetong/appframe-data": "1.7.
|
|
44
|
-
"@olenbetong/appframe-ds": "1.3.
|
|
45
|
-
"@olenbetong/appframe-mui": "7.0.
|
|
46
|
-
"@olenbetong/appframe-react": "2.2.
|
|
42
|
+
"@olenbetong/appframe-core": "2.15.1",
|
|
43
|
+
"@olenbetong/appframe-data": "1.7.4",
|
|
44
|
+
"@olenbetong/appframe-ds": "1.3.3",
|
|
45
|
+
"@olenbetong/appframe-mui": "7.0.6",
|
|
46
|
+
"@olenbetong/appframe-react": "2.2.4",
|
|
47
47
|
"clsx": "^2.1.1",
|
|
48
48
|
"filepond": "^4.32.12",
|
|
49
49
|
"filepond-plugin-file-poster": "^2.5.2",
|
|
@@ -36,6 +36,11 @@ interface Props {
|
|
|
36
36
|
plugins: Plugin[];
|
|
37
37
|
/** Optional view plugin (e.g. zoom/pan) that wraps the canvas and contributes top-bar controls. */
|
|
38
38
|
viewPlugin?: ViewPlugin;
|
|
39
|
+
/**
|
|
40
|
+
* Id of a tool plugin (e.g. `"crop"`) to open as soon as the editor mounts, instead of the
|
|
41
|
+
* plain image. Cancelling the tool returns to the plain image as usual.
|
|
42
|
+
*/
|
|
43
|
+
initialTool?: string;
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
/**
|
|
@@ -45,12 +50,12 @@ interface Props {
|
|
|
45
50
|
* Supports undo/redo: each applied transformation is recorded with its EditAction list.
|
|
46
51
|
*/
|
|
47
52
|
export const ImageEditor = forwardRef<ImageEditorRef, Props>(function ImageEditor(
|
|
48
|
-
{ imageUrl, onConfirm, onCancel, plugins, viewPlugin }: Props,
|
|
53
|
+
{ imageUrl, onConfirm, onCancel, plugins, viewPlugin, initialTool }: Props,
|
|
49
54
|
ref,
|
|
50
55
|
) {
|
|
51
56
|
let registry = useMemo(() => buildActionRegistry(plugins), [plugins]);
|
|
52
57
|
let history = useImageHistory(imageUrl, registry);
|
|
53
|
-
let { activePlugin, activateTool, deactivateTool } = useActiveTool(plugins);
|
|
58
|
+
let { activePlugin, activateTool, deactivateTool } = useActiveTool(plugins, initialTool ?? null);
|
|
54
59
|
let [busy, setBusy] = useState(false);
|
|
55
60
|
let disabled = busy || history.replaying;
|
|
56
61
|
let isSmall = useIsSmall();
|
|
@@ -8,9 +8,9 @@ interface UseActiveToolResult {
|
|
|
8
8
|
deactivateTool: () => void;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** Manages which tool plugin is currently active. */
|
|
12
|
-
export function useActiveTool(plugins: Plugin[]): UseActiveToolResult {
|
|
13
|
-
let [activeId, setActiveId] = useState<string | null>(
|
|
11
|
+
/** Manages which tool plugin is currently active. `initialTool` names the tool to start in. */
|
|
12
|
+
export function useActiveTool(plugins: Plugin[], initialTool: string | null = null): UseActiveToolResult {
|
|
13
|
+
let [activeId, setActiveId] = useState<string | null>(initialTool);
|
|
14
14
|
let activePlugin = (plugins.find((p) => p.type === "tool" && p.id === activeId) ?? null) as ToolPlugin | null;
|
|
15
15
|
|
|
16
16
|
return {
|