@tinacms/mdx 2.1.10 → 2.2.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { TokenizeContext, Effects, State } from 'micromark-util-types';
2
1
  import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
2
+ import type { Effects, State, TokenizeContext } from 'micromark-util-types';
3
3
  import { Pattern } from './syntax';
4
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;
@@ -1,3 +1,3 @@
1
- import type { Construct } from 'micromark-util-types';
2
1
  import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
2
+ import type { Construct } from 'micromark-util-types';
3
3
  export declare const jsxFlow: (acorn: Acorn | undefined, acornOptions: AcornOptions | undefined, addResult: boolean | undefined, pattern: any) => Construct;
@@ -1,3 +1,3 @@
1
- import type { Construct } from 'micromark-util-types';
2
1
  import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
2
+ import type { Construct } from 'micromark-util-types';
3
3
  export declare const jsxText: (acorn: Acorn | undefined, acornOptions: AcornOptions | undefined, addResult: boolean | undefined, pattern: any) => Construct;
@@ -1,5 +1,5 @@
1
- import type { Extension } from 'micromark-util-types';
2
1
  import type { Acorn, AcornOptions } from 'micromark-factory-mdx-expression';
2
+ import type { Extension } from 'micromark-util-types';
3
3
  export type Pattern = {
4
4
  start: string;
5
5
  end: string;
@@ -1,6 +1,6 @@
1
- import { Pattern } from '../lib/syntax';
2
1
  import type { Handle as FromMarkdownHandle } from 'mdast-util-from-markdown';
3
- import type { Handle as ToMarkdownHandle, Options } from 'mdast-util-to-markdown';
2
+ import type { Options, Handle as ToMarkdownHandle } from 'mdast-util-to-markdown';
3
+ import { Pattern } from '../lib/syntax';
4
4
  export declare function mdxJsxFromMarkdown({ patterns }: {
5
5
  patterns: Pattern[];
6
6
  }): {
@@ -1,7 +1,7 @@
1
1
  import type { RichTextField } from '@tinacms/schema-tools';
2
+ import type * as Md from 'mdast';
2
3
  import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
3
4
  import * as Plate from '../../parse/plate';
4
- import type * as Md from 'mdast';
5
5
  export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, field: RichTextField, imageCallback: (url: string) => string) => {
6
6
  attributes: MdxJsxAttribute[];
7
7
  children: Md.PhrasingContent[];
@@ -1,6 +1,6 @@
1
+ import type { RichTextField } from '@tinacms/schema-tools';
1
2
  import type * as Md from 'mdast';
2
3
  import type * as Plate from '../../parse/plate';
3
- import type { RichTextField } from '@tinacms/schema-tools';
4
4
  type InlineElementWithCallback = Plate.InlineElement & {
5
5
  linkifyTextNode?: (arg: Md.Text) => Md.Link;
6
6
  };
@@ -1,4 +1,4 @@
1
- import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
2
1
  import type { TinaField } from '@tinacms/schema-tools';
2
+ import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
3
3
  export declare const extractAttributes: (attributes: (MdxJsxAttribute | MdxJsxExpressionAttribute)[], fields: TinaField[], imageCallback: (image: string) => string) => Record<string, unknown>;
4
4
  export declare const trimFragments: (string: string) => string;
@@ -1,6 +1,6 @@
1
- import type * as Plate from './plate';
2
1
  import type { PhrasingContent } from 'mdast';
3
2
  import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
3
+ import type * as Plate from './plate';
4
4
  export declare const getHighlightColorFromAttributes: (attributes?: (MdxJsxAttribute | MdxJsxExpressionAttribute)[]) => string | undefined;
5
5
  export declare const parseMarkMdxText: <TChild extends PhrasingContent = PhrasingContent>(content: MdxJsxTextElement & {
6
6
  children?: TChild[];
@@ -1,13 +1,13 @@
1
+ import type { RichTextType } from '@tinacms/schema-tools';
2
+ import { ContainerDirective } from 'mdast-util-directive';
3
+ import { LeafDirective } from 'mdast-util-directive/lib';
1
4
  /**
2
5
 
3
6
 
4
7
 
5
8
  */
6
- import type { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
7
- import type { RichTextType } from '@tinacms/schema-tools';
9
+ import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
8
10
  import type * as Plate from './plate';
9
- import { ContainerDirective } from 'mdast-util-directive';
10
- import { LeafDirective } from 'mdast-util-directive/lib';
11
11
  export declare function mdxJsxElement(node: MdxJsxTextElement, field: RichTextType, imageCallback: (url: string) => string): Plate.MdxInlineElement;
12
12
  export declare function mdxJsxElement(node: MdxJsxFlowElement, field: RichTextType, imageCallback: (url: string) => string): Plate.MdxBlockElement;
13
13
  export declare const directiveElement: (node: ContainerDirective | LeafDirective, field: RichTextType, imageCallback: (url: string) => string, raw?: string) => Plate.BlockElement | Plate.ParagraphElement;
@@ -90,6 +90,8 @@ export type ListItemChildrenElement = ListItemContentElement | UnorderedListElem
90
90
  */
91
91
  export type ListItemElement = {
92
92
  type: 'li';
93
+ /** Set only on GFM task list items. `false` is an unticked checkbox. */
94
+ checked?: boolean;
93
95
  children: ListItemChildrenElement[];
94
96
  };
95
97
  /**
@@ -7,6 +7,7 @@ import type { RichTextType } 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';
10
+ import { sanitizeUrl } from '../sanitize-url';
10
11
  import type * as Plate from './plate';
11
12
  export type { Position, PositionItem } from './plate';
12
13
  declare module 'mdast' {
@@ -28,4 +29,4 @@ export declare class RichTextParseError extends Error {
28
29
  position?: Plate.Position;
29
30
  constructor(message: string, position?: Plate.Position);
30
31
  }
31
- export declare const sanitizeUrl: (url: string | undefined) => string;
32
+ export { sanitizeUrl };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sanitizes a URL, rejecting disallowed schemes (eg. `javascript:alert(document.domain)`).
3
+ *
4
+ * This file is intentionally dependency-free — it's built as its own entry point
5
+ * (`@tinacms/mdx/sanitize-url`) so consumers that only need URL sanitization (eg.
6
+ * `tinacms`'s rich-text renderer) don't have to pull in the full remark/mdast/micromark
7
+ * markdown-parsing toolchain that the rest of `@tinacms/mdx` bundles.
8
+ */
9
+ export declare const sanitizeUrl: (url: string | undefined) => string;
@@ -0,0 +1,26 @@
1
+ const sanitizeUrl = (url) => {
2
+ const allowedSchemes = ["http", "https", "mailto", "tel", "xref"];
3
+ if (!url) return "";
4
+ let parsedUrl = null;
5
+ try {
6
+ parsedUrl = new URL(url);
7
+ } catch (error) {
8
+ return url;
9
+ }
10
+ const scheme = parsedUrl.protocol.slice(0, -1);
11
+ if (allowedSchemes && !allowedSchemes.includes(scheme)) {
12
+ console.warn(`Invalid URL scheme detected ${scheme}`);
13
+ return "";
14
+ }
15
+ if (parsedUrl.pathname === "/") {
16
+ if (url.endsWith("/")) {
17
+ return parsedUrl.href;
18
+ }
19
+ return `${parsedUrl.origin}${parsedUrl.search}${parsedUrl.hash}`;
20
+ } else {
21
+ return parsedUrl.href;
22
+ }
23
+ };
24
+ export {
25
+ sanitizeUrl
26
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type * as Md from 'mdast';
2
+ /**
3
+ * Marks created in the editor can hold leading or trailing whitespace — a word
4
+ * selected along with the space after it. Markdown emphasis markers cannot sit
5
+ * next to whitespace, so that whitespace is moved out of the mark and marks
6
+ * left with nothing are dropped. Mutates the tree in place.
7
+ */
8
+ export declare const normalizeMarkWhitespace: (tree: Md.Root) => Md.Root;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,9 +3,9 @@
3
3
 
4
4
 
5
5
  */
6
+ import type { RichTextType } from '@tinacms/schema-tools';
6
7
  import type * as Md from 'mdast';
7
8
  import type * as Plate from '../parse/plate';
8
- import type { RichTextType } from '@tinacms/schema-tools';
9
9
  type InlineElementWithCallback = Plate.InlineElement & {
10
10
  linkifyTextNode?: (arg: Md.Text) => Md.Link;
11
11
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/mdx",
3
- "version": "2.1.10",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,6 +14,10 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "browser": "./dist/index.browser.js",
16
16
  "default": "./dist/index.js"
17
+ },
18
+ "./sanitize-url": {
19
+ "types": "./dist/sanitize-url.d.ts",
20
+ "default": "./dist/sanitize-url.js"
17
21
  }
18
22
  },
19
23
  "license": "Apache-2.0",
@@ -23,7 +27,8 @@
23
27
  "name": "src/index.ts",
24
28
  "target": "node",
25
29
  "bundleDeps": true
26
- }
30
+ },
31
+ "src/sanitize-url.ts"
27
32
  ]
28
33
  },
29
34
  "dependencies": {
@@ -55,7 +60,7 @@
55
60
  "unist-util-visit": "4.1.2",
56
61
  "uvu": "0.5.6",
57
62
  "vfile-message": "3.1.4",
58
- "@tinacms/schema-tools": "2.8.3"
63
+ "@tinacms/schema-tools": "^2.9.0"
59
64
  },
60
65
  "publishConfig": {
61
66
  "registry": "https://registry.npmjs.org"
@@ -78,7 +83,7 @@
78
83
  "typescript": "^5.7.3",
79
84
  "vite": "^4.5.9",
80
85
  "vitest": "^0.32.4",
81
- "@tinacms/scripts": "1.6.2"
86
+ "@tinacms/scripts": "1.6.3"
82
87
  },
83
88
  "scripts": {
84
89
  "types": "tsc",