@nextgensoftwares/folio-plugin-import
Import UI and applying imports to an editor. Guide: Import. @nextgensoftwares/folio-plugin-import/apply has the non-React part only.
Plugin
| Export | Description |
|---|---|
importPlugin(options) | toolbar items import.open ("Open file…") and import.insert ("Import…": a new document, the end or the caret, per placement) in group file, the overlay dialog, the drop hook |
type ImportPluginOptions | importers, openDocument?(prepared, { name, result }), placement? (value or getter), applyOptions?(editor), attach?(editor, files, at), drop?, limits?, importOptions?, schema? (e.g. docxImportSchema), toolbar?, onImported? |
type ImportPlacement | where "Import…" puts the file: new-document (default; end without openDocument), end (after the last block), caret |
type ImportPlugin | FolioPlugin plus controller, pick(editor, mode), importFile(editor, file, mode), placement() (the placement in effect) |
ImportController | the flow as a store: state, busy, subscribe, run(editor, file, mode), ask(editor, files, at), choose('open' | 'insert' | 'attach'), cancel(), dismiss() |
type ImportState, type ImportPhase, type ImportMode | idle, choose, reading, converting, applying, done, error, cancelled; progress (0..1) and stage while busy; mode open | insert | append. While busy, run also publishes each step to the export progress hub (runExport), so <FolioView>'s progress dialog shows the import and its Cancel aborts it |
createImportOverlay(controller) | the dialog component (for hosts rendering their own overlay) |
importable(file, importers), filesFrom(dataTransfer), pickFile(accept), type DropPoint | helpers |
Applying
| Export | Description |
|---|---|
applyImport(editor, result, options) | stores assets, fits to the schema, replaces, inserts or appends as one undo step (progressive), applies theme, comments, meta |
type ApplyImportOptions | mode (replace | insert | append), theme?, setTheme?, upload?, comments? ({ store, actor } or a callback), setMeta?, applyPage?, adoptTheme?, adoptFonts?, adoptTextSize?, signal?, onProgress?(fraction, stage?) ("Storing images 3/12", "Adding to the document"), batchMs? |
type ApplyImportReport | warnings, meta, blocks |
prepareImport(result, options), type PrepareOptions, type PreparedImport | the same without an editor: doc, theme, comments, meta, warnings |
mergedTheme(result, theme, options?) | the host theme with the import's page setup and hints |
storeAssets(content, assets, options) | upload (or inline) assets and rewrite refs |
importComments(threads, store, actor) | creates threads, replies and resolution in a comment store, each with the file's author and date as origin |
type CommentStoreLike, type CommentActorLike, type CommentOpLike, type CommentAnchorLike, type CommentOriginLike | structural types matching @nextgensoftwares/folio-plugin-comments |
assetUploaderFrom(uploader), type MediaUploaderLike | plugin-media uploaders as an AssetUploader |