@readme/markdown 7.6.7 → 7.7.1

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.
Files changed (86) hide show
  1. package/components/Code/index.tsx +4 -0
  2. package/components/Code/style.scss +6 -0
  3. package/components/CodeTabs/index.tsx +25 -2
  4. package/components/Image/style.scss +1 -4
  5. package/dist/10.js +22718 -0
  6. package/dist/10.node.js +22721 -0
  7. package/dist/11.js +1440 -0
  8. package/dist/11.node.js +1443 -0
  9. package/dist/120.js +19 -0
  10. package/dist/120.node.js +22 -0
  11. package/dist/134.js +19 -0
  12. package/dist/134.node.js +22 -0
  13. package/dist/150.js +1888 -0
  14. package/dist/150.node.js +1891 -0
  15. package/dist/17.js +1373 -0
  16. package/dist/17.node.js +1376 -0
  17. package/dist/246.js +1929 -0
  18. package/dist/246.node.js +1932 -0
  19. package/dist/351.js +2400 -0
  20. package/dist/351.node.js +2403 -0
  21. package/dist/366.js +1181 -0
  22. package/dist/366.node.js +1184 -0
  23. package/dist/403.js +2192 -0
  24. package/dist/403.node.js +2195 -0
  25. package/dist/429.js +11130 -0
  26. package/dist/429.node.js +11133 -0
  27. package/dist/485.js +514 -0
  28. package/dist/485.node.js +517 -0
  29. package/dist/486.js +31820 -0
  30. package/dist/486.node.js +31818 -0
  31. package/dist/488.js +55 -0
  32. package/dist/488.node.js +58 -0
  33. package/dist/489.js +18472 -0
  34. package/dist/489.node.js +18475 -0
  35. package/dist/510.js +246 -0
  36. package/dist/510.node.js +249 -0
  37. package/dist/52.js +808 -0
  38. package/dist/52.node.js +811 -0
  39. package/dist/550.node.js +1456 -0
  40. package/dist/551.js +2722 -0
  41. package/dist/551.node.js +2725 -0
  42. package/dist/617.js +19 -0
  43. package/dist/617.node.js +22 -0
  44. package/dist/687.js +3671 -0
  45. package/dist/687.node.js +3674 -0
  46. package/dist/745.js +7504 -0
  47. package/dist/745.node.js +7507 -0
  48. package/dist/775.js +1900 -0
  49. package/dist/775.node.js +1903 -0
  50. package/dist/786.js +31378 -0
  51. package/dist/786.node.js +31381 -0
  52. package/dist/788.js +1021 -0
  53. package/dist/788.node.js +1024 -0
  54. package/dist/81.js +382 -0
  55. package/dist/81.node.js +385 -0
  56. package/dist/849.js +2586 -0
  57. package/dist/849.node.js +2589 -0
  58. package/dist/863.js +19 -0
  59. package/dist/863.node.js +22 -0
  60. package/dist/867.js +1414 -0
  61. package/dist/867.node.js +1417 -0
  62. package/dist/871.js +1533 -0
  63. package/dist/881.js +1276 -0
  64. package/dist/881.node.js +1279 -0
  65. package/dist/885.js +48 -0
  66. package/dist/885.node.js +51 -0
  67. package/dist/896.js +1613 -0
  68. package/dist/896.node.js +1616 -0
  69. package/dist/906.js +1815 -0
  70. package/dist/906.node.js +1818 -0
  71. package/dist/91.js +19 -0
  72. package/dist/91.node.js +22 -0
  73. package/dist/940.js +3359 -0
  74. package/dist/940.node.js +3362 -0
  75. package/dist/952.js +243 -0
  76. package/dist/952.node.js +246 -0
  77. package/dist/995.js +5734 -0
  78. package/dist/995.node.js +5737 -0
  79. package/dist/components/Code/index.d.ts +1 -1
  80. package/dist/lib/ast-processor.d.ts +1 -1
  81. package/dist/main.css +1 -1
  82. package/dist/main.js +453 -11212
  83. package/dist/main.node.js +387 -11250
  84. package/dist/processor/transform/index.d.ts +2 -1
  85. package/dist/processor/transform/mermaid.d.ts +3 -0
  86. package/package.json +6 -3
