@olenbetong/synergi-react 2.7.1 → 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.
Files changed (82) hide show
  1. package/dist/styles/styles.css.map +1 -1
  2. package/es/{components → chrome}/AppMenu/AppMenu.css +648 -648
  3. package/es/{components → chrome}/AppMenu/index.d.ts +1 -1
  4. package/es/components/ImageEditor/ImageEditor.d.ts +12 -0
  5. package/es/components/ImageEditor/ImageEditor.js +27 -6
  6. package/es/components/ImageEditor/index.d.ts +2 -0
  7. package/es/components/ImageEditor/index.js +2 -0
  8. package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +1 -1
  9. package/es/components/ImageEditor/useImageHistory.d.ts +6 -1
  10. package/es/components/ImageEditor/useImageHistory.js +21 -23
  11. package/es/components/PageBanner/index.d.ts +1 -1
  12. package/es/elements/ElementDamage/DamageFormButtons.d.ts +2 -3
  13. package/es/elements/ElementDamage/DamageFormButtons.js +1 -1
  14. package/es/elements/ElementDamage/TransportElementSelect.d.ts +1 -2
  15. package/es/elements/index.d.ts +5 -0
  16. package/es/elements/index.js +5 -0
  17. package/es/index.d.ts +2 -2
  18. package/es/index.js +2 -2
  19. package/package.json +4 -4
  20. package/src/{components → chrome}/AppMenu/AppMenu.css +648 -648
  21. package/src/{components → chrome}/AppMenu/AppMenu.tsx +285 -285
  22. package/src/{components → chrome}/AppMenu/AppMenuFavoriteButton.tsx +47 -47
  23. package/src/{components → chrome}/AppMenu/AppMenuHeader.tsx +79 -79
  24. package/src/{components → chrome}/AppMenu/AppMenuList.tsx +89 -89
  25. package/src/{components → chrome}/AppMenu/AppMenuRail.tsx +117 -117
  26. package/src/{components → chrome}/AppMenu/icons.tsx +76 -76
  27. package/src/{components → chrome}/AppMenu/index.ts +17 -17
  28. package/src/{components → chrome}/AppMenu/menuEntries.ts +128 -128
  29. package/src/{components → chrome}/AppMenu/types.ts +45 -45
  30. package/src/{components → chrome}/AppMenu/useFavorites.ts +40 -40
  31. package/src/{components → chrome}/AppMenu/useRovingTabIndex.ts +130 -130
  32. package/src/{components → chrome}/AppShell/index.tsx +287 -287
  33. package/src/colorScheme.ts +81 -81
  34. package/src/components/ImageEditor/ImageEditor.tsx +41 -6
  35. package/src/components/ImageEditor/index.ts +2 -0
  36. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +7 -8
  37. package/src/components/ImageEditor/useImageHistory.ts +27 -19
  38. package/src/components/LinkedCardList/index.scss +95 -93
  39. package/src/components/PageBanner/index.tsx +5 -4
  40. package/src/components/ProgressBar/index.scss +96 -94
  41. package/src/elements/ElementDamage/DamageFormButtons.tsx +2 -2
  42. package/src/elements/ElementDamage/TransportElementSelect.tsx +1 -1
  43. package/src/elements/index.ts +5 -0
  44. package/src/index.ts +70 -61
  45. /package/es/{components → chrome}/AppMenu/AppMenu.d.ts +0 -0
  46. /package/es/{components → chrome}/AppMenu/AppMenu.js +0 -0
  47. /package/es/{components → chrome}/AppMenu/AppMenuColorScheme.d.ts +0 -0
  48. /package/es/{components → chrome}/AppMenu/AppMenuColorScheme.js +0 -0
  49. /package/es/{components → chrome}/AppMenu/AppMenuFavoriteButton.d.ts +0 -0
  50. /package/es/{components → chrome}/AppMenu/AppMenuFavoriteButton.js +0 -0
  51. /package/es/{components → chrome}/AppMenu/AppMenuHeader.d.ts +0 -0
  52. /package/es/{components → chrome}/AppMenu/AppMenuHeader.js +0 -0
  53. /package/es/{components → chrome}/AppMenu/AppMenuList.d.ts +0 -0
  54. /package/es/{components → chrome}/AppMenu/AppMenuList.js +0 -0
  55. /package/es/{components → chrome}/AppMenu/AppMenuRail.d.ts +0 -0
  56. /package/es/{components → chrome}/AppMenu/AppMenuRail.js +0 -0
  57. /package/es/{components → chrome}/AppMenu/AppMenuToggle.d.ts +0 -0
  58. /package/es/{components → chrome}/AppMenu/AppMenuToggle.js +0 -0
  59. /package/es/{components → chrome}/AppMenu/AppMenuUserMenu.d.ts +0 -0
  60. /package/es/{components → chrome}/AppMenu/AppMenuUserMenu.js +0 -0
  61. /package/es/{components → chrome}/AppMenu/developerCategories.d.ts +0 -0
  62. /package/es/{components → chrome}/AppMenu/developerCategories.js +0 -0
  63. /package/es/{components → chrome}/AppMenu/icons.d.ts +0 -0
  64. /package/es/{components → chrome}/AppMenu/icons.js +0 -0
  65. /package/es/{components → chrome}/AppMenu/index.js +0 -0
  66. /package/es/{components → chrome}/AppMenu/menuEntries.d.ts +0 -0
  67. /package/es/{components → chrome}/AppMenu/menuEntries.js +0 -0
  68. /package/es/{components → chrome}/AppMenu/types.d.ts +0 -0
  69. /package/es/{components → chrome}/AppMenu/types.js +0 -0
  70. /package/es/{components → chrome}/AppMenu/useFavorites.d.ts +0 -0
  71. /package/es/{components → chrome}/AppMenu/useFavorites.js +0 -0
  72. /package/es/{components → chrome}/AppMenu/useRovingTabIndex.d.ts +0 -0
  73. /package/es/{components → chrome}/AppMenu/useRovingTabIndex.js +0 -0
  74. /package/es/{components → chrome}/AppMenu/useServiceWorkerUpdate.d.ts +0 -0
  75. /package/es/{components → chrome}/AppMenu/useServiceWorkerUpdate.js +0 -0
  76. /package/es/{components → chrome}/AppShell/index.d.ts +0 -0
  77. /package/es/{components → chrome}/AppShell/index.js +0 -0
  78. /package/src/{components → chrome}/AppMenu/AppMenuColorScheme.tsx +0 -0
  79. /package/src/{components → chrome}/AppMenu/AppMenuToggle.tsx +0 -0
  80. /package/src/{components → chrome}/AppMenu/AppMenuUserMenu.tsx +0 -0
  81. /package/src/{components → chrome}/AppMenu/developerCategories.ts +0 -0
  82. /package/src/{components → chrome}/AppMenu/useServiceWorkerUpdate.ts +0 -0
