@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
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "4.0.3",
5
+ "version": "4.0.5-ens-1",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {
@@ -129,12 +129,12 @@
129
129
  "@dnd-kit/sortable": ">=10.0.0",
130
130
  "@dnd-kit/utilities": ">=3.2.2",
131
131
  "@fileverse/crypto": ">=0.0.21",
132
- "@fileverse/ens": "0.0.3",
133
- "@fileverse/ui": ">=5.1.8",
132
+ "@fileverse/ens": "0.0.4",
133
+ "@fileverse/ui": "5.1.9",
134
134
  "framer-motion": ">=11.2.10",
135
135
  "frimousse": ">=0.3.0",
136
136
  "mermaid": "11.14.0",
137
- "viem": ">=2.13.8"
137
+ "viem": ">=2.35.0"
138
138
  },
139
139
  "devDependencies": {
140
140
  "@types/dompurify": "^3.0.5",
@@ -162,4 +162,4 @@
162
162
  "typescript": "^5.2.2",
163
163
  "vite": "^5.0.0"
164
164
  }
165
- }
165
+ }
@@ -1,12 +0,0 @@
1
- import { LucideIconProps } from '@fileverse/ui';
2
- import { IEditorToolElement } from './editor-utils';
3
-
4
- declare const EditorToolbarDropdown: ({ tool, isLoading, renderContent, }: {
5
- tool: IEditorToolElement;
6
- isLoading: boolean;
7
- renderContent: (tool: {
8
- title: string;
9
- icon: LucideIconProps["name"];
10
- }) => JSX.Element | null;
11
- }) => import("react/jsx-runtime").JSX.Element;
12
- export default EditorToolbarDropdown;
@@ -1,305 +0,0 @@
1
- import { j as r } from "./index-DmFqb-mP.mjs";
2
- import { useRef as I, useState as D, useEffect as E } from "react";
3
- import { DynamicDropdown as P, Tooltip as y, IconButton as L } from "@fileverse/ui";
4
- import { a3 as A, a4 as _, c as O } from "./index-7Up0fuRf.mjs";
5
- const p = (e, n, s = n) => {
6
- const { state: o } = e, l = o.changeByRange((t) => {
7
- const u = o.sliceDoc(t.from, t.to), a = o.sliceDoc(
8
- Math.max(0, t.from - n.length),
9
- t.from
10
- ), m = o.sliceDoc(
11
- t.to,
12
- Math.min(o.doc.length, t.to + s.length)
13
- );
14
- if (a === n && m === s)
15
- return {
16
- changes: [
17
- { from: t.from - n.length, to: t.from, insert: "" },
18
- { from: t.to, to: t.to + s.length, insert: "" }
19
- ],
20
- range: O.range(
21
- t.from - n.length,
22
- t.to - n.length
23
- )
24
- };
25
- const b = n + u + s;
26
- return {
27
- changes: { from: t.from, to: t.to, insert: b },
28
- range: O.range(
29
- t.from + n.length,
30
- t.from + n.length + u.length
31
- )
32
- };
33
- });
34
- e.dispatch(o.update(l, { scrollIntoView: !0 })), e.focus();
35
- }, S = (e, n) => {
36
- const { state: s } = e, o = [], l = /* @__PURE__ */ new Set();
37
- for (const t of s.selection.ranges) {
38
- let u = t.from;
39
- for (; ; ) {
40
- const a = s.doc.lineAt(u);
41
- if (!l.has(a.number)) {
42
- l.add(a.number);
43
- const m = n(a.text, a.from);
44
- m && o.push(m);
45
- }
46
- if (a.to >= t.to) break;
47
- u = a.to + 1;
48
- }
49
- }
50
- o.length && e.dispatch(s.update({ changes: o, scrollIntoView: !0 })), e.focus();
51
- }, k = (e, n) => S(
52
- e,
53
- (s, o) => s.startsWith(n) ? { from: o, to: o + n.length, insert: "" } : { from: o, insert: n }
54
- ), w = (e, n) => {
55
- const s = "#".repeat(n) + " ";
56
- return S(e, (o, l) => {
57
- const t = o.match(/^(#{1,6})\s/);
58
- return t && t[1].length === n ? { from: l, to: l + t[0].length, insert: "" } : t ? { from: l, to: l + t[0].length, insert: s } : { from: l, insert: s };
59
- });
60
- }, f = (e, n) => {
61
- const { state: s } = e, o = s.selection.main, a = `${s.doc.lineAt(o.from).text.trim() === "" ? "" : `
62
-
63
- `}${n}
64
- `;
65
- e.dispatch(
66
- s.update({
67
- changes: { from: o.from, insert: a },
68
- selection: { anchor: o.from + a.length },
69
- scrollIntoView: !0
70
- })
71
- ), e.focus();
72
- }, z = (e, n) => {
73
- const { state: s } = e, o = s.changeByRange((l) => {
74
- const t = s.sliceDoc(l.from, l.to) || "text", u = n ?? "url", a = `[${t}](${u})`, m = l.from + 1 + t.length + 2;
75
- return {
76
- changes: { from: l.from, to: l.to, insert: a },
77
- range: O.range(m, m + u.length)
78
- };
79
- });
80
- e.dispatch(s.update(o, { scrollIntoView: !0 })), e.focus();
81
- }, G = (e, n) => {
82
- const s = `<img src="${n.src}" media-type="secure-img" encryptionKey="${n.encryptionKey}" nonce="${n.nonce}" ipfsUrl="${n.ipfsUrl}" ipfsHash="${n.ipfsHash}" version="2" authTag="${n.authTag}" mimeType="${n.mimeType}" />`;
83
- f(e, s);
84
- }, K = (e, n) => f(e, `<img src="${n}" media-type="img" />`), M = `| 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, n) => w(e, n),
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, M),
100
- link: (e, n) => z(e, n),
101
- undo: (e) => {
102
- _(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, n) => n ? p(e, `<mark style="background-color: ${n}">`, "</mark>") : p(e, "<mark>", "</mark>")
109
- }, B = [
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
- ], N = 3, W = B.slice(0, N), C = B.slice(N), R = "!h-6 !w-6 !min-w-0", v = 560, j = () => /* @__PURE__ */ r.jsx("div", { className: "w-[1px] h-4 vertical-divider mx-1" });
191
- function X({
192
- view: e,
193
- onExit: n,
194
- ipfsImageUploadFn: s,
195
- onError: o
196
- }) {
197
- const l = (i) => {
198
- const d = document.createElement("input");
199
- d.type = "file", d.accept = "image/*", d.onchange = async () => {
200
- var U;
201
- const h = (U = d.files) == null ? void 0 : U[0];
202
- if (!(!h || !h.type.includes("image/")))
203
- try {
204
- if (s) {
205
- const g = await s(h);
206
- G(i, {
207
- src: URL.createObjectURL(h),
208
- ipfsUrl: g.ipfsUrl,
209
- encryptionKey: g.encryptionKey,
210
- nonce: g.nonce,
211
- ipfsHash: g.ipfsHash,
212
- authTag: g.authTag,
213
- mimeType: h.type
214
- });
215
- } else {
216
- const g = await new Promise((H, $) => {
217
- const x = new FileReader();
218
- x.onload = () => H(x.result), x.onerror = $, x.readAsDataURL(h);
219
- });
220
- K(i, g);
221
- }
222
- } catch {
223
- o == null || o("Failed to upload image");
224
- }
225
- }, d.click();
226
- }, t = (i, d) => {
227
- if (i.upload) {
228
- l(d);
229
- return;
230
- }
231
- i.run(d);
232
- }, u = I(null), [a, m] = D(!1);
233
- E(() => {
234
- const i = u.current;
235
- if (!i || typeof ResizeObserver > "u") return;
236
- const d = () => m(i.clientWidth < v);
237
- d();
238
- const h = new ResizeObserver(d);
239
- return h.observe(i), () => h.disconnect();
240
- }, []);
241
- const b = (i) => /* @__PURE__ */ r.jsx(y, { text: i.label, children: /* @__PURE__ */ r.jsx(
242
- L,
243
- {
244
- variant: "ghost",
245
- size: "sm",
246
- className: R,
247
- icon: i.icon,
248
- disabled: !e,
249
- onClick: () => e && t(i, e)
250
- }
251
- ) }, i.label), T = (i, d) => /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-0.5", children: [
252
- d && /* @__PURE__ */ r.jsx(j, {}),
253
- i.map(b)
254
- ] }, i[0].label);
255
- return /* @__PURE__ */ r.jsxs("div", { className: "flex items-center px-2 py-2 border-b color-border-default shrink-0", children: [
256
- /* @__PURE__ */ r.jsxs(
257
- "div",
258
- {
259
- ref: u,
260
- className: "flex items-center gap-0.5 flex-1 min-w-0 overflow-hidden",
261
- children: [
262
- W.map((i, d) => T(i, d > 0)),
263
- a ? /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-0.5", children: [
264
- /* @__PURE__ */ r.jsx(j, {}),
265
- /* @__PURE__ */ r.jsx(
266
- P,
267
- {
268
- align: "start",
269
- sideOffset: 8,
270
- anchorTrigger: /* @__PURE__ */ r.jsx(y, { text: "More", children: /* @__PURE__ */ r.jsx(
271
- L,
272
- {
273
- variant: "ghost",
274
- size: "sm",
275
- className: R,
276
- icon: "Ellipsis",
277
- disabled: !e
278
- }
279
- ) }),
280
- content: /* @__PURE__ */ r.jsx("div", { className: "flex items-center gap-0.5 p-1", children: C.flat().map(b) })
281
- },
282
- "md-more-dropdown"
283
- )
284
- ] }) : C.map((i) => T(i, !0))
285
- ]
286
- }
287
- ),
288
- n && /* @__PURE__ */ r.jsxs("div", { className: "flex items-center pl-1 shrink-0", children: [
289
- /* @__PURE__ */ r.jsx(j, {}),
290
- /* @__PURE__ */ r.jsx(y, { text: "Back to editor", children: /* @__PURE__ */ r.jsx(
291
- L,
292
- {
293
- variant: "ghost",
294
- size: "sm",
295
- className: R,
296
- icon: "PenLine",
297
- onClick: n
298
- }
299
- ) })
300
- ] })
301
- ] });
302
- }
303
- export {
304
- X as default
305
- };