@tinacms/mdx 1.1.1 → 1.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.
Files changed (30) hide show
  1. package/LICENSE +8 -0
  2. package/dist/extensions/tina-shortcodes/extension.d.ts +3 -0
  3. package/dist/extensions/tina-shortcodes/factory-attributes.d.ts +2 -0
  4. package/dist/extensions/tina-shortcodes/factory-name.d.ts +2 -0
  5. package/dist/extensions/tina-shortcodes/from-markdown.d.ts +2 -0
  6. package/dist/extensions/tina-shortcodes/shortcode-container.d.ts +3 -0
  7. package/dist/extensions/tina-shortcodes/shortcode-leaf.d.ts +5 -0
  8. package/dist/extensions/tina-shortcodes/to-markdown.d.ts +3 -0
  9. package/dist/index.d.ts +0 -12
  10. package/dist/index.es.js +2262 -0
  11. package/dist/index.js +10948 -6057
  12. package/dist/parse/acorn.d.ts +0 -12
  13. package/dist/parse/index.d.ts +2 -14
  14. package/dist/parse/mdx.d.ts +3 -12
  15. package/dist/parse/parseShortcode.d.ts +0 -12
  16. package/dist/parse/plate.d.ts +0 -12
  17. package/dist/parse/remarkToPlate.d.ts +2 -13
  18. package/dist/stringify/acorn.d.ts +4 -0
  19. package/dist/stringify/index.d.ts +8 -12
  20. package/dist/stringify/marks.d.ts +0 -12
  21. package/dist/stringify/stringifyShortcode.d.ts +0 -12
  22. package/dist/tests/autotest/_config.d.ts +0 -12
  23. package/dist/tests/setup.d.ts +0 -12
  24. package/dist/tests/{autotest → temp}/shortcodes.test.d.ts +0 -0
  25. package/package.json +48 -3
  26. package/dist/tests/autotest/invalid mdx with a closing tag.test.d.ts +0 -1
  27. package/dist/tests/autotest/invalid mdx with a const expression.test.d.ts +0 -1
  28. package/dist/tests/autotest/invalid mdx with an expression {{}}.test.d.ts +0 -1
  29. package/dist/tests/autotest/invalid mdx with an expression.test.d.ts +0 -1
  30. package/dist/tests/autotest/invalid mdx with an import statement.test.d.ts +0 -1
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
@@ -1,23 +1,10 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import { RichTextParseError } from './remarkToPlate';
19
7
  import type { RichTypeInner } from '@tinacms/schema-tools';
20
- import type * as Md from 'mdast';
21
8
  import type * as Plate from './plate';
22
9
  /**
23
10
  * ### Convert the MDXAST into an API-friendly format
@@ -68,7 +55,8 @@ import type * as Plate from './plate';
68
55
  * 2. We don't need to do any client-side parsing. Since TinaMarkdown and the slate editor work with the same
69
56
  * format we can just allow Tina to do it's thing and update the form value with no additional work.
70
57
  */
71
- export declare const markdownToAst: (value: string, field: RichTypeInner) => Md.Root;
58
+ export declare const markdownToAst: (value: string, field: RichTypeInner) => import("mdast").Root;
59
+ export declare const mdxToAst: (value: string) => import("mdast").Root;
72
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";
73
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>";
74
62
  export declare const parseMDX: (value: string, field: RichTypeInner, imageCallback: (s: string) => string) => Plate.RootElement;
