@atlaskit/renderer 126.7.0 → 126.8.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.
@@ -0,0 +1,89 @@
1
+ import { useRef, useCallback } from 'react';
2
+ /**
3
+ * Hook that provides functionality to wait for layout stability before performing an action.
4
+ * Uses ResizeObserver to detect when a container has stopped resizing (e.g., images finished loading).
5
+ */
6
+ export var useStableScroll = function useStableScroll() {
7
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8
+ var _options$stabilityWai = options.stabilityWaitTime,
9
+ stabilityWaitTime = _options$stabilityWai === void 0 ? 200 : _options$stabilityWai,
10
+ _options$maxStability = options.maxStabilityWaitTime,
11
+ maxStabilityWaitTime = _options$maxStability === void 0 ? 10000 : _options$maxStability;
12
+ var stabilityTimeoutRef = useRef(null);
13
+ var resizeObserverRef = useRef(null);
14
+ var lastStableTimeRef = useRef(0);
15
+ var onStableCallbackRef = useRef(null);
16
+ var cleanup = useCallback(function () {
17
+ if (stabilityTimeoutRef.current) {
18
+ clearTimeout(stabilityTimeoutRef.current);
19
+ stabilityTimeoutRef.current = null;
20
+ }
21
+ if (resizeObserverRef.current) {
22
+ resizeObserverRef.current.disconnect();
23
+ resizeObserverRef.current = null;
24
+ }
25
+ onStableCallbackRef.current = null;
26
+ lastStableTimeRef.current = 0;
27
+ }, []);
28
+ var scheduleStabilityCheck = useCallback(function () {
29
+ // Clear any existing stability timeout.
30
+ if (stabilityTimeoutRef.current) {
31
+ clearTimeout(stabilityTimeoutRef.current);
32
+ stabilityTimeoutRef.current = null;
33
+ }
34
+
35
+ // Check if we've exceeded the maximum stability wait time.
36
+ var now = Date.now();
37
+ if (lastStableTimeRef.current === 0) {
38
+ lastStableTimeRef.current = now;
39
+ } else if (now - lastStableTimeRef.current > maxStabilityWaitTime) {
40
+ // We've waited too long for stability, call the callback now.
41
+ if (onStableCallbackRef.current) {
42
+ onStableCallbackRef.current();
43
+ cleanup();
44
+ }
45
+ return;
46
+ }
47
+
48
+ // Set a timeout to call the callback after the stability wait time.
49
+ stabilityTimeoutRef.current = setTimeout(function () {
50
+ if (onStableCallbackRef.current) {
51
+ onStableCallbackRef.current();
52
+ cleanup();
53
+ }
54
+ }, stabilityWaitTime);
55
+ }, [stabilityWaitTime, maxStabilityWaitTime, cleanup]);
56
+ var waitForStability = useCallback(function (container, onStable) {
57
+ // Clean up any existing observer
58
+ cleanup();
59
+
60
+ // Store the callback
61
+ onStableCallbackRef.current = onStable;
62
+
63
+ // Check if ResizeObserver is available
64
+ if (typeof ResizeObserver === 'undefined') {
65
+ // Fallback: just call the callback after the stability wait time
66
+ stabilityTimeoutRef.current = setTimeout(function () {
67
+ if (onStableCallbackRef.current) {
68
+ onStableCallbackRef.current();
69
+ cleanup();
70
+ }
71
+ }, stabilityWaitTime);
72
+ return;
73
+ }
74
+
75
+ // Create a ResizeObserver to monitor the container for size changes.
76
+ resizeObserverRef.current = new ResizeObserver(function () {
77
+ // Container size changed, reset stability timer.
78
+ scheduleStabilityCheck();
79
+ });
80
+ resizeObserverRef.current.observe(container);
81
+
82
+ // Start the initial stability check
83
+ scheduleStabilityCheck();
84
+ }, [stabilityWaitTime, scheduleStabilityCheck, cleanup]);
85
+ return {
86
+ waitForStability: waitForStability,
87
+ cleanup: cleanup
88
+ };
89
+ };
@@ -3,6 +3,7 @@ import type { AEP } from './enums';
3
3
  import type { SortOrder } from '@atlaskit/editor-common/types';
4
4
  import type { SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UnsupportedContentPayload, UnsupportedContentTooltipPayload } from '@atlaskit/editor-common/utils';
