Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Specs

The specs in `specs/` are the source of truth. Start with `specs/README.md` (reading order, conventions), then `specs/01-architecture.md` (layout, package rules, how the apps are served). App specs: `specs/wonky_write/`, `specs/wonky_sheets/`, `specs/wonky_drive/` and `specs/wonky_slides/` (v2 decisions: `specs/v2-review.md`). Cross-app features: `specs/16-bugs-and-improvements.md` (Bugs & improvements board, M12); the RevLog sync of Sheets and Slides: `specs/17-revlog-sync.md`. Blog submissions from Wonky Write (M14, built): `specs/18-publications-and-submissions.md`; the guide for blog owners is `docs/blog-integration.md`. First-party usage analytics for admins in Wonky Drive (`/drive/analytics`, built): `specs/19-usage-analytics.md`. When implementation reveals a better approach, update the spec in the same change.
The specs in `specs/` are the source of truth. Start with `specs/README.md` (reading order, conventions), then `specs/01-architecture.md` (layout, package rules, how the apps are served). App specs: `specs/wonky_write/`, `specs/wonky_sheets/`, `specs/wonky_drive/` and `specs/wonky_slides/` (v2 decisions: `specs/v2-review.md`). Cross-app features: `specs/16-bugs-and-improvements.md` (Bugs & improvements board, M12); the RevLog sync of Sheets and Slides: `specs/17-revlog-sync.md`. Blog submissions from Wonky Write (M14, built): `specs/18-publications-and-submissions.md`; the guide for blog owners is `docs/blog-integration.md`. Wonky Markdown, Write's second Markdown flavor (the blog's directives: callouts, details, cards, grids, buttons, chips, numbered headings; set per document, publications choose theirs): `specs/wonky_write/11-wonky-markdown.md`. First-party usage analytics for admins in Wonky Drive (`/drive/analytics`, built): `specs/19-usage-analytics.md`. When implementation reveals a better approach, update the spec in the same change.

Key rules from the specs: every user-visible action is a command and every state change is undoable (`specs/08-commands-and-undo.md`); single window, never open new tabs or windows (`specs/03-app-shell-and-navigation.md`); UI is built with `shad` and custom widgets in `wonky_ui` (`specs/02-design-system.md`); everything works in light and dark.

Expand Down
21 changes: 21 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ Spec: `specs/18-publications-and-submissions.md` §13; guide: `docs/blog-integra
- [ ] Moderators who sign up later get access only with the next submit or status change; grant
at sign-up instead.

## Wonky Markdown (Write 11) — open items

Spec: `specs/wonky_write/11-wonky-markdown.md`.

- [ ] Chip icons (`:chip[x]{icon=…}`): kept in the Delta and in Markdown, not drawn in the
editor or the exports (out of scope by decision).
- [ ] App widget tests per §12: container frames and chrome, grid inline editing (Enter,
Backspace, arrows, Tab), link style popover, slash items, menu and toolbar visibility per
flavor; light/dark goldens of the elements in the editor, print preview, PDF and HTML.
- [ ] Submit dialog: a *Switch flavor* action next to the flavor warning (today it points to
*File › Markdown flavor*).
- [ ] AC-WM.1–7 and 9 were walked through in a release build (2026-10-26); still open: the
same with two collaborators (flavor switch seen by both), AC-WM.8 through the UI (a
Wonky publication and a submission), and pasting the blog examples as Markdown (the
agent browser pane can't write the clipboard; covered by the codec tests).
- [ ] YouTube videos: the blog's renderer for `::youtube` (`docs/blog-integration.md`; the
serverpod_website repository); thumbnails instead of a link in PDF, DOCX and ODT
exports; other video sites if needed.
- [ ] Chips inside tinted callouts have little contrast (the chip's gray `@codeBg` pill on a
light tint, editor and PDF); consider a subtle border or a tint-aware chip color.

## RevLog sync — open items

Sheets and Slides sync through RevLog (`specs/17-revlog-sync.md`); the CRDT engine, the sync
Expand Down
23 changes: 22 additions & 1 deletion docs/blog-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Every body has these fields:
| `type` | When | Other fields |
|--------|------|--------------|
| `publication.ping` | You choose *Send test*, or save a new webhook URL | — |
| `submission.submitted` | Every Submit, Resubmit and Submit update | `submission`, `sequence`, `revision`, `fields`, `markdown`, `assets`, `submittedBy` |
| `submission.submitted` | Every Submit, Resubmit and Submit update | `submission`, `sequence`, `revision`, `fields`, `markdown`, `markdownFlavor`, `assets`, `submittedBy` |
| `submission.withdrawn` | The contributor withdraws the story, or moves the document to the trash | `submission`, `reason`: `author` or `trashed` |
| `submission.disconnected` | The contributor disconnects the document from your blog. No more updates will come for this submission | `submission` |
| `comment.created` | Someone replies in the document's thread of your blog's messages (§6.2) | `submission`, `comment` |
Expand Down Expand Up @@ -260,6 +260,7 @@ Ignore types you don't know; new ones may be added.
"note": "Fixed the code samples, thanks!"
},
"markdown": "# How we sped up our CI three times\n\n…\n\n![Build times](https://wonky.work/api/pub/v1/assets/ast_0192a3b4-1111-7000-8000-000000000002)\n",
"markdownFlavor": "gfm",
"assets": [
{
"id": "ast_0192a3b4-1111-7000-8000-000000000002",
Expand Down Expand Up @@ -287,6 +288,26 @@ Ignore types you don't know; new ones may be added.
- Images uploaded to Wonky are WebP (`image/webp`), at most 2048 px on their longest side, with
their metadata (EXIF, including GPS) removed. Older images can keep the type they were
uploaded with, so read the `type` of each asset.
- `markdownFlavor` is `gfm` or `wonky`. A publication set to **Wonky Markdown** (in its settings)
starts new stories as Wonky documents, and their `markdown` can use the Serverpod blog
directives: callouts (`:::warning[Title]` … `:::`), `:::details`, `:::card`,
`:::grid{columns=3 bullets=check}`, `:button[…](…)`, `:link[…](…)`, `:chip[…]` and numbered
headings (`## (1) Title`); see `specs/wonky_write/11-wonky-markdown.md` §4. A `gfm` story
never contains them.
- Wonky stories can also hold **YouTube videos**, a Wonky extension your renderer has to add:
a line `::youtube[Title]{id=AGAQ_N56wCs start=90}` (the title and `start`, in seconds, are
optional; the id is always the 11-character video id). Render it like this, escaping the
title:

