ai-design-system 0.1.59 → 0.1.61
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/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.tsx +1 -1
- package/components/features/NodeEditor/NodeEditor.tsx +5 -3
- package/components/features/TextEditor/TextEditor.tsx +16 -12
- package/components/features/TextEditor/useTextEditor.mock.ts +1 -1
- package/dist/index.cjs +18 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +18 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ export interface DocumentEditorWithCommentsProps {
|
|
|
26
26
|
* Content format - determines how content prop is interpreted
|
|
27
27
|
* @default 'json'
|
|
28
28
|
*/
|
|
29
|
-
format?: 'json' | 'markdown'
|
|
29
|
+
format?: 'json' | 'markdown' | string
|
|
30
30
|
/** Array of annotations to display */
|
|
31
31
|
annotations: Annotation[]
|
|
32
32
|
/** ID of currently selected annotation */
|
|
@@ -37,6 +37,7 @@ export interface NodeEditorProps {
|
|
|
37
37
|
|
|
38
38
|
showMinimap?: boolean;
|
|
39
39
|
interactive?: boolean;
|
|
40
|
+
hideDefaultActions?: boolean;
|
|
40
41
|
className?: string;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -62,6 +63,7 @@ export function NodeEditor({
|
|
|
62
63
|
extraActions,
|
|
63
64
|
showMinimap,
|
|
64
65
|
interactive = false,
|
|
66
|
+
hideDefaultActions = false,
|
|
65
67
|
className,
|
|
66
68
|
}: NodeEditorProps) {
|
|
67
69
|
const defaultActionGroups: ToolbarAction[][] = [
|
|
@@ -72,9 +74,9 @@ export function NodeEditor({
|
|
|
72
74
|
],
|
|
73
75
|
];
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
let allActionGroups: ToolbarAction[][] = [];
|
|
78
|
+
if (extraActions) allActionGroups = [...allActionGroups, ...extraActions];
|
|
79
|
+
if (!hideDefaultActions) allActionGroups = [...allActionGroups, ...defaultActionGroups];
|
|
78
80
|
|
|
79
81
|
return (
|
|
80
82
|
<div
|
|
@@ -66,7 +66,7 @@ export interface TextEditorSingleProps {
|
|
|
66
66
|
*
|
|
67
67
|
* @default 'json'
|
|
68
68
|
*/
|
|
69
|
-
format?: 'json' | 'markdown'
|
|
69
|
+
format?: 'json' | 'markdown' | string
|
|
70
70
|
/** Array of annotations to display */
|
|
71
71
|
annotations: Annotation[]
|
|
72
72
|
/** ID of currently selected annotation */
|
|
@@ -262,12 +262,15 @@ export const TextEditor = React.memo<TextEditorProps>(
|
|
|
262
262
|
* Single-document mode
|
|
263
263
|
*/
|
|
264
264
|
if (!isMultiTab) {
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
265
|
+
const format = props.format || 'markdown'
|
|
266
|
+
const isMarkdown = format === 'markdown'
|
|
267
|
+
const isCode = !isMarkdown && typeof props.content === 'string'
|
|
268
|
+
|
|
269
|
+
if (isMarkdown || isCode) {
|
|
270
|
+
const contentStr = props.content as string
|
|
271
|
+
const content = isCode
|
|
272
|
+
? `\`\`\`${format}\n${format === 'json' ? formatJson(contentStr) : contentStr}\n\`\`\``
|
|
273
|
+
: contentStr
|
|
271
274
|
return (
|
|
272
275
|
<div className={cn('text-editor p-6 flex flex-col h-screen w-full flex-1', className)}>
|
|
273
276
|
<StreamingMarkdown mode="streaming">
|
|
@@ -319,9 +322,10 @@ export const TextEditor = React.memo<TextEditorProps>(
|
|
|
319
322
|
</div>
|
|
320
323
|
)
|
|
321
324
|
} else {
|
|
322
|
-
const
|
|
323
|
-
const
|
|
324
|
-
const
|
|
325
|
+
const format = currentDocument.file.format || 'markdown'
|
|
326
|
+
const isMarkdownMulti = format === 'markdown'
|
|
327
|
+
const isCodeMulti = !isMarkdownMulti && typeof currentDocument.content === 'string'
|
|
328
|
+
const renderAsStreamdown = isMarkdownMulti || isCodeMulti
|
|
325
329
|
|
|
326
330
|
editorPane = (
|
|
327
331
|
<div className="text-editor flex flex-col h-full w-full">
|
|
@@ -342,8 +346,8 @@ export const TextEditor = React.memo<TextEditorProps>(
|
|
|
342
346
|
isAnimating
|
|
343
347
|
className="[&>*:first-child]:mt-0 [&>*:last-child]:mb-0"
|
|
344
348
|
>
|
|
345
|
-
{
|
|
346
|
-
?
|
|
349
|
+
{isCodeMulti
|
|
350
|
+
? `\`\`\`${format}\n${format === 'json' ? formatJson(currentDocument.content as string) : currentDocument.content}\n\`\`\``
|
|
347
351
|
: (currentDocument.content as string)}
|
|
348
352
|
</StreamingMarkdown>
|
|
349
353
|
</div>
|
package/dist/index.cjs
CHANGED
|
@@ -11658,12 +11658,14 @@ var TextEditor = React3__namespace.default.memo(
|
|
|
11658
11658
|
return rootNodes;
|
|
11659
11659
|
}, [isMultiTab, props.documents, props.fileTree]);
|
|
11660
11660
|
if (!isMultiTab) {
|
|
11661
|
-
const
|
|
11662
|
-
const
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11661
|
+
const format = props.format || "markdown";
|
|
11662
|
+
const isMarkdown = format === "markdown";
|
|
11663
|
+
const isCode = !isMarkdown && typeof props.content === "string";
|
|
11664
|
+
if (isMarkdown || isCode) {
|
|
11665
|
+
const contentStr = props.content;
|
|
11666
|
+
const content = isCode ? `\`\`\`${format}
|
|
11667
|
+
${format === "json" ? formatJson(contentStr) : contentStr}
|
|
11668
|
+
\`\`\`` : contentStr;
|
|
11667
11669
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("text-editor p-6 flex flex-col h-screen w-full flex-1", className), children: /* @__PURE__ */ jsxRuntime.jsx(StreamingMarkdown, { mode: "streaming", children: content }) });
|
|
11668
11670
|
}
|
|
11669
11671
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("text-editor flex flex-col h-screen w-full flex-1", className), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -11699,9 +11701,10 @@ ${formatJson(props.content)}
|
|
|
11699
11701
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-center p-6 text-muted-foreground", children: "No documents open" })
|
|
11700
11702
|
] });
|
|
11701
11703
|
} else {
|
|
11702
|
-
const
|
|
11703
|
-
const
|
|
11704
|
-
const
|
|
11704
|
+
const format = currentDocument.file.format || "markdown";
|
|
11705
|
+
const isMarkdownMulti = format === "markdown";
|
|
11706
|
+
const isCodeMulti = !isMarkdownMulti && typeof currentDocument.content === "string";
|
|
11707
|
+
const renderAsStreamdown = isMarkdownMulti || isCodeMulti;
|
|
11705
11708
|
editorPane = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-editor flex flex-col h-full w-full", children: [
|
|
11706
11709
|
!hideTabBar && /* @__PURE__ */ jsxRuntime.jsx(
|
|
11707
11710
|
DocumentTabBar,
|
|
@@ -11719,8 +11722,8 @@ ${formatJson(props.content)}
|
|
|
11719
11722
|
mode: "streaming",
|
|
11720
11723
|
isAnimating: true,
|
|
11721
11724
|
className: "[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
|
|
11722
|
-
children:
|
|
11723
|
-
${formatJson(currentDocument.content)}
|
|
11725
|
+
children: isCodeMulti ? `\`\`\`${format}
|
|
11726
|
+
${format === "json" ? formatJson(currentDocument.content) : currentDocument.content}
|
|
11724
11727
|
\`\`\`` : currentDocument.content
|
|
11725
11728
|
}
|
|
11726
11729
|
) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -12107,6 +12110,7 @@ function NodeEditor({
|
|
|
12107
12110
|
extraActions,
|
|
12108
12111
|
showMinimap,
|
|
12109
12112
|
interactive = false,
|
|
12113
|
+
hideDefaultActions = false,
|
|
12110
12114
|
className
|
|
12111
12115
|
}) {
|
|
12112
12116
|
const defaultActionGroups = [
|
|
@@ -12116,7 +12120,9 @@ function NodeEditor({
|
|
|
12116
12120
|
{ id: "save", icon: "save", title: "Save", onClick: onSave, loading: isSaving, indicator: hasUnsavedChanges }
|
|
12117
12121
|
]
|
|
12118
12122
|
];
|
|
12119
|
-
|
|
12123
|
+
let allActionGroups = [];
|
|
12124
|
+
if (extraActions) allActionGroups = [...allActionGroups, ...extraActions];
|
|
12125
|
+
if (!hideDefaultActions) allActionGroups = [...allActionGroups, ...defaultActionGroups];
|
|
12120
12126
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12121
12127
|
"div",
|
|
12122
12128
|
{
|