@readme/markdown 7.6.7 → 7.7.0

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 (81) 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/488.js +55 -0
  30. package/dist/488.node.js +58 -0
  31. package/dist/489.js +18472 -0
  32. package/dist/489.node.js +18475 -0
  33. package/dist/510.js +246 -0
  34. package/dist/510.node.js +249 -0
  35. package/dist/52.js +808 -0
  36. package/dist/52.node.js +811 -0
  37. package/dist/550.node.js +1456 -0
  38. package/dist/551.js +2722 -0
  39. package/dist/551.node.js +2725 -0
  40. package/dist/617.js +19 -0
  41. package/dist/617.node.js +22 -0
  42. package/dist/687.js +3671 -0
  43. package/dist/687.node.js +3674 -0
  44. package/dist/745.js +7504 -0
  45. package/dist/745.node.js +7507 -0
  46. package/dist/775.js +1900 -0
  47. package/dist/775.node.js +1903 -0
  48. package/dist/786.js +31378 -0
  49. package/dist/786.node.js +31381 -0
  50. package/dist/788.js +1021 -0
  51. package/dist/788.node.js +1024 -0
  52. package/dist/81.js +382 -0
  53. package/dist/81.node.js +385 -0
  54. package/dist/849.js +2586 -0
  55. package/dist/849.node.js +2589 -0
  56. package/dist/863.js +19 -0
  57. package/dist/863.node.js +22 -0
  58. package/dist/867.js +1414 -0
  59. package/dist/867.node.js +1417 -0
  60. package/dist/871.js +1533 -0
  61. package/dist/881.js +1276 -0
  62. package/dist/881.node.js +1279 -0
  63. package/dist/885.js +48 -0
  64. package/dist/885.node.js +51 -0
  65. package/dist/896.js +1613 -0
  66. package/dist/896.node.js +1616 -0
  67. package/dist/906.js +1815 -0
  68. package/dist/906.node.js +1818 -0
  69. package/dist/91.js +19 -0
  70. package/dist/91.node.js +22 -0
  71. package/dist/940.js +3359 -0
  72. package/dist/940.node.js +3362 -0
  73. package/dist/952.js +243 -0
  74. package/dist/952.node.js +246 -0
  75. package/dist/995.js +5734 -0
  76. package/dist/995.node.js +5737 -0
  77. package/dist/components/Code/index.d.ts +1 -1
  78. package/dist/main.css +1 -1
  79. package/dist/main.js +94897 -73869
  80. package/dist/main.node.js +103618 -82699
  81. package/package.json +3 -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,17 @@
1
1
  import { uppercase } from '@readme/syntax-highlighter';
2
- import React from 'react';
2
+ import React, { useEffect } from 'react';
3
+ import mermaid from 'mermaid';
3
4
 
4
5
  const CodeTabs = props => {
5
6
  const { children, theme } = props;
6
7
 
8
+ // set Mermaid theme
9
+ useEffect(() => {
10
+ mermaid.initialize({
11
+ theme: theme === 'dark' ? 'dark' : 'default',
12
+ });
13
+ }, [theme])
14
+
7
15
  function handleClick({ target }, index: number) {
8
16
  const $wrap = target.parentElement.parentElement;
9
17
  const $open = [].slice.call($wrap.querySelectorAll('.CodeTabs_active'));
@@ -14,6 +22,21 @@ const CodeTabs = props => {
14
22
  codeblocks[index].classList.add('CodeTabs_active');
15
23
 
16
24
  target.classList.add('CodeTabs_active');
25
+
26
+ if (target.value === 'mermaid') {
27
+ const $openMermaid = [].slice.call($wrap.querySelectorAll('.mermaid'));
28
+ $openMermaid.forEach((el: Element) => el.classList.remove('mermaid'));
29
+ codeblocks[index].classList.add('mermaid');
30
+ mermaid.contentLoaded();
31
+ }
32
+ }
33
+
34
+ // render single Mermaid diagram
35
+ if (!Array.isArray(children) && children.props?.children.props.lang === 'mermaid') {
36
+ const value = children.props.children.props.value;
37
+ return (
38
+ <pre className="mermaid mermaid_single">{value}</pre>
39
+ )
17
40
  }
18
41
 
19
42
  return (
@@ -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
  }