@atlaskit/editor-common 111.11.7 → 111.11.9
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/CHANGELOG.md +13 -0
- package/dist/cjs/analytics/types/enums.js +8 -0
- package/dist/cjs/block-menu/block-link.js +27 -13
- package/dist/cjs/block-menu/index.js +44 -1
- package/dist/cjs/block-menu/scroll-to-block-utils.js +330 -0
- package/dist/es2019/analytics/types/enums.js +8 -0
- package/dist/es2019/block-menu/block-link.js +27 -13
- package/dist/es2019/block-menu/index.js +2 -1
- package/dist/es2019/block-menu/scroll-to-block-utils.js +306 -0
- package/dist/esm/analytics/types/enums.js +8 -0
- package/dist/esm/block-menu/block-link.js +27 -13
- package/dist/esm/block-menu/index.js +2 -1
- package/dist/esm/block-menu/scroll-to-block-utils.js +322 -0
- package/dist/types/analytics/types/enums.d.ts +8 -0
- package/dist/types/analytics/types/sync-block-events.d.ts +12 -2
- package/dist/types/block-menu/block-link.d.ts +22 -10
- package/dist/types/block-menu/index.d.ts +2 -0
- package/dist/types/block-menu/scroll-to-block-utils.d.ts +94 -0
- package/dist/types-ts4.5/analytics/types/enums.d.ts +8 -0
- package/dist/types-ts4.5/analytics/types/sync-block-events.d.ts +12 -2
- package/dist/types-ts4.5/block-menu/block-link.d.ts +22 -10
- package/dist/types-ts4.5/block-menu/index.d.ts +2 -0
- package/dist/types-ts4.5/block-menu/scroll-to-block-utils.d.ts +94 -0
- package/package.json +3 -3
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
export declare const DEFAULT_BLOCK_LINK_HASH_PREFIX = "block-";
|
|
2
2
|
/**
|
|
3
|
-
* Matches hashes that start with the block link prefix followed by
|
|
3
|
+
* Matches hashes that start with the block link prefix followed by either:
|
|
4
|
+
* - A UUID (e.g., '123e4567-e89b-12d3-a456-426614174000')
|
|
5
|
+
* - A short hex ID (e.g., 'ab2366c43b52')
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Short hex IDs are 12-character hexadecimal strings without dashes, used in some contexts
|
|
8
|
+
* as a compact alternative to full UUIDs. Both formats are valid block identifiers.
|
|
9
|
+
*
|
|
10
|
+
* Note: The short ID pattern matches exactly 12 hex characters. While this could theoretically
|
|
11
|
+
* match heading IDs or other anchors, block links are typically generated programmatically
|
|
12
|
+
* with known ID formats, minimizing collision risk.
|
|
13
|
+
*
|
|
14
|
+
* @param hash - The hash string to check (e.g., '#block-123e4567-e89b-12d3-a456-426614174000', '#block-ab2366c43b52', or without '#').
|
|
15
|
+
* @param prefix - The prefix to look for (default is 'block-').
|
|
16
|
+
* @returns True if the hash matches the block link pattern, false otherwise.
|
|
8
17
|
*/
|
|
9
18
|
export declare const isBlockLinkHash: (hash: string, prefix?: string) => boolean;
|
|
10
19
|
/**
|
|
11
20
|
* Extracts the block ID from a block link hash.
|
|
12
21
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
22
|
+
* Supports both UUID format (e.g., '123e4567-e89b-12d3-a456-426614174000') and
|
|
23
|
+
* short hex ID format (e.g., 'ab2366c43b52').
|
|
24
|
+
*
|
|
25
|
+
* @param hash - The hash string to extract the block ID from (e.g., '#block-123e4567-e89b-12d3-a456-426614174000', '#block-ab2366c43b52', or without '#').
|
|
26
|
+
* @param prefix - The prefix to look for (default is 'block-').
|
|
27
|
+
* @returns The extracted block ID if the hash is valid, null otherwise.
|
|
16
28
|
*/
|
|
17
29
|
export declare const extractBlockIdFromLinkHash: (hash: string, prefix?: string) => string | null;
|
|
18
30
|
/**
|
|
19
31
|
* Creates a block link hash from a given block ID.
|
|
20
32
|
*
|
|
21
|
-
* @param blockId The block ID to create the hash from (e.g., '123e4567-e89b-12d3-a456-426614174000')
|
|
22
|
-
* @param prefix The prefix to use (default is 'block-')
|
|
23
|
-
* @returns The constructed block link hash value (e.g., 'block-123e4567-e89b-12d3-a456-426614174000')
|
|
33
|
+
* @param blockId - The block ID to create the hash from (e.g., '123e4567-e89b-12d3-a456-426614174000').
|
|
34
|
+
* @param prefix - The prefix to use (default is 'block-').
|
|
35
|
+
* @returns The constructed block link hash value (e.g., 'block-123e4567-e89b-12d3-a456-426614174000').
|
|
24
36
|
*/
|
|
25
37
|
export declare const createBlockLinkHashValue: (blockId: string, prefix?: string) => string;
|
|
@@ -4,4 +4,6 @@ export { FORMAT_HEADING_1_MENU_ITEM, FORMAT_HEADING_2_MENU_ITEM, FORMAT_HEADING_
|
|
|
4
4
|
export { MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_HEADINGS_MENU_SECTION_RANK, TRANSFORM_STRUCTURE_MENU_SECTION_RANK, TRANSFORM_CLEAR_MENU_SECTION_RANK, BLOCK_ACTIONS_MENU_SECTION_RANK, POSITION_MENU_SECTION_RANK, DELETE_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION_RANK, } from './rank';
|
|
5
5
|
export { FORMAT_NESTED_MENU_RANK, FORMAT_NESTED_MENU_RANK_REVISED, BLOCK_MENU_SECTION_RANK, PRIMARY_MENU_SECTION_RANK, COPY_MENU_SECTION_RANK, DELETE_SECTION_RANK, MOVE_BLOCK_SECTION_RANK, ADD_BLOCKS_MENU_SECTION_RANK, } from './rank-deprecated';
|
|
6
6
|
export { createBlockLinkHashValue, DEFAULT_BLOCK_LINK_HASH_PREFIX, extractBlockIdFromLinkHash, isBlockLinkHash, } from './block-link';
|
|
7
|
+
export { expandAllParentsThenScroll, findParentExpands, isExpandCollapsed, expandElement, findNodeWithExpandParents, SCROLL_TO_BLOCK_TIMING, getLocalIdSelector, } from './scroll-to-block-utils';
|
|
8
|
+
export type { NodeWithExpandParents } from './scroll-to-block-utils';
|
|
7
9
|
export type { BlockMenuPlacement } from './placement';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for scrolling to block elements with expand node support.
|
|
3
|
+
* Used by both Confluence's useScrollOnUrlChange and platform renderer's useScrollToBlock.
|
|
4
|
+
*/
|
|
5
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
6
|
+
/**
|
|
7
|
+
* Timing constants for expand animation and DOM update delays.
|
|
8
|
+
* These values are tuned for the expand component's behavior and React's update cycle.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCROLL_TO_BLOCK_TIMING: {
|
|
11
|
+
/** Minimal delay for DOM/React updates after expanding (no animation in expand component). */
|
|
12
|
+
readonly DOM_UPDATE_DELAY: 50;
|
|
13
|
+
/** Delay when expand operation fails and needs retry. */
|
|
14
|
+
readonly RETRY_DELAY: 100;
|
|
15
|
+
/** Maximum number of retry attempts before giving up and scrolling anyway. */
|
|
16
|
+
readonly MAX_ATTEMPTS: 5;
|
|
17
|
+
/** Maximum depth of nested expands to search (prevents infinite loops). */
|
|
18
|
+
readonly MAX_EXPAND_DEPTH: 2;
|
|
19
|
+
};
|
|
20
|
+
export type NodeWithExpandParents = {
|
|
21
|
+
/** Array of expand parent localIds (empty if no expand parents, ordered from outermost to innermost). */
|
|
22
|
+
expandParentLocalIds: string[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Find a node by its localId in an ADF document and determine if it has expand or nestedExpand parents.
|
|
26
|
+
* This is used to identify nodes that may be hidden inside collapsed expands.
|
|
27
|
+
*
|
|
28
|
+
* @param adfDoc - The ADF document to search
|
|
29
|
+
* @param targetLocalId - The localId to search for
|
|
30
|
+
* @returns NodeWithExpandParents if found, undefined otherwise
|
|
31
|
+
*/
|
|
32
|
+
export declare function findNodeWithExpandParents(adfDoc: DocNode, targetLocalId: string): NodeWithExpandParents | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Find all parent expand elements that contain the target element.
|
|
35
|
+
* Searches up the DOM tree to find expand or nestedExpand containers.
|
|
36
|
+
*
|
|
37
|
+
* This function limits the search depth to prevent infinite loops and performance issues.
|
|
38
|
+
* The default maxDepth of 2 is chosen because:
|
|
39
|
+
* - Most use cases have 0-2 levels of nesting
|
|
40
|
+
* - Searching deeper can impact performance
|
|
41
|
+
* - Users rarely nest expands more than 2 levels deep
|
|
42
|
+
*
|
|
43
|
+
* @param element - The target element to find parents for.
|
|
44
|
+
* @param maxDepth - Maximum depth to search (default: 2). This is the maximum number of
|
|
45
|
+
* expand ancestors to find, starting from the target element.
|
|
46
|
+
* @returns Array of expand containers ordered from outermost to innermost.
|
|
47
|
+
* For example, if element is inside expand B which is inside expand A,
|
|
48
|
+
* this returns [expandA, expandB].
|
|
49
|
+
*/
|
|
50
|
+
export declare const findParentExpands: (element: HTMLElement, maxDepth?: number) => HTMLElement[];
|
|
51
|
+
/**
|
|
52
|
+
* Check if an expand node is currently collapsed.
|
|
53
|
+
*
|
|
54
|
+
* Uses two methods to determine collapse state:
|
|
55
|
+
* 1. First checks aria-expanded attribute on the toggle button (most reliable).
|
|
56
|
+
* 2. Falls back to checking content div visibility via computed styles.
|
|
57
|
+
*
|
|
58
|
+
* @param expandContainer - The expand container element.
|
|
59
|
+
* @returns True if the expand is collapsed, false if expanded or state cannot be determined.
|
|
60
|
+
*/
|
|
61
|
+
export declare const isExpandCollapsed: (expandContainer: HTMLElement) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Expand a collapsed expand node by clicking its toggle button.
|
|
64
|
+
*
|
|
65
|
+
* This function finds the toggle button with aria-expanded="false" and programmatically
|
|
66
|
+
* clicks it to expand the node. It does not wait for the expansion to complete.
|
|
67
|
+
*
|
|
68
|
+
* @param expandContainer - The expand container element.
|
|
69
|
+
* @returns True if the toggle button was found and clicked, false otherwise.
|
|
70
|
+
*/
|
|
71
|
+
export declare const expandElement: (expandContainer: HTMLElement) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Expand all parent expands then scroll to the element.
|
|
74
|
+
*
|
|
75
|
+
* This is the main entry point for scrolling to elements that may be hidden inside collapsed expands.
|
|
76
|
+
* It handles nested expands by expanding them one at a time from outermost to innermost,
|
|
77
|
+
* waiting for DOM updates between each expansion.
|
|
78
|
+
*
|
|
79
|
+
* The function uses a recursive approach with retry logic to handle:
|
|
80
|
+
* - Nested expands that need sequential expansion
|
|
81
|
+
* - DOM updates that may take time to reflect
|
|
82
|
+
* - Failed expand operations (e.g., if toggle button is temporarily unavailable)
|
|
83
|
+
* - Disconnected elements (removed from DOM)
|
|
84
|
+
*
|
|
85
|
+
* After all parent expands are open (or max attempts reached), scrolls the element into view
|
|
86
|
+
* with smooth behavior and centered in the viewport.
|
|
87
|
+
*
|
|
88
|
+
* @param element - The target element to scroll to.
|
|
89
|
+
* @param attempt - Current attempt number (used internally for retry logic, starts at 0).
|
|
90
|
+
* @returns A cleanup function that cancels any pending timeouts. Call this when the operation
|
|
91
|
+
* should be aborted (e.g., component unmount, navigation, or new scroll request).
|
|
92
|
+
*/
|
|
93
|
+
export declare const expandAllParentsThenScroll: (element: HTMLElement, attempt?: number) => (() => void);
|
|
94
|
+
export declare const getLocalIdSelector: (localId: string, container: HTMLElement) => HTMLElement | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "111.11.
|
|
3
|
+
"version": "111.11.9",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
75
75
|
"@atlaskit/react-ufo": "^5.1.0",
|
|
76
76
|
"@atlaskit/section-message": "^8.12.0",
|
|
77
|
-
"@atlaskit/smart-card": "^43.
|
|
77
|
+
"@atlaskit/smart-card": "^43.24.0",
|
|
78
78
|
"@atlaskit/smart-user-picker": "^8.9.0",
|
|
79
79
|
"@atlaskit/spinner": "^19.0.0",
|
|
80
80
|
"@atlaskit/status": "^3.1.0",
|
|
81
81
|
"@atlaskit/task-decision": "^19.2.0",
|
|
82
82
|
"@atlaskit/textfield": "^8.2.0",
|
|
83
83
|
"@atlaskit/theme": "^21.0.0",
|
|
84
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
84
|
+
"@atlaskit/tmp-editor-statsig": "^22.0.0",
|
|
85
85
|
"@atlaskit/tokens": "^11.0.0",
|
|
86
86
|
"@atlaskit/tooltip": "^20.14.0",
|
|
87
87
|
"@atlaskit/width-detector": "^5.0.0",
|