@readme/markdown 6.75.0-beta.47 → 6.75.0-beta.49

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,31 @@
1
+ import React from 'react';
2
+
3
+ export type Depth = 1 | 2 | 3 | 4 | 5 | 6;
4
+
5
+ interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLHeadingElement>> {
6
+ tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
7
+ depth: Depth;
8
+ }
9
+
10
+ const Heading = ({ tag: Tag = 'h3', depth = 3, id, children, ...attrs }: Props) => {
11
+ if (!children) return '';
12
+
13
+ return (
14
+ <Tag {...attrs} className={`heading heading-${depth} header-scroll`}>
15
+ <div key={`heading-anchor-${id}`} className="heading-anchor anchor waypoint" id={id} />
16
+ <div key={`heading-text-${id}`} className="heading-text">
17
+ {children}
18
+ </div>
19
+ <a
20
+ key={`heading-anchor-icon-${id}`}
21
+ aria-label={`Skip link to ${children}`}
22
+ className="heading-anchor-icon fa fa-anchor"
23
+ href={`#${id}`}
24
+ />
25
+ </Tag>
26
+ );
27
+ };
28
+
29
+ const CreateHeading = (depth: Depth) => (props: Props) => <Heading {...props} depth={depth} tag={`h${depth}`} />;
30
+
31
+ export default CreateHeading;
@@ -1,7 +1,6 @@
1
- import { element } from 'prop-types';
2
1
  import React from 'react';
3
2
 
