@redocly/theme 0.70.0-next.8 → 0.70.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.
- package/lib/components/LoadProgressBar/LoadProgressBar.d.ts +8 -0
- package/lib/components/LoadProgressBar/LoadProgressBar.js +122 -0
- package/lib/core/constants/index.d.ts +1 -0
- package/lib/core/constants/index.js +1 -0
- package/lib/core/constants/prompt.d.ts +9 -0
- package/lib/core/constants/prompt.js +33 -0
- package/lib/core/hooks/index.d.ts +3 -0
- package/lib/core/hooks/index.js +3 -0
- package/lib/core/hooks/prompt/use-prompt-actions.d.ts +7 -0
- package/lib/core/hooks/prompt/use-prompt-actions.js +19 -0
- package/lib/core/hooks/prompt/use-prompt-text-limit.d.ts +19 -0
- package/lib/core/hooks/prompt/use-prompt-text-limit.js +35 -0
- package/lib/core/hooks/use-page-actions.js +4 -8
- package/lib/core/hooks/use-pointer-border-highlight.d.ts +7 -0
- package/lib/core/hooks/use-pointer-border-highlight.js +29 -0
- package/lib/core/hooks/use-telemetry-fallback.d.ts +2 -0
- package/lib/core/hooks/use-telemetry-fallback.js +2 -0
- package/lib/core/styles/dark.js +14 -12
- package/lib/core/styles/global.js +16 -54
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/prompt.d.ts +9 -0
- package/lib/core/types/prompt.js +3 -0
- package/lib/core/utils/get-ai-prompt-link.d.ts +15 -0
- package/lib/core/utils/get-ai-prompt-link.js +29 -0
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/urls.js +1 -1
- package/lib/core/utils/with-load-progress.d.ts +3 -0
- package/lib/core/utils/with-load-progress.js +24 -19
- package/lib/ext/configure.d.ts +1 -1
- package/lib/ext/configure.js +0 -1
- package/lib/icons/LinkIcon/LinkIconSymbol.d.ts +12 -0
- package/lib/icons/LinkIcon/LinkIconSymbol.js +41 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/markdoc/components/Cards/Card.js +1 -1
- package/lib/markdoc/components/Prompt/Prompt.d.ts +15 -0
- package/lib/markdoc/components/Prompt/Prompt.js +163 -0
- package/lib/markdoc/components/Prompt/PromptActions.d.ts +13 -0
- package/lib/markdoc/components/Prompt/PromptActions.js +43 -0
- package/lib/markdoc/components/Prompt/PromptBody.d.ts +14 -0
- package/lib/markdoc/components/Prompt/PromptBody.js +99 -0
- package/lib/markdoc/components/Prompt/PromptCopyButton.d.ts +10 -0
- package/lib/markdoc/components/Prompt/PromptCopyButton.js +28 -0
- package/lib/markdoc/components/Prompt/PromptHeader.d.ts +9 -0
- package/lib/markdoc/components/Prompt/PromptHeader.js +57 -0
- package/lib/markdoc/components/Prompt/PromptShowHideButton.d.ts +7 -0
- package/lib/markdoc/components/Prompt/PromptShowHideButton.js +21 -0
- package/lib/markdoc/components/Prompt/PromptToggleLabel.d.ts +7 -0
- package/lib/markdoc/components/Prompt/PromptToggleLabel.js +28 -0
- package/lib/markdoc/components/Prompt/variables.d.ts +1 -0
- package/lib/markdoc/components/Prompt/variables.dark.d.ts +1 -0
- package/lib/markdoc/components/Prompt/variables.dark.js +8 -0
- package/lib/markdoc/components/Prompt/variables.js +44 -0
- package/lib/markdoc/components/default.d.ts +1 -0
- package/lib/markdoc/components/default.js +1 -0
- package/lib/markdoc/default.d.ts +2 -0
- package/lib/markdoc/default.js +2 -0
- package/lib/markdoc/tags/code-walkthrough.d.ts +1 -1
- package/lib/markdoc/tags/code-walkthrough.js +3 -5
- package/lib/markdoc/tags/prompt.d.ts +2 -0
- package/lib/markdoc/tags/prompt.js +56 -0
- package/package.json +2 -7
- package/src/components/LoadProgressBar/LoadProgressBar.tsx +113 -0
- package/src/core/constants/index.ts +1 -0
- package/src/core/constants/prompt.ts +34 -0
- package/src/core/hooks/__mocks__/index.ts +3 -0
- package/src/core/hooks/__mocks__/use-theme-hooks.ts +2 -0
- package/src/core/hooks/index.ts +3 -0
- package/src/core/hooks/prompt/use-prompt-actions.ts +28 -0
- package/src/core/hooks/prompt/use-prompt-text-limit.ts +59 -0
- package/src/core/hooks/use-page-actions.ts +4 -9
- package/src/core/hooks/use-pointer-border-highlight.ts +46 -0
- package/src/core/hooks/use-telemetry-fallback.ts +2 -0
- package/src/core/styles/dark.ts +2 -0
- package/src/core/styles/global.ts +2 -40
- package/src/core/types/index.ts +1 -0
- package/src/core/types/l10n.ts +11 -0
- package/src/core/types/prompt.ts +11 -0
- package/src/core/utils/get-ai-prompt-link.ts +30 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/urls.ts +1 -1
- package/src/core/utils/with-load-progress.ts +23 -18
- package/src/ext/configure.ts +1 -1
- package/src/icons/LinkIcon/LinkIconSymbol.tsx +51 -0
- package/src/index.ts +1 -0
- package/src/markdoc/components/Cards/Card.tsx +1 -1
- package/src/markdoc/components/Prompt/Prompt.tsx +219 -0
- package/src/markdoc/components/Prompt/PromptActions.tsx +104 -0
- package/src/markdoc/components/Prompt/PromptBody.tsx +107 -0
- package/src/markdoc/components/Prompt/PromptCopyButton.tsx +73 -0
- package/src/markdoc/components/Prompt/PromptHeader.tsx +81 -0
- package/src/markdoc/components/Prompt/PromptShowHideButton.tsx +43 -0
- package/src/markdoc/components/Prompt/PromptToggleLabel.tsx +41 -0
- package/src/markdoc/components/Prompt/variables.dark.ts +5 -0
- package/src/markdoc/components/Prompt/variables.ts +41 -0
- package/src/markdoc/components/default.ts +1 -0
- package/src/markdoc/default.ts +2 -0
- package/src/markdoc/tags/code-walkthrough.ts +4 -12
- package/src/markdoc/tags/prompt.ts +58 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const promptTag = css`
|
|
4
|
+
/**
|
|
5
|
+
* @tokens Prompt
|
|
6
|
+
**/
|
|
7
|
+
--prompt-bg-color: var(--bg-color); // @presenter Color
|
|
8
|
+
--prompt-border-color: var(--border-color-secondary); // @presenter Color
|
|
9
|
+
--prompt-border-width: var(--border-width); // @presenter Border
|
|
10
|
+
--prompt-border-radius: var(--border-radius-xl); // @presenter BorderRadius
|
|
11
|
+
--prompt-margin: var(--spacing-base) 0; // @presenter Spacing
|
|
12
|
+
--prompt-padding-vertical: var(--spacing-sm); // @presenter Spacing
|
|
13
|
+
--prompt-padding-horizontal: var(--spacing-base); // @presenter Spacing
|
|
14
|
+
--prompt-gap: var(--spacing-sm); // @presenter Spacing
|
|
15
|
+
--prompt-border-highlight-color-start: var(--search-ai-gradient-start-color, var(--search-ai-gradient-start-color-legacy)); // @presenter Color
|
|
16
|
+
--prompt-border-highlight-color-end: var(--search-ai-gradient-end-color, var(--search-ai-gradient-end-color-legacy)); // @presenter Color
|
|
17
|
+
--prompt-border-highlight-size: 120px;
|
|
18
|
+
--prompt-border-highlight-transition: opacity 0.2s ease-out;
|
|
19
|
+
|
|
20
|
+
--prompt-header-gap: var(--spacing-xs); // @presenter Spacing
|
|
21
|
+
--prompt-header-actions-gap: var(--spacing-xxs); // @presenter Spacing
|
|
22
|
+
--prompt-header-copy-button-padding: var(--spacing-xxs); // @presenter Spacing
|
|
23
|
+
--prompt-icon-size: 18px;
|
|
24
|
+
--prompt-icon-color: var(--color-primary-base, var(--color-warm-grey-11)); // @presenter Color
|
|
25
|
+
--prompt-title-font-size: var(--font-size-base); // @presenter FontSize
|
|
26
|
+
--prompt-title-font-weight: var(--font-weight-semibold); // @presenter FontWeight
|
|
27
|
+
--prompt-title-line-height: var(--line-height-base); // @presenter LineHeight
|
|
28
|
+
--prompt-title-text-color: var(--text-color-primary); // @presenter Color
|
|
29
|
+
|
|
30
|
+
--prompt-body-bg-color: var(--color-primary-bg, var(--color-warm-grey-2)); // @presenter Color
|
|
31
|
+
--prompt-body-border-radius: var(--border-radius-lg); // @presenter BorderRadius
|
|
32
|
+
--prompt-body-padding-vertical: var(--spacing-xs); // @presenter Spacing
|
|
33
|
+
--prompt-body-padding-horizontal: var(--spacing-sm); // @presenter Spacing
|
|
34
|
+
--prompt-body-gap: var(--spacing-xxs); // @presenter Spacing
|
|
35
|
+
--prompt-body-font-size: var(--font-size-base); // @presenter FontSize
|
|
36
|
+
--prompt-body-line-height: var(--line-height-base); // @presenter LineHeight
|
|
37
|
+
--prompt-body-text-color: var(--text-color-primary); // @presenter Color
|
|
38
|
+
--prompt-body-max-lines: 5;
|
|
39
|
+
--prompt-body-toggle-gap: var(--spacing-xxs); // @presenter Spacing
|
|
40
|
+
// @tokens End
|
|
41
|
+
`;
|
|
@@ -28,3 +28,4 @@ export * from '@redocly/theme/markdoc/components/Icon/Icon';
|
|
|
28
28
|
export * from '@redocly/theme/markdoc/components/ConnectMCP/ConnectMCP';
|
|
29
29
|
export * from '@redocly/theme/markdoc/components/LoginButton/LoginButton';
|
|
30
30
|
export * from '@redocly/theme/markdoc/components/MarkdownLink/MarkdownLink';
|
|
31
|
+
export * from '@redocly/theme/markdoc/components/Prompt/Prompt';
|
package/src/markdoc/default.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { icon } from '@redocly/theme/markdoc/tags/icon';
|
|
|
33
33
|
import { connectMcp } from '@redocly/theme/markdoc/tags/connect-mcp';
|
|
34
34
|
import { loginButton } from '@redocly/theme/markdoc/tags/login-button';
|
|
35
35
|
import { diagram } from '@redocly/theme/markdoc/tags/diagram';
|
|
36
|
+
import { prompt } from '@redocly/theme/markdoc/tags/prompt';
|
|
36
37
|
|
|
37
38
|
export const tags = {
|
|
38
39
|
[accordion.tagName]: accordion.schema,
|
|
@@ -60,4 +61,5 @@ export const tags = {
|
|
|
60
61
|
[connectMcp.tagName]: connectMcp.schema,
|
|
61
62
|
[loginButton.tagName]: loginButton.schema,
|
|
62
63
|
[diagram.tagName]: diagram.schema,
|
|
64
|
+
[prompt.tagName]: prompt.schema,
|
|
63
65
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, RenderableTreeNode, ValidationError } from '@markdoc/markdoc';
|
|
1
|
+
import type { Node, RenderableTreeNode, Tag, ValidationError } from '@markdoc/markdoc';
|
|
2
2
|
import markdoc from '@markdoc/markdoc';
|
|
3
3
|
|
|
4
4
|
import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
|
|
@@ -67,12 +67,7 @@ export const codeWalkthrough: MarkdocSchemaWrapper = {
|
|
|
67
67
|
...attributes,
|
|
68
68
|
filters: node.attributes.filters || {},
|
|
69
69
|
filesets: node.attributes.resolvedFilesets || [],
|
|
70
|
-
steps: steps.map((step) =>
|
|
71
|
-
return {
|
|
72
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
73
|
-
...((step as any)?.attributes || {}),
|
|
74
|
-
} as CodeWalkthroughStepAttr;
|
|
75
|
-
}),
|
|
70
|
+
steps: steps.map((step) => (step as Tag).attributes as CodeWalkthroughStepAttr),
|
|
76
71
|
inputs,
|
|
77
72
|
toggles,
|
|
78
73
|
},
|
|
@@ -184,17 +179,14 @@ export const codeWalkthrough: MarkdocSchemaWrapper = {
|
|
|
184
179
|
},
|
|
185
180
|
};
|
|
186
181
|
|
|
187
|
-
export function collectStepsFromChildren(
|
|
188
|
-
children: RenderableTreeNode[],
|
|
189
|
-
idx = 0,
|
|
190
|
-
): RenderableTreeNode[] {
|
|
182
|
+
export function collectStepsFromChildren(children: RenderableTreeNode[]): RenderableTreeNode[] {
|
|
191
183
|
return children.flatMap((child) => {
|
|
192
184
|
const isTag = markdoc.Tag.isTag(child);
|
|
193
185
|
|
|
194
186
|
if (!isTag) return [];
|
|
195
187
|
if (child.name === 'CodeStep') return [child];
|
|
196
188
|
|
|
197
|
-
return collectStepsFromChildren(child.children
|
|
189
|
+
return collectStepsFromChildren(child.children);
|
|
198
190
|
});
|
|
199
191
|
}
|
|
200
192
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import markdoc from '@markdoc/markdoc';
|
|
2
|
+
|
|
3
|
+
import type { Node, ValidationError } from '@markdoc/markdoc';
|
|
4
|
+
import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
|
|
5
|
+
|
|
6
|
+
import { AI_PROMPT_TARGETS, PROMPT_TAG } from '@redocly/theme/core/constants';
|
|
7
|
+
|
|
8
|
+
const ALLOWED_ACTIONS: string[] = Object.values(AI_PROMPT_TARGETS);
|
|
9
|
+
|
|
10
|
+
export const prompt: MarkdocSchemaWrapper = {
|
|
11
|
+
schema: {
|
|
12
|
+
render: 'Prompt',
|
|
13
|
+
attributes: {
|
|
14
|
+
title: { type: String },
|
|
15
|
+
icon: { type: String, resolver: 'relativeOrCdnIcon' },
|
|
16
|
+
iconRawContent: { type: String, render: true }, // internal
|
|
17
|
+
actions: { type: Array, default: [] },
|
|
18
|
+
hidePrompt: { type: Boolean, default: false },
|
|
19
|
+
singleLine: { type: Boolean, default: false },
|
|
20
|
+
buttonOnly: { type: Boolean, default: false },
|
|
21
|
+
rawContent: { type: String, render: false, resolver: 'tagRawContent' }, // internal
|
|
22
|
+
},
|
|
23
|
+
transform(node, config) {
|
|
24
|
+
const attributes = node.transformAttributes(config);
|
|
25
|
+
const actions = Array.isArray(attributes.actions)
|
|
26
|
+
? [...new Set(attributes.actions.filter((action) => ALLOWED_ACTIONS.includes(action)))]
|
|
27
|
+
: [];
|
|
28
|
+
const prompt = getRawBody(node);
|
|
29
|
+
return new markdoc.Tag('Prompt', { ...attributes, actions, prompt }, []);
|
|
30
|
+
},
|
|
31
|
+
validate(node) {
|
|
32
|
+
const errors: ValidationError[] = [];
|
|
33
|
+
const { actions } = node.attributes;
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(actions)) {
|
|
36
|
+
for (const action of actions) {
|
|
37
|
+
if (!ALLOWED_ACTIONS.includes(action)) {
|
|
38
|
+
errors.push({
|
|
39
|
+
id: 'prompt-unknown-action',
|
|
40
|
+
level: 'error',
|
|
41
|
+
message: `attribute "actions" contains unknown value "${action}"; allowed values: ${ALLOWED_ACTIONS.join(', ')}`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return errors;
|
|
48
|
+
},
|
|
49
|
+
// The prompt is for human readers: it stays out of the .md page, llms.txt, and AI search.
|
|
50
|
+
renderForLlms: () => '',
|
|
51
|
+
},
|
|
52
|
+
tagName: PROMPT_TAG,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function getRawBody(node: Node): string {
|
|
56
|
+
const rawContent = node.attributes.rawContent;
|
|
57
|
+
return typeof rawContent === 'string' ? rawContent : '';
|
|
58
|
+
}
|