Skip to content

Inkkit 0.4.0

Choose a tag to compare

@aicayzer aicayzer released this 29 Oct 04:17
· 7 commits to main since this release
f6ade87

Inkkit 0.4.0

Inkkit opens, edits and saves RTF documents, beside Markdown and plain text. RTF is a new document format, so this release raises the minor version. See #415 and RTF documents.

The host converts RTF with Apple's text system, using the new InkKitRTF Swift package in this repository, and gives Inkkit a JSON RichTextDocument. A host offers RTF through the formats mount option. It loads RTF with { format: 'rtf', document } and saves the document that snapshot() returns. Apps add the package with .package(url: "https://github.com/aicayzer/inkkit", exact: "0.4.0"). The npm package doesn't include it.

What an RTF document keeps

An RTF document keeps paragraphs with their alignment, nested bulleted and numbered lists, tables and line breaks. It also keeps bold, italic, underline, strikethrough, superscript, subscript, code and links. Fonts, sizes and colors are replaced by Inkkit's style, so the first save after an edit rewrites the file in that style. Saving an unedited document doesn't change it.

RTF documents have no headings. Apple's reader never reports a heading level, so a heading wouldn't survive a reopen.

The converter refuses content it can't keep instead of dropping it: pictures and attachments, headers and footers, footnotes, comments, equations, merged or nested table cells, very large tables and data that isn't RTF. RTFConversionError names the reason.

New in the editor

  • The format commands alignLeft, alignCenter, alignRight and alignJustify, available in RTF documents.
  • convertDocument(format, generation), which converts the loaded document between Markdown and RTF. It reports what didn't carry over as FormatLoss codes, and the host loads the result.
  • The label richTextEditor.

Upgrading from 0.3

DocumentFormat now includes rtf. Code that only loads Markdown and TXT compiles unchanged, except where a load's format is typed as DocumentFormat: use TextDocumentFormat there. A Record<DocumentFormat, …> needs an rtf key. FormatCommand and CommandState.commands.format gain the four alignment commands. The editor reference describes the generic InkKitEditor<F>.

Fixes

  • Formatting that opened with a link no longer writes the link and the text after it twice. For example, ~~[x](u)b~~ was written as ~~[x](u)b[x](u)b~~. This affected Markdown copies and edits.

Hosts update the package, rebuild their offline page and regenerate their license notices as usual.