rayo-editor 0.0.1

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 (43) hide show
  1. package/README.md +563 -0
  2. package/dist/components/BlogEditor.d.ts +4 -0
  3. package/dist/components/BlogEditor.d.ts.map +1 -0
  4. package/dist/components/DiffOverlay.d.ts +4 -0
  5. package/dist/components/DiffOverlay.d.ts.map +1 -0
  6. package/dist/components/ImageGenerationLoader.d.ts +5 -0
  7. package/dist/components/ImageGenerationLoader.d.ts.map +1 -0
  8. package/dist/components/RayoEditor.d.ts +74 -0
  9. package/dist/components/RayoEditor.d.ts.map +1 -0
  10. package/dist/components/ReviewButtons.d.ts +4 -0
  11. package/dist/components/ReviewButtons.d.ts.map +1 -0
  12. package/dist/components/TitleTextarea.d.ts +4 -0
  13. package/dist/components/TitleTextarea.d.ts.map +1 -0
  14. package/dist/components/index.d.ts +7 -0
  15. package/dist/components/index.d.ts.map +1 -0
  16. package/dist/hooks/index.d.ts +3 -0
  17. package/dist/hooks/index.d.ts.map +1 -0
  18. package/dist/hooks/useContentProcessing.d.ts +83 -0
  19. package/dist/hooks/useContentProcessing.d.ts.map +1 -0
  20. package/dist/hooks/useEditorDiff.d.ts +65 -0
  21. package/dist/hooks/useEditorDiff.d.ts.map +1 -0
  22. package/dist/index.d.ts +213 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.mjs +1011 -0
  25. package/dist/index.umd.js +32 -0
  26. package/dist/styles.css +1150 -0
  27. package/dist/types/diff.types.d.ts +84 -0
  28. package/dist/types/diff.types.d.ts.map +1 -0
  29. package/dist/types/editor.types.d.ts +59 -0
  30. package/dist/types/editor.types.d.ts.map +1 -0
  31. package/dist/utils/contentProcessing.d.ts +81 -0
  32. package/dist/utils/contentProcessing.d.ts.map +1 -0
  33. package/dist/utils/diffDetection.d.ts +85 -0
  34. package/dist/utils/diffDetection.d.ts.map +1 -0
  35. package/dist/utils/errorHandling.d.ts +57 -0
  36. package/dist/utils/errorHandling.d.ts.map +1 -0
  37. package/dist/utils/imageHandling.d.ts +52 -0
  38. package/dist/utils/imageHandling.d.ts.map +1 -0
  39. package/dist/utils/index.d.ts +6 -0
  40. package/dist/utils/index.d.ts.map +1 -0
  41. package/dist/utils/proximityMatching.d.ts +80 -0
  42. package/dist/utils/proximityMatching.d.ts.map +1 -0
  43. package/package.json +70 -0
