Skip to content

Commit 6bc5d5e

Browse files
committed
Update SuperDoc.js to accept a File object via document key
1 parent cd43fa9 commit 6bc5d5e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/superdoc/src/core/SuperDoc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export class SuperDoc extends EventEmitter {
221221
const doc = this.config.document;
222222
const hasDocumentConfig = !!doc && typeof doc === 'object' && Object.keys(this.config.document)?.length;
223223
const hasDocumentUrl = !!doc && typeof doc === 'string' && doc.length > 0;
224+
const hasDocumentFile = !!doc && doc instanceof File;
224225
const hasListOfDocuments = this.config.documents && this.config.documents?.length;
225226
if (hasDocumentConfig && hasListOfDocuments) {
226227
console.warn('🦋 [superdoc] You can only provide one of document or documents');
@@ -237,6 +238,15 @@ export class SuperDoc extends EventEmitter {
237238
isNewFile: true,
238239
},
239240
];
241+
} else if (hasDocumentFile) {
242+
this.config.documents = [
243+
{
244+
type: this.config.document.type,
245+
data: this.config.document,
246+
name: this.config.document.name,
247+
isNewFile: true,
248+
},
249+
];
240250
}
241251
}
242252

0 commit comments

Comments
 (0)