ai-design-system 0.1.60 → 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/TextEditor/TextEditor.tsx +16 -12
- package/components/features/TextEditor/useTextEditor.mock.ts +1 -1
- package/dist/index.cjs +14 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -11
- 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 */
|
|
@@ -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(
|