eddyter 1.3.76 → 1.3.78

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.
@@ -1,31 +1,31 @@
1
1
  import { jsx as i, jsxs as p } from "react/jsx-runtime";
2
2
  import { useLexicalComposerContext as U } from "@lexical/react/LexicalComposerContext";
3
3
  import { $getNodeByKey as v } from "lexical";
4
- import { useState as N, useEffect as k } from "react";
5
- import { q as w, r as L, s as E, F as g, v as j, w as B } from "./index-DjD3NbU0.js";
4
+ import { useState as N, useEffect as y } from "react";
5
+ import { v as w, w as L, x as E, F as g, y as j, z as B } from "./index-BDzAe_Dw.js";
6
6
  function W(t, e) {
7
7
  const l = t.split(".").pop()?.toLowerCase();
8
8
  return l === "pdf" || e.startsWith("data:application/pdf") ? "pdf" : l === "docx" || e.startsWith("data:application/vnd.openxmlformats") && t.toLowerCase().endsWith(".docx") ? "docx" : l === "xlsx" || l === "xls" || e.startsWith("data:application/vnd.openxmlformats-officedocument.spreadsheetml") || e.startsWith("data:application/vnd.ms-excel") ? "xlsx" : null;
9
9
  }
10
10
  function $(t, e) {
11
11
  const [l, d] = N(null);
12
- return k(() => {
12
+ return y(() => {
13
13
  const s = t && e ? W(e, t) : null;
14
14
  if (!t || !e || !s) {
15
15
  d(null);
16
16
  return;
17
17
  }
18
18
  let c = !1;
19
- return s === "pdf" ? import("./generatePdfThumbnail-U8R2yu3J.js").then(({ generatePdfThumbnail: r }) => r(t)).then((r) => {
20
- c || d(r);
19
+ return s === "pdf" ? import("./generatePdfThumbnail-B7hHlIu1.js").then(({ generatePdfThumbnail: o }) => o(t)).then((o) => {
20
+ c || d(o);
21
21
  }).catch(() => {
22
22
  c || d(null);
23
- }) : s === "docx" ? import("./generateDocxThumbnail-BbSs-3CJ.js").then(({ generateDocxThumbnail: r }) => r(t)).then((r) => {
24
- c || d(r);
23
+ }) : s === "docx" ? import("./generateDocxThumbnail-DI95OEXG.js").then(({ generateDocxThumbnail: o }) => o(t)).then((o) => {
24
+ c || d(o);
25
25
  }).catch(() => {
26
26
  c || d(null);
27
- }) : s === "xlsx" && import("./generateXlsxThumbnail-BUwuqsXR.js").then(({ generateXlsxThumbnail: r }) => r(t)).then((r) => {
28
- c || d(r);
27
+ }) : s === "xlsx" && import("./generateXlsxThumbnail-L2Rxm_uB.js").then(({ generateXlsxThumbnail: o }) => o(t)).then((o) => {
28
+ c || d(o);
29
29
  }).catch(() => {
30
30
  c || d(null);
31
31
  }), () => {
@@ -33,29 +33,29 @@ function $(t, e) {
33
33
  };
34
34
  }, [t, e]), l;
35
35
  }
36
- const R = (t) => t ? t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : t < 1024 * 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${(t / (1024 * 1024 * 1024)).toFixed(1)} GB` : "", y = (t) => {
36
+ const z = (t) => t ? t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : t < 1024 * 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${(t / (1024 * 1024 * 1024)).toFixed(1)} GB` : "", k = (t) => {
37
37
  const e = t.split(".");
38
38
  return e.length > 1 ? e[e.length - 1].toLowerCase() : "";
39
39
  }, b = (t) => {
40
- const e = y(t);
40
+ const e = k(t);
41
41
  return e === "pdf" || e === "docx" || e === "xlsx" || e === "xls";
42
- }, T = (t) => {
43
- const e = y(t);
42
+ }, R = (t) => {
43
+ const e = k(t);
44
44
  return ["pdf", "doc", "docx", "txt", "odt"].includes(e) ? /* @__PURE__ */ i(g, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-blue-500" }) : ["xls", "xlsx", "csv"].includes(e) ? /* @__PURE__ */ i(g, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-green-600" }) : ["zip", "rar", "7z", "tar", "gz"].includes(e) ? /* @__PURE__ */ i(j, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-orange-500" }) : /* @__PURE__ */ i(B, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-gray-500" });
45
- }, V = ({ src: t, fileName: e, fileSize: l, nodeKey: d }) => {
45
+ }, _ = ({ src: t, fileName: e, fileSize: l, nodeKey: d }) => {
46
46
  const [s] = U(), c = $(b(e) ? t : void 0, e);
47
- if (k(() => {
47
+ if (y(() => {
48
48
  c && s.update(() => {
49
49
  const n = v(d);
50
50
  w(n) && n.setPreviewDataUrl(c);
51
51
  });
52
52
  }, [s, d, c]), !t || !e)
53
53
  return console.error("FileView: Missing required props", { src: t, fileName: e, fileSize: l, nodeKey: d }), /* @__PURE__ */ i("div", { className: "cteditor-inline-flex cteditor-items-center cteditor-gap-3 cteditor-px-4 cteditor-py-3 cteditor-my-2 cteditor-border cteditor-border-destructive cteditor-rounded-lg cteditor-bg-destructive/10", children: /* @__PURE__ */ i("div", { className: "cteditor-text-sm cteditor-text-destructive", children: "Error loading file" }) });
54
- const r = (n) => {
54
+ const o = (n) => {
55
55
  n.preventDefault(), n.stopPropagation();
56
56
  try {
57
57
  if (t.startsWith("data:")) {
58
- const o = t.split(","), f = o[0].match(/:(.*?);/), D = f ? f[1] : "application/octet-stream", m = atob(o[1]);
58
+ const r = t.split(","), f = r[0].match(/:(.*?);/), D = f ? f[1] : "application/octet-stream", m = atob(r[1]);
59
59
  let u = m.length;
60
60
  const x = new Uint8Array(u);
61
61
  for (; u--; )
@@ -63,27 +63,27 @@ const R = (t) => t ? t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFix
63
63
  const P = new Blob([x], { type: D }), h = URL.createObjectURL(P), a = document.createElement("a");
64
64
  a.href = h, a.download = e, a.style.display = "none", document.body.appendChild(a), a.click(), document.body.removeChild(a), setTimeout(() => URL.revokeObjectURL(h), 100);
65
65
  } else {
66
- const o = document.createElement("a");
67
- o.href = t, o.download = e, o.style.display = "none", o.target = "_blank", document.body.appendChild(o), o.click(), document.body.removeChild(o);
66
+ const r = document.createElement("a");
67
+ r.href = t, r.download = e, r.style.display = "none", r.target = "_blank", document.body.appendChild(r), r.click(), document.body.removeChild(r);
68
68
  }
69
- } catch (o) {
70
- console.error("Error downloading file:", o), window.open(t, "_blank");
69
+ } catch (r) {
70
+ console.error("Error downloading file:", r), window.open(t, "_blank");
71
71
  }
72
72
  }, F = (n) => {
73
73
  n.preventDefault(), n.stopPropagation(), s.update(() => {
74
- const o = v(d);
75
- w(o) && o.remove();
74
+ const r = v(d);
75
+ w(r) && r.remove();
76
76
  });
77
77
  }, C = b(e) && c;
78
78
  return /* @__PURE__ */ p(
79
79
  "div",
80
80
  {
81
81
  className: "cteditor-inline-flex cteditor-flex-col cteditor-gap-2 cteditor-py-2 cteditor-px-2 cteditor-my-2 cteditor-border cteditor-border-border cteditor-rounded-lg cteditor-bg-background hover:cteditor-bg-accent/50 cteditor-transition-colors cteditor-cursor-pointer cteditor-max-w-[240px]",
82
- onClick: r,
82
+ onClick: o,
83
83
  role: "button",
84
84
  tabIndex: 0,
85
85
  onKeyDown: (n) => {
86
- (n.key === "Enter" || n.key === " ") && (n.preventDefault(), r(n));
86
+ (n.key === "Enter" || n.key === " ") && (n.preventDefault(), o(n));
87
87
  },
88
88
  children: [
89
89
  /* @__PURE__ */ i("div", { className: "cteditor-w-full cteditor-aspect-[120/88] cteditor-rounded cteditor-overflow-hidden cteditor-bg-muted cteditor-flex cteditor-items-center cteditor-justify-center", children: C ? /* @__PURE__ */ i(
@@ -93,17 +93,17 @@ const R = (t) => t ? t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFix
93
93
  alt: "",
94
94
  className: "cteditor-w-full cteditor-h-full cteditor-object-cover"
95
95
  }
96
- ) : /* @__PURE__ */ i("div", { className: "*:cteditor-size-8", children: T(e) }) }),
96
+ ) : /* @__PURE__ */ i("div", { className: "*:cteditor-size-8", children: R(e) }) }),
97
97
  /* @__PURE__ */ p("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-2 cteditor-w-full", children: [
98
98
  /* @__PURE__ */ p("div", { className: "cteditor-flex-1 cteditor-min-w-0", children: [
99
99
  /* @__PURE__ */ i("div", { className: "cteditor-font-medium cteditor-text-xs cteditor-text-foreground cteditor-truncate", children: e }),
100
- l && /* @__PURE__ */ i("div", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: R(l) })
100
+ l && /* @__PURE__ */ i("div", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: z(l) })
101
101
  ] }),
102
102
  /* @__PURE__ */ p("div", { className: "cteditor-flex cteditor-gap-1 cteditor-flex-shrink-0", children: [
103
103
  /* @__PURE__ */ i(
104
104
  "button",
105
105
  {
106
- onClick: r,
106
+ onClick: o,
107
107
  className: "cteditor-p-1 cteditor-rounded-md hover:cteditor-bg-accent cteditor-transition-colors",
108
108
  "aria-label": "Download file",
109
109
  title: "Download file",
@@ -127,5 +127,5 @@ const R = (t) => t ? t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFix
127
127
  );
128
128
  };
129
129
  export {
130
- V as default
130
+ _ as default
131
131
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G as a, H as r, I as t, J as s, K as o, M as d, N as v, O as u, P as f, Q as n, R as l, U as w } from "./index-DjD3NbU0.js";
1
+ import { J as a, K as r, M as t, N as s, O as o, P as d, Q as v, R as u, U as f, V as n, X as l, Y as w } from "./index-BDzAe_Dw.js";
2
2
  export {
3
3
  a as ConfigurableEditor,
4
4
  r as ConfigurableEditorWithAuth,
@@ -1,4 +1,4 @@
1
- import { DecoratorNode, DOMExportOutput, NodeKey } from '../../node_modules/lexical';
1
+ import { DecoratorNode, DOMConversionMap, DOMExportOutput, NodeKey } from '../../node_modules/lexical';
2
2
  /**
3
3
  * A custom Lexical node that embeds and renders various types of content
4
4
  * such as videos, PDFs, documents, and other media files.
@@ -21,6 +21,7 @@ export declare class EmbedNode extends DecoratorNode<JSX.Element> {
21
21
  updateDOM(): boolean;
22
22
  static importJSON(serializedNode: any): EmbedNode;
23
23
  exportJSON(): any;
24
+ static importDOM(): DOMConversionMap | null;
24
25
  exportDOM(): DOMExportOutput;
25
26
  getURL(): string;
26
27
  getDisplayType(): DisplayType;
package/dist/types.d.ts CHANGED
@@ -45,6 +45,7 @@ export interface ToolbarProps {
45
45
  enableCharts?: boolean;
46
46
  enableAutoCorrection?: boolean;
47
47
  enablePdfExport?: boolean;
48
+ enableDocExport?: boolean;
48
49
  enableSpeechToText?: boolean;
49
50
  enableComments?: boolean;
50
51
  enableMentions?: boolean;
@@ -147,6 +148,7 @@ export interface EditorConfigTypes {
147
148
  enableCharts: boolean;
148
149
  enableAutoCorrection: boolean;
149
150
  enablePdfExport: boolean;
151
+ enableDocExport: boolean;
150
152
  enableSpeechToText: boolean;
151
153
  enableComments: boolean;
152
154
  enableMentions: boolean;
@@ -0,0 +1,28 @@
1
+ export type CropData = {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ naturalWidth: number;
7
+ naturalHeight: number;
8
+ };
9
+ /**
10
+ * Returns true if the given src is served from our CloudFront CDN.
11
+ * Includes both direct CDN URLs and /transform-image/... crop URLs.
12
+ */
13
+ export declare function isCdnUrl(src: string): boolean;
14
+ /**
15
+ * Builds the crop URL using CDN: https://<cdn>/transform-image/<s3-key>?crop=x,y,w,h
16
+ */
17
+ export declare function buildCropUrl(src: string, crop: CropData): string;
18
+ /**
19
+ * Strips the `crop` query param. Used when re-opening the crop dialog (full image).
20
+ */
21
+ export declare function stripCropParams(src: string): string;
22
+ /**
23
+ * Returns the URL for the original (full, uncropped) image. Use this for the crop
24
+ * dialog preview so the user always sees the full image to draw a new crop.
25
+ * For CDN images this is the direct object URL (e.g. https://cdn.../key), not
26
+ * /transform-image/..., so the preview loads reliably.
27
+ */
28
+ export declare function getOriginalImageUrl(src: string): string;
@@ -1,2 +1,7 @@
1
1
  import { LexicalEditor } from '../../node_modules/lexical';
2
2
  export declare function exportEditorToPDF(editor: LexicalEditor, filename?: string, apiKey?: string): Promise<void>;
3
+ /**
4
+ * Export editor content as a Word document (.docx).
5
+ * Uses the same HTML as the editor (with inline styles). Requires complete HTML document for html-docx-js.
6
+ */
7
+ export declare function exportEditorToDoc(editor: LexicalEditor, filename?: string, _apiKey?: string): Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eddyter",
3
3
  "private": false,
4
- "version": "1.3.76",
4
+ "version": "1.3.78",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@9.0.0",
7
7
  "keywords": [
@@ -88,16 +88,16 @@
88
88
  "class-variance-authority": "^0.7.1",
89
89
  "clsx": "^2.1.1",
90
90
  "docx-preview": "^0.3.0",
91
- "html2canvas": "^1.4.1",
92
91
  "emoji-picker-react": "^4.12.0",
92
+ "html-docx-js": "^0.3.1",
93
+ "html2canvas": "^1.4.1",
93
94
  "html2pdf.js": "^0.14.0",
94
95
  "lexical": "^0.24.0",
95
96
  "lexical-ai-plugin": "0.0.2-alpha",
96
97
  "lodash-es": "^4.17.21",
97
- "pdfjs-dist": "^3.11.174",
98
- "xlsx": "^0.18.5",
99
98
  "lucide-react": "^0.344.0",
100
99
  "marked": "^17.0.1",
100
+ "pdfjs-dist": "^3.11.174",
101
101
  "prettier": "^3.5.1",
102
102
  "react-colorful": "^5.6.1",
103
103
  "react-router-dom": "^7.2.0",
@@ -105,7 +105,8 @@
105
105
  "sass": "^1.57.1",
106
106
  "tailwind-merge": "^3.0.2",
107
107
  "tailwindcss": "3",
108
- "tailwindcss-animate": "^1.0.7"
108
+ "tailwindcss-animate": "^1.0.7",
109
+ "xlsx": "^0.18.5"
109
110
  },
110
111
  "license": "SEE LICENSE IN LICENSE",
111
112
  "devDependencies": {