@haklex/rich-ext-excalidraw 0.49.0 → 0.50.0
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/ExcalidrawConfigContext.d.ts +3 -1
- package/dist/ExcalidrawConfigContext.d.ts.map +1 -1
- package/dist/ExcalidrawDisplayRenderer.d.ts +1 -0
- package/dist/ExcalidrawDisplayRenderer.d.ts.map +1 -1
- package/dist/ExcalidrawEditRenderer.d.ts.map +1 -1
- package/dist/ExcalidrawFrameStates.d.ts +11 -0
- package/dist/ExcalidrawFrameStates.d.ts.map +1 -0
- package/dist/ExcalidrawSSRRenderer.d.ts.map +1 -1
- package/dist/index.mjs +51 -55
- package/dist/rich-ext-excalidraw.css +1 -1
- package/dist/scene/InteractiveScene.d.ts +11 -0
- package/dist/scene/InteractiveScene.d.ts.map +1 -0
- package/dist/scene/Scene.d.ts +24 -0
- package/dist/scene/Scene.d.ts.map +1 -0
- package/dist/scene/fonts.d.ts +8 -0
- package/dist/scene/fonts.d.ts.map +1 -0
- package/dist/scene/normalize.d.ts +4 -0
- package/dist/scene/normalize.d.ts.map +1 -0
- package/dist/scene/rough.d.ts +19 -0
- package/dist/scene/rough.d.ts.map +1 -0
- package/dist/scene/scene.test.d.ts +2 -0
- package/dist/scene/scene.test.d.ts.map +1 -0
- package/dist/scene/styles.css.d.ts +7 -0
- package/dist/scene/styles.css.d.ts.map +1 -0
- package/dist/scene/types.d.ts +118 -0
- package/dist/scene/types.d.ts.map +1 -0
- package/dist/static.mjs +2 -2
- package/dist/styles.css.d.ts +5 -2
- package/dist/styles.css.d.ts.map +1 -1
- package/dist/transformer-C2e_qiIg.js +487 -0
- package/dist/useExcalidrawData.d.ts +2 -0
- package/dist/useExcalidrawData.d.ts.map +1 -1
- package/dist/useExcalidrawFont-DAmoYxvU.js +795 -0
- package/dist/useExcalidrawFont.d.ts +2 -0
- package/dist/useExcalidrawFont.d.ts.map +1 -0
- package/package.json +12 -6
- package/dist/constants.d.ts +0 -5
- package/dist/constants.d.ts.map +0 -1
- package/dist/transformer-BaQILRBF.js +0 -315
- package/dist/useExcalidrawData-ZN9PHFyy.js +0 -227
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExcalidrawFont.d.ts","sourceRoot":"","sources":["../src/useExcalidrawFont.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,IAAI,IAAI,CAUxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-ext-excalidraw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Excalidraw whiteboard extension",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@haklex/rich-headless": "0.
|
|
29
|
-
"jsondiffpatch": "^0.7.6"
|
|
28
|
+
"@haklex/rich-headless": "0.50.0",
|
|
29
|
+
"jsondiffpatch": "^0.7.6",
|
|
30
|
+
"roughjs": "^4.6.6"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@excalidraw/excalidraw": "^0.18.1",
|
|
@@ -45,15 +46,20 @@
|
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
48
|
"@excalidraw/excalidraw": ">=0.18.0",
|
|
48
|
-
"@haklex/rich-editor": "^0.
|
|
49
|
-
"@haklex/rich-editor-ui": "^0.
|
|
50
|
-
"@haklex/rich-style-token": "^0.
|
|
49
|
+
"@haklex/rich-editor": "^0.50.0",
|
|
50
|
+
"@haklex/rich-editor-ui": "^0.50.0",
|
|
51
|
+
"@haklex/rich-style-token": "^0.50.0",
|
|
51
52
|
"@lexical/react": "^0.52.0",
|
|
52
53
|
"lexical": "^0.52.0",
|
|
53
54
|
"lucide-react": "^1.0.0",
|
|
54
55
|
"react": ">=19",
|
|
55
56
|
"react-dom": ">=19"
|
|
56
57
|
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@excalidraw/excalidraw": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
57
63
|
"publishConfig": {
|
|
58
64
|
"access": "public"
|
|
59
65
|
},
|
package/dist/constants.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ExcalidrawImperativeAPI, ExcalidrawProps } from '@excalidraw/excalidraw/types';
|
|
2
|
-
export declare const readonlyUIOptions: ExcalidrawProps['UIOptions'];
|
|
3
|
-
export declare const fitSceneToViewport: (api: ExcalidrawImperativeAPI) => void;
|
|
4
|
-
export declare const fitSceneOnReady: (api: ExcalidrawImperativeAPI) => void;
|
|
5
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE7F,eAAO,MAAM,iBAAiB,EAAE,eAAe,CAAC,WAAW,CAQ1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,uBAAuB,SAC+B,CAAC;AAG/F,eAAO,MAAM,eAAe,GAAI,KAAK,uBAAuB,SAW3D,CAAC"}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { A as fitSceneOnReady, D as excalidrawPlaceholder, E as excalidrawLoading, M as readonlyUIOptions, O as excalidrawStaticContainer, S as excalidrawError, T as excalidrawHeaderClose, c as excalidrawActionButton, g as excalidrawDialogHeaderTitle, h as excalidrawDialogHeader, j as fitSceneToViewport, l as excalidrawActionGroup, m as excalidrawDialogCanvas, t as useExcalidrawData, v as excalidrawDialogTitle } from "./useExcalidrawData-ZN9PHFyy.js";
|
|
2
|
-
import { Component, Suspense, lazy, useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { createRendererDecoration, useColorScheme } from "@haklex/rich-editor/static";
|
|
5
|
-
import { Maximize2, ScanSearch, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
6
|
-
import { ViewportGate } from "@haklex/rich-editor-ui";
|
|
7
|
-
import { DecoratorNode } from "lexical";
|
|
8
|
-
import { EXCALIDRAW_BLOCK_TRANSFORMER } from "@haklex/rich-headless/transformers";
|
|
9
|
-
//#region \0rolldown/runtime.js
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __exportAll = (all, no_symbols) => {
|
|
12
|
-
let target = {};
|
|
13
|
-
for (var name in all) __defProp(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/typeof.js
|
|
22
|
-
function _typeof(o) {
|
|
23
|
-
"@babel/helpers - typeof";
|
|
24
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
25
|
-
return typeof o;
|
|
26
|
-
} : function(o) {
|
|
27
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
28
|
-
}, _typeof(o);
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPrimitive.js
|
|
32
|
-
function toPrimitive(t, r) {
|
|
33
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
34
|
-
var e = t[Symbol.toPrimitive];
|
|
35
|
-
if (void 0 !== e) {
|
|
36
|
-
var i = e.call(t, r || "default");
|
|
37
|
-
if ("object" != _typeof(i)) return i;
|
|
38
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
39
|
-
}
|
|
40
|
-
return ("string" === r ? String : Number)(t);
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPropertyKey.js
|
|
44
|
-
function toPropertyKey(t) {
|
|
45
|
-
var i = toPrimitive(t, "string");
|
|
46
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/defineProperty.js
|
|
50
|
-
function _defineProperty(e, r, t) {
|
|
51
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
52
|
-
value: t,
|
|
53
|
-
enumerable: !0,
|
|
54
|
-
configurable: !0,
|
|
55
|
-
writable: !0
|
|
56
|
-
}) : e[r] = t, e;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/ExcalidrawDisplayRenderer.tsx
|
|
60
|
-
var ExcalidrawDisplayRenderer_exports = /* @__PURE__ */ __exportAll({ ExcalidrawDisplayRenderer: () => ExcalidrawDisplayRenderer });
|
|
61
|
-
var ExcalidrawDisplayRenderer = ({ onExpand, snapshot }) => {
|
|
62
|
-
const theme = useColorScheme();
|
|
63
|
-
return /* @__PURE__ */ jsx(ExcalidrawStaticCanvas, {
|
|
64
|
-
snapshot,
|
|
65
|
-
theme,
|
|
66
|
-
onExpand
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
var ExcalidrawStaticCanvas = ({ onExpand, snapshot, theme }) => {
|
|
70
|
-
const { snapshot: data, loading: dataLoading, error: dataError } = useExcalidrawData(snapshot);
|
|
71
|
-
const [ExcalidrawComponent, setExcalidrawComponent] = useState(null);
|
|
72
|
-
const [libLoading, setLibLoading] = useState(true);
|
|
73
|
-
const apiRef = useRef(null);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
Promise.all([import("@excalidraw/excalidraw"), import("@excalidraw/excalidraw/index.css")]).then(([mod]) => {
|
|
76
|
-
const Comp = mod.Excalidraw;
|
|
77
|
-
if (Comp) setExcalidrawComponent(() => Comp);
|
|
78
|
-
setLibLoading(false);
|
|
79
|
-
}).catch((error) => {
|
|
80
|
-
console.error("Error loading excalidraw", error);
|
|
81
|
-
setLibLoading(false);
|
|
82
|
-
});
|
|
83
|
-
}, []);
|
|
84
|
-
const handleExpand = useCallback((e) => {
|
|
85
|
-
if (!onExpand || !ExcalidrawComponent || !data) return;
|
|
86
|
-
onExpand({
|
|
87
|
-
content: /* @__PURE__ */ jsx(ExcalidrawComponent, {
|
|
88
|
-
viewModeEnabled: true,
|
|
89
|
-
zenModeEnabled: true,
|
|
90
|
-
UIOptions: readonlyUIOptions,
|
|
91
|
-
initialData: data,
|
|
92
|
-
theme,
|
|
93
|
-
excalidrawAPI: (api) => {
|
|
94
|
-
fitSceneOnReady(api);
|
|
95
|
-
}
|
|
96
|
-
}),
|
|
97
|
-
target: e.currentTarget,
|
|
98
|
-
theme
|
|
99
|
-
});
|
|
100
|
-
}, [
|
|
101
|
-
onExpand,
|
|
102
|
-
ExcalidrawComponent,
|
|
103
|
-
data,
|
|
104
|
-
theme
|
|
105
|
-
]);
|
|
106
|
-
if (dataLoading || libLoading) return /* @__PURE__ */ jsx("div", {
|
|
107
|
-
className: excalidrawStaticContainer,
|
|
108
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
109
|
-
className: excalidrawLoading,
|
|
110
|
-
children: "Loading excalidraw..."
|
|
111
|
-
})
|
|
112
|
-
});
|
|
113
|
-
if (dataError || !data) return /* @__PURE__ */ jsx("div", {
|
|
114
|
-
className: excalidrawStaticContainer,
|
|
115
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
116
|
-
className: excalidrawError,
|
|
117
|
-
children: dataError || "No data"
|
|
118
|
-
})
|
|
119
|
-
});
|
|
120
|
-
if (!ExcalidrawComponent) return /* @__PURE__ */ jsx("div", {
|
|
121
|
-
className: excalidrawStaticContainer,
|
|
122
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
123
|
-
className: excalidrawError,
|
|
124
|
-
children: "Failed to load excalidraw"
|
|
125
|
-
})
|
|
126
|
-
});
|
|
127
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
128
|
-
suppressHydrationWarning: true,
|
|
129
|
-
className: excalidrawStaticContainer,
|
|
130
|
-
"data-color-scheme": theme,
|
|
131
|
-
"data-theme": theme,
|
|
132
|
-
children: [/* @__PURE__ */ jsx(ExcalidrawErrorBoundary, {
|
|
133
|
-
fallback: /* @__PURE__ */ jsx("div", {
|
|
134
|
-
className: excalidrawError,
|
|
135
|
-
children: "Failed to render excalidraw"
|
|
136
|
-
}),
|
|
137
|
-
children: /* @__PURE__ */ jsx(ExcalidrawComponent, {
|
|
138
|
-
viewModeEnabled: true,
|
|
139
|
-
zenModeEnabled: true,
|
|
140
|
-
UIOptions: readonlyUIOptions,
|
|
141
|
-
initialData: data,
|
|
142
|
-
theme,
|
|
143
|
-
excalidrawAPI: (api) => {
|
|
144
|
-
apiRef.current = api;
|
|
145
|
-
fitSceneOnReady(api);
|
|
146
|
-
}
|
|
147
|
-
})
|
|
148
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
149
|
-
className: excalidrawActionGroup,
|
|
150
|
-
children: [
|
|
151
|
-
/* @__PURE__ */ jsx("button", {
|
|
152
|
-
className: excalidrawActionButton,
|
|
153
|
-
title: "Zoom In",
|
|
154
|
-
type: "button",
|
|
155
|
-
onClick: () => {
|
|
156
|
-
const api = apiRef.current;
|
|
157
|
-
if (!api) return;
|
|
158
|
-
const zoom = api.getAppState().zoom.value;
|
|
159
|
-
api.updateScene({ appState: { zoom: { value: zoom * 1.25 } } });
|
|
160
|
-
},
|
|
161
|
-
children: /* @__PURE__ */ jsx(ZoomIn, { size: 20 })
|
|
162
|
-
}),
|
|
163
|
-
/* @__PURE__ */ jsx("button", {
|
|
164
|
-
className: excalidrawActionButton,
|
|
165
|
-
title: "Zoom Out",
|
|
166
|
-
type: "button",
|
|
167
|
-
onClick: () => {
|
|
168
|
-
const api = apiRef.current;
|
|
169
|
-
if (!api) return;
|
|
170
|
-
const zoom = api.getAppState().zoom.value;
|
|
171
|
-
api.updateScene({ appState: { zoom: { value: zoom / 1.25 } } });
|
|
172
|
-
},
|
|
173
|
-
children: /* @__PURE__ */ jsx(ZoomOut, { size: 20 })
|
|
174
|
-
}),
|
|
175
|
-
/* @__PURE__ */ jsx("button", {
|
|
176
|
-
className: excalidrawActionButton,
|
|
177
|
-
title: "Fit to Content",
|
|
178
|
-
type: "button",
|
|
179
|
-
onClick: () => apiRef.current && fitSceneToViewport(apiRef.current),
|
|
180
|
-
children: /* @__PURE__ */ jsx(ScanSearch, { size: 20 })
|
|
181
|
-
}),
|
|
182
|
-
Boolean(onExpand) && /* @__PURE__ */ jsx("button", {
|
|
183
|
-
className: "_1c3wdzl7",
|
|
184
|
-
title: "Expand",
|
|
185
|
-
type: "button",
|
|
186
|
-
onClick: handleExpand,
|
|
187
|
-
children: /* @__PURE__ */ jsx(Maximize2, { size: 20 })
|
|
188
|
-
})
|
|
189
|
-
]
|
|
190
|
-
})]
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
var ExcalidrawErrorBoundary = class extends Component {
|
|
194
|
-
constructor(..._args) {
|
|
195
|
-
super(..._args);
|
|
196
|
-
_defineProperty(this, "state", { hasError: false });
|
|
197
|
-
}
|
|
198
|
-
static getDerivedStateFromError() {
|
|
199
|
-
return { hasError: true };
|
|
200
|
-
}
|
|
201
|
-
render() {
|
|
202
|
-
return this.state.hasError ? this.props.fallback : this.props.children;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/ExcalidrawSSRRenderer.tsx
|
|
207
|
-
var LazyDisplayRenderer = lazy(() => Promise.resolve().then(() => ExcalidrawDisplayRenderer_exports).then((m) => ({ default: m.ExcalidrawDisplayRenderer })));
|
|
208
|
-
var ExcalidrawPlaceholder = ({ snapshot }) => {
|
|
209
|
-
let label = "Excalidraw Whiteboard";
|
|
210
|
-
try {
|
|
211
|
-
const data = JSON.parse(snapshot);
|
|
212
|
-
if (data && typeof data === "object") {
|
|
213
|
-
const elementCount = Array.isArray(data.elements) ? data.elements.length : 0;
|
|
214
|
-
if (elementCount > 0) label = `Excalidraw Whiteboard (${elementCount} elements)`;
|
|
215
|
-
}
|
|
216
|
-
} catch {}
|
|
217
|
-
return /* @__PURE__ */ jsx("div", {
|
|
218
|
-
"aria-label": label,
|
|
219
|
-
className: excalidrawPlaceholder,
|
|
220
|
-
children: /* @__PURE__ */ jsx("span", { children: label })
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
var ExcalidrawSSRRenderer = ({ onExpand, snapshot }) => {
|
|
224
|
-
return /* @__PURE__ */ jsx(ViewportGate, {
|
|
225
|
-
fallback: /* @__PURE__ */ jsx(ExcalidrawPlaceholder, { snapshot }),
|
|
226
|
-
children: /* @__PURE__ */ jsx(Suspense, {
|
|
227
|
-
fallback: /* @__PURE__ */ jsx(ExcalidrawPlaceholder, { snapshot }),
|
|
228
|
-
children: /* @__PURE__ */ jsx(LazyDisplayRenderer, {
|
|
229
|
-
snapshot,
|
|
230
|
-
onExpand
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/slot.ts
|
|
237
|
-
var EXCALIDRAW_NODE_KEY = "Excalidraw";
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region src/ExcalidrawNode.ts
|
|
240
|
-
var ExcalidrawNode = class ExcalidrawNode extends DecoratorNode {
|
|
241
|
-
static getType() {
|
|
242
|
-
return "excalidraw";
|
|
243
|
-
}
|
|
244
|
-
static clone(node) {
|
|
245
|
-
return new ExcalidrawNode(node.__snapshot, node.__key);
|
|
246
|
-
}
|
|
247
|
-
constructor(snapshot, key) {
|
|
248
|
-
super(key);
|
|
249
|
-
_defineProperty(this, "__snapshot", void 0);
|
|
250
|
-
this.__snapshot = snapshot;
|
|
251
|
-
}
|
|
252
|
-
createDOM(_config) {
|
|
253
|
-
const div = document.createElement("div");
|
|
254
|
-
div.className = "rich-excalidraw-wrapper";
|
|
255
|
-
return div;
|
|
256
|
-
}
|
|
257
|
-
updateDOM() {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
isInline() {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
static importJSON(_serializedNode) {
|
|
264
|
-
return $createExcalidrawNode(_serializedNode.snapshot).updateFromJSON(_serializedNode);
|
|
265
|
-
}
|
|
266
|
-
exportJSON() {
|
|
267
|
-
return {
|
|
268
|
-
...super.exportJSON(),
|
|
269
|
-
type: "excalidraw",
|
|
270
|
-
snapshot: this.__snapshot,
|
|
271
|
-
version: 1
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
getSnapshot() {
|
|
275
|
-
return this.__snapshot;
|
|
276
|
-
}
|
|
277
|
-
setSnapshot(snapshot) {
|
|
278
|
-
const writable = this.getWritable();
|
|
279
|
-
writable.__snapshot = snapshot;
|
|
280
|
-
}
|
|
281
|
-
decorate(_editor, _config) {
|
|
282
|
-
return createRendererDecoration(EXCALIDRAW_NODE_KEY, ExcalidrawSSRRenderer, { snapshot: this.__snapshot });
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
function $createExcalidrawNode(snapshot) {
|
|
286
|
-
return new ExcalidrawNode(snapshot);
|
|
287
|
-
}
|
|
288
|
-
function $isExcalidrawNode(node) {
|
|
289
|
-
return node instanceof ExcalidrawNode;
|
|
290
|
-
}
|
|
291
|
-
//#endregion
|
|
292
|
-
//#region src/ExcalidrawExpandShell.tsx
|
|
293
|
-
var ExcalidrawExpandShell = ({ children, dismiss, meta = "excalidraw", title = "Whiteboard" }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
294
|
-
className: excalidrawDialogHeader,
|
|
295
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
296
|
-
className: excalidrawDialogHeaderTitle,
|
|
297
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
298
|
-
className: excalidrawDialogTitle,
|
|
299
|
-
children: title
|
|
300
|
-
}), meta != null && /* @__PURE__ */ jsx("span", {
|
|
301
|
-
className: "_1c3wdzld",
|
|
302
|
-
children: meta
|
|
303
|
-
})]
|
|
304
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
305
|
-
className: excalidrawHeaderClose,
|
|
306
|
-
type: "button",
|
|
307
|
-
onClick: dismiss,
|
|
308
|
-
children: /* @__PURE__ */ jsx(X, { size: 18 })
|
|
309
|
-
})]
|
|
310
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
311
|
-
className: excalidrawDialogCanvas,
|
|
312
|
-
children
|
|
313
|
-
})] });
|
|
314
|
-
//#endregion
|
|
315
|
-
export { ExcalidrawNode as a, ExcalidrawDisplayRenderer as c, $isExcalidrawNode as i, _defineProperty as l, ExcalidrawExpandShell as n, EXCALIDRAW_NODE_KEY as o, $createExcalidrawNode as r, ExcalidrawSSRRenderer as s, EXCALIDRAW_BLOCK_TRANSFORMER as t, __exportAll as u };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
//#region src/ExcalidrawConfigContext.tsx
|
|
4
|
-
var ExcalidrawConfigContext = createContext({});
|
|
5
|
-
function ExcalidrawConfigProvider({ apiUrl, saveSnapshot, children }) {
|
|
6
|
-
const value = useMemo(() => ({
|
|
7
|
-
apiUrl,
|
|
8
|
-
saveSnapshot
|
|
9
|
-
}), [apiUrl, saveSnapshot]);
|
|
10
|
-
return /* @__PURE__ */ jsx(ExcalidrawConfigContext.Provider, {
|
|
11
|
-
value,
|
|
12
|
-
children
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function useExcalidrawConfig() {
|
|
16
|
-
return use(ExcalidrawConfigContext);
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/constants.ts
|
|
20
|
-
var readonlyUIOptions = { canvasActions: {
|
|
21
|
-
toggleTheme: false,
|
|
22
|
-
export: false,
|
|
23
|
-
saveAsImage: false,
|
|
24
|
-
loadScene: false,
|
|
25
|
-
changeViewBackgroundColor: false
|
|
26
|
-
} };
|
|
27
|
-
var fitSceneToViewport = (api) => api.scrollToContent(void 0, {
|
|
28
|
-
fitToViewport: true,
|
|
29
|
-
viewportZoomFactor: .9,
|
|
30
|
-
maxZoom: 1
|
|
31
|
-
});
|
|
32
|
-
var fitSceneOnReady = (api) => {
|
|
33
|
-
const isReady = () => api.getAppState().width > 0 && api.getSceneElements().length > 0;
|
|
34
|
-
if (isReady()) {
|
|
35
|
-
fitSceneToViewport(api);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const unsubscribe = api.onChange(() => {
|
|
39
|
-
if (!isReady()) return;
|
|
40
|
-
unsubscribe();
|
|
41
|
-
fitSceneToViewport(api);
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/styles.css.ts
|
|
46
|
-
var excalidrawStaticContainer = "_1c3wdzl0";
|
|
47
|
-
var excalidrawEditorContainer = "_1c3wdzl1";
|
|
48
|
-
var excalidrawPlaceholder = "_1c3wdzl2";
|
|
49
|
-
var excalidrawLoading = "_1c3wdzl3";
|
|
50
|
-
var excalidrawError = "_1c3wdzl5";
|
|
51
|
-
var excalidrawActionGroup = "_1c3wdzl6";
|
|
52
|
-
var excalidrawActionButton = "_1c3wdzl7";
|
|
53
|
-
var excalidrawFullscreenPopup = "_1c3wdzl8";
|
|
54
|
-
var excalidrawDialogHeader = "_1c3wdzl9";
|
|
55
|
-
var excalidrawDialogHeaderTitle = "_1c3wdzla";
|
|
56
|
-
var excalidrawStatusDot = "_1c3wdzlb";
|
|
57
|
-
var excalidrawDialogTitle = "_1c3wdzlc";
|
|
58
|
-
var excalidrawDialogMeta = "_1c3wdzld";
|
|
59
|
-
var excalidrawHeaderActions = "_1c3wdzle";
|
|
60
|
-
var excalidrawHeaderClose = "_1c3wdzlf";
|
|
61
|
-
var excalidrawActionBarBtn = "_1c3wdzlg";
|
|
62
|
-
var excalidrawActionBarSep = "_1c3wdzlh";
|
|
63
|
-
var excalidrawActionBarUrl = "_1c3wdzli";
|
|
64
|
-
var excalidrawDialogCanvas = "_1c3wdzlj";
|
|
65
|
-
var excalidrawConfirmActions = "_1c3wdzlk";
|
|
66
|
-
var excalidrawConfirmBtn = "_1c3wdzll";
|
|
67
|
-
var excalidrawConfirmBtnPrimary = "_1c3wdzlm";
|
|
68
|
-
var excalidrawConfirmBtnDanger = "_1c3wdzln";
|
|
69
|
-
var excalidrawEditOverlay = "_1c3wdzlo";
|
|
70
|
-
var excalidrawEditLabel = "_1c3wdzlp";
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/types.ts
|
|
73
|
-
var LOCAL_SCENE_PATH = /^(?:\.{1,2}\/)?[\w-][\w./-]*\.excalidraw$/;
|
|
74
|
-
function isLocalScenePath(ref) {
|
|
75
|
-
return LOCAL_SCENE_PATH.test(ref);
|
|
76
|
-
}
|
|
77
|
-
function parseSnapshot(raw) {
|
|
78
|
-
if (!raw || !raw.trim()) return null;
|
|
79
|
-
try {
|
|
80
|
-
const json = JSON.parse(raw);
|
|
81
|
-
if (json && typeof json === "object") return {
|
|
82
|
-
type: "inline",
|
|
83
|
-
data: json
|
|
84
|
-
};
|
|
85
|
-
} catch {}
|
|
86
|
-
const lines = raw.split("\n");
|
|
87
|
-
const firstLine = lines[0].trim();
|
|
88
|
-
if (!firstLine.startsWith("http") && !firstLine.startsWith("blob:") && !firstLine.startsWith("ref:") && !isLocalScenePath(firstLine)) return null;
|
|
89
|
-
const remaining = lines.slice(1).join("\n").trim();
|
|
90
|
-
if (remaining) try {
|
|
91
|
-
const delta = JSON.parse(remaining);
|
|
92
|
-
if (delta && typeof delta === "object") return {
|
|
93
|
-
type: "delta",
|
|
94
|
-
baseUrl: firstLine,
|
|
95
|
-
delta
|
|
96
|
-
};
|
|
97
|
-
} catch {}
|
|
98
|
-
return {
|
|
99
|
-
type: "remote",
|
|
100
|
-
url: firstLine
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function serializeSnapshot(snapshot) {
|
|
104
|
-
switch (snapshot.type) {
|
|
105
|
-
case "inline": return JSON.stringify(snapshot.data);
|
|
106
|
-
case "remote": return snapshot.url;
|
|
107
|
-
case "delta": return [snapshot.baseUrl, JSON.stringify(snapshot.delta)].join("\n");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/useExcalidrawData.ts
|
|
112
|
-
function resolveUrl(url, apiUrl) {
|
|
113
|
-
const refLine = url;
|
|
114
|
-
if (url.startsWith("http") || url.startsWith("blob:") || isLocalScenePath(url)) return {
|
|
115
|
-
fetchUrl: url,
|
|
116
|
-
refLine
|
|
117
|
-
};
|
|
118
|
-
if (url.startsWith("ref:") && apiUrl) return {
|
|
119
|
-
fetchUrl: `${apiUrl}/objects/${url.slice(4)}`,
|
|
120
|
-
refLine
|
|
121
|
-
};
|
|
122
|
-
return { error: url.startsWith("ref:") ? "Missing apiUrl for ref resolution" : "Unrecognized snapshot format" };
|
|
123
|
-
}
|
|
124
|
-
function typedToParsed(typed, apiUrl) {
|
|
125
|
-
switch (typed.type) {
|
|
126
|
-
case "inline": return {
|
|
127
|
-
type: "inline",
|
|
128
|
-
snapshot: typed.data
|
|
129
|
-
};
|
|
130
|
-
case "remote": {
|
|
131
|
-
const result = resolveUrl(typed.url, apiUrl);
|
|
132
|
-
if ("error" in result) return {
|
|
133
|
-
type: "error",
|
|
134
|
-
error: result.error
|
|
135
|
-
};
|
|
136
|
-
return {
|
|
137
|
-
type: "remote",
|
|
138
|
-
fetchUrl: result.fetchUrl,
|
|
139
|
-
refLine: result.refLine
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
case "delta": {
|
|
143
|
-
const result = resolveUrl(typed.baseUrl, apiUrl);
|
|
144
|
-
if ("error" in result) return {
|
|
145
|
-
type: "error",
|
|
146
|
-
error: result.error
|
|
147
|
-
};
|
|
148
|
-
return {
|
|
149
|
-
type: "incremental",
|
|
150
|
-
fetchUrl: result.fetchUrl,
|
|
151
|
-
refLine: result.refLine,
|
|
152
|
-
delta: typed.delta
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function stringToParsed(data, apiUrl) {
|
|
158
|
-
const typed = parseSnapshot(data);
|
|
159
|
-
if (!typed) return { type: "empty" };
|
|
160
|
-
return typedToParsed(typed, apiUrl);
|
|
161
|
-
}
|
|
162
|
-
function useExcalidrawData(data) {
|
|
163
|
-
const { apiUrl } = useExcalidrawConfig();
|
|
164
|
-
const parsed = useMemo(() => {
|
|
165
|
-
if (data === null || data === void 0) return { type: "empty" };
|
|
166
|
-
if (typeof data === "string") return stringToParsed(data, apiUrl);
|
|
167
|
-
return typedToParsed(data, apiUrl);
|
|
168
|
-
}, [data, apiUrl]);
|
|
169
|
-
const [remoteSnapshot, setRemoteSnapshot] = useState();
|
|
170
|
-
const [baseData, setBaseData] = useState();
|
|
171
|
-
const [loading, setLoading] = useState(parsed.type === "remote" || parsed.type === "incremental");
|
|
172
|
-
const [error, setError] = useState("");
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
if (parsed.type !== "remote" && parsed.type !== "incremental") return;
|
|
175
|
-
const { fetchUrl } = parsed;
|
|
176
|
-
const delta = parsed.type === "incremental" ? parsed.delta : void 0;
|
|
177
|
-
let cancelled = false;
|
|
178
|
-
setLoading(true);
|
|
179
|
-
setError("");
|
|
180
|
-
fetch(fetchUrl).then((res) => {
|
|
181
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
182
|
-
return res.json();
|
|
183
|
-
}).then(async (json) => {
|
|
184
|
-
if (cancelled) return;
|
|
185
|
-
setBaseData(json);
|
|
186
|
-
if ((delta ? Object.keys(delta) : []).length > 0) {
|
|
187
|
-
const { patch } = await import("jsondiffpatch");
|
|
188
|
-
if (cancelled) return;
|
|
189
|
-
const patched = patch(structuredClone(json), delta);
|
|
190
|
-
setRemoteSnapshot(patched);
|
|
191
|
-
} else setRemoteSnapshot(json);
|
|
192
|
-
setLoading(false);
|
|
193
|
-
}).catch((err) => {
|
|
194
|
-
if (!cancelled) {
|
|
195
|
-
setError(err instanceof Error ? err.message : "Failed to load");
|
|
196
|
-
setLoading(false);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
return () => {
|
|
200
|
-
cancelled = true;
|
|
201
|
-
};
|
|
202
|
-
}, [parsed]);
|
|
203
|
-
if (parsed.type === "inline") return {
|
|
204
|
-
snapshot: parsed.snapshot,
|
|
205
|
-
loading: false,
|
|
206
|
-
error: ""
|
|
207
|
-
};
|
|
208
|
-
if (parsed.type === "remote" || parsed.type === "incremental") return {
|
|
209
|
-
snapshot: remoteSnapshot,
|
|
210
|
-
loading,
|
|
211
|
-
error,
|
|
212
|
-
baseRef: parsed.refLine,
|
|
213
|
-
baseData
|
|
214
|
-
};
|
|
215
|
-
if (parsed.type === "error") return {
|
|
216
|
-
snapshot: void 0,
|
|
217
|
-
loading: false,
|
|
218
|
-
error: parsed.error
|
|
219
|
-
};
|
|
220
|
-
return {
|
|
221
|
-
snapshot: void 0,
|
|
222
|
-
loading: false,
|
|
223
|
-
error: ""
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
//#endregion
|
|
227
|
-
export { fitSceneOnReady as A, excalidrawFullscreenPopup as C, excalidrawPlaceholder as D, excalidrawLoading as E, readonlyUIOptions as M, ExcalidrawConfigProvider as N, excalidrawStaticContainer as O, useExcalidrawConfig as P, excalidrawError as S, excalidrawHeaderClose as T, excalidrawDialogMeta as _, excalidrawActionBarBtn as a, excalidrawEditOverlay as b, excalidrawActionButton as c, excalidrawConfirmBtn as d, excalidrawConfirmBtnDanger as f, excalidrawDialogHeaderTitle as g, excalidrawDialogHeader as h, serializeSnapshot as i, fitSceneToViewport as j, excalidrawStatusDot as k, excalidrawActionGroup as l, excalidrawDialogCanvas as m, isLocalScenePath as n, excalidrawActionBarSep as o, excalidrawConfirmBtnPrimary as p, parseSnapshot as r, excalidrawActionBarUrl as s, useExcalidrawData as t, excalidrawConfirmActions as u, excalidrawDialogTitle as v, excalidrawHeaderActions as w, excalidrawEditorContainer as x, excalidrawEditLabel as y };
|