@redocly/theme 0.64.0-next.2 → 0.64.0-next.4

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 (162) hide show
  1. package/lib/components/Admonition/Admonition.d.ts +1 -1
  2. package/lib/components/Admonition/Admonition.js +2 -0
  3. package/lib/components/Admonition/variables.dark.js +3 -0
  4. package/lib/components/Admonition/variables.js +13 -0
  5. package/lib/components/Button/variables.dark.js +2 -2
  6. package/lib/components/Button/variables.js +3 -3
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +3 -1
  8. package/lib/components/Catalog/CatalogTags.js +5 -2
  9. package/lib/components/Filter/variables.js +1 -1
  10. package/lib/components/LanguagePicker/LanguagePicker.js +5 -6
  11. package/lib/components/Link/Link.js +2 -2
  12. package/lib/components/Menu/MenuItem.js +1 -0
  13. package/lib/components/Menu/variables.dark.js +2 -0
  14. package/lib/components/Menu/variables.js +4 -3
  15. package/lib/components/Search/SearchAiMessage.js +9 -6
  16. package/lib/components/SvgViewer/SvgViewer.js +0 -3
  17. package/lib/components/SvgViewer/variables.js +1 -1
  18. package/lib/components/Switch/variables.dark.js +2 -2
  19. package/lib/components/Switch/variables.js +1 -1
  20. package/lib/components/TableOfContent/TableOfContent.js +1 -0
  21. package/lib/components/TableOfContent/variables.js +3 -2
  22. package/lib/components/Toast/Toast.d.ts +14 -0
  23. package/lib/components/Toast/Toast.js +239 -0
  24. package/lib/components/Toast/variables.d.ts +1 -0
  25. package/lib/components/Toast/variables.js +64 -0
  26. package/lib/components/Tooltip/JsTooltip.js +1 -1
  27. package/lib/core/constants/search.d.ts +3 -3
  28. package/lib/core/constants/toast.d.ts +1 -0
  29. package/lib/core/constants/toast.js +5 -0
  30. package/lib/core/contexts/MarkdownLinkContext.d.ts +5 -0
  31. package/lib/core/contexts/MarkdownLinkContext.js +6 -0
  32. package/lib/core/contexts/Toast/ToastContext.d.ts +2 -0
  33. package/lib/core/contexts/Toast/ToastContext.js +6 -0
  34. package/lib/core/contexts/Toast/ToastProvider.d.ts +3 -0
  35. package/lib/core/contexts/Toast/ToastProvider.js +156 -0
  36. package/lib/core/contexts/index.d.ts +3 -0
  37. package/lib/core/contexts/index.js +3 -0
  38. package/lib/core/hooks/index.d.ts +2 -0
  39. package/lib/core/hooks/index.js +2 -0
  40. package/lib/core/hooks/use-toast-logic.d.ts +18 -0
  41. package/lib/core/hooks/use-toast-logic.js +141 -0
  42. package/lib/core/hooks/use-toast.d.ts +11 -0
  43. package/lib/core/hooks/use-toast.js +17 -0
  44. package/lib/core/styles/dark.js +33 -40
  45. package/lib/core/styles/global.js +56 -54
  46. package/lib/core/styles/palette.dark.js +15 -30
  47. package/lib/core/styles/palette.js +130 -134
  48. package/lib/core/types/hooks.d.ts +2 -9
  49. package/lib/core/types/index.d.ts +1 -0
  50. package/lib/core/types/l10n.d.ts +1 -1
  51. package/lib/core/types/search.d.ts +2 -1
  52. package/lib/core/types/toast.d.ts +23 -0
  53. package/lib/core/types/toast.js +3 -0
  54. package/lib/core/utils/get-auto-dismiss-duration.d.ts +2 -0
  55. package/lib/core/utils/get-auto-dismiss-duration.js +15 -0
  56. package/lib/core/utils/index.d.ts +1 -0
  57. package/lib/core/utils/index.js +1 -0
  58. package/lib/icons/CheckboxIcon/CheckboxIcon.js +6 -4
  59. package/lib/icons/CheckboxIcon/variables.dark.js +2 -1
  60. package/lib/icons/CheckboxIcon/variables.js +3 -3
  61. package/lib/icons/IdeaIcon/IdeaIcon.d.ts +9 -0
  62. package/lib/icons/IdeaIcon/IdeaIcon.js +24 -0
  63. package/lib/icons/NewChatIcon/NewChatIcon.d.ts +11 -0
  64. package/lib/icons/NewChatIcon/NewChatIcon.js +25 -0
  65. package/lib/index.d.ts +4 -0
  66. package/lib/index.js +4 -0
  67. package/lib/markdoc/attributes/diagram-file.d.ts +5 -0
  68. package/lib/markdoc/attributes/diagram-file.js +16 -0
  69. package/lib/markdoc/components/Diagram/Diagram.d.ts +15 -0
  70. package/lib/markdoc/components/Diagram/Diagram.js +135 -0
  71. package/lib/markdoc/components/Diagram/variables.d.ts +1 -0
  72. package/lib/markdoc/components/Diagram/variables.js +15 -0
  73. package/lib/markdoc/components/MarkdownLink/MarkdownLink.d.ts +7 -0
  74. package/lib/markdoc/components/MarkdownLink/MarkdownLink.js +61 -0
  75. package/lib/markdoc/components/Tabs/variables.js +3 -3
  76. package/lib/markdoc/components/default.d.ts +2 -2
  77. package/lib/markdoc/components/default.js +2 -2
  78. package/lib/markdoc/default.d.ts +7 -0
  79. package/lib/markdoc/default.js +3 -0
  80. package/lib/markdoc/tags/admonition.js +1 -1
  81. package/lib/markdoc/tags/diagram.d.ts +2 -0
  82. package/lib/markdoc/tags/diagram.js +63 -0
  83. package/package.json +3 -3
  84. package/src/components/Admonition/Admonition.tsx +3 -1
  85. package/src/components/Admonition/variables.dark.ts +3 -0
  86. package/src/components/Admonition/variables.ts +13 -0
  87. package/src/components/Button/variables.dark.ts +2 -2
  88. package/src/components/Button/variables.ts +3 -3
  89. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +3 -1
  90. package/src/components/Catalog/CatalogTags.tsx +6 -1
  91. package/src/components/Filter/variables.ts +1 -1
  92. package/src/components/LanguagePicker/LanguagePicker.tsx +5 -5
  93. package/src/components/Link/Link.tsx +1 -1
  94. package/src/components/Menu/MenuItem.tsx +5 -1
  95. package/src/components/Menu/variables.dark.ts +2 -0
  96. package/src/components/Menu/variables.ts +4 -3
  97. package/src/components/Search/SearchAiMessage.tsx +15 -10
  98. package/src/components/SvgViewer/SvgViewer.tsx +0 -4
  99. package/src/components/SvgViewer/variables.ts +1 -1
  100. package/src/components/Switch/variables.dark.ts +2 -2
  101. package/src/components/Switch/variables.ts +1 -1
  102. package/src/components/TableOfContent/TableOfContent.tsx +1 -0
  103. package/src/components/TableOfContent/variables.ts +3 -2
  104. package/src/components/Toast/Toast.tsx +289 -0
  105. package/src/components/Toast/variables.ts +61 -0
  106. package/src/components/Tooltip/JsTooltip.tsx +1 -1
  107. package/src/core/constants/search.ts +2 -3
  108. package/src/core/constants/toast.ts +1 -0
  109. package/src/core/contexts/MarkdownLinkContext.tsx +9 -0
  110. package/src/core/contexts/Toast/ToastContext.tsx +5 -0
  111. package/src/core/contexts/Toast/ToastProvider.tsx +206 -0
  112. package/src/core/contexts/index.ts +3 -0
  113. package/src/core/hooks/index.ts +2 -0
  114. package/src/core/hooks/use-toast-logic.ts +203 -0
  115. package/src/core/hooks/use-toast.ts +47 -0
  116. package/src/core/styles/dark.ts +5 -12
  117. package/src/core/styles/global.ts +28 -26
  118. package/src/core/styles/palette.dark.ts +15 -30
  119. package/src/core/styles/palette.ts +130 -134
  120. package/src/core/types/hooks.ts +2 -7
  121. package/src/core/types/index.ts +1 -0
  122. package/src/core/types/l10n.ts +9 -9
  123. package/src/core/types/search.ts +2 -1
  124. package/src/core/types/toast.ts +28 -0
  125. package/src/core/utils/get-auto-dismiss-duration.ts +20 -0
  126. package/src/core/utils/index.ts +1 -0
  127. package/src/icons/CheckboxIcon/CheckboxIcon.tsx +26 -17
  128. package/src/icons/CheckboxIcon/variables.dark.ts +2 -1
  129. package/src/icons/CheckboxIcon/variables.ts +3 -3
  130. package/src/icons/IdeaIcon/IdeaIcon.tsx +32 -0
  131. package/src/icons/NewChatIcon/NewChatIcon.tsx +39 -0
  132. package/src/index.ts +4 -0
  133. package/src/markdoc/attributes/diagram-file.ts +9 -0
  134. package/src/markdoc/components/Diagram/Diagram.tsx +173 -0
  135. package/src/markdoc/components/Diagram/variables.ts +12 -0
  136. package/src/markdoc/components/MarkdownLink/MarkdownLink.tsx +21 -0
  137. package/src/markdoc/components/Tabs/variables.ts +3 -3
  138. package/src/markdoc/components/default.ts +2 -2
  139. package/src/markdoc/default.ts +3 -0
  140. package/src/markdoc/tags/admonition.ts +1 -1
  141. package/src/markdoc/tags/diagram.ts +73 -0
  142. package/lib/components/SvgViewer/variables.dark.d.ts +0 -1
  143. package/lib/components/SvgViewer/variables.dark.js +0 -8
  144. package/lib/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.d.ts +0 -7
  145. package/lib/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.js +0 -95
  146. package/lib/markdoc/components/ExcalidrawDiagram/variables.d.ts +0 -1
  147. package/lib/markdoc/components/ExcalidrawDiagram/variables.dark.d.ts +0 -1
  148. package/lib/markdoc/components/ExcalidrawDiagram/variables.dark.js +0 -8
  149. package/lib/markdoc/components/ExcalidrawDiagram/variables.js +0 -15
  150. package/lib/markdoc/components/Mermaid/Mermaid.d.ts +0 -9
  151. package/lib/markdoc/components/Mermaid/Mermaid.js +0 -96
  152. package/lib/markdoc/components/Mermaid/variables.d.ts +0 -1
  153. package/lib/markdoc/components/Mermaid/variables.dark.d.ts +0 -1
  154. package/lib/markdoc/components/Mermaid/variables.dark.js +0 -8
  155. package/lib/markdoc/components/Mermaid/variables.js +0 -16
  156. package/src/components/SvgViewer/variables.dark.ts +0 -5
  157. package/src/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.tsx +0 -85
  158. package/src/markdoc/components/ExcalidrawDiagram/variables.dark.ts +0 -5
  159. package/src/markdoc/components/ExcalidrawDiagram/variables.ts +0 -12
  160. package/src/markdoc/components/Mermaid/Mermaid.tsx +0 -95
  161. package/src/markdoc/components/Mermaid/variables.dark.ts +0 -5
  162. package/src/markdoc/components/Mermaid/variables.ts +0 -13
