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.
@@ -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
- const allActionGroups = extraActions
76
- ? [...extraActions, ...defaultActionGroups]
77
- : defaultActionGroups;
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 isMarkdown = props.format === 'markdown'
266
- const isJson = props.format === 'json'
267
- if (isMarkdown || isJson) {
268
- const content = isJson
269
- ? `\`\`\`json\n${formatJson(props.content as string)}\n\`\`\``
270
- : (props.content as string)
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 isMarkdownMulti = currentDocument.file.format === 'markdown'
323
- const isJsonMulti = currentDocument.file.format === 'json'
324
- const renderAsStreamdown = isMarkdownMulti || isJsonMulti
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
- {isJsonMulti
346
- ? `\`\`\`json\n${formatJson(currentDocument.content as string)}\n\`\`\``
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>
@@ -16,7 +16,7 @@ interface DocumentFile {
16
16
  id: string
17
17
  name: string
18
18
  isDirty: boolean
19
- format?: 'json' | 'markdown'
19
+ format?: 'json' | 'markdown' | string
20
20
  lastModified: number
21
21
  }
22
22
 
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 isMarkdown = props.format === "markdown";
11662
- const isJson = props.format === "json";
11663
- if (isMarkdown || isJson) {
11664
- const content = isJson ? `\`\`\`json
11665
- ${formatJson(props.content)}
11666
- \`\`\`` : props.content;
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 isMarkdownMulti = currentDocument.file.format === "markdown";
11703
- const isJsonMulti = currentDocument.file.format === "json";
11704
- const renderAsStreamdown = isMarkdownMulti || isJsonMulti;
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: isJsonMulti ? `\`\`\`json
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
- const allActionGroups = extraActions ? [...extraActions, ...defaultActionGroups] : defaultActionGroups;
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
  {