5
5
  import type { EditorBreakpointKey } from '@atlaskit/editor-common/utils/analytics';
6
+ import type { NestedRendererType } from '../ui/Renderer/types';
6
7
  export declare enum PLATFORM {
7
8
  NATIVE = "mobileNative",
8
9
  HYBRID = "mobileHybrid",
@@ -18,6 +19,7 @@ type RendererStartAEP = AEP<ACTION.STARTED, ACTION_SUBJECT.RENDERER, undefined,
18
19
  type RendererRenderedAEP = AEP<ACTION.RENDERED, ACTION_SUBJECT.RENDERER, undefined, {
19
20
  distortedDuration: boolean;
20
21
  duration: number;
22
+ nestedRendererType?: NestedRendererType;
21
23
  nodes: Record<string, number>;
22
24
  platform: PLATFORM.WEB;
23
25
  severity?: SEVERITY;
@@ -26,6 +28,7 @@ type RendererRenderedAEP = AEP<ACTION.RENDERED, ACTION_SUBJECT.RENDERER, undefin
26
28
  type RendererRenderedSampledAEP = AEP<ACTION.RENDERED_SAMPLED, ACTION_SUBJECT.RENDERER, undefined, {
27
29
  distortedDuration: boolean;
28
30
  duration: number;
31
+ nestedRendererType?: NestedRendererType;
29
32
  nodes: Record<string, number>;
30
33
  platform: PLATFORM.WEB;
31
34
  severity?: SEVERITY;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
3
- import type { RendererContentMode } from './ui/Renderer/types';
3
+ import type { RendererContentMode, NestedRendererType } from './ui/Renderer/types';
4
4
  export type RendererContextProps = {
5
5
  contentMode?: RendererContentMode;
6
6
  featureFlags?: FeatureFlags;
7
7
  isTopLevelRenderer?: boolean;
8
+ nestedRendererType?: NestedRendererType;
8
9
  };
9
10
  export declare const useRendererContext: () => RendererContextProps;
10
11
  export declare const RendererContextProvider: React.Provider<{}>;
@@ -1,5 +1,6 @@
1
1
  export type RendererAppearance = 'comment' | 'full-page' | 'full-width' | 'max' | undefined;
2
2
  export type RendererContentMode = 'standard' | 'compact' | undefined;
3
+ export type NestedRendererType = 'syncedBlock' | undefined;
3
4
  /**
4
5
  * DO NOT USE THESE OPTIONS
5
6
  * These StickyHeaderConfig_DO_NOT_USE options are being TEMPORARILY added so Confluence can use Sticky Table Headers
@@ -0,0 +1,23 @@
1
+ import type { DocNode } from '@atlaskit/adf-schema';
2
+ /**
3
+ * useScrollToBlock - Handler for block link scrolling in the renderer with expand support
4
+ *
5
+ * This hook enables scroll-to-block functionality when blocks may be hidden inside collapsed expands.
6
+ * It searches the ADF document for the target block, identifies any parent expand nodes,
7
+ * expands them if needed, and waits for layout stability before scrolling to the block.
8
+ *
9
+ * This implementation waits for the container to stabilize (no layout shifts) before scrolling,
10
+ * which prevents issues with images loading, dynamic content, or other async operations that
11
+ * cause layout changes.
12
+ *
13
+ * This hook replaces useScrollToLocalId when the platform_editor_expand_on_scroll_to_block experiment is enabled.
14
+ *
15
+ * When platform_editor_expand_on_scroll_to_block experiment is cleaned up:
16
+ * - Remove the experiment check
17
+ * - Delete the deprecated useScrollToLocalId hook
18
+ * - Make this the default scroll-to-block behavior
19
+ *
20
+ * @param containerRef - Optional ref to the renderer container (RendererStyleContainer)
21
+ * @param adfDoc - The ADF document to search for nodes and expand parents
22
+ */
23
+ export declare const useScrollToBlock: (containerRef?: React.RefObject<HTMLDivElement>, adfDoc?: DocNode) => void;
@@ -1 +1,10 @@
1
+ /**
2
+ * useScrollToLocalId - Handler for block link scrolling in the renderer (traditional pages)
3
+ *
4
+ * This hook is deprecated in favor of useScrollToBlock which supports expanding parent nodes.
5
+ * This hook will be removed when the platform_editor_expand_on_scroll_to_block experiment is cleaned up.
6
+ *
7
+ * @param containerRef - Optional ref to the renderer container (RendererStyleContainer).
8
+ * @param shouldScrollToLocalId - Whether scroll-to-block functionality should be enabled
9
+ */
1
10
  export declare const useScrollToLocalId: (containerRef?: React.RefObject<HTMLDivElement>, shouldScrollToLocalId?: boolean) => void;
@@ -0,0 +1,27 @@
1
+ export interface UseStableScrollOptions {
2
+ /**
3
+ * Maximum time (in ms) to wait for stability before scrolling anyway
4
+ * @default 10000
5
+ */
6
+ maxStabilityWaitTime?: number;
7
+ /**
8
+ * Time to wait (in ms) after the last resize event before considering the layout stable
9
+ * @default 200
10
+ */
11
+ stabilityWaitTime?: number;
12
+ }
13
+ export interface UseStableScrollReturn {
14
+ /**
15
+ * Cleans up all timers and observers
16
+ */
17
+ cleanup: () => void;
18
+ /**
19
+ * Starts monitoring the container for stability and calls the callback when stable
20
+ */
21
+ waitForStability: (container: HTMLElement, onStable: () => void) => void;
22
+ }
23
+ /**
24
+ * Hook that provides functionality to wait for layout stability before performing an action.
25
+ * Uses ResizeObserver to detect when a container has stopped resizing (e.g., images finished loading).
26
+ */
27
+ export declare const useStableScroll: (options?: UseStableScrollOptions) => UseStableScrollReturn;
@@ -3,6 +3,7 @@ import type { AEP } from './enums';
3
3
  import type { SortOrder } from '@atlaskit/editor-common/types';
4
4
  import type { SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UnsupportedContentPayload, UnsupportedContentTooltipPayload } from '@atlaskit/editor-common/utils';
5
5
  import type { EditorBreakpointKey } from '@atlaskit/editor-common/utils/analytics';
6
+ import type { NestedRendererType } from '../ui/Renderer/types';
6
7
  export declare enum PLATFORM {
7
8
  NATIVE = "mobileNative",
8
9
  HYBRID = "mobileHybrid",
@@ -18,6 +19,7 @@ type RendererStartAEP = AEP<ACTION.STARTED, ACTION_SUBJECT.RENDERER, undefined,
18
19
  type RendererRenderedAEP = AEP<ACTION.RENDERED, ACTION_SUBJECT.RENDERER, undefined, {
19
20
  distortedDuration: boolean;
20
21
  duration: number;
22
+ nestedRendererType?: NestedRendererType;
21
23
  nodes: Record<string, number>;
22
24
  platform: PLATFORM.WEB;
23
25
  severity?: SEVERITY;
@@ -26,6 +28,7 @@ type RendererRenderedAEP = AEP<ACTION.RENDERED, ACTION_SUBJECT.RENDERER, undefin
26
28
  type RendererRenderedSampledAEP = AEP<ACTION.RENDERED_SAMPLED, ACTION_SUBJECT.RENDERER, undefined, {
27
29
  distortedDuration: boolean;
28
30
  duration: number;
31
+ nestedRendererType?: NestedRendererType;
29
32
  nodes: Record<string, number>;
30
33
  platform: PLATFORM.WEB;
31
34
  severity?: SEVERITY;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
3
- import type { RendererContentMode } from './ui/Renderer/types';
3
+ import type { RendererContentMode, NestedRendererType } from './ui/Renderer/types';
4
4
  export type RendererContextProps = {
5
5
  contentMode?: RendererContentMode;
6
6
  featureFlags?: FeatureFlags;
7
7
  isTopLevelRenderer?: boolean;
8
+ nestedRendererType?: NestedRendererType;
8
9
  };
9
10
  export declare const useRendererContext: () => RendererContextProps;
10
11
  export declare const RendererContextProvider: React.Provider<{}>;
@@ -1,5 +1,6 @@
1
1
  export type RendererAppearance = 'comment' | 'full-page' | 'full-width' | 'max' | undefined;
2
2
  export type RendererContentMode = 'standard' | 'compact' | undefined;
3
+ export type NestedRendererType = 'syncedBlock' | undefined;
3
4
  /**
4
5
  * DO NOT USE THESE OPTIONS
5
6
  * These StickyHeaderConfig_DO_NOT_USE options are being TEMPORARILY added so Confluence can use Sticky Table Headers
@@ -0,0 +1,23 @@
1
+ import type { DocNode } from '@atlaskit/adf-schema';
2
+ /**
3
+ * useScrollToBlock - Handler for block link scrolling in the renderer with expand support
4
+ *
5
+ * This hook enables scroll-to-block functionality when blocks may be hidden inside collapsed expands.
6
+ * It searches the ADF document for the target block, identifies any parent expand nodes,
7
+ * expands them if needed, and waits for layout stability before scrolling to the block.
8
+ *
9
+ * This implementation waits for the container to stabilize (no layout shifts) before scrolling,
10
+ * which prevents issues with images loading, dynamic content, or other async operations that
11
+ * cause layout changes.
12
+ *
13
+ * This hook replaces useScrollToLocalId when the platform_editor_expand_on_scroll_to_block experiment is enabled.
14
+ *
15
+ * When platform_editor_expand_on_scroll_to_block experiment is cleaned up:
16
+ * - Remove the experiment check
17
+ * - Delete the deprecated useScrollToLocalId hook
18
+ * - Make this the default scroll-to-block behavior
19
+ *
20
+ * @param containerRef - Optional ref to the renderer container (RendererStyleContainer)
21
+ * @param adfDoc - The ADF document to search for nodes and expand parents
22
+ */
23
+ export declare const useScrollToBlock: (containerRef?: React.RefObject<HTMLDivElement>, adfDoc?: DocNode) => void;
@@ -1 +1,10 @@
1
+ /**
2
+ * useScrollToLocalId - Handler for block link scrolling in the renderer (traditional pages)
3
+ *
4
+ * This hook is deprecated in favor of useScrollToBlock which supports expanding parent nodes.
5
+ * This hook will be removed when the platform_editor_expand_on_scroll_to_block experiment is cleaned up.
6
+ *
7
+ * @param containerRef - Optional ref to the renderer container (RendererStyleContainer).
8
+ * @param shouldScrollToLocalId - Whether scroll-to-block functionality should be enabled
9
+ */
1
10
  export declare const useScrollToLocalId: (containerRef?: React.RefObject<HTMLDivElement>, shouldScrollToLocalId?: boolean) => void;
@@ -0,0 +1,27 @@
1
+ export interface UseStableScrollOptions {
2
+ /**
3
+ * Maximum time (in ms) to wait for stability before scrolling anyway
4
+ * @default 10000
5
+ */
6
+ maxStabilityWaitTime?: number;
7
+ /**
8
+ * Time to wait (in ms) after the last resize event before considering the layout stable
9
+ * @default 200
10
+ */
11
+ stabilityWaitTime?: number;
12
+ }
13
+ export interface UseStableScrollReturn {
14
+ /**
15
+ * Cleans up all timers and observers
16
+ */
17
+ cleanup: () => void;
18
+ /**
19
+ * Starts monitoring the container for stability and calls the callback when stable
20
+ */
21
+ waitForStability: (container: HTMLElement, onStable: () => void) => void;
22
+ }
23
+ /**
24
+ * Hook that provides functionality to wait for layout stability before performing an action.
25
+ * Uses ResizeObserver to detect when a container has stopped resizing (e.g., images finished loading).
26
+ */
27
+ export declare const useStableScroll: (options?: UseStableScrollOptions) => UseStableScrollReturn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "126.7.0",
3
+ "version": "126.8.0",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/status": "^3.1.0",
58
58
  "@atlaskit/task-decision": "^19.2.0",
59
59
  "@atlaskit/theme": "^21.0.0",
60
- "@atlaskit/tmp-editor-statsig": "^20.3.0",
60
+ "@atlaskit/tmp-editor-statsig": "^21.1.0",
61
61
  "@atlaskit/tokens": "^11.0.0",
62
62
  "@atlaskit/tooltip": "^20.14.0",
63
63
  "@atlaskit/visually-hidden": "^3.0.0",
@@ -249,6 +249,9 @@
249
249
  },
250
250
  "confluence_ttvc_inline_extensions": {
251
251
  "type": "boolean"
252
+ },
253
+ "platform_synced_block_patch_1": {
254
+ "type": "boolean"
252
255
  }
253
256
  }
254
257
  }