Files
writingkit/dist/react/ArticleComposer.d.ts
CatoandClaude Opus 5.5 0f3f481a3b feat: charts in articles and suggestions the writer accepts or rejects (0.3.0) (#14)
* feat: charts in articles and suggestions the writer accepts or rejects (0.3.0)

- ```chart blocks (JSON or CSV spec): parseChartBlock, splitChartBlocks,
  table fallbacks for RSS/share cards (chartsToTables), chartValuesNotInText
  so a proposed chart draws only the writer's own numbers
- @bitbaum/writingkit/react/chart: ArticleChart / ArticleChartBlock drawn by
  @bitbaum/chartkit (new optional peer)
- Suggestion, applySuggestion (refuses stale text), wordDiff, SuggestionCard
- suggestMedia: a chart beside the paragraph with figures, else an illustration
- ArticleComposer: renderChart in Preview; draft-from-brief is a suggestion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmvT2nQyPBK4EfWf3Rn

* feat(chart): read bip-kit's series-line format too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmvT2nQyPBK4EfWf3Rn

* fix(suggestions): show a rewrite whole; keep Publish the one primary action

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmvT2nQyPBK4EfWf3Rn

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-15 02:26:30 +01:00

98 lines
4.4 KiB
TypeScript

import { type ReactNode } from "react";
import { type ComposerVoice } from "@bitbaum/chatkit/react";
import { type DraftStorage } from "../drafts.js";
import { type AssistMode } from "../assist.js";
import { type ComposerLabels } from "./labels.js";
import { type ArticleChart } from "../chart.js";
export type ArticleStatus = "published" | "draft";
export interface ArticleContent {
title: string;
body: string;
}
export interface AssistRequest extends ArticleContent {
mode: AssistMode;
instruction: string;
}
/**
* What the app owns. The composer owns the writing; the app owns the account,
* the database and the model call.
*/
export interface ArticleTransport {
/**
* Writing help: resolve with the new `{ title, body }`; throw (or resolve
* `null`) when it could not be done. Omit and no writing help is offered.
*/
assist?: (request: AssistRequest) => Promise<ArticleContent | null>;
/**
* Store the article. Resolve with `{ problems }` to show what is wrong; throw
* for a network failure. On success navigate away yourself — the composer
* clears the local draft and stops.
*/
publish: (status: ArticleStatus, content: ArticleContent) => Promise<{
problems?: string[];
} | void>;
}
/** A photo the app found; the composer turns it into a figure with its credit. */
export interface PhotoPick {
alt: string;
src: string;
caption?: string;
credit?: string;
license?: string;
}
export interface ArticleComposerProps {
transport: ArticleTransport;
/** Text to start from (editing). A restored local draft only fills what is empty. */
initial?: Partial<ArticleContent>;
/** Where this draft is kept on the device. One per account and article. */
draftKey: string;
/** The key used before signing in; its draft moves to `draftKey`. */
anonymousDraftKey?: string;
storage?: DraftStorage;
/** `false`: a signed-out writer can write and keep a draft, and is shown the way to sign in. */
signedIn: boolean;
signInHref?: string;
/** The name readers will see, for the note under the buttons. */
authorName?: string;
/** Extra condition for publishing (a byline that must be chosen first). */
canPublish?: boolean;
/** The first publish of an edited, already-published article reads "Save changes". */
editingPublished?: boolean;
/** The microphone. `{ transcribeUrl }` for the server leg; `false` hides it. */
voice?: ComposerVoice | false;
/** The app's photo finder, rendered inside the Photo panel; call `pick` with the choice. */
photos?: (pick: (photo: PhotoPick) => void) => ReactNode;
/** Above the title: what is being written about, a headline to pick, the article being answered. */
above?: ReactNode;
/** Between the text and the buttons: the byline field. */
below?: ReactNode;
/** Extra equal cells beside "Save as draft" (Cancel). */
extraActions?: ReactNode;
/** The body's text area, for an app that puts the caret there (a headline's "Write about it"). */
bodyRef?: React.MutableRefObject<HTMLTextAreaElement | null>;
/** How the preview draws Markdown. Default: chatkit's `Markdown`. */
renderPreview?: (markdown: string) => ReactNode;
/**
* How the preview draws a ` ```chart ` block. Pass
* `chart => <ArticleChart chart={chart} />` from
* `@bitbaum/writingkit/react/chart`; left out, the numbers show as a table.
*/
renderChart?: (chart: ArticleChart) => ReactNode;
/** Formats the time of a restored draft for the person. */
formatTime?: (iso: string) => string;
limits?: {
title: number;
body: number;
};
labels?: Partial<ComposerLabels>;
}
/**
* One place to write, the same in every product: a title and a text that both
* have the microphone and writing help, a speak-to-write panel, photos and
* charts, a preview, a draft that survives sign-in, and a publish bar with one
* primary action. Built from chatkit's `DictationField`, so it is also the
* same microphone as in every chat. Apps pass transports and context, never a
* second composer.
*/
export declare function ArticleComposer({ transport, initial, draftKey, anonymousDraftKey, storage, signedIn, signInHref, authorName, canPublish, editingPublished, voice, photos, above, below, extraActions, bodyRef: externalBodyRef, renderPreview, renderChart, formatTime, limits, labels: overrides, }: ArticleComposerProps): import("react").JSX.Element;