@tinacms/mdx 1.3.1 → 1.3.2
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.es.js +2231 -1307
- package/dist/index.js +15747 -11148
- package/dist/next/index.d.ts +2 -0
- package/dist/next/parse/index.d.ts +2 -0
- package/dist/next/parse/markdown.d.ts +2 -0
- package/dist/next/parse/post-processing.d.ts +3 -0
- package/dist/next/shortcodes/index.d.ts +2 -0
- package/dist/next/shortcodes/lib/factory-tag.d.ts +4 -0
- package/dist/next/shortcodes/lib/jsx-flow.d.ts +3 -0
- package/dist/next/shortcodes/lib/jsx-text.d.ts +3 -0
- package/dist/next/shortcodes/lib/syntax.d.ts +17 -0
- package/dist/next/shortcodes/lib/util.d.ts +3 -0
- package/dist/next/shortcodes/mdast/index.d.ts +106 -0
- package/dist/next/stringify/acorn.d.ts +21 -0
- package/dist/next/stringify/index.d.ts +3 -0
- package/dist/next/stringify/marks.d.ts +8 -0
- package/dist/next/stringify/pre-processing.d.ts +9 -0
- package/dist/next/stringify/to-markdown.d.ts +3 -0
- package/dist/next/tests/block-level-1/field.d.ts +2 -0
- package/dist/next/tests/block-level-2/field.d.ts +2 -0
- package/dist/next/tests/block-level-2/index.test.d.ts +1 -0
- package/dist/next/tests/block-level-3/field.d.ts +2 -0
- package/dist/next/tests/block-level-3/index.test.d.ts +1 -0
- package/dist/next/tests/block-level-nested/field.d.ts +2 -0
- package/dist/next/tests/block-level-nested/index.test.d.ts +1 -0
- package/dist/next/tests/block-level-unclosed/field.d.ts +2 -0
- package/dist/next/tests/block-level-unclosed/index.test.d.ts +1 -0
- package/dist/next/tests/expressions-in-text/field.d.ts +2 -0
- package/dist/next/tests/expressions-in-text/index.test.d.ts +1 -0
- package/dist/next/tests/image-callback/field.d.ts +2 -0
- package/dist/next/tests/image-callback/index.test.d.ts +1 -0
- package/dist/next/tests/inline/field.d.ts +2 -0
- package/dist/next/tests/inline/index.test.d.ts +1 -0
- package/dist/next/tests/inline-with-children/field.d.ts +2 -0
- package/dist/next/tests/inline-with-children/index.test.d.ts +1 -0
- package/dist/next/tests/invalid/field.d.ts +2 -0
- package/dist/next/tests/invalid/index.test.d.ts +1 -0
- package/dist/next/tests/invalid-2/field.d.ts +2 -0
- package/dist/next/tests/invalid-2/index.test.d.ts +1 -0
- package/dist/next/tests/invalid-3/field.d.ts +2 -0
- package/dist/next/tests/invalid-3/index.test.d.ts +1 -0
- package/dist/next/tests/invalid-4/field.d.ts +2 -0
- package/dist/next/tests/invalid-4/index.test.d.ts +1 -0
- package/dist/next/tests/lists/field.d.ts +2 -0
- package/dist/next/tests/lists/index.test.d.ts +1 -0
- package/dist/next/tests/markdoc/field.d.ts +2 -0
- package/dist/next/tests/markdoc/index.test.d.ts +1 -0
- package/dist/next/tests/unrecognized-shortcodes/field.d.ts +2 -0
- package/dist/next/tests/unrecognized-shortcodes/index.test.d.ts +1 -0
- package/dist/next/tests/util.d.ts +4 -0
- package/dist/next/tests/wordpress-style/field.d.ts +2 -0
- package/dist/next/tests/wordpress-style/index.test.d.ts +1 -0
- package/dist/next/tests/wordpress-style-2/field.d.ts +2 -0
- package/dist/next/tests/wordpress-style-2/index.test.d.ts +1 -0
- package/dist/next/tests/wordpress-style-2-block-with-children/field.d.ts +2 -0
- package/dist/next/tests/wordpress-style-2-block-with-children/index.test.d.ts +1 -0
- package/dist/next/tests/wordpress-style-2-with-children/field.d.ts +2 -0
- package/dist/next/tests/wordpress-style-2-with-children/index.test.d.ts +1 -0
- package/dist/next/util.d.ts +3 -0
- package/dist/parse/acorn.d.ts +2 -2
- package/dist/parse/index.d.ts +3 -3
- package/dist/parse/mdx.d.ts +4 -4
- package/dist/parse/parseShortcode.d.ts +2 -4
- package/dist/parse/remarkToPlate.d.ts +2 -2
- package/dist/stringify/acorn.d.ts +4 -4
- package/dist/stringify/index.d.ts +5 -5
- package/dist/stringify/marks.d.ts +2 -2
- package/dist/stringify/stringifyShortcode.d.ts +2 -4
- package/dist/tests/autotest/_config.d.ts +2 -2
- package/dist/tests/setup.d.ts +4 -4
- package/package.json +53 -47
- /package/dist/{tests/temp/shortcodes.test.d.ts → next/tests/block-level-1/index.test.d.ts} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TokenizeContext, Effects, State } from 'micromark-util-types';
|
|
2
|
+
import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
|
|
3
|
+
import { Pattern } from './syntax';
|
|
4
|
+
export declare function factoryTag(this: TokenizeContext, effects: Effects, ok: State, nok: State, acorn: Acorn | undefined, acornOptions: AcornOptions | undefined, addResult: boolean | undefined, allowLazy: boolean | undefined, tagType: string, tagMarkerType: string, tagClosingMarkerType: string, tagSelfClosingMarker: string, tagNameType: string, tagNamePrimaryType: string, tagNameMemberMarkerType: string, tagNameMemberType: string, tagNamePrefixMarkerType: string, tagNameLocalType: string, tagExpressionAttributeType: string, tagExpressionAttributeMarkerType: string, tagExpressionAttributeValueType: string, tagAttributeType: string, tagAttributeNameType: string, tagAttributeNamePrimaryType: string, tagAttributeNamePrefixMarkerType: string, tagAttributeNameLocalType: string, tagAttributeInitializerMarkerType: string, tagAttributeValueLiteralType: string, tagAttributeValueLiteralMarkerType: string, tagAttributeValueLiteralValueType: string, tagAttributeValueExpressionType: string, tagAttributeValueExpressionMarkerType: string, tagAttributeValueExpressionValueType: string, pattern: Pattern): State;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Construct } from 'micromark-util-types';
|
|
2
|
+
import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
|
|
3
|
+
export declare const jsxFlow: (acorn: Acorn | undefined, acornOptions: AcornOptions | undefined, addResult: boolean | undefined, pattern: any) => Construct;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Construct } from 'micromark-util-types';
|
|
2
|
+
import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
|
|
3
|
+
export declare const jsxText: (acorn: Acorn | undefined, acornOptions: AcornOptions | undefined, addResult: boolean | undefined, pattern: any) => Construct;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Extension } from 'micromark-util-types';
|
|
2
|
+
import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
|
|
3
|
+
export declare type Pattern = {
|
|
4
|
+
start: string;
|
|
5
|
+
end: string;
|
|
6
|
+
name: string;
|
|
7
|
+
templateName: string;
|
|
8
|
+
type: 'inline' | 'flow';
|
|
9
|
+
leaf: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare type Options = {
|
|
12
|
+
acorn?: Acorn;
|
|
13
|
+
acornOptions?: AcornOptions;
|
|
14
|
+
patterns?: Pattern[];
|
|
15
|
+
addResult?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function mdxJsx(options?: Options): Extension;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Pattern } from '../lib/syntax';
|
|
2
|
+
import type { Handle as FromMarkdownHandle } from 'mdast-util-from-markdown';
|
|
3
|
+
import type { Handle as ToMarkdownHandle, Options } from 'mdast-util-to-markdown';
|
|
4
|
+
export declare function mdxJsxFromMarkdown({ patterns }: {
|
|
5
|
+
patterns: Pattern[];
|
|
6
|
+
}): {
|
|
7
|
+
canContainEols: string[];
|
|
8
|
+
enter: {
|
|
9
|
+
mdxJsxFlowTag: FromMarkdownHandle;
|
|
10
|
+
mdxJsxFlowTagClosingMarker: FromMarkdownHandle;
|
|
11
|
+
mdxJsxFlowTagAttribute: FromMarkdownHandle;
|
|
12
|
+
mdxJsxFlowTagExpressionAttribute: FromMarkdownHandle;
|
|
13
|
+
mdxJsxFlowTagAttributeValueLiteral: FromMarkdownHandle;
|
|
14
|
+
mdxJsxFlowTagAttributeValueExpression: FromMarkdownHandle;
|
|
15
|
+
mdxJsxFlowTagSelfClosingMarker: FromMarkdownHandle;
|
|
16
|
+
mdxJsxTextTag: FromMarkdownHandle;
|
|
17
|
+
mdxJsxTextTagClosingMarker: FromMarkdownHandle;
|
|
18
|
+
mdxJsxTextTagAttribute: FromMarkdownHandle;
|
|
19
|
+
mdxJsxTextTagExpressionAttribute: FromMarkdownHandle;
|
|
20
|
+
mdxJsxTextTagAttributeValueLiteral: FromMarkdownHandle;
|
|
21
|
+
mdxJsxTextTagAttributeValueExpression: FromMarkdownHandle;
|
|
22
|
+
mdxJsxTextTagSelfClosingMarker: FromMarkdownHandle;
|
|
23
|
+
};
|
|
24
|
+
exit: {
|
|
25
|
+
mdxJsxFlowTagClosingMarker: FromMarkdownHandle;
|
|
26
|
+
mdxJsxFlowTagNamePrimary: FromMarkdownHandle;
|
|
27
|
+
mdxJsxFlowTagNameMember: FromMarkdownHandle;
|
|
28
|
+
mdxJsxFlowTagNameLocal: FromMarkdownHandle;
|
|
29
|
+
mdxJsxFlowTagExpressionAttribute: FromMarkdownHandle;
|
|
30
|
+
mdxJsxFlowTagExpressionAttributeValue: FromMarkdownHandle;
|
|
31
|
+
mdxJsxFlowTagAttributeNamePrimary: FromMarkdownHandle;
|
|
32
|
+
mdxJsxFlowTagAttributeNameLocal: FromMarkdownHandle;
|
|
33
|
+
mdxJsxFlowTagAttributeValueLiteral: FromMarkdownHandle;
|
|
34
|
+
mdxJsxFlowTagAttributeValueLiteralValue: FromMarkdownHandle;
|
|
35
|
+
mdxJsxFlowTagAttributeValueExpression: FromMarkdownHandle;
|
|
36
|
+
mdxJsxFlowTagAttributeValueExpressionValue: FromMarkdownHandle;
|
|
37
|
+
mdxJsxFlowTagSelfClosingMarker: FromMarkdownHandle;
|
|
38
|
+
mdxJsxFlowTag: FromMarkdownHandle;
|
|
39
|
+
mdxJsxTextTagClosingMarker: FromMarkdownHandle;
|
|
40
|
+
mdxJsxTextTagNamePrimary: FromMarkdownHandle;
|
|
41
|
+
mdxJsxTextTagNameMember: FromMarkdownHandle;
|
|
42
|
+
mdxJsxTextTagNameLocal: FromMarkdownHandle;
|
|
43
|
+
mdxJsxTextTagExpressionAttribute: FromMarkdownHandle;
|
|
44
|
+
mdxJsxTextTagExpressionAttributeValue: FromMarkdownHandle;
|
|
45
|
+
mdxJsxTextTagAttributeNamePrimary: FromMarkdownHandle;
|
|
46
|
+
mdxJsxTextTagAttributeNameLocal: FromMarkdownHandle;
|
|
47
|
+
mdxJsxTextTagAttributeValueLiteral: FromMarkdownHandle;
|
|
48
|
+
mdxJsxTextTagAttributeValueLiteralValue: FromMarkdownHandle;
|
|
49
|
+
mdxJsxTextTagAttributeValueExpression: FromMarkdownHandle;
|
|
50
|
+
mdxJsxTextTagAttributeValueExpressionValue: FromMarkdownHandle;
|
|
51
|
+
mdxJsxTextTagSelfClosingMarker: FromMarkdownHandle;
|
|
52
|
+
mdxJsxTextTag: FromMarkdownHandle;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Create an extension for `mdast-util-to-markdown` to enable MDX JSX.
|
|
57
|
+
*
|
|
58
|
+
* This extension configures `mdast-util-to-markdown` with
|
|
59
|
+
* `options.fences: true` and `options.resourceLink: true` too, do not
|
|
60
|
+
* overwrite them!
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
export declare const mdxJsxToMarkdown: (options: Options & {
|
|
64
|
+
printWidth?: number;
|
|
65
|
+
quoteSmart?: boolean;
|
|
66
|
+
tightSelfClosing?: boolean;
|
|
67
|
+
patterns: Pattern[];
|
|
68
|
+
}) => {
|
|
69
|
+
handlers: {
|
|
70
|
+
mdxJsxFlowElement: ToMarkdownHandle;
|
|
71
|
+
mdxJsxTextElement: ToMarkdownHandle;
|
|
72
|
+
};
|
|
73
|
+
unsafe: ({
|
|
74
|
+
character: string;
|
|
75
|
+
inConstruct: "phrasing"[];
|
|
76
|
+
atBreak?: undefined;
|
|
77
|
+
} | {
|
|
78
|
+
atBreak: boolean;
|
|
79
|
+
character: string;
|
|
80
|
+
inConstruct?: undefined;
|
|
81
|
+
})[];
|
|
82
|
+
fences: boolean;
|
|
83
|
+
resourceLink: boolean;
|
|
84
|
+
bullet?: "-" | "*" | "+" | null | undefined;
|
|
85
|
+
bulletOther?: "-" | "*" | "+" | null | undefined;
|
|
86
|
+
bulletOrdered?: ")" | "." | null | undefined;
|
|
87
|
+
bulletOrderedOther?: ")" | "." | null | undefined;
|
|
88
|
+
closeAtx?: boolean | null | undefined;
|
|
89
|
+
emphasis?: "*" | "_" | null | undefined;
|
|
90
|
+
fence?: "`" | "~" | null | undefined;
|
|
91
|
+
incrementListMarker?: boolean | null | undefined;
|
|
92
|
+
listItemIndent?: "tab" | "one" | "mixed" | null | undefined;
|
|
93
|
+
quote?: "\"" | "'" | null | undefined;
|
|
94
|
+
rule?: "-" | "*" | "_" | null | undefined;
|
|
95
|
+
ruleRepetition?: number | null | undefined;
|
|
96
|
+
ruleSpaces?: boolean | null | undefined;
|
|
97
|
+
setext?: boolean | null | undefined;
|
|
98
|
+
strong?: "*" | "_" | null | undefined;
|
|
99
|
+
tightDefinitions?: boolean | null | undefined;
|
|
100
|
+
join?: import("mdast-util-to-markdown").Join[] | null | undefined;
|
|
101
|
+
extensions?: Options[] | null | undefined;
|
|
102
|
+
printWidth?: number | undefined;
|
|
103
|
+
quoteSmart?: boolean | undefined;
|
|
104
|
+
tightSelfClosing?: boolean | undefined;
|
|
105
|
+
patterns: Pattern[];
|
|
106
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
2
|
+
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
3
|
+
import * as Plate from '../../parse/plate';
|
|
4
|
+
import type * as Md from 'mdast';
|
|
5
|
+
export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, field: RichTextField, imageCallback: (url: string) => string) => {
|
|
6
|
+
attributes: MdxJsxAttribute[];
|
|
7
|
+
children: Md.PhrasingContent[];
|
|
8
|
+
};
|
|
9
|
+
export declare function stringifyProps(element: Plate.MdxInlineElement, parentField: RichTextField, flatten: boolean, imageCallback: (url: string) => string): {
|
|
10
|
+
attributes: MdxJsxAttribute[];
|
|
11
|
+
children: Md.PhrasingContent[];
|
|
12
|
+
useDirective: boolean;
|
|
13
|
+
directiveType: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function stringifyProps(element: Plate.MdxBlockElement, parentField: RichTextField, flatten: boolean, imageCallback: (url: string) => string): {
|
|
16
|
+
attributes: MdxJsxAttribute[];
|
|
17
|
+
children: Md.BlockContent[];
|
|
18
|
+
useDirective: boolean;
|
|
19
|
+
directiveType: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function assertShape<T extends unknown>(value: unknown, callback: (item: any) => boolean, errorMessage?: string): asserts value is T;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as Md from 'mdast';
|
|
2
|
+
import type * as Plate from '../../parse/plate';
|
|
3
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
4
|
+
declare type InlineElementWithCallback = Plate.InlineElement & {
|
|
5
|
+
linkifyTextNode?: (arg: Md.Text) => Md.Link;
|
|
6
|
+
};
|
|
7
|
+
export declare const eat: (c: InlineElementWithCallback[], field: RichTextField, imageCallback: (url: string) => string) => Md.PhrasingContent[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RichTextField } from '@tinacms/schema-tools';
|
|
2
|
+
import type * as Md from 'mdast';
|
|
3
|
+
import type * as Plate from '../../parse/plate';
|
|
4
|
+
import type { RootElement } from '../../parse/plate';
|
|
5
|
+
export declare const preProcess: (tree: RootElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Root;
|
|
6
|
+
export declare const rootElement: (content: Plate.RootElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Root;
|
|
7
|
+
export declare const blockElement: (content: Plate.BlockElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Content | null;
|
|
8
|
+
export declare type Marks = 'strong' | 'emphasis' | 'inlineCode';
|
|
9
|
+
export declare const getMarks: (content: Plate.InlineElement) => Marks[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/parse/acorn.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
6
|
import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
|
7
|
-
import type {
|
|
8
|
-
export declare const extractAttributes: (attributes: (MdxJsxAttribute | MdxJsxExpressionAttribute)[], fields:
|
|
7
|
+
import type { TinaField } from '@tinacms/schema-tools';
|
|
8
|
+
export declare const extractAttributes: (attributes: (MdxJsxAttribute | MdxJsxExpressionAttribute)[], fields: TinaField[], imageCallback: (image: string) => string) => Record<string, unknown>;
|
|
9
9
|
export declare const trimFragments: (string: string) => string;
|
package/dist/parse/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
6
|
import { RichTextParseError } from './remarkToPlate';
|
|
7
|
-
import type {
|
|
7
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
8
8
|
import type * as Plate from './plate';
|
|
9
9
|
/**
|
|
10
10
|
* ### Convert the MDXAST into an API-friendly format
|
|
@@ -55,10 +55,10 @@ import type * as Plate from './plate';
|
|
|
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: RichTextType) => 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/editing/mdx/#differences-from-other-mdx-implementations";
|
|
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/editing/mdx/#differences-from-other-mdx-implementations\" target=\"_blank\" rel=\"noopener noreferrer\">Learn More</a>";
|
|
62
|
-
export declare const parseMDX: (value: string, field:
|
|
62
|
+
export declare const parseMDX: (value: string, field: RichTextType, 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
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
6
|
import type { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
7
|
-
import type {
|
|
7
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
8
8
|
import type * as Plate from './plate';
|
|
9
9
|
import { ContainerDirective } from 'mdast-util-directive';
|
|
10
10
|
import { LeafDirective } from 'mdast-util-directive/lib';
|
|
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: RichTextType, imageCallback: (url: string) => string): Plate.MdxInlineElement;
|
|
12
|
+
export declare function mdxJsxElement(node: MdxJsxFlowElement, field: RichTextType, imageCallback: (url: string) => string): Plate.MdxBlockElement;
|
|
13
|
+
export declare const directiveElement: (node: ContainerDirective | LeafDirective, field: RichTextType, imageCallback: (url: string) => string, raw?: string | undefined) => Plate.BlockElement | Plate.ParagraphElement;
|
|
@@ -3,7 +3,5 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
export declare function parseShortcode(preprocessedString: string, template:
|
|
8
|
-
inline?: boolean;
|
|
9
|
-
}): string;
|
|
6
|
+
import { RichTextTemplate } from '@tinacms/schema-tools';
|
|
7
|
+
export declare function parseShortcode(preprocessedString: string, template: RichTextTemplate): string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type * as Md from 'mdast';
|
|
7
7
|
import type * as Plate from './plate';
|
|
8
|
-
import type {
|
|
8
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
9
9
|
import type { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
10
10
|
import { ContainerDirective } from 'mdast-util-directive';
|
|
11
11
|
export type { Position, PositionItem } from './plate';
|
|
@@ -23,7 +23,7 @@ declare module 'mdast' {
|
|
|
23
23
|
mdxJsxFlowElement: MdxJsxFlowElement;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field:
|
|
26
|
+
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field: RichTextType, imageCallback: (url: string) => string, raw?: string | undefined, skipMDXProcess?: boolean | undefined) => Plate.RootElement;
|
|
27
27
|
export declare class RichTextParseError extends Error {
|
|
28
28
|
position?: Plate.Position;
|
|
29
29
|
constructor(message: string, position?: Plate.Position);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
2
2
|
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
3
3
|
import * as Plate from '../parse/plate';
|
|
4
4
|
import type * as Md from 'mdast';
|
|
5
|
-
export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, field:
|
|
5
|
+
export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, field: RichTextType, imageCallback: (url: string) => string) => {
|
|
6
6
|
attributes: MdxJsxAttribute[];
|
|
7
7
|
children: Md.PhrasingContent[];
|
|
8
8
|
};
|
|
9
|
-
export declare function stringifyProps(element: Plate.MdxInlineElement, parentField:
|
|
9
|
+
export declare function stringifyProps(element: Plate.MdxInlineElement, parentField: RichTextType, flatten: boolean, imageCallback: (url: string) => string): {
|
|
10
10
|
attributes: MdxJsxAttribute[];
|
|
11
11
|
children: Md.PhrasingContent[];
|
|
12
12
|
useDirective: boolean;
|
|
13
13
|
directiveType: string;
|
|
14
14
|
};
|
|
15
|
-
export declare function stringifyProps(element: Plate.MdxBlockElement, parentField:
|
|
15
|
+
export declare function stringifyProps(element: Plate.MdxBlockElement, parentField: RichTextType, flatten: boolean, imageCallback: (url: string) => string): {
|
|
16
16
|
attributes: MdxJsxAttribute[];
|
|
17
17
|
children: Md.BlockContent[];
|
|
18
18
|
useDirective: boolean;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
6
|
import { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
7
|
-
import type {
|
|
7
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
8
8
|
import type * as Md from 'mdast';
|
|
9
9
|
import type * as Plate from '../parse/plate';
|
|
10
10
|
declare module 'mdast' {
|
|
@@ -21,7 +21,7 @@ declare module 'mdast' {
|
|
|
21
21
|
mdxJsxFlowElement: MdxJsxFlowElement;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
export declare const stringifyMDX: (value: Plate.RootElement, field:
|
|
24
|
+
export declare const stringifyMDX: (value: Plate.RootElement, field: RichTextType, imageCallback: (url: string) => string) => string | undefined;
|
|
25
25
|
export declare type Pattern = {
|
|
26
26
|
start: string;
|
|
27
27
|
end: string;
|
|
@@ -29,8 +29,8 @@ export declare type Pattern = {
|
|
|
29
29
|
templateName: string;
|
|
30
30
|
type: 'block' | 'leaf';
|
|
31
31
|
};
|
|
32
|
-
export declare const toTinaMarkdown: (tree: Md.Root, field:
|
|
33
|
-
export declare const rootElement: (content: Plate.RootElement, field:
|
|
34
|
-
export declare const blockElement: (content: Plate.BlockElement, field:
|
|
32
|
+
export declare const toTinaMarkdown: (tree: Md.Root, field: RichTextType) => string;
|
|
33
|
+
export declare const rootElement: (content: Plate.RootElement, field: RichTextType, imageCallback: (url: string) => string) => Md.Root;
|
|
34
|
+
export declare const blockElement: (content: Plate.BlockElement, field: RichTextType, imageCallback: (url: string) => string) => Md.Content | null;
|
|
35
35
|
export declare type Marks = 'strong' | 'emphasis' | 'inlineCode';
|
|
36
36
|
export declare const getMarks: (content: Plate.InlineElement) => Marks[];
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type * as Md from 'mdast';
|
|
7
7
|
import type * as Plate from '../parse/plate';
|
|
8
|
-
import type {
|
|
8
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
9
9
|
declare 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: RichTextType, imageCallback: (url: string) => string) => Md.PhrasingContent[];
|
|
13
13
|
export {};
|
|
@@ -3,7 +3,5 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
export declare function stringifyShortcode(preprocessedString: string, template:
|
|
8
|
-
inline?: boolean;
|
|
9
|
-
}): string;
|
|
6
|
+
import { RichTextTemplate } from '@tinacms/schema-tools';
|
|
7
|
+
export declare function stringifyShortcode(preprocessedString: string, template: RichTextTemplate): string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
7
7
|
export { output } from '../setup';
|
|
8
8
|
export { parseMDX, stringifyMDX } from '../..';
|
|
9
|
-
export declare const field:
|
|
9
|
+
export declare const field: RichTextType;
|
package/dist/tests/setup.d.ts
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { RichTextType } from '@tinacms/schema-tools';
|
|
7
7
|
import type { BlockElement, RootElement } from '../parse/plate';
|
|
8
|
-
export type { BlockElement,
|
|
8
|
+
export type { BlockElement, RichTextType };
|
|
9
9
|
export declare const output: (object: RootElement) => RootElement;
|
|
10
10
|
export declare const print: (ast: object, name: string, autoformatted?: boolean | undefined) => string;
|
|
11
|
-
export declare const run: (dirname: string, content: any, outputString: any, field:
|
|
11
|
+
export declare const run: (dirname: string, content: any, outputString: any, field: RichTextType) => void;
|
|
12
12
|
declare type GlobFile = Record<string, () => Promise<string>>;
|
|
13
13
|
export declare const setupNewTests: (markdownContentFiles: GlobFile, testFiles: GlobFile, callback: (newTests: {
|
|
14
14
|
name: string;
|
|
15
15
|
markdownContent: () => Promise<string>;
|
|
16
16
|
}) => void) => void;
|
|
17
|
-
export declare const runInner: (name: string, dirname: string, content: string, outputString: Record<string, string>, field:
|
|
17
|
+
export declare const runInner: (name: string, dirname: string, content: string, outputString: Record<string, string>, field: RichTextType) => void;
|
|
18
18
|
export declare const writeTestFile: (dirname: string, name: string, astResult: object, autoformatted?: boolean | undefined) => void;
|
|
19
19
|
export declare const writeAutoformatFile: (dirname: string, name: string, stringResult: string) => void;
|