@@ -0,0 +1,3 @@
1
+ export { useEditorDiff } from './useEditorDiff';
2
+ export { useContentProcessing } from './useContentProcessing';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Hook for processing and transforming editor content
3
+ *
4
+ * Manages content state with processing status tracking and error handling.
5
+ * Useful for integrating with AI content transformation services or
6
+ * implementing custom content processing pipelines.
7
+ *
8
+ * @param initialContent - Initial content state (default: empty string)
9
+ * @returns Object with content state and processing utilities
10
+ *
11
+ * @returns {Object} Content processing state containing:
12
+ * - content: string - Current processed content
13
+ * - setContent: (content: string) => void - Directly set content
14
+ * - isProcessing: boolean - Whether processing is in progress
15
+ * - error: Error | null - Last processing error (if any)
16
+ * - processContent: (content: string) => void - Process and update content
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const {
21
+ * content,
22
+ * isProcessing,
23
+ * error,
24
+ * processContent
25
+ * } = useContentProcessing('Initial content');
26
+ *
27
+ * const handleAIEnhance = async () => {
28
+ * const enhanced = await fetch('/api/enhance', {
29
+ * method: 'POST',
30
+ * body: JSON.stringify({ content })
31
+ * }).then(r => r.json());
32
+ *
33
+ * processContent(enhanced.content);
34
+ * };
35
+ *
36
+ * return (
37
+ * <>
38
+ * {error && <div className="error">{error.message}</div>}
39
+ * <button onClick={handleAIEnhance} disabled={isProcessing}>
40
+ * {isProcessing ? 'Processing...' : 'Enhance'}
41
+ * </button>
42
+ * </>
43
+ * );
44
+ * ```
45
+ *
46
+ * @example
47
+ * With RayoEditor:
48
+ * ```tsx
49
+ * const { content, isProcessing, processContent } = useContentProcessing('');
50
+ *
51
+ * return (
52
+ * <RayoEditor
53
+ * content={content}
54
+ * title=""
55
+ * onChange={processContent}
56
+ * isLoading={isProcessing}
57
+ * editorRef={editorRef}
58
+ * />
59
+ * );
60
+ * ```
61
+ *
62
+ * @example
63
+ * Error handling:
64
+ * ```tsx
65
+ * const { content, isProcessing, error, processContent } = useContentProcessing();
66
+ *
67
+ * const safeProcess = useCallback((newContent: string) => {
68
+ * try {
69
+ * processContent(newContent);
70
+ * } catch (err) {
71
+ * console.error('Processing failed:', err);
72
+ * }
73
+ * }, [processContent]);
74
+ * ```
75
+ */
76
+ export declare const useContentProcessing: (initialContent?: string) => {
77
+ content: string;
78
+ setContent: import('react').Dispatch<import('react').SetStateAction<string>>;
79
+ isProcessing: boolean;
80
+ error: Error | null;
81
+ processContent: (newContent: string) => void;
82
+ };
83
+ //# sourceMappingURL=useContentProcessing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentProcessing.d.ts","sourceRoot":"","sources":["../../src/hooks/useContentProcessing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,eAAO,MAAM,oBAAoB,GAAI,iBAAgB,MAAW;;;;;iCAKd,MAAM;CAmBvD,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { DiffPair } from '../types/diff.types';
2
+ /**
3
+ * Hook for managing diff detection and overlay state
4
+ *
5
+ * Tracks detected diff pairs, active/hover indices, and overlay positioning.
6
+ * Automatically throttles diff updates to prevent excessive processing.
7
+ *
8
+ * @param editorRef - Reference to the editor instance
9
+ * @param options - Optional configuration
10
+ * @param options.focusMode - Enable focus mode UI (default: false)
11
+ * @returns Object with diff state and control functions
12
+ *
13
+ * @returns {Object} Diff state object containing:
14
+ * - diffPairs: DiffPair[] - Array of detected diff pairs
15
+ * - setDiffPairs: (pairs: DiffPair[]) => void - Update diff pairs
16
+ * - activePairIndex: number - Currently active pair index (-1 if none)
17
+ * - setActivePairIndex: (index: number) => void - Set active pair
18
+ * - hoverPairIndex: number - Currently hovered pair index
19
+ * - setHoverPairIndex: (index: number) => void - Set hovered pair
20
+ * - overlayHoleRect: Rect | null - Rectangle for overlay positioning
21
+ * - setOverlayHoleRect: (rect: Rect | null) => void - Set overlay position
22
+ * - updateDiffRanges: () => void - Trigger diff detection update
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * const {
27
+ * diffPairs,
28
+ * activePairIndex,
29
+ * hoverPairIndex,
30
+ * updateDiffRanges
31
+ * } = useEditorDiff(editorRef, { focusMode: false });
32
+ *
33
+ * // Update when needed
34
+ * useEffect(() => {
35
+ * updateDiffRanges();
36
+ * }, [content]);
37
+ * ```
38
+ *
39
+ * @example
40
+ * Interactive diff UI:
41
+ * ```tsx
42
+ * const {
43
+ * diffPairs,
44
+ * setActivePairIndex,
45
+ * setHoverPairIndex
46
+ * } = useEditorDiff(editorRef);
47
+ *
48
+ * // Use diffPairs to render interactive UI elements
49
+ * // with hover and click handlers
50
+ * ```
51
+ */
52
+ export declare const useEditorDiff: (_editorRef: any, _options?: {
53
+ focusMode?: boolean;
54
+ }) => {
55
+ diffPairs: DiffPair[];
56
+ setDiffPairs: import('react').Dispatch<import('react').SetStateAction<DiffPair[]>>;
57
+ activePairIndex: number;
58
+ setActivePairIndex: import('react').Dispatch<import('react').SetStateAction<number>>;
59
+ hoverPairIndex: number;
60
+ setHoverPairIndex: import('react').Dispatch<import('react').SetStateAction<number>>;
61
+ overlayHoleRect: any;
62
+ setOverlayHoleRect: import('react').Dispatch<any>;
63
+ updateDiffRanges: () => void;
64
+ };
65
+ //# sourceMappingURL=useEditorDiff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditorDiff.d.ts","sourceRoot":"","sources":["../../src/hooks/useEditorDiff.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,GAAG,EAAE,WAAW;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;CAwChF,CAAC"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * @fileoverview rayo-editor - A professional-grade rich text editor for React
3
+ *
4
+ * This module provides a complete rich text editing solution with:
5
+ * - Full HTML editing with TipTap
6
+ * - Diff highlighting and review UI
7
+ * - Image and table support
8
+ * - TypeScript definitions
9
+ * - Comprehensive utilities
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { RayoEditor } from 'rayo-editor';
14
+ * import 'rayo-editor/styles';
15
+ *
16
+ * <RayoEditor
17
+ * content={content}
18
+ * title={title}
19
+ * onChange={setContent}
20
+ * onTitleChange={setTitle}
21
+ * isLoading={false}
22
+ * editorRef={editorRef}
23
+ * />
24
+ * ```
25
+ */
26
+ /**
27
+ * Main Rayo Editor component - a drop-in rich blog editor
28
+ * Features diff highlighting, review UI, and full content control
29
+ */
30
+ export { RayoEditor } from './components';
31
+ /**
32
+ * Legacy BlogEditor component - alias for RayoEditor
33
+ * Maintained for backward compatibility
34
+ * @deprecated Use RayoEditor instead
35
+ */
36
+ export { BlogEditor } from './components';
37
+ /**
38
+ * Standalone title input component
39
+ * Supports read-only mode and custom change callbacks
40
+ */
41
+ export { TitleTextarea } from './components';
42
+ /**
43
+ * Visual overlay for displaying diff highlights
44
+ * Shows green additions and red deletions with interactive hover/click
45
+ */
46
+ export { DiffOverlay } from './components';
47
+ /**
48
+ * Accept/reject buttons for review operations
49
+ * Positioned absolutely with configurable placement
50
+ */
51
+ export { ReviewButtons } from './components';
52
+ /**
53
+ * Image loading state indicator with Rive animation
54
+ */
55
+ export { ImageGenerationLoader } from './components';
56
+ /**
57
+ * Hook for managing diff detection and overlay state
58
+ * Tracks diff pairs, active indices, and hover states
59
+ *
60
+ * @example
61
+ * ```tsx
62
+ * const {
63
+ * diffPairs,
64
+ * activePairIndex,
65
+ * updateDiffRanges
66
+ * } = useEditorDiff(editorRef, { focusMode: false });
67
+ * ```
68
+ */
69
+ export { useEditorDiff } from './hooks';
70
+ /**
71
+ * Hook for processing and transforming editor content
72
+ * Handles content state, processing flags, and error management
73
+ *
74
+ * @example
75
+ * ```tsx
76
+ * const { content, isProcessing, error, processContent } = useContentProcessing();
77
+ * ```
78
+ */
79
+ export { useContentProcessing } from './hooks';
80
+ /**
81
+ * Detect diff markers in HTML content
82
+ * Returns markers for insertions, deletions, and highlights
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * const { hasDiffs, markers } = detectDiffMarkers(content);
87
+ * ```
88
+ */
89
+ export { detectDiffMarkers } from './utils';
90
+ /**
91
+ * Normalize diff text for consistent comparison
92
+ * Strips HTML tags and normalizes whitespace
93
+ */
94
+ export { normalizeDiffText } from './utils';
95
+ /**
96
+ * Extract diff ranges from content
97
+ * Returns arrays of {from, to} positions for changes
98
+ */
99
+ export { extractDiffRanges } from './utils';
100
+ /**
101
+ * Merge consecutive or overlapping ranges
102
+ * Optimizes ranges for rendering and processing
103
+ */
104
+ export { mergeConsecutiveRanges } from './utils';
105
+ /**
106
+ * Extract plain text from HTML content
107
+ * Removes all tags and returns readable text
108
+ */
109
+ export { extractTextContent } from './utils';
110
+ /**
111
+ * Optimize ranges for rendering performance
112
+ * Removes overlaps and sorts by position
113
+ */
114
+ export { optimizeRanges } from './utils';
115
+ /**
116
+ * Group consecutive images in content
117
+ * Returns array of image operations with positions
118
+ */
119
+ export { groupConsecutiveImages } from './utils';
120
+ /**
121
+ * Match image replacements in diff pairs
122
+ * Identifies old→new image mappings
123
+ */
124
+ export { matchImageReplacements } from './utils';
125
+ /**
126
+ * Calculate proximity score between text segments
127
+ * Returns 0-1 similarity score
128
+ */
129
+ export { calculateProximity } from './utils';
130
+ /**
131
+ * Find the best matching text pair from candidates
132
+ * Uses proximity matching for robust matching
133
+ */
134
+ export { findOwnerTextPair } from './utils';
135
+ /**
136
+ * Group consecutive items by similarity
137
+ * Returns grouped arrays of related items
138
+ */
139
+ export { groupConsecutiveItems } from './utils';
140
+ /**
141
+ * Custom error class for diff processing failures
142
+ * Extends Error with original error chain
143
+ */
144
+ export { DiffProcessingError } from './utils';
145
+ /**
146
+ * Safely execute a function with error handling
147
+ * Returns result or null if error occurs
148
+ *
149
+ * @example
150
+ * ```tsx
151
+ * const result = safeExecute(() => riskyOperation());
152
+ * ```
153
+ */
154
+ export { safeExecute } from './utils';
155
+ /**
156
+ * Props for the RayoEditor component
157
+ * Includes all configuration, state, and callback options
158
+ */
159
+ export type { RayoEditorProps } from './types/editor.types';
160
+ /**
161
+ * Reference object for BlogSimpleEditor instance
162
+ * Provides access to underlying TipTap editor
163
+ */
164
+ export type { BlogSimpleEditorRef } from './types/editor.types';
165
+ /**
166
+ * Props for the TitleTextarea component
167
+ */
168
+ export type { TitleTextareaProps } from './types/editor.types';
169
+ /**
170
+ * Props for the DiffOverlay component
171
+ */
172
+ export type { DiffOverlayProps } from './types/editor.types';
173
+ /**
174
+ * Props for the ReviewButtons component
175
+ */
176
+ export type { ReviewButtonsProps } from './types/editor.types';
177
+ /**
178
+ * Represents a text range with start and end positions
179
+ */
180
+ export type { DiffRange } from './types/diff.types';
181
+ /**
182
+ * Represents a pair of diff ranges (old and new content)
183
+ */
184
+ export type { DiffPair } from './types/diff.types';
185
+ /**
186
+ * Rectangle coordinates for positioning overlays
187
+ */
188
+ export type { DiffRect } from './types/diff.types';
189
+ /**
190
+ * Marker indicating a diff location in content
191
+ */
192
+ export type { DiffMarker } from './types/diff.types';
193
+ /**
194
+ * Result object from diff marker detection
195
+ */
196
+ export type { DiffMarkerResult } from './types/diff.types';
197
+ /**
198
+ * Operation representing an image change
199
+ */
200
+ export type { ImageOperation } from './types/diff.types';
201
+ /**
202
+ * Operation representing a table change
203
+ */
204
+ export type { TableOperation } from './types/diff.types';
205
+ /**
206
+ * Operation representing a code block change
207
+ */
208
+ export type { CodeBlockOperation } from './types/diff.types';
209
+ /**
210
+ * Highlight information for rendering
211
+ */
212
+ export type { HighlightInfo } from './types/diff.types';
213
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;GAEG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;GAQG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AA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