@relyio/sdk 0.12.0 → 0.13.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 +84 -0
- package/dist/{chunk-3DRDHXLY.js → chunk-3NPPMGB6.js} +435 -23
- package/dist/{chunk-FRJEUAAF.js → chunk-6NGJXLOR.js} +22 -11
- package/dist/{chunk-DXCVO6M5.cjs → chunk-DEDIJKHY.cjs} +22 -11
- package/dist/{chunk-POEEDYFM.js → chunk-EW23SZPX.js} +7 -2
- package/dist/{chunk-3MSFWXQL.cjs → chunk-FOSM4LMM.cjs} +7 -2
- package/dist/{chunk-FI5VIF4M.cjs → chunk-Z6GLWSSD.cjs} +442 -22
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +4 -5
- package/dist/client/index.d.ts +4 -5
- package/dist/client/index.js +1 -1
- package/dist/{define-schema-mrEZbY1h.d.ts → define-schema-UHViXKiv.d.ts} +2 -219
- package/dist/{define-schema-DgctHlI2.d.cts → define-schema-sWJ8Zn7C.d.cts} +2 -219
- package/dist/{include-paths-CL4gHv6I.d.cts → include-paths-Bs5FhNw2.d.cts} +2191 -108
- package/dist/{include-paths-CrJNTsMl.d.ts → include-paths-Cb7iPCW2.d.ts} +2191 -108
- package/dist/index--_u1nPHv.d.cts +507 -0
- package/dist/index-8DozAWsA.d.ts +507 -0
- package/dist/{index-BrvEg6-A.d.cts → index-BT0L8xJj.d.cts} +41 -53
- package/dist/{index-Pw0onkJe.d.ts → index-CPjJ25R4.d.ts} +41 -53
- package/dist/index.cjs +119 -112
- package/dist/index.d.cts +39 -70
- package/dist/index.d.ts +39 -70
- package/dist/index.js +5 -29
- package/dist/markdown/index.cjs +13750 -0
- package/dist/markdown/index.d.cts +111 -0
- package/dist/markdown/index.d.ts +111 -0
- package/dist/markdown/index.js +13742 -0
- package/dist/rich-text/index.cjs +26 -6
- package/dist/rich-text/index.d.cts +3 -148
- package/dist/rich-text/index.d.ts +3 -148
- package/dist/rich-text/index.js +1 -1
- package/dist/rich-text.d-BWc-5gX1.d.cts +326 -0
- package/dist/rich-text.d-BWc-5gX1.d.ts +326 -0
- package/dist/schema/index.cjs +34 -34
- package/dist/schema/index.d.cts +9 -178
- package/dist/schema/index.d.ts +9 -178
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.ts +2 -3
- package/package.json +14 -3
- package/dist/index-B9RfZVF1.d.ts +0 -861
- package/dist/index-b-AkfTUv.d.cts +0 -861
- package/dist/rich-text.d-rKmpgdGd.d.cts +0 -200
- package/dist/rich-text.d-rKmpgdGd.d.ts +0 -200
package/dist/rich-text/index.cjs
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkZ6GLWSSD_cjs = require('../chunk-Z6GLWSSD.cjs');
|
|
4
4
|
require('../chunk-MWMSFIWN.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "RICH_TEXT_VOID_TAGS", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkZ6GLWSSD_cjs.RICH_TEXT_VOID_TAGS; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "entryHeadingAnchors", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkZ6GLWSSD_cjs.entryHeadingAnchors; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "escapeHtml", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkZ6GLWSSD_cjs.escapeHtml; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "isDeclaredRichTextNode", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkZ6GLWSSD_cjs.isDeclaredRichTextNode; }
|
|
11
23
|
});
|
|
12
24
|
Object.defineProperty(exports, "renderRichText", {
|
|
13
25
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkZ6GLWSSD_cjs.renderRichText; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "richTextHeadingAnchors", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkZ6GLWSSD_cjs.richTextHeadingAnchors; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "richTextHeadingSlug", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkZ6GLWSSD_cjs.richTextHeadingSlug; }
|
|
15
35
|
});
|
|
16
36
|
Object.defineProperty(exports, "richTextToHtml", {
|
|
17
37
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkZ6GLWSSD_cjs.richTextToHtml; }
|
|
19
39
|
});
|
|
20
40
|
Object.defineProperty(exports, "richTextToMarkdown", {
|
|
21
41
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkZ6GLWSSD_cjs.richTextToMarkdown; }
|
|
23
43
|
});
|
|
24
44
|
Object.defineProperty(exports, "safeRichTextHref", {
|
|
25
45
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkZ6GLWSSD_cjs.safeRichTextHref; }
|
|
27
47
|
});
|
|
28
48
|
//# sourceMappingURL=index.cjs.map
|
|
29
49
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,148 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* The one walk of a rich-text tree into elements, for every output (REL-1804).
|
|
5
|
-
*
|
|
6
|
-
* Rich text is a versioned tree (ADR 0013, `RichTextValue`). What each built-in looks like by
|
|
7
|
-
* default — which element a node or a mark becomes, with which attributes, holding what — is
|
|
8
|
-
* written here once, generic over the output: {@link richTextToHtml} hands it a target that builds
|
|
9
|
-
* strings, `@relyio/react`'s `<RichText>` one that builds React elements. So the HTML a server
|
|
10
|
-
* writes and the markup `<RichText>` renders are one rendering by construction, not two kept equal
|
|
11
|
-
* by hand; a test over the corpus holds them byte for byte.
|
|
12
|
-
*
|
|
13
|
-
* Three rules every output inherits from this walk:
|
|
14
|
-
*
|
|
15
|
-
* - **Every tag is a literal here, never data.** A heading's level picks from a fixed table, and a
|
|
16
|
-
* level the table lacks renders as a paragraph. An attribute's name is a literal too; its value is
|
|
17
|
-
* the target's to escape.
|
|
18
|
-
* - **A link to an unsafe scheme is not a link.** An `href` is drawn only when it is relative or
|
|
19
|
-
* `http:`, `https:`, `mailto:` or `tel:` ({@link safeRichTextHref}); any other scheme —
|
|
20
|
-
* `javascript:`, `data:`, `vbscript:`, … — renders the link's text with no anchor, and a site's
|
|
21
|
-
* own `link` renderer is never handed one.
|
|
22
|
-
* - **Version 1 grows by addition** (`rich-text-format.md`). The switches below cover every node
|
|
23
|
-
* and mark of the vocabulary this build knows, with no fallback: a type added to it fails to
|
|
24
|
-
* compile here until it is drawn. At run time a newer server can still send a `_type` this build
|
|
25
|
-
* does not know; such a node renders nothing, and such a mark renders its text unformatted. Never
|
|
26
|
-
* an error.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/** Every element the default rendering of rich text uses. A tag is always one of these literals. */
|
|
30
|
-
type RichTextTag = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote' | 'ul' | 'ol' | 'li' | 'input' | 'pre' | 'code' | 'figure' | 'figcaption' | 'div' | 'table' | 'thead' | 'tbody' | 'tr' | 'th' | 'td' | 'hr' | 'br' | 'a' | 'strong' | 'em' | 'u' | 's' | 'mark' | 'sub' | 'sup';
|
|
31
|
-
/** The elements that hold nothing and have no closing tag. */
|
|
32
|
-
declare const RICH_TEXT_VOID_TAGS: ReadonlySet<RichTextTag>;
|
|
33
|
-
/**
|
|
34
|
-
* An element's attributes, in the order they are written. A value is a string or a number, or
|
|
35
|
-
* `true` for a boolean attribute that is present. `style` is a CSS declaration list (`text-align:center`).
|
|
36
|
-
*/
|
|
37
|
-
type RichTextAttributes = Readonly<Record<string, string | number | true>>;
|
|
38
|
-
/** Every node a site may draw itself: all of them but a run of text, whose marks are drawn instead. */
|
|
39
|
-
type RichTextReplaceableNode = Exclude<RichTextNode, RichTextSpan>;
|
|
40
|
-
/** Where a node stands, for a renderer that draws it differently there. */
|
|
41
|
-
interface RichTextNodeContext {
|
|
42
|
-
/** Whether a table row or cell is in the table's header row; `false` for every other node. */
|
|
43
|
-
readonly header: boolean;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* What a walk of the tree builds with. {@link renderRichText} decides what each built-in becomes and
|
|
47
|
-
* calls `element` and `text` for it; `node` and `mark` are where an output may draw a node or a mark
|
|
48
|
-
* its own way, handed the default drawing to fall back on.
|
|
49
|
-
*/
|
|
50
|
-
interface RichTextTarget<Out> {
|
|
51
|
-
/** An element of the default rendering. `key` is the node's `_key` when the element is a node's own. */
|
|
52
|
-
element(tag: RichTextTag, attributes: RichTextAttributes | undefined, children: readonly Out[], key: string | undefined): Out;
|
|
53
|
-
/** Text, exactly as the tree holds it: the target escapes it. */
|
|
54
|
-
text(text: string): Out;
|
|
55
|
-
/**
|
|
56
|
-
* A node, given what it holds already drawn (`contents`) and the default drawing of it (`draw`).
|
|
57
|
-
* Return `draw(contents)` to draw it the default way.
|
|
58
|
-
*/
|
|
59
|
-
node(node: RichTextReplaceableNode, contents: readonly Out[], draw: (contents: readonly Out[]) => Out, context: RichTextNodeContext): Out;
|
|
60
|
-
/**
|
|
61
|
-
* A mark around `contents`, the runs it covers already drawn. A link reaches it only with a safe
|
|
62
|
-
* `href`. Return `draw(contents)` to draw it the default way.
|
|
63
|
-
*/
|
|
64
|
-
mark(mark: RichTextMark, contents: readonly Out[], draw: (contents: readonly Out[]) => Out): Out;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* What the walk renders: a `richText` field's tree, or a `table` or `code` field's value — exactly
|
|
68
|
-
* one of the tree's built-ins (REL-1806), drawn as the same block is inside a tree, so a table field
|
|
69
|
-
* on a page and a table in a doc render the same markup.
|
|
70
|
-
*/
|
|
71
|
-
type RichTextRenderable = RichTextValue | RichTextTable | RichTextCodeGroup;
|
|
72
|
-
/**
|
|
73
|
-
* Walk `value` into `target`'s output: one entry per block the tree holds, in order — or, for a
|
|
74
|
-
* `table` or `code` field's value, the one block it is. A block of a `_type` this build does not
|
|
75
|
-
* know adds nothing.
|
|
76
|
-
*/
|
|
77
|
-
declare function renderRichText<Out>(value: RichTextRenderable, target: RichTextTarget<Out>): Out[];
|
|
78
|
-
/**
|
|
79
|
-
* `href` as a link may carry it, or `undefined` when it must not be one: not a string, empty, or
|
|
80
|
-
* naming a scheme outside `http:`, `https:`, `mailto:` and `tel:`. The scheme is read the way a
|
|
81
|
-
* browser reads it — leading and trailing controls and spaces stripped, tabs and newlines removed
|
|
82
|
-
* anywhere — so `" java\tscript:"` is the `javascript:` it runs as. The `href` returned is the one
|
|
83
|
-
* given; escaping it is the output's.
|
|
84
|
-
*/
|
|
85
|
-
declare function safeRichTextHref(href: unknown): string | undefined;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Rich text as HTML (REL-1804): the default rendering ({@link renderRichText}) written as a string.
|
|
89
|
-
* No DOM and no dependency, so it runs the same in a browser, Node and a Worker.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* A rich-text value as HTML: every built-in drawn the way `<RichText>` from `@relyio/react` draws it
|
|
94
|
-
* with no components given, text and attributes escaped. `''` for an absent value. A `table` or
|
|
95
|
-
* `code` field's value — one of the tree's built-ins — is drawn as the same block inside a tree.
|
|
96
|
-
*
|
|
97
|
-
* - A link keeps its `href` only when it is relative or `http:`, `https:`, `mailto:` or `tel:`;
|
|
98
|
-
* one to any other scheme (`javascript:`, `data:`, …) renders its text with no anchor.
|
|
99
|
-
* - A node of a `_type` this version of the SDK does not know — content a newer server sends —
|
|
100
|
-
* renders nothing, and a mark it does not know leaves its text unformatted.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* import { richTextToHtml } from '@relyio/sdk'
|
|
105
|
-
*
|
|
106
|
-
* const post = await relyio.content('post').findById('hello').execute()
|
|
107
|
-
* const html = richTextToHtml(post?.body) // '<h2>Getting started</h2><p>Install the <code>SDK</code>…</p>'
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
declare function richTextToHtml(value: RichTextRenderable | undefined): string;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Rich text as plain Markdown (REL-1804): GitHub Flavored Markdown — CommonMark with tables, task
|
|
114
|
-
* lists and strikethrough — which drops what it cannot hold. RelyIO Markdown, the form that
|
|
115
|
-
* round-trips through directives for what plain Markdown lacks, is a separate serializer (REL-1809).
|
|
116
|
-
*
|
|
117
|
-
* What plain Markdown cannot hold, and what becomes of it:
|
|
118
|
-
*
|
|
119
|
-
* - The marks `underline`, `highlight`, `subscript` and `superscript`: their text, unformatted.
|
|
120
|
-
* - A code block's `filename`, `label` and line range: dropped; a code group's tabs follow one
|
|
121
|
-
* another as fenced blocks.
|
|
122
|
-
* - A table's per-cell alignment: a column takes its first row's; a table with no header row gets
|
|
123
|
-
* an empty one, since a Markdown table has to have one; a cell's paragraphs and line breaks join
|
|
124
|
-
* with spaces.
|
|
125
|
-
* - A line break in a heading: a space. An empty paragraph or heading: nothing.
|
|
126
|
-
* - A link to a scheme other than `http:`, `https:`, `mailto:` and `tel:`: its text, as in HTML.
|
|
127
|
-
* - A node of a `_type` this version of the SDK does not know: nothing. A mark it does not know:
|
|
128
|
-
* its text, unformatted.
|
|
129
|
-
*
|
|
130
|
-
* Text is escaped so it reads back as the same text: `*`, `_`, a bracket or a backtick in a
|
|
131
|
-
* sentence is a character, not syntax.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* A rich-text value as plain Markdown, ending in a newline; `''` for an absent or empty value. What
|
|
136
|
-
* Markdown cannot hold is dropped, its text kept (see the module's notes). A `table` or `code`
|
|
137
|
-
* field's value — one of the tree's built-ins — is written as the same block inside a tree.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* import { richTextToMarkdown } from '@relyio/sdk'
|
|
142
|
-
*
|
|
143
|
-
* richTextToMarkdown(post.body) // '## Getting started\n\nInstall the `SDK`, then read the [**guide**](/docs/guide).\n'
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
declare function richTextToMarkdown(value: RichTextRenderable | undefined): string;
|
|
147
|
-
|
|
148
|
-
export { RICH_TEXT_VOID_TAGS, type RichTextAttributes, type RichTextNodeContext, type RichTextRenderable, type RichTextReplaceableNode, type RichTextTag, type RichTextTarget, renderRichText, richTextToHtml, richTextToMarkdown, safeRichTextHref };
|
|
1
|
+
export { n as RICH_TEXT_VOID_TAGS, q as RichTextAnchorsOption, t as RichTextAttributes, u as RichTextBlocksOf, v as RichTextDeclaredOf, w as RichTextDeclaredWriters, x as RichTextEntryLinkOf, y as RichTextEntryLinkOption, j as RichTextHtmlDeclaredWriters, k as RichTextHtmlFieldOption, l as RichTextHtmlOptions, z as RichTextInlineOf, m as RichTextMarkdownOptions, A as RichTextNodeContext, B as RichTextRenderable, C as RichTextRenderableOf, D as RichTextReplaceableNode, E as RichTextTag, F as RichTextTarget, e as entryHeadingAnchors, g as escapeHtml, o as isDeclaredRichTextNode, p as renderRichText, d as richTextHeadingAnchors, f as richTextHeadingSlug, h as richTextToHtml, i as richTextToMarkdown, s as safeRichTextHref } from '../index--_u1nPHv.cjs';
|
|
2
|
+
import '../rich-text.d-BWc-5gX1.cjs';
|
|
3
|
+
import '../include-paths-Bs5FhNw2.cjs';
|
|
@@ -1,148 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* The one walk of a rich-text tree into elements, for every output (REL-1804).
|
|
5
|
-
*
|
|
6
|
-
* Rich text is a versioned tree (ADR 0013, `RichTextValue`). What each built-in looks like by
|
|
7
|
-
* default — which element a node or a mark becomes, with which attributes, holding what — is
|
|
8
|
-
* written here once, generic over the output: {@link richTextToHtml} hands it a target that builds
|
|
9
|
-
* strings, `@relyio/react`'s `<RichText>` one that builds React elements. So the HTML a server
|
|
10
|
-
* writes and the markup `<RichText>` renders are one rendering by construction, not two kept equal
|
|
11
|
-
* by hand; a test over the corpus holds them byte for byte.
|
|
12
|
-
*
|
|
13
|
-
* Three rules every output inherits from this walk:
|
|
14
|
-
*
|
|
15
|
-
* - **Every tag is a literal here, never data.** A heading's level picks from a fixed table, and a
|
|
16
|
-
* level the table lacks renders as a paragraph. An attribute's name is a literal too; its value is
|
|
17
|
-
* the target's to escape.
|
|
18
|
-
* - **A link to an unsafe scheme is not a link.** An `href` is drawn only when it is relative or
|
|
19
|
-
* `http:`, `https:`, `mailto:` or `tel:` ({@link safeRichTextHref}); any other scheme —
|
|
20
|
-
* `javascript:`, `data:`, `vbscript:`, … — renders the link's text with no anchor, and a site's
|
|
21
|
-
* own `link` renderer is never handed one.
|
|
22
|
-
* - **Version 1 grows by addition** (`rich-text-format.md`). The switches below cover every node
|
|
23
|
-
* and mark of the vocabulary this build knows, with no fallback: a type added to it fails to
|
|
24
|
-
* compile here until it is drawn. At run time a newer server can still send a `_type` this build
|
|
25
|
-
* does not know; such a node renders nothing, and such a mark renders its text unformatted. Never
|
|
26
|
-
* an error.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/** Every element the default rendering of rich text uses. A tag is always one of these literals. */
|
|
30
|
-
type RichTextTag = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote' | 'ul' | 'ol' | 'li' | 'input' | 'pre' | 'code' | 'figure' | 'figcaption' | 'div' | 'table' | 'thead' | 'tbody' | 'tr' | 'th' | 'td' | 'hr' | 'br' | 'a' | 'strong' | 'em' | 'u' | 's' | 'mark' | 'sub' | 'sup';
|
|
31
|
-
/** The elements that hold nothing and have no closing tag. */
|
|
32
|
-
declare const RICH_TEXT_VOID_TAGS: ReadonlySet<RichTextTag>;
|
|
33
|
-
/**
|
|
34
|
-
* An element's attributes, in the order they are written. A value is a string or a number, or
|
|
35
|
-
* `true` for a boolean attribute that is present. `style` is a CSS declaration list (`text-align:center`).
|
|
36
|
-
*/
|
|
37
|
-
type RichTextAttributes = Readonly<Record<string, string | number | true>>;
|
|
38
|
-
/** Every node a site may draw itself: all of them but a run of text, whose marks are drawn instead. */
|
|
39
|
-
type RichTextReplaceableNode = Exclude<RichTextNode, RichTextSpan>;
|
|
40
|
-
/** Where a node stands, for a renderer that draws it differently there. */
|
|
41
|
-
interface RichTextNodeContext {
|
|
42
|
-
/** Whether a table row or cell is in the table's header row; `false` for every other node. */
|
|
43
|
-
readonly header: boolean;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* What a walk of the tree builds with. {@link renderRichText} decides what each built-in becomes and
|
|
47
|
-
* calls `element` and `text` for it; `node` and `mark` are where an output may draw a node or a mark
|
|
48
|
-
* its own way, handed the default drawing to fall back on.
|
|
49
|
-
*/
|
|
50
|
-
interface RichTextTarget<Out> {
|
|
51
|
-
/** An element of the default rendering. `key` is the node's `_key` when the element is a node's own. */
|
|
52
|
-
element(tag: RichTextTag, attributes: RichTextAttributes | undefined, children: readonly Out[], key: string | undefined): Out;
|
|
53
|
-
/** Text, exactly as the tree holds it: the target escapes it. */
|
|
54
|
-
text(text: string): Out;
|
|
55
|
-
/**
|
|
56
|
-
* A node, given what it holds already drawn (`contents`) and the default drawing of it (`draw`).
|
|
57
|
-
* Return `draw(contents)` to draw it the default way.
|
|
58
|
-
*/
|
|
59
|
-
node(node: RichTextReplaceableNode, contents: readonly Out[], draw: (contents: readonly Out[]) => Out, context: RichTextNodeContext): Out;
|
|
60
|
-
/**
|
|
61
|
-
* A mark around `contents`, the runs it covers already drawn. A link reaches it only with a safe
|
|
62
|
-
* `href`. Return `draw(contents)` to draw it the default way.
|
|
63
|
-
*/
|
|
64
|
-
mark(mark: RichTextMark, contents: readonly Out[], draw: (contents: readonly Out[]) => Out): Out;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* What the walk renders: a `richText` field's tree, or a `table` or `code` field's value — exactly
|
|
68
|
-
* one of the tree's built-ins (REL-1806), drawn as the same block is inside a tree, so a table field
|
|
69
|
-
* on a page and a table in a doc render the same markup.
|
|
70
|
-
*/
|
|
71
|
-
type RichTextRenderable = RichTextValue | RichTextTable | RichTextCodeGroup;
|
|
72
|
-
/**
|
|
73
|
-
* Walk `value` into `target`'s output: one entry per block the tree holds, in order — or, for a
|
|
74
|
-
* `table` or `code` field's value, the one block it is. A block of a `_type` this build does not
|
|
75
|
-
* know adds nothing.
|
|
76
|
-
*/
|
|
77
|
-
declare function renderRichText<Out>(value: RichTextRenderable, target: RichTextTarget<Out>): Out[];
|
|
78
|
-
/**
|
|
79
|
-
* `href` as a link may carry it, or `undefined` when it must not be one: not a string, empty, or
|
|
80
|
-
* naming a scheme outside `http:`, `https:`, `mailto:` and `tel:`. The scheme is read the way a
|
|
81
|
-
* browser reads it — leading and trailing controls and spaces stripped, tabs and newlines removed
|
|
82
|
-
* anywhere — so `" java\tscript:"` is the `javascript:` it runs as. The `href` returned is the one
|
|
83
|
-
* given; escaping it is the output's.
|
|
84
|
-
*/
|
|
85
|
-
declare function safeRichTextHref(href: unknown): string | undefined;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Rich text as HTML (REL-1804): the default rendering ({@link renderRichText}) written as a string.
|
|
89
|
-
* No DOM and no dependency, so it runs the same in a browser, Node and a Worker.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* A rich-text value as HTML: every built-in drawn the way `<RichText>` from `@relyio/react` draws it
|
|
94
|
-
* with no components given, text and attributes escaped. `''` for an absent value. A `table` or
|
|
95
|
-
* `code` field's value — one of the tree's built-ins — is drawn as the same block inside a tree.
|
|
96
|
-
*
|
|
97
|
-
* - A link keeps its `href` only when it is relative or `http:`, `https:`, `mailto:` or `tel:`;
|
|
98
|
-
* one to any other scheme (`javascript:`, `data:`, …) renders its text with no anchor.
|
|
99
|
-
* - A node of a `_type` this version of the SDK does not know — content a newer server sends —
|
|
100
|
-
* renders nothing, and a mark it does not know leaves its text unformatted.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* import { richTextToHtml } from '@relyio/sdk'
|
|
105
|
-
*
|
|
106
|
-
* const post = await relyio.content('post').findById('hello').execute()
|
|
107
|
-
* const html = richTextToHtml(post?.body) // '<h2>Getting started</h2><p>Install the <code>SDK</code>…</p>'
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
declare function richTextToHtml(value: RichTextRenderable | undefined): string;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Rich text as plain Markdown (REL-1804): GitHub Flavored Markdown — CommonMark with tables, task
|
|
114
|
-
* lists and strikethrough — which drops what it cannot hold. RelyIO Markdown, the form that
|
|
115
|
-
* round-trips through directives for what plain Markdown lacks, is a separate serializer (REL-1809).
|
|
116
|
-
*
|
|
117
|
-
* What plain Markdown cannot hold, and what becomes of it:
|
|
118
|
-
*
|
|
119
|
-
* - The marks `underline`, `highlight`, `subscript` and `superscript`: their text, unformatted.
|
|
120
|
-
* - A code block's `filename`, `label` and line range: dropped; a code group's tabs follow one
|
|
121
|
-
* another as fenced blocks.
|
|
122
|
-
* - A table's per-cell alignment: a column takes its first row's; a table with no header row gets
|
|
123
|
-
* an empty one, since a Markdown table has to have one; a cell's paragraphs and line breaks join
|
|
124
|
-
* with spaces.
|
|
125
|
-
* - A line break in a heading: a space. An empty paragraph or heading: nothing.
|
|
126
|
-
* - A link to a scheme other than `http:`, `https:`, `mailto:` and `tel:`: its text, as in HTML.
|
|
127
|
-
* - A node of a `_type` this version of the SDK does not know: nothing. A mark it does not know:
|
|
128
|
-
* its text, unformatted.
|
|
129
|
-
*
|
|
130
|
-
* Text is escaped so it reads back as the same text: `*`, `_`, a bracket or a backtick in a
|
|
131
|
-
* sentence is a character, not syntax.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* A rich-text value as plain Markdown, ending in a newline; `''` for an absent or empty value. What
|
|
136
|
-
* Markdown cannot hold is dropped, its text kept (see the module's notes). A `table` or `code`
|
|
137
|
-
* field's value — one of the tree's built-ins — is written as the same block inside a tree.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* import { richTextToMarkdown } from '@relyio/sdk'
|
|
142
|
-
*
|
|
143
|
-
* richTextToMarkdown(post.body) // '## Getting started\n\nInstall the `SDK`, then read the [**guide**](/docs/guide).\n'
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
declare function richTextToMarkdown(value: RichTextRenderable | undefined): string;
|
|
147
|
-
|
|
148
|
-
export { RICH_TEXT_VOID_TAGS, type RichTextAttributes, type RichTextNodeContext, type RichTextRenderable, type RichTextReplaceableNode, type RichTextTag, type RichTextTarget, renderRichText, richTextToHtml, richTextToMarkdown, safeRichTextHref };
|
|
1
|
+
export { n as RICH_TEXT_VOID_TAGS, q as RichTextAnchorsOption, t as RichTextAttributes, u as RichTextBlocksOf, v as RichTextDeclaredOf, w as RichTextDeclaredWriters, x as RichTextEntryLinkOf, y as RichTextEntryLinkOption, j as RichTextHtmlDeclaredWriters, k as RichTextHtmlFieldOption, l as RichTextHtmlOptions, z as RichTextInlineOf, m as RichTextMarkdownOptions, A as RichTextNodeContext, B as RichTextRenderable, C as RichTextRenderableOf, D as RichTextReplaceableNode, E as RichTextTag, F as RichTextTarget, e as entryHeadingAnchors, g as escapeHtml, o as isDeclaredRichTextNode, p as renderRichText, d as richTextHeadingAnchors, f as richTextHeadingSlug, h as richTextToHtml, i as richTextToMarkdown, s as safeRichTextHref } from '../index-8DozAWsA.js';
|
|
2
|
+
import '../rich-text.d-BWc-5gX1.js';
|
|
3
|
+
import '../include-paths-Cb7iPCW2.js';
|
package/dist/rich-text/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RICH_TEXT_VOID_TAGS, renderRichText, richTextToHtml, richTextToMarkdown, safeRichTextHref } from '../chunk-
|
|
1
|
+
export { RICH_TEXT_VOID_TAGS, entryHeadingAnchors, escapeHtml, isDeclaredRichTextNode, renderRichText, richTextHeadingAnchors, richTextHeadingSlug, richTextToHtml, richTextToMarkdown, safeRichTextHref } from '../chunk-3NPPMGB6.js';
|
|
2
2
|
import '../chunk-XQ4QHWZE.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|