@superdoc/react 2.5.0-next.9 → 2.5.1-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.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +16 -2
- package/dist/index.js +54 -48
- package/package.json +3 -3
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,1);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,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,
|
|
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,1);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,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,onPageMarginsChange:C,document:w,user:T,users:E,modules:D,ui:O,...k}=e,A=e.documentMode??`editing`,j=e.role??`editor`,M=O!==!1&&O?.toolbar,N=typeof M==`object`&&!!M&&M.container!==void 0,P=!o&&M!==!1&&!N,F=(()=>{if(O===!1||O===void 0||!o)return O;let{toolbar:e,...t}=O;return{...t,toolbar:!1}})(),I=p(T),L=p(E),R=(0,c.useRef)(null),z=(0,c.useRef)(null),B=f(),V=i??`superdoc${B}`,H=V,U=`${V}-toolbar`,[W,G]=(0,c.useState)(!0),K=(0,c.useRef)({onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S,onPageMarginsChange:C});(0,c.useEffect)(()=>{K.current={onReady:m,onEditorCreate:h,onEditorDestroy:g,onEditorUpdate:_,onTransaction:v,onContentError:y,onException:b,onZoomChange:x,onViewportChange:S,onPageMarginsChange:C}},[m,h,g,_,v,y,b,x,S,C]);let q=(0,c.useRef)(null),J=(0,c.useRef)(!1),Y=(0,c.useRef)(A);(0,c.useEffect)(()=>{Y.current!==A&&(R.current?R.current.setDocumentMode(A):J.current&&(q.current=A)),Y.current=A},[A]),(0,c.useImperativeHandle)(t,()=>({getInstance:()=>R.current}),[]),(0,c.useEffect)(()=>{G(!0),r(!1),J.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(H)}`,...P&&z.current?{toolbar:`#${CSS.escape(U)}`}:{},documentMode:A,role:j,contained:s,...w==null?{}:{document:w},...I?{user:I}:{},...L?{users:L}:{},...D?{modules:D}:{},...F===void 0?{}:{ui:F},onReady:t=>{e||(G(!1),J.current=!1,q.current&&q.current!==A&&(t.superdoc.setDocumentMode(q.current),q.current=null),K.current.onReady?.(t))},onEditorCreate:t=>{e||K.current.onEditorCreate?.(t)},onEditorDestroy:()=>{e||K.current.onEditorDestroy?.()},onEditorUpdate:t=>{e||K.current.onEditorUpdate?.(t)},onTransaction:t=>{e||K.current.onTransaction?.(t)},onContentError:t=>{e||K.current.onContentError?.(t)},onException:t=>{e||K.current.onException?.(t)},onZoomChange:t=>{e||K.current.onZoomChange?.(t)},onViewportChange:t=>{e||K.current.onViewportChange?.(t)},onPageMarginsChange:t=>{e||K.current.onPageMarginsChange?.(t)}}),R.current=t}catch(t){e||(J.current=!1,G(!1),r(!0),console.error(`[SuperDocEditor] Failed to initialize SuperDoc:`,t),K.current.onException?.({error:t}))}})(),()=>{J.current=!1,q.current=null,t&&(t.destroy(),R.current=null),e=!0}},[w,I,L,D,O,j,o,s,H,U]);let X=[`superdoc-wrapper`,u].filter(Boolean).join(` `),Z=O!==!1&&O?.loading!==!1,Q=W?{display:`none`}:void 0,$=W&&(a||!Z)?{display:`none`}:void 0;return(0,l.jsxs)(`div`,{className:X,style:{...d,...s&&{display:`flex`,flexDirection:`column`}},children:[P&&(0,l.jsx)(`div`,{ref:z,id:U,className:`superdoc-toolbar-container`,style:Q}),(0,l.jsx)(`div`,{id:H,className:`superdoc-editor-container`,style:{...$,...s&&{flex:1,minHeight:0}}}),W&&!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.`})]})}var g=(0,c.forwardRef)(h);g.displayName=`SuperDocEditor`,exports.SuperDocEditor=g,exports.default=g;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,12 +22,14 @@ import { HyperlinksConfig } from 'superdoc';
|
|
|
22
22
|
import { HyperlinkTarget } from 'superdoc';
|
|
23
23
|
import { ReactNode } from 'react';
|
|
24
24
|
import { RefAttributes } from 'react';
|
|
25
|
+
import { RulerConfig } from 'superdoc';
|
|
25
26
|
import { SearchConfig } from 'superdoc';
|
|
26
27
|
import { SearchFloatingConfig } from 'superdoc';
|
|
27
28
|
import { SearchStrings } from 'superdoc';
|
|
28
29
|
import { SuperDoc } from 'superdoc';
|
|
29
30
|
import { SuperDocExceptionHyperlinkPayload } from 'superdoc';
|
|
30
31
|
import { SuperDocExceptionPayload } from 'superdoc';
|
|
32
|
+
import { SuperDocPageMarginsChangePayload } from 'superdoc';
|
|
31
33
|
import { ToolbarConfig } from 'superdoc';
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -53,6 +55,8 @@ export declare interface CallbackProps {
|
|
|
53
55
|
onZoomChange?: (event: SuperDocZoomChangeEvent) => void;
|
|
54
56
|
/** Callback when the implied fit changes (rounded fit zoom or base page width); see the core viewport-change event */
|
|
55
57
|
onViewportChange?: (event: SuperDocViewportChangeEvent) => void;
|
|
58
|
+
/** Callback after a ruler drag changes the active section's left or right page margin. */
|
|
59
|
+
onPageMarginsChange?: (event: SuperDocPageMarginsChangeEvent) => void;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
export { CommentInteractionConfig }
|
|
@@ -93,7 +97,7 @@ export declare type EditorSurface = 'body' | 'header' | 'footer';
|
|
|
93
97
|
* Callback props that are explicitly typed in CallbackProps.
|
|
94
98
|
* These are excluded from SuperDocConfig to avoid type conflicts.
|
|
95
99
|
*/
|
|
96
|
-
declare type ExplicitCallbackProps = 'onReady' | 'onEditorCreate' | 'onEditorDestroy' | 'onEditorUpdate' | 'onTransaction' | 'onContentError' | 'onException' | 'onZoomChange' | 'onViewportChange';
|
|
100
|
+
declare type ExplicitCallbackProps = 'onReady' | 'onEditorCreate' | 'onEditorDestroy' | 'onEditorUpdate' | 'onTransaction' | 'onContentError' | 'onException' | 'onZoomChange' | 'onViewportChange' | 'onPageMarginsChange';
|
|
97
101
|
|
|
98
102
|
export { HyperlinkActivationContext }
|
|
99
103
|
|
|
@@ -125,7 +129,10 @@ declare type OptionalInReact = 'documentMode';
|
|
|
125
129
|
declare interface ReactProps {
|
|
126
130
|
/** Optional ID for the editor container. Auto-generated if not provided. */
|
|
127
131
|
id?: string;
|
|
128
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Render application-owned content while the Editor opens. When omitted,
|
|
134
|
+
* SuperDoc shows its built-in loading overlay unless `ui.loading` is false.
|
|
135
|
+
*/
|
|
129
136
|
renderLoading?: () => ReactNode;
|
|
130
137
|
/**
|
|
131
138
|
* Hide the toolbar container. When true, no toolbar is rendered.
|
|
@@ -147,6 +154,8 @@ declare interface ReactProps {
|
|
|
147
154
|
style?: CSSProperties;
|
|
148
155
|
}
|
|
149
156
|
|
|
157
|
+
export { RulerConfig }
|
|
158
|
+
|
|
150
159
|
export { SearchConfig }
|
|
151
160
|
|
|
152
161
|
export { SearchFloatingConfig }
|
|
@@ -222,6 +231,11 @@ export declare type SuperDocInstance = InstanceType<typeof SuperDoc>;
|
|
|
222
231
|
/** Modules configuration - extracted from Config.modules */
|
|
223
232
|
export declare type SuperDocModules = NonNullable<SuperDocConstructorConfig['modules']>;
|
|
224
233
|
|
|
234
|
+
/** Event passed to onPageMarginsChange callback. */
|
|
235
|
+
export declare type SuperDocPageMarginsChangeEvent = Parameters<NonNullable<SuperDocConfig['onPageMarginsChange']>>[0];
|
|
236
|
+
|
|
237
|
+
export { SuperDocPageMarginsChangePayload }
|
|
238
|
+
|
|
225
239
|
/** Event passed to onReady callback */
|
|
226
240
|
export declare type SuperDocReadyEvent = Parameters<NonNullable<SuperDocConfig['onReady']>>[0];
|
|
227
241
|
|
package/dist/index.js
CHANGED
|
@@ -23,14 +23,14 @@ function f(e, t) {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/SuperDocEditor.tsx
|
|
25
25
|
function p(e, t) {
|
|
26
|
-
let [c, l] = a(!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,
|
|
27
|
-
if (
|
|
28
|
-
let { toolbar: e, ...t } =
|
|
26
|
+
let [c, l] = a(!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, onPageMarginsChange: D, document: O, user: k, users: A, modules: j, ui: M, ...N } = e, P = e.documentMode ?? "editing", F = e.role ?? "editor", I = M !== !1 && M?.toolbar, L = typeof I == "object" && !!I && I.container !== void 0, R = !m && I !== !1 && !L, z = (() => {
|
|
27
|
+
if (M === !1 || M === void 0 || !m) return M;
|
|
28
|
+
let { toolbar: e, ...t } = M;
|
|
29
29
|
return {
|
|
30
30
|
...t,
|
|
31
31
|
toolbar: !1
|
|
32
32
|
};
|
|
33
|
-
})(),
|
|
33
|
+
})(), B = d(k), V = d(A), H = i(null), U = i(null), W = u(), G = f ?? `superdoc${W}`, K = G, q = `${G}-toolbar`, [J, Y] = a(!0), X = i({
|
|
34
34
|
onReady: v,
|
|
35
35
|
onEditorCreate: y,
|
|
36
36
|
onEditorDestroy: b,
|
|
@@ -39,10 +39,11 @@ function p(e, t) {
|
|
|
39
39
|
onContentError: C,
|
|
40
40
|
onException: w,
|
|
41
41
|
onZoomChange: T,
|
|
42
|
-
onViewportChange: E
|
|
42
|
+
onViewportChange: E,
|
|
43
|
+
onPageMarginsChange: D
|
|
43
44
|
});
|
|
44
45
|
n(() => {
|
|
45
|
-
|
|
46
|
+
X.current = {
|
|
46
47
|
onReady: v,
|
|
47
48
|
onEditorCreate: y,
|
|
48
49
|
onEditorDestroy: b,
|
|
@@ -51,7 +52,8 @@ function p(e, t) {
|
|
|
51
52
|
onContentError: C,
|
|
52
53
|
onException: w,
|
|
53
54
|
onZoomChange: T,
|
|
54
|
-
onViewportChange: E
|
|
55
|
+
onViewportChange: E,
|
|
56
|
+
onPageMarginsChange: D
|
|
55
57
|
};
|
|
56
58
|
}, [
|
|
57
59
|
v,
|
|
@@ -62,77 +64,81 @@ function p(e, t) {
|
|
|
62
64
|
C,
|
|
63
65
|
w,
|
|
64
66
|
T,
|
|
65
|
-
E
|
|
67
|
+
E,
|
|
68
|
+
D
|
|
66
69
|
]);
|
|
67
|
-
let
|
|
70
|
+
let Z = i(null), Q = i(!1), $ = i(P);
|
|
68
71
|
n(() => {
|
|
69
|
-
|
|
70
|
-
}, [
|
|
71
|
-
|
|
72
|
+
$.current !== P && (H.current ? H.current.setDocumentMode(P) : Q.current && (Z.current = P)), $.current = P;
|
|
73
|
+
}, [P]), r(t, () => ({ getInstance: () => H.current }), []), n(() => {
|
|
74
|
+
Y(!0), l(!1), Q.current = !0;
|
|
72
75
|
let e = !1, t = null;
|
|
73
76
|
return (async () => {
|
|
74
77
|
try {
|
|
75
78
|
let n = (await import("superdoc")).SuperDoc;
|
|
76
79
|
if (e) return;
|
|
77
80
|
t = new n({
|
|
78
|
-
...
|
|
79
|
-
selector: `#${CSS.escape(
|
|
80
|
-
...
|
|
81
|
-
documentMode:
|
|
82
|
-
role:
|
|
81
|
+
...N,
|
|
82
|
+
selector: `#${CSS.escape(K)}`,
|
|
83
|
+
...R && U.current ? { toolbar: `#${CSS.escape(q)}` } : {},
|
|
84
|
+
documentMode: P,
|
|
85
|
+
role: F,
|
|
83
86
|
contained: h,
|
|
84
|
-
...
|
|
85
|
-
...
|
|
86
|
-
...
|
|
87
|
-
...
|
|
88
|
-
...
|
|
87
|
+
...O == null ? {} : { document: O },
|
|
88
|
+
...B ? { user: B } : {},
|
|
89
|
+
...V ? { users: V } : {},
|
|
90
|
+
...j ? { modules: j } : {},
|
|
91
|
+
...z === void 0 ? {} : { ui: z },
|
|
89
92
|
onReady: (t) => {
|
|
90
|
-
e || (
|
|
93
|
+
e || (Y(!1), Q.current = !1, Z.current && Z.current !== P && (t.superdoc.setDocumentMode(Z.current), Z.current = null), X.current.onReady?.(t));
|
|
91
94
|
},
|
|
92
95
|
onEditorCreate: (t) => {
|
|
93
|
-
e ||
|
|
96
|
+
e || X.current.onEditorCreate?.(t);
|
|
94
97
|
},
|
|
95
98
|
onEditorDestroy: () => {
|
|
96
|
-
e ||
|
|
99
|
+
e || X.current.onEditorDestroy?.();
|
|
97
100
|
},
|
|
98
101
|
onEditorUpdate: (t) => {
|
|
99
|
-
e ||
|
|
102
|
+
e || X.current.onEditorUpdate?.(t);
|
|
100
103
|
},
|
|
101
104
|
onTransaction: (t) => {
|
|
102
|
-
e ||
|
|
105
|
+
e || X.current.onTransaction?.(t);
|
|
103
106
|
},
|
|
104
107
|
onContentError: (t) => {
|
|
105
|
-
e ||
|
|
108
|
+
e || X.current.onContentError?.(t);
|
|
106
109
|
},
|
|
107
110
|
onException: (t) => {
|
|
108
|
-
e ||
|
|
111
|
+
e || X.current.onException?.(t);
|
|
109
112
|
},
|
|
110
113
|
onZoomChange: (t) => {
|
|
111
|
-
e ||
|
|
114
|
+
e || X.current.onZoomChange?.(t);
|
|
112
115
|
},
|
|
113
116
|
onViewportChange: (t) => {
|
|
114
|
-
e ||
|
|
117
|
+
e || X.current.onViewportChange?.(t);
|
|
118
|
+
},
|
|
119
|
+
onPageMarginsChange: (t) => {
|
|
120
|
+
e || X.current.onPageMarginsChange?.(t);
|
|
115
121
|
}
|
|
116
|
-
}),
|
|
122
|
+
}), H.current = t;
|
|
117
123
|
} catch (t) {
|
|
118
|
-
e || (
|
|
124
|
+
e || (Q.current = !1, Y(!1), l(!0), console.error("[SuperDocEditor] Failed to initialize SuperDoc:", t), X.current.onException?.({ error: t }));
|
|
119
125
|
}
|
|
120
126
|
})(), () => {
|
|
121
|
-
|
|
127
|
+
Q.current = !1, Z.current = null, t && (t.destroy(), H.current = null), e = !0;
|
|
122
128
|
};
|
|
123
129
|
}, [
|
|
124
|
-
|
|
125
|
-
z,
|
|
130
|
+
O,
|
|
126
131
|
B,
|
|
127
|
-
|
|
132
|
+
V,
|
|
128
133
|
j,
|
|
129
|
-
|
|
134
|
+
M,
|
|
135
|
+
F,
|
|
130
136
|
m,
|
|
131
137
|
h,
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
K,
|
|
139
|
+
q
|
|
134
140
|
]);
|
|
135
|
-
let ee = ["superdoc-wrapper", g].filter(Boolean).join(" "),
|
|
141
|
+
let ee = ["superdoc-wrapper", g].filter(Boolean).join(" "), te = M !== !1 && M?.loading !== !1, ne = J ? { display: "none" } : void 0, re = J && (p || !te) ? { display: "none" } : void 0;
|
|
136
142
|
return /* @__PURE__ */ s("div", {
|
|
137
143
|
className: ee,
|
|
138
144
|
style: {
|
|
@@ -143,24 +149,24 @@ function p(e, t) {
|
|
|
143
149
|
}
|
|
144
150
|
},
|
|
145
151
|
children: [
|
|
146
|
-
|
|
147
|
-
ref:
|
|
148
|
-
id:
|
|
152
|
+
R && /* @__PURE__ */ o("div", {
|
|
153
|
+
ref: U,
|
|
154
|
+
id: q,
|
|
149
155
|
className: "superdoc-toolbar-container",
|
|
150
|
-
style:
|
|
156
|
+
style: ne
|
|
151
157
|
}),
|
|
152
158
|
/* @__PURE__ */ o("div", {
|
|
153
|
-
id:
|
|
159
|
+
id: K,
|
|
154
160
|
className: "superdoc-editor-container",
|
|
155
161
|
style: {
|
|
156
|
-
|
|
162
|
+
...re,
|
|
157
163
|
...h && {
|
|
158
164
|
flex: 1,
|
|
159
165
|
minHeight: 0
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
}),
|
|
163
|
-
|
|
169
|
+
J && !c && p && /* @__PURE__ */ o("div", {
|
|
164
170
|
className: "superdoc-loading-container",
|
|
165
171
|
children: p()
|
|
166
172
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/react",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1-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": "2.10.
|
|
30
|
+
"superdoc": "2.10.1-next.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=16.8.0",
|
|
34
34
|
"react-dom": ">=16.8.0",
|
|
35
|
-
"superdoc": "2.10.
|
|
35
|
+
"superdoc": "2.10.1-next.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@testing-library/react": "^16.3.0",
|