@haklex/rich-ext-excalidraw 0.0.65 → 0.0.66

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 ADDED
@@ -0,0 +1,147 @@
1
+ # @haklex/rich-ext-excalidraw
2
+
3
+ Excalidraw whiteboard integration for the Haklex rich editor.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @haklex/rich-ext-excalidraw
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ | Package | Version |
14
+ | --- | --- |
15
+ | `@lexical/react` | `^0.41.0` |
16
+ | `lexical` | `^0.41.0` |
17
+ | `lucide-react` | `^0.574.0` |
18
+ | `react` | `>= 19` |
19
+ | `react-dom` | `>= 19` |
20
+
21
+ ## Usage
22
+
23
+ ### Register nodes in your editor config
24
+
25
+ ```ts
26
+ import { ExcalidrawEditNode } from '@haklex/rich-ext-excalidraw'
27
+
28
+ const editorConfig = {
29
+ nodes: [ExcalidrawEditNode],
30
+ }
31
+ ```
32
+
33
+ For static/read-only rendering:
34
+
35
+ ```ts
36
+ import { ExcalidrawNode } from '@haklex/rich-ext-excalidraw/static'
37
+
38
+ const staticConfig = {
39
+ nodes: [ExcalidrawNode],
40
+ }
41
+ ```
42
+
43
+ ### Use the Excalidraw plugin
44
+
45
+ ```tsx
46
+ import { ExcalidrawPlugin } from '@haklex/rich-ext-excalidraw'
47
+
48
+ function EditorPlugins() {
49
+ return <ExcalidrawPlugin />
50
+ }
51
+ ```
52
+
53
+ ### Insert an Excalidraw block programmatically
54
+
55
+ ```ts
56
+ import { INSERT_EXCALIDRAW_COMMAND } from '@haklex/rich-ext-excalidraw'
57
+
58
+ editor.dispatchCommand(INSERT_EXCALIDRAW_COMMAND, undefined)
59
+ ```
60
+
61
+ ### Configure Excalidraw behavior
62
+
63
+ ```tsx
64
+ import { ExcalidrawConfigProvider } from '@haklex/rich-ext-excalidraw'
65
+ import type { ExcalidrawConfig } from '@haklex/rich-ext-excalidraw'
66
+
67
+ const config: ExcalidrawConfig = {
68
+ // your Excalidraw configuration
69
+ }
70
+
71
+ function App() {
72
+ return (
73
+ <ExcalidrawConfigProvider value={config}>
74
+ <Editor />
75
+ </ExcalidrawConfigProvider>
76
+ )
77
+ }
78
+ ```
79
+
80
+ ### Use renderers
81
+
82
+ ```tsx
83
+ import { ExcalidrawEditRenderer } from '@haklex/rich-ext-excalidraw'
84
+ import { ExcalidrawDisplayRenderer, ExcalidrawSSRRenderer } from '@haklex/rich-ext-excalidraw/static'
85
+ ```
86
+
87
+ ### Snapshot utilities
88
+
89
+ ```ts
90
+ import { parseSnapshot, serializeSnapshot } from '@haklex/rich-ext-excalidraw'
91
+ ```
92
+
93
+ ### Import styles
94
+
95
+ ```ts
96
+ import '@haklex/rich-ext-excalidraw/style.css'
97
+ ```
98
+
99
+ ## Exports
100
+
101
+ ### Nodes
102
+
103
+ - `ExcalidrawNode` -- static (read-only) node
104
+ - `ExcalidrawEditNode` -- edit node with full Excalidraw editor
105
+ - `$createExcalidrawNode()` / `$isExcalidrawNode()` -- Lexical helpers
106
+
107
+ ### Renderers
108
+
109
+ - `ExcalidrawDisplayRenderer` -- static display renderer
110
+ - `ExcalidrawEditRenderer` -- interactive edit renderer
111
+ - `ExcalidrawSSRRenderer` -- server-side rendering renderer
112
+
113
+ ### Plugin
114
+
115
+ - `ExcalidrawPlugin` -- editor plugin for Excalidraw block insertion
116
+ - `INSERT_EXCALIDRAW_COMMAND` -- Lexical command for programmatic insertion
117
+
118
+ ### Context
119
+
120
+ - `ExcalidrawConfigProvider` -- context provider for Excalidraw configuration
121
+ - `useExcalidrawConfig` -- hook to access Excalidraw config context
122
+
123
+ ### Utilities
124
+
125
+ - `parseSnapshot` -- deserialize an Excalidraw snapshot
126
+ - `serializeSnapshot` -- serialize an Excalidraw snapshot
127
+
128
+ ### Types
129
+
130
+ - `ExcalidrawConfig` -- configuration type
131
+ - `ExcalidrawSnapshot` -- snapshot data type
132
+
133
+ ### Sub-path Exports
134
+
135
+ | Path | Description |
136
+ | --- | --- |
137
+ | `@haklex/rich-ext-excalidraw` | Full exports (edit + static) |
138
+ | `@haklex/rich-ext-excalidraw/static` | Static-only (no Excalidraw editor deps) |
139
+ | `@haklex/rich-ext-excalidraw/style.css` | Stylesheet |
140
+
141
+ ## Part of Haklex
142
+
143
+ This package is part of the [Haklex](../../README.md) rich editor ecosystem.
144
+
145
+ ## License
146
+
147
+ MIT
@@ -1 +1 @@
1
- {"version":3,"file":"ExcalidrawDisplayRenderer.d.ts","sourceRoot":"","sources":["../src/ExcalidrawDisplayRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAiC,KAAK,EAAE,EAAkB,MAAM,OAAO,CAAA;AAO9E,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,yBAAyB,EAAE,EAAE,CAAC,6BAA6B,CAKvE,CAAA"}
1
+ {"version":3,"file":"ExcalidrawDisplayRenderer.d.ts","sourceRoot":"","sources":["../src/ExcalidrawDisplayRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiC,KAAK,EAAE,EAAkB,MAAM,OAAO,CAAC;AAO/E,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,yBAAyB,EAAE,EAAE,CAAC,6BAA6B,CAGvE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { CommandItemConfig } from '@haklex/rich-editor';
1
+ import { CommandItemConfig } from '@haklex/rich-editor/commands';
2
2
  import { EditorConfig, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
3
3
  import { ReactElement } from 'react';
4
4
  import { ExcalidrawNode, SerializedExcalidrawNode } from './ExcalidrawNode';
@@ -1 +1 @@
1
- {"version":3,"file":"ExcalidrawEditNode.d.ts","sourceRoot":"","sources":["../src/ExcalidrawEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,cAAc,EAAE,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAUhF,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAevC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB;gBAI9C,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO;IAI3C,MAAM,CAAC,UAAU,CACf,cAAc,EAAE,wBAAwB,GACvC,kBAAkB;IAIrB,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,YAAY;CAqCpE;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAEpB;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,kBAAkB,CAE5B"}
1
+ {"version":3,"file":"ExcalidrawEditNode.d.ts","sourceRoot":"","sources":["../src/ExcalidrawEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAUjF,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAetC;IAEF,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB;gBAI9C,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO;IAI3C,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,wBAAwB,GAAG,kBAAkB;IAI/E,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,YAAY;CAqCpE;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAE9E;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,kBAAkB,CAE5B"}
@@ -1,8 +1,8 @@
1
1
  import { FC } from 'react';
2
2
  import { ExcalidrawSnapshot } from './types';
3
3
  export interface ExcalidrawEditRendererProps {
4
- snapshot: ExcalidrawSnapshot | null;
5
4
  onSnapshotChange: (snapshot: ExcalidrawSnapshot) => void;
5
+ snapshot: ExcalidrawSnapshot | null;
6
6
  }
7
7
  export declare const ExcalidrawEditRenderer: FC<ExcalidrawEditRendererProps>;
8
8
  //# sourceMappingURL=ExcalidrawEditRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExcalidrawEditRenderer.d.ts","sourceRoot":"","sources":["../src/ExcalidrawEditRenderer.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAiB,EAAE,EAAE,MAAM,OAAO,CAAA;AAM9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAGjD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAA;IACnC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAA;CACzD;AA2aD,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAiIlE,CAAA"}
1
+ {"version":3,"file":"ExcalidrawEditRenderer.d.ts","sourceRoot":"","sources":["../src/ExcalidrawEditRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAiB,EAAE,EAAE,MAAM,OAAO,CAAC;AAM/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACzD,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACrC;AAqZD,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CA0HlE,CAAC"}
@@ -72,8 +72,7 @@ function parseSnapshot(raw) {
72
72
  if (remaining) {
73
73
  try {
74
74
  const delta = JSON.parse(remaining);
75
- if (delta && typeof delta === "object")
76
- return { type: "delta", baseUrl: firstLine, delta };
75
+ if (delta && typeof delta === "object") return { type: "delta", baseUrl: firstLine, delta };
77
76
  } catch {
78
77
  }
79
78
  }
@@ -81,12 +80,15 @@ function parseSnapshot(raw) {
81
80
  }
82
81
  function serializeSnapshot(snapshot) {
83
82
  switch (snapshot.type) {
84
- case "inline":
83
+ case "inline": {
85
84
  return JSON.stringify(snapshot.data);
86
- case "remote":
85
+ }
86
+ case "remote": {
87
87
  return snapshot.url;
88
- case "delta":
88
+ }
89
+ case "delta": {
89
90
  return [snapshot.baseUrl, JSON.stringify(snapshot.delta)].join("\n");
91
+ }
90
92
  }
91
93
  }
92
94
  function resolveUrl(url, apiUrl) {
@@ -103,8 +105,9 @@ function resolveUrl(url, apiUrl) {
103
105
  }
104
106
  function typedToParsed(typed, apiUrl) {
105
107
  switch (typed.type) {
106
- case "inline":
108
+ case "inline": {
107
109
  return { type: "inline", snapshot: typed.data };
110
+ }
108
111
  case "remote": {
109
112
  const result = resolveUrl(typed.url, apiUrl);
110
113
  if ("error" in result) return { type: "error", error: result.error };
@@ -140,9 +143,7 @@ function useExcalidrawData(data) {
140
143
  }, [data, apiUrl]);
141
144
  const [remoteSnapshot, setRemoteSnapshot] = useState();
142
145
  const [baseData, setBaseData] = useState();
143
- const [loading, setLoading] = useState(
144
- parsed.type === "remote" || parsed.type === "incremental"
145
- );
146
+ const [loading, setLoading] = useState(parsed.type === "remote" || parsed.type === "incremental");
146
147
  const [error, setError] = useState("");
147
148
  useEffect(() => {
148
149
  if (parsed.type !== "remote" && parsed.type !== "incremental") return;
@@ -194,9 +195,7 @@ function useExcalidrawData(data) {
194
195
  }
195
196
  return { snapshot: void 0, loading: false, error: "" };
196
197
  }
197
- const ExcalidrawDisplayRenderer = ({
198
- snapshot
199
- }) => {
198
+ const ExcalidrawDisplayRenderer = ({ snapshot }) => {
200
199
  const theme = useColorScheme();
201
200
  return /* @__PURE__ */ jsx(ExcalidrawStaticCanvas, { snapshot, theme });
202
201
  };
@@ -208,24 +207,16 @@ const ExcalidrawExpandContent = ({ dismiss, ExcalidrawComponent, data, theme })
208
207
  /* @__PURE__ */ jsx("span", { className: excalidrawDialogTitle, children: "Whiteboard" }),
209
208
  /* @__PURE__ */ jsx("span", { className: excalidrawDialogMeta, children: "excalidraw" })
210
209
  ] }),
211
- /* @__PURE__ */ jsx(
212
- "button",
213
- {
214
- type: "button",
215
- className: excalidrawHeaderClose,
216
- onClick: dismiss,
217
- children: /* @__PURE__ */ jsx(X, { size: 18 })
218
- }
219
- )
210
+ /* @__PURE__ */ jsx("button", { className: excalidrawHeaderClose, type: "button", onClick: dismiss, children: /* @__PURE__ */ jsx(X, { size: 18 }) })
220
211
  ] }),
221
212
  /* @__PURE__ */ jsx("div", { className: excalidrawDialogCanvas, children: /* @__PURE__ */ jsx(
222
213
  ExcalidrawComponent,
223
214
  {
224
- initialData: data,
225
215
  viewModeEnabled: true,
226
216
  zenModeEnabled: true,
227
- theme,
228
217
  UIOptions: readonlyUIOptions,
218
+ initialData: data,
219
+ theme,
229
220
  excalidrawAPI: (api) => {
230
221
  apiRef.current = api;
231
222
  setTimeout(() => api.scrollToContent(), 100);
@@ -235,11 +226,7 @@ const ExcalidrawExpandContent = ({ dismiss, ExcalidrawComponent, data, theme })
235
226
  ] });
236
227
  };
237
228
  const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
238
- const {
239
- snapshot: data,
240
- loading: dataLoading,
241
- error: dataError
242
- } = useExcalidrawData(snapshot);
229
+ const { snapshot: data, loading: dataLoading, error: dataError } = useExcalidrawData(snapshot);
243
230
  const [ExcalidrawComponent, setExcalidrawComponent] = useState(null);
244
231
  const [libLoading, setLibLoading] = useState(true);
245
232
  const apiRef = useRef(null);
@@ -247,8 +234,7 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
247
234
  useEffect(() => {
248
235
  import("@excalidraw/excalidraw").then((mod) => {
249
236
  const Comp = mod.Excalidraw;
250
- if (Comp)
251
- setExcalidrawComponent(() => Comp);
237
+ if (Comp) setExcalidrawComponent(() => Comp);
252
238
  setLibLoading(false);
253
239
  }).catch((error) => {
254
240
  console.error("Error loading excalidraw", error);
@@ -261,9 +247,9 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
261
247
  content: ({ dismiss }) => /* @__PURE__ */ jsx(
262
248
  ExcalidrawExpandContent,
263
249
  {
264
- dismiss,
265
250
  ExcalidrawComponent,
266
251
  data,
252
+ dismiss,
267
253
  theme
268
254
  }
269
255
  ),
@@ -287,10 +273,10 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
287
273
  return /* @__PURE__ */ jsxs(
288
274
  "div",
289
275
  {
276
+ suppressHydrationWarning: true,
290
277
  className: excalidrawStaticContainer,
291
- "data-theme": theme,
292
278
  "data-color-scheme": theme,
293
- suppressHydrationWarning: true,
279
+ "data-theme": theme,
294
280
  children: [
295
281
  /* @__PURE__ */ jsx(
296
282
  ExcalidrawErrorBoundary,
@@ -299,11 +285,11 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
299
285
  children: /* @__PURE__ */ jsx(
300
286
  ExcalidrawComponent,
301
287
  {
302
- initialData: data,
303
288
  viewModeEnabled: true,
304
289
  zenModeEnabled: true,
305
- theme,
306
290
  UIOptions: readonlyUIOptions,
291
+ initialData: data,
292
+ theme,
307
293
  excalidrawAPI: (api) => {
308
294
  apiRef.current = api;
309
295
  setTimeout(() => api.scrollToContent(), 100);
@@ -316,9 +302,9 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
316
302
  /* @__PURE__ */ jsx(
317
303
  "button",
318
304
  {
319
- type: "button",
320
305
  className: excalidrawActionButton,
321
306
  title: "Zoom In",
307
+ type: "button",
322
308
  onClick: () => {
323
309
  const api = apiRef.current;
324
310
  if (!api) return;
@@ -331,9 +317,9 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
331
317
  /* @__PURE__ */ jsx(
332
318
  "button",
333
319
  {
334
- type: "button",
335
320
  className: excalidrawActionButton,
336
321
  title: "Zoom Out",
322
+ type: "button",
337
323
  onClick: () => {
338
324
  const api = apiRef.current;
339
325
  if (!api) return;
@@ -346,9 +332,9 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
346
332
  /* @__PURE__ */ jsx(
347
333
  "button",
348
334
  {
349
- type: "button",
350
335
  className: excalidrawActionButton,
351
336
  title: "Fit to Content",
337
+ type: "button",
352
338
  onClick: () => apiRef.current?.scrollToContent(),
353
339
  children: /* @__PURE__ */ jsx(ScanSearch, { size: 20 })
354
340
  }
@@ -356,9 +342,9 @@ const ExcalidrawStaticCanvas = ({ snapshot, theme }) => {
356
342
  /* @__PURE__ */ jsx(
357
343
  "button",
358
344
  {
359
- type: "button",
360
345
  className: excalidrawActionButton,
361
346
  title: "Expand",
347
+ type: "button",
362
348
  onClick: handleExpand,
363
349
  children: /* @__PURE__ */ jsx(Maximize2, { size: 20 })
364
350
  }
@@ -401,11 +387,9 @@ const ExcalidrawPlaceholder = ({ snapshot }) => {
401
387
  }
402
388
  } catch {
403
389
  }
404
- return /* @__PURE__ */ jsx("div", { className: excalidrawPlaceholder, "aria-label": label, children: /* @__PURE__ */ jsx("span", { children: label }) });
390
+ return /* @__PURE__ */ jsx("div", { "aria-label": label, className: excalidrawPlaceholder, children: /* @__PURE__ */ jsx("span", { children: label }) });
405
391
  };
406
- const ExcalidrawSSRRenderer = ({
407
- snapshot
408
- }) => {
392
+ const ExcalidrawSSRRenderer = ({ snapshot }) => {
409
393
  return /* @__PURE__ */ jsx(ViewportGate, { fallback: /* @__PURE__ */ jsx(ExcalidrawPlaceholder, { snapshot }), children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ExcalidrawPlaceholder, { snapshot }), children: /* @__PURE__ */ jsx(LazyDisplayRenderer, { snapshot }) }) });
410
394
  };
411
395
  class ExcalidrawNode extends DecoratorNode {
@@ -1 +1 @@
1
- {"version":3,"file":"ExcalidrawSSRRenderer.d.ts","sourceRoot":"","sources":["../src/ExcalidrawSSRRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAK/B,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAA;CACjB;AA+BD,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAUhE,CAAA"}
1
+ {"version":3,"file":"ExcalidrawSSRRenderer.d.ts","sourceRoot":"","sources":["../src/ExcalidrawSSRRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AA6BD,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAQhE,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { c as ExcalidrawNode, s as serializeSnapshot, p as parseSnapshot, u as useExcalidrawConfig, e as useExcalidrawData, f as excalidrawFullscreenPopup, g as excalidrawEditorContainer, h as excalidrawLoading, i as excalidrawError, r as readonlyUIOptions, j as excalidrawEditOverlay, k as excalidrawEditLabel, l as excalidrawConfirmActions, m as excalidrawConfirmBtn, n as excalidrawConfirmBtnDanger, o as excalidrawConfirmBtnPrimary, q as excalidrawDialogHeader, t as excalidrawStatusDot, v as excalidrawDialogTitle, w as excalidrawDialogMeta, x as excalidrawHeaderActions, y as excalidrawActionBarSep, z as excalidrawActionBarBtn, A as excalidrawActionBarUrl, B as excalidrawHeaderClose, C as excalidrawDialogCanvas } from "./ExcalidrawNode-BnvRq6SZ.js";
5
- import { $, a, E, b, b as b2, d, b as b3 } from "./ExcalidrawNode-BnvRq6SZ.js";
4
+ import { c as ExcalidrawNode, s as serializeSnapshot, p as parseSnapshot, u as useExcalidrawConfig, e as useExcalidrawData, f as excalidrawFullscreenPopup, g as excalidrawEditorContainer, h as excalidrawLoading, i as excalidrawError, r as readonlyUIOptions, j as excalidrawEditOverlay, k as excalidrawEditLabel, l as excalidrawConfirmActions, m as excalidrawConfirmBtn, n as excalidrawConfirmBtnDanger, o as excalidrawConfirmBtnPrimary, q as excalidrawDialogHeader, t as excalidrawStatusDot, v as excalidrawDialogTitle, w as excalidrawDialogMeta, x as excalidrawHeaderActions, y as excalidrawActionBarSep, z as excalidrawActionBarBtn, A as excalidrawActionBarUrl, B as excalidrawHeaderClose, C as excalidrawDialogCanvas } from "./ExcalidrawNode-DEcONli3.js";
5
+ import { $, a, E, b, b as b2, d, b as b3 } from "./ExcalidrawNode-DEcONli3.js";
6
6
  import { ViewportGate, presentDialog, SegmentedControl, dismissTopDialog } from "@haklex/rich-editor-ui";
7
7
  import { $insertNodes, $getNodeByKey, createCommand, COMMAND_PRIORITY_EDITOR } from "lexical";
8
8
  import { PenTool, Pencil, Save, Download, Clipboard, X } from "lucide-react";
@@ -107,12 +107,10 @@ const ExcalidrawEditorDialogContent = ({
107
107
  const initializedRef = useRef(false);
108
108
  const baseRefRef = useRef(baseRef);
109
109
  const baseDataRef = useRef(baseData);
110
- const [storageMode, setStorageMode] = useState(
111
- () => {
112
- if (!saveSnapshot || !initialSnapshot) return "inline";
113
- return initialSnapshot.type === "delta" ? "delta" : initialSnapshot.type === "remote" ? "remote" : "inline";
114
- }
115
- );
110
+ const [storageMode, setStorageMode] = useState(() => {
111
+ if (!saveSnapshot || !initialSnapshot) return "inline";
112
+ return initialSnapshot.type === "delta" ? "delta" : initialSnapshot.type === "remote" ? "remote" : "inline";
113
+ });
116
114
  const storageModeRef = useRef(storageMode);
117
115
  const [savedRef, setSavedRef] = useState(() => {
118
116
  if (!saveSnapshot || !initialSnapshot) return "";
@@ -258,20 +256,12 @@ const ExcalidrawEditorDialogContent = ({
258
256
  dismissConfirm();
259
257
  };
260
258
  return /* @__PURE__ */ jsxs("div", { className: excalidrawConfirmActions, children: [
259
+ /* @__PURE__ */ jsx("button", { className: excalidrawConfirmBtn, type: "button", onClick: wrappedDismiss, children: "Continue Editing" }),
261
260
  /* @__PURE__ */ jsx(
262
261
  "button",
263
262
  {
264
- type: "button",
265
- className: excalidrawConfirmBtn,
266
- onClick: wrappedDismiss,
267
- children: "Continue Editing"
268
- }
269
- ),
270
- /* @__PURE__ */ jsx(
271
- "button",
272
- {
273
- type: "button",
274
263
  className: excalidrawConfirmBtnDanger,
264
+ type: "button",
275
265
  onClick: () => {
276
266
  wrappedDismiss();
277
267
  handleDiscard();
@@ -282,8 +272,8 @@ const ExcalidrawEditorDialogContent = ({
282
272
  /* @__PURE__ */ jsx(
283
273
  "button",
284
274
  {
285
- type: "button",
286
275
  className: excalidrawConfirmBtnPrimary,
276
+ type: "button",
287
277
  onClick: () => {
288
278
  wrappedDismiss();
289
279
  handleSaveAndClose();
@@ -346,15 +336,12 @@ const ExcalidrawEditorDialogContent = ({
346
336
  if (!doc) return;
347
337
  void navigator.clipboard.writeText(JSON.stringify(doc));
348
338
  }, [getSnapshot]);
349
- const handleRefChange = useCallback(
350
- (e) => {
351
- const { value } = e.target;
352
- setSavedRef(value);
353
- baseRefRef.current = value;
354
- baseDataRef.current = void 0;
355
- },
356
- []
357
- );
339
+ const handleRefChange = useCallback((e) => {
340
+ const { value } = e.target;
341
+ setSavedRef(value);
342
+ baseRefRef.current = value;
343
+ baseDataRef.current = void 0;
344
+ }, []);
358
345
  const handleStorageModeChange = useCallback(
359
346
  (newMode) => {
360
347
  setStorageMode(newMode);
@@ -380,12 +367,12 @@ const ExcalidrawEditorDialogContent = ({
380
367
  /* @__PURE__ */ jsx(
381
368
  SegmentedControl,
382
369
  {
370
+ value: storageMode,
383
371
  items: [
384
372
  { value: "inline", label: "Inline" },
385
373
  { value: "remote", label: "Remote" },
386
374
  { value: "delta", label: "Delta" }
387
375
  ],
388
- value: storageMode,
389
376
  onChange: handleStorageModeChange
390
377
  }
391
378
  ),
@@ -393,10 +380,10 @@ const ExcalidrawEditorDialogContent = ({
393
380
  /* @__PURE__ */ jsxs(
394
381
  "button",
395
382
  {
396
- type: "button",
397
383
  className: excalidrawActionBarBtn,
398
- onClick: handleManualUpload,
399
384
  disabled: isSaving,
385
+ type: "button",
386
+ onClick: handleManualUpload,
400
387
  children: [
401
388
  /* @__PURE__ */ jsx(Save, { size: 14 }),
402
389
  /* @__PURE__ */ jsx("span", { children: isSaving ? "Saving..." : "Save" })
@@ -405,64 +392,40 @@ const ExcalidrawEditorDialogContent = ({
405
392
  ),
406
393
  /* @__PURE__ */ jsx("div", { className: excalidrawActionBarSep })
407
394
  ] }),
408
- /* @__PURE__ */ jsxs(
409
- "button",
410
- {
411
- type: "button",
412
- className: excalidrawActionBarBtn,
413
- onClick: handleExportJson,
414
- children: [
415
- /* @__PURE__ */ jsx(Download, { size: 14 }),
416
- "JSON"
417
- ]
418
- }
419
- ),
420
- /* @__PURE__ */ jsxs(
421
- "button",
422
- {
423
- type: "button",
424
- className: excalidrawActionBarBtn,
425
- onClick: handleCopyJson,
426
- children: [
427
- /* @__PURE__ */ jsx(Clipboard, { size: 14 }),
428
- "Copy"
429
- ]
430
- }
431
- ),
395
+ /* @__PURE__ */ jsxs("button", { className: excalidrawActionBarBtn, type: "button", onClick: handleExportJson, children: [
396
+ /* @__PURE__ */ jsx(Download, { size: 14 }),
397
+ "JSON"
398
+ ] }),
399
+ /* @__PURE__ */ jsxs("button", { className: excalidrawActionBarBtn, type: "button", onClick: handleCopyJson, children: [
400
+ /* @__PURE__ */ jsx(Clipboard, { size: 14 }),
401
+ "Copy"
402
+ ] }),
432
403
  storageMode !== "inline" && /* @__PURE__ */ jsxs(Fragment, { children: [
433
404
  /* @__PURE__ */ jsx("div", { className: excalidrawActionBarSep }),
434
405
  /* @__PURE__ */ jsx(
435
406
  "input",
436
407
  {
437
- type: "text",
438
408
  className: excalidrawActionBarUrl,
439
- value: savedRef,
440
- onChange: handleRefChange,
441
409
  placeholder: "base URL / ref",
442
- spellCheck: false
410
+ spellCheck: false,
411
+ type: "text",
412
+ value: savedRef,
413
+ onChange: handleRefChange
443
414
  }
444
415
  )
445
416
  ] })
446
417
  ] }),
447
- /* @__PURE__ */ jsx(
448
- "button",
449
- {
450
- type: "button",
451
- className: excalidrawHeaderClose,
452
- onClick: attemptClose,
453
- children: /* @__PURE__ */ jsx(X, { size: 18 })
454
- }
455
- )
418
+ /* @__PURE__ */ jsx("button", { className: excalidrawHeaderClose, type: "button", onClick: attemptClose, children: /* @__PURE__ */ jsx(X, { size: 18 }) })
456
419
  ] }),
457
420
  /* @__PURE__ */ jsx("div", { className: excalidrawDialogCanvas, children: /* @__PURE__ */ jsx(
458
421
  ExcalidrawComponent,
459
422
  {
460
423
  initialData,
461
424
  theme,
462
- onChange: handleChange,
463
425
  excalidrawAPI: (api) => {
464
426
  apiRef.current = api;
465
- }
427
+ },
428
+ onChange: handleChange
466
429
  }
467
430
  ) })
468
431
  ] });
@@ -518,21 +481,21 @@ const ExcalidrawEditRenderer = ({
518
481
  content: ({ dismiss }) => /* @__PURE__ */ jsx(
519
482
  ExcalidrawEditorDialogContent,
520
483
  {
521
- dismiss,
522
484
  ExcalidrawComponent,
485
+ baseData: baseDataRefOuter.current,
486
+ baseRef: baseRefRef.current,
487
+ dismiss,
523
488
  initialData: initialDataRef.current,
524
489
  initialSnapshot: snapshotRef.current,
490
+ saveSnapshot: saveSnapshotRef.current,
525
491
  theme,
526
492
  onSave: (ref) => onSnapshotChangeRef.current(ref),
527
- saveSnapshot: saveSnapshotRef.current,
528
493
  onClose: (doc) => {
529
494
  if (doc) {
530
495
  initialDataRef.current = doc;
531
496
  setPreviewKey((k) => k + 1);
532
497
  }
533
- },
534
- baseRef: baseRefRef.current,
535
- baseData: baseDataRefOuter.current
498
+ }
536
499
  }
537
500
  ),
538
501
  className: excalidrawFullscreenPopup,
@@ -553,11 +516,11 @@ const ExcalidrawEditRenderer = ({
553
516
  /* @__PURE__ */ jsx(
554
517
  ExcalidrawComponent,
555
518
  {
556
- initialData: initialDataRef.current,
557
519
  viewModeEnabled: true,
558
520
  zenModeEnabled: true,
559
- theme,
560
521
  UIOptions: readonlyUIOptions,
522
+ initialData: initialDataRef.current,
523
+ theme,
561
524
  excalidrawAPI: (api) => {
562
525
  previewApiRef.current = api;
563
526
  setTimeout(() => api.scrollToContent(), 100);
@@ -565,18 +528,10 @@ const ExcalidrawEditRenderer = ({
565
528
  },
566
529
  previewKey
567
530
  ),
568
- /* @__PURE__ */ jsx(
569
- "button",
570
- {
571
- type: "button",
572
- className: excalidrawEditOverlay,
573
- onClick: handleOpenEditor,
574
- children: /* @__PURE__ */ jsxs("span", { className: excalidrawEditLabel, children: [
575
- /* @__PURE__ */ jsx(Pencil, { size: 16 }),
576
- "Edit Whiteboard"
577
- ] })
578
- }
579
- )
531
+ /* @__PURE__ */ jsx("button", { className: excalidrawEditOverlay, type: "button", onClick: handleOpenEditor, children: /* @__PURE__ */ jsxs("span", { className: excalidrawEditLabel, children: [
532
+ /* @__PURE__ */ jsx(Pencil, { size: 16 }),
533
+ "Edit Whiteboard"
534
+ ] }) })
580
535
  ] });
581
536
  };
582
537
  const ExcalidrawEditRenderer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
package/dist/static.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $, a, E, b, c, b as b2, d, b as b3, u } from "./ExcalidrawNode-BnvRq6SZ.js";
1
+ import { $, a, E, b, c, b as b2, d, b as b3, u } from "./ExcalidrawNode-DEcONli3.js";
2
2
  import { EXCALIDRAW_BLOCK_TRANSFORMER } from "@haklex/rich-headless/transformers";
3
3
  export {
4
4
  $ as $createExcalidrawNode,
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAgCpE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAStE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CA+BpE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAYtE"}
@@ -1,12 +1,12 @@
1
1
  import { ExcalidrawSnapshot } from './types';
2
2
  export interface ExcalidrawDataState {
3
- snapshot: Record<string, any> | undefined;
4
- loading: boolean;
5
- error: string;
6
- /** The base reference line (URL or ref:file/xxx) when snapshot is remote or incremental */
7
- baseRef?: string;
8
3
  /** The raw base data before delta patch (for computing new diffs in edit mode) */
9
4
  baseData?: Record<string, any>;
5
+ /** The base reference line (URL or ref:file/xxx) when snapshot is remote or incremental */
6
+ baseRef?: string;
7
+ error: string;
8
+ loading: boolean;
9
+ snapshot: Record<string, any> | undefined;
10
10
  }
11
11
  export declare function useExcalidrawData(data: string | ExcalidrawSnapshot | null): ExcalidrawDataState;
12
12
  //# sourceMappingURL=useExcalidrawData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useExcalidrawData.d.ts","sourceRoot":"","sources":["../src/useExcalidrawData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAGjD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC/B;AA8DD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,GACvC,mBAAmB,CAiFrB"}
1
+ {"version":3,"file":"useExcalidrawData.d.ts","sourceRoot":"","sources":["../src/useExcalidrawData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;CAC3C;AA4DD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,GAAG,mBAAmB,CA2E/F"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haklex/rich-ext-excalidraw",
3
3
  "type": "module",
4
- "version": "0.0.65",
4
+ "version": "0.0.66",
5
5
  "description": "Excalidraw whiteboard extension",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -29,10 +29,10 @@
29
29
  "dependencies": {
30
30
  "@excalidraw/excalidraw": "0.17.0",
31
31
  "jsondiffpatch": "^0.7.3",
32
- "@haklex/rich-editor": "0.0.65",
33
- "@haklex/rich-editor-ui": "0.0.65",
34
- "@haklex/rich-headless": "0.0.65",
35
- "@haklex/rich-style-token": "0.0.65"
32
+ "@haklex/rich-editor": "0.0.66",
33
+ "@haklex/rich-editor-ui": "0.0.66",
34
+ "@haklex/rich-style-token": "0.0.66",
35
+ "@haklex/rich-headless": "0.0.66"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@lexical/react": "^0.41.0",
@@ -51,6 +51,11 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/Innei/haklex.git",
57
+ "directory": "packages/rich-ext-excalidraw"
58
+ },
54
59
  "scripts": {
55
60
  "build": "vite build",
56
61
  "dev:build": "vite build --watch"