This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Recipe: formatted text in a drag
html= beside text= gives a drag formatted text, which Notes, Mail, TextEdit, Pages and a browser's editor take where a plain field takes text (LLP 1094.000 D19).
html= beside text= gives a drag formatted text, which Notes, Mail,
TextEdit, Pages and a browser's editor take where a plain field takes
text (LLP 1094.000 D19).
Use this recipe in my app
Paste this into Claude, Cursor, Codex, or another agent.
text
fn place(p: Place): string = `<p style="color: ${cssValue(p.ink)};"><b>${escapeHtml(p.name)}</b></p><div><img src="${escapeHtml(p.photo)}"></div>`
row draggable=true dataTransfer=DataTransfer(text=c.name, html=`<h2>${escapeHtml(c.name)}</h2>${c.places.map(p => place(p)).join("")}`, files=c.places.map(p => p.photo))
•
It is HTML with CSS: headings, paragraphs, quotes, lists, tables,
bold, links, pictures, and style with fonts, sizes, weights, colours,
lines, alignment, indents, spacing and cell borders. The full list is
under draggable in docs/contract-grammar.md; anything else is refused
by name when compiled.
•
Data goes in two ways only: escapeHtml(x) in text and in a quoted
attribute, and cssValue(x) in a style declaration's value, after its
:. A number or a boolean may stand in either. Anything else, a bare
${p.name} among them, is refused when compiled.
•
Say less. A run with no font or colour takes the destination's own.
What you write goes with the drag, as a copy from another app does, and
the destination keeps what it keeps. A role (-exact-label) is the
colour the app shows as the drag begins.
•
Pictures: each picture's src is one of files or of pictures.
With files, each picture is also a file that Photos, Files and a
page's upload take, and Notes takes the pictures without the text.
With pictures, the drag is one item, the text with its pictures
inside: Notes takes both, Ask Siri shows it as a document, and Photos
and Files take nothing.
On Android, when html= is set, a destination that takes plain text (a
search box, a chat field, a plain EditText) gets the words of html,
not text. For the drag above that is the collection's name, then each
place's name, not c.name alone. Android's own apps work this way: a drag
item's plain text is read from its formatted text. Every other platform
gives such a destination text. So write html whose words read well as
plain text, and do not rely on text reaching Android.
tree shows a node's formatted text as text/html "…", in the canonical
form every host gets: each style its longhands in one order, aliases
written as b, i, s and u, runs beside a block in a div of their
own. A test compares it:
contract-test
test "a collection carries its places as formatted text"
clock settle
expect drag "collection" has "text/html" == "<h2>Peaks</h2><p style=\"color: #336699;\"><b>Fuji</b></p><div><img src=\"assets/fuji.jpg\"></div>"
A picture, link, attribute or declaration the runner refuses is left out
and journaled (drag: refused: html: …); markup it cannot read refuses
the formatted text, and the drag carries the rest.
Is this helpful
Last updated December 1, 2026