Skip to content

feat(code): add comark-code, copy and wrap buttons on code blocks and actions of your own - #46

Merged
vitehub-bot[bot] merged 7 commits into
mainfrom
feat/code
Oct 21, 2026
Merged

vitehub-bot[bot] merged 7 commits into
mainfrom
feat/code

Conversation

@onmax

@onmax onmax commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #47 (docs restructure); merge that first, and this PR's base switches to main.

Adds comark-code, a new package that puts Copy and Wrap buttons on every code block, like T3 Code's code blocks, plus buttons of your own, such as Run, that hand the block's code to the host app. It has renderers for HTML, Vue, React, and Svelte that output the same markup, an inlined script with start()/stop(), style.css, docs at /code/, and e2e tests.

const render = createHtmlRenderer({
  plugins: [code({ actions: [{ id: "run", label: "Run", languages: ["sh", "bash"] }] })],
  components,
});

document.addEventListener("comark-code-action", (event) => {
  const { action, code, language } = event.detail; // typed
  if (action === "run") terminal.run(code);
});

What it does

  • Components replace pre. Each one wraps the block, rendered as it would be without the plugin, in <div class="ck"> with a .ck-bar of buttons. Shiki's classes and the host's pre styles still apply. The wrapper has no padding or border, so the block's margins collapse through it and the bar sits in the block's top right corner.
  • Why not a parse-time wrapper node. Plugins run in the order they're listed, and comark-tabs looks for pre children in ::code-group. Wrapping at parse time would break code groups whenever code() came before tabs(). Overriding pre in the renderers works in either order (tested both).
  • The parse plugin only handles actions. It writes actions: [{ id, label }] onto pre nodes whose language matches. Copy and Wrap need only the components. The HTML renderer removes actions from both the node and state.renderData.props before calling Comark's default handler, since in HTML mode that handler writes the resolved props.
  • One markup string. buttons() in client.ts builds the inside of the bar from escaped text, and every renderer inlines it (innerHTML, dangerouslySetInnerHTML, {@html}), so the four can't drift apart.
  • Copy writes code.textContent, shows a check, and announces "Copied" through a role="status". Without clipboard access (plain http, a frame that isn't allowed it), it selects the code and says to press Ctrl+C or ⌘C.
  • Wrap toggles data-code-wrap and aria-pressed on one block, and isn't saved. Its rule sits outside the comark layer, because pages set white-space on code blocks with plain rules.
  • Actions dispatch a bubbling comark-code-action CustomEvent with { action, code, language }. HTMLElementEventMap, DocumentEventMap, and WindowEventMap are augmented, so event.detail is typed. The plugin never runs anything itself.
  • Without JS the bar is hidden. With JS it shows on hover and :focus-within, and always on touch screens.

Other changes

  • comark-tabs: the rule that joins a code group's block to its header now also matches .ct-panel>.ck>pre. The e2e test checks that the block still meets the header with square top corners.
  • comark-lint: loads comark-code/html as an optional peer dependency, like the others.
  • Docs: stacked on docs: group the site into guides, recipes, and package pages #47, so /code/ follows the new structure. It sits under Page behavior and links the shared guides instead of repeating them. Code also gets a row in the Renderers guide, its .ck root in Theming, and a mention in Validation (it has nothing to report). The site renders its code blocks with the plugin, so its hand-rolled copy script and .copy styles are gone. I removed the forced pre-wrap on txt blocks too, because with it the Wrap button did nothing there.
  • Before release: comark-code needs a trusted publisher on npmjs.com (workflow release.yaml, environment npm) before its first release.

Checks

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ d1b6191 2026-10-21T10:34:57.099Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 1922ee4 2026-10-21T10:25:24.547Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 3b9b3dc 2026-10-21T10:18:31.095Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 826de74 2026-10-21T09:20:40.099Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ ddde964 2026-10-21T08:39:20.420Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ b799d72 2026-10-21T05:46:25.291Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ da8fded 2026-10-21T05:20:30.022Z Visit the dashboard ↗

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-annotate@46

comark-carousel

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-carousel@46

comark-charts

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-charts@46

comark-code

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-code@46

comark-embed

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-embed@46

comark-github-callouts

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-github-callouts@46

comark-include

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-include@46

comark-lint

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-lint@46

comark-tabs

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-tabs@46

comark-zoom

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-zoom@46

commit: d1b6191

@vitehub-bot

vitehub-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Waiting for GitHub merge request c6dd82dd-fb6f-4abc-ba51-0d6cb321f9f5.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

Session

Restored the docs index card-copy and window-tab runtime handlers, which caused the three reported e2e failures, and fixed the docs stylesheet formatting issue. Pushed the single repair commit; current-head checks are pending. Local validation was limited by the host pnpm SQLite store error.

onmax added 2 commits October 21, 2026 07:43
Shared guides for renderers, theming, validation, and agents replace the
sections each package page copied. Recipes show annotate with zoom groups,
carousels, and a whole review document. The sidebar groups every page, and
a package's For agents button installs only its own skill.
@onmax
onmax changed the base branch from main to docs/restructure October 21, 2026 05:46

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • New code-block package — Reviewed the parse plugin, shared browser runtime, CSS, HTML/Vue/React/Svelte renderers, package exports, and public documentation for Copy, Wrap, and custom action buttons.
  • Renderer and lifecycle integration — Traced the HTML pre handler against Comark's renderer state semantics and checked the framework component cleanup/reference-counting behavior.
  • Code-group and workspace integration — Reviewed the tabs CSS adjustment, optional lint loading, package build configuration, tests, and lockfile changes.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Documentation restructure integration — Reviewed the new /code/ links and Page behavior grouping, the shared Renderers, Theming, and Validation guide updates, and the docs build's updated TOC selector.
  • Feature documentation consistency — Confirmed the incremental edits preserve the package's documented renderer imports, shared styling guidance, and validation behavior without changing runtime code.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@vitehub-bot
vitehub-bot Bot changed the base branch from docs/restructure to main October 21, 2026 07:52

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The merge-resolution commit removes comark-charts from the generated Agent Skills discovery indexes, so the existing charts skill is no longer discoverable from the deployed docs site.

Reviewed changes

  • Resolved the stacked docs merge — Reviewed the new ddde964 changes to the docs builder, page navigation, chart/code documentation integration, and workspace configuration.
  • Preserved code package behavior — Rechecked the comark-code renderer, runtime, action metadata, tabs integration, and framework/package exports in the full PR context.
  • Validated prior review state — Confirmed the earlier Pullfrog reviews have no open threads requiring retirement.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

Comment thread docs/build.ts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Restored charts skill discovery — Rechecked the new docs build output path and confirmed the charts skill is copied alongside annotate and included in both Agent Skills discovery manifests.
  • Revalidated the incremental delta — Reviewed the docs build restructuring, code documentation updates, and dependency ordering in the full PR context; no additional behavioral regressions were found.
  • Retired the prior concern — Confirmed the issue reported against ddde964 is addressed by 826de74.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Resolved merge conflicts — Rechecked the latest 3b9b3dc delta: the root Doctor config now has one components declaration, comark-tabs parser-only blocks are recognized by comark-lint, and code-group CSS still joins .ck-wrapped code blocks to their headers.
  • Preserved prior fixes — Confirmed the restored annotate and charts Agent Skills discovery remains present in the current full diff and was not regressed by the latest merge-resolution changes.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Restored docs interactions — Rechecked the package-card copy buttons, installer behavior, and the index window's tab and reduced-motion interactions after the merge-resolution commits.
  • Removed obsolete docs copy UI — Confirmed the old hand-rolled pre copy selector and related styles were removed without affecting the new comark-code controls.
  • Preserved prior fixes — Revalidated the charts skill discovery restoration and the existing code-package, tabs, and framework integration in the current full diff.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Restored docs interactions — Rechecked the new commit's restoration of package-card copy handlers and the index window tab, keyboard, indicator, and typing transitions, plus the removal of obsolete generic code-copy styling.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@vitehub-bot
vitehub-bot Bot merged commit fb7d815 into main Oct 21, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant