@superdoc-dev/react 1.11.0-next.41 → 1.11.0-next.43

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/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,editorVersion:D,editorIntegration:O,...k}=e,A=e.documentMode??`editing`,j=e.role??`editor`,M=p(w),N=p(T),P=(0,c.useRef)(null),F=(0,c.useRef)(null),I=f(),L=i??`superdoc${I}`,R=L,z=`${L}-toolbar`,[B,V]=(0,c.useState)(!0),H=(0,c.useRef)({onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S});(0,c.useEffect)(()=>{H.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 U=(0,c.useRef)(null),W=(0,c.useRef)(!1),G=(0,c.useRef)(A);(0,c.useEffect)(()=>{G.current!==A&&(P.current?P.current.setDocumentMode(A):W.current&&(U.current=A)),G.current=A},[A]),(0,c.useImperativeHandle)(t,()=>({getInstance:()=>P.current}),[]),(0,c.useEffect)(()=>{V(!0),r(!1),W.current=!0;let e=!1,t=null;return(async()=>{try{let n=(await import(`superdoc`)).SuperDoc;if(e)return;t=new n({...k,selector:`#${CSS.escape(R)}`,...!o&&F.current?{toolbar:`#${CSS.escape(z)}`}:{},documentMode:A,role:j,contained:s,...C==null?{}:{document:C},...M?{user:M}:{},...N?{users:N}:{},...E?{modules:E}:{},...D==null?{}:{editorVersion:D},...O==null?{}:{editorIntegration:O},onReady:t=>{e||(V(!1),W.current=!1,U.current&&U.current!==A&&(t.superdoc.setDocumentMode(U.current),U.current=null),H.current.onReady?.(t))},onEditorCreate:t=>{e||H.current.onEditorCreate?.(t)},onEditorDestroy:()=>{e||H.current.onEditorDestroy?.()},onEditorUpdate:t=>{e||H.current.onEditorUpdate?.(t)},onTransaction:t=>{e||H.current.onTransaction?.(t)},onContentError:t=>{e||H.current.onContentError?.(t)},onException:t=>{e||H.current.onException?.(t)},onZoomChange:t=>{e||H.current.onZoomChange?.(t)},onViewportChange:t=>{e||H.current.onViewportChange?.(t)}}),P.current=t}catch(t){e||(W.current=!1,V(!1),r(!0),console.error(`[SuperDocEditor] Failed to initialize SuperDoc:`,t),H.current.onException?.({error:t}))}})(),()=>{W.current=!1,U.current=null,t&&(t.destroy(),P.current=null),e=!0}},[C,M,N,E,j,o,s,D,O,R,z]);let K=[`superdoc-wrapper`,u].filter(Boolean).join(` `),q=B?{display:`none`}:void 0;return(0,l.jsxs)(`div`,{className:K,style:{...d,...s&&{display:`flex`,flexDirection:`column`}},children:[!o&&(0,l.jsx)(`div`,{ref:F,id:z,className:`superdoc-toolbar-container`,style:q}),(0,l.jsx)(`div`,{id:R,className:`superdoc-editor-container`,style:{...q,...s&&{flex:1,minHeight:0}}}),B&&!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,...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=_;
package/dist/index.d.ts CHANGED
@@ -37,16 +37,6 @@ export declare type DocumentMode = NonNullable<SuperDocConstructorConfig['docume
37
37
 
38
38
  export { Editor }
39
39
 
40
- /**
41
- * Explicitly typed editor implementation props.
42
- */
43
- declare interface EditorImplementationProps {
44
- /** Select the DOCX editor implementation. @default 1 */
45
- editorVersion?: 1 | 2;
46
- /** Private editor integration object or factory. Required when editorVersion is 2. */
47
- editorIntegration?: unknown;
48
- }
49
-
50
40
  /** Surface where an editor event originated. */
51
41
  export declare type EditorSurface = 'body' | 'header' | 'footer';
52
42
 
@@ -129,7 +119,7 @@ export declare interface SuperDocEditorCreateEvent {
129
119
  *
130
120
  * Callback props are explicitly typed to ensure proper TypeScript inference.
131
121
  */
132
- export declare interface SuperDocEditorProps extends Omit<SuperDocConfig, InternalProps | OptionalInReact | ExplicitCallbackProps | keyof EditorImplementationProps>, Partial<Pick<SuperDocConfig, OptionalInReact>>, EditorImplementationProps, CallbackProps, ReactProps {
122
+ export declare interface SuperDocEditorProps extends Omit<SuperDocConfig, InternalProps | OptionalInReact | ExplicitCallbackProps>, Partial<Pick<SuperDocConfig, OptionalInReact>>, CallbackProps, ReactProps {
133
123
  }
134
124
 
135
125
  /** Event passed to onEditorUpdate callback. Mirrors superdoc's EditorUpdateEvent. */
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ function shallowJsonEqual(e, s) {
21
21
  }
22
22
  }
23
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, editorVersion: j, editorIntegration: M, ...N } = e, P = e.documentMode ?? "editing", F = e.role ?? "editor", I = useMemoByValue(O), L = useMemoByValue(k), R = useRef(null), z = useRef(null), B = useStableId(), V = f ?? `superdoc${B}`, H = V, U = `${V}-toolbar`, [W, G] = useState(!0), K = useRef({
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
25
  onReady: v,
26
26
  onEditorCreate: y,
27
27
  onEditorDestroy: b,
@@ -33,7 +33,7 @@ function SuperDocEditorInner(e, s) {
33
33
  onViewportChange: E
34
34
  });
35
35
  useEffect(() => {
36
- K.current = {
36
+ W.current = {
37
37
  onReady: v,
38
38
  onEditorCreate: y,
39
39
  onEditorDestroy: b,
@@ -55,79 +55,75 @@ function SuperDocEditorInner(e, s) {
55
55
  T,
56
56
  E
57
57
  ]);
58
- let q = useRef(null), J = useRef(!1), Y = useRef(P);
58
+ let G = useRef(null), K = useRef(!1), q = useRef(M);
59
59
  useEffect(() => {
60
- Y.current !== P && (R.current ? R.current.setDocumentMode(P) : J.current && (q.current = P)), Y.current = P;
61
- }, [P]), useImperativeHandle(s, () => ({ getInstance: () => R.current }), []), useEffect(() => {
62
- G(!0), d(!1), J.current = !0;
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
63
  let e = !1, s = null;
64
64
  return (async () => {
65
65
  try {
66
66
  let c = (await import("superdoc")).SuperDoc;
67
67
  if (e) return;
68
68
  s = new c({
69
- ...N,
70
- selector: `#${CSS.escape(H)}`,
71
- ...!m && z.current ? { toolbar: `#${CSS.escape(U)}` } : {},
72
- documentMode: P,
73
- role: F,
69
+ ...j,
70
+ selector: `#${CSS.escape(B)}`,
71
+ ...!m && L.current ? { toolbar: `#${CSS.escape(V)}` } : {},
72
+ documentMode: M,
73
+ role: N,
74
74
  contained: h,
75
75
  ...D == null ? {} : { document: D },
76
- ...I ? { user: I } : {},
77
- ...L ? { users: L } : {},
76
+ ...P ? { user: P } : {},
77
+ ...F ? { users: F } : {},
78
78
  ...A ? { modules: A } : {},
79
- ...j == null ? {} : { editorVersion: j },
80
- ...M == null ? {} : { editorIntegration: M },
81
79
  onReady: (s) => {
82
- e || (G(!1), J.current = !1, q.current && q.current !== P && (s.superdoc.setDocumentMode(q.current), q.current = null), K.current.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));
83
81
  },
84
82
  onEditorCreate: (s) => {
85
- e || K.current.onEditorCreate?.(s);
83
+ e || W.current.onEditorCreate?.(s);
86
84
  },
87
85
  onEditorDestroy: () => {
88
- e || K.current.onEditorDestroy?.();
86
+ e || W.current.onEditorDestroy?.();
89
87
  },
90
88
  onEditorUpdate: (s) => {
91
- e || K.current.onEditorUpdate?.(s);
89
+ e || W.current.onEditorUpdate?.(s);
92
90
  },
93
91
  onTransaction: (s) => {
94
- e || K.current.onTransaction?.(s);
92
+ e || W.current.onTransaction?.(s);
95
93
  },
96
94
  onContentError: (s) => {
97
- e || K.current.onContentError?.(s);
95
+ e || W.current.onContentError?.(s);
98
96
  },
99
97
  onException: (s) => {
100
- e || K.current.onException?.(s);
98
+ e || W.current.onException?.(s);
101
99
  },
102
100
  onZoomChange: (s) => {
103
- e || K.current.onZoomChange?.(s);
101
+ e || W.current.onZoomChange?.(s);
104
102
  },
105
103
  onViewportChange: (s) => {
106
- e || K.current.onViewportChange?.(s);
104
+ e || W.current.onViewportChange?.(s);
107
105
  }
108
- }), R.current = s;
106
+ }), I.current = s;
109
107
  } catch (s) {
110
- e || (J.current = !1, G(!1), d(!0), console.error("[SuperDocEditor] Failed to initialize SuperDoc:", s), K.current.onException?.({ error: s }));
108
+ e || (K.current = !1, U(!1), d(!0), console.error("[SuperDocEditor] Failed to initialize SuperDoc:", s), W.current.onException?.({ error: s }));
111
109
  }
112
110
  })(), () => {
113
- J.current = !1, q.current = null, s && (s.destroy(), R.current = null), e = !0;
111
+ K.current = !1, G.current = null, s && (s.destroy(), I.current = null), e = !0;
114
112
  };
115
113
  }, [
116
114
  D,
117
- I,
118
- L,
119
- A,
115
+ P,
120
116
  F,
117
+ A,
118
+ N,
121
119
  m,
122
120
  h,
123
- j,
124
- M,
125
- H,
126
- U
121
+ B,
122
+ V
127
123
  ]);
128
- let X = ["superdoc-wrapper", g].filter(Boolean).join(" "), Z = W ? { display: "none" } : void 0;
124
+ let J = ["superdoc-wrapper", g].filter(Boolean).join(" "), Y = H ? { display: "none" } : void 0;
129
125
  return /* @__PURE__ */ jsxs("div", {
130
- className: X,
126
+ className: J,
131
127
  style: {
132
128
  ..._,
133
129
  ...h && {
@@ -137,23 +133,23 @@ function SuperDocEditorInner(e, s) {
137
133
  },
138
134
  children: [
139
135
  !m && /* @__PURE__ */ jsx("div", {
140
- ref: z,
141
- id: U,
136
+ ref: L,
137
+ id: V,
142
138
  className: "superdoc-toolbar-container",
143
- style: Z
139
+ style: Y
144
140
  }),
145
141
  /* @__PURE__ */ jsx("div", {
146
- id: H,
142
+ id: B,
147
143
  className: "superdoc-editor-container",
148
144
  style: {
149
- ...Z,
145
+ ...Y,
150
146
  ...h && {
151
147
  flex: 1,
152
148
  minHeight: 0
153
149
  }
154
150
  }
155
151
  }),
156
- W && !u && p && /* @__PURE__ */ jsx("div", {
152
+ H && !u && p && /* @__PURE__ */ jsx("div", {
157
153
  className: "superdoc-loading-container",
158
154
  children: p()
159
155
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/react",
3
- "version": "1.11.0-next.41",
3
+ "version": "1.11.0-next.43",
4
4
  "description": "Official React wrapper for the SuperDoc document editor",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",