@readme/markdown 6.75.0-beta.3 → 6.75.0-beta.31
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/components/Callout/index.tsx +27 -0
- package/components/Code/index.tsx +73 -0
- package/components/CodeTabs/{index.jsx → index.tsx} +8 -19
- package/components/GlossaryItem/index.tsx +31 -0
- package/components/HTMLBlock/index.tsx +36 -0
- package/components/Image/index.tsx +96 -0
- package/components/Table/index.tsx +19 -0
- package/components/TableOfContents/index.jsx +4 -4
- package/dist/components/Callout/index.d.ts +9 -0
- package/dist/components/Code/index.d.ts +10 -0
- package/dist/components/CodeTabs/index.d.ts +3 -0
- package/dist/components/GlossaryItem/index.d.ts +9 -0
- package/dist/components/HTMLBlock/index.d.ts +7 -0
- package/dist/components/Image/index.d.ts +14 -0
- package/dist/components/Table/index.d.ts +6 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/contexts/GlossaryTerms.d.ts +15 -0
- package/dist/enums.d.ts +7 -0
- package/dist/errors/mdx-syntax-error.d.ts +5 -0
- package/dist/example/App.d.ts +3 -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 +26 -0
- package/dist/lib/owlmoji.d.ts +4 -0
- package/dist/main.js +81787 -2
- package/dist/main.node.js +83665 -2
- package/dist/processor/compile/code-tabs.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/transform/callouts.d.ts +2 -0
- package/dist/processor/transform/code-tabs.d.ts +2 -0
- package/dist/processor/transform/gemoji+.d.ts +3 -0
- package/dist/processor/transform/index.d.ts +2 -0
- package/package.json +39 -22
- package/components/Callout/index.jsx +0 -42
- package/components/Code/index.jsx +0 -101
- package/components/GlossaryItem/index.jsx +0 -44
- package/components/HTMLBlock/index.jsx +0 -69
- package/components/Image/index.jsx +0 -111
- package/components/Table/index.jsx +0 -19
- package/dist/main.css +0 -399
- package/dist/main.js.LICENSE.txt +0 -17
- package/dist/main.node.js.LICENSE.txt +0 -50
- /package/components/{index.js → index.ts} +0 -0
|
File without changes
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@readme/markdown",
|
|
3
3
|
"description": "ReadMe's React-based Markdown parser",
|
|
4
4
|
"author": "Rafe Goldberg <rafe@readme.io>",
|
|
5
|
-
"version": "6.75.0-beta.
|
|
5
|
+
"version": "6.75.0-beta.31",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
@@ -12,43 +12,54 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "webpack --mode production",
|
|
15
|
+
"build": "webpack --mode production && npm run build-types",
|
|
16
|
+
"build-types": "npx tsc --declaration --emitDeclarationOnly --declarationDir ./dist --skipLibCheck",
|
|
16
17
|
"lint": "eslint . --ext .jsx --ext .js --ext .ts --ext .tsx",
|
|
17
18
|
"release": "npx semantic-release",
|
|
18
19
|
"release.dry": "npx semantic-release --dry-run",
|
|
19
|
-
"
|
|
20
|
-
"test
|
|
20
|
+
"start": "webpack serve --open --mode development --config ./webpack.dev.js",
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"test.ui": "vitest --ui",
|
|
23
|
+
"test.browser": "jest",
|
|
21
24
|
"watch": "webpack --watch --progress --mode development"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
27
|
"@mdx-js/mdx": "^3.0.0",
|
|
25
|
-
"@
|
|
26
|
-
"@readme/
|
|
27
|
-
"@readme/syntax-highlighter": "^12.0.2",
|
|
28
|
+
"@readme/emojis": "^5.1.0",
|
|
29
|
+
"@readme/syntax-highlighter": "^13.0.0",
|
|
28
30
|
"copy-to-clipboard": "^3.3.2",
|
|
31
|
+
"core-js": "^3.36.1",
|
|
29
32
|
"debug": "^4.3.4",
|
|
30
33
|
"emoji-regex": "^10.2.1",
|
|
34
|
+
"gemoji": "^8.1.0",
|
|
31
35
|
"hast-util-sanitize": "^4.0.0",
|
|
32
36
|
"lodash.escape": "^4.0.1",
|
|
33
37
|
"lodash.kebabcase": "^4.1.1",
|
|
38
|
+
"mdast-util-find-and-replace": "^3.0.1",
|
|
34
39
|
"mdast-util-toc": "^5.1.0",
|
|
35
40
|
"path-browserify": "^1.0.1",
|
|
36
41
|
"process": "^0.11.10",
|
|
37
42
|
"prop-types": "^15.8.1",
|
|
38
43
|
"rehype-sanitize": "^4.0.0",
|
|
39
|
-
"remark": "^
|
|
44
|
+
"remark": "^15.0.1",
|
|
45
|
+
"remark-frontmatter": "^5.0.0",
|
|
46
|
+
"remark-gfm": "^4.0.0",
|
|
40
47
|
"remark-mdx": "^3.0.0",
|
|
41
|
-
"remark-parse": "^
|
|
48
|
+
"remark-parse": "^11.0.0",
|
|
49
|
+
"remark-rehype": "^11.1.0",
|
|
50
|
+
"remark-stringify": "^11.0.0",
|
|
42
51
|
"trim": "^1.0.1",
|
|
43
52
|
"unified": "^8.4.0",
|
|
44
53
|
"unist-util-flatmap": "^1.0.0",
|
|
45
|
-
"unist-util-visit": "^4.1.1"
|
|
54
|
+
"unist-util-visit": "^4.1.1",
|
|
55
|
+
"util": "^0.12.5"
|
|
46
56
|
},
|
|
47
57
|
"peerDependencies": {
|
|
48
|
-
"@
|
|
58
|
+
"@mdx-js/react": "^3.0.0",
|
|
59
|
+
"@readme/variable": "^16.0.0",
|
|
49
60
|
"@tippyjs/react": "^4.1.0",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
61
|
+
"react": "16.x || 17.x || 18.x",
|
|
62
|
+
"react-dom": "16.x || 17.x || 18.x"
|
|
52
63
|
},
|
|
53
64
|
"devDependencies": {
|
|
54
65
|
"@babel/core": "^7.21.4",
|
|
@@ -57,6 +68,7 @@
|
|
|
57
68
|
"@babel/plugin-proposal-export-default-from": "^7.23.3",
|
|
58
69
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
59
70
|
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
71
|
+
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
60
72
|
"@babel/plugin-transform-runtime": "^7.21.4",
|
|
61
73
|
"@babel/preset-env": "^7.21.4",
|
|
62
74
|
"@babel/preset-react": "^7.18.6",
|
|
@@ -64,37 +76,42 @@
|
|
|
64
76
|
"@commitlint/cli": "^17.5.1",
|
|
65
77
|
"@commitlint/config-angular": "^17.4.4",
|
|
66
78
|
"@commitlint/config-conventional": "^17.4.4",
|
|
67
|
-
"@
|
|
68
|
-
"@readme/eslint-config": "^10.5.2",
|
|
79
|
+
"@readme/eslint-config": "^14.0.0",
|
|
69
80
|
"@semantic-release/changelog": "^6.0.3",
|
|
70
81
|
"@semantic-release/git": "^10.0.1",
|
|
71
|
-
"@testing-library/jest-dom": "^
|
|
72
|
-
"@testing-library/react": "^
|
|
82
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
83
|
+
"@testing-library/react": "^14",
|
|
84
|
+
"@testing-library/user-event": "^14.5.2",
|
|
85
|
+
"@types/jest": "^29.5.12",
|
|
86
|
+
"@types/mdast": "^4.0.3",
|
|
87
|
+
"@types/mdx": "^2.0.12",
|
|
88
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
89
|
+
"@vitest/ui": "^1.6.0",
|
|
73
90
|
"babel-jest": "^29.5.0",
|
|
74
91
|
"babel-loader": "^9.1.2",
|
|
75
92
|
"browserify-fs": "^1.0.0",
|
|
76
93
|
"codemirror": "^5.54.0",
|
|
77
|
-
"core-js": "^2.6.12",
|
|
78
94
|
"css-loader": "^6.7.3",
|
|
79
95
|
"eslint": "^8.37.0",
|
|
80
96
|
"identity-obj-proxy": "^3.0.0",
|
|
81
97
|
"jest": "^29.5.0",
|
|
82
98
|
"jest-environment-jsdom": "^29.5.0",
|
|
83
99
|
"jest-environment-puppeteer": "^8.0.6",
|
|
84
|
-
"jest-image-snapshot": "^6.
|
|
100
|
+
"jest-image-snapshot": "^6.4.0",
|
|
85
101
|
"jest-puppeteer": "^8.0.6",
|
|
86
102
|
"mini-css-extract-plugin": "^2.7.5",
|
|
87
103
|
"node-sass": "^8.0.0",
|
|
88
|
-
"prettier": "^2.
|
|
104
|
+
"prettier": "^3.2.5",
|
|
89
105
|
"puppeteer": "^19.8.3",
|
|
90
|
-
"react-
|
|
106
|
+
"react-router-dom": "^6.22.3",
|
|
91
107
|
"sass-loader": "^13.2.2",
|
|
92
108
|
"semantic-release": "^22.0.12",
|
|
93
109
|
"stream-browserify": "^3.0.0",
|
|
94
110
|
"string.prototype.trimend": "^1.0.6",
|
|
95
111
|
"terser-webpack-plugin": "^5.3.7",
|
|
96
112
|
"ts-loader": "^9.4.2",
|
|
97
|
-
"typescript": "^5.
|
|
113
|
+
"typescript": "^5.4.5",
|
|
114
|
+
"vitest": "^1.4.0",
|
|
98
115
|
"webpack": "^5.56.0",
|
|
99
116
|
"webpack-cli": "^5.0.1",
|
|
100
117
|
"webpack-dev-server": "^4.13.2",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const PropTypes = require('prop-types');
|
|
2
|
-
const React = require('react');
|
|
3
|
-
|
|
4
|
-
const Callout = props => {
|
|
5
|
-
const { attributes, theme, icon } = props;
|
|
6
|
-
const [title, ...content] = !props.title ? [null, props.children] : props.children;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
10
|
-
<blockquote {...attributes} className={`callout callout_${theme}`} theme={icon}>
|
|
11
|
-
<h3 className={`callout-heading${title ? '' : ' empty'}`}>
|
|
12
|
-
<span className="callout-icon">{icon}</span>
|
|
13
|
-
{title}
|
|
14
|
-
</h3>
|
|
15
|
-
{content}
|
|
16
|
-
</blockquote>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
Callout.propTypes = {
|
|
21
|
-
attributes: PropTypes.shape({}),
|
|
22
|
-
calloutStyle: PropTypes.string,
|
|
23
|
-
children: PropTypes.arrayOf(PropTypes.any).isRequired,
|
|
24
|
-
icon: PropTypes.string,
|
|
25
|
-
node: PropTypes.shape(),
|
|
26
|
-
theme: PropTypes.string,
|
|
27
|
-
title: PropTypes.string,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
Callout.defaultProps = {
|
|
31
|
-
attributes: null,
|
|
32
|
-
calloutStyle: 'info',
|
|
33
|
-
node: null,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
Callout.sanitize = sanitizeSchema => {
|
|
37
|
-
sanitizeSchema.attributes['rdme-callout'] = ['icon', 'theme', 'title'];
|
|
38
|
-
|
|
39
|
-
return sanitizeSchema;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
module.exports = Callout;
|
|
@@ -1,101 +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
|
-
>
|
|
67
|
-
{codeContent}
|
|
68
|
-
</code>
|
|
69
|
-
</React.Fragment>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function CreateCode({ copyButtons, theme }) {
|
|
74
|
-
// eslint-disable-next-line react/display-name
|
|
75
|
-
return props => <Code {...props} copyButtons={copyButtons} theme={theme} />;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
Code.propTypes = {
|
|
79
|
-
children: PropTypes.arrayOf(PropTypes.string),
|
|
80
|
-
className: PropTypes.string,
|
|
81
|
-
copyButtons: PropTypes.bool,
|
|
82
|
-
lang: PropTypes.string,
|
|
83
|
-
meta: PropTypes.string,
|
|
84
|
-
theme: PropTypes.string,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
Code.defaultProps = {
|
|
88
|
-
className: '',
|
|
89
|
-
copyButtons: true,
|
|
90
|
-
lang: '',
|
|
91
|
-
meta: '',
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
CreateCode.sanitize = sanitizeSchema => {
|
|
95
|
-
// This is for code blocks class name
|
|
96
|
-
sanitizeSchema.attributes.code = ['className', 'lang', 'meta', 'value'];
|
|
97
|
-
|
|
98
|
-
return sanitizeSchema;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
module.exports = CreateCode;
|
|
@@ -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,69 +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 =>
|
|
60
|
-
<HTMLBlock {...props} safeMode={safeMode} />;
|
|
61
|
-
|
|
62
|
-
CreateHtmlBlock.sanitize = schema => {
|
|
63
|
-
schema.tagNames.push('html-block');
|
|
64
|
-
schema.attributes['html-block'] = ['html', 'runScripts'];
|
|
65
|
-
|
|
66
|
-
return schema;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
module.exports = CreateHtmlBlock;
|
|
@@ -1,111 +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
|
-
|
|
52
|
-
const { alt, lazy = true } = props;
|
|
53
|
-
|
|
54
|
-
if (this.isEmoji) {
|
|
55
|
-
return <img {...props} alt={alt} loading={lazy ? 'lazy' : ''} />;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const align = props.align === 'center' ? 'middle' : props.align;
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<span
|
|
62
|
-
aria-label={alt}
|
|
63
|
-
className={`img lightbox ${this.state.lightbox ? 'open' : 'closed'}`}
|
|
64
|
-
onClick={() => this.toggle()}
|
|
65
|
-
onKeyDown={this.handleKey}
|
|
66
|
-
role={'button'}
|
|
67
|
-
tabIndex={0}
|
|
68
|
-
>
|
|
69
|
-
<span className="lightbox-inner">
|
|
70
|
-
<img {...props} align={align} alt={alt} loading={lazy ? 'lazy' : ''} />
|
|
71
|
-
</span>
|
|
72
|
-
</span>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
Image.propTypes = {
|
|
78
|
-
align: PropTypes.string,
|
|
79
|
-
alt: PropTypes.string,
|
|
80
|
-
caption: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
81
|
-
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
82
|
-
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
83
|
-
lazy: PropTypes.bool,
|
|
84
|
-
src: PropTypes.string.isRequired,
|
|
85
|
-
title: PropTypes.string,
|
|
86
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
Image.defaultProps = {
|
|
90
|
-
align: '',
|
|
91
|
-
alt: '',
|
|
92
|
-
caption: '',
|
|
93
|
-
height: 'auto',
|
|
94
|
-
src: '',
|
|
95
|
-
title: '',
|
|
96
|
-
width: 'auto',
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
Image.sanitize = sanitizeSchema => {
|
|
100
|
-
sanitizeSchema.attributes.img = ['className', 'title', 'alt', 'width', 'height', 'align', 'src', 'longDesc'];
|
|
101
|
-
|
|
102
|
-
return sanitizeSchema;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const CreateImage =
|
|
106
|
-
({ lazyImages }) =>
|
|
107
|
-
// eslint-disable-next-line react/display-name
|
|
108
|
-
props =>
|
|
109
|
-
<Image lazy={lazyImages} {...props} />;
|
|
110
|
-
|
|
111
|
-
module.exports = CreateImage;
|
|
@@ -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;
|