Skip to content

Plugin SDK v0.1.3

Latest

Choose a tag to compare

@SugarFatFree SugarFatFree released this 11 Sep 06:54
· 4 commits to main since this release

Added

  • as = "web" — a plugin can draw its own HTML page. ui.webview had been
    declared, described to the reader, listed here in twelve languages and given a
    proxy of its own, and there was no way for a plugin to open a page. There is
    now: a pane whose text is an HTML document, drawn by the operating system's
    web engine rather than a browser packaged with the editor, and created only
    when a plugin asks so a reader who never opens one never pays for an engine.
    Where the page goes is written to the plugin log. Windows and macOS have an
    engine the editor can use; a Linux box without one gets a line saying so,
    naming the plugin, rather than an empty pane.

    Declaring ui.webview now carries ui.sidebar as well as network.request:
    a page arrives as a pane, and taking room beside the document is not something
    to get for free alongside the engine.

  • What a panel is asked on a second round. A command run from a panel can
    now be run again, with the reader asking for its answer to be changed rather
    than describing the whole thing afresh. The editor says so in fields the
    script already knows: ctx.selection is the script's own last answer,
    because a follow-up is about the draft in front of the reader rather than
    the document, and ctx.answer is what was asked for this time.

    A command that reads the selection as "the part to work on" needs no change.
    One that ignores ctx.selection will rewrite the whole document every
    round, which is not what was asked. The box is only offered when the command
    asked something to begin with, since that is where a follow-up arrives.

  • sdk.ui — a plugin can draw its own interface. It returns a tree of
    nodes (text, input, chips, button, row, column, spacer) and the
    editor renders them as its own widgets; pressing a button calls
    on_event(ctx, id, values) with every input in the tree by id, so a plugin
    never has to remember the form it drew a step ago.

    Not HTML, and deliberately: these are the editor's own widgets, so they cost
    nothing at startup, follow the reader's theme without the plugin knowing what
    the theme is, and cannot draw outside the container they were given. A
    WebView escape hatch is planned separately for what this cannot express.

    A misspelled node refuses the whole tree with an error rather than quietly
    drawing nothing, and so does a tree deeper than 12 or larger than 500 nodes —
    half a form is worse than none.

  • Three more nodes: select (a dropdown, for when there are too many options
    for chips), checkbox (its value arrives as "true" or "false", because
    everything a plugin is told is a string), and markdown — drawn by the
    editor's own renderer, so an answer that is a document looks like one
    instead of showing its own ## and **.

  • An image node. source is a data: URI, a path inside your own plugin
    directory, or an http(s) URL — and that last one is fetched by the
    editor
    , so it follows the reader's system proxy and lands in your plugin's
    log with the host, status, size and time. You may reach the network; the
    reader may find out where you went. A permission nobody can check up on
    afterwards is a promise rather than a permission.

  • ui.webview joins the permission list, and carries network.request with
    it
    — the reader is shown both, because a permission list that understates
    what it grants is worse than none. The web view itself lands in a later
    release; the permission and the logging are here first.

Nothing here changes how a plugin behaves. One of them changes what the
documentation tells you to do, which for someone starting a plugin is the
same thing.

  • The safety rules now state the limits an installed ZIP has to fit: 64 MB for
    the archive, 10000 entries, 256 MB unpacked. They were added to the editor
    today (a ZIP was free to claim it unpacked to gigabytes, and to mean it), and
    an author who packages three platforms' executables should hear the number
    from here rather than from a failed install.

  • The icon names a panel may use are in the schema. It asked only for a
    non-empty string, so the forty names the editor can draw were something to
    guess at — and a name it does not know draws a generic plugin square with
    nothing said, which reads as the editor ignoring your icon rather than as a
    typo. An editor writing your manifest now completes them and refuses the
    rest.

  • Where to look when a plugin installs and does not appear. The editor
    lists a plugin whose manifest it could not read below the ones that loaded,
    with the key it could not read and what it expected there, and a delete
    button on that row. "Trying a plugin before you ship it" only covered trying
    one before shipping; it now covers the case where it is installed and
    invisible, with the three reasons that account for most of it.

