@superdoc/react 2.4.0-next.9 → 2.5.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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +49 -49
- package/package.json +5 -5
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,
|
|
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,document:C,user:w,users:T,modules:E,ui:D,...O}=e,k=e.documentMode??`editing`,A=e.role??`editor`,j=D!==!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.`})]})}var g=(0,c.forwardRef)(h);g.displayName=`SuperDocEditor`,exports.SuperDocEditor=g,exports.default=g;
|
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, document: D, user:
|
|
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, document: D, user: O, users: k, modules: A, ui: j, ...M } = e, N = e.documentMode ?? "editing", P = e.role ?? "editor", F = j !== !1 && j?.toolbar, I = typeof F == "object" && !!F && F.container !== void 0, L = !m && F !== !1 && !I, R = (() => {
|
|
27
|
+
if (j === !1 || j === void 0 || !m) return j;
|
|
28
|
+
let { toolbar: e, ...t } = j;
|
|
29
29
|
return {
|
|
30
30
|
...t,
|
|
31
31
|
toolbar: !1
|
|
32
32
|
};
|
|
33
|
-
})(),
|
|
33
|
+
})(), z = d(O), B = d(k), V = i(null), H = i(null), U = u(), W = f ?? `superdoc${U}`, G = W, K = `${W}-toolbar`, [q, J] = a(!0), Y = i({
|
|
34
34
|
onReady: v,
|
|
35
35
|
onEditorCreate: y,
|
|
36
36
|
onEditorDestroy: b,
|
|
@@ -42,7 +42,7 @@ function p(e, t) {
|
|
|
42
42
|
onViewportChange: E
|
|
43
43
|
});
|
|
44
44
|
n(() => {
|
|
45
|
-
|
|
45
|
+
Y.current = {
|
|
46
46
|
onReady: v,
|
|
47
47
|
onEditorCreate: y,
|
|
48
48
|
onEditorDestroy: b,
|
|
@@ -64,93 +64,93 @@ function p(e, t) {
|
|
|
64
64
|
T,
|
|
65
65
|
E
|
|
66
66
|
]);
|
|
67
|
-
let
|
|
67
|
+
let X = i(null), Z = i(!1), Q = i(N);
|
|
68
68
|
n(() => {
|
|
69
|
-
|
|
70
|
-
}, [
|
|
71
|
-
|
|
69
|
+
Q.current !== N && (V.current ? V.current.setDocumentMode(N) : Z.current && (X.current = N)), Q.current = N;
|
|
70
|
+
}, [N]), r(t, () => ({ getInstance: () => V.current }), []), n(() => {
|
|
71
|
+
J(!0), l(!1), Z.current = !0;
|
|
72
72
|
let e = !1, t = null;
|
|
73
73
|
return (async () => {
|
|
74
74
|
try {
|
|
75
75
|
let n = (await import("superdoc")).SuperDoc;
|
|
76
76
|
if (e) return;
|
|
77
77
|
t = new n({
|
|
78
|
-
...
|
|
79
|
-
selector: `#${CSS.escape(
|
|
80
|
-
...
|
|
81
|
-
documentMode:
|
|
82
|
-
role:
|
|
78
|
+
...M,
|
|
79
|
+
selector: `#${CSS.escape(G)}`,
|
|
80
|
+
...L && H.current ? { toolbar: `#${CSS.escape(K)}` } : {},
|
|
81
|
+
documentMode: N,
|
|
82
|
+
role: P,
|
|
83
83
|
contained: h,
|
|
84
84
|
...D == null ? {} : { document: D },
|
|
85
|
-
...
|
|
86
|
-
...
|
|
87
|
-
...
|
|
88
|
-
...
|
|
85
|
+
...z ? { user: z } : {},
|
|
86
|
+
...B ? { users: B } : {},
|
|
87
|
+
...A ? { modules: A } : {},
|
|
88
|
+
...R === void 0 ? {} : { ui: R },
|
|
89
89
|
onReady: (t) => {
|
|
90
|
-
e || (
|
|
90
|
+
e || (J(!1), Z.current = !1, X.current && X.current !== N && (t.superdoc.setDocumentMode(X.current), X.current = null), Y.current.onReady?.(t));
|
|
91
91
|
},
|
|
92
92
|
onEditorCreate: (t) => {
|
|
93
|
-
e ||
|
|
93
|
+
e || Y.current.onEditorCreate?.(t);
|
|
94
94
|
},
|
|
95
95
|
onEditorDestroy: () => {
|
|
96
|
-
e ||
|
|
96
|
+
e || Y.current.onEditorDestroy?.();
|
|
97
97
|
},
|
|
98
98
|
onEditorUpdate: (t) => {
|
|
99
|
-
e ||
|
|
99
|
+
e || Y.current.onEditorUpdate?.(t);
|
|
100
100
|
},
|
|
101
101
|
onTransaction: (t) => {
|
|
102
|
-
e ||
|
|
102
|
+
e || Y.current.onTransaction?.(t);
|
|
103
103
|
},
|
|
104
104
|
onContentError: (t) => {
|
|
105
|
-
e ||
|
|
105
|
+
e || Y.current.onContentError?.(t);
|
|
106
106
|
},
|
|
107
107
|
onException: (t) => {
|
|
108
|
-
e ||
|
|
108
|
+
e || Y.current.onException?.(t);
|
|
109
109
|
},
|
|
110
110
|
onZoomChange: (t) => {
|
|
111
|
-
e ||
|
|
111
|
+
e || Y.current.onZoomChange?.(t);
|
|
112
112
|
},
|
|
113
113
|
onViewportChange: (t) => {
|
|
114
|
-
e ||
|
|
114
|
+
e || Y.current.onViewportChange?.(t);
|
|
115
115
|
}
|
|
116
|
-
}),
|
|
116
|
+
}), V.current = t;
|
|
117
117
|
} catch (t) {
|
|
118
|
-
e || (
|
|
118
|
+
e || (Z.current = !1, J(!1), l(!0), console.error("[SuperDocEditor] Failed to initialize SuperDoc:", t), Y.current.onException?.({ error: t }));
|
|
119
119
|
}
|
|
120
120
|
})(), () => {
|
|
121
|
-
|
|
121
|
+
Z.current = !1, X.current = null, t && (t.destroy(), V.current = null), e = !0;
|
|
122
122
|
};
|
|
123
123
|
}, [
|
|
124
124
|
D,
|
|
125
|
-
R,
|
|
126
125
|
z,
|
|
127
|
-
|
|
126
|
+
B,
|
|
128
127
|
A,
|
|
129
|
-
|
|
128
|
+
j,
|
|
129
|
+
P,
|
|
130
130
|
m,
|
|
131
131
|
h,
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
G,
|
|
133
|
+
K
|
|
134
134
|
]);
|
|
135
|
-
let
|
|
136
|
-
..._,
|
|
137
|
-
...h && {
|
|
138
|
-
display: "flex",
|
|
139
|
-
flexDirection: "column"
|
|
140
|
-
}
|
|
141
|
-
};
|
|
135
|
+
let ee = ["superdoc-wrapper", g].filter(Boolean).join(" "), $ = q ? { display: "none" } : void 0;
|
|
142
136
|
return /* @__PURE__ */ s("div", {
|
|
143
|
-
className:
|
|
144
|
-
style:
|
|
137
|
+
className: ee,
|
|
138
|
+
style: {
|
|
139
|
+
..._,
|
|
140
|
+
...h && {
|
|
141
|
+
display: "flex",
|
|
142
|
+
flexDirection: "column"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
145
|
children: [
|
|
146
|
-
|
|
147
|
-
ref:
|
|
148
|
-
id:
|
|
146
|
+
L && /* @__PURE__ */ o("div", {
|
|
147
|
+
ref: H,
|
|
148
|
+
id: K,
|
|
149
149
|
className: "superdoc-toolbar-container",
|
|
150
150
|
style: $
|
|
151
151
|
}),
|
|
152
152
|
/* @__PURE__ */ o("div", {
|
|
153
|
-
id:
|
|
153
|
+
id: G,
|
|
154
154
|
className: "superdoc-editor-container",
|
|
155
155
|
style: {
|
|
156
156
|
...$,
|
|
@@ -160,7 +160,7 @@ function p(e, t) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}),
|
|
163
|
-
|
|
163
|
+
q && !c && p && /* @__PURE__ */ o("div", {
|
|
164
164
|
className: "superdoc-loading-container",
|
|
165
165
|
children: p()
|
|
166
166
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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": "2.
|
|
30
|
+
"superdoc": "2.10.0-next.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=16.8.0",
|
|
34
34
|
"react-dom": ">=16.8.0",
|
|
35
|
-
"superdoc": "2.
|
|
35
|
+
"superdoc": "2.10.0-next.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@testing-library/react": "^16.3.0",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"react": "19.2.4",
|
|
45
45
|
"react-dom": "19.2.4",
|
|
46
46
|
"typescript": "^5.9.2",
|
|
47
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.
|
|
47
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.7",
|
|
48
48
|
"vite-plugin-dts": "~4.5.4",
|
|
49
|
-
"vite-plus": "0.2.
|
|
49
|
+
"vite-plus": "0.2.7",
|
|
50
50
|
"vitest": "4.1.10"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|