@@ -0,0 +1,173 @@
1
+ import React, { useState } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { JSX } from 'react';
5
+
6
+ import { concatClassNames } from '@redocly/theme/core/utils';
7
+ import { useColorSwitcher } from '@redocly/theme/core/hooks';
8
+ import { useThemeHooks } from '@redocly/theme/core/hooks';
9
+ import { SvgViewer } from '@redocly/theme/components/SvgViewer/SvgViewer';
10
+
11
+ type DiagramProps = {
12
+ id?: string;
13
+ diagramHtml: string;
14
+ diagramHtmlDark?: string;
15
+ diagramError?: string;
16
+ diagramType: string;
17
+ align?: 'left' | 'center' | 'right';
18
+ width?: string;
19
+ 'data-source'?: string;
20
+ 'data-hash'?: string;
21
+ className?: string;
22
+ };
23
+
24
+ export function Diagram({
25
+ id,
26
+ diagramHtml,
27
+ diagramHtmlDark,
28
+ diagramError,
29
+ diagramType,
30
+ align,
31
+ width,
32
+ 'data-source': dataSource,
33
+ 'data-hash': dataHash,
34
+ className,
35
+ }: DiagramProps): JSX.Element {
36
+ const { useTranslate } = useThemeHooks();
37
+ const { translate } = useTranslate();
38
+ const { activeColorMode } = useColorSwitcher();
39
+ const [isOpen, setIsOpen] = useState(false);
40
+ const activeDiagramHtml =
41
+ activeColorMode === 'dark' ? diagramHtmlDark || diagramHtml : diagramHtml;
42
+
43
+ const open = () => setIsOpen(true);
44
+ const close = () => setIsOpen(false);
45
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
46
+ if (event.key === 'Enter' || event.key === ' ') {
47
+ event.preventDefault();
48
+ open();
49
+ }
50
+ };
51
+
52
+ if (diagramError) {
53
+ return (
54
+ <ErrorWrapper id={id} className={concatClassNames('diagram-error', className)}>
55
+ {diagramError}
56
+ </ErrorWrapper>
57
+ );
58
+ }
59
+
60
+ return (
61
+ <>
62
+ <Wrapper
63
+ id={id}
64
+ $width={width}
65
+ className={concatClassNames(`diagram-wrapper diagram-${diagramType}`, className)}
66
+ data-component-name="Markdoc/Diagram/Diagram"
67
+ data-diagram-type={diagramType}
68
+ data-source={dataSource}
69
+ data-hash={dataHash}
70
+ onClick={open}
71
+ onKeyDown={handleKeyDown}
72
+ role="button"
73
+ tabIndex={0}
74
+ aria-label={translate('diagram.openFullscreen', 'Click to open diagram in fullscreen')}
75
+ >
76
+ <DiagramVariant
77
+ $align={align}
78
+ $colorMode="light"
79
+ className={`diagram-variant diagram-variant-light diagram-${diagramType}`}
80
+ dangerouslySetInnerHTML={{ __html: diagramHtml }}
81
+ />
82
+ {diagramHtmlDark ? (
83
+ <DiagramVariant
84
+ $align={align}
85
+ $colorMode="dark"
86
+ className={`diagram-variant diagram-variant-dark diagram-${diagramType}`}
87
+ dangerouslySetInnerHTML={{ __html: diagramHtmlDark }}
88
+ />
89
+ ) : null}
90
+ </Wrapper>
91
+ <SvgViewer
92
+ isOpen={isOpen}
93
+ onClose={close}
94
+ labels={{
95
+ zoomIn: translate('diagram.zoomIn', 'Zoom in'),
96
+ zoomOut: translate('diagram.zoomOut', 'Zoom out'),
97
+ fitToView: translate('diagram.reset', 'Fit to view'),
98
+ close: translate('diagram.close', 'Close'),
99
+ dialogLabel: translate('diagram.viewer', 'Diagram viewer'),
100
+ }}
101
+ >
102
+ <ViewerContent
103
+ className={`diagram-viewer-content diagram-${diagramType}`}
104
+ dangerouslySetInnerHTML={{ __html: activeDiagramHtml }}
105
+ />
106
+ </SvgViewer>
107
+ </>
108
+ );
109
+ }
110
+
111
+ const Wrapper = styled.div<{ $width?: string }>`
112
+ background-color: var(--diagram-bg-color);
113
+ border-radius: var(--diagram-border-radius);
114
+ cursor: pointer;
115
+ transition: box-shadow 0.2s ease;
116
+
117
+ &:hover,
118
+ &:focus {
119
+ outline: none;
120
+ box-shadow: 0 0 0 2px var(--border-color-input-focus);
121
+ }
122
+
123
+ svg {
124
+ max-width: 100%;
125
+ display: block;
126
+ ${({ $width }) => ($width ? `width: ${$width} !important; height: auto !important;` : '')}
127
+ }
128
+ `;
129
+
130
+ const DiagramVariant = styled.div<{ $colorMode: 'light' | 'dark'; $align?: DiagramProps['align'] }>`
131
+ display: flex;
132
+ justify-content: ${({ $align }) => {
133
+ switch ($align) {
134
+ case 'center':
135
+ return 'center';
136
+ case 'right':
137
+ return 'flex-end';
138
+ default:
139
+ return 'flex-start';
140
+ }
141
+ }};
142
+ width: 100%;
143
+ ${({ $colorMode }) =>
144
+ $colorMode === 'dark'
145
+ ? `
146
+ html:not(.dark) && {
147
+ display: none;
148
+ }
149
+ `
150
+ : `
151
+ html.dark && {
152
+ display: none;
153
+ }
154
+ `}
155
+ `;
156
+
157
+ const ErrorWrapper = styled.div`
158
+ border: 1px solid var(--color-error-border);
159
+ border-radius: var(--diagram-border-radius);
160
+ background: var(--color-error-bg);
161
+ color: var(--color-error-text);
162
+ font-size: var(--font-size-sm);
163
+ padding: var(--spacing-sm);
164
+ white-space: pre-wrap;
165
+ word-break: break-word;
166
+ `;
167
+
168
+ const ViewerContent = styled.div`
169
+ svg {
170
+ display: block;
171
+ max-width: none !important;
172
+ }
173
+ `;
@@ -0,0 +1,12 @@
1
+ import { css } from "styled-components";
2
+
3
+ export const diagram = css`
4
+ /**
5
+ * @tokens Diagram
6
+ */
7
+
8
+ --diagram-bg-color: var(--bg-color-raised); // @presenter Color
9
+ --diagram-border-radius: var(--border-radius-lg); // @presenter BorderRadius
10
+
11
+ // @tokens End
12
+ `;
@@ -0,0 +1,21 @@
1
+ import React, { useCallback, useContext } from 'react';
2
+
3
+ import type { ComponentProps, ReactElement } from 'react';
4
+
5
+ import { MarkdownLinkContext } from '@redocly/theme/core/contexts';
6
+ import { Link } from '@redocly/theme/components/Link/Link';
7
+
8
+ type MarkdownLinkProps = Omit<ComponentProps<typeof Link>, 'to' | 'onClick'> & {
9
+ href: string;
10
+ };
11
+
12
+ export function MarkdownLink({ href, ...props }: MarkdownLinkProps): ReactElement {
13
+ const markdownLinkContext = useContext(MarkdownLinkContext);
14
+ const onClick = useCallback(() => {
15
+ markdownLinkContext?.onMarkdownLinkClick?.();
16
+ }, [markdownLinkContext]);
17
+
18
+ const linkProps = { ...props, languageInsensitive: true, onClick };
19
+
20
+ return <Link to={href} {...linkProps} />;
21
+ }
@@ -52,11 +52,11 @@ export const markdownTabs = css`
52
52
  --md-tabs-small-tab-line-height: var(--line-height-base); // @presenter LineHeight
53
53
  --md-tabs-small-tab-border-radius: var(--border-radius); // @presenter BorderRadius
54
54
 
55
- --md-tabs-active-tab-text-color: var(--text-color-primary); // @presenter Color
55
+ --md-tabs-active-tab-text-color: var(--color-primary-text, var(--md-tabs-active-tab-text-color-legacy)); // @presenter Color
56
56
  --md-tabs-active-tab-font-family: var(--md-tabs-tab-font-family); // @presenter FontFamily
57
57
  --md-tabs-active-tab-font-style: normal; // @presenter FontStyle
58
- --md-tabs-active-tab-bg-color: var(--bg-color-active); // @presenter Color
59
- --md-tabs-active-tab-border-color: var(--text-color-primary); // @presenter Color
58
+ --md-tabs-active-tab-bg-color: var(--color-primary-bg, var(--md-tabs-active-tab-bg-color-legacy)); // @presenter Color
59
+ --md-tabs-active-tab-border-color: var(--color-primary-active, var(--md-tabs-active-tab-border-color-legacy)); // @presenter Color
60
60
 
61
61
  --md-tabs-medium-active-tab-font-size: var(--md-tabs-medium-tab-font-size); // @presenter FontSize
62
62
  --md-tabs-medium-active-tab-font-weight: var(--md-tabs-medium-tab-font-weight); // @presenter FontWeight
@@ -2,8 +2,7 @@ export * from '@redocly/theme/markdoc/components/Admonition/Admonition';
2
2
  export * from '@redocly/theme/markdoc/components/InlineSvg/InlineSvg';
3
3
  export * from '@redocly/theme/markdoc/components/MarkdocExample/MarkdocExample';
4
4
  export * from '@redocly/theme/markdoc/components/Heading/Heading';
5
- export * from '@redocly/theme/markdoc/components/Mermaid/Mermaid';
6
- export * from '@redocly/theme/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram';
5
+ export * from '@redocly/theme/markdoc/components/Diagram/Diagram';
7
6
  export * from '@redocly/theme/markdoc/components/HtmlBlock/HtmlBlock';
8
7
  export * from '@redocly/theme/markdoc/components/Tabs/Tab';
9
8
  export * from '@redocly/theme/markdoc/components/Tabs/TabList';
@@ -23,3 +22,4 @@ export * from '@redocly/theme/markdoc/components/CodeGroup/CodeGroup';
23
22
  export * from '@redocly/theme/markdoc/components/Icon/Icon';
24
23
  export * from '@redocly/theme/markdoc/components/ConnectMCP/ConnectMCP';
25
24
  export * from '@redocly/theme/markdoc/components/LoginButton/LoginButton';
25
+ export * from '@redocly/theme/markdoc/components/MarkdownLink/MarkdownLink';
@@ -1,5 +1,6 @@
1
1
  /* Attributes */
2
2
  export * from '@redocly/theme/markdoc/attributes/code-snippet-file';
3
+ export * from '@redocly/theme/markdoc/attributes/diagram-file';
3
4
  export * from '@redocly/theme/markdoc/attributes/img-src';
4
5
  export * from '@redocly/theme/markdoc/attributes/img-srcset';
5
6
  export * from '@redocly/theme/markdoc/attributes/relative-path';
@@ -27,6 +28,7 @@ import { codeGroup } from '@redocly/theme/markdoc/tags/code-group';
27
28
  import { icon } from '@redocly/theme/markdoc/tags/icon';
28
29
  import { connectMcp } from '@redocly/theme/markdoc/tags/connect-mcp';
29
30
  import { loginButton } from '@redocly/theme/markdoc/tags/login-button';
31
+ import { diagram } from '@redocly/theme/markdoc/tags/diagram';
30
32
 
31
33
  export const tags = {
32
34
  [admonition.tagName]: admonition.schema,
@@ -49,4 +51,5 @@ export const tags = {
49
51
  [icon.tagName]: icon.schema,
50
52
  [connectMcp.tagName]: connectMcp.schema,
51
53
  [loginButton.tagName]: loginButton.schema,
54
+ [diagram.tagName]: diagram.schema,
52
55
  };
@@ -7,7 +7,7 @@ export const admonition: MarkdocSchemaWrapper = {
7
7
  type: String,
8
8
  required: true,
9
9
  default: 'info',
10
- matches: ['warning', 'info', 'danger', 'success'],
10
+ matches: ['warning', 'info', 'danger', 'success', 'default'],
11
11
  },
12
12
  name: { type: String },
13
13
  },
@@ -0,0 +1,73 @@
1
+ import markdoc from '@markdoc/markdoc';
2
+
3
+ import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
4
+
5
+ import { DiagramFile } from '@redocly/theme/markdoc/attributes/diagram-file';
6
+
7
+ const DIAGRAM_TYPES = ['mermaid', 'plantuml', 'excalidraw'];
8
+ const DIAGRAM_ALIGNMENTS = ['left', 'center', 'right'];
9
+
10
+ export const diagram: MarkdocSchemaWrapper = {
11
+ schema: {
12
+ attributes: {
13
+ file: { type: DiagramFile, required: true },
14
+ type: {
15
+ type: String,
16
+ required: true,
17
+ matches: DIAGRAM_TYPES,
18
+ },
19
+ align: {
20
+ type: String,
21
+ matches: DIAGRAM_ALIGNMENTS,
22
+ },
23
+ width: {
24
+ type: String,
25
+ },
26
+ rawContent: { type: String, render: false }, // internal — populated by resolver
27
+ },
28
+ render: 'Diagram',
29
+ selfClosing: true,
30
+ transform: (node, config) => {
31
+ const attributes = node.transformAttributes(config);
32
+ const rawContent = node.attributes.rawContent;
33
+ const diagramType = node.attributes.type;
34
+
35
+ if (typeof rawContent === 'string') {
36
+ return new markdoc.Tag(
37
+ 'Diagram',
38
+ {
39
+ ...attributes,
40
+ diagramType,
41
+ diagramSource: rawContent,
42
+ },
43
+ [],
44
+ );
45
+ }
46
+
47
+ return new markdoc.Tag(node.tag, attributes, []);
48
+ },
49
+ validate(node) {
50
+ const errors = [];
51
+ const type = node.attributes.type;
52
+ if (type && !DIAGRAM_TYPES.includes(type)) {
53
+ errors.push({
54
+ id: 'invalid-diagram-type',
55
+ level: 'error' as const,
56
+ message: `Invalid diagram type "${type}". Must be one of: ${DIAGRAM_TYPES.join(', ')}`,
57
+ });
58
+ }
59
+ const align = node.attributes.align;
60
+ if (align && !DIAGRAM_ALIGNMENTS.includes(align)) {
61
+ errors.push({
62
+ id: 'invalid-diagram-align',
63
+ level: 'error' as const,
64
+ message: `Invalid diagram align "${align}". Must be one of: ${DIAGRAM_ALIGNMENTS.join(
65
+ ', ',
66
+ )}`,
67
+ });
68
+ }
69
+ return errors;
70
+ },
71
+ },
72
+ tagName: 'diagram',
73
+ };
@@ -1 +0,0 @@
1
- export declare const svgViewerDarkMode: import("styled-components").FlattenSimpleInterpolation;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.svgViewerDarkMode = void 0;
4
- const styled_components_1 = require("styled-components");
5
- exports.svgViewerDarkMode = (0, styled_components_1.css) `
6
- --svg-viewer-bg-color: var(--color-warm-grey-3);
7
- `;
8
- //# sourceMappingURL=variables.dark.js.map
@@ -1,7 +0,0 @@
1
- import type { JSX } from 'react';
2
- type ExcalidrawDiagramProps = {
3
- diagramHtml: string;
4
- className?: string;
5
- };
6
- export declare function ExcalidrawDiagram({ diagramHtml, className }: ExcalidrawDiagramProps): JSX.Element;
7
- export {};
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ExcalidrawDiagram = ExcalidrawDiagram;
40
- const react_1 = __importStar(require("react"));
41
- const styled_components_1 = __importDefault(require("styled-components"));
42
- const utils_1 = require("../../../core/utils");
43
- const hooks_1 = require("../../../core/hooks");
44
- const SvgViewer_1 = require("../../../components/SvgViewer/SvgViewer");
45
- function ExcalidrawDiagram({ diagramHtml, className }) {
46
- const { useTranslate } = (0, hooks_1.useThemeHooks)();
47
- const { translate } = useTranslate();
48
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
49
- const open = () => setIsOpen(true);
50
- const close = () => setIsOpen(false);
51
- return (react_1.default.createElement(react_1.default.Fragment, null,
52
- react_1.default.createElement(Wrapper, { className: (0, utils_1.concatClassNames)('excalidraw-wrapper', className), dangerouslySetInnerHTML: { __html: diagramHtml }, "data-component-name": "Markdoc/ExcalidrawDiagram/ExcalidrawDiagram", onClick: open, onKeyDown: (e) => (e.key === 'Enter' || e.key === ' ') && open(), role: "button", tabIndex: 0, "aria-label": translate('excalidraw.openFullscreen', 'Click to open diagram in fullscreen') }),
53
- react_1.default.createElement(SvgViewer_1.SvgViewer, { isOpen: isOpen, onClose: close, labels: {
54
- zoomIn: translate('excalidraw.zoomIn', 'Zoom in'),
55
- zoomOut: translate('excalidraw.zoomOut', 'Zoom out'),
56
- fitToView: translate('excalidraw.reset', 'Fit to view'),
57
- close: translate('excalidraw.close', 'Close'),
58
- dialogLabel: translate('excalidraw.viewer', 'Excalidraw diagram viewer'),
59
- } },
60
- react_1.default.createElement(ViewerContent, { dangerouslySetInnerHTML: { __html: diagramHtml } }))));
61
- }
62
- const Wrapper = styled_components_1.default.div `
63
- background-color: var(--excalidraw-bg-color);
64
- border-radius: var(--excalidraw-border-radius);
65
- cursor: pointer;
66
- transition: box-shadow 0.2s ease;
67
- overflow: hidden;
68
-
69
- &:hover,
70
- &:focus {
71
- outline: none;
72
- box-shadow: 0 0 0 2px var(--border-color-input-focus);
73
- }
74
-
75
- svg {
76
- max-width: 100%;
77
- height: auto;
78
- display: block;
79
-
80
- > rect {
81
- fill: var(--excalidraw-bg-color);
82
- }
83
- }
84
-
85
- & + & {
86
- margin-top: var(--spacing-md);
87
- }
88
- `;
89
- const ViewerContent = styled_components_1.default.div `
90
- svg {
91
- display: block;
92
- max-width: none !important;
93
- }
94
- `;
95
- //# sourceMappingURL=ExcalidrawDiagram.js.map
@@ -1 +0,0 @@
1
- export declare const excalidraw: import("styled-components").FlattenSimpleInterpolation;
@@ -1 +0,0 @@
1
- export declare const excalidrawDarkMode: import("styled-components").FlattenSimpleInterpolation;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.excalidrawDarkMode = void 0;
4
- const styled_components_1 = require("styled-components");
5
- exports.excalidrawDarkMode = (0, styled_components_1.css) `
6
- --excalidraw-bg-color: var(--bg-color); // @presenter Color
7
- `;
8
- //# sourceMappingURL=variables.dark.js.map
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.excalidraw = void 0;
4
- const styled_components_1 = require("styled-components");
5
- exports.excalidraw = (0, styled_components_1.css) `
6
- /**
7
- * @tokens Excalidraw
8
- */
9
-
10
- --excalidraw-bg-color: var(--bg-color); // @presenter Color
11
- --excalidraw-border-radius: var(--border-radius-lg); // @presenter BorderRadius
12
-
13
- // @tokens End
14
- `;
15
- //# sourceMappingURL=variables.js.map
@@ -1,9 +0,0 @@
1
- import type { JSX } from 'react';
2
- type MermaidProps = {
3
- diagramHtml: string;
4
- 'data-source'?: string;
5
- 'data-hash'?: string;
6
- className?: string;
7
- };
8
- export declare function Mermaid({ diagramHtml, 'data-source': dataSource, 'data-hash': dataHash, className, }: MermaidProps): JSX.Element;
9
- export {};
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Mermaid = Mermaid;
40
- const react_1 = __importStar(require("react"));
41
- const styled_components_1 = __importDefault(require("styled-components"));
42
- const utils_1 = require("../../../core/utils");
43
- const hooks_1 = require("../../../core/hooks");
44
- const SvgViewer_1 = require("../../../components/SvgViewer/SvgViewer");
45
- function Mermaid({ diagramHtml, 'data-source': dataSource, 'data-hash': dataHash, className, }) {
46
- const { useTranslate } = (0, hooks_1.useThemeHooks)();
47
- const { translate } = useTranslate();
48
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
49
- const open = () => setIsOpen(true);
50
- const close = () => setIsOpen(false);
51
- return (react_1.default.createElement(react_1.default.Fragment, null,
52
- react_1.default.createElement(Wrapper, { className: (0, utils_1.concatClassNames)('mermaid-wrapper', className), dangerouslySetInnerHTML: { __html: diagramHtml }, "data-component-name": "Markdoc/Mermaid/Mermaid", "data-source": dataSource, "data-hash": dataHash, onClick: open, onKeyDown: (e) => e.key === 'Enter' || (e.key === ' ' && open()), role: "button", tabIndex: 0, "aria-label": translate('mermaid.openFullscreen', 'Click to open diagram in fullscreen') }),
53
- react_1.default.createElement(SvgViewer_1.SvgViewer, { isOpen: isOpen, onClose: close, labels: {
54
- zoomIn: translate('mermaid.zoomIn', 'Zoom in'),
55
- zoomOut: translate('mermaid.zoomOut', 'Zoom out'),
56
- fitToView: translate('mermaid.reset', 'Fit to view'),
57
- close: translate('mermaid.close', 'Close'),
58
- dialogLabel: translate('mermaid.viewer', 'Mermaid diagram viewer'),
59
- } },
60
- react_1.default.createElement(ViewerContent, { dangerouslySetInnerHTML: { __html: diagramHtml } }))));
61
- }
62
- const Wrapper = styled_components_1.default.div `
63
- background-color: var(--mermaid-bg-color);
64
- border-radius: var(--mermaid-border-radius);
65
- cursor: pointer;
66
- transition: box-shadow 0.2s ease;
67
-
68
- &:hover,
69
- &:focus {
70
- outline: none;
71
- box-shadow: 0 0 0 2px var(--border-color-input-focus);
72
- }
73
-
74
- * {
75
- font-family: var(--mermaid-font-family) !important;
76
- }
77
-
78
- .mermaid > svg {
79
- font-size: var(--font-size-base) !important;
80
- max-width: 100%;
81
- }
82
- `;
83
- const ViewerContent = styled_components_1.default.div `
84
- background-color: var(--mermaid-bg-color);
85
-
86
- * {
87
- font-family: var(--mermaid-font-family) !important;
88
- }
89
-
90
- .mermaid > svg {
91
- font-size: var(--font-size-base) !important;
92
- display: block;
93
- max-width: none !important;
94
- }
95
- `;
96
- //# sourceMappingURL=Mermaid.js.map
@@ -1 +0,0 @@
1
- export declare const mermaid: import("styled-components").FlattenSimpleInterpolation;
@@ -1 +0,0 @@
1
- export declare const mermaidDarkMode: import("styled-components").FlattenSimpleInterpolation;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mermaidDarkMode = void 0;
4
- const styled_components_1 = require("styled-components");
5
- exports.mermaidDarkMode = (0, styled_components_1.css) `
6
- --mermaid-bg-color: var(--color-warm-grey-8); // @presenter Color
7
- `;
8
- //# sourceMappingURL=variables.dark.js.map
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mermaid = void 0;
4
- const styled_components_1 = require("styled-components");
5
- exports.mermaid = (0, styled_components_1.css) `
6
- /**
7
- * @tokens Mermaid
8
- */
9
-
10
- --mermaid-bg-color: var(--bg-color-raised); // @presenter Color
11
- --mermaid-border-radius: var(--border-radius-lg); // @presenter BorderRadius
12
- --mermaid-font-family: var(--font-family-base); // @presenter FontFamily
13
-
14
- // @tokens End
15
- `;
16
- //# sourceMappingURL=variables.js.map
@@ -1,5 +0,0 @@
1
- import { css } from 'styled-components';
2
-
3
- export const svgViewerDarkMode = css`
4
- --svg-viewer-bg-color: var(--color-warm-grey-3);
5
- `;