@readme/markdown 6.75.0-beta.27 → 6.75.0-beta.28
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 +0 -6
- package/components/Code/index.tsx +73 -0
- package/components/CodeTabs/{index.jsx → index.tsx} +8 -19
- package/dist/components/Callout/index.d.ts +1 -4
- package/dist/components/Code/index.d.ts +10 -0
- package/dist/components/CodeTabs/index.d.ts +3 -0
- package/dist/enums.d.ts +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/lib/owlmoji.d.ts +4 -0
- package/dist/main.js +33012 -10919
- package/dist/main.node.js +30257 -8016
- package/dist/processor/compile/code-tabs.d.ts +3 -0
- package/dist/processor/compile/gemoji.d.ts +3 -0
- package/dist/processor/compile/index.d.ts +7 -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 +8 -3
- package/components/Code/index.jsx +0 -100
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.28",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
@@ -24,15 +24,17 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@mdx-js/mdx": "^3.0.0",
|
|
27
|
-
"@readme/emojis": "^5.
|
|
27
|
+
"@readme/emojis": "^5.1.0",
|
|
28
28
|
"@readme/syntax-highlighter": "^13.0.0",
|
|
29
29
|
"copy-to-clipboard": "^3.3.2",
|
|
30
30
|
"core-js": "^3.36.1",
|
|
31
31
|
"debug": "^4.3.4",
|
|
32
32
|
"emoji-regex": "^10.2.1",
|
|
33
|
+
"gemoji": "^8.1.0",
|
|
33
34
|
"hast-util-sanitize": "^4.0.0",
|
|
34
35
|
"lodash.escape": "^4.0.1",
|
|
35
36
|
"lodash.kebabcase": "^4.1.1",
|
|
37
|
+
"mdast-util-find-and-replace": "^3.0.1",
|
|
36
38
|
"mdast-util-toc": "^5.1.0",
|
|
37
39
|
"path-browserify": "^1.0.1",
|
|
38
40
|
"process": "^0.11.10",
|
|
@@ -40,8 +42,11 @@
|
|
|
40
42
|
"rehype-sanitize": "^4.0.0",
|
|
41
43
|
"remark": "^15.0.1",
|
|
42
44
|
"remark-frontmatter": "^5.0.0",
|
|
45
|
+
"remark-gfm": "^4.0.0",
|
|
43
46
|
"remark-mdx": "^3.0.0",
|
|
44
47
|
"remark-parse": "^11.0.0",
|
|
48
|
+
"remark-rehype": "^11.1.0",
|
|
49
|
+
"remark-stringify": "^11.0.0",
|
|
45
50
|
"trim": "^1.0.1",
|
|
46
51
|
"unified": "^8.4.0",
|
|
47
52
|
"unist-util-flatmap": "^1.0.0",
|
|
@@ -100,7 +105,7 @@
|
|
|
100
105
|
"string.prototype.trimend": "^1.0.6",
|
|
101
106
|
"terser-webpack-plugin": "^5.3.7",
|
|
102
107
|
"ts-loader": "^9.4.2",
|
|
103
|
-
"typescript": "^5.
|
|
108
|
+
"typescript": "^5.4.5",
|
|
104
109
|
"vitest": "^1.4.0",
|
|
105
110
|
"webpack": "^5.56.0",
|
|
106
111
|
"webpack-cli": "^5.0.1",
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import copy from 'copy-to-clipboard';
|
|
2
|
-
import { string, oneOfType, func, shape, instanceOf, arrayOf, bool } from 'prop-types';
|
|
3
|
-
import React, { createRef, Element, Fragment } from '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 = 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: string,
|
|
35
|
-
codeRef: oneOfType([func, shape({ current: instanceOf(Element) })]).isRequired,
|
|
36
|
-
rootClass: string,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function Code(props) {
|
|
40
|
-
const { children, className, copyButtons, lang, meta, theme } = props;
|
|
41
|
-
|
|
42
|
-
const langClass = className.search(/lang(?:uage)?-\w+/) >= 0 ? className.match(/\s?lang(?:uage)?-(\w+)/)[1] : '';
|
|
43
|
-
const language = canonicalLanguage(lang) || langClass;
|
|
44
|
-
|
|
45
|
-
const codeRef = createRef();
|
|
46
|
-
|
|
47
|
-
const codeOpts = {
|
|
48
|
-
inline: !lang,
|
|
49
|
-
tokenizeVariables: true,
|
|
50
|
-
dark: theme === 'dark',
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const codeContent =
|
|
54
|
-
syntaxHighlighter && children ? syntaxHighlighter(children[0], language, codeOpts) : children?.[0] || '';
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Fragment>
|
|
58
|
-
{copyButtons && <CopyCode className="fa" codeRef={codeRef} />}
|
|
59
|
-
<code
|
|
60
|
-
ref={codeRef}
|
|
61
|
-
className={['rdmd-code', `lang-${language}`, `theme-${theme}`].join(' ')}
|
|
62
|
-
data-lang={language}
|
|
63
|
-
name={meta}
|
|
64
|
-
suppressHydrationWarning={true}
|
|
65
|
-
>
|
|
66
|
-
{codeContent}
|
|
67
|
-
</code>
|
|
68
|
-
</Fragment>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function CreateCode({ copyButtons, theme }) {
|
|
73
|
-
// eslint-disable-next-line react/display-name
|
|
74
|
-
return props => <Code {...props} copyButtons={copyButtons} theme={theme} />;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
Code.propTypes = {
|
|
78
|
-
children: arrayOf(string),
|
|
79
|
-
className: string,
|
|
80
|
-
copyButtons: bool,
|
|
81
|
-
lang: string,
|
|
82
|
-
meta: string,
|
|
83
|
-
theme: string,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
Code.defaultProps = {
|
|
87
|
-
className: '',
|
|
88
|
-
copyButtons: true,
|
|
89
|
-
lang: '',
|
|
90
|
-
meta: '',
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
CreateCode.sanitize = sanitizeSchema => {
|
|
94
|
-
// This is for code blocks class name
|
|
95
|
-
sanitizeSchema.attributes.code = ['className', 'lang', 'meta', 'value'];
|
|
96
|
-
|
|
97
|
-
return sanitizeSchema;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export default CreateCode;
|