@superdoc-dev/react 1.16.0-next.1 → 2.0.0-next.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 (3) hide show
  1. package/README.md +10 -32
  2. package/dist/index.d.ts +32 -38
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -5,38 +5,12 @@ Official React wrapper for [SuperDoc](https://www.superdoc.dev).
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @superdoc-dev/react
8
+ pnpm add @superdoc-dev/react@next
9
9
  ```
10
10
 
11
- > `superdoc` is included as a dependency - no need to install it separately.
11
+ The V2 prerelease installs its matching `superdoc@2` version automatically.
12
12
 
13
- ## Pinning SuperDoc Version (Optional)
14
-
15
- If you need to force a specific `superdoc` version (for example, to align multiple apps or test a local build), pin it in your app's `package.json` using overrides.
16
-
17
- ### npm
18
-
19
- ```json
20
- {
21
- "overrides": {
22
- "superdoc": "1.14.1"
23
- }
24
- }
25
- ```
26
-
27
- ### pnpm
28
-
29
- ```json
30
- {
31
- "pnpm": {
32
- "overrides": {
33
- "superdoc": "1.14.1"
34
- }
35
- }
36
- }
37
- ```
38
-
39
- Then run your package manager install command again.
13
+ The React and SuperDoc V2 prereleases are released together and use exact matching versions. Do not override `superdoc` independently.
40
14
 
41
15
  ## Quick Start
42
16
 
@@ -191,9 +165,13 @@ function Editor() {
191
165
 
192
166
  ```tsx
193
167
  <SuperDocEditor
194
- document={file}
195
- modules={{
196
- collaboration: { ydoc, provider },
168
+ document={{
169
+ type: 'docx',
170
+ data: file,
171
+ v2Collaboration: {
172
+ documentId: 'contract-123',
173
+ serverUrl: 'wss://collab.example.com',
174
+ },
197
175
  }}
198
176
  />
199
177
  ```
package/dist/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import { CSSProperties } from 'react';
2
- import { Editor } from 'superdoc';
3
2
  import { ForwardRefExoticComponent } from 'react';
4
3
  import { ReactNode } from 'react';
5
4
  import { RefAttributes } from 'react';
6
5
  import { SuperDoc } from 'superdoc';
7
6
  import { SuperDocExceptionPayload } from 'superdoc';
8
- import { Transaction } from 'superdoc';
9
7
 
10
8
  /**
11
9
  * Explicitly typed callback props to ensure proper TypeScript inference.
@@ -35,8 +33,6 @@ export declare interface CallbackProps {
35
33
  /** Document mode - extracted from Config.documentMode */
36
34
  export declare type DocumentMode = NonNullable<SuperDocConstructorConfig['documentMode']>;
37
35
 
38
- export { Editor }
39
-
40
36
  /** Surface where an editor event originated. */
41
37
  export declare type EditorSurface = 'body' | 'header' | 'footer';
42
38
 
@@ -77,6 +73,12 @@ declare interface ReactProps {
77
73
  style?: CSSProperties;
78
74
  }
79
75
 
76
+ declare type SuperDocActiveEditor = NonNullable<SuperDocInstance['activeEditor']>;
77
+
78
+ declare type SuperDocActiveEditorDoc = SuperDocActiveEditor extends {
79
+ doc?: infer T;
80
+ } ? T : never;
81
+
80
82
  /** Full SuperDoc config - extracted from constructor */
81
83
  export declare type SuperDocConfig = SuperDocConstructorConfig;
82
84
 
@@ -107,9 +109,7 @@ export { SuperDocEditor }
107
109
  export default SuperDocEditor;
108
110
 
109
111
  /** Event passed to onEditorCreate callback */
110
- export declare interface SuperDocEditorCreateEvent {
111
- editor: Editor;
112
- }
112
+ export declare type SuperDocEditorCreateEvent = Parameters<NonNullable<SuperDocConfig['onEditorCreate']>>[0];
113
113
 
114
114
  /**
115
115
  * Props for SuperDocEditor component.
@@ -123,18 +123,7 @@ export declare interface SuperDocEditorProps extends Omit<SuperDocConfig, Intern
123
123
  }
124
124
 
125
125
  /** Event passed to onEditorUpdate callback. Mirrors superdoc's EditorUpdateEvent. */
126
- export declare interface SuperDocEditorUpdateEvent {
127
- /** The primary editor associated with the update. For header/footer edits, this is the main body editor. */
128
- editor: Editor;
129
- /** The editor instance that emitted the update. For body edits, this matches `editor`. */
130
- sourceEditor: Editor;
131
- /** The surface where the edit originated. */
132
- surface: EditorSurface;
133
- /** Relationship ID for header/footer edits. */
134
- headerId?: string | null;
135
- /** Header/footer variant (`default`, `first`, `even`, `odd`) when available. */
136
- sectionType?: string | null;
137
- }
126
+ export declare type SuperDocEditorUpdateEvent = Parameters<NonNullable<SuperDocConfig['onEditorUpdate']>>[0];
138
127
 
139
128
  /**
140
129
  * Event passed to onException callback. Re-exports the core union so
@@ -152,9 +141,7 @@ export declare type SuperDocInstance = InstanceType<typeof SuperDoc>;
152
141
  export declare type SuperDocModules = NonNullable<SuperDocConstructorConfig['modules']>;
153
142
 
154
143
  /** Event passed to onReady callback */
155
- export declare interface SuperDocReadyEvent {
156
- superdoc: SuperDocInstance;
157
- }
144
+ export declare type SuperDocReadyEvent = Parameters<NonNullable<SuperDocConfig['onReady']>>[0];
158
145
 
159
146
  /**
160
147
  * Ref interface for SuperDocEditor component
@@ -164,24 +151,31 @@ export declare interface SuperDocRef {
164
151
  getInstance(): SuperDocInstance | null;
165
152
  }
166
153
 
167
- /** Event passed to onTransaction callback. Mirrors superdoc's EditorTransactionEvent. */
168
- export declare interface SuperDocTransactionEvent {
169
- /** The primary editor associated with the transaction. For header/footer edits, this is the main body editor. */
170
- editor: Editor;
171
- /** The editor instance that emitted the transaction. For body edits, this matches `editor`. */
172
- sourceEditor: Editor;
173
- /** The ProseMirror transaction emitted by the source editor. */
174
- transaction: Transaction;
175
- /** Time spent applying the transaction, in milliseconds. */
176
- duration?: number;
177
- /** The surface where the transaction originated. */
178
- surface: EditorSurface;
179
- /** Relationship ID for header/footer edits. */
180
- headerId?: string | null;
181
- /** Header/footer variant (`default`, `first`, `even`, `odd`) when available. */
182
- sectionType?: string | null;
154
+ /**
155
+ * Runtime editor facade reported by `superdoc@2` callback events.
156
+ *
157
+ * v2 no longer exposes the v1 ProseMirror/Tiptap `Editor` type. Consumers that
158
+ * need document operations should use the SuperDoc instance and Document API;
159
+ * callback editor values are intentionally structural runtime evidence.
160
+ */
161
+ export declare interface SuperDocRuntimeEditor {
162
+ editorVersion?: 2;
163
+ /**
164
+ * The public, read-only-guarded browser Document API facade for the active
165
+ * editor in inline v2 mode (`editor.doc`). Derived from the `superdoc`
166
+ * instance type so this wrapper does not need its own Document API package
167
+ * dependency.
168
+ */
169
+ doc?: SuperDocActiveEditorDoc;
170
+ [key: string]: unknown;
183
171
  }
184
172
 
173
+ /** Transaction-like payload emitted by the runtime. v2 does not expose a ProseMirror transaction type. */
174
+ export declare type SuperDocRuntimeTransaction = unknown;
175
+
176
+ /** Event passed to onTransaction callback. Mirrors superdoc's EditorTransactionEvent. */
177
+ export declare type SuperDocTransactionEvent = Parameters<NonNullable<SuperDocConfig['onTransaction']>>[0];
178
+
185
179
  /** User object - extracted from Config.user */
186
180
  export declare type SuperDocUser = NonNullable<SuperDocConstructorConfig['user']>;
187
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/react",
3
- "version": "1.16.0-next.1",
3
+ "version": "2.0.0-next.1",
4
4
  "description": "Official React wrapper for the SuperDoc document editor",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -27,12 +27,12 @@
27
27
  ],
28
28
  "license": "AGPL-3.0",
29
29
  "dependencies": {
30
- "superdoc": ">=1.0.0"
30
+ "superdoc": "2.0.0-next.25"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=16.8.0",
34
34
  "react-dom": ">=16.8.0",
35
- "superdoc": ">=1.0.0"
35
+ "superdoc": "2.0.0-next.25"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@testing-library/react": "^16.3.0",