@redocly/theme 0.46.2 → 0.46.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.
@@ -5,7 +5,6 @@ import type { ResolvedNavLinkItem } from '@redocly/config';
5
5
 
6
6
  import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
7
7
  import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
8
- import { GridIcon } from '@redocly/theme/icons/GridIcon/GridIcon';
9
8
  import { useThemeHooks, useThemeConfig } from '@redocly/theme/core/hooks';
10
9
  import { LoginButton } from '@redocly/theme/components/UserMenu/LoginButton';
11
10
  import { UserAvatar } from '@redocly/theme/components/UserMenu/UserAvatar';
@@ -25,7 +24,7 @@ export function UserMenu({ className }: UserMenuProps) {
25
24
  };
26
25
  }>();
27
26
  const { useTranslate, useUserMenu } = useThemeHooks();
28
- const { userData, hasDeveloperOnboarding, loginUrl } = useUserMenu();
27
+ const { userData, loginUrl } = useUserMenu();
29
28
  const { translate } = useTranslate();
30
29
 
31
30
  if (!userData?.isAuthenticated) {
@@ -40,24 +39,11 @@ export function UserMenu({ className }: UserMenuProps) {
40
39
  }
41
40
  }
42
41
 
43
- const devOnboardingMenuItem = hasDeveloperOnboarding
44
- ? [
45
- <DropdownMenuItem
46
- key="my-apps"
47
- to="/apps"
48
- data-translation-key="userMenu.devOnboardingLabel"
49
- prefix={<GridIcon />}
50
- >
51
- {translate('userMenu.devOnboardingLabel')}
52
- </DropdownMenuItem>,
53
- ]
54
- : [];
55
-
56
42
  const menuItems = userMenu?.['menu'] || [];
57
43
 
58
44
  const customItems = menuItems.map((item) => (
59
45
  <DropdownMenuItem key={item.label} external={item.external} to={item.link || ''}>
60
- {item.label}
46
+ {item.labelTranslationKey ? translate(item.labelTranslationKey) : item.label}
61
47
  </DropdownMenuItem>
62
48
  ));
63
49
 
@@ -69,7 +55,6 @@ export function UserMenu({ className }: UserMenuProps) {
69
55
  key="userinfo"
70
56
  />,
71
57
  <DropdownMenuItem separatorLine={true} separator key="separator" />,
72
- ...devOnboardingMenuItem,
73
58
  ...customItems,
74
59
  <LogoutMenuItem key="logout" />,
75
60
  ];
@@ -13,6 +13,7 @@ const fallbacks = {
13
13
  useTelemetry: () => ({ telemetry: () => {} }),
14
14
  useBreadcrumbs: () => [],
15
15
  useCodeHighlight: () => ({ highlight: (rawContent: string) => rawContent }),
16
+ useUserMenu: () => ({}),
16
17
  };
17
18
 
18
19
  export const useThemeHooks = () => {
@@ -129,6 +129,8 @@ export type TranslationKey =
129
129
  | 'feedback.sentiment.thumbDown'
130
130
  | 'feedback.settings.leftScaleLabel'
131
131
  | 'feedback.settings.rightScaleLabel'
132
+ | 'feedback.settings.anonymousUserEmail.placeholder'
133
+ | 'feedback.settings.anonymousUserEmail.label'
132
134
  | 'codeSnippet.report.buttonText'
133
135
  | 'codeSnippet.report.tooltipText'
134
136
  | 'codeSnippet.report.label'
@@ -7,7 +7,7 @@ import { CardIcon } from '@redocly/theme/markdoc/components/Cards/CardIcon';
7
7
  import { Link } from '@redocly/theme/components/Link/Link';
8
8
 
9
9
  export type CardProps = React.PropsWithChildren<{
10
- title: string;
10
+ title?: string;
11
11
  image?: string;
12
12
  icon?: string;
13
13
  iconRawContent?: string;
@@ -22,7 +22,7 @@ export type CardProps = React.PropsWithChildren<{
22
22
  }>;
23
23
 
24
24
  export function Card({
25
- title,
25
+ title = '',
26
26
  image,
27
27
  icon,
28
28
  iconRawContent,
@@ -36,7 +36,7 @@ export function Card({
36
36
  to,
37
37
  children,
38
38
  }: CardProps) {
39
- const titleNoSpaces = title.replace(/\s+/g, '-').toLowerCase();
39
+ const titleNoSpaces = title?.replace(/\s+/g, '-').toLowerCase();
40
40
  const cardTitleId = `card-title-${titleNoSpaces}`;
41
41
  const justifyContent =
42
42
  align === 'center' ? 'center' : align === 'end' ? 'flex-end' : 'flex-start';
@@ -1,8 +1,30 @@
1
1
  import markdoc from '@markdoc/markdoc';
2
2
 
3
- import type { Config, Node } from '@markdoc/markdoc';
3
+ import type { Config, Node, RenderableTreeNode } from '@markdoc/markdoc';
4
4
  import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
5
5
 
6
+ // Walk through AST and look for raw markdown to parse
7
+ function parseInlineMarkdown(
8
+ ast: RenderableTreeNode | RenderableTreeNode[],
9
+ config: Config,
10
+ ): RenderableTreeNode | RenderableTreeNode[] {
11
+ if (Array.isArray(ast)) {
12
+ return ast.flatMap((child) => parseInlineMarkdown(child, config));
13
+ }
14
+
15
+ if (typeof ast === 'string') {
16
+ const parsed = markdoc.parse(ast);
17
+ return markdoc.transform(parsed, config);
18
+ }
19
+
20
+ if (ast && typeof ast === 'object' && ast.$$mdtype === 'Tag') {
21
+ const children = parseInlineMarkdown(ast.children, config);
22
+ return { ...ast, children } as RenderableTreeNode;
23
+ }
24
+
25
+ return ast;
26
+ }
27
+
6
28
  // This custom tag prevents evaluating any children markdoc tags (no children) so we can
7
29
  // have markdoc examples in code fences
8
30
  // approach copied from: https://github.com/markdoc/docs/blob/main/markdoc/tags/markdoc-example.markdoc.js
@@ -29,13 +51,16 @@ export const markdocExample: MarkdocSchemaWrapper = {
29
51
  title = fenceWithTitle?.value;
30
52
  }
31
53
 
54
+ const demoContent = node.children[0].transformChildren(config);
55
+ const parsedDemoContent = parseInlineMarkdown(demoContent, config);
56
+
32
57
  return new markdoc.Tag(
33
58
  'MarkdocExample',
34
59
  {
35
60
  ...attributes,
36
61
  title,
37
62
  language,
38
- demoContent: node.children[0].transformChildren(config),
63
+ demoContent: parsedDemoContent,
39
64
  rawContent: content,
40
65
  },
41
66
  [],