diff --git a/models/view/src/index.ts b/models/view/src/index.ts index f77d6bff86..81b1dc09f9 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -647,7 +647,7 @@ export function createModel (builder: Builder): void { presentation.class.FilePreviewExtension, core.space.Model, { - contentType: ['application/pdf', 'application/json', 'text/*'], + contentType: ['application/pdf'], alignment: 'float', component: view.component.PDFViewer, extension: presentation.extension.FilePreviewExtension @@ -655,6 +655,18 @@ export function createModel (builder: Builder): void { view.extension.PDF ) + builder.createDoc( + presentation.class.FilePreviewExtension, + core.space.Model, + { + contentType: ['application/json', 'text/*'], + alignment: 'float', + component: view.component.TextViewer, + extension: presentation.extension.FilePreviewExtension + }, + view.extension.Text + ) + createAction( builder, { diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index 2978ee19b8..c45bfc0e37 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -88,7 +88,8 @@ export default mergeIds(viewId, view, { AudioViewer: '' as AnyComponent, ImageViewer: '' as AnyComponent, VideoViewer: '' as AnyComponent, - PDFViewer: '' as AnyComponent + PDFViewer: '' as AnyComponent, + TextViewer: '' as AnyComponent }, string: { Table: '' as IntlString, @@ -150,6 +151,7 @@ export default mergeIds(viewId, view, { Audio: '' as Ref, Image: '' as Ref, Video: '' as Ref, - PDF: '' as Ref + PDF: '' as Ref, + Text: '' as Ref } }) diff --git a/packages/presentation/src/components/FilePreview.svelte b/packages/presentation/src/components/FilePreview.svelte index 0bdf857e9d..96d3eee38e 100644 --- a/packages/presentation/src/components/FilePreview.svelte +++ b/packages/presentation/src/components/FilePreview.svelte @@ -14,7 +14,14 @@ --> + +{#if loading} +
+ +
+{:else} +
+ +
{text}
+
+
+{/if} + + diff --git a/plugins/view-resources/src/index.ts b/plugins/view-resources/src/index.ts index ae48431a23..f05390a215 100644 --- a/plugins/view-resources/src/index.ts +++ b/plugins/view-resources/src/index.ts @@ -99,6 +99,7 @@ import AudioViewer from './components/viewer/AudioViewer.svelte' import ImageViewer from './components/viewer/ImageViewer.svelte' import VideoViewer from './components/viewer/VideoViewer.svelte' import PDFViewer from './components/viewer/PDFViewer.svelte' +import TextViewer from './components/viewer/TextViewer.svelte' import { blobImageMetadata, blobVideoMetadata } from './blob' @@ -295,7 +296,8 @@ export default async (): Promise => ({ AudioViewer, ImageViewer, VideoViewer, - PDFViewer + PDFViewer, + TextViewer }, popup: { PositionElementAlignment