wendang-react 0.6.3 → 0.6.4
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/NOTICE.md +1 -1
- package/README.md +105 -0
- package/dist/bindings/yjs.js +1 -5
- package/dist/chunks/AnchoredPanel-C7jMoPze.js +1 -0
- package/dist/chunks/DocumentExportMenu-CUMsgq3w.js +2 -0
- package/dist/chunks/Dropdown-D98tXfe0.js +3 -0
- package/dist/chunks/MindMapCanvas-CVXQXNOg.js +163 -0
- package/dist/chunks/MindMapViewer-BI8zbQM1.js +13 -0
- package/dist/chunks/SpreadsheetViewer-CoQ4VIgj.js +23 -0
- package/dist/chunks/code-highlight-BmaqTe1m.js +1 -30
- package/dist/chunks/code-highlight-engine-BFDzDPzy.js +1 -40
- package/dist/chunks/comment-hint-BhUxKjKK.js +14 -0
- package/dist/chunks/composition-state-Bl-U1R_2.js +1 -40
- package/dist/chunks/extensions-C1fCBnEs.js +14 -0
- package/dist/chunks/fuzzy-match-DYQR-4w2.js +1 -89
- package/dist/chunks/hooks-C53Dp0pr.js +1 -35
- package/dist/chunks/i18n-B0kCsIjc.js +2 -0
- package/dist/chunks/index-COeA2QcQ.js +15 -0
- package/dist/chunks/katex-WjrodtTU.js +1 -71
- package/dist/chunks/locale-DWpIJ_9X.js +1 -0
- package/dist/chunks/mind-map-controller-Ce76mETT.js +1 -0
- package/dist/chunks/mind-map-delete-CVsxdXfs.js +1 -31
- package/dist/chunks/mind-map-input-CEWRz_t6.js +1 -43
- package/dist/chunks/mind-topic-text-Bn1waxff.js +31 -0
- package/dist/chunks/popover-placement-D3xVYdkt.js +1 -47
- package/dist/chunks/worksheet-engine-c84sdD4N.js +1 -0
- package/dist/chunks/worksheet-preview-DsDVWxIM.js +1 -129
- package/dist/document/viewer.js +30 -289
- package/dist/document.js +120 -3811
- package/dist/export/json.js +1 -5
- package/dist/export/markdown.js +1 -2
- package/dist/export/mindmap.js +1 -2
- package/dist/export/pdf.js +1 -6
- package/dist/export/word.js +1 -2
- package/dist/export.js +1 -2
- package/dist/i18n.js +1 -0
- package/dist/index.js +1 -8
- package/dist/locales/en-US.js +1 -0
- package/dist/locales/es-ES.js +1 -0
- package/dist/locales/ja-JP.js +1 -0
- package/dist/locales/ko-KR.js +1 -0
- package/dist/locales/zh-CN.js +1 -0
- package/dist/locales/zh-TW.js +1 -0
- package/dist/mindmap/viewer.js +1 -6
- package/dist/mindmap.js +3 -123
- package/dist/shared.js +1 -52
- package/dist/spreadsheet/viewer.js +1 -5
- package/dist/spreadsheet/xlsx.js +1 -299
- package/dist/spreadsheet.js +2 -120
- package/dist/styles/callout.css +1 -34
- package/dist/styles/code-block.css +1 -58
- package/dist/styles/content-style.css +1 -619
- package/dist/styles/content-tokens.css +1 -29
- package/dist/styles/editor-interaction.css +1 -621
- package/dist/styles/file-video.css +1 -12
- package/dist/styles/image-preview.css +1 -103
- package/dist/styles/mind-map-block.css +1 -14
- package/dist/styles/mind-map-canvas.css +1 -80
- package/dist/styles/mind-map-comments.css +1 -93
- package/dist/styles/mind-map-details.css +1 -7
- package/dist/styles/mind-map-preview.css +1 -7
- package/dist/styles/mind-map-topic.css +1 -112
- package/dist/styles/page-picker.css +1 -47
- package/dist/styles/renderer.css +1 -45
- package/dist/styles/spreadsheet-editor.css +1 -3
- package/dist/styles/tokens.css +1 -142
- package/dist/styles/video-dialog.css +1 -41
- package/dist/styles/video-embed.css +1 -35
- package/dist/styles.css +1 -2655
- package/dist/types/editor/BlockAffordance.d.ts +5 -2
- package/dist/types/editor/CalloutView.d.ts +2 -1
- package/dist/types/editor/ImagePreview.d.ts +1 -1
- package/dist/types/editor/PagePicker.d.ts +1 -1
- package/dist/types/editor/extensions.d.ts +4 -1
- package/dist/types/engine/editor/block-commands.d.ts +1 -1
- package/dist/types/engine/editor/block-menu-hover.d.ts +16 -0
- package/dist/types/engine/editor/extensions/locale.d.ts +3 -0
- package/dist/types/engine/editor/nodes/image-nodeview.d.ts +1 -1
- package/dist/types/engine/host.d.ts +60 -2
- package/dist/types/engine/renderer/attachments.d.ts +3 -3
- package/dist/types/engine/shared/video-feedback.d.ts +1 -1
- package/dist/types/engine/worksheets/worksheet-engine.d.ts +1 -0
- package/dist/types/engine/worksheets/worksheet-xlsx.d.ts +6 -1
- package/dist/types/host-types.d.ts +2 -60
- package/dist/types/host.d.ts +8 -1
- package/dist/types/i18n.d.ts +3 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/locales/en-US.d.ts +1 -0
- package/dist/types/locales/es-ES.d.ts +1 -0
- package/dist/types/locales/ja-JP.d.ts +1 -0
- package/dist/types/locales/ko-KR.d.ts +1 -0
- package/dist/types/locales/zh-CN.d.ts +1 -0
- package/dist/types/locales/zh-TW.d.ts +1 -0
- package/dist/types/spreadsheet/xlsx.d.ts +1 -1
- package/dist/types/wui/Dropdown.d.ts +2 -1
- package/dist/types/wui/index.d.ts +2 -1
- package/integrity.json +3135 -0
- package/package.json +15 -5
- package/verify-integrity.mjs +138 -0
- package/dist/chunks/AnchoredPanel-Cv4RURwF.js +0 -68
- package/dist/chunks/DocumentExportMenu-BrGipZ59.js +0 -75
- package/dist/chunks/MindMapCanvas-tkFBBs4g.js +0 -2090
- package/dist/chunks/MindMapViewer-DJrryb2Y.js +0 -180
- package/dist/chunks/SpreadsheetViewer-DxCxIUx_.js +0 -163
- package/dist/chunks/comment-hint-B9qcrqvn.js +0 -296
- package/dist/chunks/extensions-ByORRoRa.js +0 -4210
- package/dist/chunks/host-C-V688Rq.js +0 -197
- package/dist/chunks/index-DdfMnva8.js +0 -726
- package/dist/chunks/mind-map-controller-B6SxK3GZ.js +0 -479
- package/dist/chunks/mind-topic-text-DSyb95vL.js +0 -446
- package/dist/chunks/nodes-iKqTGr_N.js +0 -291
- package/dist/chunks/worksheet-engine-TJ54m0KC.js +0 -125
- package/third-party-notices/wendang-export@0.6.0-NOTICE.md.txt +0 -51
- package/third-party-notices/wendang-export@0.6.1-LICENSE.txt +0 -21
- package/third-party-notices/wendang-export@0.6.2-LICENSE.txt +0 -21
- package/third-party-notices/wendang-export@0.6.2-NOTICE.md.txt +0 -70
- /package/third-party-notices/{wendang-export@0.6.0-LICENSE.txt → wendang-export@0.6.3-LICENSE.txt} +0 -0
- /package/third-party-notices/{wendang-export@0.6.1-NOTICE.md.txt → wendang-export@0.6.3-NOTICE.md.txt} +0 -0
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useRef, useEffect, useContext, createContext } from "react";
|
|
4
|
-
const unavailableAttachment = async () => {
|
|
5
|
-
throw new Error("未配置附件读取服务");
|
|
6
|
-
};
|
|
7
|
-
const defaultAttachmentFetcher = unavailableAttachment;
|
|
8
|
-
const PRIMED_LIMIT = 16;
|
|
9
|
-
const primedAttachments = /* @__PURE__ */ new Map();
|
|
10
|
-
function primeAttachment(id, blob) {
|
|
11
|
-
if (!id || !blob) return;
|
|
12
|
-
primedAttachments.delete(id);
|
|
13
|
-
primedAttachments.set(id, blob);
|
|
14
|
-
while (primedAttachments.size > PRIMED_LIMIT) {
|
|
15
|
-
const oldest = primedAttachments.keys().next();
|
|
16
|
-
if (oldest.done) break;
|
|
17
|
-
primedAttachments.delete(oldest.value);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function takePrimedAttachment(id) {
|
|
21
|
-
const blob = primedAttachments.get(id);
|
|
22
|
-
if (!blob) return null;
|
|
23
|
-
primedAttachments.delete(id);
|
|
24
|
-
return blob;
|
|
25
|
-
}
|
|
26
|
-
const attachmentCache = /* @__PURE__ */ new Map();
|
|
27
|
-
const inflightFetches = /* @__PURE__ */ new Map();
|
|
28
|
-
const MAX_CACHE_BYTES = 48 * 1024 * 1024;
|
|
29
|
-
let cachedBytes = 0;
|
|
30
|
-
let touchClock = 0;
|
|
31
|
-
function cacheKey(id, scope) {
|
|
32
|
-
return scope ? `${scope}\0${id}` : id;
|
|
33
|
-
}
|
|
34
|
-
function trimCache() {
|
|
35
|
-
if (cachedBytes <= MAX_CACHE_BYTES) return;
|
|
36
|
-
const evictable = [...attachmentCache.entries()].filter(([, entry]) => entry.refs === 0).sort((a, b) => a[1].touched - b[1].touched);
|
|
37
|
-
for (const [id, entry] of evictable) {
|
|
38
|
-
if (cachedBytes <= MAX_CACHE_BYTES) break;
|
|
39
|
-
attachmentCache.delete(id);
|
|
40
|
-
cachedBytes -= entry.blob.size;
|
|
41
|
-
URL.revokeObjectURL(entry.url);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function acquireEntry(key, blob) {
|
|
45
|
-
let entry = attachmentCache.get(key);
|
|
46
|
-
if (!entry) {
|
|
47
|
-
entry = { blob, url: URL.createObjectURL(blob), refs: 0, touched: ++touchClock };
|
|
48
|
-
attachmentCache.set(key, entry);
|
|
49
|
-
cachedBytes += blob.size;
|
|
50
|
-
}
|
|
51
|
-
entry.touched = ++touchClock;
|
|
52
|
-
return entry;
|
|
53
|
-
}
|
|
54
|
-
function attachmentObjectUrl(id, onReady, fetcher = unavailableAttachment, onError, scope) {
|
|
55
|
-
const key = cacheKey(id, scope);
|
|
56
|
-
let released = false;
|
|
57
|
-
const dispose = () => {
|
|
58
|
-
if (released) return;
|
|
59
|
-
released = true;
|
|
60
|
-
releaseEntry(key);
|
|
61
|
-
};
|
|
62
|
-
const existing = attachmentCache.get(key);
|
|
63
|
-
if (existing) {
|
|
64
|
-
existing.refs += 1;
|
|
65
|
-
existing.touched = ++touchClock;
|
|
66
|
-
onReady(existing.url);
|
|
67
|
-
return dispose;
|
|
68
|
-
}
|
|
69
|
-
const primed = takePrimedAttachment(id);
|
|
70
|
-
if (primed) {
|
|
71
|
-
const entry = acquireEntry(key, primed);
|
|
72
|
-
entry.refs += 1;
|
|
73
|
-
onReady(entry.url);
|
|
74
|
-
trimCache();
|
|
75
|
-
return dispose;
|
|
76
|
-
}
|
|
77
|
-
let pending = inflightFetches.get(key);
|
|
78
|
-
if (!pending) {
|
|
79
|
-
pending = fetcher(id).finally(() => {
|
|
80
|
-
inflightFetches.delete(key);
|
|
81
|
-
});
|
|
82
|
-
inflightFetches.set(key, pending);
|
|
83
|
-
}
|
|
84
|
-
void pending.then((blob) => {
|
|
85
|
-
if (released) return;
|
|
86
|
-
const entry = acquireEntry(key, blob);
|
|
87
|
-
entry.refs += 1;
|
|
88
|
-
onReady(entry.url);
|
|
89
|
-
trimCache();
|
|
90
|
-
}).catch(() => {
|
|
91
|
-
if (!released) onError == null ? void 0 : onError();
|
|
92
|
-
});
|
|
93
|
-
return dispose;
|
|
94
|
-
}
|
|
95
|
-
function releaseEntry(key) {
|
|
96
|
-
const entry = attachmentCache.get(key);
|
|
97
|
-
if (!entry || entry.refs === 0) return;
|
|
98
|
-
entry.refs -= 1;
|
|
99
|
-
if (entry.refs === 0) {
|
|
100
|
-
entry.touched = ++touchClock;
|
|
101
|
-
trimCache();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function clearAttachmentCache(scope) {
|
|
105
|
-
const matches = (key) => scope === void 0 || key.startsWith(`${scope}\0`);
|
|
106
|
-
for (const [key, entry] of attachmentCache) if (matches(key)) {
|
|
107
|
-
URL.revokeObjectURL(entry.url);
|
|
108
|
-
attachmentCache.delete(key);
|
|
109
|
-
cachedBytes -= entry.blob.size;
|
|
110
|
-
}
|
|
111
|
-
for (const key of inflightFetches.keys()) if (matches(key)) inflightFetches.delete(key);
|
|
112
|
-
if (scope === void 0) primedAttachments.clear();
|
|
113
|
-
}
|
|
114
|
-
async function downloadAttachment(attachmentId, filename, fetcher = defaultAttachmentFetcher) {
|
|
115
|
-
const blob = await fetcher(attachmentId);
|
|
116
|
-
const url = URL.createObjectURL(blob);
|
|
117
|
-
const a = document.createElement("a");
|
|
118
|
-
a.href = url;
|
|
119
|
-
a.download = filename || "attachment";
|
|
120
|
-
document.body.appendChild(a);
|
|
121
|
-
a.click();
|
|
122
|
-
a.remove();
|
|
123
|
-
setTimeout(() => URL.revokeObjectURL(url), 1e4);
|
|
124
|
-
}
|
|
125
|
-
function formatBytes(bytes) {
|
|
126
|
-
if (!Number.isFinite(bytes) || bytes <= 0) return "";
|
|
127
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
128
|
-
let n = bytes;
|
|
129
|
-
let i = 0;
|
|
130
|
-
while (n >= 1024 && i < units.length - 1) {
|
|
131
|
-
n /= 1024;
|
|
132
|
-
i += 1;
|
|
133
|
-
}
|
|
134
|
-
return `${n >= 10 || i === 0 ? Math.round(n) : n.toFixed(1)} ${units[i]}`;
|
|
135
|
-
}
|
|
136
|
-
const Context = createContext({ host: {}, theme: "light", accent: "#2f6feb", portal: null });
|
|
137
|
-
function useContentContext() {
|
|
138
|
-
return useContext(Context);
|
|
139
|
-
}
|
|
140
|
-
function useContentHost() {
|
|
141
|
-
return useContentContext().host;
|
|
142
|
-
}
|
|
143
|
-
function ContentContextBridge({ value, children }) {
|
|
144
|
-
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
145
|
-
}
|
|
146
|
-
function ContentProvider({ host = {}, theme = "light", accent = "#2f6feb", unstyled = false, children, className = "" }) {
|
|
147
|
-
const [portal, setPortal] = useState(null);
|
|
148
|
-
const previousScope = useRef(host.scope), latestTheme = useRef({ theme, accent, unstyled });
|
|
149
|
-
latestTheme.current = { theme, accent, unstyled };
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
const element = document.createElement("div");
|
|
152
|
-
const { theme: currentTheme, accent: currentAccent, unstyled: currentUnstyled } = latestTheme.current;
|
|
153
|
-
element.className = `wendang-portal ${currentUnstyled ? "" : "wendang"}`.trim();
|
|
154
|
-
element.dataset.wendangPortal = "";
|
|
155
|
-
element.dataset.wendangTheme = currentTheme;
|
|
156
|
-
element.style.setProperty("--wendang-accent", currentAccent);
|
|
157
|
-
element.style.colorScheme = currentTheme;
|
|
158
|
-
document.body.append(element);
|
|
159
|
-
setPortal(element);
|
|
160
|
-
return () => {
|
|
161
|
-
element.remove();
|
|
162
|
-
};
|
|
163
|
-
}, []);
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
if (previousScope.current !== host.scope) {
|
|
166
|
-
clearAttachmentCache(previousScope.current);
|
|
167
|
-
previousScope.current = host.scope;
|
|
168
|
-
}
|
|
169
|
-
}, [host.scope]);
|
|
170
|
-
useEffect(() => {
|
|
171
|
-
if (!portal) return;
|
|
172
|
-
portal.className = `wendang-portal ${unstyled ? "" : "wendang"}`.trim();
|
|
173
|
-
portal.dataset.wendangTheme = theme;
|
|
174
|
-
portal.style.setProperty("--wendang-accent", accent);
|
|
175
|
-
portal.style.colorScheme = theme;
|
|
176
|
-
}, [portal, theme, accent, unstyled]);
|
|
177
|
-
return /* @__PURE__ */ jsx(Context.Provider, { value: { host, theme, accent, portal }, children: /* @__PURE__ */ jsx(
|
|
178
|
-
"div",
|
|
179
|
-
{
|
|
180
|
-
className: `wendang-root ${className}`,
|
|
181
|
-
"data-wendang-theme": theme,
|
|
182
|
-
style: { "--wendang-accent": accent, colorScheme: theme },
|
|
183
|
-
children: /* @__PURE__ */ jsx("div", { className: unstyled ? void 0 : "wendang", "data-wendang-theme": theme, children }, host.scope ?? "")
|
|
184
|
-
}
|
|
185
|
-
) });
|
|
186
|
-
}
|
|
187
|
-
export {
|
|
188
|
-
ContentProvider as C,
|
|
189
|
-
useContentContext as a,
|
|
190
|
-
useContentHost as b,
|
|
191
|
-
attachmentObjectUrl as c,
|
|
192
|
-
downloadAttachment as d,
|
|
193
|
-
ContentContextBridge as e,
|
|
194
|
-
formatBytes as f,
|
|
195
|
-
primeAttachment as p,
|
|
196
|
-
unavailableAttachment as u
|
|
197
|
-
};
|