@@ -1,22 +1,13 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import type { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
19
7
  import type { RichTypeInner } from '@tinacms/schema-tools';
20
8
  import type * as Plate from './plate';
9
+ import { ContainerDirective } from 'mdast-util-directive';
10
+ import { LeafDirective } from 'mdast-util-directive/lib';
21
11
  export declare function mdxJsxElement(node: MdxJsxTextElement, field: RichTypeInner, imageCallback: (url: string) => string): Plate.MdxInlineElement;
22
12
  export declare function mdxJsxElement(node: MdxJsxFlowElement, field: RichTypeInner, imageCallback: (url: string) => string): Plate.MdxBlockElement;
13
+ export declare const directiveElement: (node: ContainerDirective | LeafDirective, field: RichTypeInner, imageCallback: (url: string) => string, raw?: string | undefined) => Plate.BlockElement | Plate.ParagraphElement;
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import { Template } from '@tinacms/schema-tools';
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  /**
@@ -1,24 +1,13 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import type * as Md from 'mdast';
19
7
  import type * as Plate from './plate';
20
8
  import type { RichTypeInner } from '@tinacms/schema-tools';
21
9
  import type { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
10
+ import { ContainerDirective } from 'mdast-util-directive';
22
11
  export type { Position, PositionItem } from './plate';
23
12
  declare module 'mdast' {
24
13
  interface StaticPhrasingContentMap {
@@ -34,7 +23,7 @@ declare module 'mdast' {
34
23
  mdxJsxFlowElement: MdxJsxFlowElement;
35
24
  }
36
25
  }
37
- export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement, field: RichTypeInner, imageCallback: (url: string) => string) => Plate.RootElement;
26
+ export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field: RichTypeInner, imageCallback: (url: string) => string, raw?: string | undefined) => Plate.RootElement;
38
27
  export declare class RichTextParseError extends Error {
39
28
  position?: Plate.Position;
40
29
  constructor(message: string, position?: Plate.Position);
@@ -9,9 +9,13 @@ export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, fie
9
9
  export declare function stringifyProps(element: Plate.MdxInlineElement, parentField: RichTypeInner, flatten: boolean, imageCallback: (url: string) => string): {
10
10
  attributes: MdxJsxAttribute[];
11
11
  children: Md.PhrasingContent[];
12
+ useDirective: boolean;
13
+ directiveType: string;
12
14
  };
13
15
  export declare function stringifyProps(element: Plate.MdxBlockElement, parentField: RichTypeInner, flatten: boolean, imageCallback: (url: string) => string): {
14
16
  attributes: MdxJsxAttribute[];
15
17
  children: Md.BlockContent[];
18
+ useDirective: boolean;
19
+ directiveType: string;
16
20
  };
17
21
  export declare function assertShape<T extends unknown>(value: unknown, callback: (item: any) => boolean, errorMessage?: string): asserts value is T;
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
@@ -34,6 +22,14 @@ declare module 'mdast' {
34
22
  }
35
23
  }
36
24
  export declare const stringifyMDX: (value: Plate.RootElement, field: RichTypeInner, imageCallback: (url: string) => string) => string | undefined;
25
+ export declare type Pattern = {
26
+ start: string;
27
+ end: string;
28
+ name: string;
29
+ templateName: string;
30
+ type: 'block' | 'leaf';
31
+ };
32
+ export declare const toTinaMarkdown: (tree: Md.Root, field: RichTypeInner) => string;
37
33
  export declare const rootElement: (content: Plate.RootElement, field: RichTypeInner, imageCallback: (url: string) => string) => Md.Root;
38
34
  export declare const blockElement: (content: Plate.BlockElement, field: RichTypeInner, imageCallback: (url: string) => string) => Md.Content | null;
39
35
  export declare type Marks = 'strong' | 'emphasis' | 'inlineCode';
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import type * as Md from 'mdast';
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import { Template } from '@tinacms/schema-tools';
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import type { RichTypeInner } from '@tinacms/schema-tools';
@@ -1,18 +1,6 @@
1
1
  /**
2
2
 
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
3
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
4
 
17
5
  */
18
6
  import type { RichTypeInner } from '@tinacms/schema-tools';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/mdx",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "typings": "dist/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -8,6 +8,10 @@
8
8
  "package.json",
9
9
  "dist"
10
10
  ],
11
+ "exports": {
12
+ "import": "./dist/index.es.js",
13
+ "require": "./dist/index.js"
14
+ },
11
15
  "license": "Apache-2.0",
12
16
  "buildConfig": {
13
17
  "entryPoints": [
@@ -19,18 +23,50 @@
19
23
  ]
20
24
  },
