@particle-academy/react-fancy 5.66.0 → 5.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/dist/ContentRenderer.types-RO_l7_6N.d.cts +137 -0
- package/dist/ContentRenderer.types-RO_l7_6N.d.ts +137 -0
- package/dist/button.cjs +3 -4
- package/dist/button.js +1 -2
- package/dist/{chunk-J44EV6SP.js → chunk-23AVEYUP.js} +3 -3
- package/dist/{chunk-J44EV6SP.js.map → chunk-23AVEYUP.js.map} +1 -1
- package/dist/{chunk-L24LUSEE.js → chunk-2LQR4EAN.js} +553 -35
- package/dist/chunk-2LQR4EAN.js.map +1 -0
- package/dist/{chunk-C5YX5XVL.cjs → chunk-3U7PUZLI.cjs} +214 -4
- package/dist/chunk-3U7PUZLI.cjs.map +1 -0
- package/dist/{chunk-MCQJFMDP.cjs → chunk-464QSZ4A.cjs} +553 -35
- package/dist/chunk-464QSZ4A.cjs.map +1 -0
- package/dist/{chunk-QP35Z2WB.js → chunk-BL5IKSB3.js} +3 -3
- package/dist/{chunk-QP35Z2WB.js.map → chunk-BL5IKSB3.js.map} +1 -1
- package/dist/{chunk-4EUDW2WU.js → chunk-DCAD2JPP.js} +3 -3
- package/dist/{chunk-4EUDW2WU.js.map → chunk-DCAD2JPP.js.map} +1 -1
- package/dist/{chunk-ATIDUWY6.cjs → chunk-E4DXICU3.cjs} +19 -13
- package/dist/chunk-E4DXICU3.cjs.map +1 -0
- package/dist/{chunk-TLRRMYNV.js → chunk-OXERDFFF.js} +212 -4
- package/dist/chunk-OXERDFFF.js.map +1 -0
- package/dist/{chunk-SYEHWUM5.cjs → chunk-RALJMI7C.cjs} +4 -4
- package/dist/{chunk-SYEHWUM5.cjs.map → chunk-RALJMI7C.cjs.map} +1 -1
- package/dist/{chunk-UM4JXBRZ.cjs → chunk-S3NB6LDV.cjs} +4 -4
- package/dist/{chunk-UM4JXBRZ.cjs.map → chunk-S3NB6LDV.cjs.map} +1 -1
- package/dist/{chunk-MCQWTOTV.cjs → chunk-SAG6DHQK.cjs} +6 -6
- package/dist/{chunk-MCQWTOTV.cjs.map → chunk-SAG6DHQK.cjs.map} +1 -1
- package/dist/{chunk-CAUEKGMR.js → chunk-TQ77ZWBD.js} +11 -5
- package/dist/chunk-TQ77ZWBD.js.map +1 -0
- package/dist/{chunk-7HXFEYOV.cjs → chunk-U5LKNGHU.cjs} +15 -15
- package/dist/{chunk-7HXFEYOV.cjs.map → chunk-U5LKNGHU.cjs.map} +1 -1
- package/dist/{chunk-M52S3TFI.js → chunk-WFR7HKJL.js} +3 -3
- package/dist/{chunk-M52S3TFI.js.map → chunk-WFR7HKJL.js.map} +1 -1
- package/dist/content-renderer.cjs +7 -5
- package/dist/content-renderer.d.cts +4 -21
- package/dist/content-renderer.d.ts +4 -21
- package/dist/content-renderer.js +4 -2
- package/dist/editor.cjs +6 -5
- package/dist/editor.d.cts +19 -2
- package/dist/editor.d.ts +19 -2
- package/dist/editor.js +4 -3
- package/dist/index.cjs +37 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/json-editor.cjs +13 -14
- package/dist/json-editor.js +2 -3
- package/dist/magic-wand.cjs +3 -4
- package/dist/magic-wand.js +2 -3
- package/dist/prompt-input.cjs +5 -6
- package/dist/prompt-input.js +2 -3
- package/dist/reason-tag.cjs +3 -4
- package/dist/reason-tag.js +2 -3
- package/docs/ContentRenderer.md +192 -3
- package/docs/Editor.md +38 -0
- package/package.json +1 -1
- package/dist/chunk-6TBRBN7H.js +0 -212
- package/dist/chunk-6TBRBN7H.js.map +0 -1
- package/dist/chunk-ATIDUWY6.cjs.map +0 -1
- package/dist/chunk-C5YX5XVL.cjs.map +0 -1
- package/dist/chunk-CAUEKGMR.js.map +0 -1
- package/dist/chunk-L24LUSEE.js.map +0 -1
- package/dist/chunk-MCQJFMDP.cjs.map +0 -1
- package/dist/chunk-TLRRMYNV.js.map +0 -1
- package/dist/chunk-X2FC7ODX.cjs +0 -215
- package/dist/chunk-X2FC7ODX.cjs.map +0 -1
- package/dist/extensions-6PVd3-vB.d.cts +0 -38
- package/dist/extensions-6PVd3-vB.d.ts +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,97 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
## [Unreleased]
|
|
13
13
|
|
|
14
|
+
## [5.68.0] - 2026-10-27
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **`Editor` forwards `copyButtons`, `clipboardWriter` and `onCopy` to the
|
|
19
|
+
`ContentRenderer` its view mode renders through.** 5.67.0 turned copy buttons
|
|
20
|
+
on in view mode but gave a host no way to route those copies (a sandboxed
|
|
21
|
+
Electron window), observe them, or turn them off from `Editor`. Same types and
|
|
22
|
+
same defaults as on `ContentRenderer`; with the props absent nothing changes.
|
|
23
|
+
They have no effect in edit mode. Editor's docs now also document `mode`.
|
|
24
|
+
- **`ContentRenderer streaming="progressive"`: an open block shows as it
|
|
25
|
+
fills.** `streaming={true}` still hides an open block until it closes. In the
|
|
26
|
+
new mode:
|
|
27
|
+
- an open tag of a registered extension whose opening tag is complete renders
|
|
28
|
+
its component with the body so far (a `markdown` extension gets it as
|
|
29
|
+
`content` and rendered, sanitised, as `children`);
|
|
30
|
+
- an open code fence renders as a code block of what has arrived, with **no
|
|
31
|
+
copy button until it closes** (hidden rather than disabled: half a block is
|
|
32
|
+
never what a copy means). Finished blocks before it keep theirs;
|
|
33
|
+
- a partial opening tag (`<result title="Do`), a partial closing tag, a fence
|
|
34
|
+
marker still arriving and a fence opener line with no newline yet are still
|
|
35
|
+
held back, so none of it flashes raw. Inside an open fence `<` is code;
|
|
36
|
+
- it closes the open fence and open tags itself and renders normally, so the
|
|
37
|
+
body is the one the final render shows once the real closes arrive.
|
|
38
|
+
- The root carries `data-streaming-mode="progressive"` as well as
|
|
39
|
+
`data-streaming="true"`.
|
|
40
|
+
|
|
41
|
+
It is a value of `streaming` rather than a new prop because it is a way of
|
|
42
|
+
streaming: a separate flag would add a combination that means nothing.
|
|
43
|
+
`streaming` is now typed `boolean | "progressive"`. Code that passes a
|
|
44
|
+
boolean is unaffected; code that READS the prop's type and assumes `boolean`
|
|
45
|
+
needs to allow the string.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- **Docs: `markdown` tags are lifted only at line start and only when closed,
|
|
50
|
+
and that is now stated as deliberate.** The behaviour is unchanged.
|
|
51
|
+
Progressive streaming does not relax either rule.
|
|
52
|
+
|
|
53
|
+
## [5.67.0] - 2026-10-27
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
|
|
57
|
+
- **`ContentRenderer`: copy buttons, markdown-body tags, streaming, and a
|
|
58
|
+
clipboard writer** (genie#1263). Genie and MOIC render chat markup with this.
|
|
59
|
+
Until now Genie split replies into blocks itself, because custom tags were
|
|
60
|
+
only found after the markdown had become HTML.
|
|
61
|
+
- **Copy buttons** on every code block and table. They are react-fancy
|
|
62
|
+
`Button`s with `copy`/`check` icons and the handle
|
|
63
|
+
`data-react-fancy-content-copy="code" | "table"`, plus `data-copy-state`.
|
|
64
|
+
Code copies exactly what is between the fences: no language label and no
|
|
65
|
+
added trailing newline. A table copies as TSV. Every copy is announced as
|
|
66
|
+
`Copied` or `Copy failed` in a polite live region
|
|
67
|
+
(`[data-react-fancy-content-renderer-live]`). Opt out with
|
|
68
|
+
`copyButtons={false}`, or per kind with `copyButtons={{ table: false }}`.
|
|
69
|
+
`onCopy` reports `{ kind, index, text, html, ok }`.
|
|
70
|
+
- **`markdown: true` on a `RenderExtension`.** A tag that starts a line is
|
|
71
|
+
lifted out of the markdown source before conversion. The component gets
|
|
72
|
+
the raw markdown body as `content`, and the body rendered as `children`.
|
|
73
|
+
The rendered body is sanitised, and it gets nested extensions and copy
|
|
74
|
+
buttons. Same-name nesting is balanced. Tags inside code are left alone.
|
|
75
|
+
Nesting stops at depth 8.
|
|
76
|
+
- **`streaming`** holds back an unfinished trailing tag of a registered
|
|
77
|
+
extension (`<res`, `<result title="x`, an opened tag with no close yet,
|
|
78
|
+
`</res`) and an open code fence, so none of it flashes as raw text. A `<`
|
|
79
|
+
that cannot become a registered tag still renders (`a < b`). When
|
|
80
|
+
`streaming` turns off, everything renders. While streaming, the root
|
|
81
|
+
carries `data-streaming="true"`.
|
|
82
|
+
- **`clipboardWriter`** lets a host supply its own clipboard write, for a
|
|
83
|
+
sandboxed Electron window where `navigator.clipboard` can fail silently.
|
|
84
|
+
The default writes text/html plus text/plain through `ClipboardItem`. If
|
|
85
|
+
that is missing or refused, it falls back to `writeText`. A writer fails if
|
|
86
|
+
it throws, rejects, returns `false`, or has not settled after 5 s. A failure
|
|
87
|
+
is never silent.
|
|
88
|
+
- New types: `ContentCopyKind`, `ContentCopyEvent`, `ContentClipboardPayload`,
|
|
89
|
+
`ContentClipboardWriter`. `RenderExtensionProps` gains an optional
|
|
90
|
+
`children`.
|
|
91
|
+
|
|
92
|
+
### Changed
|
|
93
|
+
|
|
94
|
+
- **`ContentRenderer` (and `Editor`'s view mode, which renders through it) now
|
|
95
|
+
shows copy buttons by default.** Each `<pre>` and `<table>` is wrapped in a
|
|
96
|
+
`div[data-react-fancy-content-copy-block]`. A live-region `<span>` sits at
|
|
97
|
+
the end of the root. Pass `copyButtons={false}` to get the old markup back.
|
|
98
|
+
If you style or select `pre`/`table` by direct-child position, check it. If
|
|
99
|
+
you do not, do nothing.
|
|
100
|
+
- **Attributes of a lifted `markdown` tag are cleaned before the component sees
|
|
101
|
+
them.** `on*`, `srcdoc` and unsafe URLs are removed. This matches what the
|
|
102
|
+
HTML sanitiser already did to tags matched in HTML, so nothing an existing
|
|
103
|
+
extension received changes.
|
|
104
|
+
|
|
14
105
|
## [5.66.0] - 2026-10-27
|
|
15
106
|
|
|
16
107
|
### Added
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/** Props passed to every render-extension component. */
|
|
4
|
+
interface RenderExtensionProps {
|
|
5
|
+
/**
|
|
6
|
+
* The inner content of the custom tag (raw string). For an extension with
|
|
7
|
+
* `markdown: true` in markdown content this is the raw MARKDOWN body, before
|
|
8
|
+
* conversion. Either way it is untrusted: render `children` rather than
|
|
9
|
+
* injecting it.
|
|
10
|
+
*/
|
|
11
|
+
content: string;
|
|
12
|
+
/**
|
|
13
|
+
* Parsed attributes from the opening tag. Event handlers (`on*`), `srcdoc`,
|
|
14
|
+
* and URL attributes with an unsafe scheme are removed (unless the renderer
|
|
15
|
+
* is `unsafe`).
|
|
16
|
+
*/
|
|
17
|
+
attributes: Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Only for extensions with `markdown: true`: the body, rendered by the same
|
|
20
|
+
* pipeline as the rest of the content (sanitised, nested extensions, copy
|
|
21
|
+
* buttons).
|
|
22
|
+
*/
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/** Registers a custom tag with a React component for rendering. */
|
|
26
|
+
interface RenderExtension {
|
|
27
|
+
/** Tag name to match, e.g. "questions", "thinking". Case-insensitive. */
|
|
28
|
+
tag: string;
|
|
29
|
+
/** React component that renders the matched tag. */
|
|
30
|
+
component: ComponentType<RenderExtensionProps>;
|
|
31
|
+
/**
|
|
32
|
+
* Whether this is a block-level element.
|
|
33
|
+
* Block extensions are wrapped in a `<div>`, inline in a `<span>`.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
block?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The tag's body is MARKDOWN. In markdown content, a tag that starts a line
|
|
39
|
+
* is lifted out of the source before conversion, so the component gets the
|
|
40
|
+
* raw markdown as `content` and the rendered, sanitised body as `children`.
|
|
41
|
+
* In HTML content the body is HTML and `children` renders it.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
markdown?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** A parsed segment — either raw HTML or a matched extension tag. */
|
|
47
|
+
type ContentSegment = {
|
|
48
|
+
type: "html";
|
|
49
|
+
content: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: "extension";
|
|
52
|
+
tag: string;
|
|
53
|
+
content: string;
|
|
54
|
+
attributes: Record<string, string>;
|
|
55
|
+
};
|
|
56
|
+
/** Register a single render extension globally (available to all ContentRenderer and Editor instances). */
|
|
57
|
+
declare function registerExtension(extension: RenderExtension): void;
|
|
58
|
+
/** Register multiple render extensions globally. */
|
|
59
|
+
declare function registerExtensions(extensions: RenderExtension[]): void;
|
|
60
|
+
|
|
61
|
+
/** What a copy button copies. */
|
|
62
|
+
type ContentCopyKind = "code" | "table";
|
|
63
|
+
/** What is handed to a clipboard writer. */
|
|
64
|
+
interface ContentClipboardPayload {
|
|
65
|
+
kind: ContentCopyKind;
|
|
66
|
+
/**
|
|
67
|
+
* Plain text. For code: exactly the code between the fences, with no
|
|
68
|
+
* language label and no added trailing newline. For a table: TSV (tab
|
|
69
|
+
* between cells, newline between rows, no trailing newline).
|
|
70
|
+
*/
|
|
71
|
+
text: string;
|
|
72
|
+
/** The block's sanitised HTML (`<pre>…</pre>` or `<table>…</table>`), for rich paste. */
|
|
73
|
+
html: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Writes one copy to the clipboard. Throwing, rejecting, or returning `false`
|
|
77
|
+
* means the copy failed; the failure is announced, never swallowed.
|
|
78
|
+
*/
|
|
79
|
+
type ContentClipboardWriter = (payload: ContentClipboardPayload) => void | boolean | Promise<void | boolean>;
|
|
80
|
+
/** Reported through `onCopy` after every copy attempt. */
|
|
81
|
+
interface ContentCopyEvent extends ContentClipboardPayload {
|
|
82
|
+
/** Position of the button among this renderer's copy buttons, in document order. */
|
|
83
|
+
index: number;
|
|
84
|
+
/** Whether the clipboard write succeeded. */
|
|
85
|
+
ok: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface ContentRendererProps {
|
|
88
|
+
value: string;
|
|
89
|
+
format?: "html" | "markdown" | "auto";
|
|
90
|
+
lineSpacing?: number;
|
|
91
|
+
className?: string;
|
|
92
|
+
/** Per-instance render extensions. Merged with any globally-registered extensions. */
|
|
93
|
+
extensions?: RenderExtension[];
|
|
94
|
+
/**
|
|
95
|
+
* Skip HTML sanitization. By default, rendered output is sanitized to remove
|
|
96
|
+
* `<script>`, `<iframe>`, event handlers, and `javascript:` URIs. Pass
|
|
97
|
+
* `unsafe` only when the input is fully trusted (e.g. server-rendered
|
|
98
|
+
* markdown from your own CMS).
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
unsafe?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Copy buttons on code blocks and tables. `false` turns them all off; an
|
|
104
|
+
* object turns kinds off individually (`{ table: false }`).
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
copyButtons?: boolean | {
|
|
108
|
+
code?: boolean;
|
|
109
|
+
table?: boolean;
|
|
110
|
+
};
|
|
111
|
+
/** Called after every copy attempt, successful or not. */
|
|
112
|
+
onCopy?: (event: ContentCopyEvent) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Host-supplied clipboard writer, for environments where
|
|
115
|
+
* `navigator.clipboard` is unreliable (e.g. a sandboxed Electron window:
|
|
116
|
+
* pass one that calls Electron's `clipboard`). The default writes
|
|
117
|
+
* text/html + text/plain via `ClipboardItem`, falling back to `writeText`.
|
|
118
|
+
*/
|
|
119
|
+
clipboardWriter?: ContentClipboardWriter;
|
|
120
|
+
/**
|
|
121
|
+
* The value is still arriving. Set it back to `false` when the stream ends
|
|
122
|
+
* and everything renders.
|
|
123
|
+
*
|
|
124
|
+
* - `true` holds back an unfinished trailing custom tag (of a registered
|
|
125
|
+
* extension) or code fence until it closes, so a partial `<result` or half
|
|
126
|
+
* a code block never flashes as raw text.
|
|
127
|
+
* - `"progressive"` shows an open block as it fills: an open registered tag
|
|
128
|
+
* whose opening tag is complete renders its component with the body so
|
|
129
|
+
* far, and an open code fence renders as a code block of what has arrived
|
|
130
|
+
* (with no copy button until it closes). A partial opening tag
|
|
131
|
+
* (`<result title="Do`) is still held back.
|
|
132
|
+
* @default false
|
|
133
|
+
*/
|
|
134
|
+
streaming?: boolean | "progressive";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { type ContentClipboardPayload as C, type RenderExtension as R, type ContentClipboardWriter as a, type ContentCopyEvent as b, type ContentCopyKind as c, type ContentRendererProps as d, type RenderExtensionProps as e, registerExtensions as f, type ContentSegment as g, registerExtension as r };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/** Props passed to every render-extension component. */
|
|
4
|
+
interface RenderExtensionProps {
|
|
5
|
+
/**
|
|
6
|
+
* The inner content of the custom tag (raw string). For an extension with
|
|
7
|
+
* `markdown: true` in markdown content this is the raw MARKDOWN body, before
|
|
8
|
+
* conversion. Either way it is untrusted: render `children` rather than
|
|
9
|
+
* injecting it.
|
|
10
|
+
*/
|
|
11
|
+
content: string;
|
|
12
|
+
/**
|
|
13
|
+
* Parsed attributes from the opening tag. Event handlers (`on*`), `srcdoc`,
|
|
14
|
+
* and URL attributes with an unsafe scheme are removed (unless the renderer
|
|
15
|
+
* is `unsafe`).
|
|
16
|
+
*/
|
|
17
|
+
attributes: Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Only for extensions with `markdown: true`: the body, rendered by the same
|
|
20
|
+
* pipeline as the rest of the content (sanitised, nested extensions, copy
|
|
21
|
+
* buttons).
|
|
22
|
+
*/
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/** Registers a custom tag with a React component for rendering. */
|
|
26
|
+
interface RenderExtension {
|
|
27
|
+
/** Tag name to match, e.g. "questions", "thinking". Case-insensitive. */
|
|
28
|
+
tag: string;
|
|
29
|
+
/** React component that renders the matched tag. */
|
|
30
|
+
component: ComponentType<RenderExtensionProps>;
|
|
31
|
+
/**
|
|
32
|
+
* Whether this is a block-level element.
|
|
33
|
+
* Block extensions are wrapped in a `<div>`, inline in a `<span>`.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
block?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The tag's body is MARKDOWN. In markdown content, a tag that starts a line
|
|
39
|
+
* is lifted out of the source before conversion, so the component gets the
|
|
40
|
+
* raw markdown as `content` and the rendered, sanitised body as `children`.
|
|
41
|
+
* In HTML content the body is HTML and `children` renders it.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
markdown?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** A parsed segment — either raw HTML or a matched extension tag. */
|
|
47
|
+
type ContentSegment = {
|
|
48
|
+
type: "html";
|
|
49
|
+
content: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: "extension";
|
|
52
|
+
tag: string;
|
|
53
|
+
content: string;
|
|
54
|
+
attributes: Record<string, string>;
|
|
55
|
+
};
|
|
56
|
+
/** Register a single render extension globally (available to all ContentRenderer and Editor instances). */
|
|
57
|
+
declare function registerExtension(extension: RenderExtension): void;
|
|
58
|
+
/** Register multiple render extensions globally. */
|
|
59
|
+
declare function registerExtensions(extensions: RenderExtension[]): void;
|
|
60
|
+
|
|
61
|
+
/** What a copy button copies. */
|
|
62
|
+
type ContentCopyKind = "code" | "table";
|
|
63
|
+
/** What is handed to a clipboard writer. */
|
|
64
|
+
interface ContentClipboardPayload {
|
|
65
|
+
kind: ContentCopyKind;
|
|
66
|
+
/**
|
|
67
|
+
* Plain text. For code: exactly the code between the fences, with no
|
|
68
|
+
* language label and no added trailing newline. For a table: TSV (tab
|
|
69
|
+
* between cells, newline between rows, no trailing newline).
|
|
70
|
+
*/
|
|
71
|
+
text: string;
|
|
72
|
+
/** The block's sanitised HTML (`<pre>…</pre>` or `<table>…</table>`), for rich paste. */
|
|
73
|
+
html: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Writes one copy to the clipboard. Throwing, rejecting, or returning `false`
|
|
77
|
+
* means the copy failed; the failure is announced, never swallowed.
|
|
78
|
+
*/
|
|
79
|
+
type ContentClipboardWriter = (payload: ContentClipboardPayload) => void | boolean | Promise<void | boolean>;
|
|
80
|
+
/** Reported through `onCopy` after every copy attempt. */
|
|
81
|
+
interface ContentCopyEvent extends ContentClipboardPayload {
|
|
82
|
+
/** Position of the button among this renderer's copy buttons, in document order. */
|
|
83
|
+
index: number;
|
|
84
|
+
/** Whether the clipboard write succeeded. */
|
|
85
|
+
ok: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface ContentRendererProps {
|
|
88
|
+
value: string;
|
|
89
|
+
format?: "html" | "markdown" | "auto";
|
|
90
|
+
lineSpacing?: number;
|
|
91
|
+
className?: string;
|
|
92
|
+
/** Per-instance render extensions. Merged with any globally-registered extensions. */
|
|
93
|
+
extensions?: RenderExtension[];
|
|
94
|
+
/**
|
|
95
|
+
* Skip HTML sanitization. By default, rendered output is sanitized to remove
|
|
96
|
+
* `<script>`, `<iframe>`, event handlers, and `javascript:` URIs. Pass
|
|
97
|
+
* `unsafe` only when the input is fully trusted (e.g. server-rendered
|
|
98
|
+
* markdown from your own CMS).
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
unsafe?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Copy buttons on code blocks and tables. `false` turns them all off; an
|
|
104
|
+
* object turns kinds off individually (`{ table: false }`).
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
copyButtons?: boolean | {
|
|
108
|
+
code?: boolean;
|
|
109
|
+
table?: boolean;
|
|
110
|
+
};
|
|
111
|
+
/** Called after every copy attempt, successful or not. */
|
|
112
|
+
onCopy?: (event: ContentCopyEvent) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Host-supplied clipboard writer, for environments where
|
|
115
|
+
* `navigator.clipboard` is unreliable (e.g. a sandboxed Electron window:
|
|
116
|
+
* pass one that calls Electron's `clipboard`). The default writes
|
|
117
|
+
* text/html + text/plain via `ClipboardItem`, falling back to `writeText`.
|
|
118
|
+
*/
|
|
119
|
+
clipboardWriter?: ContentClipboardWriter;
|
|
120
|
+
/**
|
|
121
|
+
* The value is still arriving. Set it back to `false` when the stream ends
|
|
122
|
+
* and everything renders.
|
|
123
|
+
*
|
|
124
|
+
* - `true` holds back an unfinished trailing custom tag (of a registered
|
|
125
|
+
* extension) or code fence until it closes, so a partial `<result` or half
|
|
126
|
+
* a code block never flashes as raw text.
|
|
127
|
+
* - `"progressive"` shows an open block as it fills: an open registered tag
|
|
128
|
+
* whose opening tag is complete renders its component with the body so
|
|
129
|
+
* far, and an open code fence renders as a code block of what has arrived
|
|
130
|
+
* (with no copy button until it closes). A partial opening tag
|
|
131
|
+
* (`<result title="Do`) is still held back.
|
|
132
|
+
* @default false
|
|
133
|
+
*/
|
|
134
|
+
streaming?: boolean | "progressive";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { type ContentClipboardPayload as C, type RenderExtension as R, type ContentClipboardWriter as a, type ContentCopyEvent as b, type ContentCopyKind as c, type ContentRendererProps as d, type RenderExtensionProps as e, registerExtensions as f, type ContentSegment as g, registerExtension as r };
|
package/dist/button.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('./chunk-M5MUGSON.cjs');
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-X2FC7ODX.cjs');
|
|
4
|
+
var chunk3U7PUZLI_cjs = require('./chunk-3U7PUZLI.cjs');
|
|
6
5
|
require('./chunk-XCZZVRBY.cjs');
|
|
7
6
|
require('./chunk-MXWR3T3N.cjs');
|
|
8
7
|
require('./chunk-ZU5Q77OT.cjs');
|
|
@@ -11,11 +10,11 @@ require('./chunk-ZU5Q77OT.cjs');
|
|
|
11
10
|
|
|
12
11
|
Object.defineProperty(exports, "Action", {
|
|
13
12
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk3U7PUZLI_cjs.Action; }
|
|
15
14
|
});
|
|
16
15
|
Object.defineProperty(exports, "Button", {
|
|
17
16
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk3U7PUZLI_cjs.Button; }
|
|
19
18
|
});
|
|
20
19
|
//# sourceMappingURL=button.cjs.map
|
|
21
20
|
//# sourceMappingURL=button.cjs.map
|
package/dist/button.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import './chunk-LQ4ICCN2.js';
|
|
2
|
-
export { Action, Button } from './chunk-
|
|
3
|
-
import './chunk-6TBRBN7H.js';
|
|
2
|
+
export { Action, Button } from './chunk-OXERDFFF.js';
|
|
4
3
|
import './chunk-45BBNJQD.js';
|
|
5
4
|
import './chunk-J3A4Z2P7.js';
|
|
6
5
|
import './chunk-MMW2JGKZ.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tooltip } from './chunk-GR2WKBER.js';
|
|
2
2
|
import { useInlinePaste, InlinePasteEditor, PastedFilesInput, markedIds, expandMarkers } from './chunk-YIKXJWO4.js';
|
|
3
|
-
import { Button } from './chunk-
|
|
3
|
+
import { Button } from './chunk-OXERDFFF.js';
|
|
4
4
|
import { Icon } from './chunk-J3A4Z2P7.js';
|
|
5
5
|
import { cn } from './chunk-MMW2JGKZ.js';
|
|
6
6
|
import { forwardRef, useState, useRef, useCallback, useReducer, useMemo, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
@@ -815,5 +815,5 @@ function fmtSize(b) {
|
|
|
815
815
|
}
|
|
816
816
|
|
|
817
817
|
export { PromptInput, browserPlatformHints, detectPlatform, modifierKeyLabel, promptDataUrlToFile, promptFileToDataUrl };
|
|
818
|
-
//# sourceMappingURL=chunk-
|
|
819
|
-
//# sourceMappingURL=chunk-
|
|
818
|
+
//# sourceMappingURL=chunk-23AVEYUP.js.map
|
|
819
|
+
//# sourceMappingURL=chunk-23AVEYUP.js.map
|