File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,17 @@ export class File implements FileLike {
170
170
this . dispatchEvent ( 'ondocumentobjchange' ) ;
171
171
}
172
172
173
+ /**
174
+ * Use this file to make updates to `documentObj` that you want reflected in
175
+ * `fileObj` and `thumbnail`. Since mutations directly to `documentObj` will
176
+ * not be detected, using this function tells `File` to trigger an update.
177
+ */
178
+ async updateDocumentObj ( updater : ( documentObj : CoreControls . Document ) => Promise < void > ) {
179
+ const documentObj = await this . documentObj . get ( ) ;
180
+ await updater ( documentObj ) ;
181
+ this . setDocumentObj ( documentObj ) ;
182
+ }
183
+
173
184
/* --- File utility functions. --- */
174
185
175
186
/**
@@ -189,10 +200,10 @@ export class File implements FileLike {
189
200
*/
190
201
clone ( ) {
191
202
return new File ( {
192
- name : this . _name ,
193
- originalName : this . _originalName ,
194
- extension : this . _extension ,
195
- documentObj : blobToDocument ( documentToBlob ( this . _documentObj . get ( ) ) , this . _extension ) ,
203
+ name : this . name ,
204
+ originalName : this . originalName ,
205
+ extension : this . extension ,
206
+ documentObj : blobToDocument ( documentToBlob ( this . documentObj . get ( ) ) , this . extension ) ,
196
207
} ) ;
197
208
}
198
209
You can’t perform that action at this time.
0 commit comments