Skip to the content
v1.0.1-beta.17

Word, EPUB, OpenDocument, Notion and Confluence

Premium add-on. This page covers a premium add-on, included in Scriviamo Pro and Pro + Collaboration. See pricing

Four premium add-ons read and write formats beyond JSON, HTML, Markdown and text. Each loads the library it needs from a CDN the first time it's used, so the add-ons stay small; set its URL to load the library from your own server, or pass a module you've imported to its use().

Add-onDoesLibrary
wordImports and exports Word documents (.docx)docx and mammoth
epubExports EPUB 3 booksfflate
odtExports OpenDocument Text (.odt)fflate
wikiimportImports Notion and Confluence exportsfflate

Each export is also in editor.exporters, as "docx", "epub" and "odt", so editor.exporters.item("docx").exportToFile(editor, "Report") saves one. These exporters make binary files: their exportBlob(editor) resolves to the file, and export(editor) returns "".

Word

The Word tool imports a .docx file, into an empty editor as its document or else where the user is working, and exports the document as one.

import {WordDocuments} from "./dist/addons/scriviamo.word.js"

let blob = await WordDocuments.toBlob(editor, "Report")
await WordDocuments.importFile(editor, file)
let html = await WordDocuments.toHTML(file)   // a document's contents, without importing them

Export walks the document's HTML, so blocks from every add-on come through: headings, paragraphs, bulleted, numbered and checklist lists, quotes, code, tables with merged cells and cell colors, pictures, links, and bold, italic, underline, strikethrough, raised and lowered text, colors and highlights become Word's own. Page breaks become Word page breaks. Blocks Word has no equivalent for, such as players, become their title. Import reads headings, lists, tables, pictures, links and formatting, and Word's Title, Subtitle, Quote and Code styles.

WordDocuments.docxURL and WordDocuments.mammothURL set where the libraries load from.

EPUB

The Export as EPUB tool makes an EPUB 3 book for e-readers.

import {EpubDocuments} from "./dist/addons/scriviamo.epub.js"

let book = await EpubDocuments.toBlob(editor, {title: "Field Guide", author: "Ada Lovelace", language: "en"})

The book has a chapter for each top-level first-level heading, a table of contents, the export stylesheet, and the document's pictures stored in it. Charts, maps' tiles and formulas come through as SVG, pictures and MathML, which EPUB 3 readers show. Players and other embeds, which books can't play, become links. title defaults to the first heading, language to the page's, and identifier to a new UUID; pass an ISBN or a URL to keep it stable between editions.

OpenDocument Text

The Export as OpenDocument Text tool makes an .odt file, which LibreOffice, Google Docs, Word and Pages open. Like Word export, it walks the document's HTML: headings, lists, quotes, code, tables, pictures, links and inline formatting become the format's own.

import {OdtDocuments} from "./dist/addons/scriviamo.odt.js"

let file = await OdtDocuments.toBlob(editor, "Report")

Fonts

The fonts text is in come through as the font's name: on each run of text in Word, in each text style in OpenDocument, and in the stylesheet in EPUB. The document's own font is the file's default.

Web fonts the document uses are also stored in the file, unless they're registered with embed: false:

  • EPUB stores every face, in any format, and its stylesheet uses them.
  • Word stores TrueType and OpenType faces (.ttf and .otf) the way Word does, obfuscated, as the regular, bold, italic and bold italic of the font. WOFF and WOFF2 faces aren't stored, as Word can't read them: register a .ttf alongside them for Word.
  • OpenDocument stores TrueType and OpenType faces, which LibreOffice uses and keeps when it saves the file again.

Fonts that aren't stored are named only; a computer without the font uses another in its place. A file that can't be fetched, such as one on a server that refuses cross-origin requests, is left out the same way.

Notion and Confluence

The Import from Notion or Confluence tool reads an export: a whole one as a .zip, or a single page as Markdown, HTML or CSV. It tells which app the export came from.

  • Notion: export a page or a workspace as "Markdown & CSV" or as "HTML". Pages keep their headings, lists and to-dos, tables, code, quotes, toggles, callouts, links and pictures; a database exported as CSV becomes a table, with all its columns.
  • Confluence: export a space as HTML. Pages keep their headings, lists, task lists, tables, code, expand sections, links and pictures; info, note, tip and warning panels become alerts.

Callouts and panels become alerts when the callouts add-on is loaded, and toggles and expand sections become collapsible sections when the blocks add-on is. An export with several pages becomes one document, each page under its title as a first-level heading. Links between pages of the export, which don't exist outside it, become plain text. Pictures are stored like any added file: through the editor's file uploader, or in the document.

import {WikiImport} from "./dist/addons/scriviamo.wikiimport.js"

let count = await WikiImport.importFile(editor, file)       // how many pages were imported
let pages = await WikiImport.read(editor, file)             // [{title, html, path}], without importing