@@ -57,6 +57,10 @@ const Code = (props: CodeProps) => {
57
57
  const code = value ?? (Array.isArray(children) ? children[0] : children) ?? '';
58
58
  const highlightedCode = syntaxHighlighter && code ? syntaxHighlighter(code, language, codeOpts, { mdx: true }) : code;
59
59
 
60
+ if (language === 'mermaid') {
61
+ return code;
62
+ }
63
+
60
64
  return (
61
65
  <>
62
66
  {copyButtons && <CopyCode className="fa" codeRef={codeRef} />}
@@ -84,6 +84,12 @@
84
84
  word-wrap: normal;
85
85
  }
86
86
 
87
+ pre.mermaid {
88
+ &_single {
89
+ background: var(--color-bg-page, white);
90
+ }
91
+ }
92
+
87
93
  kbd {
88
94
  background-color: $background;
89
95
  background-color: var(--d-code-background, $background);
@@ -1,9 +1,26 @@
1
+ import type { Mermaid } from 'mermaid';
2
+
1
3
  import { uppercase } from '@readme/syntax-highlighter';
2
- import React from 'react';
4
+ import React, { useEffect } from 'react';
5
+
6
+ let mermaid: Mermaid;
7
+
8
+ if (typeof window !== 'undefined') {
9
+ import('mermaid').then(module => {
10
+ mermaid = module.default;
11
+ });
12
+ }
3
13
 
4
14
  const CodeTabs = props => {
5
15
  const { children, theme } = props;
6
16
 
17
+ // set Mermaid theme
18
+ useEffect(() => {
19
+ mermaid?.initialize({
20
+ theme: theme === 'dark' ? 'dark' : 'default',
21
+ });
22
+ }, [theme]);
23
+
7
24
  function handleClick({ target }, index: number) {
8
25
  const $wrap = target.parentElement.parentElement;
9
26
  const $open = [].slice.call($wrap.querySelectorAll('.CodeTabs_active'));
@@ -16,6 +33,12 @@ const CodeTabs = props => {
16
33
  target.classList.add('CodeTabs_active');
17
34
  }
18
35
 
36
+ // render single Mermaid diagram
37
+ if (!Array.isArray(children) && children.props?.children.props.lang === 'mermaid') {
38
+ const value = children.props.children.props.value;
39
+ return <pre className="mermaid mermaid_single">{value}</pre>;
40
+ }
41
+
19
42
  return (
20
43
  <div className={`CodeTabs CodeTabs_initial theme-${theme}`}>
21
44
  <div className="CodeTabs-toolbar">
@@ -24,7 +47,7 @@ const CodeTabs = props => {
24
47
 
25
48
  /* istanbul ignore next */
26
49
  return (
27
- <button key={i} onClick={e => handleClick(e, i)} type="button">
50
+ <button key={i} onClick={e => handleClick(e, i)} type="button" value={lang}>
28
51
  {meta || `${!lang ? 'Text' : uppercase(lang)}`}
29
52
  </button>
30
53
  );
@@ -103,16 +103,13 @@
103
103
  content: '\f00d';
104
104
  cursor: pointer;
105
105
  display: inline-block;
106
- font: normal normal normal 2em/1 FontAwesome;
106
+ font-family: var(--fa-style-family, 'Font Awesome 6 Pro');
107
107
  font-size: inherit;
108
- -webkit-font-smoothing: antialiased;
109
- -moz-osx-font-smoothing: grayscale;
110
108
  opacity: 1;
111
109
  position: fixed;
112
110
  right: 1em;
113
111
  text-rendering: auto;
114
112
  top: 1em;
115
- transform: translate(0, 0);
116
113
  transform: scale(1.5);
117
114
  transition: 0.3s 0.3s ease-in;
118
115
  }