@readme/markdown 6.75.0-beta.30 → 6.75.0-beta.32
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 +19 -2
- package/components/Code/index.tsx +8 -5
- package/components/HTMLBlock/index.tsx +36 -0
- package/components/Image/index.tsx +12 -27
- package/dist/components/Callout/index.d.ts +1 -1
- package/dist/components/HTMLBlock/index.d.ts +7 -0
- package/dist/components/Image/index.d.ts +12 -13
- package/dist/enums.d.ts +3 -1
- package/dist/example/App.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/main.js +55025 -57165
- package/dist/main.node.js +53488 -55318
- package/dist/processor/compile/html-block.d.ts +3 -0
- package/dist/processor/transform/index.d.ts +2 -0
- package/dist/processor/transform/readme-components.d.ts +6 -0
- package/package.json +5 -3
- package/components/HTMLBlock/index.jsx +0 -69
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.32",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"trim": "^1.0.1",
|
|
52
52
|
"unified": "^8.4.0",
|
|
53
53
|
"unist-util-flatmap": "^1.0.0",
|
|
54
|
-
"unist-util-visit": "^
|
|
54
|
+
"unist-util-visit": "^5.0.0",
|
|
55
55
|
"util": "^0.12.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -85,8 +85,9 @@
|
|
|
85
85
|
"@types/jest": "^29.5.12",
|
|
86
86
|
"@types/mdast": "^4.0.3",
|
|
87
87
|
"@types/mdx": "^2.0.12",
|
|
88
|
+
"@types/unist": "^3.0.2",
|
|
88
89
|
"@vitejs/plugin-react": "^4.2.1",
|
|
89
|
-
"@vitest/ui": "^1.
|
|
90
|
+
"@vitest/ui": "^1.6.0",
|
|
90
91
|
"babel-jest": "^29.5.0",
|
|
91
92
|
"babel-loader": "^9.1.2",
|
|
92
93
|
"browserify-fs": "^1.0.0",
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
"terser-webpack-plugin": "^5.3.7",
|
|
112
113
|
"ts-loader": "^9.4.2",
|
|
113
114
|
"typescript": "^5.4.5",
|
|
115
|
+
"unist-util-map": "^4.0.0",
|
|
114
116
|
"vitest": "^1.4.0",
|
|
115
117
|
"webpack": "^5.56.0",
|
|
116
118
|
"webpack-cli": "^5.0.1",
|
|
@@ -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;
|