@readme/markdown 6.87.1 → 6.88.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/README.md +81 -23
- package/components/Anchor.jsx +15 -26
- package/components/Callout/index.tsx +41 -0
- package/components/Callout/style.scss +11 -39
- package/components/CardsGrid/index.tsx +18 -0
- package/components/CardsGrid/style.scss +12 -0
- package/components/Code/index.tsx +75 -0
- package/components/Code/style.scss +54 -47
- package/components/CodeTabs/index.tsx +38 -0
- package/components/CodeTabs/style.scss +22 -30
- package/components/Embed/index.tsx +98 -0
- package/components/Embed/style.scss +59 -69
- package/components/Glossary/index.tsx +37 -0
- package/components/{GlossaryItem → Glossary}/style.scss +16 -18
- package/components/HTMLBlock/index.tsx +38 -0
- package/components/Heading/index.tsx +31 -0
- package/components/Heading/style.scss +9 -15
- package/components/Image/index.tsx +113 -0
- package/components/Image/style.scss +62 -64
- package/components/Table/index.tsx +20 -0
- package/components/Table/style.scss +17 -23
- package/components/TableOfContents/{index.jsx → index.tsx} +3 -8
- package/components/{index.js → index.ts} +2 -2
- package/dist/components/Callout/index.d.ts +9 -0
- package/dist/components/CardsGrid/index.d.ts +7 -0
- package/dist/components/Code/index.d.ts +11 -0
- package/dist/components/CodeTabs/index.d.ts +3 -0
- package/dist/components/Embed/index.d.ts +15 -0
- package/dist/components/Glossary/index.d.ts +10 -0
- package/dist/components/HTMLBlock/index.d.ts +7 -0
- package/dist/components/Heading/index.d.ts +8 -0
- package/dist/components/Image/index.d.ts +16 -0
- package/dist/components/Table/index.d.ts +7 -0
- package/dist/components/TableOfContents/index.d.ts +3 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/contexts/GlossaryTerms.d.ts +7 -0
- package/dist/contexts/index.d.ts +5 -0
- package/dist/enums.d.ts +14 -0
- package/dist/errors/mdx-syntax-error.d.ts +5 -0
- package/dist/example/App.d.ts +4 -0
- package/dist/example/Doc.d.ts +3 -0
- package/dist/example/Form.d.ts +3 -0
- package/dist/example/Header.d.ts +3 -0
- package/dist/example/RenderError.d.ts +23 -0
- package/dist/example/Root.d.ts +3 -0
- package/dist/example/docs.d.ts +2 -0
- package/dist/example/index.d.ts +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/lib/ast-processor.d.ts +12 -0
- package/dist/lib/compile.d.ts +8 -0
- package/dist/lib/hast.d.ts +3 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/mdast.d.ts +2 -0
- package/dist/lib/mdx.d.ts +4 -0
- package/dist/lib/owlmoji.d.ts +4 -0
- package/dist/lib/plain.d.ts +6 -0
- package/dist/lib/run.d.ts +24 -0
- package/dist/main.css +2 -17
- package/dist/main.js +70676 -29848
- package/dist/main.node.js +90238 -50277
- package/dist/processor/compile/callout.d.ts +3 -0
- package/dist/processor/compile/code-tabs.d.ts +3 -0
- package/dist/processor/compile/compatibility.d.ts +53 -0
- package/dist/processor/compile/embed.d.ts +3 -0
- package/dist/processor/compile/gemoji.d.ts +3 -0
- package/dist/processor/compile/html-block.d.ts +3 -0
- package/dist/processor/compile/image.d.ts +3 -0
- package/dist/processor/compile/index.d.ts +2 -0
- package/dist/processor/compile/table.d.ts +0 -0
- package/dist/processor/compile/variable.d.ts +3 -0
- package/dist/processor/plugin/toc.d.ts +9 -0
- package/dist/processor/transform/callouts.d.ts +2 -0
- package/dist/processor/transform/code-tabs.d.ts +3 -0
- package/dist/processor/transform/div.d.ts +3 -0
- package/dist/processor/transform/embeds.d.ts +3 -0
- package/dist/processor/transform/gemoji+.d.ts +3 -0
- package/dist/processor/transform/images.d.ts +3 -0
- package/dist/processor/transform/index.d.ts +9 -0
- package/dist/processor/transform/inject-components.d.ts +7 -0
- package/dist/processor/transform/readme-components.d.ts +7 -0
- package/dist/processor/transform/readme-to-mdx.d.ts +3 -0
- package/dist/processor/transform/tables-to-jsx.d.ts +3 -0
- package/dist/processor/transform/variables.d.ts +5 -0
- package/dist/processor/utils.d.ts +77 -0
- package/package.json +93 -99
- package/styles/components.scss +1 -1
- package/components/Callout/index.jsx +0 -42
- package/components/Code/index.jsx +0 -103
- package/components/CodeTabs/index.jsx +0 -60
- package/components/Embed/index.jsx +0 -88
- package/components/GlossaryItem/index.jsx +0 -44
- package/components/HTMLBlock/index.jsx +0 -68
- package/components/Heading/index.jsx +0 -56
- package/components/Image/index.jsx +0 -107
- package/components/Style.jsx +0 -30
- package/components/Table/index.jsx +0 -19
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
const copy = require('copy-to-clipboard');
|
|
2
|
-
const PropTypes = require('prop-types');
|
|
3
|
-
const React = require('react');
|
|
4
|
-
|
|
5
|
-
// Only load CodeMirror in the browser, for SSR
|
|
6
|
-
// apps. Necessary because of people like this:
|
|
7
|
-
// https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
|
|
8
|
-
let syntaxHighlighter;
|
|
9
|
-
let canonicalLanguage = () => {};
|
|
10
|
-
if (typeof window !== 'undefined') {
|
|
11
|
-
// eslint-disable-next-line global-require
|
|
12
|
-
syntaxHighlighter = require('@readme/syntax-highlighter').default;
|
|
13
|
-
// eslint-disable-next-line global-require
|
|
14
|
-
({ canonical: canonicalLanguage } = require('@readme/syntax-highlighter'));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '' }) {
|
|
18
|
-
const copyClass = `${rootClass}_copied`;
|
|
19
|
-
const button = React.createRef();
|
|
20
|
-
/* istanbul ignore next */
|
|
21
|
-
const copier = () => {
|
|
22
|
-
const code = codeRef.current.textContent;
|
|
23
|
-
|
|
24
|
-
if (copy(code)) {
|
|
25
|
-
const $el = button.current;
|
|
26
|
-
$el.classList.add(copyClass);
|
|
27
|
-
setTimeout(() => $el.classList.remove(copyClass), 1500);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
return <button ref={button} aria-label="Copy Code" className={`${rootClass} ${className}`} onClick={copier} />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
CopyCode.propTypes = {
|
|
34
|
-
className: PropTypes.string,
|
|
35
|
-
codeRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(React.Element) })])
|
|
36
|
-
.isRequired,
|
|
37
|
-
rootClass: PropTypes.string,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function Code(props) {
|
|
41
|
-
const { children, className, copyButtons, lang, meta, theme } = props;
|
|
42
|
-
|
|
43
|
-
const langClass = className.search(/lang(?:uage)?-\w+/) >= 0 ? className.match(/\s?lang(?:uage)?-(\w+)/)[1] : '';
|
|
44
|
-
const language = canonicalLanguage(lang) || langClass;
|
|
45
|
-
|
|
46
|
-
const codeRef = React.createRef();
|
|
47
|
-
|
|
48
|
-
const codeOpts = {
|
|
49
|
-
inline: !lang,
|
|
50
|
-
tokenizeVariables: true,
|
|
51
|
-
dark: theme === 'dark',
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const codeContent =
|
|
55
|
-
syntaxHighlighter && children ? syntaxHighlighter(children[0], language, codeOpts) : children?.[0] || '';
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<React.Fragment>
|
|
59
|
-
{copyButtons && <CopyCode className="fa" codeRef={codeRef} />}
|
|
60
|
-
<code
|
|
61
|
-
ref={codeRef}
|
|
62
|
-
className={['rdmd-code', `lang-${language}`, `theme-${theme}`].join(' ')}
|
|
63
|
-
data-lang={language}
|
|
64
|
-
name={meta}
|
|
65
|
-
suppressHydrationWarning={true}
|
|
66
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
67
|
-
tabIndex={0}
|
|
68
|
-
>
|
|
69
|
-
{codeContent}
|
|
70
|
-
</code>
|
|
71
|
-
</React.Fragment>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function CreateCode({ copyButtons, theme }) {
|
|
76
|
-
// eslint-disable-next-line react/display-name
|
|
77
|
-
return props => <Code {...props} copyButtons={copyButtons} theme={theme} />;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
Code.propTypes = {
|
|
81
|
-
children: PropTypes.arrayOf(PropTypes.string),
|
|
82
|
-
className: PropTypes.string,
|
|
83
|
-
copyButtons: PropTypes.bool,
|
|
84
|
-
lang: PropTypes.string,
|
|
85
|
-
meta: PropTypes.string,
|
|
86
|
-
theme: PropTypes.string,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
Code.defaultProps = {
|
|
90
|
-
className: '',
|
|
91
|
-
copyButtons: true,
|
|
92
|
-
lang: '',
|
|
93
|
-
meta: '',
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
CreateCode.sanitize = sanitizeSchema => {
|
|
97
|
-
// This is for code blocks class name
|
|
98
|
-
sanitizeSchema.attributes.code = ['className', 'lang', 'meta', 'value'];
|
|
99
|
-
|
|
100
|
-
return sanitizeSchema;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
module.exports = CreateCode;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const { uppercase } = require('@readme/syntax-highlighter');
|
|
2
|
-
const PropTypes = require('prop-types');
|
|
3
|
-
const React = require('react');
|
|
4
|
-
const { useState } = require('react');
|
|
5
|
-
|
|
6
|
-
const CodeTabs = props => {
|
|
7
|
-
const { children, theme } = props;
|
|
8
|
-
const [activeIndex, setActiveIndex] = useState(0);
|
|
9
|
-
|
|
10
|
-
function handleClick({ target }, index) {
|
|
11
|
-
const $wrap = target.parentElement.parentElement;
|
|
12
|
-
const $open = [].slice.call($wrap.querySelectorAll('.CodeTabs_active'));
|
|
13
|
-
$open.forEach(el => el.classList.remove('CodeTabs_active'));
|
|
14
|
-
$wrap.classList.remove('CodeTabs_initial');
|
|
15
|
-
|
|
16
|
-
const codeblocks = $wrap.querySelectorAll('pre');
|
|
17
|
-
codeblocks[index].classList.add('CodeTabs_active');
|
|
18
|
-
|
|
19
|
-
setActiveIndex(index);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className={`CodeTabs CodeTabs_initial theme-${theme}`}>
|
|
24
|
-
<div className="CodeTabs-toolbar" role="tablist">
|
|
25
|
-
{children.map(({ props: pre }, i) => {
|
|
26
|
-
const { meta, lang } = pre.children[0].props;
|
|
27
|
-
/* istanbul ignore next */
|
|
28
|
-
return (
|
|
29
|
-
<button
|
|
30
|
-
key={i}
|
|
31
|
-
aria-selected={activeIndex === i}
|
|
32
|
-
className={activeIndex === i ? 'CodeTabs_active' : ''}
|
|
33
|
-
onClick={e => handleClick(e, i)}
|
|
34
|
-
role="tab"
|
|
35
|
-
type="button"
|
|
36
|
-
>
|
|
37
|
-
{meta || `${!lang ? 'Text' : uppercase(lang)}`}
|
|
38
|
-
</button>
|
|
39
|
-
);
|
|
40
|
-
})}
|
|
41
|
-
</div>
|
|
42
|
-
<div className="CodeTabs-inner" role="tabpanel">
|
|
43
|
-
{children}
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
CodeTabs.propTypes = {
|
|
50
|
-
children: PropTypes.arrayOf(PropTypes.any).isRequired,
|
|
51
|
-
theme: PropTypes.string,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function CreateCodeTabs({ theme }) {
|
|
55
|
-
// eslint-disable-next-line react/display-name
|
|
56
|
-
return props => <CodeTabs {...props} theme={theme} />;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports = CreateCodeTabs;
|
|
60
|
-
module.exports.CodeTabs = CodeTabs;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/jsx-props-no-spreading, jsx-a11y/iframe-has-title */
|
|
2
|
-
const propTypes = require('prop-types');
|
|
3
|
-
const React = require('react');
|
|
4
|
-
|
|
5
|
-
const Favicon = ({ src, alt = 'favicon', ...attr }) => <img {...attr} alt={alt} height="14" src={src} width="14" />;
|
|
6
|
-
Favicon.propTypes = {
|
|
7
|
-
alt: propTypes.string,
|
|
8
|
-
src: propTypes.string,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
class Embed extends React.Component {
|
|
12
|
-
render() {
|
|
13
|
-
const { lazy = true, provider, url, title, html, iframe, image, favicon, ...attrs } = this.props;
|
|
14
|
-
|
|
15
|
-
if (!url) {
|
|
16
|
-
return <div />;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if ('iframe' in this.props) {
|
|
20
|
-
return <iframe {...attrs} border="none" src={url} style={{ border: 'none', display: 'flex', margin: 'auto' }} />;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const classes = ['embed', image && 'embed_hasImg'];
|
|
24
|
-
return (
|
|
25
|
-
<div className={classes.join(' ')}>
|
|
26
|
-
{html ? (
|
|
27
|
-
<div className="embed-media" dangerouslySetInnerHTML={{ __html: html }}></div>
|
|
28
|
-
) : (
|
|
29
|
-
<a className="embed-link" href={url} rel="noopener noreferrer" target="_blank">
|
|
30
|
-
{!image || <img alt={title} className="embed-img" loading={lazy ? 'lazy' : ''} src={image} />}
|
|
31
|
-
{title ? (
|
|
32
|
-
<div className="embed-body">
|
|
33
|
-
{!favicon || (
|
|
34
|
-
<Favicon
|
|
35
|
-
alt={provider}
|
|
36
|
-
className="embed-favicon"
|
|
37
|
-
loading={lazy ? 'lazy' : ''}
|
|
38
|
-
src={favicon}
|
|
39
|
-
style={{ float: 'left' }}
|
|
40
|
-
/>
|
|
41
|
-
)}
|
|
42
|
-
{provider && (
|
|
43
|
-
<small className="embed-provider">
|
|
44
|
-
{provider.search(/^@{1}/) < 0 ? (
|
|
45
|
-
provider
|
|
46
|
-
) : (
|
|
47
|
-
<code style={{ fontFamily: 'var(--md-code-font, monospace)' }}>{url}</code>
|
|
48
|
-
)}
|
|
49
|
-
</small>
|
|
50
|
-
)}
|
|
51
|
-
<div className="embed-title">{title}</div>
|
|
52
|
-
</div>
|
|
53
|
-
) : (
|
|
54
|
-
<div className="embed-body">
|
|
55
|
-
<b>View</b>: <span className="embed-body-url">{url}</span>
|
|
56
|
-
</div>
|
|
57
|
-
)}
|
|
58
|
-
</a>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
Embed.propTypes = {
|
|
66
|
-
children: propTypes.oneOfType([propTypes.string, propTypes.array, propTypes.shape({}), propTypes.element]),
|
|
67
|
-
favicon: propTypes.string,
|
|
68
|
-
height: propTypes.string,
|
|
69
|
-
html: propTypes.string,
|
|
70
|
-
iframe: propTypes.any,
|
|
71
|
-
image: propTypes.string,
|
|
72
|
-
lazy: propTypes.bool,
|
|
73
|
-
provider: propTypes.string,
|
|
74
|
-
title: propTypes.string,
|
|
75
|
-
url: propTypes.oneOfType([propTypes.string, propTypes.shape({})]),
|
|
76
|
-
width: propTypes.string,
|
|
77
|
-
};
|
|
78
|
-
Embed.defaultProps = {
|
|
79
|
-
height: '300px',
|
|
80
|
-
width: '100%',
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const CreateEmbed =
|
|
84
|
-
({ lazyImages }) =>
|
|
85
|
-
// eslint-disable-next-line react/display-name
|
|
86
|
-
props => <Embed {...props} lazy={lazyImages} />;
|
|
87
|
-
|
|
88
|
-
module.exports = CreateEmbed;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const Tooltip = require('@tippyjs/react').default;
|
|
2
|
-
const PropTypes = require('prop-types');
|
|
3
|
-
const React = require('react');
|
|
4
|
-
|
|
5
|
-
const GlossaryContext = require('../../contexts/GlossaryTerms');
|
|
6
|
-
|
|
7
|
-
// https://github.com/readmeio/api-explorer/blob/0dedafcf71102feedaa4145040d3f57d79d95752/packages/api-explorer/src/lib/replace-vars.js#L8
|
|
8
|
-
function GlossaryItem({ term, terms }) {
|
|
9
|
-
const foundTerm = terms.find(i => term.toLowerCase() === i.term.toLowerCase());
|
|
10
|
-
|
|
11
|
-
if (!foundTerm) return <span>{term}</span>;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Tooltip
|
|
15
|
-
content={
|
|
16
|
-
<div className="GlossaryItem-tooltip-content">
|
|
17
|
-
<strong className="GlossaryItem-term">{foundTerm.term}</strong> - {foundTerm.definition}
|
|
18
|
-
</div>
|
|
19
|
-
}
|
|
20
|
-
offset={[-5, 5]}
|
|
21
|
-
placement="bottom-start"
|
|
22
|
-
>
|
|
23
|
-
<span className="GlossaryItem-trigger">{term}</span>
|
|
24
|
-
</Tooltip>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
GlossaryItem.propTypes = {
|
|
29
|
-
term: PropTypes.string.isRequired,
|
|
30
|
-
terms: PropTypes.arrayOf(
|
|
31
|
-
PropTypes.shape({
|
|
32
|
-
definition: PropTypes.string.isRequired,
|
|
33
|
-
term: PropTypes.string.isRequired,
|
|
34
|
-
}),
|
|
35
|
-
).isRequired,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line react/display-name
|
|
39
|
-
module.exports = props => (
|
|
40
|
-
<GlossaryContext.Consumer>{terms => terms && <GlossaryItem {...props} terms={terms} />}</GlossaryContext.Consumer>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
module.exports.GlossaryItem = GlossaryItem;
|
|
44
|
-
module.exports.GlossaryContext = GlossaryContext;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-eval
|
|
2
|
-
*/
|
|
3
|
-
const escape = require('lodash.escape');
|
|
4
|
-
const PropTypes = require('prop-types');
|
|
5
|
-
const React = require('react');
|
|
6
|
-
|
|
7
|
-
const MATCH_SCRIPT_TAGS = /<script\b[^>]*>([\s\S]*?)<\/script *>\n?/gim;
|
|
8
|
-
|
|
9
|
-
const extractScripts = (html = '') => {
|
|
10
|
-
const scripts = [];
|
|
11
|
-
let match;
|
|
12
|
-
while ((match = MATCH_SCRIPT_TAGS.exec(html)) !== null) {
|
|
13
|
-
scripts.push(match[1]);
|
|
14
|
-
}
|
|
15
|
-
const cleaned = html.replace(MATCH_SCRIPT_TAGS, '');
|
|
16
|
-
return [cleaned, () => scripts.map(js => window.eval(js))];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
class HTMLBlock extends React.PureComponent {
|
|
20
|
-
constructor(props) {
|
|
21
|
-
super(props);
|
|
22
|
-
[this.html, this.exec] = extractScripts(this.props.html);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
componentDidMount() {
|
|
26
|
-
const { runScripts } = this.props;
|
|
27
|
-
if (typeof window !== 'undefined' && (runScripts === '' || runScripts)) this.exec();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
render() {
|
|
31
|
-
const { html, safeMode } = this.props;
|
|
32
|
-
|
|
33
|
-
if (safeMode) {
|
|
34
|
-
return (
|
|
35
|
-
<pre className="html-unsafe">
|
|
36
|
-
<code dangerouslySetInnerHTML={{ __html: escape(html) }} />
|
|
37
|
-
</pre>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return <div className="rdmd-html" dangerouslySetInnerHTML={{ __html: this.html }} />;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
HTMLBlock.defaultProps = {
|
|
46
|
-
runScripts: false,
|
|
47
|
-
safeMode: false,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
HTMLBlock.propTypes = {
|
|
51
|
-
html: PropTypes.string,
|
|
52
|
-
runScripts: PropTypes.any,
|
|
53
|
-
safeMode: PropTypes.bool,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const CreateHtmlBlock =
|
|
57
|
-
({ safeMode }) =>
|
|
58
|
-
// eslint-disable-next-line react/display-name
|
|
59
|
-
props => <HTMLBlock {...props} safeMode={safeMode} />;
|
|
60
|
-
|
|
61
|
-
CreateHtmlBlock.sanitize = schema => {
|
|
62
|
-
schema.tagNames.push('html-block');
|
|
63
|
-
schema.attributes['html-block'] = ['html', 'runScripts'];
|
|
64
|
-
|
|
65
|
-
return schema;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
module.exports = CreateHtmlBlock;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const PropTypes = require('prop-types');
|
|
2
|
-
const React = require('react');
|
|
3
|
-
|
|
4
|
-
function Heading({ tag, showAnchorIcons, ...props }) {
|
|
5
|
-
if (!props.children) return '';
|
|
6
|
-
|
|
7
|
-
const attrs = {
|
|
8
|
-
className: `heading heading-${props.level} header-scroll`,
|
|
9
|
-
align: props.align,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const children = [
|
|
13
|
-
<div key={`heading-anchor-${props.id}`} className="heading-anchor anchor waypoint" id={props.id} />,
|
|
14
|
-
<div key={`heading-text-${props.id}`} className="heading-text">
|
|
15
|
-
{props.children}
|
|
16
|
-
</div>,
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
if (showAnchorIcons) {
|
|
20
|
-
const headingText = props.children[1];
|
|
21
|
-
children.push(
|
|
22
|
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
23
|
-
<a
|
|
24
|
-
key={`heading-anchor-icon-${props.id}`}
|
|
25
|
-
aria-label={`Skip link to ${headingText}`}
|
|
26
|
-
className="heading-anchor-icon fa fa-anchor"
|
|
27
|
-
href={`#${props.id}`}
|
|
28
|
-
/>,
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return React.createElement(tag, attrs, children);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function CreateHeading(level, { showAnchorIcons }) {
|
|
36
|
-
// eslint-disable-next-line react/display-name
|
|
37
|
-
return props => <Heading {...props} level={level} showAnchorIcons={showAnchorIcons} tag={`h${level}`} />;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
Heading.propTypes = {
|
|
41
|
-
align: PropTypes.oneOf(['left', 'center', 'right', '']),
|
|
42
|
-
children: PropTypes.array.isRequired,
|
|
43
|
-
id: PropTypes.string.isRequired,
|
|
44
|
-
level: PropTypes.number,
|
|
45
|
-
showAnchorIcons: PropTypes.bool,
|
|
46
|
-
tag: PropTypes.string.isRequired,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
Heading.defaultProps = {
|
|
50
|
-
align: '',
|
|
51
|
-
id: '',
|
|
52
|
-
level: 2,
|
|
53
|
-
showAnchorIcons: true,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
module.exports = CreateHeading;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign, react/jsx-props-no-spreading, no-fallthrough */
|
|
2
|
-
|
|
3
|
-
const PropTypes = require('prop-types');
|
|
4
|
-
const React = require('react');
|
|
5
|
-
|
|
6
|
-
class Image extends React.Component {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super(props);
|
|
9
|
-
|
|
10
|
-
this.state = {
|
|
11
|
-
lightbox: false,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
this.toggle = this.toggle.bind(this);
|
|
15
|
-
this.handleKey = this.handleKey.bind(this);
|
|
16
|
-
|
|
17
|
-
this.isEmoji = props.className === 'emoji';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
toggle(toState) {
|
|
21
|
-
if (this.props.className === 'emoji') return;
|
|
22
|
-
|
|
23
|
-
if (typeof toState === 'undefined') toState = !this.state.lightbox;
|
|
24
|
-
|
|
25
|
-
this.setState({ lightbox: toState });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
handleKey(e) {
|
|
29
|
-
let { key, metaKey: cmd } = e;
|
|
30
|
-
|
|
31
|
-
cmd = cmd ? 'cmd+' : '';
|
|
32
|
-
key = `${cmd}${key.toLowerCase()}`;
|
|
33
|
-
|
|
34
|
-
switch (key) {
|
|
35
|
-
case 'cmd+.':
|
|
36
|
-
case 'escape':
|
|
37
|
-
// CLOSE
|
|
38
|
-
this.toggle(false);
|
|
39
|
-
break;
|
|
40
|
-
case ' ':
|
|
41
|
-
case 'enter':
|
|
42
|
-
// OPEN
|
|
43
|
-
if (!this.state.open) this.toggle(true);
|
|
44
|
-
e.preventDefault();
|
|
45
|
-
default:
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
render() {
|
|
50
|
-
const { props } = this;
|
|
51
|
-
const { alt, lazy = true, ...otherProps } = props;
|
|
52
|
-
|
|
53
|
-
if (this.isEmoji) {
|
|
54
|
-
return <img alt={alt} loading={lazy ? 'lazy' : ''} {...otherProps} />;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<span
|
|
59
|
-
aria-label={alt}
|
|
60
|
-
className={`img lightbox ${this.state.lightbox ? 'open' : 'closed'}`}
|
|
61
|
-
onClick={() => this.toggle()}
|
|
62
|
-
onKeyDown={this.handleKey}
|
|
63
|
-
role={'button'}
|
|
64
|
-
tabIndex={0}
|
|
65
|
-
>
|
|
66
|
-
<span className="lightbox-inner">
|
|
67
|
-
<img alt={alt} loading={lazy ? 'lazy' : ''} {...otherProps} />
|
|
68
|
-
</span>
|
|
69
|
-
</span>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
Image.propTypes = {
|
|
75
|
-
align: PropTypes.string,
|
|
76
|
-
alt: PropTypes.string,
|
|
77
|
-
caption: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
78
|
-
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
79
|
-
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
80
|
-
lazy: PropTypes.bool,
|
|
81
|
-
src: PropTypes.string.isRequired,
|
|
82
|
-
title: PropTypes.string,
|
|
83
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
Image.defaultProps = {
|
|
87
|
-
align: '',
|
|
88
|
-
alt: '',
|
|
89
|
-
caption: '',
|
|
90
|
-
height: 'auto',
|
|
91
|
-
src: '',
|
|
92
|
-
title: '',
|
|
93
|
-
width: 'auto',
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
Image.sanitize = sanitizeSchema => {
|
|
97
|
-
sanitizeSchema.attributes.img = ['className', 'title', 'alt', 'width', 'height', 'align', 'src', 'longDesc'];
|
|
98
|
-
|
|
99
|
-
return sanitizeSchema;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const CreateImage =
|
|
103
|
-
({ lazyImages }) =>
|
|
104
|
-
// eslint-disable-next-line react/display-name
|
|
105
|
-
props => <Image lazy={lazyImages} {...props} />;
|
|
106
|
-
|
|
107
|
-
module.exports = CreateImage;
|
package/components/Style.jsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const PropTypes = require('prop-types');
|
|
2
|
-
const React = require('react');
|
|
3
|
-
|
|
4
|
-
const Style = ({ children, safeMode }) => {
|
|
5
|
-
return safeMode ? (
|
|
6
|
-
<pre>
|
|
7
|
-
<code>{`<style>\n${children}\n</style>`}</code>
|
|
8
|
-
</pre>
|
|
9
|
-
) : (
|
|
10
|
-
<style>{children}</style>
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
Style.propTypes = {
|
|
15
|
-
children: PropTypes.node,
|
|
16
|
-
safeMode: PropTypes.bool,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const CreateStyle =
|
|
20
|
-
({ safeMode }) =>
|
|
21
|
-
// eslint-disable-next-line react/display-name
|
|
22
|
-
props => <Style {...props} safeMode={safeMode} />;
|
|
23
|
-
|
|
24
|
-
CreateStyle.sanitize = sanitize => {
|
|
25
|
-
sanitize.tagNames.push('style');
|
|
26
|
-
|
|
27
|
-
return sanitize;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
module.exports = CreateStyle;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const PropTypes = require('prop-types');
|
|
2
|
-
const React = require('react');
|
|
3
|
-
|
|
4
|
-
function Table(props) {
|
|
5
|
-
const { children } = props;
|
|
6
|
-
return (
|
|
7
|
-
<div className="rdmd-table">
|
|
8
|
-
<div className="rdmd-table-inner">
|
|
9
|
-
<table>{children}</table>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Table.propTypes = {
|
|
16
|
-
children: PropTypes.arrayOf(PropTypes.node).isRequired,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
module.exports = Table;
|