@tinacms/mdx 2.2.3 → 2.3.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/dist/index.browser.js +1026 -14643
- package/dist/index.js +1030 -14647
- package/dist/parse/index.d.ts +3 -3
- package/dist/parse/mdx.d.ts +4 -4
- package/dist/parse/remarkToPlate.d.ts +2 -2
- package/dist/stringify/index.d.ts +5 -5
- package/dist/stringify/marks.d.ts +2 -2
- package/dist/stringify/print-object-literal.corpus.d.ts +12 -0
- package/dist/stringify/print-object-literal.d.ts +1 -0
- package/dist/stringify/print-object-literal.snapshot.d.ts +12 -0
- package/dist/stringify/print-object-literal.test.d.ts +1 -0
- package/package.json +6 -4
package/dist/parse/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
7
7
|
import type * as Plate from './plate';
|
|
8
8
|
import { RichTextParseError } from './remarkToPlate';
|
|
9
9
|
/**
|
|
@@ -55,10 +55,10 @@ import { RichTextParseError } from './remarkToPlate';
|
|
|
55
55
|
* 2. We don't need to do any client-side parsing. Since TinaMarkdown and the slate editor work with the same
|
|
56
56
|
* format we can just allow Tina to do it's thing and update the form value with no additional work.
|
|
57
57
|
*/
|
|
58
|
-
export declare const markdownToAst: (value: string, field:
|
|
58
|
+
export declare const markdownToAst: (value: string, field: RichTextField) => import("mdast").Root;
|
|
59
59
|
export declare const mdxToAst: (value: string) => import("mdast").Root;
|
|
60
60
|
export declare const MDX_PARSE_ERROR_MSG = "TinaCMS supports a stricter version of markdown and a subset of MDX. https://tina.io/docs/r/what-is-markdown";
|
|
61
61
|
export declare const MDX_PARSE_ERROR_MSG_HTML = "TinaCMS supports a stricter version of markdown and a subset of MDX. <a href=\"https://tina.io/docs/r/what-is-markdown\" target=\"_blank\" rel=\"noopener noreferrer\">Learn More</a>";
|
|
62
|
-
export declare const parseMDX: (value: string, field:
|
|
62
|
+
export declare const parseMDX: (value: string, field: RichTextField, imageCallback: (s: string) => string) => Plate.RootElement;
|
|
63
63
|
export declare const invalidMarkdown: (e: RichTextParseError, value: string) => Plate.RootElement;
|
|
64
64
|
export declare const replaceAll: (string: string, target: string, value: string) => string;
|
package/dist/parse/mdx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
2
2
|
import { ContainerDirective } from 'mdast-util-directive';
|
|
3
3
|
import { LeafDirective } from 'mdast-util-directive/lib';
|
|
4
4
|
/**
|
|
@@ -8,6 +8,6 @@ import { LeafDirective } from 'mdast-util-directive/lib';
|
|
|
8
8
|
*/
|
|
9
9
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
10
10
|
import type * as Plate from './plate';
|
|
11
|
-
export declare function mdxJsxElement(node: MdxJsxTextElement, field:
|
|
12
|
-
export declare function mdxJsxElement(node: MdxJsxFlowElement, field:
|
|
13
|
-
export declare const directiveElement: (node: ContainerDirective | LeafDirective, field:
|
|
11
|
+
export declare function mdxJsxElement(node: MdxJsxTextElement, field: RichTextField, imageCallback: (url: string) => string): Plate.MdxInlineElement;
|
|
12
|
+
export declare function mdxJsxElement(node: MdxJsxFlowElement, field: RichTextField, imageCallback: (url: string) => string): Plate.MdxBlockElement;
|
|
13
|
+
export declare const directiveElement: (node: ContainerDirective | LeafDirective, field: RichTextField, imageCallback: (url: string) => string, raw?: string) => Plate.BlockElement | Plate.ParagraphElement;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
7
7
|
import type * as Md from 'mdast';
|
|
8
8
|
import type { ContainerDirective } from 'mdast-util-directive';
|
|
9
9
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
@@ -24,7 +24,7 @@ declare module 'mdast' {
|
|
|
24
24
|
mdxJsxFlowElement: MdxJsxFlowElement;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field:
|
|
27
|
+
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field: RichTextField, imageCallback: (url: string) => string, raw?: string, skipMDXProcess?: boolean) => Plate.RootElement;
|
|
28
28
|
export declare class RichTextParseError extends Error {
|
|
29
29
|
position?: Plate.Position;
|
|
30
30
|
constructor(message: string, position?: Plate.Position);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
2
2
|
import type * as Md from 'mdast';
|
|
3
3
|
import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
4
4
|
import type * as Plate from '../parse/plate';
|
|
@@ -16,7 +16,7 @@ declare module 'mdast' {
|
|
|
16
16
|
mdxJsxFlowElement: MdxJsxFlowElement;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
export declare const serializeMDX: (value: Plate.RootElement, field:
|
|
19
|
+
export declare const serializeMDX: (value: Plate.RootElement, field: RichTextField, imageCallback: (url: string) => string) => string | Plate.RootElement | undefined;
|
|
20
20
|
export type Pattern = {
|
|
21
21
|
start: string;
|
|
22
22
|
end: string;
|
|
@@ -24,9 +24,9 @@ export type Pattern = {
|
|
|
24
24
|
templateName: string;
|
|
25
25
|
type: 'block' | 'leaf';
|
|
26
26
|
};
|
|
27
|
-
export declare const toTinaMarkdown: (tree: Md.Root, field:
|
|
28
|
-
export declare const rootElement: (content: Plate.RootElement, field:
|
|
27
|
+
export declare const toTinaMarkdown: (tree: Md.Root, field: RichTextField) => string;
|
|
28
|
+
export declare const rootElement: (content: Plate.RootElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Root;
|
|
29
29
|
export declare function codeLinesToString(content: Plate.CodeBlockElement): string;
|
|
30
|
-
export declare const blockElement: (content: Plate.BlockElement, field:
|
|
30
|
+
export declare const blockElement: (content: Plate.BlockElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Content | null;
|
|
31
31
|
export type Marks = 'strong' | 'emphasis' | 'inlineCode' | 'delete' | 'highlight';
|
|
32
32
|
export declare const getMarks: (content: Plate.InlineElement) => Marks[];
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
7
7
|
import type * as Md from 'mdast';
|
|
8
8
|
import type * as Plate from '../parse/plate';
|
|
9
9
|
type InlineElementWithCallback = Plate.InlineElement & {
|
|
10
10
|
linkifyTextNode?: (arg: Md.Text) => Md.Link;
|
|
11
11
|
};
|
|
12
|
-
export declare const eat: (c: InlineElementWithCallback[], field:
|
|
12
|
+
export declare const eat: (c: InlineElementWithCallback[], field: RichTextField, imageCallback: (url: string) => string) => Md.PhrasingContent[];
|
|
13
13
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The differential corpus for `printObjectLiteral`. Every case is
|
|
3
|
+
* deterministic, so the expected output of each one is recorded in
|
|
4
|
+
* `__snapshots__/print-object-literal.txt` by `pnpm snapshot:print-object-literal`.
|
|
5
|
+
* Append new cases; never reorder or rename existing ones.
|
|
6
|
+
*/
|
|
7
|
+
export type Case = {
|
|
8
|
+
name: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
};
|
|
11
|
+
export declare const corpus: Case[];
|
|
12
|
+
export declare const MINIMUM_CORPUS = 5000;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const printObjectLiteral: (value: unknown) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One record per corpus case, in corpus order. Blank lines separate records;
|
|
3
|
+
* neither a `JSON.stringify` input nor a printed object literal contains one.
|
|
4
|
+
*/
|
|
5
|
+
export type SnapshotRecord = {
|
|
6
|
+
index: number;
|
|
7
|
+
name: string;
|
|
8
|
+
input: string;
|
|
9
|
+
expected: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const formatSnapshot: (records: SnapshotRecord[]) => string;
|
|
12
|
+
export declare const parseSnapshot: (text: string) => SnapshotRecord[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/mdx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"acorn": "^8.16.0",
|
|
36
36
|
"ccount": "2.0.1",
|
|
37
|
+
"emoji-regex": "9.2.2",
|
|
37
38
|
"estree-util-is-identifier-name": "2.1.0",
|
|
39
|
+
"esutils": "2.0.3",
|
|
38
40
|
"mdast-util-compact": "4.1.1",
|
|
39
41
|
"mdast-util-directive": "2.2.4",
|
|
40
42
|
"mdast-util-from-markdown": "1.3.0",
|
|
@@ -49,7 +51,6 @@
|
|
|
49
51
|
"micromark-util-symbol": "1.0.1",
|
|
50
52
|
"micromark-util-types": "1.1.0",
|
|
51
53
|
"parse-entities": "4.0.1",
|
|
52
|
-
"prettier": "^2.8.8",
|
|
53
54
|
"remark": "14.0.2",
|
|
54
55
|
"remark-gfm": "^2.0.0",
|
|
55
56
|
"remark-mdx": "2.3.0",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"unist-util-stringify-position": "3.0.3",
|
|
59
60
|
"unist-util-visit": "4.1.2",
|
|
60
61
|
"vfile-message": "3.1.4",
|
|
61
|
-
"@tinacms/schema-tools": "^2.10.
|
|
62
|
+
"@tinacms/schema-tools": "^2.10.1"
|
|
62
63
|
},
|
|
63
64
|
"publishConfig": {
|
|
64
65
|
"registry": "https://registry.npmjs.org"
|
|
@@ -69,9 +70,9 @@
|
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@types/estree": "1.0.0",
|
|
73
|
+
"@types/esutils": "^2.0.2",
|
|
72
74
|
"@types/mdast": "^3.0.15",
|
|
73
75
|
"@types/node": "^22.13.1",
|
|
74
|
-
"@types/prettier": "^2.7.3",
|
|
75
76
|
"@types/unist": "^2.0.11",
|
|
76
77
|
"c8": "^7.14.0",
|
|
77
78
|
"jest-file-snapshot": "^0.5.0",
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"build": "tinacms-scripts build",
|
|
87
88
|
"serve": "nodemon dist/server.js",
|
|
88
89
|
"test": "vitest run",
|
|
90
|
+
"snapshot:print-object-literal": "node --experimental-strip-types scripts/generate-print-object-literal-snapshot.mjs",
|
|
89
91
|
"coverage": "vitest run --coverage",
|
|
90
92
|
"test-watch": "vitest"
|
|
91
93
|
}
|