@superdoc-dev/react 1.0.0-canary.4 → 1.0.0-canary.6

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/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # @superdoc/react
1
+ # @superdoc-dev/react
2
2
 
3
3
  Official React wrapper for [SuperDoc](https://www.superdoc.dev).
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @superdoc/react
8
+ npm install @superdoc-dev/react
9
9
  ```
10
10
 
11
11
  > `superdoc` is included as a dependency - no need to install it separately.
@@ -13,8 +13,8 @@ npm install @superdoc/react
13
13
  ## Quick Start
14
14
 
15
15
  ```tsx
16
- import { SuperDocEditor } from '@superdoc/react';
17
- import '@superdoc/react/style.css';
16
+ import { SuperDocEditor } from '@superdoc-dev/react';
17
+ import '@superdoc-dev/react/style.css';
18
18
 
19
19
  function App() {
20
20
  return <SuperDocEditor document={file} />;
@@ -45,7 +45,7 @@ Access SuperDoc methods via `getInstance()`:
45
45
 
46
46
  ```tsx
47
47
  import { useRef } from 'react';
48
- import { SuperDocEditor, SuperDocRef } from '@superdoc/react';
48
+ import { SuperDocEditor, SuperDocRef } from '@superdoc-dev/react';
49
49
 
50
50
  function App() {
51
51
  const ref = useRef<SuperDocRef>(null);
@@ -134,7 +134,7 @@ function Editor() {
134
134
  import dynamic from 'next/dynamic';
135
135
 
136
136
  const SuperDocEditor = dynamic(
137
- () => import('@superdoc/react').then((m) => m.SuperDocEditor),
137
+ () => import('@superdoc-dev/react').then((m) => m.SuperDocEditor),
138
138
  { ssr: false }
139
139
  );
140
140
  ```
@@ -148,7 +148,7 @@ import type {
148
148
  DocumentMode,
149
149
  UserRole,
150
150
  SuperDocUser,
151
- } from '@superdoc/react';
151
+ } from '@superdoc-dev/react';
152
152
  ```
153
153
 
154
154
  Types are extracted from the `superdoc` package, ensuring they stay in sync.
package/dist/index.d.ts CHANGED
@@ -5,14 +5,42 @@
5
5
  */
6
6
 
7
7
  import { CSSProperties } from 'react';
8
+ import { Editor } from 'superdoc';
8
9
  import { ForwardRefExoticComponent } from 'react';
9
10
  import { ReactNode } from 'react';
10
11
  import { RefAttributes } from 'react';
11
12
  import { SuperDoc } from 'superdoc';
12
13
 
14
+ /**
15
+ * Explicitly typed callback props to ensure proper TypeScript inference.
16
+ * These override any loosely-typed callbacks from SuperDocConfig.
17
+ */
18
+ declare interface CallbackProps {
19
+ /** Callback when SuperDoc is ready */
20
+ onReady?: (event: SuperDocReadyEvent) => void;
21
+ /** Callback after an editor is created */
22
+ onEditorCreate?: (event: SuperDocEditorCreateEvent) => void;
23
+ /** Callback when editor is destroyed */
24
+ onEditorDestroy?: () => void;
25
+ /** Callback when document content is updated */
26
+ onEditorUpdate?: (event: SuperDocEditorUpdateEvent) => void;
27
+ /** Callback when there is a content parsing error */
28
+ onContentError?: (event: SuperDocContentErrorEvent) => void;
29
+ /** Callback when an exception is thrown */
30
+ onException?: (event: SuperDocExceptionEvent) => void;
31
+ }
32
+
13
33
  /** Document mode - extracted from Config.documentMode */
14
34
  export declare type DocumentMode = NonNullable<SuperDocConstructorConfig['documentMode']>;
15
35
 
36
+ export { Editor }
37
+
38
+ /**
39
+ * Callback props that are explicitly typed in CallbackProps.
40
+ * These are excluded from SuperDocConfig to avoid type conflicts.
41
+ */
42
+ declare type ExplicitCallbackProps = 'onReady' | 'onEditorCreate' | 'onEditorDestroy' | 'onEditorUpdate' | 'onContentError' | 'onException';
43
+
16
44
  /**
17
45
  * Props managed internally by the React component (not exposed to users).
18
46
  * - selector: managed by component (creates internal container)
@@ -45,7 +73,7 @@ declare interface ReactProps {
45
73
  export declare type SuperDocConfig = SuperDocConstructorConfig;
46
74
 
47
75
  /**
48
- * Types for @superdoc/react
76
+ * Types for @superdoc-dev/react
49
77
  *
50
78
  * Core types are extracted from the SuperDoc constructor parameter type,
51
79
  * ensuring they stay in sync with the superdoc package.
@@ -53,6 +81,14 @@ export declare type SuperDocConfig = SuperDocConstructorConfig;
53
81
  /** SuperDoc constructor config - extracted from superdoc package */
54
82
  declare type SuperDocConstructorConfig = ConstructorParameters<typeof SuperDoc>[0];
55
83
 
84
+ /** Event passed to onContentError callback */
85
+ export declare interface SuperDocContentErrorEvent {
86
+ error: Error;
87
+ editor: Editor;
88
+ documentId: string;
89
+ file: File;
90
+ }
91
+
56
92
  /**
57
93
  * SuperDocEditor component with forwardRef - Initializes SuperDoc instance and handles cleanup.
58
94
  */
@@ -60,16 +96,30 @@ declare const SuperDocEditor: ForwardRefExoticComponent<SuperDocEditorProps & Re
60
96
  export { SuperDocEditor }
61
97
  export default SuperDocEditor;
62
98
 
99
+ /** Event passed to onEditorCreate callback */
100
+ export declare interface SuperDocEditorCreateEvent {
101
+ editor: Editor;
102
+ }
103
+
63
104
  /**
64
105
  * Props for SuperDocEditor component.
65
106
  *
66
107
  * Extends SuperDocConfig (minus internal props) with React-specific additions.
67
108
  * When new props are added to SuperDoc core, they're automatically available here.
68
109
  *
69
- * Note: All callback types (onReady, onEditorCreate, etc.) come directly from
70
- * SuperDocConfig, ensuring type compatibility with the core package.
110
+ * Callback props are explicitly typed to ensure proper TypeScript inference.
71
111
  */
72
- export declare interface SuperDocEditorProps extends Omit<SuperDocConfig, InternalProps | OptionalInReact>, Partial<Pick<SuperDocConfig, OptionalInReact>>, ReactProps {
112
+ export declare interface SuperDocEditorProps extends Omit<SuperDocConfig, InternalProps | OptionalInReact | ExplicitCallbackProps>, Partial<Pick<SuperDocConfig, OptionalInReact>>, CallbackProps, ReactProps {
113
+ }
114
+
115
+ /** Event passed to onEditorUpdate callback */
116
+ export declare interface SuperDocEditorUpdateEvent {
117
+ editor: Editor;
118
+ }
119
+
120
+ /** Event passed to onException callback */
121
+ export declare interface SuperDocExceptionEvent {
122
+ error: Error;
73
123
  }
74
124
 
75
125
  /** SuperDoc instance type - from superdoc package */
@@ -78,6 +128,11 @@ export declare type SuperDocInstance = InstanceType<typeof SuperDoc>;
78
128
  /** Modules configuration - extracted from Config.modules */
79
129
  export declare type SuperDocModules = NonNullable<SuperDocConstructorConfig['modules']>;
80
130
 
131
+ /** Event passed to onReady callback */
132
+ export declare interface SuperDocReadyEvent {
133
+ superdoc: SuperDocInstance;
134
+ }
135
+
81
136
  /**
82
137
  * Ref interface for SuperDocEditor component
83
138
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/react",
3
- "version": "1.0.0-canary.4",
3
+ "version": "1.0.0-canary.6",
4
4
  "description": "Official React wrapper for SuperDoc document editor",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
package/style.css CHANGED
@@ -1,2 +1,2 @@
1
- /* @superdoc/react styles - re-exports superdoc styles */
1
+ /* @superdoc-dev/react styles - re-exports superdoc styles */
2
2
  @import 'superdoc/style.css';