@superdoc-dev/react 2.0.0-next.2 → 2.0.0-next.4

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
@@ -92,7 +92,8 @@ All [SuperDoc config options](https://docs.superdoc.dev) are available as props,
92
92
  |------|------|-------------|
93
93
  | `id` | `string` | Custom container ID (auto-generated if not provided) |
94
94
  | `renderLoading` | `() => ReactNode` | Loading UI |
95
- | `hideToolbar` | `boolean` | Hide toolbar (default: false) |
95
+ | `hideToolbar` | `boolean` | Hide toolbar (default: false). Older spelling of `ui.toolbar: false`; still wins when set |
96
+ | `contained` | `boolean` | Scroll inside a fixed-height parent (default: false) |
96
97
  | `className` | `string` | Wrapper CSS class |
97
98
  | `style` | `CSSProperties` | Wrapper inline styles |
98
99
 
@@ -104,8 +105,11 @@ These props cause the SuperDoc instance to be destroyed and recreated when chang
104
105
  - `user` - Current user identity
105
106
  - `users` - List of users
106
107
  - `modules` - Module configuration (collaboration, comments, etc.)
108
+ - `ui` - Built-in UI configuration (see below)
107
109
  - `role` - User permission level
108
110
  - `hideToolbar` - Toolbar visibility
111
+ - `contained` - Fixed-height container mode
112
+ - `id` - Editor and toolbar container identity
109
113
 
110
114
  ### Props Handled Efficiently
111
115
 
@@ -121,6 +125,22 @@ Other SuperDoc options (`rulers`, `pagination`, etc.) are applied only on initia
121
125
  ref.current?.getInstance()?.toggleRuler();
122
126
  ```
123
127
 
128
+ ### Built-in UI
129
+
130
+ `ui` controls which built-in surfaces SuperDoc renders. Omit it and everything behaves as it always has.
131
+
132
+ ```tsx
133
+ <SuperDocEditor document={file} ui={{ toolbar: false }} />
134
+ ```
135
+
136
+ - `ui={false}` renders no built-in UI at all: no toolbar, comments, or context menu. It does not disable editing, the Document API, or `superdoc.ui`, so it is the setting to reach for when the application draws its own interface.
137
+ - `ui={{ toolbar: false }}` turns off one surface and leaves the rest alone. Every key works this way, so a partial `ui` object stays additive.
138
+ - `ui={{ toolbar: { container: '#my-toolbar' } }}` mounts the built-in toolbar into an element you own. React then skips its own toolbar host rather than rendering an empty one.
139
+
140
+ `hideToolbar` predates this and still wins when set, so existing components keep working. Prefer `ui.toolbar: false` in new code: it says the same thing in the core configuration and applies across every framework.
141
+
142
+ Changing `ui` rebuilds the instance, as the list above notes. Pass a stable object (a module constant, or one wrapped in `useMemo`) rather than an inline literal, or every render will tear the editor down and recreate it.
143
+
124
144
  ### Common Props
125
145
 
126
146
  ```tsx
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`react/jsx-runtime`);function u(){let e=c.useRef(null);return e.current===null&&(e.current=`-${Date.now()}-${Math.random().toString(36).slice(2,9)}`),e.current}var d=c.useId;const f=typeof d==`function`?d:u;function p(e){let t=c.useRef(e),n=c.useRef(e);return t.current!==e&&(m(n.current,e)||(n.current=e),t.current=e),n.current}function m(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function h(e,t){let[n,r]=(0,c.useState)(!1),{id:i,renderLoading:a,hideToolbar:o=!1,contained:s=!1,className:u,style:d,onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S,document:C,user:w,users:T,modules:E,...D}=e,O=e.documentMode??`editing`,k=e.role??`editor`,A=p(w),j=p(T),M=(0,c.useRef)(null),N=(0,c.useRef)(null),P=f(),F=i??`superdoc${P}`,I=F,L=`${F}-toolbar`,[R,z]=(0,c.useState)(!0),B=(0,c.useRef)({onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S});(0,c.useEffect)(()=>{B.current={onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S}},[m,h,g,_,v,y,b,x,S]);let V=(0,c.useRef)(null),H=(0,c.useRef)(!1),U=(0,c.useRef)(O);(0,c.useEffect)(()=>{U.current!==O&&(M.current?M.current.setDocumentMode(O):H.current&&(V.current=O)),U.current=O},[O]),(0,c.useImperativeHandle)(t,()=>({getInstance:()=>M.current}),[]),(0,c.useEffect)(()=>{z(!0),r(!1),H.current=!0;let e=!1,t=null;return(async()=>{try{let n=(await import(`superdoc`)).SuperDoc;if(e)return;t=new n({...D,selector:`#${CSS.escape(I)}`,...!o&&N.current?{toolbar:`#${CSS.escape(L)}`}:{},documentMode:O,role:k,contained:s,...C==null?{}:{document:C},...A?{user:A}:{},...j?{users:j}:{},...E?{modules:E}:{},onReady:t=>{e||(z(!1),H.current=!1,V.current&&V.current!==O&&(t.superdoc.setDocumentMode(V.current),V.current=null),B.current.onReady?.(t))},onEditorCreate:t=>{e||B.current.onEditorCreate?.(t)},onEditorDestroy:()=>{e||B.current.onEditorDestroy?.()},onEditorUpdate:t=>{e||B.current.onEditorUpdate?.(t)},onTransaction:t=>{e||B.current.onTransaction?.(t)},onContentError:t=>{e||B.current.onContentError?.(t)},onException:t=>{e||B.current.onException?.(t)},onZoomChange:t=>{e||B.current.onZoomChange?.(t)},onViewportChange:t=>{e||B.current.onViewportChange?.(t)}}),M.current=t}catch(t){e||(H.current=!1,z(!1),r(!0),console.error(`[SuperDocEditor] Failed to initialize SuperDoc:`,t),B.current.onException?.({error:t}))}})(),()=>{H.current=!1,V.current=null,t&&(t.destroy(),M.current=null),e=!0}},[C,A,j,E,k,o,s,I,L]);let W=[`superdoc-wrapper`,u].filter(Boolean).join(` `),G=R?{display:`none`}:void 0;return(0,l.jsxs)(`div`,{className:W,style:{...d,...s&&{display:`flex`,flexDirection:`column`}},children:[!o&&(0,l.jsx)(`div`,{ref:N,id:L,className:`superdoc-toolbar-container`,style:G}),(0,l.jsx)(`div`,{id:I,className:`superdoc-editor-container`,style:{...G,...s&&{flex:1,minHeight:0}}}),R&&!n&&a&&(0,l.jsx)(`div`,{className:`superdoc-loading-container`,children:a()}),n&&(0,l.jsx)(`div`,{className:`superdoc-error-container`,children:`Failed to load editor. Check console for details.`})]})}const g=(0,c.forwardRef)(h);g.displayName=`SuperDocEditor`;var _=g;exports.SuperDocEditor=g,exports.default=_;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`react/jsx-runtime`);function u(){let e=c.useRef(null);return e.current===null&&(e.current=`-${Date.now()}-${Math.random().toString(36).slice(2,9)}`),e.current}var d=c.useId;const f=typeof d==`function`?d:u;function p(e){let t=c.useRef(e),n=c.useRef(e);return t.current!==e&&(m(n.current,e)||(n.current=e),t.current=e),n.current}function m(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function h(e,t){let[n,r]=(0,c.useState)(!1),{id:i,renderLoading:a,hideToolbar:o=!1,contained:s=!1,className:u,style:d,onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S,document:C,user:w,users:T,modules:E,ui:D,...O}=e,k=e.documentMode??`editing`,A=e.role??`editor`,j=D===!1?!1:D?.toolbar,M=typeof j==`object`&&!!j&&j.container!==void 0,N=!o&&j!==!1&&!M,P=(()=>{if(D===!1||D===void 0||!o)return D;let{toolbar:e,...t}=D;return{...t,toolbar:!1}})(),F=p(w),I=p(T),L=(0,c.useRef)(null),R=(0,c.useRef)(null),z=f(),B=i??`superdoc${z}`,V=B,H=`${B}-toolbar`,[U,W]=(0,c.useState)(!0),G=(0,c.useRef)({onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S});(0,c.useEffect)(()=>{G.current={onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S}},[m,h,g,_,v,y,b,x,S]);let K=(0,c.useRef)(null),q=(0,c.useRef)(!1),J=(0,c.useRef)(k);(0,c.useEffect)(()=>{J.current!==k&&(L.current?L.current.setDocumentMode(k):q.current&&(K.current=k)),J.current=k},[k]),(0,c.useImperativeHandle)(t,()=>({getInstance:()=>L.current}),[]),(0,c.useEffect)(()=>{W(!0),r(!1),q.current=!0;let e=!1,t=null;return(async()=>{try{let n=(await import(`superdoc`)).SuperDoc;if(e)return;t=new n({...O,selector:`#${CSS.escape(V)}`,...N&&R.current?{toolbar:`#${CSS.escape(H)}`}:{},documentMode:k,role:A,contained:s,...C==null?{}:{document:C},...F?{user:F}:{},...I?{users:I}:{},...E?{modules:E}:{},...P===void 0?{}:{ui:P},onReady:t=>{e||(W(!1),q.current=!1,K.current&&K.current!==k&&(t.superdoc.setDocumentMode(K.current),K.current=null),G.current.onReady?.(t))},onEditorCreate:t=>{e||G.current.onEditorCreate?.(t)},onEditorDestroy:()=>{e||G.current.onEditorDestroy?.()},onEditorUpdate:t=>{e||G.current.onEditorUpdate?.(t)},onTransaction:t=>{e||G.current.onTransaction?.(t)},onContentError:t=>{e||G.current.onContentError?.(t)},onException:t=>{e||G.current.onException?.(t)},onZoomChange:t=>{e||G.current.onZoomChange?.(t)},onViewportChange:t=>{e||G.current.onViewportChange?.(t)}}),L.current=t}catch(t){e||(q.current=!1,W(!1),r(!0),console.error(`[SuperDocEditor] Failed to initialize SuperDoc:`,t),G.current.onException?.({error:t}))}})(),()=>{q.current=!1,K.current=null,t&&(t.destroy(),L.current=null),e=!0}},[C,F,I,E,D,A,o,s,V,H]);let Y=[`superdoc-wrapper`,u].filter(Boolean).join(` `),X=U?{display:`none`}:void 0;return(0,l.jsxs)(`div`,{className:Y,style:{...d,...s&&{display:`flex`,flexDirection:`column`}},children:[N&&(0,l.jsx)(`div`,{ref:R,id:H,className:`superdoc-toolbar-container`,style:X}),(0,l.jsx)(`div`,{id:V,className:`superdoc-editor-container`,style:{...X,...s&&{flex:1,minHeight:0}}}),U&&!n&&a&&(0,l.jsx)(`div`,{className:`superdoc-loading-container`,children:a()}),n&&(0,l.jsx)(`div`,{className:`superdoc-error-container`,children:`Failed to load editor. Check console for details.`})]})}const g=(0,c.forwardRef)(h);g.displayName=`SuperDocEditor`;var _=g;exports.SuperDocEditor=g,exports.default=_;
package/dist/index.d.ts CHANGED
@@ -62,7 +62,16 @@ declare interface ReactProps {
62
62
  id?: string;
63
63
  /** Render function for loading state */
64
64
  renderLoading?: () => ReactNode;
65
- /** Hide the toolbar container. When true, no toolbar is rendered. @default false */
65
+ /**
66
+ * Hide the toolbar container. When true, no toolbar is rendered.
67
+ *
68
+ * Prefer `ui.toolbar: false`, which says this in the core configuration and
69
+ * applies to every framework. `ui: false` also hides the toolbar, but it
70
+ * turns off every built-in surface — comments, context menu, and the rest —
71
+ * so reach for it only when the application owns the whole interface.
72
+ *
73
+ * This prop is the older spelling and still wins when set. @default false
74
+ */
66
75
  hideToolbar?: boolean;
67
76
  /** Enable contained mode for fixed-height container embedding. When true, SuperDoc
68
77
  * fits within its parent's height and scrolls internally. @default false */
@@ -104,7 +113,7 @@ export declare type SuperDocContentErrorEvent = Parameters<NonNullable<SuperDocC
104
113
  /**
105
114
  * SuperDocEditor component with forwardRef - Initializes SuperDoc instance and handles cleanup.
106
115
  */
107
- declare const SuperDocEditor: ForwardRefExoticComponent<SuperDocEditorProps & RefAttributes<SuperDocRef>>;
116
+ declare const SuperDocEditor: ForwardRefExoticComponent<Omit<SuperDocEditorProps, "ref"> & RefAttributes<SuperDocRef>>;
108
117
  export { SuperDocEditor }
109
118
  export default SuperDocEditor;
110
119
 
package/dist/index.js CHANGED
@@ -2,49 +2,57 @@ import * as React from "react";
2
2
  import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  function useIdPolyfill() {
5
- let s = React.useRef(null);
6
- return s.current === null && (s.current = `-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`), s.current;
5
+ let o = React.useRef(null);
6
+ return o.current === null && (o.current = `-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`), o.current;
7
7
  }
8
8
  var reactUseId = React.useId;
9
9
  const useStableId = typeof reactUseId == "function" ? reactUseId : useIdPolyfill;
10
- function useMemoByValue(s) {
11
- let c = React.useRef(s), l = React.useRef(s);
12
- return c.current !== s && (shallowJsonEqual(l.current, s) || (l.current = s), c.current = s), l.current;
10
+ function useMemoByValue(o) {
11
+ let s = React.useRef(o), c = React.useRef(o);
12
+ return s.current !== o && (shallowJsonEqual(c.current, o) || (c.current = o), s.current = o), c.current;
13
13
  }
14
- function shallowJsonEqual(e, s) {
15
- if (e === s) return !0;
16
- if (e == null || s == null) return e === s;
14
+ function shallowJsonEqual(e, o) {
15
+ if (e === o) return !0;
16
+ if (e == null || o == null) return e === o;
17
17
  try {
18
- return JSON.stringify(e) === JSON.stringify(s);
18
+ return JSON.stringify(e) === JSON.stringify(o);
19
19
  } catch {
20
20
  return !1;
21
21
  }
22
22
  }
23
- function SuperDocEditorInner(e, s) {
24
- let [u, d] = useState(!1), { id: f, renderLoading: p, hideToolbar: m = !1, contained: h = !1, className: g, style: _, onReady: v, onEditorCreate: y, onEditorDestroy: b, onEditorUpdate: x, onTransaction: S, onContentError: C, onException: w, onZoomChange: T, onViewportChange: E, document: D, user: O, users: k, modules: A, ...j } = e, M = e.documentMode ?? "editing", N = e.role ?? "editor", P = useMemoByValue(O), F = useMemoByValue(k), I = useRef(null), L = useRef(null), R = useStableId(), z = f ?? `superdoc${R}`, B = z, V = `${z}-toolbar`, [H, U] = useState(!0), W = useRef({
25
- onReady: v,
26
- onEditorCreate: y,
27
- onEditorDestroy: b,
28
- onEditorUpdate: x,
29
- onTransaction: S,
30
- onContentError: C,
31
- onException: w,
32
- onZoomChange: T,
33
- onViewportChange: E
23
+ function SuperDocEditorInner(e, o) {
24
+ let [l, u] = useState(!1), { id: d, renderLoading: f, hideToolbar: p = !1, contained: m = !1, className: h, style: g, onReady: _, onEditorCreate: v, onEditorDestroy: y, onEditorUpdate: b, onTransaction: x, onContentError: S, onException: C, onZoomChange: w, onViewportChange: T, document: E, user: D, users: O, modules: k, ui: A, ...j } = e, M = e.documentMode ?? "editing", N = e.role ?? "editor", P = A === !1 ? !1 : A?.toolbar, F = typeof P == "object" && !!P && P.container !== void 0, I = !p && P !== !1 && !F, L = (() => {
25
+ if (A === !1 || A === void 0 || !p) return A;
26
+ let { toolbar: e, ...o } = A;
27
+ return {
28
+ ...o,
29
+ toolbar: !1
30
+ };
31
+ })(), R = useMemoByValue(D), z = useMemoByValue(O), B = useRef(null), V = useRef(null), H = useStableId(), U = d ?? `superdoc${H}`, W = U, G = `${U}-toolbar`, [K, q] = useState(!0), J = useRef({
32
+ onReady: _,
33
+ onEditorCreate: v,
34
+ onEditorDestroy: y,
35
+ onEditorUpdate: b,
36
+ onTransaction: x,
37
+ onContentError: S,
38
+ onException: C,
39
+ onZoomChange: w,
40
+ onViewportChange: T
34
41
  });
35
42
  useEffect(() => {
36
- W.current = {
37
- onReady: v,
38
- onEditorCreate: y,
39
- onEditorDestroy: b,
40
- onEditorUpdate: x,
41
- onTransaction: S,
42
- onContentError: C,
43
- onException: w,
44
- onZoomChange: T,
45
- onViewportChange: E
43
+ J.current = {
44
+ onReady: _,
45
+ onEditorCreate: v,
46
+ onEditorDestroy: y,
47
+ onEditorUpdate: b,
48
+ onTransaction: x,
49
+ onContentError: S,
50
+ onException: C,
51
+ onZoomChange: w,
52
+ onViewportChange: T
46
53
  };
47
54
  }, [
55
+ _,
48
56
  v,
49
57
  y,
50
58
  b,
@@ -52,108 +60,109 @@ function SuperDocEditorInner(e, s) {
52
60
  S,
53
61
  C,
54
62
  w,
55
- T,
56
- E
63
+ T
57
64
  ]);
58
- let G = useRef(null), K = useRef(!1), q = useRef(M);
65
+ let Y = useRef(null), X = useRef(!1), Z = useRef(M);
59
66
  useEffect(() => {
60
- q.current !== M && (I.current ? I.current.setDocumentMode(M) : K.current && (G.current = M)), q.current = M;
61
- }, [M]), useImperativeHandle(s, () => ({ getInstance: () => I.current }), []), useEffect(() => {
62
- U(!0), d(!1), K.current = !0;
63
- let e = !1, s = null;
67
+ Z.current !== M && (B.current ? B.current.setDocumentMode(M) : X.current && (Y.current = M)), Z.current = M;
68
+ }, [M]), useImperativeHandle(o, () => ({ getInstance: () => B.current }), []), useEffect(() => {
69
+ q(!0), u(!1), X.current = !0;
70
+ let e = !1, o = null;
64
71
  return (async () => {
65
72
  try {
66
- let c = (await import("superdoc")).SuperDoc;
73
+ let s = (await import("superdoc")).SuperDoc;
67
74
  if (e) return;
68
- s = new c({
75
+ o = new s({
69
76
  ...j,
70
- selector: `#${CSS.escape(B)}`,
71
- ...!m && L.current ? { toolbar: `#${CSS.escape(V)}` } : {},
77
+ selector: `#${CSS.escape(W)}`,
78
+ ...I && V.current ? { toolbar: `#${CSS.escape(G)}` } : {},
72
79
  documentMode: M,
73
80
  role: N,
74
- contained: h,
75
- ...D == null ? {} : { document: D },
76
- ...P ? { user: P } : {},
77
- ...F ? { users: F } : {},
78
- ...A ? { modules: A } : {},
79
- onReady: (s) => {
80
- e || (U(!1), K.current = !1, G.current && G.current !== M && (s.superdoc.setDocumentMode(G.current), G.current = null), W.current.onReady?.(s));
81
+ contained: m,
82
+ ...E == null ? {} : { document: E },
83
+ ...R ? { user: R } : {},
84
+ ...z ? { users: z } : {},
85
+ ...k ? { modules: k } : {},
86
+ ...L === void 0 ? {} : { ui: L },
87
+ onReady: (o) => {
88
+ e || (q(!1), X.current = !1, Y.current && Y.current !== M && (o.superdoc.setDocumentMode(Y.current), Y.current = null), J.current.onReady?.(o));
81
89
  },
82
- onEditorCreate: (s) => {
83
- e || W.current.onEditorCreate?.(s);
90
+ onEditorCreate: (o) => {
91
+ e || J.current.onEditorCreate?.(o);
84
92
  },
85
93
  onEditorDestroy: () => {
86
- e || W.current.onEditorDestroy?.();
94
+ e || J.current.onEditorDestroy?.();
87
95
  },
88
- onEditorUpdate: (s) => {
89
- e || W.current.onEditorUpdate?.(s);
96
+ onEditorUpdate: (o) => {
97
+ e || J.current.onEditorUpdate?.(o);
90
98
  },
91
- onTransaction: (s) => {
92
- e || W.current.onTransaction?.(s);
99
+ onTransaction: (o) => {
100
+ e || J.current.onTransaction?.(o);
93
101
  },
94
- onContentError: (s) => {
95
- e || W.current.onContentError?.(s);
102
+ onContentError: (o) => {
103
+ e || J.current.onContentError?.(o);
96
104
  },
97
- onException: (s) => {
98
- e || W.current.onException?.(s);
105
+ onException: (o) => {
106
+ e || J.current.onException?.(o);
99
107
  },
100
- onZoomChange: (s) => {
101
- e || W.current.onZoomChange?.(s);
108
+ onZoomChange: (o) => {
109
+ e || J.current.onZoomChange?.(o);
102
110
  },
103
- onViewportChange: (s) => {
104
- e || W.current.onViewportChange?.(s);
111
+ onViewportChange: (o) => {
112
+ e || J.current.onViewportChange?.(o);
105
113
  }
106
- }), I.current = s;
107
- } catch (s) {
108
- e || (K.current = !1, U(!1), d(!0), console.error("[SuperDocEditor] Failed to initialize SuperDoc:", s), W.current.onException?.({ error: s }));
114
+ }), B.current = o;
115
+ } catch (o) {
116
+ e || (X.current = !1, q(!1), u(!0), console.error("[SuperDocEditor] Failed to initialize SuperDoc:", o), J.current.onException?.({ error: o }));
109
117
  }
110
118
  })(), () => {
111
- K.current = !1, G.current = null, s && (s.destroy(), I.current = null), e = !0;
119
+ X.current = !1, Y.current = null, o && (o.destroy(), B.current = null), e = !0;
112
120
  };
113
121
  }, [
114
- D,
115
- P,
116
- F,
122
+ E,
123
+ R,
124
+ z,
125
+ k,
117
126
  A,
118
127
  N,
128
+ p,
119
129
  m,
120
- h,
121
- B,
122
- V
130
+ W,
131
+ G
123
132
  ]);
124
- let J = ["superdoc-wrapper", g].filter(Boolean).join(" "), Y = H ? { display: "none" } : void 0;
133
+ let Q = ["superdoc-wrapper", h].filter(Boolean).join(" "), $ = K ? { display: "none" } : void 0;
125
134
  return /* @__PURE__ */ jsxs("div", {
126
- className: J,
135
+ className: Q,
127
136
  style: {
128
- ..._,
129
- ...h && {
137
+ ...g,
138
+ ...m && {
130
139
  display: "flex",
131
140
  flexDirection: "column"
132
141
  }
133
142
  },
134
143
  children: [
135
- !m && /* @__PURE__ */ jsx("div", {
136
- ref: L,
137
- id: V,
144
+ I && /* @__PURE__ */ jsx("div", {
145
+ ref: V,
146
+ id: G,
138
147
  className: "superdoc-toolbar-container",
139
- style: Y
148
+ style: $
140
149
  }),
141
150
  /* @__PURE__ */ jsx("div", {
142
- id: B,
151
+ id: W,
143
152
  className: "superdoc-editor-container",
144
153
  style: {
145
- ...Y,
146
- ...h && {
154
+ ...$,
155
+ ...m && {
147
156
  flex: 1,
148
157
  minHeight: 0
149
158
  }
150
159
  }
151
160
  }),
152
- H && !u && p && /* @__PURE__ */ jsx("div", {
161
+ K && !l && f && /* @__PURE__ */ jsx("div", {
153
162
  className: "superdoc-loading-container",
154
- children: p()
163
+ children: f()
155
164
  }),
156
- u && /* @__PURE__ */ jsx("div", {
165
+ l && /* @__PURE__ */ jsx("div", {
157
166
  className: "superdoc-error-container",
158
167
  children: "Failed to load editor. Check console for details."
159
168
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/react",
3
- "version": "2.0.0-next.2",
3
+ "version": "2.0.0-next.4",
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": "2.0.0-next.26"
30
+ "superdoc": "2.4.0-next.6"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=16.8.0",
34
34
  "react-dom": ">=16.8.0",
35
- "superdoc": "2.0.0-next.26"
35
+ "superdoc": "2.4.0-next.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@testing-library/react": "^16.3.0",
@@ -61,13 +61,13 @@
61
61
  },
62
62
  "repository": {
63
63
  "type": "git",
64
- "url": "git+https://github.com/superdoc-dev/superdoc.git",
64
+ "url": "git+https://github.com/superdoc/docx-editor.git",
65
65
  "directory": "packages/react"
66
66
  },
67
67
  "bugs": {
68
- "url": "https://github.com/superdoc-dev/superdoc/issues"
68
+ "url": "https://github.com/superdoc/docx-editor/issues"
69
69
  },
70
- "homepage": "https://github.com/superdoc-dev/superdoc/tree/main/packages/react#readme",
70
+ "homepage": "https://github.com/superdoc/docx-editor/tree/main/packages/react#readme",
71
71
  "scripts": {
72
72
  "build": "vite build",
73
73
  "dev": "vite build --watch",