@olenbetong/synergi-react 2.8.0 → 2.9.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/styles/styles.css.map +1 -1
- package/es/components/ImageEditor/ImageEditor.d.ts +12 -0
- package/es/components/ImageEditor/ImageEditor.js +27 -6
- package/es/components/ImageEditor/index.d.ts +2 -0
- package/es/components/ImageEditor/index.js +2 -0
- package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +1 -1
- package/es/components/ImageEditor/useImageHistory.d.ts +6 -1
- package/es/components/ImageEditor/useImageHistory.js +21 -23
- package/es/elements/ElementDamage/DamageFormButtons.d.ts +2 -3
- package/es/elements/ElementDamage/DamageFormButtons.js +1 -1
- package/es/elements/ElementDamage/TransportElementSelect.d.ts +1 -2
- package/es/elements/index.d.ts +5 -0
- package/es/elements/index.js +5 -0
- package/package.json +1 -1
- package/src/components/ImageEditor/ImageEditor.tsx +40 -5
- package/src/components/ImageEditor/useImageHistory.ts +27 -19
- package/src/components/LinkedCardList/index.scss +4 -2
- package/src/components/ProgressBar/index.scss +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../../src/components/Checkbox/index.scss","../../src/components/ColorCard/index.css","../../src/components/DateNavigator/index.css","../../src/components/LinkedCardList/index.scss","../../src/components/PageBanner/index.scss","../../src/styles/_variables.scss","../../src/components/ProgressBar/index.scss","../../src/components/Sidebar/index.scss","../../src/components/Spinner/index.css","../../src/components/SplitContainer/index.scss","../../src/components/ValueToggleGroup/index.css"],"names":[],"mappings":"CAAA,iBACC,oBACA,qDACA,8DACA,wCAEA,qBACA,0BACA,gBAEA,8CACC,wBAGD,6BACC,qCACA,kCAIF,gBACC,kBAEA,2BACA,iCAEA,gBAEA,0CACA,0BACA,yBAEA,sBACC,iCAIF,kBACC,kBACA,gBACA,gBAEA,wBACC,aAIF,iBACC,WACA,qBACA,sCACA,SACA,UACA,oBACA,kBACA,QACA,iCACA,qBACA,yCAGD,kBACC,mBACA,qBACA,WACA,gBACA,kBACA,mBACA,UAEA,wBACC,aAIF,kBACC,aACA,UACA,mBAEA,iBAGD,8CACC,2BAGD,2EACC,kCAGD,2EACC,oCAGD,6EACC,yCACA,uBACA,UAGD,6CACC,mBAGD,kBACC,IACC,gCAGD,IACC,kCAGD,IACC,kCAGD,IACC,kCAGD,KACC,+BC3HF,kBACC,yBACA,uBACA,mBACA,2BAEA,aACA,oBACA,iBACA,gBACA,qBACA,WACC,6DAED,WACA,qKAOA,YACC,6LAaD,eACA,iCACA,eAEA,sBACC,sCAED,sBACC,oCAED,sBACC,qCAED,sBACC,oCAED,sBACC,qCAGD,gBAEC,yBACA,WACC,8DAED,sBAGD,qCAjED,kBAkEE,kBAIF,oBACC,aACA,cACA,sBACA,8BACA,cACA,gCACA,gBACA,uBAEA,cACC,oCAGD,oBACC,cACA,+BACA,oCAEA,qCACC,gBAKH,yBACC,WAGD,yBACC,cACA,gBACA,yBAGD,oBACC,mBACC,oBAGD,qEAEC,kBACA,gBAGD,+CACC,aAGD,qCAfD,oBAgBE,gBAIF,sBACC,aACA,sBACA,SAGD,kBACC,kBACA,wBAEA,aACA,uBACA,UAGD,0BACC,cACA,WAEA,kBACA,UAEA,WACA,YACA,iBACA,8CACA,kBACA,sBACA,UAGD,0CACC,WACA,kBACA,QACA,sBACA,2CACA,4BACA,UCnKD,MACC,gCAGD,sBACC,qBAEA,IACC,aACA,kBACA,UAIF,sBACC,oCACA,8CACA,aACA,eACA,aAEA,gBACC,6CACA,oBAIF,uBACC,aACA,mBACA,wCACA,uBAEA,sCAEA,eACA,kBAEA,uBACC,yBACA,kDAGD,WACC,mBACA,uBAIF,2BACC,4BACA,QAGD,4BACC,2BACA,QAGD,sBACC,aACA,cACA,sBACA,uBACA,QAEA,sCAEA,kBAGD,uBACC,QACA,eACA,sCACA,aACA,mBACA,uBACA,kBACA,iCACA,yBACA,eAEA,iBAEA,2BAEA,uBACC,kDAGD,gBACC,6CACA,oBCxFF,MACC,oCACA,mCAGD,
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../src/components/Checkbox/index.scss","../../src/components/ColorCard/index.css","../../src/components/DateNavigator/index.css","../../src/components/LinkedCardList/index.scss","../../src/components/PageBanner/index.scss","../../src/styles/_variables.scss","../../src/components/ProgressBar/index.scss","../../src/components/Sidebar/index.scss","../../src/components/Spinner/index.css","../../src/components/SplitContainer/index.scss","../../src/components/ValueToggleGroup/index.css"],"names":[],"mappings":"CAAA,iBACC,oBACA,qDACA,8DACA,wCAEA,qBACA,0BACA,gBAEA,8CACC,wBAGD,6BACC,qCACA,kCAIF,gBACC,kBAEA,2BACA,iCAEA,gBAEA,0CACA,0BACA,yBAEA,sBACC,iCAIF,kBACC,kBACA,gBACA,gBAEA,wBACC,aAIF,iBACC,WACA,qBACA,sCACA,SACA,UACA,oBACA,kBACA,QACA,iCACA,qBACA,yCAGD,kBACC,mBACA,qBACA,WACA,gBACA,kBACA,mBACA,UAEA,wBACC,aAIF,kBACC,aACA,UACA,mBAEA,iBAGD,8CACC,2BAGD,2EACC,kCAGD,2EACC,oCAGD,6EACC,yCACA,uBACA,UAGD,6CACC,mBAGD,kBACC,IACC,gCAGD,IACC,kCAGD,IACC,kCAGD,IACC,kCAGD,KACC,+BC3HF,kBACC,yBACA,uBACA,mBACA,2BAEA,aACA,oBACA,iBACA,gBACA,qBACA,WACC,6DAED,WACA,qKAOA,YACC,6LAaD,eACA,iCACA,eAEA,sBACC,sCAED,sBACC,oCAED,sBACC,qCAED,sBACC,oCAED,sBACC,qCAGD,gBAEC,yBACA,WACC,8DAED,sBAGD,qCAjED,kBAkEE,kBAIF,oBACC,aACA,cACA,sBACA,8BACA,cACA,gCACA,gBACA,uBAEA,cACC,oCAGD,oBACC,cACA,+BACA,oCAEA,qCACC,gBAKH,yBACC,WAGD,yBACC,cACA,gBACA,yBAGD,oBACC,mBACC,oBAGD,qEAEC,kBACA,gBAGD,+CACC,aAGD,qCAfD,oBAgBE,gBAIF,sBACC,aACA,sBACA,SAGD,kBACC,kBACA,wBAEA,aACA,uBACA,UAGD,0BACC,cACA,WAEA,kBACA,UAEA,WACA,YACA,iBACA,8CACA,kBACA,sBACA,UAGD,0CACC,WACA,kBACA,QACA,sBACA,2CACA,4BACA,UCnKD,MACC,gCAGD,sBACC,qBAEA,IACC,aACA,kBACA,UAIF,sBACC,oCACA,8CACA,aACA,eACA,aAEA,gBACC,6CACA,oBAIF,uBACC,aACA,mBACA,wCACA,uBAEA,sCAEA,eACA,kBAEA,uBACC,yBACA,kDAGD,WACC,mBACA,uBAIF,2BACC,4BACA,QAGD,4BACC,2BACA,QAGD,sBACC,aACA,cACA,sBACA,uBACA,QAEA,sCAEA,kBAGD,uBACC,QACA,eACA,sCACA,aACA,mBACA,uBACA,kBACA,iCACA,yBACA,eAEA,iBAEA,2BAEA,uBACC,kDAGD,gBACC,6CACA,oBCxFF,MACC,oCACA,mCAGD,mBACC,qBACA,cACA,eAGD,mBACC,aACA,mBACA,mBAGD,yBACC,aACA,gBACA,cACA,kBAGD,0BACC,cACA,0BAGD,mBACC,aACA,mBACA,cACA,gBACA,kBAGD,qBACC,gBAEA,oCACA,oBACA,OA7Ca,KA8Cb,MA9Ca,KAgDb,kBACA,OACA,QAEA,mHAMD,mBACC,cACA,gBACA,iBACA,qCACA,sBACA,cACA,eACA,cACA,kBAGD,2BACC,uCACA,4BACA,oCACA,YACA,uDACA,WACA,UACA,kBACA,kBACA,QACA,UAGD,yBACC,6CACA,cACA,wBAGD,iCACC,+CC3FD,mBACC,iBCHe,iBDIf,mCACA,sCACA,WAEA,qBACC,uBAIF,oBACC,aACA,mBACA,sBAEA,qCALD,oBAME,uBACA,oBAIF,yBACC,eAEA,qCAHD,yBAIE,gBAIF,0BACC,mBACA,sBACA,qBACA,YACA,iBACA,8BACA,WAEA,qCATD,0BAUE,kBACA,SACA,kBACA,wBACA,kBACA,aACA,aAGD,qCAnBD,0BAoBE,aACA,aAIF,0BACC,mBACA,gBACA,eAEA,qCALD,0BAME,cAGD,qCATD,0BAUE,gBAKD,6BACC,wBACA,gBACA,MACA,aAIF,2BACC,gBACA,qBACA,mBAGD,kBACC,yCACA,qBACA,iBACA,eACA,mBACA,kBACA,0BAEA,yBACC,kBE9FF,oBACC,aACA,WACA,gBACA,wBACA,yBACA,YACA,kBACA,0CACA,cACA,kBAEA,0CACC,yBACA,kBACA,0CAGD,4CACC,iBACC,2PAUD,iBACC,mRAUD,gBACC,8BAGD,kBACA,kBACA,8BAGD,kDACC,sBACA,WAEA,mBACA,WAEA,kBACA,UACA,QACA,UAGD,uCACC,iBACC,2PAUD,iBACC,0QAUD,gBACC,8BAGD,kBACA,8BC7FF,gBACC,eACA,SACA,OACA,MACA,UAEA,sBAEA,4BACA,kCACA,sBAEA,yBACC,WACA,QACA,2BAhBF,gBAmBC,gBAEA,wBACC,wBAGD,iCACC,uCAEA,0CACC,wCAKH,mBACC,eACA,SACA,OACA,QACA,MACA,UAEA,UACA,kBAEA,WACC,6CAED,gCAEA,2BACC,UACA,mBCpDF,uCAEC,qBAGD,gBACC,qBAGD,oBACC,aACA,mBACA,uBAEA,aACA,YAGD,mBACC,qBACA,oCACA,kBACA,iCAGD,kBACC,mDACA,gBACA,kBACA,0BACA,kBACA,UACA,yBAEA,eACC,kDACA,iCAGD,eACC,sDACA,iCAGD,eACC,sDACA,kCAGD,eACC,0DACA,iCAIF,0BACC,KACC,mBAGD,GACC,oBAIF,8BACC,KACC,0BAGD,GACC,yDCpEF,IACC,gBAGD,uBACC,aACA,sBACA,YACA,WAEA,kCACC,mBAIF,wBACC,gBAGD,0BACC,eACA,+BACA,gBACA,iBAEA,aACA,mBACA,uBAEA,gCACC,gCAGD,4DACC,iBACA,yBAIF,iCACC,oBC3CD,qBACC,aACA,mBACA,SACA,kBAGD,oBACC,eACA,cACA,kBACA,yBACA,WACC,mCAED,kBAGD,oBACC,eACA,gCACA,kBAEA,aACA,WACA,eAEA,WACC,sBACA,mBAEA,uBACC,WAEA,sBACC,WACA,oBAKH,eACC,6BAIF,2BACC,kBACA,UACA,WACA,UACA,YACA,gBACA,sBACA,SAGD,oEACC,eACA,gBAGD,uDACC,8BACA,iCACA,YACA,eAGD,wDACC,qBAGD,qEACC,+BACA,qCAGD,6DACC","file":"styles.css"}
|
|
@@ -3,6 +3,18 @@ import type { Plugin, ViewPlugin } from "./types.js";
|
|
|
3
3
|
export type ImageEditorRef = {
|
|
4
4
|
/** Returns the current edited blob, or null if no edits have been applied since the last source image. */
|
|
5
5
|
getCurrentBlob: () => Blob | null;
|
|
6
|
+
/**
|
|
7
|
+
* Runs a registered action plugin (e.g. `"rotate-cw"`) against the current image.
|
|
8
|
+
* Use this instead of calling `plugin.execute()` directly so external toolbars and
|
|
9
|
+
* keyboard shortcuts share the editor's image state and undo history.
|
|
10
|
+
* Resolves once the resulting image has been applied.
|
|
11
|
+
*/
|
|
12
|
+
executeAction: (pluginId: string) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves once every queued action has been applied. Await this before `getCurrentBlob()`
|
|
15
|
+
* to be sure an action started moments earlier is included.
|
|
16
|
+
*/
|
|
17
|
+
whenIdle: () => Promise<void>;
|
|
6
18
|
};
|
|
7
19
|
interface Props {
|
|
8
20
|
imageUrl: string;
|
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Button, Spinner, Tooltip } from "@digdir/designsystemet-react";
|
|
3
3
|
import { ArrowCirclepathIcon, ArrowLeftIcon, ArrowRedoIcon, ArrowUndoIcon, CheckmarkIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
|
-
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
|
5
|
+
import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
6
6
|
import "./ImageEditor.css";
|
|
7
7
|
import { ResponsiveButton } from "./ResponsiveButton.js";
|
|
8
8
|
import { useActiveTool } from "./useActiveTool.js";
|
|
@@ -21,15 +21,36 @@ export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm
|
|
|
21
21
|
let [busy, setBusy] = useState(false);
|
|
22
22
|
let disabled = busy || history.replaying;
|
|
23
23
|
let isSmall = useIsSmall();
|
|
24
|
+
// Keeps async/imperative callers working against the latest history state instead of
|
|
25
|
+
// the snapshot captured when their closure was created.
|
|
26
|
+
let historyRef = useRef(history);
|
|
27
|
+
historyRef.current = history;
|
|
28
|
+
// Serialises every action (toolbar clicks and imperative calls alike) so rapid
|
|
29
|
+
// invocations each build on the previous result instead of racing on a stale image.
|
|
30
|
+
let actionQueueRef = useRef(Promise.resolve());
|
|
24
31
|
useImperativeHandle(ref, () => ({
|
|
25
|
-
getCurrentBlob: () =>
|
|
32
|
+
getCurrentBlob: () => historyRef.current.getCurrentBlob(),
|
|
33
|
+
whenIdle: () => actionQueueRef.current,
|
|
34
|
+
executeAction: (pluginId) => {
|
|
35
|
+
let plugin = plugins.find((p) => p.type === "action" && p.id === pluginId);
|
|
36
|
+
if (!plugin) {
|
|
37
|
+
console.warn(`[ImageEditor] No action plugin registered with id "${pluginId}"`);
|
|
38
|
+
return Promise.resolve();
|
|
39
|
+
}
|
|
40
|
+
return enqueueAction(plugin);
|
|
41
|
+
},
|
|
26
42
|
}));
|
|
43
|
+
function enqueueAction(plugin) {
|
|
44
|
+
let next = actionQueueRef.current.then(() => executeAction(plugin));
|
|
45
|
+
actionQueueRef.current = next.catch(() => { });
|
|
46
|
+
return next;
|
|
47
|
+
}
|
|
27
48
|
async function executeAction(plugin) {
|
|
28
49
|
setBusy(true);
|
|
29
50
|
try {
|
|
30
|
-
let blob = await plugin.execute(
|
|
51
|
+
let blob = await plugin.execute(historyRef.current.getCurrentImageUrl());
|
|
31
52
|
let actions = [{ type: plugin.id, params: {} }];
|
|
32
|
-
|
|
53
|
+
historyRef.current.applyActions(blob, actions);
|
|
33
54
|
}
|
|
34
55
|
finally {
|
|
35
56
|
setBusy(false);
|
|
@@ -52,7 +73,7 @@ export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm
|
|
|
52
73
|
}
|
|
53
74
|
let CanvasWrapper = viewPlugin?.CanvasWrapper;
|
|
54
75
|
let TopBarControls = viewPlugin?.TopBarControls;
|
|
55
|
-
let inner = (_jsxs("div", { className: "image-editor", "data-color-scheme": "dark", children: [_jsxs("div", { className: "image-editor__topbar", children: [_jsxs("div", { className: "image-editor__toolbar-group", children: [onCancel && (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ArrowLeftIcon, { "aria-hidden": true }), label: getLocalizedString("Back"), onClick: onCancel, isSmall: isSmall }), _jsx("span", { className: "image-editor__topbar-divider", "aria-hidden": true })] })), _jsx(ResponsiveButton, { icon: _jsx(ArrowUndoIcon, { "aria-hidden": true }), label: getLocalizedString("Undo"), onClick: history.undo, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowRedoIcon, { "aria-hidden": true }), label: getLocalizedString("Redo"), onClick: history.redo, disabled: disabled || !history.canRedo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowCirclepathIcon, { "aria-hidden": true }), label: getLocalizedString("Reset"), onClick: history.reset, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall })] }), TopBarControls && (_jsx("div", { className: "image-editor__toolbar-group", children: _jsx(TopBarControls, { disabled: disabled, isSmall: isSmall }) }))] }), _jsxs("div", { className: "image-editor__canvas", children: [CanvasWrapper ? (_jsx(CanvasWrapper, { panEnabled: !activePlugin, children: activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })) })) : activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })), !activePlugin && onConfirm && (_jsxs(Button, { className: "image-editor__done", variant: "primary", icon: isSmall, "aria-label": isSmall ? getLocalizedString("Done") : undefined, onClick: confirm, disabled: disabled, children: [_jsx(CheckmarkIcon, { "aria-hidden": true }), !isSmall && getLocalizedString("Done")] })), history.replaying && (_jsx("div", { className: "image-editor__replay-overlay", children: _jsx(Spinner, { "aria-label": getLocalizedString("Loading") }) }))] }), _jsx("div", { className: "image-editor__toolbar", children: activePlugin ? (_jsx(ActiveToolbar, { plugin: activePlugin })) : (_jsx("div", { className: "image-editor__toolbar-group", children: plugins.map((p) => p.type === "tool" ? (_jsx(ToolButton, { plugin: p, busy: disabled, onActivate: () => activateTool(p.id), isSmall: isSmall }, p.id)) : (_jsx(ActionButton, { plugin: p, busy: disabled, onExecute: () =>
|
|
76
|
+
let inner = (_jsxs("div", { className: "image-editor", "data-color-scheme": "dark", children: [_jsxs("div", { className: "image-editor__topbar", children: [_jsxs("div", { className: "image-editor__toolbar-group", children: [onCancel && (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ArrowLeftIcon, { "aria-hidden": true }), label: getLocalizedString("Back"), onClick: onCancel, isSmall: isSmall }), _jsx("span", { className: "image-editor__topbar-divider", "aria-hidden": true })] })), _jsx(ResponsiveButton, { icon: _jsx(ArrowUndoIcon, { "aria-hidden": true }), label: getLocalizedString("Undo"), onClick: history.undo, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowRedoIcon, { "aria-hidden": true }), label: getLocalizedString("Redo"), onClick: history.redo, disabled: disabled || !history.canRedo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowCirclepathIcon, { "aria-hidden": true }), label: getLocalizedString("Reset"), onClick: history.reset, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall })] }), TopBarControls && (_jsx("div", { className: "image-editor__toolbar-group", children: _jsx(TopBarControls, { disabled: disabled, isSmall: isSmall }) }))] }), _jsxs("div", { className: "image-editor__canvas", children: [CanvasWrapper ? (_jsx(CanvasWrapper, { panEnabled: !activePlugin, children: activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })) })) : activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })), !activePlugin && onConfirm && (_jsxs(Button, { className: "image-editor__done", variant: "primary", icon: isSmall, "aria-label": isSmall ? getLocalizedString("Done") : undefined, onClick: confirm, disabled: disabled, children: [_jsx(CheckmarkIcon, { "aria-hidden": true }), !isSmall && getLocalizedString("Done")] })), history.replaying && (_jsx("div", { className: "image-editor__replay-overlay", children: _jsx(Spinner, { "aria-label": getLocalizedString("Loading") }) }))] }), _jsx("div", { className: "image-editor__toolbar", children: activePlugin ? (_jsx(ActiveToolbar, { plugin: activePlugin })) : (_jsx("div", { className: "image-editor__toolbar-group", children: plugins.map((p) => p.type === "tool" ? (_jsx(ToolButton, { plugin: p, busy: disabled, onActivate: () => activateTool(p.id), isSmall: isSmall }, p.id)) : (_jsx(ActionButton, { plugin: p, busy: disabled, onExecute: () => enqueueAction(p), isSmall: isSmall }, p.id))) })) })] }));
|
|
56
77
|
// Wrap with the active tool's provider so Overlay and Toolbar share context.
|
|
57
78
|
if (activePlugin) {
|
|
58
79
|
let ActiveProvider = activePlugin.Provider;
|
|
@@ -71,7 +92,7 @@ function ToolButton({ plugin, busy, onActivate, isSmall, }) {
|
|
|
71
92
|
if (isSmall) {
|
|
72
93
|
return (_jsx(Tooltip, { content: label, children: _jsx(Button, { icon: true, variant: "tertiary", "data-size": "sm", "aria-label": label, onClick: onActivate, disabled: busy, children: _jsx(Icon, {}) }) }));
|
|
73
94
|
}
|
|
74
|
-
return (_jsxs(Button, { variant: "
|
|
95
|
+
return (_jsxs(Button, { variant: "tertiary", "data-size": "sm", onClick: onActivate, disabled: busy, children: [_jsx(Icon, {}), label] }));
|
|
75
96
|
}
|
|
76
97
|
function ActionButton({ plugin, busy, onExecute, isSmall, }) {
|
|
77
98
|
let Icon = plugin.Icon;
|
|
@@ -2,5 +2,7 @@ export { defaultPlugins, defaultViewPlugin } from "./defaultPlugins.js";
|
|
|
2
2
|
export type { ImageEditorRef } from "./ImageEditor.js";
|
|
3
3
|
export { ImageEditor } from "./ImageEditor.js";
|
|
4
4
|
export { cropPlugin } from "./plugins/cropPlugin/index.js";
|
|
5
|
+
export { redactPlugin } from "./plugins/redactPlugin/index.js";
|
|
6
|
+
export { zoomPlugin } from "./plugins/zoomPlugin/index.js";
|
|
5
7
|
export { rotateCcwPlugin, rotateCwPlugin } from "./plugins/rotatePlugin.js";
|
|
6
8
|
export type { ActionPlugin, EditAction, Plugin, ToolPlugin, ViewPlugin } from "./types.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { defaultPlugins, defaultViewPlugin } from "./defaultPlugins.js";
|
|
2
2
|
export { ImageEditor } from "./ImageEditor.js";
|
|
3
3
|
export { cropPlugin } from "./plugins/cropPlugin/index.js";
|
|
4
|
+
export { redactPlugin } from "./plugins/redactPlugin/index.js";
|
|
5
|
+
export { zoomPlugin } from "./plugins/zoomPlugin/index.js";
|
|
4
6
|
export { rotateCcwPlugin, rotateCwPlugin } from "./plugins/rotatePlugin.js";
|
|
@@ -5,5 +5,5 @@ import { ResponsiveButton } from "../../ResponsiveButton.js";
|
|
|
5
5
|
import { useZoom } from "./ZoomContext.js";
|
|
6
6
|
export function ZoomControls({ disabled, isSmall = false }) {
|
|
7
7
|
let { zoom, zoomIn, zoomOut, resetZoom, canZoomIn, canZoomOut, isZoomed } = useZoom();
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ZoomMinusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom out"), onClick: zoomOut, disabled: disabled || !canZoomOut, isSmall: isSmall }), _jsxs("span", { className: "image-editor__zoom-level", children: [Math.round(zoom * 100), "%"] }), _jsx(ResponsiveButton, { icon: _jsx(ZoomPlusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom in"), onClick: zoomIn, disabled: disabled || !canZoomIn, isSmall: isSmall }),
|
|
8
|
+
return (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ZoomMinusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom out"), onClick: zoomOut, disabled: disabled || !canZoomOut, isSmall: isSmall }), _jsxs("span", { className: "image-editor__zoom-level", children: [Math.round(zoom * 100), "%"] }), _jsx(ResponsiveButton, { icon: _jsx(ZoomPlusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom in"), onClick: zoomIn, disabled: disabled || !canZoomIn, isSmall: isSmall }), _jsx(ResponsiveButton, { disabled: !isZoomed, icon: _jsx(ShrinkIcon, { "aria-hidden": true }), label: getLocalizedString("Reset zoom"), onClick: resetZoom, isSmall: isSmall })] }));
|
|
9
9
|
}
|
|
@@ -2,11 +2,16 @@ import type { ActionRegistry, EditAction } from "./types.js";
|
|
|
2
2
|
export interface UseImageHistoryResult {
|
|
3
3
|
currentImageUrl: string;
|
|
4
4
|
currentBlob: Blob | null;
|
|
5
|
+
/** Synchronous read of the current image URL — valid immediately after `applyActions`. */
|
|
6
|
+
getCurrentImageUrl: () => string;
|
|
7
|
+
/** Synchronous read of the current blob — valid immediately after `applyActions`. */
|
|
8
|
+
getCurrentBlob: () => Blob | null;
|
|
5
9
|
canUndo: boolean;
|
|
6
10
|
canRedo: boolean;
|
|
7
11
|
/** True while an async replay (undo/redo) is in progress. */
|
|
8
12
|
replaying: boolean;
|
|
9
|
-
|
|
13
|
+
/** Applies a new blob to the current state and records it in history. Returns the new object URL. */
|
|
14
|
+
applyActions: (blob: Blob, actions: EditAction[]) => string;
|
|
10
15
|
undo: () => void;
|
|
11
16
|
redo: () => void;
|
|
12
17
|
reset: () => void;
|
|
@@ -12,20 +12,24 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
12
12
|
let [replaying, setReplaying] = useState(false);
|
|
13
13
|
let historyRef = useRef(history);
|
|
14
14
|
historyRef.current = history;
|
|
15
|
+
// Written synchronously by `replaceCurrent` so imperative callers can read the current
|
|
16
|
+
// image/blob before React has committed the corresponding render.
|
|
15
17
|
let currentRef = useRef(current);
|
|
16
|
-
currentRef.current = current;
|
|
17
18
|
let isReplaying = useRef(false);
|
|
18
19
|
let replayAbort = useRef(null);
|
|
20
|
+
function replaceCurrent(next) {
|
|
21
|
+
let prev = currentRef.current;
|
|
22
|
+
if (prev.generated && prev.url !== next.url)
|
|
23
|
+
URL.revokeObjectURL(prev.url);
|
|
24
|
+
currentRef.current = next;
|
|
25
|
+
setCurrent(next);
|
|
26
|
+
}
|
|
19
27
|
// When source changes (e.g. component remount with new image), reset fully.
|
|
20
28
|
useEffect(() => {
|
|
21
29
|
replayAbort.current?.abort();
|
|
22
30
|
isReplaying.current = false;
|
|
23
31
|
setReplaying(false);
|
|
24
|
-
|
|
25
|
-
if (prev.generated)
|
|
26
|
-
URL.revokeObjectURL(prev.url);
|
|
27
|
-
return { url: sourceUrl, blob: null, generated: false };
|
|
28
|
-
});
|
|
32
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
29
33
|
setHistory({ past: [], future: [] });
|
|
30
34
|
}, [sourceUrl]);
|
|
31
35
|
useEffect(() => {
|
|
@@ -41,12 +45,9 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
41
45
|
isReplaying.current = false;
|
|
42
46
|
setReplaying(false);
|
|
43
47
|
let newUrl = URL.createObjectURL(blob);
|
|
44
|
-
|
|
45
|
-
if (prev.generated)
|
|
46
|
-
URL.revokeObjectURL(prev.url);
|
|
47
|
-
return { url: newUrl, blob, generated: true };
|
|
48
|
-
});
|
|
48
|
+
replaceCurrent({ url: newUrl, blob, generated: true });
|
|
49
49
|
setHistory((prev) => ({ past: [...prev.past, actions], future: [] }));
|
|
50
|
+
return newUrl;
|
|
50
51
|
}
|
|
51
52
|
async function doReplay(newPast, newFuture) {
|
|
52
53
|
replayAbort.current?.abort();
|
|
@@ -58,13 +59,12 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
58
59
|
let result = await replayAll(sourceUrl, newPast, registry, abort.signal);
|
|
59
60
|
if (abort.signal.aborted)
|
|
60
61
|
return;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
62
|
+
if (result) {
|
|
63
|
+
replaceCurrent({ url: result.url, blob: result.blob, generated: true });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
67
|
+
}
|
|
68
68
|
setHistory({ past: newPast, future: newFuture });
|
|
69
69
|
}
|
|
70
70
|
finally {
|
|
@@ -94,16 +94,14 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
94
94
|
replayAbort.current?.abort();
|
|
95
95
|
isReplaying.current = false;
|
|
96
96
|
setReplaying(false);
|
|
97
|
-
|
|
98
|
-
if (prev.generated)
|
|
99
|
-
URL.revokeObjectURL(prev.url);
|
|
100
|
-
return { url: sourceUrl, blob: null, generated: false };
|
|
101
|
-
});
|
|
97
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
102
98
|
setHistory({ past: [], future: [] });
|
|
103
99
|
}
|
|
104
100
|
return {
|
|
105
101
|
currentImageUrl: current.url,
|
|
106
102
|
currentBlob: current.blob,
|
|
103
|
+
getCurrentImageUrl: () => currentRef.current.url,
|
|
104
|
+
getCurrentBlob: () => currentRef.current.blob,
|
|
107
105
|
canUndo: history.past.length > 0,
|
|
108
106
|
canRedo: history.future.length > 0,
|
|
109
107
|
replaying,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
type DamageFormButtonsProps = {
|
|
1
|
+
export type DamageFormButtonsProps = {
|
|
2
2
|
isEdit: boolean;
|
|
3
3
|
loading: boolean;
|
|
4
4
|
uploadingFile: boolean;
|
|
5
5
|
handleDelete: () => void;
|
|
6
6
|
handleCancel: () => void;
|
|
7
7
|
};
|
|
8
|
-
export declare function
|
|
9
|
-
export {};
|
|
8
|
+
export declare function DamageFormButtons({ isEdit, loading, uploadingFile, handleDelete, handleCancel, }: DamageFormButtonsProps): import("react").JSX.Element;
|
|
@@ -2,6 +2,6 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import Add from "@mui/icons-material/Add";
|
|
3
3
|
import { Button } from "@mui/material";
|
|
4
4
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
|
-
export function
|
|
5
|
+
export function DamageFormButtons({ isEdit, loading, uploadingFile, handleDelete, handleCancel, }) {
|
|
6
6
|
return (_jsxs(_Fragment, { children: [isEdit && _jsx(Button, { onClick: handleDelete, children: getLocalizedString("Delete") }), _jsx(Button, { onClick: handleCancel, children: getLocalizedString("Cancel") }), _jsx(Button, { loading: loading || uploadingFile, loadingPosition: "start", startIcon: _jsx(Add, {}), type: "submit", variant: "contained", children: isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage") })] }));
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { TransportElementsRecord } from "../data/dsTransportElements.js";
|
|
2
|
-
type TransportElementSelectProps = {
|
|
2
|
+
export type TransportElementSelectProps = {
|
|
3
3
|
elements: TransportElementsRecord[];
|
|
4
4
|
onSelect: (element: TransportElementsRecord) => void;
|
|
5
5
|
};
|
|
6
6
|
export declare function TransportElementSelect({ elements, onSelect }: TransportElementSelectProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
package/es/elements/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from "./data/index.js";
|
|
2
|
+
export * from "./ElementDamage/DamageFormButtons.js";
|
|
2
3
|
export * from "./ElementDamage/DescriptionInput.js";
|
|
3
4
|
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
4
5
|
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
5
6
|
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
6
7
|
export * from "./ElementDamage/RegisterFix.js";
|
|
7
8
|
export * from "./ElementDamage/SubmitButtons.js";
|
|
9
|
+
export * from "./ElementDamage/TransportElementSelect.js";
|
|
8
10
|
export * from "./ElementLookup.js";
|
|
11
|
+
export * from "./ElementLookupDialog/BarcodeScanner/index.js";
|
|
12
|
+
export * from "./ElementLookupDialog/HIDScanner/index.js";
|
|
9
13
|
export * from "./ElementLookupDialog/index.js";
|
|
14
|
+
export * from "./ElementLookupDialog/Manual/ManualForm.js";
|
|
10
15
|
export * from "./ProjectSelect.js";
|
package/es/elements/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from "./data/index.js";
|
|
2
|
+
export * from "./ElementDamage/DamageFormButtons.js";
|
|
2
3
|
export * from "./ElementDamage/DescriptionInput.js";
|
|
3
4
|
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
4
5
|
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
5
6
|
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
6
7
|
export * from "./ElementDamage/RegisterFix.js";
|
|
7
8
|
export * from "./ElementDamage/SubmitButtons.js";
|
|
9
|
+
export * from "./ElementDamage/TransportElementSelect.js";
|
|
8
10
|
export * from "./ElementLookup.js";
|
|
11
|
+
export * from "./ElementLookupDialog/BarcodeScanner/index.js";
|
|
12
|
+
export * from "./ElementLookupDialog/HIDScanner/index.js";
|
|
9
13
|
export * from "./ElementLookupDialog/index.js";
|
|
14
|
+
export * from "./ElementLookupDialog/Manual/ManualForm.js";
|
|
10
15
|
export * from "./ProjectSelect.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button, Spinner, Tooltip } from "@digdir/designsystemet-react";
|
|
2
2
|
import { ArrowCirclepathIcon, ArrowLeftIcon, ArrowRedoIcon, ArrowUndoIcon, CheckmarkIcon } from "@navikt/aksel-icons";
|
|
3
3
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
|
-
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
|
4
|
+
import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
5
5
|
|
|
6
6
|
import "./ImageEditor.css";
|
|
7
7
|
import { ResponsiveButton } from "./ResponsiveButton.js";
|
|
@@ -13,6 +13,18 @@ import { useIsSmall } from "./useIsSmall.js";
|
|
|
13
13
|
export type ImageEditorRef = {
|
|
14
14
|
/** Returns the current edited blob, or null if no edits have been applied since the last source image. */
|
|
15
15
|
getCurrentBlob: () => Blob | null;
|
|
16
|
+
/**
|
|
17
|
+
* Runs a registered action plugin (e.g. `"rotate-cw"`) against the current image.
|
|
18
|
+
* Use this instead of calling `plugin.execute()` directly so external toolbars and
|
|
19
|
+
* keyboard shortcuts share the editor's image state and undo history.
|
|
20
|
+
* Resolves once the resulting image has been applied.
|
|
21
|
+
*/
|
|
22
|
+
executeAction: (pluginId: string) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves once every queued action has been applied. Await this before `getCurrentBlob()`
|
|
25
|
+
* to be sure an action started moments earlier is included.
|
|
26
|
+
*/
|
|
27
|
+
whenIdle: () => Promise<void>;
|
|
16
28
|
};
|
|
17
29
|
|
|
18
30
|
interface Props {
|
|
@@ -43,16 +55,39 @@ export const ImageEditor = forwardRef<ImageEditorRef, Props>(function ImageEdito
|
|
|
43
55
|
let disabled = busy || history.replaying;
|
|
44
56
|
let isSmall = useIsSmall();
|
|
45
57
|
|
|
58
|
+
// Keeps async/imperative callers working against the latest history state instead of
|
|
59
|
+
// the snapshot captured when their closure was created.
|
|
60
|
+
let historyRef = useRef(history);
|
|
61
|
+
historyRef.current = history;
|
|
62
|
+
// Serialises every action (toolbar clicks and imperative calls alike) so rapid
|
|
63
|
+
// invocations each build on the previous result instead of racing on a stale image.
|
|
64
|
+
let actionQueueRef = useRef<Promise<void>>(Promise.resolve());
|
|
65
|
+
|
|
46
66
|
useImperativeHandle(ref, () => ({
|
|
47
|
-
getCurrentBlob: () =>
|
|
67
|
+
getCurrentBlob: () => historyRef.current.getCurrentBlob(),
|
|
68
|
+
whenIdle: () => actionQueueRef.current,
|
|
69
|
+
executeAction: (pluginId: string) => {
|
|
70
|
+
let plugin = plugins.find((p): p is ActionPlugin => p.type === "action" && p.id === pluginId);
|
|
71
|
+
if (!plugin) {
|
|
72
|
+
console.warn(`[ImageEditor] No action plugin registered with id "${pluginId}"`);
|
|
73
|
+
return Promise.resolve();
|
|
74
|
+
}
|
|
75
|
+
return enqueueAction(plugin);
|
|
76
|
+
},
|
|
48
77
|
}));
|
|
49
78
|
|
|
79
|
+
function enqueueAction(plugin: ActionPlugin) {
|
|
80
|
+
let next = actionQueueRef.current.then(() => executeAction(plugin));
|
|
81
|
+
actionQueueRef.current = next.catch(() => {});
|
|
82
|
+
return next;
|
|
83
|
+
}
|
|
84
|
+
|
|
50
85
|
async function executeAction(plugin: ActionPlugin) {
|
|
51
86
|
setBusy(true);
|
|
52
87
|
try {
|
|
53
|
-
let blob = await plugin.execute(
|
|
88
|
+
let blob = await plugin.execute(historyRef.current.getCurrentImageUrl());
|
|
54
89
|
let actions: EditAction[] = [{ type: plugin.id, params: {} }];
|
|
55
|
-
|
|
90
|
+
historyRef.current.applyActions(blob, actions);
|
|
56
91
|
} finally {
|
|
57
92
|
setBusy(false);
|
|
58
93
|
}
|
|
@@ -186,7 +221,7 @@ export const ImageEditor = forwardRef<ImageEditorRef, Props>(function ImageEdito
|
|
|
186
221
|
key={p.id}
|
|
187
222
|
plugin={p}
|
|
188
223
|
busy={disabled}
|
|
189
|
-
onExecute={() =>
|
|
224
|
+
onExecute={() => enqueueAction(p)}
|
|
190
225
|
isSmall={isSmall}
|
|
191
226
|
/>
|
|
192
227
|
),
|
|
@@ -17,11 +17,16 @@ interface CurrentState {
|
|
|
17
17
|
export interface UseImageHistoryResult {
|
|
18
18
|
currentImageUrl: string;
|
|
19
19
|
currentBlob: Blob | null;
|
|
20
|
+
/** Synchronous read of the current image URL — valid immediately after `applyActions`. */
|
|
21
|
+
getCurrentImageUrl: () => string;
|
|
22
|
+
/** Synchronous read of the current blob — valid immediately after `applyActions`. */
|
|
23
|
+
getCurrentBlob: () => Blob | null;
|
|
20
24
|
canUndo: boolean;
|
|
21
25
|
canRedo: boolean;
|
|
22
26
|
/** True while an async replay (undo/redo) is in progress. */
|
|
23
27
|
replaying: boolean;
|
|
24
|
-
|
|
28
|
+
/** Applies a new blob to the current state and records it in history. Returns the new object URL. */
|
|
29
|
+
applyActions: (blob: Blob, actions: EditAction[]) => string;
|
|
25
30
|
undo: () => void;
|
|
26
31
|
redo: () => void;
|
|
27
32
|
reset: () => void;
|
|
@@ -41,20 +46,25 @@ export function useImageHistory(sourceUrl: string, registry: ActionRegistry): Us
|
|
|
41
46
|
|
|
42
47
|
let historyRef = useRef(history);
|
|
43
48
|
historyRef.current = history;
|
|
49
|
+
// Written synchronously by `replaceCurrent` so imperative callers can read the current
|
|
50
|
+
// image/blob before React has committed the corresponding render.
|
|
44
51
|
let currentRef = useRef(current);
|
|
45
|
-
currentRef.current = current;
|
|
46
52
|
let isReplaying = useRef(false);
|
|
47
53
|
let replayAbort = useRef<AbortController | null>(null);
|
|
48
54
|
|
|
55
|
+
function replaceCurrent(next: CurrentState) {
|
|
56
|
+
let prev = currentRef.current;
|
|
57
|
+
if (prev.generated && prev.url !== next.url) URL.revokeObjectURL(prev.url);
|
|
58
|
+
currentRef.current = next;
|
|
59
|
+
setCurrent(next);
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
// When source changes (e.g. component remount with new image), reset fully.
|
|
50
63
|
useEffect(() => {
|
|
51
64
|
replayAbort.current?.abort();
|
|
52
65
|
isReplaying.current = false;
|
|
53
66
|
setReplaying(false);
|
|
54
|
-
|
|
55
|
-
if (prev.generated) URL.revokeObjectURL(prev.url);
|
|
56
|
-
return { url: sourceUrl, blob: null, generated: false };
|
|
57
|
-
});
|
|
67
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
58
68
|
setHistory({ past: [], future: [] });
|
|
59
69
|
}, [sourceUrl]);
|
|
60
70
|
|
|
@@ -72,11 +82,10 @@ export function useImageHistory(sourceUrl: string, registry: ActionRegistry): Us
|
|
|
72
82
|
setReplaying(false);
|
|
73
83
|
|
|
74
84
|
let newUrl = URL.createObjectURL(blob);
|
|
75
|
-
|
|
76
|
-
if (prev.generated) URL.revokeObjectURL(prev.url);
|
|
77
|
-
return { url: newUrl, blob, generated: true };
|
|
78
|
-
});
|
|
85
|
+
replaceCurrent({ url: newUrl, blob, generated: true });
|
|
79
86
|
setHistory((prev) => ({ past: [...prev.past, actions], future: [] }));
|
|
87
|
+
|
|
88
|
+
return newUrl;
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
async function doReplay(newPast: EditAction[][], newFuture: EditAction[][]) {
|
|
@@ -90,11 +99,11 @@ export function useImageHistory(sourceUrl: string, registry: ActionRegistry): Us
|
|
|
90
99
|
let result = await replayAll(sourceUrl, newPast, registry, abort.signal);
|
|
91
100
|
if (abort.signal.aborted) return;
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
102
|
+
if (result) {
|
|
103
|
+
replaceCurrent({ url: result.url, blob: result.blob, generated: true });
|
|
104
|
+
} else {
|
|
105
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
106
|
+
}
|
|
98
107
|
setHistory({ past: newPast, future: newFuture });
|
|
99
108
|
} finally {
|
|
100
109
|
if (!abort.signal.aborted) {
|
|
@@ -122,16 +131,15 @@ export function useImageHistory(sourceUrl: string, registry: ActionRegistry): Us
|
|
|
122
131
|
replayAbort.current?.abort();
|
|
123
132
|
isReplaying.current = false;
|
|
124
133
|
setReplaying(false);
|
|
125
|
-
|
|
126
|
-
if (prev.generated) URL.revokeObjectURL(prev.url);
|
|
127
|
-
return { url: sourceUrl, blob: null, generated: false };
|
|
128
|
-
});
|
|
134
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
129
135
|
setHistory({ past: [], future: [] });
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
return {
|
|
133
139
|
currentImageUrl: current.url,
|
|
134
140
|
currentBlob: current.blob,
|
|
141
|
+
getCurrentImageUrl: () => currentRef.current.url,
|
|
142
|
+
getCurrentBlob: () => currentRef.current.blob,
|
|
135
143
|
canUndo: history.past.length > 0,
|
|
136
144
|
canRedo: history.future.length > 0,
|
|
137
145
|
replaying,
|
|
@@ -9,7 +9,6 @@ $line-width: 0.2em;
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.ObLinkedList-root {
|
|
12
|
-
|
|
13
12
|
list-style-type: none;
|
|
14
13
|
margin-left: 0;
|
|
15
14
|
padding-left: 0;
|
|
@@ -53,7 +52,10 @@ $line-width: 0.2em;
|
|
|
53
52
|
left: 0;
|
|
54
53
|
top: 50%;
|
|
55
54
|
|
|
56
|
-
transform: translate(
|
|
55
|
+
transform: translate(
|
|
56
|
+
calc(-1 * (var(--ob-linked-list-bullet-size) / 2) + (var(--ob-linked-list-line-width) / 2)),
|
|
57
|
+
-50%
|
|
58
|
+
);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
.ObLinkedList-card {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
&::-webkit-progress-value {
|
|
22
|
-
background-image:
|
|
22
|
+
background-image:
|
|
23
|
+
linear-gradient(
|
|
23
24
|
135deg,
|
|
24
25
|
transparent,
|
|
25
26
|
transparent 33%,
|
|
@@ -63,7 +64,8 @@
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
&::-moz-progress-bar {
|
|
66
|
-
background-image:
|
|
67
|
+
background-image:
|
|
68
|
+
linear-gradient(
|
|
67
69
|
135deg,
|
|
68
70
|
transparent,
|
|
69
71
|
transparent 33%,
|