Repository navigation
InkKit 0.1.0
InkKit 0.1.0 is the first release for apps to adopt: every call and output names its document, every failure is a coded InkKitError, the styling contract uses only inkkit- names, and tables, saving and long notes work better. It breaks the host API and CSS, so read "Moving from 0.0.x" before you update.
For people
- Tables. Tables draw borders, padded cells, a shaded header row and a scroller for wide tables. Controls on the active column and row align, add, delete and move them, by pointer or keyboard.
- Source stays as authored. Setext headings, the indentation of a paragraph's other lines, list and quote items before a split or join, and formatting around an inline comment keep their bytes. A block the parser cannot build opens as literal source, and typing into a literal block saves what you typed.
- Long notes. Enter, Backspace and paste across blocks cost about what typing a character costs. Code blocks over 5,000 characters stay unhighlighted so a note cannot freeze the editor.
- Callouts. Enter and Backspace in a callout work as in a quote.
- Comments. Hidden author comments survive Backspace and Delete beside them.
- Links. Mod-click opens Markdown and wiki links (Command on Apple platforms, Control elsewhere), a click never makes the web view follow a link, and a link keeps the form it was written in when you edit it.
- Paste and input. Text pasted inside a sentence joins the paragraph, pasted HTML imports only what it shows, and multi-character input inserts exactly its text.
- Accessibility. File cards, footnote definitions, author comments and preserved Markdown blocks have roles and names.
For hosts
- Document identity.
DocumentVersion(documentId,generation,revision) is on every output, andchangedreceives a fullDocumentSnapshot. Most calls takeexpectedGenerationand throwstale-documentwhen it is not the loaded one. - One error type. Every failure is an
InkKitErrorwith a code from one closed list. The API reference documents each code, where it arrives and whether to retry. - Settled signatures.
format,keyDown,insertImages,insertPaths,clipboardSnapshotandKeymaphave typed, validated arguments, andformatreports whether it applied. - Styling. Every class InkKit draws and every custom property it reads begins
inkkit-. New tokens are--inkkit-column-insetand--inkkit-surface-focus-width,-colorand-offset. - Files.
FileReference.targetis the reference without its fragment. - Labels.
commentandpreservedMarkdownare new labels. - Dependencies. The package bundles Milkdown, ProseMirror and every other runtime dependency except Mermaid, so a host runs the tree InkKit tested. Mermaid 12.1.0, pinned exactly, is the one runtime dependency.
- Engines. WebKit 17.5, Chromium 123 and Firefox 125 (untested) are the supported engines. Without the Custom Highlight API, the editor now mounts and uses the browser's selection.
Moving from 0.0.x
Each line is a change a host must make. The API reference describes every member named here.
Mounting and events
- Remove unknown names.
mountrejects withinvalid-argumentfor an unknowneventsname, an unknownlabelskey and an unknown option, so delete anything that is not inEditorEvents,EditorLabelsorEditorOptions. stateChangedis gone. Read caret state fromcommandStateChanged(state)asstate.caret; passingstateChangedmakesmountreject.changed(markdown, generation)is nowchanged(snapshot). Readsnapshot.text,snapshot.generationandsnapshot.revision.openLinkandcopyare optional. Withoutcopy, InkKit draws no Copy button, and withoutopenLink, links do not open. Delete stub handlers you added for them.- Your handlers' exceptions go to
reportError(). An exception fromchanged,commandStateChanged,openLink,copyorerrorno longer fails the InkKit call that raised it.
Documents and generations
- Use a greater generation on every load.
loadDocumentandreloadDocumentthrowinvalid-argumentunlessgenerationis greater than the loaded one, and the first load accepts any integer. - Pass
expectedGenerationlast. Replace hand-written generation checks andcommandState(expected)calls with the parameter onreloadDocument,paste,pasteAsPlainText,format,table,insertPaths,insertImages,insertFootnote,navigateFootnote,editReferenceDefinition,clipboardSnapshot,focusandblur. - Replace
.ProseMirrorblur code withblur(expected).
Calls
format('heading', n)isformat('heading' + n). Useheading1toheading6, and readcommands.format.heading1toheading6instead ofcommands.format.heading.formattakes an options object. Useformat('link', { destination })andformat('codeBlock', { language });format('link')without a destination now only removes a link, and the call returns whether it applied.keyDowntakes one object. ChangekeyDown(key, code, meta, ctrl, alt, shift, generation)tokeyDown({ key, code, metaKey, ctrlKey, altKey, shiftKey }, generation).insertImagestakes references and a point. ChangeinsertImages([{ path, alt }], x, y)toinsertImages([{ reference, alt, title? }], { clientX, clientY }?, generation?); it returnsfalseinstead of throwingimage-unavailable, and works with only aFileAdapter.insertPathstakes a point. ChangeinsertPaths(paths, x, y)toinsertPaths(paths, { clientX, clientY }, generation?).clipboardSnapshottakes a scope. ChangeclipboardSnapshot(true)toclipboardSnapshot('document', generation)andclipboardSnapshot(false)toclipboardSnapshot('selection', generation).- Two members are removed. Use
pasteAsPlainText(text, generation)instead ofpaste({ text, plainText: true }), andtextRangesRects([range])[0]instead oftextRangeRects(range). - Type keymaps as
Keymap. An unknown shortcut name now throwsinvalid-argumentinsetKeymapandEditorOptions.keymap.
Errors
- Branch on
error.codeonly. There is oneInkKitErrorwith a closed list of codes; stop matching messages or classes, and treat any code exceptdestroyedandinternalas an editor that still works. - A refused facade edit throws.
insertText,pasteAsPlainText,format,table,replaceTextRangeandpastethrow or reject withpreservationand no longer also callevents.error; edits the person makes still arrive there. - Replace
RangeErrorandTypeErrorhandling withinvalid-argument. Four codes are new:invalid-argument,file-unavailable,clipboard-unavailableandinternal. - Match file and clipboard failures by code. File and wiki-link failures are
file-unavailable, and a copy withoutevents.clipboardor a rejected handler isclipboard-unavailable. clipboardSnapshot()sends no error events for degraded output. Readimages[].erroranddiagrams[].error.- Drop
?? undefinedshims.nullcounts as omitted for an optional argument. - A failed call changes nothing and sends nothing. The
changedandcommandStateChangedevents a successful call raises arrive when it returns.
Files and links
- Read
FileReference.target. Stop slicing the fragment offreferenceyourself, and settargeton anyFileReferenceyour tests build. - Delete your
metaclass code. InkKit tracks Mod itself and no longer reads ametaclass on an ancestor; do not open links on Control-click yourself. - Expect fewer openable links. Only relative, fragment, query,
http,https,mailtoandteladdresses render and open, softp:no longer does, andopenLinkis never called with an empty address.
CSS
- Rename seven classes.
.copy,.empty,.image,.image-handle,.image-absent,.literal-markdownand.hljs-*are now.inkkit-copy,.inkkit-empty,.inkkit-image,.inkkit-image-handle,.inkkit-image-absent,.inkkit-literal-markdownand.inkkit-hljs-*. - Rename the custom properties.
--accent,--text,--muted,--rule,--code-bg,--monoand--reading-widthare now--inkkit-accent-color,--inkkit-text-color,--inkkit-muted-color,--inkkit-rule-color,--inkkit-code-background,--inkkit-monospace-fontand--inkkit-reading-width, and the old names are no longer read. - Set
--inkkit-column-insetinstead of overriding.ProseMirrorpadding. Delete host rules that restyle.ProseMirror, the renamed classes or.hljs-*, and check host table rules, because tables now draw their own borders and padding.
Verification
2,187 unit tests, 378 Chromium and 375 WebKit browser tests, and clean packed and registry consumers in Chromium and WebKit passed on the release commit. The native WKWebView runner was not run on this release, and browser WebKit does not prove WKWebView behavior, so check your bridge when you adopt it. Synthetic composition tests do not establish every operating-system input method.