21
25
  "dependencies": {
22
- "@tinacms/schema-tools": "1.2.1",
26
+ "@tinacms/schema-tools": "1.3.1",
27
+ "@types/mdast": "^3.0.10",
28
+ "@types/unist": "^2.0.6",
23
29
  "acorn": "^8.7.1",
24
30
  "concat-md": "^0.5.0",
25
31
  "lodash-es": "^4.17.21",
32
+ "mdast": "^3.0.0",
33
+ "mdast-util-directive": "^2.2.2",
34
+ "mdast-util-from-markdown": "^1.3.0",
35
+ "mdast-util-frontmatter": "^1.0.0",
36
+ "mdast-util-gfm": "^2.0.1",
37
+ "mdast-util-gfm-table": "^1.0.6",
38
+ "mdast-util-mdx": "2.0.0",
26
39
  "mdast-util-mdx-jsx": "^2.0.1",
27
40
  "mdast-util-to-markdown": "^1.3.0",
41
+ "mdast-util-toc": "^6.1.0",
42
+ "micromark": "^3.1.0",
43
+ "micromark-core-commonmark": "^1.0.6",
44
+ "micromark-extension-directive": "^2.1.2",
45
+ "micromark-extension-frontmatter": "^1.0.0",
46
+ "micromark-extension-gfm": "^2.0.1",
47
+ "micromark-extension-mdx": "1.0.0",
48
+ "micromark-extension-mdx-jsx": "1.0.3",
49
+ "micromark-extension-mdxjs": "1.0.0",
50
+ "micromark-factory-space": "^1.0.0",
51
+ "micromark-factory-whitespace": "^1.0.0",
52
+ "micromark-util-character": "^1.1.0",
53
+ "micromark-util-chunked": "^1.0.0",
54
+ "micromark-util-classify-character": "^1.0.0",
55
+ "micromark-util-normalize-identifier": "^1.0.0",
56
+ "micromark-util-resolve-all": "^1.0.0",
57
+ "micromark-util-symbol": "^1.0.1",
58
+ "micromark-util-types": "^1.0.2",
59
+ "parse-entities": "^4.0.0",
28
60
  "prettier": "^2.7.1",
29
61
  "remark": "^14.0.2",
30
62
  "remark-mdx": "^2.1.2",
63
+ "stringify-entities": "^4.0.3",
31
64
  "typedoc": "^0.23.21",
32
65
  "typedoc-plugin-markdown": "^3.13.6",
66
+ "unist-util-source": "^4.0.2",
33
67
  "unist-util-visit": "^4.1.0",
68
+ "unist-util-visit-parents": "^5.1.3",
69
+ "uvu": "^0.5.6",
34
70
  "vfile": "^4.2.0"
35
71
  },
36
72
  "publishConfig": {
@@ -43,7 +79,9 @@
43
79
  "devDependencies": {
44
80
  "@swc/core": "^1.2.210",
45
81
  "@swc/jest": "^0.2.21",
46
- "@tinacms/scripts": "1.0.1",
82
+ "@tailwindcss/forms": "^0.5.3",
83
+ "@tailwindcss/typography": "^0.5.9",
84
+ "@tinacms/scripts": "1.0.2",
47
85
  "@types/cors": "^2.8.7",
48
86
  "@types/estree": "^0.0.50",
49
87
  "@types/estree-jsx": "^1.0.0",
@@ -56,8 +94,10 @@
56
94
  "@types/node": "^14.18.21",
57
95
  "@types/normalize-path": "^3.0.0",
58
96
  "@types/prettier": "^2.6.3",
97
+ "@types/react": "^18.0.27",
59
98
  "@types/ws": "^7.2.6",
60
99
  "@types/yup": "^0.29.7",
100
+ "@vitejs/plugin-react": "^2.1.0",
61
101
  "c8": "^7.11.3",
62
102
  "estree-jsx": "^0.0.1",
63
103
  "jest": "^28.1.2",
@@ -66,6 +106,11 @@
66
106
  "jest-matcher-utils": "^28.1.1",
67
107
  "mdast": "^3.0.0",
68
108
  "nodemon": "2.0.19",
109
+ "postcss": "^8.4.21",
110
+ "react": "^18.2.0",
111
+ "react-dom": "^18.2.0",
112
+ "react-monaco-editor": "^0.51.0",
113
+ "tailwindcss": "^3.2.4",
69
114
  "ts-node": "^10.8.2",
70
115
  "typescript": "^4.7.4",
71
116
  "vite": "^3.0.2",