@fileverse-dev/ddoc 4.0.3 → 4.0.5-ens-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.
Files changed (24) hide show
  1. package/dist/{index-DmFqb-mP.mjs → index-BaUcfd1H.mjs} +22321 -22290
  2. package/dist/{index-7Up0fuRf.mjs → index-C2SwsBqH.mjs} +1 -1
  3. package/dist/index.es.js +1 -1
  4. package/dist/{markdown-source-pane-BetUwmxR.mjs → markdown-source-pane-DTB7T16w.mjs} +2 -2
  5. package/dist/package/components/editor-toolbar/alignment.d.ts +7 -0
  6. package/dist/package/components/editor-toolbar/font-family.d.ts +7 -0
  7. package/dist/package/components/editor-toolbar/font-size.d.ts +7 -0
  8. package/dist/package/components/editor-toolbar/heading.d.ts +5 -0
  9. package/dist/package/components/editor-toolbar/highlight.d.ts +7 -0
  10. package/dist/package/components/editor-toolbar/line-height.d.ts +7 -0
  11. package/dist/package/components/editor-toolbar/link.d.ts +8 -0
  12. package/dist/package/components/editor-toolbar/text-color.d.ts +7 -0
  13. package/dist/package/components/editor-toolbar/zoom-level.d.ts +6 -0
  14. package/dist/package/components/editor-toolbar.d.ts +1 -1
  15. package/dist/package/components/editor-utils.d.ts +1 -3
  16. package/dist/package/components/import-export-button.d.ts +1 -2
  17. package/dist/package/components/split-view/split-view-markdown-pane.d.ts +1 -3
  18. package/dist/package/components/split-view/split-view-right-header.d.ts +3 -1
  19. package/dist/package/components/split-view/split-view-toolbar.d.ts +1 -3
  20. package/dist/split-view-toolbar-DrprtqFo.mjs +289 -0
  21. package/dist/style.css +1 -1
  22. package/package.json +5 -5
  23. package/dist/package/components/editor-toolbar-dropdown.d.ts +0 -12
  24. package/dist/split-view-toolbar-DviBCc0N.mjs +0 -305
@@ -1,4 +1,4 @@
1
- import { k as Ql, b as Zl, s as eh } from "./index-DmFqb-mP.mjs";
1
+ import { k as Ql, b as Zl, s as eh } from "./index-BaUcfd1H.mjs";
2
2
  let An = [], Xr = [];
3
3
  (() => {
4
4
  let s = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e) => e ? parseInt(e, 36) : 1);
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as e, a as o, E as d, P as t, d as r, h as i, m as n, c as E, u as l } from "./index-DmFqb-mP.mjs";
1
+ import { D as e, a as o, E as d, P as t, d as r, h as i, m as n, c as E, u as l } from "./index-BaUcfd1H.mjs";
2
2
  export {
3
3
  e as DdocEditor,
4
4
  o as DdocExportModal,
@@ -1,9 +1,9 @@
1
1
  var Vr = Object.defineProperty;
2
2
  var Wr = (t, e, O) => e in t ? Vr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: O }) : t[e] = O;
3
3
  var gt = (t, e, O) => Wr(t, typeof e != "symbol" ? e + "" : e, O);
4
- import { j as Cr } from "./index-DmFqb-mP.mjs";
4
+ import { j as Cr } from "./index-BaUcfd1H.mjs";
5
5
  import { useRef as pe, useEffect as St } from "react";