4
- function TableOfContents({ children }) {
3
+ function TableOfContents({ children }: React.PropsWithChildren) {
5
4
  return (
6
5
  <nav>
7
6
  <ul className="toc-list">
@@ -18,8 +17,4 @@ function TableOfContents({ children }) {
18
17
  );
19
18
  }
20
19
 
21
- TableOfContents.propTypes = {
22
- children: element,
23
- };
24
-
25
20
  export default TableOfContents;
@@ -7,6 +7,5 @@ export { default as Glossary } from './Glossary';
7
7
  export { default as HTMLBlock } from './HTMLBlock';
8
8
  export { default as Heading } from './Heading';
9
9
  export { default as Image } from './Image';
10
- export { default as Style } from './Style';
11
10
  export { default as Table } from './Table';
12
11
  export { default as TableOfContents } from './TableOfContents';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export type Depth = 1 | 2 | 3 | 4 | 5 | 6;
3
+ interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLHeadingElement>> {
4
+ tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
+ depth: Depth;
6
+ }
7
+ declare const CreateHeading: (depth: Depth) => (props: Props) => React.JSX.Element;
8
+ export default CreateHeading;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare function TableOfContents({ children }: React.PropsWithChildren): React.JSX.Element;
3
+ export default TableOfContents;
@@ -7,6 +7,5 @@ export { default as Glossary } from './Glossary';
7
7
  export { default as HTMLBlock } from './HTMLBlock';
8
8
  export { default as Heading } from './Heading';
9
9
  export { default as Image } from './Image';
10
- export { default as Style } from './Style';
11
10
  export { default as Table } from './Table';
12
11
  export { default as TableOfContents } from './TableOfContents';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { RunOpts } from '../index';
2
+ import { RunOpts } from '../lib/run';
3
3
  type Props = React.PropsWithChildren & Pick<RunOpts, 'baseUrl' | 'terms' | 'variables'>;
4
4
  declare const Contexts: ({ children, terms, variables, baseUrl }: Props) => React.ReactNode;
5
5
  export default Contexts;
package/dist/index.d.ts CHANGED
@@ -1,34 +1,13 @@
1
- import React from 'react';
2
- import { RunOptions } from '@mdx-js/mdx';
3
1
  import * as Components from './components';
4
- import { GlossaryTerm } from './contexts/GlossaryTerms';
2
+ import { compile, run, mdx } from './lib';
5
3
  import './styles/main.scss';
6
- type ComponentOpts = Record<string, (props: any) => React.ReactNode>;
7
- interface Variables {
8
- user: Record<string, string>;
9
- defaults: {
10
- name: string;
11
- default: string;
12
- }[];
13
- }
14
- export type RunOpts = Omit<RunOptions, 'Fragment'> & {
15
- components?: ComponentOpts;
16
- imports?: Record<string, unknown>;
17
- baseUrl?: string;
18
- terms?: GlossaryTerm[];
19
- variables?: Variables;
20
- };
21
- export { Components };
22
- export declare const utils: {
4
+ declare const utils: {
23
5
  readonly options: any;
24
6
  getHref: any;
25
7
  calloutIcons: {};
26
8
  };
9
+ export { compile, run, mdx, Components, utils };
27
10
  export declare const reactProcessor: (opts?: {}) => import("unified").Processor<import("mdast").Root, import("estree").Program, import("estree").Program, import("estree").Program, string>;
28
- export declare const compile: (text: string, opts?: {}) => string;
29
- export declare const run: (code: string, _opts?: RunOpts) => Promise<() => React.JSX.Element>;
30
- export declare const reactTOC: (text: string, opts?: {}) => void;
31
- export declare const mdx: (tree: any, opts?: {}) => string;
32
11
  export declare const html: (text: string, opts?: {}) => void;
33
12
  export declare const mdast: any;
34
13
  export declare const hast: (text: string, opts?: {}) => import("hast").Root;
@@ -0,0 +1,8 @@
1
+ import remarkFrontmatter from 'remark-frontmatter';
2
+ import remarkGfm from 'remark-gfm';
3
+ export type MdastOpts = {
4
+ components?: Record<string, string>;
5
+ };
6
+ export declare const remarkPlugins: ((() => (tree: any) => void) | typeof remarkFrontmatter | typeof remarkGfm)[];
7
+ declare const astProcessor: (opts?: MdastOpts) => import("unified").Processor<import("mdast").Root, import("mdast").Root, import("mdast").Root, import("mdast").Root, string>;
8
+ export default astProcessor;
@@ -0,0 +1,9 @@
1
+ import { CompileOptions } from '@mdx-js/mdx';
2
+ import { VFileWithToc } from '../types';
3
+ export type CompileOpts = CompileOptions & {
4
+ components?: Record<string, VFileWithToc>;
5
+ lazyImages?: boolean;
6
+ safeMode?: boolean;
7
+ };
8
+ declare const compile: (text: string, opts?: CompileOpts) => VFileWithToc;
9
+ export default compile;
@@ -0,0 +1,6 @@
1
+ import astProcessor, { MdastOpts, remarkPlugins } from './ast-processor';
2
+ import compile from './compile';
3
+ import mdx from './mdx';
4
+ import run from './run';
5
+ export type { MdastOpts };
6
+ export { astProcessor, compile, mdx, run, remarkPlugins };
@@ -0,0 +1,4 @@
1
+ export declare const mdx: (tree: any, { hast }?: {
2
+ hast?: boolean;
3
+ }) => string;
4
+ export default mdx;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { RunOptions } from '@mdx-js/mdx';
3
+ import { VFileWithToc } from '../types';
4
+ import { GlossaryTerm } from '../contexts/GlossaryTerms';
5
+ interface Variables {
6
+ user: Record<string, string>;
7
+ defaults: {
8
+ name: string;
9
+ default: string;
10
+ }[];
11
+ }
12
+ export type RunOpts = Omit<RunOptions, 'Fragment'> & {
13
+ components?: ComponentOpts;
14
+ imports?: Record<string, unknown>;
15
+ baseUrl?: string;
16
+ terms?: GlossaryTerm[];
17
+ variables?: Variables;
18
+ };
19
+ type ComponentOpts = Record<string, (props: any) => React.ReactNode>;
20
+ declare const run: (stringOrFile: string | VFileWithToc, _opts?: RunOpts) => Promise<{
21
+ default: () => React.JSX.Element;
22
+ toc: () => React.JSX.Element;
23
+ }>;
24
+ export default run;