@veltdev/lexical-velt-comments 4.5.2-beta.2 → 4.5.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/types/src/adapters/host/doc.d.ts +97 -0
- package/cjs/types/src/adapters/host/marks.d.ts +89 -0
- package/cjs/types/src/adapters/host/storage.d.ts +37 -0
- package/cjs/types/src/adapters/velt.d.ts +55 -0
- package/cjs/types/src/constants/common.d.ts +67 -0
- package/cjs/types/src/core/extension.d.ts +40 -0
- package/cjs/types/src/core/registry.d.ts +71 -0
- package/cjs/types/src/core/state.d.ts +86 -0
- package/cjs/types/src/features/addComment.d.ts +63 -0
- package/cjs/types/src/features/commentRenderer.d.ts +46 -0
- package/cjs/types/src/features/renderComments.d.ts +73 -0
- package/cjs/types/src/features/updateContent.d.ts +32 -0
- package/cjs/types/src/index.d.ts +26 -0
- package/cjs/types/src/types/common.d.ts +72 -0
- package/cjs/types/src/types/host.d.ts +65 -0
- package/cjs/types/src/types/state.d.ts +28 -0
- package/cjs/types/src/types/velt.d.ts +6 -0
- package/cjs/types/src/utils/common.d.ts +56 -0
- package/cjs/types/src/utils/console.d.ts +37 -0
- package/cjs/types/src/utils/host.d.ts +44 -0
- package/cjs/types/src/utils/serializer.d.ts +19 -0
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/types/src/adapters/host/doc.d.ts +97 -0
- package/esm/types/src/adapters/host/marks.d.ts +89 -0
- package/esm/types/src/adapters/host/storage.d.ts +37 -0
- package/esm/types/src/adapters/velt.d.ts +55 -0
- package/esm/types/src/constants/common.d.ts +67 -0
- package/esm/types/src/core/extension.d.ts +40 -0
- package/esm/types/src/core/registry.d.ts +71 -0
- package/esm/types/src/core/state.d.ts +86 -0
- package/esm/types/src/features/addComment.d.ts +63 -0
- package/esm/types/src/features/commentRenderer.d.ts +46 -0
- package/esm/types/src/features/renderComments.d.ts +73 -0
- package/esm/types/src/features/updateContent.d.ts +32 -0
- package/esm/types/src/index.d.ts +26 -0
- package/esm/types/src/types/common.d.ts +72 -0
- package/esm/types/src/types/host.d.ts +65 -0
- package/esm/types/src/types/state.d.ts +28 -0
- package/esm/types/src/types/velt.d.ts +6 -0
- package/esm/types/src/utils/common.d.ts +56 -0
- package/esm/types/src/utils/console.d.ts +37 -0
- package/esm/types/src/utils/host.d.ts +44 -0
- package/esm/types/src/utils/serializer.d.ts +19 -0
- package/index.d.ts +275 -26
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/cjs/types/comment-node.d.ts +0 -23
- package/cjs/types/constants.d.ts +0 -6
- package/cjs/types/editor.d.ts +0 -166
- package/cjs/types/index.d.ts +0 -24
- package/cjs/types/plugin.d.ts +0 -14
- package/cjs/types/serializer.d.ts +0 -5
- package/cjs/types/store.d.ts +0 -39
- package/cjs/types/types.d.ts +0 -40
- package/cjs/types/utility.d.ts +0 -122
- package/cjs/types/velt.d.ts +0 -21
- package/esm/types/comment-node.d.ts +0 -23
- package/esm/types/constants.d.ts +0 -6
- package/esm/types/editor.d.ts +0 -166
- package/esm/types/index.d.ts +0 -24
- package/esm/types/plugin.d.ts +0 -14
- package/esm/types/serializer.d.ts +0 -5
- package/esm/types/store.d.ts +0 -39
- package/esm/types/types.d.ts +0 -40
- package/esm/types/utility.d.ts +0 -122
- package/esm/types/velt.d.ts +0 -21
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render comments feature module.
|
|
3
|
+
*
|
|
4
|
+
* Purpose: Public API entry point for rendering comment annotations.
|
|
5
|
+
* Orchestrates state updates, subscriptions, and delegates to commentRenderer.
|
|
6
|
+
*
|
|
7
|
+
* Key responsibilities:
|
|
8
|
+
* - Update state with new annotations
|
|
9
|
+
* - Subscribe to selected annotations from Velt
|
|
10
|
+
* - Delegate rendering logic to commentRenderer
|
|
11
|
+
*
|
|
12
|
+
* Dependencies:
|
|
13
|
+
* - adapters/velt.ts (for Velt SDK subscription)
|
|
14
|
+
* - adapters/host/doc.ts (for editor setup)
|
|
15
|
+
* - core/state.ts (for state management)
|
|
16
|
+
* - core/registry.ts (for editor ID extraction)
|
|
17
|
+
* - features/commentRenderer.ts (for rendering logic)
|
|
18
|
+
* - types/velt.ts (for CommentAnnotation)
|
|
19
|
+
*
|
|
20
|
+
* IMPORTANT: This module MUST NOT import editor or Velt types directly.
|
|
21
|
+
* All SDK access goes through adapters.
|
|
22
|
+
*/
|
|
23
|
+
import type { RenderCommentsRequest } from '@/types/common';
|
|
24
|
+
/**
|
|
25
|
+
* Renders comment annotations as marks in the editor.
|
|
26
|
+
*
|
|
27
|
+
* This function renders comment annotations as visual marks in the editor.
|
|
28
|
+
* It filters annotations for the specific editor and applies marks accordingly.
|
|
29
|
+
*
|
|
30
|
+
* @param request - Object containing editor, editorId (optional), and commentAnnotations (optional)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Simple usage
|
|
35
|
+
* renderComments({ editor });
|
|
36
|
+
*
|
|
37
|
+
* // With editor ID
|
|
38
|
+
* renderComments({ editorId: 'my-editor', editor });
|
|
39
|
+
*
|
|
40
|
+
* // With annotations
|
|
41
|
+
* renderComments({
|
|
42
|
+
* editorId: 'my-editor',
|
|
43
|
+
* editor,
|
|
44
|
+
* commentAnnotations: [
|
|
45
|
+
* {
|
|
46
|
+
* annotationId: 'ann-123',
|
|
47
|
+
* context: {
|
|
48
|
+
* textEditorConfig: {
|
|
49
|
+
* text: 'Hello world',
|
|
50
|
+
* occurrence: 1,
|
|
51
|
+
* editorId: 'my-editor'
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ]
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* - Only annotations with matching editorId are rendered
|
|
61
|
+
* - Automatically subscribes to selected annotations changes
|
|
62
|
+
* - Filters out terminal/resolved comments unless they're selected
|
|
63
|
+
* - Removes marks when comments become resolved
|
|
64
|
+
* - Re-applies marks when resolved comments are selected
|
|
65
|
+
*/
|
|
66
|
+
export declare const renderComments: ({ editor, editorId, commentAnnotations, }: RenderCommentsRequest) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Cleans up subscriptions and renderer state for an editor.
|
|
69
|
+
* Should be called when editor is destroyed.
|
|
70
|
+
*
|
|
71
|
+
* @param editorId Unique identifier for the editor
|
|
72
|
+
*/
|
|
73
|
+
export declare const cleanupRenderComments: (editorId: string) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update content feature module.
|
|
3
|
+
*
|
|
4
|
+
* Purpose: Handle document changes and annotation context updates.
|
|
5
|
+
* Orchestrates adapters and core to detect and process annotation changes.
|
|
6
|
+
*
|
|
7
|
+
* Key responsibilities:
|
|
8
|
+
* - Detect document changes during transactions
|
|
9
|
+
* - Compare current state with original annotations
|
|
10
|
+
* - Detect content, occurrence, and container changes
|
|
11
|
+
* - Update Velt contexts for changed annotations
|
|
12
|
+
* - Update marks in editor if needed
|
|
13
|
+
*
|
|
14
|
+
* Dependencies:
|
|
15
|
+
* - adapters/host/doc.ts (for change detection)
|
|
16
|
+
* - adapters/velt.ts (for context updates)
|
|
17
|
+
* - adapters/host/marks.ts (for mark updates)
|
|
18
|
+
* - core/state.ts (for state access)
|
|
19
|
+
* - types/host.ts (for AnnotationChange)
|
|
20
|
+
*
|
|
21
|
+
* IMPORTANT: This module MUST NOT import Lexical or Velt types directly.
|
|
22
|
+
* All SDK access goes through adapters.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Handles content updates when document changes occur.
|
|
26
|
+
* Detects annotation changes and updates Velt contexts accordingly.
|
|
27
|
+
*
|
|
28
|
+
* @param editorId Unique identifier for the editor
|
|
29
|
+
* @param editor The editor instance
|
|
30
|
+
* @param transaction The transaction object
|
|
31
|
+
*/
|
|
32
|
+
export declare const handleContentUpdate: (editorId: string, editor: unknown, transaction: unknown) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for Lexical-Velt Comments extension.
|
|
3
|
+
*
|
|
4
|
+
* This module exports the public API surface for the v2 implementation.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { addComment, renderComments, CommentNode } from 'lexical-velt-comments';
|
|
9
|
+
*
|
|
10
|
+
* // Create editor with CommentNode registered
|
|
11
|
+
* const editor = createEditor({
|
|
12
|
+
* nodes: [CommentNode, ...otherNodes]
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Add a comment (auto-registers editor)
|
|
16
|
+
* await addComment({ editor, context: { customData: 'value' } });
|
|
17
|
+
*
|
|
18
|
+
* // Render existing comments (auto-registers editor)
|
|
19
|
+
* renderComments({ editor, commentAnnotations: annotations });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export { addComment } from '@/features/addComment';
|
|
23
|
+
export { renderComments } from '@/features/renderComments';
|
|
24
|
+
export type { AddCommentRequest, CommentAnnotationContext, LexicalVeltCommentConfig, RenderCommentsRequest } from '@/types/common';
|
|
25
|
+
export { CommentNode } from '@/adapters/host/marks';
|
|
26
|
+
export { exportJSONWithoutComments } from '@/utils/serializer';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common type definitions shared across the entire codebase.
|
|
3
|
+
* These types are SDK-agnostic and represent domain concepts.
|
|
4
|
+
*/
|
|
5
|
+
import type { CommentAnnotation } from '@/types/velt';
|
|
6
|
+
/**
|
|
7
|
+
* Context object for comment annotations.
|
|
8
|
+
* Contains text editor configuration and any additional context data.
|
|
9
|
+
*/
|
|
10
|
+
export interface CommentAnnotationContext {
|
|
11
|
+
textEditorConfig?: {
|
|
12
|
+
text: string;
|
|
13
|
+
occurrence: number;
|
|
14
|
+
editorId?: string;
|
|
15
|
+
targetTextNodeId?: string;
|
|
16
|
+
};
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for Lexical Velt Comments extension.
|
|
21
|
+
* Matches Tiptap's TiptapVeltCommentConfig structure.
|
|
22
|
+
*/
|
|
23
|
+
export interface LexicalVeltCommentConfig {
|
|
24
|
+
editorId?: string;
|
|
25
|
+
context?: CommentAnnotationContext;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Extension configuration options for LexicalVeltComments.
|
|
29
|
+
* Matches Tiptap's TiptapVeltCommentsOptions structure.
|
|
30
|
+
* Note: Lexical doesn't use HTMLAttributes or persistVeltMarks, but we keep the structure for consistency.
|
|
31
|
+
*/
|
|
32
|
+
export interface LexicalVeltCommentsOptions {
|
|
33
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
34
|
+
persistVeltMarks?: boolean;
|
|
35
|
+
editorId?: string;
|
|
36
|
+
context?: CommentAnnotationContext;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extension configuration for registry.
|
|
40
|
+
*/
|
|
41
|
+
export interface ExtensionConfig {
|
|
42
|
+
persistVeltMarks?: boolean;
|
|
43
|
+
editorId?: string;
|
|
44
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Request interface for addComment function.
|
|
48
|
+
* Matches legacy AddCommentRequest interface.
|
|
49
|
+
*/
|
|
50
|
+
export interface AddCommentRequest {
|
|
51
|
+
editorId?: string;
|
|
52
|
+
editor: unknown;
|
|
53
|
+
context?: CommentAnnotationContext;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request interface for renderComments function.
|
|
57
|
+
* Matches legacy RenderCommentsRequest interface.
|
|
58
|
+
*/
|
|
59
|
+
export interface RenderCommentsRequest {
|
|
60
|
+
editor: unknown;
|
|
61
|
+
editorId?: string;
|
|
62
|
+
commentAnnotations?: CommentAnnotation[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Editor context containing editor instance and related state.
|
|
66
|
+
* Note: Editor type is generic to avoid importing Lexical/Tiptap types here.
|
|
67
|
+
*/
|
|
68
|
+
export interface EditorContext<TEditor = unknown> {
|
|
69
|
+
editorId: string;
|
|
70
|
+
editor: TEditor;
|
|
71
|
+
config: ExtensionConfig;
|
|
72
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexical editor-specific type definitions
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY place where Lexical types may be imported.
|
|
5
|
+
* All other modules must use adapter interfaces instead of concrete Lexical types.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnnotationData } from '@/types/state';
|
|
8
|
+
/**
|
|
9
|
+
* Selection context extracted from editor
|
|
10
|
+
* Contains all information needed about the current selection
|
|
11
|
+
*/
|
|
12
|
+
export interface SelectionContext {
|
|
13
|
+
text: string;
|
|
14
|
+
from: number;
|
|
15
|
+
to: number;
|
|
16
|
+
occurrence: number;
|
|
17
|
+
targetTextNodeId?: string;
|
|
18
|
+
locationId?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Occurrence match found in document
|
|
22
|
+
* Represents one occurrence of a text pattern
|
|
23
|
+
*/
|
|
24
|
+
export interface OccurrenceMatch {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
occurrence: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Document change event
|
|
31
|
+
* Represents a change to the document content
|
|
32
|
+
*/
|
|
33
|
+
export interface DocumentChangeEvent {
|
|
34
|
+
type: 'insert' | 'delete' | 'replace';
|
|
35
|
+
from: number;
|
|
36
|
+
to: number;
|
|
37
|
+
insertedText?: string;
|
|
38
|
+
deletedText?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Represents a detected change to an annotation during document editing.
|
|
42
|
+
* Matches Tiptap's AnnotationChange interface.
|
|
43
|
+
*/
|
|
44
|
+
export interface AnnotationChange {
|
|
45
|
+
annotationId: string;
|
|
46
|
+
multiThreadAnnotationId?: string;
|
|
47
|
+
originalText: string;
|
|
48
|
+
currentText: string;
|
|
49
|
+
originalOccurrence: number;
|
|
50
|
+
currentOccurrence: number;
|
|
51
|
+
originalTargetTextNodeId: string;
|
|
52
|
+
newTargetTextNodeId: string;
|
|
53
|
+
annotation: AnnotationData;
|
|
54
|
+
contentChanged: boolean;
|
|
55
|
+
occurrenceChanged: boolean;
|
|
56
|
+
targetTextNodeIdChanged: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Text match interface for search results.
|
|
60
|
+
* Represents a range of text found in the document.
|
|
61
|
+
*/
|
|
62
|
+
export interface TextMatch {
|
|
63
|
+
start: number;
|
|
64
|
+
end: number;
|
|
65
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State management type definitions.
|
|
3
|
+
* These types represent the internal state structure for managing annotations.
|
|
4
|
+
*/
|
|
5
|
+
import type { CommentAnnotationContext } from '@/types/common';
|
|
6
|
+
import type { CommentAnnotation } from '@/types/velt';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a single annotation with its associated data and position.
|
|
9
|
+
*/
|
|
10
|
+
export interface AnnotationData {
|
|
11
|
+
annotationId: string;
|
|
12
|
+
multiThreadAnnotationId?: string;
|
|
13
|
+
context: CommentAnnotationContext;
|
|
14
|
+
position?: {
|
|
15
|
+
from: number;
|
|
16
|
+
to: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Complete annotation state for a single editor instance.
|
|
21
|
+
* Maintains annotations map, comment annotations array (with status), and selected annotations set.
|
|
22
|
+
*/
|
|
23
|
+
export interface AnnotationState {
|
|
24
|
+
annotations: Map<string, AnnotationData>;
|
|
25
|
+
commentAnnotations: CommentAnnotation[];
|
|
26
|
+
selectedAnnotations: Set<string>;
|
|
27
|
+
editorId: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure utility functions with zero side effects
|
|
3
|
+
*
|
|
4
|
+
* This module contains pure, testable utility functions extracted from src/utility.ts.
|
|
5
|
+
* These functions have NO dependencies on Lexical, Velt, or any external SDKs.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* KMP Search implementation for finding text patterns
|
|
9
|
+
*
|
|
10
|
+
* Pure function for efficient string pattern matching using the Knuth-Morris-Pratt algorithm.
|
|
11
|
+
* Migrated from src/utility.ts UtilityService.kmpSearch()
|
|
12
|
+
*
|
|
13
|
+
* @param text - The text to search in
|
|
14
|
+
* @param pattern - The pattern to search for
|
|
15
|
+
* @param startPos - Starting position offset (default: 0)
|
|
16
|
+
* @param maxOccurrences - Maximum number of occurrences to find (optional)
|
|
17
|
+
* @returns Array of positions where pattern was found
|
|
18
|
+
*/
|
|
19
|
+
export declare const kmpSearch: (text: string, pattern: string, startPos?: number, maxOccurrences?: number) => number[];
|
|
20
|
+
/**
|
|
21
|
+
* Compute KMP failure function table
|
|
22
|
+
*
|
|
23
|
+
* Pure function that computes the longest proper prefix which is also a suffix (LPS) table
|
|
24
|
+
* for the Knuth-Morris-Pratt algorithm.
|
|
25
|
+
* Migrated from src/utility.ts UtilityService.computeKMPTable()
|
|
26
|
+
*
|
|
27
|
+
* @param pattern - The pattern to compute table for
|
|
28
|
+
* @returns Array representing the failure function (LPS table)
|
|
29
|
+
*/
|
|
30
|
+
export declare const computeKMPTable: (pattern: string) => number[];
|
|
31
|
+
/**
|
|
32
|
+
* Find text occurrences in a string
|
|
33
|
+
*
|
|
34
|
+
* Convenience function that uses KMP search to find all occurrences.
|
|
35
|
+
*
|
|
36
|
+
* @param text - Text to search in
|
|
37
|
+
* @param searchText - Text to search for
|
|
38
|
+
* @returns Array of occurrence matches with start/end positions
|
|
39
|
+
*/
|
|
40
|
+
export declare const findTextOccurrences: (text: string, searchText: string) => Array<{
|
|
41
|
+
start: number;
|
|
42
|
+
end: number;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate occurrence index for a given position
|
|
46
|
+
*
|
|
47
|
+
* Determines which occurrence (1-indexed) a given position corresponds to.
|
|
48
|
+
*
|
|
49
|
+
* @param matches - Array of match positions with start/end
|
|
50
|
+
* @param position - Position to find occurrence for
|
|
51
|
+
* @returns 1-indexed occurrence number, or null if not found
|
|
52
|
+
*/
|
|
53
|
+
export declare const calculateOccurrenceIndex: (matches: Array<{
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
}>, position: number) => number | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console utility class providing controlled logging with debug mode support.
|
|
3
|
+
*
|
|
4
|
+
* Logging methods (log, warn, error, debug, info) are only active when debug mode
|
|
5
|
+
* is enabled via sessionStorage. The `catch` method always outputs as warnings
|
|
6
|
+
* for error handling visibility.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Console {
|
|
9
|
+
/** Log a message (only when debug mode is enabled via sessionStorage) */
|
|
10
|
+
static log: (...data: any[]) => void;
|
|
11
|
+
/** Log a warning (only when debug mode is enabled via sessionStorage) */
|
|
12
|
+
static warn: (...data: any[]) => void;
|
|
13
|
+
/** Log an error (only when debug mode is enabled via sessionStorage) */
|
|
14
|
+
static error: (...data: any[]) => void;
|
|
15
|
+
/** Log debug info (only when debug mode is enabled via sessionStorage) */
|
|
16
|
+
static debug: (...data: any[]) => void;
|
|
17
|
+
/** Log info (only when debug mode is enabled via sessionStorage) */
|
|
18
|
+
static info: (...data: any[]) => void;
|
|
19
|
+
/** Flag indicating if logging is enabled (used by catch method) */
|
|
20
|
+
static logsEnabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Log caught errors from try/catch blocks.
|
|
23
|
+
* Always outputs as console.warn with the LOG_PREFIX for visibility.
|
|
24
|
+
* Use this instead of console.error in catch blocks.
|
|
25
|
+
*
|
|
26
|
+
* @param message - Descriptive message about what operation failed
|
|
27
|
+
* @param error - Optional error object caught in the try/catch
|
|
28
|
+
*/
|
|
29
|
+
static catch: (message: string, error?: unknown) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Check if debug logging should be shown.
|
|
32
|
+
* Checks sessionStorage for debugMode or forceDebugMode flags.
|
|
33
|
+
*
|
|
34
|
+
* @returns true if debug mode is enabled, false otherwise
|
|
35
|
+
*/
|
|
36
|
+
static showLogs(): boolean;
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host editor-specific utility functions
|
|
3
|
+
*
|
|
4
|
+
* This module contains host editor-specific utility functions that are shared
|
|
5
|
+
* across multiple adapters. These functions depend on host editor types (Lexical).
|
|
6
|
+
*
|
|
7
|
+
* For pure utilities without host editor dependencies, see utils/common.ts
|
|
8
|
+
*/
|
|
9
|
+
import { type LexicalEditor, type LexicalNode, type TextNode } from 'lexical';
|
|
10
|
+
/**
|
|
11
|
+
* Collect all text content including paragraph breaks.
|
|
12
|
+
* Migrated from src/utility.ts UtilityService.collectTextContent()
|
|
13
|
+
*
|
|
14
|
+
* @param root - Root Lexical node to traverse
|
|
15
|
+
* @returns Object with combined text and node map
|
|
16
|
+
*/
|
|
17
|
+
export declare const collectTextContent: (root: LexicalNode) => {
|
|
18
|
+
combinedText: string;
|
|
19
|
+
nodeMap: Array<{
|
|
20
|
+
node: TextNode | null;
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
isParagraphBreak?: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Get text content for a specific container.
|
|
28
|
+
* Migrated from src/utility.ts UtilityService.getContainerTextContent()
|
|
29
|
+
*
|
|
30
|
+
* @param containerElement - DOM element representing the container
|
|
31
|
+
* @param editor - Lexical editor instance
|
|
32
|
+
* @param nodeMap - Node map from collectTextContent
|
|
33
|
+
* @param combinedText - Combined text from collectTextContent
|
|
34
|
+
* @returns Container text content with start offset, or null if not found
|
|
35
|
+
*/
|
|
36
|
+
export declare const getContainerTextContent: (containerElement: HTMLElement, editor: LexicalEditor, nodeMap: Array<{
|
|
37
|
+
node: TextNode | null;
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
isParagraphBreak?: boolean;
|
|
41
|
+
}>, combinedText: string) => {
|
|
42
|
+
text: string;
|
|
43
|
+
startOffset: number;
|
|
44
|
+
} | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializer utilities for Lexical editor state
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities for serializing Lexical editor state,
|
|
5
|
+
* particularly for removing comment nodes from serialized JSON.
|
|
6
|
+
*
|
|
7
|
+
* Migrated from src/serializer.ts
|
|
8
|
+
*/
|
|
9
|
+
import type { LexicalEditor, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
10
|
+
/**
|
|
11
|
+
* Export JSON without comment nodes.
|
|
12
|
+
*
|
|
13
|
+
* This function serializes the editor state and removes all comment nodes,
|
|
14
|
+
* unwrapping their children and normalizing adjacent text nodes.
|
|
15
|
+
*
|
|
16
|
+
* @param editor - Lexical editor instance
|
|
17
|
+
* @returns Serialized editor state without comment nodes
|
|
18
|
+
*/
|
|
19
|
+
export declare const exportJSONWithoutComments: (editor: LexicalEditor) => SerializedEditorState<SerializedLexicalNode>;
|