@dxos/plugin-wnfs 0.8.4-main.72ec0f3 → 0.8.4-main.74a063c4e0
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/dist/lib/browser/chunk-BM3MEFES.mjs +69 -0
- package/dist/lib/browser/chunk-BM3MEFES.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D6VTEQIE.mjs → chunk-N6Y4QPNF.mjs} +23 -32
- package/dist/lib/browser/chunk-N6Y4QPNF.mjs.map +7 -0
- package/dist/lib/browser/chunk-VXUCZHVZ.mjs +69 -0
- package/dist/lib/browser/chunk-VXUCZHVZ.mjs.map +7 -0
- package/dist/lib/browser/create-NOHKWE67.mjs +24 -0
- package/dist/lib/browser/create-NOHKWE67.mjs.map +7 -0
- package/dist/lib/browser/create-file-N7ADCFOF.mjs +49 -0
- package/dist/lib/browser/create-file-N7ADCFOF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +92 -91
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -3
- package/dist/lib/browser/upload-DA7GBOXF.mjs +42 -0
- package/dist/lib/browser/upload-DA7GBOXF.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +3 -2
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +4 -2
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +3 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +16 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
- package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +1 -1
- package/dist/types/src/helpers/load.d.ts.map +1 -1
- package/dist/types/src/helpers/upload.d.ts +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +5 -0
- package/dist/types/src/operations/create-file.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +38 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/upload.d.ts +5 -0
- package/dist/types/src/operations/upload.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +13 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +11 -11
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -50
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -36
- package/src/WnfsPlugin.tsx +53 -73
- package/src/blockstore.ts +1 -1
- package/src/capabilities/blockstore.ts +15 -11
- package/src/capabilities/file-uploader.ts +24 -17
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/markdown.ts +22 -14
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +40 -34
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +6 -6
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +43 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/{components → containers/FileContainer}/FileContainer.tsx +13 -15
- package/src/containers/FileContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +8 -9
- package/src/extensions/image.tsx +4 -3
- package/src/helpers/load.ts +12 -7
- package/src/helpers/upload.ts +5 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +3 -3
- package/src/operations/create-file.ts +31 -0
- package/src/operations/create.ts +22 -0
- package/src/operations/definitions.ts +41 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/upload.ts +29 -0
- package/src/translations.ts +13 -9
- package/src/types/File.ts +11 -7
- package/src/{capabilities → types}/capabilities.ts +4 -4
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +3 -20
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs +0 -103
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs.map +0 -7
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs +0 -191
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs.map +0 -7
- package/dist/lib/browser/chunk-CWMKN2F6.mjs +0 -71
- package/dist/lib/browser/chunk-CWMKN2F6.mjs.map +0 -7
- package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
- package/dist/lib/browser/chunk-F4QHZWQD.mjs +0 -16
- package/dist/lib/browser/chunk-F4QHZWQD.mjs.map +0 -7
- package/dist/lib/browser/chunk-OGPGLJCV.mjs +0 -25
- package/dist/lib/browser/chunk-OGPGLJCV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs +0 -16
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs +0 -30
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs +0 -48
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs.map +0 -7
- package/dist/lib/browser/markdown-WYQDCVFQ.mjs +0 -198
- package/dist/lib/browser/markdown-WYQDCVFQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-DMU47U3X.mjs +0 -88
- package/dist/lib/browser/react-surface-DMU47U3X.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -9
- package/dist/types/src/components/FileContainer.d.ts.map +0 -1
- package/dist/types/src/components/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview.d.ts +0 -11
- package/dist/types/src/components/FilePreview.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/components/FilePreview.tsx +0 -23
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getBlobUrl,
|
|
3
|
-
getPathFromUrl,
|
|
4
|
-
loadWnfs
|
|
5
|
-
} from "./chunk-D6VTEQIE.mjs";
|
|
6
|
-
import {
|
|
7
|
-
WnfsCapabilities
|
|
8
|
-
} from "./chunk-F4QHZWQD.mjs";
|
|
9
|
-
import "./chunk-OGPGLJCV.mjs";
|
|
10
|
-
|
|
11
|
-
// src/capabilities/markdown.ts
|
|
12
|
-
import { contributes } from "@dxos/app-framework";
|
|
13
|
-
import { MarkdownCapabilities } from "@dxos/plugin-markdown";
|
|
14
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
15
|
-
|
|
16
|
-
// src/extensions/image.tsx
|
|
17
|
-
import { syntaxTree } from "@codemirror/language";
|
|
18
|
-
import { StateField } from "@codemirror/state";
|
|
19
|
-
import { Decoration, EditorView, WidgetType } from "@codemirror/view";
|
|
20
|
-
import React from "react";
|
|
21
|
-
import { createRoot } from "react-dom/client";
|
|
22
|
-
import { Status, ThemeProvider } from "@dxos/react-ui";
|
|
23
|
-
import { focusField } from "@dxos/react-ui-editor";
|
|
24
|
-
import { defaultTx } from "@dxos/react-ui-theme";
|
|
25
|
-
var WAIT_UNTIL_LOADER = 1500;
|
|
26
|
-
var image = (options) => {
|
|
27
|
-
const blobUrlCache = {};
|
|
28
|
-
const preloaded = /* @__PURE__ */ new Set();
|
|
29
|
-
const preload = (url) => {
|
|
30
|
-
if (!preloaded.has(url)) {
|
|
31
|
-
const img = document.createElement("img");
|
|
32
|
-
img.src = url;
|
|
33
|
-
preloaded.add(url);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return [
|
|
37
|
-
StateField.define({
|
|
38
|
-
create: (state) => {
|
|
39
|
-
return Decoration.set(buildDecorations({
|
|
40
|
-
from: 0,
|
|
41
|
-
to: state.doc.length,
|
|
42
|
-
state,
|
|
43
|
-
blobUrlCache,
|
|
44
|
-
preload,
|
|
45
|
-
options
|
|
46
|
-
}));
|
|
47
|
-
},
|
|
48
|
-
update: (value, tr) => {
|
|
49
|
-
if (!tr.docChanged && !tr.selection) {
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
const cursor = tr.state.selection.main.head;
|
|
53
|
-
const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);
|
|
54
|
-
let from = Math.min(cursor, oldCursor);
|
|
55
|
-
let to = Math.max(cursor, oldCursor);
|
|
56
|
-
tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {
|
|
57
|
-
from = Math.min(from, fromB);
|
|
58
|
-
to = Math.max(to, toB);
|
|
59
|
-
});
|
|
60
|
-
from = tr.state.doc.lineAt(from).from;
|
|
61
|
-
to = tr.state.doc.lineAt(to).to;
|
|
62
|
-
return value.map(tr.changes).update({
|
|
63
|
-
filterFrom: from,
|
|
64
|
-
filterTo: to,
|
|
65
|
-
filter: () => false,
|
|
66
|
-
add: buildDecorations({
|
|
67
|
-
from,
|
|
68
|
-
to,
|
|
69
|
-
state: tr.state,
|
|
70
|
-
blobUrlCache,
|
|
71
|
-
preload,
|
|
72
|
-
options
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
provide: (field) => EditorView.decorations.from(field)
|
|
77
|
-
})
|
|
78
|
-
];
|
|
79
|
-
};
|
|
80
|
-
var buildDecorations = ({ state, from, to, blobUrlCache, preload, options: { blockstore, instances, space } }) => {
|
|
81
|
-
const decorations = [];
|
|
82
|
-
const cursor = state.selection.main.head;
|
|
83
|
-
syntaxTree(state).iterate({
|
|
84
|
-
enter: (node) => {
|
|
85
|
-
if (node.name !== "Image") {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const urlNode = node.node.getChild("URL");
|
|
89
|
-
if (!urlNode) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const hide = state.readOnly || cursor < node.from || cursor > node.to;
|
|
93
|
-
const wnfsUrl = state.sliceDoc(urlNode.from, urlNode.to);
|
|
94
|
-
if (!wnfsUrl.startsWith("wnfs://")) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const path = getPathFromUrl(wnfsUrl);
|
|
98
|
-
const spaceId = path[1];
|
|
99
|
-
if (spaceId !== space.id) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const blobUrlPromise = (async () => {
|
|
103
|
-
const { directory, forest } = await loadWnfs({
|
|
104
|
-
blockstore,
|
|
105
|
-
instances,
|
|
106
|
-
space
|
|
107
|
-
});
|
|
108
|
-
const url = await getBlobUrl({
|
|
109
|
-
wnfsUrl,
|
|
110
|
-
blockstore,
|
|
111
|
-
directory,
|
|
112
|
-
forest
|
|
113
|
-
});
|
|
114
|
-
blobUrlCache[path.join("/")] = url;
|
|
115
|
-
preload(url);
|
|
116
|
-
return url;
|
|
117
|
-
})();
|
|
118
|
-
decorations.push(Decoration.replace({
|
|
119
|
-
block: true,
|
|
120
|
-
widget: new WnfsImageWidget(wnfsUrl, blobUrlCache[path.join("/")] ?? blobUrlPromise)
|
|
121
|
-
}).range(hide ? node.from : node.to, node.to));
|
|
122
|
-
},
|
|
123
|
-
from,
|
|
124
|
-
to
|
|
125
|
-
});
|
|
126
|
-
return decorations;
|
|
127
|
-
};
|
|
128
|
-
var createImg = (view, url) => {
|
|
129
|
-
const img = document.createElement("img");
|
|
130
|
-
img.setAttribute("src", url);
|
|
131
|
-
img.setAttribute("class", "cm-image-with-loader");
|
|
132
|
-
if (view.state.field(focusField)) {
|
|
133
|
-
img.onload = () => img.classList.add("cm-loaded-image");
|
|
134
|
-
} else {
|
|
135
|
-
img.classList.add("cm-loaded-image");
|
|
136
|
-
}
|
|
137
|
-
return img;
|
|
138
|
-
};
|
|
139
|
-
var WnfsImageWidget = class extends WidgetType {
|
|
140
|
-
_wnfsUrl;
|
|
141
|
-
_url;
|
|
142
|
-
constructor(_wnfsUrl, _url) {
|
|
143
|
-
super(), this._wnfsUrl = _wnfsUrl, this._url = _url;
|
|
144
|
-
}
|
|
145
|
-
eq(other) {
|
|
146
|
-
return this._wnfsUrl === other._wnfsUrl;
|
|
147
|
-
}
|
|
148
|
-
toDOM(view) {
|
|
149
|
-
if (typeof this._url === "string") {
|
|
150
|
-
return createImg(view, this._url);
|
|
151
|
-
}
|
|
152
|
-
const widget = document.createElement("div");
|
|
153
|
-
widget.className = "cm-image-wrapper";
|
|
154
|
-
const loader = document.createElement("div");
|
|
155
|
-
loader.className = "mx-auto transition-opacity";
|
|
156
|
-
let loaderAdded = false;
|
|
157
|
-
const timeout = setTimeout(() => {
|
|
158
|
-
const root = createRoot(loader);
|
|
159
|
-
root.render(/* @__PURE__ */ React.createElement(ThemeProvider, {
|
|
160
|
-
tx: defaultTx
|
|
161
|
-
}, /* @__PURE__ */ React.createElement(Status, {
|
|
162
|
-
indeterminate: true
|
|
163
|
-
})));
|
|
164
|
-
widget.appendChild(loader);
|
|
165
|
-
loaderAdded = true;
|
|
166
|
-
}, WAIT_UNTIL_LOADER);
|
|
167
|
-
void this._url.then((url) => {
|
|
168
|
-
clearTimeout(timeout);
|
|
169
|
-
const img = createImg(view, url);
|
|
170
|
-
loaderAdded && widget.removeChild(loader);
|
|
171
|
-
widget.appendChild(img);
|
|
172
|
-
});
|
|
173
|
-
return widget;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// src/capabilities/markdown.ts
|
|
178
|
-
var markdown_default = ((context) => contributes(MarkdownCapabilities.Extensions, [
|
|
179
|
-
({ document: document2 }) => {
|
|
180
|
-
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
181
|
-
const instances = context.getCapability(WnfsCapabilities.Instances);
|
|
182
|
-
if (document2) {
|
|
183
|
-
const space = getSpace(document2);
|
|
184
|
-
return space ? [
|
|
185
|
-
image({
|
|
186
|
-
blockstore,
|
|
187
|
-
instances,
|
|
188
|
-
space
|
|
189
|
-
})
|
|
190
|
-
] : [];
|
|
191
|
-
}
|
|
192
|
-
return [];
|
|
193
|
-
}
|
|
194
|
-
]));
|
|
195
|
-
export {
|
|
196
|
-
markdown_default as default
|
|
197
|
-
};
|
|
198
|
-
//# sourceMappingURL=markdown-WYQDCVFQ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/markdown.ts", "../../../src/extensions/image.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type PluginContext, contributes } from '@dxos/app-framework';\nimport { MarkdownCapabilities } from '@dxos/plugin-markdown';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { image } from '../extensions';\n\nimport { WnfsCapabilities } from './capabilities';\n\nexport default (context: PluginContext) =>\n contributes(MarkdownCapabilities.Extensions, [\n ({ document }) => {\n const blockstore = context.getCapability(WnfsCapabilities.Blockstore);\n const instances = context.getCapability(WnfsCapabilities.Instances);\n\n if (document) {\n const space = getSpace(document);\n return space ? [image({ blockstore, instances, space })] : [];\n }\n\n return [];\n },\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type EditorState, type Extension, type Range, StateField } from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\nimport type { Blockstore } from 'interface-blockstore';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { Status, ThemeProvider } from '@dxos/react-ui';\nimport { focusField } from '@dxos/react-ui-editor';\nimport { defaultTx } from '@dxos/react-ui-theme';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { type WnfsCapabilities } from '../capabilities';\nimport { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';\n\nconst WAIT_UNTIL_LOADER = 1500;\n\nexport type ImageOptions = {\n blockstore: Blockstore;\n instances: WnfsCapabilities.Instances;\n space: Space;\n};\n\n/**\n * Create WNFS image decorations.\n */\nexport const image = (options: ImageOptions): Extension[] => {\n const blobUrlCache: Record<string, string> = {};\n const preloaded = new Set<string>();\n\n const preload = (url: string) => {\n if (!preloaded.has(url)) {\n const img = document.createElement('img');\n img.src = url;\n preloaded.add(url);\n }\n };\n\n return [\n StateField.define({\n create: (state) => {\n return Decoration.set(\n buildDecorations({ from: 0, to: state.doc.length, state, blobUrlCache, preload, options }),\n );\n },\n update: (value, tr) => {\n if (!tr.docChanged && !tr.selection) {\n return value;\n }\n\n // Find range of changes and cursor changes.\n const cursor = tr.state.selection.main.head;\n const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);\n let from = Math.min(cursor, oldCursor);\n let to = Math.max(cursor, oldCursor);\n tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {\n from = Math.min(from, fromB);\n to = Math.max(to, toB);\n });\n\n // Expand to cover lines.\n from = tr.state.doc.lineAt(from).from;\n to = tr.state.doc.lineAt(to).to;\n\n return value.map(tr.changes).update({\n filterFrom: from,\n filterTo: to,\n filter: () => false,\n add: buildDecorations({ from, to, state: tr.state, blobUrlCache, preload, options }),\n });\n },\n provide: (field) => EditorView.decorations.from(field),\n }),\n ];\n};\n\nconst buildDecorations = ({\n state,\n from,\n to,\n blobUrlCache,\n preload,\n options: { blockstore, instances, space },\n}: {\n state: EditorState;\n from: number;\n to: number;\n blobUrlCache: Record<string, string>;\n preload: (url: string) => void;\n options: ImageOptions;\n}) => {\n const decorations: Range<Decoration>[] = [];\n const cursor = state.selection.main.head;\n syntaxTree(state).iterate({\n enter: (node) => {\n if (node.name !== 'Image') {\n return;\n }\n\n const urlNode = node.node.getChild('URL');\n if (!urlNode) {\n return;\n }\n\n const hide = state.readOnly || cursor < node.from || cursor > node.to;\n const wnfsUrl = state.sliceDoc(urlNode.from, urlNode.to);\n if (!wnfsUrl.startsWith('wnfs://')) {\n return;\n }\n\n const path = getPathFromUrl(wnfsUrl);\n\n // Cannot load images from other spaces\n const spaceId = path[1];\n if (spaceId !== space.id) {\n return;\n }\n\n // Load image contents into memory blob\n const blobUrlPromise = (async () => {\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const url = await getBlobUrl({ wnfsUrl, blockstore, directory, forest });\n blobUrlCache[path.join('/')] = url;\n preload(url);\n return url;\n })();\n\n decorations.push(\n Decoration.replace({\n block: true, // Prevent cursor from entering.\n widget: new WnfsImageWidget(wnfsUrl, blobUrlCache[path.join('/')] ?? blobUrlPromise),\n }).range(hide ? node.from : node.to, node.to),\n );\n },\n from,\n to,\n });\n\n return decorations;\n};\n\nconst createImg = (view: EditorView, url: string) => {\n const img = document.createElement('img');\n img.setAttribute('src', url);\n img.setAttribute('class', 'cm-image-with-loader');\n // If focused, hide image until successfully loaded to avoid flickering effects.\n if (view.state.field(focusField)) {\n img.onload = () => img.classList.add('cm-loaded-image');\n } else {\n img.classList.add('cm-loaded-image');\n }\n return img;\n};\n\nclass WnfsImageWidget extends WidgetType {\n constructor(\n readonly _wnfsUrl: string,\n readonly _url: MaybePromise<string>,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._wnfsUrl === other._wnfsUrl;\n }\n\n override toDOM(view: EditorView) {\n if (typeof this._url === 'string') {\n return createImg(view, this._url);\n }\n\n const widget = document.createElement('div');\n widget.className = 'cm-image-wrapper';\n const loader = document.createElement('div');\n loader.className = 'mx-auto transition-opacity';\n let loaderAdded = false;\n\n const timeout = setTimeout(() => {\n const root = createRoot(loader);\n root.render(\n <ThemeProvider tx={defaultTx}>\n <Status indeterminate />\n </ThemeProvider>,\n );\n widget.appendChild(loader);\n loaderAdded = true;\n }, WAIT_UNTIL_LOADER);\n\n void this._url.then((url) => {\n clearTimeout(timeout);\n const img = createImg(view, url);\n loaderAdded && widget.removeChild(loader);\n widget.appendChild(img);\n });\n\n return widget;\n }\n}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tCuF,WAAOD,YAAY;AACnB,QAAIE,cAAc;AAElB,UAAMC,UAAUC,WAAW,MAAA;AACzB,YAAMC,OAAOC,WAAWL,MAAAA;AACxBI,WAAKE,OACH,sBAAA,cAACC,eAAAA;QAAcC,IAAIC;SACjB,sBAAA,cAACC,QAAAA;QAAOC,eAAAA;;AAGZ3B,aAAO4B,YAAYZ,MAAAA;AACnBC,oBAAc;IAChB,GAAGnG,iBAAAA;AAEH,SAAK,KAAK6F,KAAKkB,KAAK,CAACxG,QAAAA;AACnByG,mBAAaZ,OAAAA;AACb,YAAM3F,MAAM4E,UAAUC,MAAM/E,GAAAA;AAC5B4F,qBAAejB,OAAO+B,YAAYf,MAAAA;AAClChB,aAAO4B,YAAYrG,GAAAA;IACrB,CAAA;AAEA,WAAOyE;EACT;AACF;;;AD9LA,IAAA,oBAAe,CAACgC,YACdC,YAAYC,qBAAqBC,YAAY;EAC3C,CAAC,EAAEC,UAAAA,UAAQ,MAAE;AACX,UAAMC,aAAaL,QAAQM,cAAcC,iBAAiBC,UAAU;AACpE,UAAMC,YAAYT,QAAQM,cAAcC,iBAAiBG,SAAS;AAElE,QAAIN,WAAU;AACZ,YAAMO,QAAQC,SAASR,SAAAA;AACvB,aAAOO,QAAQ;QAACE,MAAM;UAAER;UAAYI;UAAWE;QAAM,CAAA;UAAM,CAAA;IAC7D;AAEA,WAAO,CAAA;EACT;CACD;",
|
|
6
|
-
"names": ["contributes", "MarkdownCapabilities", "getSpace", "syntaxTree", "StateField", "Decoration", "EditorView", "WidgetType", "React", "createRoot", "Status", "ThemeProvider", "focusField", "defaultTx", "WAIT_UNTIL_LOADER", "image", "options", "blobUrlCache", "preloaded", "Set", "preload", "url", "has", "img", "document", "createElement", "src", "add", "StateField", "define", "create", "state", "Decoration", "set", "buildDecorations", "from", "to", "doc", "length", "update", "value", "tr", "docChanged", "selection", "cursor", "main", "head", "oldCursor", "changes", "mapPos", "startState", "Math", "min", "max", "iterChangedRanges", "fromA", "toA", "fromB", "toB", "lineAt", "map", "filterFrom", "filterTo", "filter", "provide", "field", "EditorView", "decorations", "blockstore", "instances", "space", "syntaxTree", "iterate", "enter", "node", "name", "urlNode", "getChild", "hide", "readOnly", "wnfsUrl", "sliceDoc", "startsWith", "path", "getPathFromUrl", "spaceId", "id", "blobUrlPromise", "directory", "forest", "loadWnfs", "getBlobUrl", "join", "push", "replace", "block", "widget", "WnfsImageWidget", "range", "createImg", "view", "setAttribute", "focusField", "onload", "classList", "WidgetType", "_wnfsUrl", "_url", "eq", "other", "toDOM", "className", "loader", "loaderAdded", "timeout", "setTimeout", "root", "createRoot", "render", "ThemeProvider", "tx", "defaultTx", "Status", "indeterminate", "appendChild", "then", "clearTimeout", "removeChild", "context", "contributes", "MarkdownCapabilities", "Extensions", "document", "blockstore", "getCapability", "WnfsCapabilities", "Blockstore", "instances", "Instances", "space", "getSpace", "image"]
|
|
7
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
File_exports,
|
|
3
|
-
WnfsAction
|
|
4
|
-
} from "./chunk-CWMKN2F6.mjs";
|
|
5
|
-
import {
|
|
6
|
-
meta
|
|
7
|
-
} from "./chunk-OGPGLJCV.mjs";
|
|
8
|
-
|
|
9
|
-
// src/capabilities/react-surface.tsx
|
|
10
|
-
import React2, { useCallback as useCallback2 } from "react";
|
|
11
|
-
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
12
|
-
import { Obj } from "@dxos/echo";
|
|
13
|
-
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
14
|
-
|
|
15
|
-
// src/components/index.ts
|
|
16
|
-
import { lazy } from "react";
|
|
17
|
-
|
|
18
|
-
// src/components/FileInput.tsx
|
|
19
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
20
|
-
import React, { useCallback } from "react";
|
|
21
|
-
import { useDropzone } from "react-dropzone";
|
|
22
|
-
import { findAnnotation } from "@dxos/effect";
|
|
23
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
24
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
25
|
-
var FileInput = ({ schema, onChange }) => {
|
|
26
|
-
var _effect = _useSignals();
|
|
27
|
-
try {
|
|
28
|
-
const { t } = useTranslation(meta.id);
|
|
29
|
-
const accept = findAnnotation(schema.ast, WnfsAction.UploadAnnotationId);
|
|
30
|
-
const onDropAccepted = useCallback((files) => onChange?.(files[0]), [
|
|
31
|
-
onChange
|
|
32
|
-
]);
|
|
33
|
-
const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
|
|
34
|
-
multiple: false,
|
|
35
|
-
accept,
|
|
36
|
-
onDropAccepted
|
|
37
|
-
});
|
|
38
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
39
|
-
...getRootProps(),
|
|
40
|
-
className: mx("flex flex-col items-center p-8 border border-separator", isFocused && "focus-ring", isDragAccept && "bg-attention", isDragReject && "border-roseFill")
|
|
41
|
-
}, /* @__PURE__ */ React.createElement("input", getInputProps()), acceptedFiles[0] ? /* @__PURE__ */ React.createElement("p", null, acceptedFiles[0].name) : /* @__PURE__ */ React.createElement("p", null, t("file input placeholder")));
|
|
42
|
-
} finally {
|
|
43
|
-
_effect.f();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// src/components/index.ts
|
|
48
|
-
var FileContainer = lazy(() => import("./FileContainer-LLNI7WXR.mjs"));
|
|
49
|
-
|
|
50
|
-
// src/capabilities/react-surface.tsx
|
|
51
|
-
var react_surface_default = (() => contributes(Capabilities.ReactSurface, [
|
|
52
|
-
createSurface({
|
|
53
|
-
id: `${meta.id}/article`,
|
|
54
|
-
role: [
|
|
55
|
-
"article",
|
|
56
|
-
"section",
|
|
57
|
-
"slide"
|
|
58
|
-
],
|
|
59
|
-
filter: (data) => Obj.instanceOf(File_exports.File, data.subject),
|
|
60
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(FileContainer, {
|
|
61
|
-
role,
|
|
62
|
-
file: data.subject
|
|
63
|
-
})
|
|
64
|
-
}),
|
|
65
|
-
createSurface({
|
|
66
|
-
id: `${meta.id}/create-form`,
|
|
67
|
-
role: "form-input",
|
|
68
|
-
filter: (data) => {
|
|
69
|
-
const annotation = findAnnotation2(data.schema.ast, WnfsAction.UploadAnnotationId);
|
|
70
|
-
return !!annotation;
|
|
71
|
-
},
|
|
72
|
-
component: ({ data: { prop, schema }, ...props }) => {
|
|
73
|
-
const inputProps = props;
|
|
74
|
-
const handleChange = useCallback2((file) => inputProps.onValueChange?.("object", file), [
|
|
75
|
-
prop,
|
|
76
|
-
inputProps.onValueChange
|
|
77
|
-
]);
|
|
78
|
-
return /* @__PURE__ */ React2.createElement(FileInput, {
|
|
79
|
-
schema,
|
|
80
|
-
onChange: handleChange
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
]));
|
|
85
|
-
export {
|
|
86
|
-
react_surface_default as default
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=react-surface-DMU47U3X.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/index.ts", "../../../src/components/FileInput.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { useCallback } from 'react';\n\nimport { Capabilities, contributes, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { findAnnotation } from '@dxos/effect';\nimport { type InputProps } from '@dxos/react-ui-form';\n\nimport { FileContainer, FileInput } from '../components';\nimport { meta } from '../meta';\nimport { WnfsAction, WnfsFile } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${meta.id}/article`,\n role: ['article', 'section', 'slide'],\n filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, data.subject),\n component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,\n }),\n createSurface({\n id: `${meta.id}/create-form`,\n role: 'form-input',\n filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {\n const annotation = findAnnotation<boolean>(\n (data.schema as Schema.Schema.All).ast,\n WnfsAction.UploadAnnotationId,\n );\n return !!annotation;\n },\n component: ({ data: { prop, schema }, ...props }) => {\n const inputProps = props as unknown as InputProps;\n const handleChange = useCallback(\n (file: File) => inputProps.onValueChange?.('object', file),\n [prop, inputProps.onValueChange],\n );\n\n return <FileInput schema={schema} onChange={handleChange} />;\n },\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport const FileContainer = lazy(() => import('./FileContainer'));\n\nexport * from './FileInput';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { useCallback } from 'react';\nimport { useDropzone } from 'react-dropzone';\n\nimport { findAnnotation } from '@dxos/effect';\nimport { useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../meta';\nimport { WnfsAction } from '../types';\n\nexport type FileInputProps = {\n schema: Schema.Schema.Any;\n onChange: (file: File) => void;\n};\n\nexport const FileInput = ({ schema, onChange }: FileInputProps) => {\n const { t } = useTranslation(meta.id);\n const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);\n\n const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);\n\n const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({\n multiple: false,\n accept,\n onDropAccepted,\n });\n\n return (\n <div\n {...getRootProps()}\n className={mx(\n 'flex flex-col items-center p-8 border border-separator',\n isFocused && 'focus-ring',\n isDragAccept && 'bg-attention',\n isDragReject && 'border-roseFill',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}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MAAMJ,KAAKK,OAAO;IAChGC,WAAW,CAAC,EAAEN,MAAMF,KAAI,MAAO,gBAAAS,OAAA,cAACC,eAAAA;MAAcV;MAAYW,MAAMT,KAAKK;;EACvE,CAAA;EACAV,cAAc;IACZC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNC,QAAQ,CAACC,SAAAA;AACP,YAAMU,aAAaC,gBAChBX,KAAKY,OAA6BC,KACnCC,WAAWC,kBAAkB;AAE/B,aAAO,CAAC,CAACL;IACX;IACAJ,WAAW,CAAC,EAAEN,MAAM,EAAEgB,MAAMJ,OAAM,GAAI,GAAGK,MAAAA,MAAO;AAC9C,YAAMC,aAAaD;AACnB,YAAME,eAAeC,aACnB,CAACX,SAAeS,WAAWG,gBAAgB,UAAUZ,IAAAA,GACrD;QAACO;QAAME,WAAWG;OAAc;AAGlC,aAAO,gBAAAd,OAAA,cAACe,WAAAA;QAAUV;QAAgBW,UAAUJ;;IAC9C;EACF,CAAA;CACD;",
|
|
6
|
-
"names": ["React", "useCallback", "Capabilities", "contributes", "createSurface", "Obj", "findAnnotation", "lazy", "React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "FileInput", "schema", "onChange", "t", "useTranslation", "meta", "id", "accept", "findAnnotation", "ast", "WnfsAction", "UploadAnnotationId", "onDropAccepted", "useCallback", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "useDropzone", "multiple", "div", "className", "mx", "input", "p", "name", "FileContainer", "lazy", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "WnfsFile", "File", "subject", "component", "React", "FileContainer", "file", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "prop", "props", "inputProps", "handleChange", "useCallback", "onValueChange", "FileInput", "onChange"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/capabilities.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAGjE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,yBAAiB,gBAAgB,CAAC;IACzB,MAAM,UAAU,wFAAmE,CAAC;IAE3F,KAAY,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACzF,MAAM,SAAS,uDAAiE,CAAC;CACzF"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Capabilities, type PluginContext } from '@dxos/app-framework';
|
|
2
|
-
declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<import("@dxos/app-framework").InterfaceDef<Capabilities.IntentResolver>>;
|
|
3
|
-
export default _default;
|
|
4
|
-
//# sourceMappingURL=intent-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAA+B,MAAM,qBAAqB,CAAC;yBAOpF,SAAS,aAAa;AAAtC,wBAoBK"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type WnfsFile } from '../types';
|
|
3
|
-
export type FileContainerProps = {
|
|
4
|
-
role: string;
|
|
5
|
-
file: WnfsFile.File;
|
|
6
|
-
};
|
|
7
|
-
export declare const FileContainer: ({ file }: FileContainerProps) => React.JSX.Element | null;
|
|
8
|
-
export default FileContainer;
|
|
9
|
-
//# sourceMappingURL=FileContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/FileContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAUxC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,kBAAkB,6BAiCzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../../src/components/FileInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAsB,MAAM,OAAO,CAAC;AAU3C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAsB,cAAc,sBA0B7D,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
-
export type FilePreviewProps = ThemedClassName<{
|
|
4
|
-
type: string;
|
|
5
|
-
url: string;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* File/content preview iframe.
|
|
9
|
-
*/
|
|
10
|
-
export declare const FilePreview: ({ type, url, classNames }: FilePreviewProps) => React.JSX.Element;
|
|
11
|
-
//# sourceMappingURL=FilePreview.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/FilePreview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,2BAA2B,gBAAgB,sBAQtE,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
import { upload } from '../helpers';
|
|
8
|
-
import { WnfsAction, WnfsFile } from '../types';
|
|
9
|
-
|
|
10
|
-
import { WnfsCapabilities } from './capabilities';
|
|
11
|
-
|
|
12
|
-
export default (context: PluginContext) =>
|
|
13
|
-
contributes(Capabilities.IntentResolver, [
|
|
14
|
-
// TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
|
|
15
|
-
// Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.
|
|
16
|
-
createResolver({
|
|
17
|
-
intent: WnfsAction.Create,
|
|
18
|
-
resolve: ({ name, type, cid }) => ({
|
|
19
|
-
data: {
|
|
20
|
-
object: WnfsFile.make({ name, type, cid }),
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
23
|
-
}),
|
|
24
|
-
createResolver({
|
|
25
|
-
intent: WnfsAction.Upload,
|
|
26
|
-
resolve: async ({ file, space }) => {
|
|
27
|
-
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
28
|
-
const info = await upload({ file, blockstore, space });
|
|
29
|
-
return { data: info };
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
]);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
-
|
|
10
|
-
export type FilePreviewProps = ThemedClassName<{ type: string; url: string }>;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* File/content preview iframe.
|
|
14
|
-
*/
|
|
15
|
-
export const FilePreview = ({ type, url, classNames }: FilePreviewProps) => {
|
|
16
|
-
if (type.startsWith('image/')) {
|
|
17
|
-
return <img className={mx('is-full bs-full object-contain', classNames)} src={url} />;
|
|
18
|
-
} else if (type.startsWith('video/')) {
|
|
19
|
-
return <video className={mx('is-full bs-full object-contain', classNames)} src={url} controls />;
|
|
20
|
-
} else {
|
|
21
|
-
return <iframe className={mx('is-full bs-full overflow-auto', classNames)} src={url} />;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
File without changes
|