```html
<iframe src="https://www.youtube.com/embed/AGAQ_N56wCs?start=90" title="Title"
style="width: 100%; aspect-ratio: 16 / 9; border: 0;"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
```

The pattern is `^::youtube(?:\[([^\]]*)\])?(?:\s*\{([^}]*)\})?\s*$`, with the options read like
the other directives' (`{key=value key=value}`).
- `markdown` is CommonMark with GitHub tables and task lists. Open suggestions in the document are
sent as the original text; comments are never included. There is no front matter: the title
and the other fields are in `fields` (the Markdown usually starts with the title as a heading,
Expand Down
3 changes: 3 additions & 0 deletions packages/wonky_app/lib/l10n/wonky_app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3093,6 +3093,9 @@
"pubTemplate": "Template document (optional)",
"pubTemplateHint": "Paste a link to one of your Wonky Write documents",
"pubTemplateInvalid": "Paste the link of a Wonky Write document.",
"pubMarkdownFlavor": "Markdown flavor of new stories",
"pubMarkdownGfm": "GitHub Markdown",
"pubMarkdownWonky": "Wonky Markdown (Serverpod blog directives)",
"pubRequired": "Required.",
"pubHttpsOnly": "Use an https:// address.",
"pubFieldSummary": "Summary",
Expand Down
3 changes: 3 additions & 0 deletions packages/wonky_app/lib/l10n/wonky_app_en_XA.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,9 @@
"pubTemplate": "[Ţéɱþļåţé ðöçûɱéñţ (öþţîöñåļ) one two th]",
"pubTemplateHint": "[Þåšţé å ļîñķ ţö öñé öƒ ýöûŕ Ŵöñķý Ŵŕîţé ðöçûɱéñţš one two three]",
"pubTemplateInvalid": "[Þåšţé ţĥé ļîñķ öƒ å Ŵöñķý Ŵŕîţé ðöçûɱéñţ. one two thre]",
"pubMarkdownFlavor": "[Ṁåŕķðöŵñ ƒļåṽöŕ öƒ ñéŵ šţöŕîéš one two th]",
"pubMarkdownGfm": "[ĜîţĤûƀ Ṁåŕķðöŵñ one t]",
"pubMarkdownWonky": "[Ŵöñķý Ṁåŕķðöŵñ (Šéŕṽéŕþöð ƀļöĝ ðîŕéçţîṽéš) one two three]",
"pubRequired": "[Ŕéǫûîŕéð. one]",
"pubHttpsOnly": "[Ûšé åñ ĥţţþš:// åððŕéšš. one two]",
"pubFieldSummary": "[Šûɱɱåŕý one]",
Expand Down
8 changes: 8 additions & 0 deletions packages/wonky_app/lib/src/commands/command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ abstract class Command<A extends CommandArgs> {

IconData? get icon => null;

/// The icon of a menu item that invokes the command with [args] (a
/// command with a choice argument can show one icon per choice).
IconData? iconFor(Map<String, Object?> args) => icon;

/// Extra search terms for the palette.
List<String> aliases(BuildContext context) => const [];

Expand Down Expand Up @@ -71,6 +75,10 @@ abstract class Command<A extends CommandArgs> {
/// Whether the command can run now (drives disabled state everywhere).
bool isEnabled(CommandContext ctx, A args) => true;

/// Whether menus, the palette and toolbars show the command at all (Write
/// hides its Wonky Markdown commands in GitHub Markdown documents).
bool isVisible(CommandContext ctx, A args) => true;

/// Tooltip for the disabled state ("You have view access").
String? disabledReason(CommandContext ctx, A args) => null;

Expand Down
7 changes: 7 additions & 0 deletions packages/wonky_app/lib/src/commands/command_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ class CommandState {
required this.enabled,
required this.checked,
required this.disabledReason,
this.visible = true,
});

/// Whether the command is shown ([Command.isVisible]).
final bool visible;

final bool enabled;
final bool? checked;
final String? disabledReason;
Expand Down Expand Up @@ -92,19 +96,22 @@ class CommandDispatcher {
final ctx = _context(InvocationSource.menu, null);
try {
final a = command.parseArgs(args);
final visible = command.isVisible(ctx, a);
final role = roleProblem(command, ctx);
if (role != null) {
return CommandState(
enabled: false,
checked: command.isChecked(ctx, a),
disabledReason: role,
visible: visible,
);
}
final enabled = command.isEnabled(ctx, a);
return CommandState(
enabled: enabled,
checked: command.isChecked(ctx, a),
disabledReason: enabled ? null : command.disabledReason(ctx, a),
visible: visible,
);
} catch (_) {
return const CommandState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class _CommandPaletteBodyState extends State<_CommandPaletteBody> {
final l = WonkyAppLocalizations.of(context);
final commands = [
for (final c in s.registry.all)
if (c.showInPalette) c,
if (c.showInPalette && s.dispatcher.stateOf(c.id.value).visible) c,
];
PaletteRow rowOf(
Command<CommandArgs> c, {
Expand Down
18 changes: 18 additions & 0 deletions packages/wonky_app/lib/src/l10n/wonky_app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8086,6 +8086,24 @@ abstract class WonkyAppLocalizations {
/// **'Paste the link of a Wonky Write document.'**
String get pubTemplateInvalid;

/// No description provided for @pubMarkdownFlavor.
///
/// In en, this message translates to:
/// **'Markdown flavor of new stories'**
String get pubMarkdownFlavor;

/// No description provided for @pubMarkdownGfm.
///
/// In en, this message translates to:
/// **'GitHub Markdown'**
String get pubMarkdownGfm;

/// No description provided for @pubMarkdownWonky.
///
/// In en, this message translates to:
/// **'Wonky Markdown (Serverpod blog directives)'**
String get pubMarkdownWonky;

/// No description provided for @pubRequired.
///
/// In en, this message translates to:
Expand Down
19 changes: 19 additions & 0 deletions packages/wonky_app/lib/src/l10n/wonky_app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4659,6 +4659,15 @@ class WonkyAppLocalizationsEn extends WonkyAppLocalizations {
@override
String get pubTemplateInvalid => 'Paste the link of a Wonky Write document.';

@override
String get pubMarkdownFlavor => 'Markdown flavor of new stories';

@override
String get pubMarkdownGfm => 'GitHub Markdown';

@override
String get pubMarkdownWonky => 'Wonky Markdown (Serverpod blog directives)';

@override
String get pubRequired => 'Required.';

Expand Down Expand Up @@ -9756,6 +9765,16 @@ class WonkyAppLocalizationsEnXa extends WonkyAppLocalizationsEn {
String get pubTemplateInvalid =>
'[Þåšţé ţĥé ļîñķ öƒ å Ŵöñķý Ŵŕîţé ðöçûɱéñţ. one two thre]';

@override
String get pubMarkdownFlavor => '[Ṁåŕķðöŵñ ƒļåṽöŕ öƒ ñéŵ šţöŕîéš one two th]';

@override
String get pubMarkdownGfm => '[ĜîţĤûƀ Ṁåŕķðöŵñ one t]';

@override
String get pubMarkdownWonky =>
'[Ŵöñķý Ṁåŕķðöŵñ (Šéŕṽéŕþöð ƀļöĝ ðîŕéçţîṽéš) one two three]';

@override
String get pubRequired => '[Ŕéǫûîŕéð. one]';

Expand Down
4 changes: 3 additions & 1 deletion packages/wonky_app/lib/src/menus/menu_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class MenuResolver {
return null;
}
final state = services.dispatcher.stateOf(commandId, args);
if (!state.visible) return null;
final title = label ?? command.title(context);
// Drive-scope shortcuts (F2, Del, S…) only apply on the home screen.
final driveOnly =
Expand Down Expand Up @@ -133,7 +134,7 @@ class MenuResolver {
return WonkyMenuItem(
key: k,
label: title,
icon: command.icon,
icon: command.iconFor(args),
shortcut: shortcut,
enabled: state.enabled,
disabledReason: state.disabledReason,
Expand Down Expand Up @@ -165,6 +166,7 @@ class MenuResolver {
return {
'title': c.label ?? command?.title(context) ?? c.commandId,
'enabled': state.enabled,
if (!state.visible) 'hidden': true,
if (state.checked != null) 'checked': state.checked,
if (services.keymap.shortcutTextOf(c.commandId) != null)
'shortcut': services.keymap.shortcutTextOf(c.commandId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ class _PublicationsSectionState extends State<PublicationsSection> {
? null
: l.pubTemplateInvalid,
),
SelectFieldSpec(
id: 'markdownFlavor',
label: l.pubMarkdownFlavor,
options: {'gfm': l.pubMarkdownGfm, 'wonky': l.pubMarkdownWonky},
initial: p?.markdownFlavor == 'wonky' ? 'wonky' : 'gfm',
),
SelectFieldSpec(
id: 'summary',
label: l.pubFieldSummary,
Expand Down Expand Up @@ -218,6 +224,7 @@ class _PublicationsSectionState extends State<PublicationsSection> {
? null
: r.text('termsUrl').trim(),
templateItemUuid: _uuidIn(r.text('template')),
markdownFlavor: r.text('markdownFlavor'),
fields: PublicationFields(
summary: mode('summary'),
tags: mode('tags'),
Expand Down
37 changes: 35 additions & 2 deletions packages/wonky_core/lib/mcp/write_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ abstract final class WriteSchemas {
);
}

/// The Wonky Markdown syntax, for tool descriptions (Write 11 §4, §10).
const _wonkySyntax =
'; in Wonky documents also :::info|tip|note|warning|caution|danger[Title] '
'… :::, :::details (first ### is the summary) … :::, :::card … :::, '
':::grid{columns=3 bullets=check} with "- item" lines … :::, '
':button[Label](url){variant=secondary}, :link[Label](url), '
':chip[Label], "## (1) Title" numbered headings and '
'::youtube[Title]{id=VIDEO_ID start=SECONDS} videos on their own line';

const _addressing =
' Addressing: prefer quote ranges ({"type":"quote","quote":"…"}); '
'offsets are 0-based Delta offsets (UTF-16 code units, embeds count 1, '
Expand Down Expand Up @@ -304,8 +313,10 @@ abstract final class WriteTools {
name: 'write.insert_markdown',
title: 'Insert Markdown',
description:
'Inserts GitHub-flavored Markdown at a position (headings, lists, '
'quotes, code, tables, links, images by URL). as: "auto" (default; a '
'Inserts Markdown at a position (headings, lists, quotes, code, '
'tables, links, images by URL) in the document\'s flavor '
'(markdown_flavor of write.get_document)$_wonkySyntax. as: "auto" '
'(default; a '
'single paragraph inserted mid-line is merged inline, otherwise '
'blocks), "inline" or "blocks". Use it to add new content; use '
'write.replace_range to rewrite existing text.$_addressing',
Expand Down Expand Up @@ -597,6 +608,27 @@ abstract final class WriteTools {
scopes: _edit,
);

static final setMarkdownFlavor = McpToolDefinition(
name: 'write.set_markdown_flavor',
title: 'Set the Markdown flavor',
description:
'Sets the document\'s Markdown flavor: "gfm" (GitHub-flavored, the '
'default) or "wonky" (GFM plus the Serverpod blog directives: '
'callouts, details, cards, grids, buttons, arrow links, chips, '
'numbered headings). Switching to "gfm" converts Wonky elements to '
'their closest GFM form (one change); with convert: false it fails '
'with validation_failed when there is something to convert. Revert '
'with changes.revert.',
inputSchema: WriteSchemas.doc(
{
'flavor': const JsonSchema.string(enumValues: ['gfm', 'wonky']),
'convert': const JsonSchema.boolean(defaultValue: true),
},
required: ['flavor'],
),
scopes: _edit,
);

static final updatePageSetup = McpToolDefinition(
name: 'write.update_page_setup',
title: 'Update the page setup',
Expand Down Expand Up @@ -742,6 +774,7 @@ abstract final class WriteTools {
insertTable,
updateTable,
updatePageSetup,
setMarkdownFlavor,
listSuggestions,
acceptSuggestion,
rejectSuggestion,
Expand Down
Loading
Loading