Fixed

  • The API module still listed seven kinds of interface node; there are
    eleven.
    select, checkbox, markdown and image were added to the
    editor and written into the README's table, and the one-line list inside both
    API modules stayed where it was. That list is what an author reads in an
    editor's hover, which is where "what can I put in a tree?" is actually asked
    — and a tree is refused whole over one unknown node, so not knowing a kind
    exists costs a whole interface rather than one node.

    scripts/check.py now holds the two modules to the README's table, and the
    editor's own test suite holds that table to the nodes it draws. Between them
    a kind cannot be added in one place and missed in the other two.

  • Five rows of the permissions table promised things the editor has never
    built.
    "add a toolbar button", "add a status-bar item", "add commands to
    the palette", the clipboard and the workspace: seven permissions in all, and
    behind each of them nothing. There is no toolbar or status bar a plugin can
    add to, nothing registers a plugin's commands in the palette, and neither
    script runtime mentions a clipboard or a workspace anywhere. An author who
    read a row, declared the permission, wrote the manifest entry and saw nothing
    happen had lost an evening to a sentence.

    They are marked † now, in all twelve languages, with a note under the table
    saying what the dagger means: the permission is real and the reader is shown
    it, and there is nothing behind it yet. The rows stay, because they are part
    of the manifest and will be honoured when the capability arrives. The
    editor's own test suite decides which rows carry the dagger — the day one of
    these is implemented, the dagger has to come out or that test fails.

  • The examples said they showed all of it, and showed seven of twelve.
    "Every capability the editor offers is used once" opened both scripts, and
    the five they leave out include pane — the grid the editor lays results out
    in, the one that takes a slot, a way of drawing and an Apply button, and the
    one the shipped AI plugin lives in. An example is the first thing an author
    copies, so a claim on top of it is read as a map of the API. They now say
    which seven, point at the actions table for the rest, and name pane as the
    one to read next; scripts/check.py counts both numbers and fails when
    either drifts.

  • Nothing compared the eleven translated actions tables with the English
    one.
    An eleventh action added to the English table would have left the
    other eleven at ten, and an author reading in their own language would never
    have learned it existed. Compared by the action name rather than the whole
    cell, since the metavariables inside it — <node> and the ellipses — are
    English words and are translated on purpose.

  • nothing() had lost its comment to ui(). When ui was added between
    replace and nothing, the one-line description stayed where it was — so
    Do nothing. ended up on top of the interface-drawing documentation, and the
    function that does nothing said nothing at all. In both languages, because
    they were edited together. Nobody reads this module top to bottom; it is read
    one function at a time in an editor's hover, where a comment one function out
    describes the wrong thing with the same authority as a right one.

    scripts/check.py now requires every exported name to have a doc comment
    immediately above it, in both languages, so the next insertion cannot take
    one with it.

  • The English README said there is no require, five paragraphs after
    explaining how to use it.
    The sandbox list — "no os, no package, no
    require, no dofile, no loadfile" — was written before a plugin could be
    more than one file. Lua's own require is indeed removed; the editor then
    installs one that cannot leave the plugin's own directory, which is what
    loads lib/marktext-plus.lua. So the document told an author their require
    would fail while shipping a library file that needs it. All eleven
    translations had been corrected and the English had not, which is the
    opposite of the usual direction.

  • ctx.view was documented in seven languages and missing from five.
    A script is told whether the reader is in source, preview or split;
    English, German, Japanese, Korean and Chinese never said so. The same four
    translations once lost the side panel.

    Both were found by comparing the backticked identifiers across the twelve —
    the one part of a document in eleven languages that does not change with the
    language. The editor's sdk_schema_agrees_test now holds all twelve to the
    same set of 108, with no exceptions.

  • All twelve READMEs still described the rule the editor stopped following.
    A lone pane used to sit beside the document whatever slot it claimed — "one
    pane is one pane whichever slot it claimed" — and since 2026-09-07 the name
    decides: only bottom puts it under the document, any other slot beside it.
    The editor was changed after manual testing, its own layout test was changed
    with it, and the SDK was not. An author filling only bottom was told they
    would get a pane beside the document and got one below it, while the official
    writing and proofreading commands were already relying on the new behaviour.

    The direction sentence is now in all twelve, and the editor's
    sdk_schema_agrees_test counts bottom in that paragraph: it is named once
    as a slot and a second time saying which way that slot goes, so a language
    that keeps only the list fails. The identifier does not translate, which is
    what makes the count work in eleven languages the guard cannot read.

  • The German, Japanese, Korean and Chinese docs had no panels in them at
    all
    — no line in the manifest field list, neither paragraph explaining
    what a panel is. Anyone reading those four did not know a plugin could put
    anything in the right side bar. Eight of twelve described one more
    capability than the rest, and the guard comparing the translations counts
    headings and fenced blocks, which that section has neither of.

  • A panel asks in its own drawer now, and the docs said otherwise. They
    said a command returning ask is reported there as text "because a drawer is
    not a conversation". The question goes in the drawer — its text, the
    choices you named, a box holding last time's answer — and the reply comes
    back to the same drawer. A command started from a menu still asks in the
    floating card, having no room of its own.

  • return on its own inside a nested function does nothing in the editor's
    Lua.
    if not ok then return end continues into the failure it was
    checking for, and while true do return end is an infinite loop. Write
    return nil. Every guard an experienced Lua programmer writes by reflex is
    the shape that does not work here.

  • The safety rules promised a protection that does not exist. "Keep work
    bounded; the editor enforces timeouts and step limits" — it does not, for
    Lua or JavaScript. Both run on the editor's own thread, synchronously, with
    no interrupt available: lua_dardo exposes no debug hook and flutter_js
    does not surface QuickJS's interrupt handler. A loop with no exit freezes
    the window until the process is killed. Only compiled plugins are timed out,
    because only they are a separate process. The rule now says that, in all
    twelve languages.

  • The same paragraph that argues for compiled plugins being a separate process
    listed "a loop with no exit freezes the window" among the things native code
    costs you — and called scripts safe "because both are interpreted". The
    interpreting boundary is real and it catches errors; it does nothing about a
    script that never returns. That sentence has been corrected rather than
    removed: knowing which half of the boundary holds is the point of the
    paragraph.

  • The README and all eleven translations pointed at examples/, a directory
    renamed to packages/ before 0.1.2, and taught a tool/run-js-plugin.mjs
    that was deleted at the same time. Both had been corrected; the 0.1.2 release
    commit rewrote those twelve files from an older copy and put them back, so
    0.1.2 shipped telling a new plugin author to open a directory that is not
    there. The check below now refuses any documented path this repository does
    not have.

Internal

  • The repository checks itself on every push: that the Lua and JavaScript
    modules expose the same names, that the published schema is a valid JSON
    Schema, and that each example manifest satisfies it. All three were true
    and none of them was enforced — a plugin written in one language and ported
    to the other would have been the first to find out otherwise.
    scripts/check.py runs the same checks locally, with no arguments.
  • It also refuses a README, in any language, that names a path this repository
    does not have.