@@ -1,81 +1,81 @@
1
- import { useCallback, useEffect, useState } from "react";
2
-
3
- /**
4
- * Color scheme preference (system / light / dark).
5
- *
6
- * The preference lives in the `ob-color-scheme` cookie so the article template
7
- * can read it server side and render `data-color-scheme` on `<html>` and
8
- * `<body>` before the first paint. The site script for the 2026 template
9
- * (`ob.2026.application.min.js`) owns the same cookie for the toolbar user menu
10
- * toggle, so both write the cookie, apply the attributes, and dispatch
11
- * `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
12
- */
13
-
14
- export type ColorSchemePreference = "auto" | "light" | "dark";
15
-
16
- const COOKIE_NAME = "ob-color-scheme";
17
- const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
18
- const DEFAULT_PREFERENCE: ColorSchemePreference = "auto";
19
- const PREFERENCES: ColorSchemePreference[] = ["auto", "light", "dark"];
20
-
21
- /** Dispatched on `window` whenever the preference changes. */
22
- export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
23
-
24
- function isColorSchemePreference(value: unknown): value is ColorSchemePreference {
25
- return typeof value === "string" && PREFERENCES.includes(value as ColorSchemePreference);
26
- }
27
-
28
- export function getColorSchemePreference(): ColorSchemePreference {
29
- if (typeof document === "undefined") return DEFAULT_PREFERENCE;
30
-
31
- let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
32
- let value = match ? decodeURIComponent(match[1]) : null;
33
-
34
- return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
35
- }
36
-
37
- export function setColorSchemePreference(preference: ColorSchemePreference) {
38
- if (typeof document === "undefined" || !isColorSchemePreference(preference)) return;
39
-
40
- let secure = window.location.protocol === "https:" ? ";secure" : "";
41
- document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
42
-
43
- /*
44
- * Both elements are updated: `<html>` so the browser applies `color-scheme`
45
- * to scrollbars and native controls, `<body>` because Designsystemet declares
46
- * the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
47
- */
48
- document.documentElement.dataset.colorScheme = preference;
49
- if (document.body) document.body.dataset.colorScheme = preference;
50
-
51
- window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
52
- }
53
-
54
- /** Reads the stored preference and keeps it in sync with other toggles on the page. */
55
- export function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void] {
56
- let [preference, setPreference] = useState<ColorSchemePreference>(() => getColorSchemePreference());
57
-
58
- useEffect(() => {
59
- function update() {
60
- setPreference(getColorSchemePreference());
61
- }
62
-
63
- update();
64
-
65
- window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
66
- // Cookies fire no change event, so also pick up changes made in another tab.
67
- document.addEventListener("visibilitychange", update);
68
-
69
- return () => {
70
- window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
71
- document.removeEventListener("visibilitychange", update);
72
- };
73
- }, []);
74
-
75
- let setValue = useCallback((value: ColorSchemePreference) => {
76
- setColorSchemePreference(value);
77
- setPreference(value);
78
- }, []);
79
-
80
- return [preference, setValue];
81
- }
1
+ import { useCallback, useEffect, useState } from "react";
2
+
3
+ /**
4
+ * Color scheme preference (system / light / dark).
5
+ *
6
+ * The preference lives in the `ob-color-scheme` cookie so the article template
7
+ * can read it server side and render `data-color-scheme` on `<html>` and
8
+ * `<body>` before the first paint. The site script for the 2026 template
9
+ * (`ob.2026.application.min.js`) owns the same cookie for the toolbar user menu
10
+ * toggle, so both write the cookie, apply the attributes, and dispatch
11
+ * `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
12
+ */
13
+
14
+ export type ColorSchemePreference = "auto" | "light" | "dark";
15
+
16
+ const COOKIE_NAME = "ob-color-scheme";
17
+ const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
18
+ const DEFAULT_PREFERENCE: ColorSchemePreference = "auto";
19
+ const PREFERENCES: ColorSchemePreference[] = ["auto", "light", "dark"];
20
+
21
+ /** Dispatched on `window` whenever the preference changes. */
22
+ export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
23
+
24
+ function isColorSchemePreference(value: unknown): value is ColorSchemePreference {
25
+ return typeof value === "string" && PREFERENCES.includes(value as ColorSchemePreference);
26
+ }
27
+
28
+ export function getColorSchemePreference(): ColorSchemePreference {
29
+ if (typeof document === "undefined") return DEFAULT_PREFERENCE;
30
+
31
+ let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
32
+ let value = match ? decodeURIComponent(match[1]) : null;
33
+
34
+ return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
35
+ }
36
+
37
+ export function setColorSchemePreference(preference: ColorSchemePreference) {
38
+ if (typeof document === "undefined" || !isColorSchemePreference(preference)) return;
39
+
40
+ let secure = window.location.protocol === "https:" ? ";secure" : "";
41
+ document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
42
+
43
+ /*
44
+ * Both elements are updated: `<html>` so the browser applies `color-scheme`
45
+ * to scrollbars and native controls, `<body>` because Designsystemet declares
46
+ * the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
47
+ */
48
+ document.documentElement.dataset.colorScheme = preference;
49
+ if (document.body) document.body.dataset.colorScheme = preference;
50
+
51
+ window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
52
+ }
53
+
54
+ /** Reads the stored preference and keeps it in sync with other toggles on the page. */
55
+ export function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void] {
56
+ let [preference, setPreference] = useState<ColorSchemePreference>(() => getColorSchemePreference());
57
+
58
+ useEffect(() => {
59
+ function update() {
60
+ setPreference(getColorSchemePreference());
61
+ }
62
+
63
+ update();
64
+
65
+ window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
66
+ // Cookies fire no change event, so also pick up changes made in another tab.
67
+ document.addEventListener("visibilitychange", update);
68
+
69
+ return () => {
70
+ window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
71
+ document.removeEventListener("visibilitychange", update);
72
+ };
73
+ }, []);
74
+
75
+ let setValue = useCallback((value: ColorSchemePreference) => {
76
+ setColorSchemePreference(value);
77
+ setPreference(value);
78
+ }, []);
79
+
80
+ return [preference, setValue];
81
+ }
@@ -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: () => history.currentBlob,
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(history.currentImageUrl);
88
+ let blob = await plugin.execute(historyRef.current.getCurrentImageUrl());
54
89
  let actions: EditAction[] = [{ type: plugin.id, params: {} }];