6
- import { s as y, A as pO, T as dO, a as Gr, S as et, b as Lr, P as fO, E as j, i as QO, c as _, D as le, k as tt, F as Ar, M as Pt, W as Er, R as Ur, d as mO, N as oe, e as V, f as Mr, g as Ot, h as ce, p as $O, j as Y, t as h, l as Ir, I as rt, L as at, m as ye, n as ue, o as Qe, q as gO, r as te, u as SO, v as Br, w as Nr, x as PO, y as kO, z as Dr, B as Fr, C as Kr, G as Oe, H as ZO, J as Jr, K as kt, O as Hr, Q as ea, U as ta, V as Oa, X as ra, Y as aa, Z as ia, _ as sa, $ as na, a0 as la, a1 as oa, a2 as ca } from "./index-7Up0fuRf.mjs";
6
+ import { s as y, A as pO, T as dO, a as Gr, S as et, b as Lr, P as fO, E as j, i as QO, c as _, D as le, k as tt, F as Ar, M as Pt, W as Er, R as Ur, d as mO, N as oe, e as V, f as Mr, g as Ot, h as ce, p as $O, j as Y, t as h, l as Ir, I as rt, L as at, m as ye, n as ue, o as Qe, q as gO, r as te, u as SO, v as Br, w as Nr, x as PO, y as kO, z as Dr, B as Fr, C as Kr, G as Oe, H as ZO, J as Jr, K as kt, O as Hr, Q as ea, U as ta, V as Oa, X as ra, Y as aa, Z as ia, _ as sa, $ as na, a0 as la, a1 as oa, a2 as ca } from "./index-C2SwsBqH.mjs";
7
7
  class ua {
8
8
  /**
9
9
  Create a new completion context. (Mostly useful for testing
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { IEditorToolElement } from '../editor-utils';
3
+
4
+ export declare const AlignmentDropdown: ({ tool, editor, }: {
5
+ tool: IEditorToolElement;
6
+ editor: Editor;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { FontDescriptor } from '../../types';
3
+
4
+ export declare const FontFamilyDropdown: ({ consumerFonts, editor, }: {
5
+ consumerFonts?: FontDescriptor[];
6
+ editor: Editor;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+
3
+ export declare const FontSizeDropdown: ({ editor, currentSize, onSetFontSize, }: {
4
+ editor: Editor;
5
+ currentSize?: string;
6
+ onSetFontSize: (fontSize: string) => void;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { Editor } from '@tiptap/core';
2
+
3
+ export declare const HeadingDropdown: ({ editor }: {
4
+ editor: Editor;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { IEditorToolElement } from '../editor-utils';
3
+
4
+ export declare const HighlightDropdown: ({ tool, editor, }: {
5
+ tool: IEditorToolElement;
6
+ editor: Editor;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { IEditorToolElement } from '../editor-utils';
2
+
3
+ export declare const LineHeightDropdown: ({ tool, currentLineHeight, onSetLineHeight, }: {
4
+ tool: IEditorToolElement;
5
+ currentLineHeight?: string;
6
+ onSetLineHeight: (lineHeight: string) => void;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { IEditorToolElement } from '../editor-utils';
3
+
4
+ export declare const LinkPopover: ({ tool, editor, onError, }: {
5
+ tool: IEditorToolElement;
6
+ editor: Editor;
7
+ onError?: (errorString: string) => void;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { IEditorToolElement } from '../editor-utils';
3
+
4
+ export declare const TextColorDropdown: ({ tool, editor, }: {
5
+ tool: IEditorToolElement;
6
+ editor: Editor;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ interface ZoomLevelDropdownProps {
2
+ zoomLevel: string;
3
+ setZoomLevel: (zoom: string) => void;
4
+ }
5
+ export declare const ZoomLevelDropdown: ({ zoomLevel, setZoomLevel, }: ZoomLevelDropdownProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -36,5 +36,5 @@ declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onErro
36
36
  onToggleSplitView?: () => void;
37
37
  onRegisterExportTrigger?: ((trigger: ((format?: string, name?: string) => void) | null) => void) | undefined;
38
38
  fonts?: FontDescriptor[];
39
- }) => import("react/jsx-runtime").JSX.Element>;
39
+ }) => import("react/jsx-runtime").JSX.Element | null>;
40
40
  export default MemoizedTiptapToolBar;
@@ -149,10 +149,8 @@ export declare const TextColor: ({ editor, setVisibility, elementRef, }: {
149
149
  elementRef: React.RefObject<HTMLDivElement>;
150
150
  setVisibility: Dispatch<SetStateAction<IEditorTool>>;
151
151
  }) => import("react/jsx-runtime").JSX.Element;
152
- export declare const TextHeading: ({ editor, setVisibility, elementRef, }: {
152
+ export declare const TextHeading: ({ editor }: {
153
153
  editor: Editor;
154
- elementRef: React.RefObject<HTMLDivElement>;
155
- setVisibility: Dispatch<SetStateAction<IEditorTool>>;
156
154
  }) => import("react/jsx-runtime").JSX.Element;
157
155
  export declare const FontSizePicker: ({ editor, setVisibility, elementRef, currentSize, onSetFontSize, }: {
158
156
  editor: Editor;
@@ -3,12 +3,11 @@ import { Editor } from '@tiptap/react';
3
3
  import { Tab } from './tabs/utils/tab-utils';
4
4
 
5
5
  import * as Y from 'yjs';
6
- declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, exportOptions, importOptions, setDropdownOpen, editor, tabs, ydoc, onRegisterExportTrigger, }: {
6
+ declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, exportOptions, importOptions, editor, tabs, ydoc, onRegisterExportTrigger, }: {
7
7
  fileExportsOpen: boolean;
8
8
  setFileExportsOpen: React.Dispatch<React.SetStateAction<boolean>>;
9
9
  exportOptions: (IEditorToolElement | null)[];
10
10
  importOptions: (IEditorToolElement | null)[];
11
- setDropdownOpen: React.Dispatch<React.SetStateAction<boolean>>;
12
11
  editor: Editor | null;
13
12
  tabs: Tab[];
14
13
  ydoc: Y.Doc;
@@ -3,8 +3,6 @@ import { IpfsImageUploadResponse } from '../../types';
3
3
  interface SplitViewMarkdownPaneProps {
4
4
  markdown: string;
5
5
  onMarkdownChange: (value: string) => void;
6
- /** Exit Split View (back to the normal editor). */
7
- onExitSplitView?: () => void;
8
6
  /** Same uploader the editor uses — for the markdown toolbar's Image button. */
9
7
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
10
8
  onError?: (error: string) => void;
@@ -17,5 +15,5 @@ interface SplitViewMarkdownPaneProps {
17
15
  * real ddoc editor itself — see ddoc-editor.tsx, which keeps that editor mounted
18
16
  * in place (never a second <EditorContent>) so its React node views survive.
19
17
  */
20
- export declare const SplitViewMarkdownPane: ({ markdown, onMarkdownChange, onExitSplitView, ipfsImageUploadFn, onError, style, }: SplitViewMarkdownPaneProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const SplitViewMarkdownPane: ({ markdown, onMarkdownChange, ipfsImageUploadFn, onError, style, }: SplitViewMarkdownPaneProps) => import("react/jsx-runtime").JSX.Element;
21
19
  export {};
@@ -6,10 +6,12 @@ interface SplitViewRightHeaderProps {
6
6
  showTabsPanel: boolean;
7
7
  /** Toggle the Document-tabs overlay panel (the List button). */
8
8
  onToggleTabsPanel: () => void;
9
+ /** Exit Split View (back to the normal editor). */
10
+ onExitSplitView?: () => void;
9
11
  }
10
12
  /**
11
13
  * Split View RIGHT-pane header bar: the Document-tabs toggle (left) and the
12
14
  * download actions (right). Sits above the real ddoc editor in the right pane.
13
15
  */
14
- export declare const SplitViewRightHeader: ({ editor, showTabsPanel, onToggleTabsPanel, }: SplitViewRightHeaderProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const SplitViewRightHeader: ({ editor, onExitSplitView, showTabsPanel, onToggleTabsPanel, }: SplitViewRightHeaderProps) => import("react/jsx-runtime").JSX.Element;
15
17
  export {};
@@ -4,11 +4,9 @@ import { IpfsImageUploadResponse } from '../../types';
4
4
  interface SplitViewToolbarProps {
5
5
  /** The CodeMirror view of the markdown pane (null until it mounts). */
6
6
  view: EditorView | null;
7
- /** Exit Split View (back to the normal editor). */
8
- onExit?: () => void;
9
7
  /** Same uploader the editor uses — for the Image button. */
10
8
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
11
9
  onError?: (error: string) => void;
12
10
  }
13
- export default function SplitViewToolbar({ view, onExit, ipfsImageUploadFn, onError, }: SplitViewToolbarProps): import("react/jsx-runtime").JSX.Element;
11
+ export default function SplitViewToolbar({ view, ipfsImageUploadFn, onError, }: SplitViewToolbarProps): import("react/jsx-runtime").JSX.Element;
14
12
  export {};
@@ -0,0 +1,289 @@
1
+ import { j as d } from "./index-BaUcfd1H.mjs";
2
+ import { useRef as I, useState as N, useEffect as D } from "react";
3
+ import { DynamicDropdown as E, Tooltip as R, IconButton as O } from "@fileverse/ui";
4
+ import { a3 as A, a4 as P, c as y } from "./index-C2SwsBqH.mjs";
5
+ const p = (e, t, o = t) => {
6
+ const { state: s } = e, l = s.changeByRange((n) => {
7
+ const u = s.sliceDoc(n.from, n.to), r = s.sliceDoc(
8
+ Math.max(0, n.from - t.length),
9
+ n.from
10
+ ), m = s.sliceDoc(
11
+ n.to,
12
+ Math.min(s.doc.length, n.to + o.length)
13
+ );
14
+ if (r === t && m === o)
15
+ return {
16
+ changes: [
17
+ { from: n.from - t.length, to: n.from, insert: "" },
18
+ { from: n.to, to: n.to + o.length, insert: "" }
19
+ ],
20
+ range: y.range(
21
+ n.from - t.length,
22
+ n.to - t.length
23
+ )
24
+ };
25
+ const b = t + u + o;
26
+ return {
27
+ changes: { from: n.from, to: n.to, insert: b },
28
+ range: y.range(
29
+ n.from + t.length,
30
+ n.from + t.length + u.length
31
+ )
32
+ };
33
+ });
34
+ e.dispatch(s.update(l, { scrollIntoView: !0 })), e.focus();
35
+ }, S = (e, t) => {
36
+ const { state: o } = e, s = [], l = /* @__PURE__ */ new Set();
37
+ for (const n of o.selection.ranges) {
38
+ let u = n.from;
39
+ for (; ; ) {
40
+ const r = o.doc.lineAt(u);
41
+ if (!l.has(r.number)) {
42
+ l.add(r.number);
43
+ const m = t(r.text, r.from);
44
+ m && s.push(m);
45
+ }
46
+ if (r.to >= n.to) break;
47
+ u = r.to + 1;
48
+ }
49
+ }
50
+ s.length && e.dispatch(o.update({ changes: s, scrollIntoView: !0 })), e.focus();
51
+ }, k = (e, t) => S(
52
+ e,
53
+ (o, s) => o.startsWith(t) ? { from: s, to: s + t.length, insert: "" } : { from: s, insert: t }
54
+ ), _ = (e, t) => {
55
+ const o = "#".repeat(t) + " ";
56
+ return S(e, (s, l) => {
57
+ const n = s.match(/^(#{1,6})\s/);
58
+ return n && n[1].length === t ? { from: l, to: l + n[0].length, insert: "" } : n ? { from: l, to: l + n[0].length, insert: o } : { from: l, insert: o };
59
+ });
60
+ }, f = (e, t) => {
61
+ const { state: o } = e, s = o.selection.main, r = `${o.doc.lineAt(s.from).text.trim() === "" ? "" : `
62
+
63
+ `}${t}
64
+ `;
65
+ e.dispatch(
66
+ o.update({
67
+ changes: { from: s.from, insert: r },
68
+ selection: { anchor: s.from + r.length },
69
+ scrollIntoView: !0
70
+ })
71
+ ), e.focus();
72
+ }, w = (e, t) => {
73
+ const { state: o } = e, s = o.changeByRange((l) => {
74
+ const n = o.sliceDoc(l.from, l.to) || "text", u = t ?? "url", r = `[${n}](${u})`, m = l.from + 1 + n.length + 2;
75
+ return {
76
+ changes: { from: l.from, to: l.to, insert: r },
77
+ range: y.range(m, m + u.length)
78
+ };
79
+ });
80
+ e.dispatch(o.update(s, { scrollIntoView: !0 })), e.focus();
81
+ }, z = (e, t) => {
82
+ const o = `<img src="${t.src}" media-type="secure-img" encryptionKey="${t.encryptionKey}" nonce="${t.nonce}" ipfsUrl="${t.ipfsUrl}" ipfsHash="${t.ipfsHash}" version="2" authTag="${t.authTag}" mimeType="${t.mimeType}" />`;
83
+ f(e, o);
84
+ }, G = (e, t) => f(e, `<img src="${t}" media-type="img" />`), K = `| Column 1 | Column 2 |
85
+ | -------- | -------- |
86
+ | | |`, c = {
87
+ bold: (e) => p(e, "**"),
88
+ italic: (e) => p(e, "*"),
89
+ strike: (e) => p(e, "~~"),
90
+ inlineCode: (e) => p(e, "`"),
91
+ underline: (e) => p(e, "<u>", "</u>"),
92
+ heading: (e, t) => _(e, t),
93
+ bulletList: (e) => k(e, "- "),
94
+ orderedList: (e) => k(e, "1. "),
95
+ taskList: (e) => k(e, "- [ ] "),
96
+ blockquote: (e) => k(e, "> "),
97
+ codeBlock: (e) => f(e, "```\n\n```"),
98
+ horizontalRule: (e) => f(e, "---"),
99
+ table: (e) => f(e, K),
100
+ link: (e, t) => w(e, t),
101
+ undo: (e) => {
102
+ P(e), e.focus();
103
+ },
104
+ redo: (e) => {
105
+ A(e), e.focus();
106
+ },
107
+ // Highlight → inline HTML (round-trips via our turndown/DOMPurify rules).
108
+ highlight: (e, t) => t ? p(e, `<mark style="background-color: ${t}">`, "</mark>") : p(e, "<mark>", "</mark>")
109
+ }, C = [
110
+ [
111
+ { icon: "Undo", label: "Undo", run: (e) => c.undo(e) },
112
+ { icon: "Redo", label: "Redo", run: (e) => c.redo(e) }
113
+ ],
114
+ [
115
+ {
116
+ icon: "Heading1",
117
+ label: "Heading 1",
118
+ run: (e) => c.heading(e, 1)
119
+ },
120
+ {
121
+ icon: "Heading2",
122
+ label: "Heading 2",
123
+ run: (e) => c.heading(e, 2)
124
+ },
125
+ {
126
+ icon: "Heading3",
127
+ label: "Heading 3",
128
+ run: (e) => c.heading(e, 3)
129
+ }
130
+ ],
131
+ [
132
+ { icon: "Bold", label: "Bold", run: (e) => c.bold(e) },
133
+ { icon: "Italic", label: "Italic", run: (e) => c.italic(e) },
134
+ {
135
+ icon: "Underline",
136
+ label: "Underline",
137
+ run: (e) => c.underline(e)
138
+ },
139
+ {
140
+ icon: "Strikethrough",
141
+ label: "Strikethrough",
142
+ run: (e) => c.strike(e)
143
+ },
144
+ {
145
+ icon: "Code",
146
+ label: "Inline code",
147
+ run: (e) => c.inlineCode(e)
148
+ },
149
+ {
150
+ icon: "Highlighter",
151
+ label: "Highlight",
152
+ run: (e) => c.highlight(e)
153
+ }
154
+ ],
155
+ [
156
+ {
157
+ icon: "List",
158
+ label: "Bullet list",
159
+ run: (e) => c.bulletList(e)
160
+ },
161
+ {
162
+ icon: "ListOrdered",
163
+ label: "Numbered list",
164
+ run: (e) => c.orderedList(e)
165
+ },
166
+ {
167
+ icon: "ListChecks",
168
+ label: "To-do list",
169
+ run: (e) => c.taskList(e)
170
+ },
171
+ { icon: "TextQuote", label: "Quote", run: (e) => c.blockquote(e) }
172
+ ],
173
+ [
174
+ // Inserts [text](url) inline and selects `url` to type over.
175
+ { icon: "Link", label: "Link", run: (e) => c.link(e) },
176
+ { icon: "Image", label: "Image", run: () => {
177
+ }, upload: !0 },
178
+ {
179
+ icon: "Braces",
180
+ label: "Code block",
181
+ run: (e) => c.codeBlock(e)
182
+ },
183
+ { icon: "Table", label: "Table", run: (e) => c.table(e) },
184
+ {
185
+ icon: "Minus",
186
+ label: "Divider",
187
+ run: (e) => c.horizontalRule(e)
188
+ }
189
+ ]
190
+ ], B = 3, M = C.slice(0, B), T = C.slice(B), U = "!h-6 !w-6 !min-w-0", W = 560, j = () => /* @__PURE__ */ d.jsx("div", { className: "w-[1px] h-4 vertical-divider mx-1" });
191
+ function Q({
192
+ view: e,
193
+ ipfsImageUploadFn: t,
194
+ onError: o
195
+ }) {
196
+ const s = (i) => {
197
+ const a = document.createElement("input");
198
+ a.type = "file", a.accept = "image/*", a.onchange = async () => {
199
+ var L;
200
+ const h = (L = a.files) == null ? void 0 : L[0];
201
+ if (!(!h || !h.type.includes("image/")))
202
+ try {
203
+ if (t) {
204
+ const g = await t(h);
205
+ z(i, {
206
+ src: URL.createObjectURL(h),
207
+ ipfsUrl: g.ipfsUrl,
208
+ encryptionKey: g.encryptionKey,
209
+ nonce: g.nonce,
210
+ ipfsHash: g.ipfsHash,
211
+ authTag: g.authTag,
212
+ mimeType: h.type
213
+ });
214
+ } else {
215
+ const g = await new Promise((H, $) => {
216
+ const x = new FileReader();
217
+ x.onload = () => H(x.result), x.onerror = $, x.readAsDataURL(h);
218
+ });
219
+ G(i, g);
220
+ }
221
+ } catch {
222
+ o == null || o("Failed to upload image");
223
+ }
224
+ }, a.click();
225
+ }, l = (i, a) => {
226
+ if (i.upload) {
227
+ s(a);
228
+ return;
229
+ }
230
+ i.run(a);
231
+ }, n = I(null), [u, r] = N(!1);
232
+ D(() => {
233
+ const i = n.current;
234
+ if (!i || typeof ResizeObserver > "u") return;
235
+ const a = () => r(i.clientWidth < W);
236
+ a();
237
+ const h = new ResizeObserver(a);
238
+ return h.observe(i), () => h.disconnect();
239
+ }, []);
240
+ const m = (i) => /* @__PURE__ */ d.jsx(R, { text: i.label, children: /* @__PURE__ */ d.jsx(
241
+ O,
242
+ {
243
+ variant: "ghost",
244
+ size: "sm",
245
+ className: U,
246
+ icon: i.icon,
247
+ disabled: !e,
248
+ onClick: () => e && l(i, e)
249
+ }
250
+ ) }, i.label), b = (i, a) => /* @__PURE__ */ d.jsxs("div", { className: "flex items-center gap-0.5", children: [
251
+ a && /* @__PURE__ */ d.jsx(j, {}),
252
+ i.map(m)
253
+ ] }, i[0].label);
254
+ return /* @__PURE__ */ d.jsx("div", { className: "flex items-center px-2 py-2 border-b color-border-default shrink-0", children: /* @__PURE__ */ d.jsxs(
255
+ "div",
256
+ {
257
+ ref: n,
258
+ className: "flex items-center gap-0.5 flex-1 min-w-0 overflow-hidden",
259
+ children: [
260
+ M.map((i, a) => b(i, a > 0)),
261
+ u ? /* @__PURE__ */ d.jsxs("div", { className: "flex items-center gap-0.5", children: [
262
+ /* @__PURE__ */ d.jsx(j, {}),
263
+ /* @__PURE__ */ d.jsx(
264
+ E,
265
+ {
266
+ align: "start",
267
+ sideOffset: 8,
268
+ anchorTrigger: /* @__PURE__ */ d.jsx(R, { text: "More", children: /* @__PURE__ */ d.jsx(
269
+ O,
270
+ {
271
+ variant: "ghost",
272
+ size: "sm",
273
+ className: U,
274
+ icon: "Ellipsis",
275
+ disabled: !e
276
+ }
277
+ ) }),
278
+ content: /* @__PURE__ */ d.jsx("div", { className: "flex items-center gap-0.5 p-1", children: T.flat().map(m) })
279
+ },
280
+ "md-more-dropdown"
281
+ )
282
+ ] }) : T.map((i) => b(i, !0))
283
+ ]
284
+ }
285
+ ) });
286
+ }
287
+ export {
288
+ Q as default
289
+ };