genesis-editor

Document import

Load a Word, OpenDocument, HTML, Markdown, or text file through the same HTML engine as paste.

Files#

importFile(file) replaces the document. Slash menu Import document (/import) opens a file picker. Headings, lists, tables, images, links, colours, and font sizes go through parseHTML, so re-hosting and the fidelity report still apply.

  • Word (.docx) and Google Docs downloads: unpacked and walked to HTML with inline color and size, then parseHTML. Mammoth (BSD-2-Clause) is the fallback when that walk is empty. Font family is not copied.
  • OpenDocument (.odt): unzipped with fflate (MIT) and mapped to HTML.
  • RTF, HTML, Markdown, plain text where the markup is simple enough to map. Markdown uses marked (MIT), also lazy-loaded.
  • Apple Pages is detected and refused: export as Word and import that. There isn't a reliable permissive converter for .pages.

Google Docs paste (HTML with docs-internal-guid) already uses this engine; a downloaded .docx is the file path.

const editor = useRef<BlockEditorHandle>(null);

const report = await editor.current.importFile(file);
// report.score, report.blocks, report.warnings

Google Drive#

genesis never talks to Google and ships no API keys. If your app already has a picker, pass googleDrive.pickFile and a second slash item appears.

<BlockEditor
  googleDrive={{
    pickFile: async () => myPicker(), // File you already have; genesis does not do OAuth
  }}
  onImportError={(error) => console.warn(error.code, error.message)}
/>
marked, fflate, and mammoth stay out of the initial editor chunk. They load the first time you import a matching file. fflate and marked are MIT; mammoth is BSD-2-Clause.