55
- history.applyActions(blob, actions);
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={() => executeAction(p)}
224
+ onExecute={() => enqueueAction(p)}
190
225
  isSmall={isSmall}
191
226
  />
192
227
  ),
@@ -241,7 +276,7 @@ function ToolButton({
241
276
  }
242
277
 
243
278
  return (
244
- <Button variant="secondary" data-size="sm" onClick={onActivate} disabled={busy}>
279
+ <Button variant="tertiary" data-size="sm" onClick={onActivate} disabled={busy}>
245
280
  <Icon />
246
281
  {label}
247
282
  </Button>
@@ -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";
@@ -28,14 +28,13 @@ export function ZoomControls({ disabled, isSmall = false }: Props) {
28
28
  disabled={disabled || !canZoomIn}
29
29
  isSmall={isSmall}
30
30
  />
31
- {isZoomed && (
32
- <ResponsiveButton
33
- icon={<ShrinkIcon aria-hidden />}
34
- label={getLocalizedString("Reset zoom")}
35
- onClick={resetZoom}
36
- isSmall={isSmall}
37
- />
38
- )}
31
+ <ResponsiveButton
32
+ disabled={!isZoomed}
33
+ icon={<ShrinkIcon aria-hidden />}
34
+ label={getLocalizedString("Reset zoom")}
35
+ onClick={resetZoom}
36
+ isSmall={isSmall}
37
+ />
39
38
  </>
40
39
  );
41
40
  }
@@ -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
- applyActions: (blob: Blob, actions: EditAction[]) => void;
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
- setCurrent((prev) => {
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
- setCurrent((prev) => {
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
- setCurrent((prev) => {
94
- if (prev.generated) URL.revokeObjectURL(prev.url);
95
- if (result) return { url: result.url, blob: result.blob, generated: true };
96
- return { url: sourceUrl, blob: null, generated: false };
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
- setCurrent((prev) => {
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,
@@ -1,93 +1,95 @@
1
- @use "../../styles/variables";
2
-
3
- $bullet-size: 0.7em;
4
- $line-width: 0.2em;
5
-
6
- :root {
7
- --ob-linked-list-bullet-size: 0.7em;
8
- --ob-linked-list-line-width: 0.2em;
9
- }
10
-
11
- .ObLinkedList-root {
12
-
13
- list-style-type: none;
14
- margin-left: 0;
15
- padding-left: 0;
16
- }
17
-
18
- .ObLinkedList-item {
19
- display: flex;
20
- align-items: center;
21
- flex-direction: row;
22
- }
23
-
24
- .ObLinkedList-leftColumn {
25
- flex: 1 1 4em;
26
- font-size: 0.75em;
27
- padding: 0 1em;
28
- text-align: center;
29
- }
30
-
31
- .ObLinkedList-rightColumn {
32
- flex: 1 1 100%;
33
- padding: 1em 1em 1em 1.5em;
34
- }
35
-
36
- .ObLinkedList-line {
37
- display: flex;
38
- align-self: stretch;
39
- flex: 0 0 $line-width;
40
- background: white;
41
- position: relative;
42
- }
43
-
44
- .ObLinkedList-bullet {
45
- background: white;
46
-
47
- border: 1px solid rgba(50, 50, 50, 0.25);
48
- border-radius: 0.55em;
49
- height: $bullet-size;
50
- width: $bullet-size;
51
-
52
- position: absolute;
53
- left: 0;
54
- top: 50%;
55
-
56
- transform: translate(calc(-1 * (var(--ob-linked-list-bullet-size) / 2) + (var(--ob-linked-list-line-width) / 2)), -50%);
57
- }
58
-
59
- .ObLinkedList-card {
60
- display: block;
61
- background: white;
62
- border: 1px solid;
63
- border-color: variables.$color-border-top variables.$color-border-side variables.$color-border-bottom;
64
- border-radius: 0.1875em;
65
- color: inherit;
66
- cursor: pointer;
67
- flex: 100% 1 1;
68
- position: relative;
69
- }
70
-
71
- .ObLinkedList-card::before {
72
- border-bottom: 0.5em solid transparent;
73
- border-right: 1em solid white;
74
- border-top: 0.5em solid transparent;
75
- content: " ";
76
- filter: drop-shadow(-1px 0px 1px rgba(50, 50, 50, 0.2));
77
- height: 1em;
78
- left: -1em;
79
- margin-top: -0.5em;
80
- position: absolute;
81
- top: 50%;
82
- width: 1em;
83
- }
84
-
85
- .ObLinkedList-card:hover {
86
- background-color: variables.$block-color-bg-hover !important;
87
- color: inherit;
88
- text-decoration: inherit;
89
- }
90
-
91
- .ObLinkedList-card:hover::before {
92
- border-right-color: variables.$block-color-bg-hover !important;
93
- }
1
+ @use "../../styles/variables";
2
+
3
+ $bullet-size: 0.7em;
4
+ $line-width: 0.2em;
5
+
6
+ :root {
7
+ --ob-linked-list-bullet-size: 0.7em;
8
+ --ob-linked-list-line-width: 0.2em;
9
+ }
10
+
11
+ .ObLinkedList-root {
12
+ list-style-type: none;
13
+ margin-left: 0;
14
+ padding-left: 0;
15
+ }
16
+
17
+ .ObLinkedList-item {
18
+ display: flex;
19
+ align-items: center;
20
+ flex-direction: row;
21
+ }
22
+
23
+ .ObLinkedList-leftColumn {
24
+ flex: 1 1 4em;
25
+ font-size: 0.75em;
26
+ padding: 0 1em;
27
+ text-align: center;
28
+ }
29
+
30
+ .ObLinkedList-rightColumn {
31
+ flex: 1 1 100%;
32
+ padding: 1em 1em 1em 1.5em;
33
+ }
34
+
35
+ .ObLinkedList-line {
36
+ display: flex;
37
+ align-self: stretch;
38
+ flex: 0 0 $line-width;
39
+ background: white;
40
+ position: relative;
41
+ }
42
+
43
+ .ObLinkedList-bullet {
44
+ background: white;
45
+
46
+ border: 1px solid rgba(50, 50, 50, 0.25);
47
+ border-radius: 0.55em;
48
+ height: $bullet-size;
49
+ width: $bullet-size;
50
+
51
+ position: absolute;
52
+ left: 0;
53
+ top: 50%;
54
+
55
+ transform: translate(
56
+ calc(-1 * (var(--ob-linked-list-bullet-size) / 2) + (var(--ob-linked-list-line-width) / 2)),
57
+ -50%
58
+ );
59
+ }
60
+
61
+ .ObLinkedList-card {
62
+ display: block;
63
+ background: white;
64
+ border: 1px solid;
65
+ border-color: variables.$color-border-top variables.$color-border-side variables.$color-border-bottom;
66
+ border-radius: 0.1875em;
67
+ color: inherit;
68
+ cursor: pointer;
69
+ flex: 100% 1 1;
70
+ position: relative;
71
+ }
72
+
73
+ .ObLinkedList-card::before {
74
+ border-bottom: 0.5em solid transparent;
75
+ border-right: 1em solid white;
76
+ border-top: 0.5em solid transparent;
77
+ content: " ";
78
+ filter: drop-shadow(-1px 0px 1px rgba(50, 50, 50, 0.2));
79
+ height: 1em;
80
+ left: -1em;
81
+ margin-top: -0.5em;
82
+ position: absolute;
83
+ top: 50%;
84
+ width: 1em;
85
+ }
86
+
87
+ .ObLinkedList-card:hover {
88
+ background-color: variables.$block-color-bg-hover !important;
89
+ color: inherit;
90
+ text-decoration: inherit;
91
+ }
92
+
93
+ .ObLinkedList-card:hover::before {
94
+ border-right-color: variables.$block-color-bg-hover !important;
95
+ }
@@ -49,10 +49,11 @@ export function TabList({ as, className, children, sticky, ...other }: TabListPr
49
49
  );
50
50
  }
51
51
 
52
- export type TabProps = Pick<React.HTMLProps<HTMLDivElement>, "id" | "className" | "children"> & {
53
- active?: boolean;
54
- as?: "a" | "li" | "div" | "span";
55
- };
52
+ export type TabProps = Pick<React.HTMLProps<HTMLDivElement>, "id" | "className" | "children"> &
53
+ Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "target" | "rel"> & {
54
+ active?: boolean;
55
+ as?: "a" | "li" | "div" | "span";
56
+ };
56
57
 
57
58
  export function Tab({ active, as, className, children, ...other }: TabProps) {
58
59
  const Component = as ? as : "a";