@readme/markdown 6.75.0-beta.28 → 6.75.0-beta.29
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/GlossaryItem/index.tsx +31 -0
- package/components/Image/index.tsx +111 -0
- package/dist/components/GlossaryItem/index.d.ts +9 -0
- package/dist/components/Image/index.d.ts +15 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/contexts/GlossaryTerms.d.ts +15 -0
- package/dist/enums.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/main.js +124 -265
- package/dist/main.node.js +21951 -22027
- package/dist/processor/compile/image.d.ts +3 -0
- package/dist/processor/compile/index.d.ts +1 -0
- package/package.json +5 -1
- package/components/GlossaryItem/index.jsx +0 -44
- package/components/Image/index.jsx +0 -111
- /package/components/{index.js → index.ts} +0 -0
|
@@ -2,6 +2,7 @@ declare const compilers: {
|
|
|
2
2
|
handlers: {
|
|
3
3
|
emoji: (node: import("../../types").Gemoji) => string;
|
|
4
4
|
"code-tabs": (node: import("../../types").CodeTabs, _: any, state: any, info: any) => any;
|
|
5
|
+
image: (node: import("mdast").Image) => string;
|
|
5
6
|
};
|
|
6
7
|
};
|
|
7
8
|
export default compilers;
|
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.29",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"release.dry": "npx semantic-release --dry-run",
|
|
20
20
|
"start": "webpack serve --open --mode development --config ./webpack.dev.js",
|
|
21
21
|
"test": "vitest",
|
|
22
|
+
"test.ui": "vitest --ui",
|
|
22
23
|
"test.browser": "jest",
|
|
23
24
|
"watch": "webpack --watch --progress --mode development"
|
|
24
25
|
},
|
|
@@ -80,8 +81,11 @@
|
|
|
80
81
|
"@testing-library/jest-dom": "^6.4.2",
|
|
81
82
|
"@testing-library/react": "^14",
|
|
82
83
|
"@testing-library/user-event": "^14.5.2",
|
|
84
|
+
"@types/jest": "^29.5.12",
|
|
83
85
|
"@types/mdast": "^4.0.3",
|
|
84
86
|
"@types/mdx": "^2.0.12",
|
|
87
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
88
|
+
"@vitest/ui": "^1.5.0",
|
|
85
89
|
"babel-jest": "^29.5.0",
|
|
86
90
|
"babel-loader": "^9.1.2",
|
|
87
91
|
"browserify-fs": "^1.0.0",
|
|
@@ -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,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;
|
|
File without changes
|