@arbidocs/blocks 0.4.9 → 0.4.10

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.
Files changed (73) hide show
  1. package/README.md +9 -0
  2. package/dist/StreamedArtifactEditor-5BMNWSS4.cjs +106 -0
  3. package/dist/StreamedArtifactEditor-5BMNWSS4.cjs.map +1 -0
  4. package/dist/StreamedArtifactEditor-6ETUHNQN.js +104 -0
  5. package/dist/StreamedArtifactEditor-6ETUHNQN.js.map +1 -0
  6. package/dist/agents/index.cjs +163 -163
  7. package/dist/agents/index.js +6 -6
  8. package/dist/artifacts/ArtifactEditor.d.ts +24 -1
  9. package/dist/artifacts/ArtifactToolbar.d.ts +3 -1
  10. package/dist/artifacts/StreamedArtifactFrame.d.ts +36 -0
  11. package/dist/artifacts/editor/index.cjs +11 -82
  12. package/dist/artifacts/editor/index.cjs.map +1 -1
  13. package/dist/artifacts/editor/index.js +2 -83
  14. package/dist/artifacts/editor/index.js.map +1 -1
  15. package/dist/artifacts/index.cjs +92 -800
  16. package/dist/artifacts/index.cjs.map +1 -1
  17. package/dist/artifacts/index.d.ts +2 -1
  18. package/dist/artifacts/index.js +3 -784
  19. package/dist/artifacts/index.js.map +1 -1
  20. package/dist/chat/index.cjs +65 -65
  21. package/dist/chat/index.js +3 -3
  22. package/dist/{chunk-JLOYWXRB.js → chunk-557EU3G4.js} +3 -3
  23. package/dist/{chunk-JLOYWXRB.js.map → chunk-557EU3G4.js.map} +1 -1
  24. package/dist/{chunk-5LUI4G5R.js → chunk-BV7FEMSI.js} +3 -3
  25. package/dist/{chunk-5LUI4G5R.js.map → chunk-BV7FEMSI.js.map} +1 -1
  26. package/dist/{chunk-CVFBSUXL.js → chunk-D5BZVKIF.js} +6 -6
  27. package/dist/{chunk-CVFBSUXL.js.map → chunk-D5BZVKIF.js.map} +1 -1
  28. package/dist/{chunk-YVIOCITQ.cjs → chunk-DCEI37AX.cjs} +3 -3
  29. package/dist/{chunk-YVIOCITQ.cjs.map → chunk-DCEI37AX.cjs.map} +1 -1
  30. package/dist/chunk-DTLOXXPN.js +831 -0
  31. package/dist/chunk-DTLOXXPN.js.map +1 -0
  32. package/dist/chunk-HSFGOA6V.js +86 -0
  33. package/dist/chunk-HSFGOA6V.js.map +1 -0
  34. package/dist/{chunk-IMA6I73C.js → chunk-ILOYJE63.js} +3 -3
  35. package/dist/{chunk-IMA6I73C.js.map → chunk-ILOYJE63.js.map} +1 -1
  36. package/dist/chunk-LOJVUGBJ.js +67 -0
  37. package/dist/chunk-LOJVUGBJ.js.map +1 -0
  38. package/dist/chunk-PVK3GAMH.cjs +852 -0
  39. package/dist/chunk-PVK3GAMH.cjs.map +1 -0
  40. package/dist/chunk-QVBZESYQ.cjs +70 -0
  41. package/dist/chunk-QVBZESYQ.cjs.map +1 -0
  42. package/dist/{chunk-67HGXV4I.cjs → chunk-RMIACB7N.cjs} +6 -6
  43. package/dist/{chunk-67HGXV4I.cjs.map → chunk-RMIACB7N.cjs.map} +1 -1
  44. package/dist/chunk-RUNQFXPH.cjs +89 -0
  45. package/dist/chunk-RUNQFXPH.cjs.map +1 -0
  46. package/dist/{chunk-TO4FAMQP.cjs → chunk-XKSFJYOD.cjs} +3 -3
  47. package/dist/{chunk-TO4FAMQP.cjs.map → chunk-XKSFJYOD.cjs.map} +1 -1
  48. package/dist/{chunk-22T6KHGB.cjs → chunk-YWSWRTGH.cjs} +4 -4
  49. package/dist/{chunk-22T6KHGB.cjs.map → chunk-YWSWRTGH.cjs.map} +1 -1
  50. package/dist/connect/index.cjs +97 -23
  51. package/dist/connect/index.cjs.map +1 -1
  52. package/dist/connect/index.d.ts +1 -0
  53. package/dist/connect/index.js +79 -6
  54. package/dist/connect/index.js.map +1 -1
  55. package/dist/connection/StreamedArtifact.d.ts +43 -0
  56. package/dist/connection/StreamedArtifactEditor.d.ts +31 -0
  57. package/dist/facts/index.cjs +1 -1
  58. package/dist/facts/index.js +1 -1
  59. package/dist/files/index.cjs +5 -5
  60. package/dist/files/index.js +7 -7
  61. package/dist/index.cjs +550 -550
  62. package/dist/index.js +17 -17
  63. package/dist/settings/index.cjs +32 -32
  64. package/dist/settings/index.js +3 -3
  65. package/dist/shell/index.cjs +33 -33
  66. package/dist/shell/index.js +3 -3
  67. package/dist/site/index.cjs +14 -14
  68. package/dist/site/index.js +2 -2
  69. package/dist/studio/index.cjs +3 -3
  70. package/dist/studio/index.js +3 -3
  71. package/dist/workspaces/index.cjs +2 -2
  72. package/dist/workspaces/index.js +2 -2
  73. package/package.json +3 -3
@@ -1,16 +1,16 @@
1
1
  "use client";
2
- export { ACTION_LABELS, AgentAvatarField, AgentBar, AgentBarIconButton, AgentBarMenu, AgentBarNotes, AgentBarProbeAnswer, AgentBarQueuedNote, AgentBarStatus, AgentCard, AgentCreateView, AgentCreatedView, AgentCreator, AgentEditView, AgentGallery, AgentMainView, AgentSelect, AgentTypeSelector, CapabilityGrid, CapabilityTile, ConfigField, ConfigForm, ConsentActions, ConsentBulletList, ConsentCard, ConsentFootnote, ConsentHeader, ConsentMessage, ConsentNotice, ConsentPage, ConsentPermissionList, ConsentSection, ConsentStrong, ConsentText, CopyableUrl, DEFAULT_AGENT_AVATAR_FIELD_LABELS, DEFAULT_AGENT_BAR_LABELS, DEFAULT_AGENT_CARD_LABELS, DEFAULT_AGENT_CREATOR_LABELS, DEFAULT_AGENT_GALLERY_LABELS, DEFAULT_AGENT_SELECT_LABELS, DEFAULT_AGENT_STEPS_LABELS, DEFAULT_AGENT_TYPE_SELECTOR_LABELS, DEFAULT_AUTHORIZE_AGENT_LABELS, DEFAULT_CONFIG_FIELD_LABELS, DEFAULT_CONFIG_FORM_LABELS, DEFAULT_CONSENT_ACTIONS_LABELS, DEFAULT_COPYABLE_URL_LABELS, DEFAULT_LIVE_RUNS_BANNER_LABELS, DEFAULT_RECURRENCE, DEFAULT_RECURRENCE_BUILDER_LABELS, DEFAULT_SCHEMA_FORM_LABELS, DEFAULT_SKILL_CARD_LABELS, DEFAULT_SKILL_EDIT_FORM_LABELS, DEFAULT_SKILL_GENERATE_FORM_LABELS, DEFAULT_SKILL_GLOBAL_BADGE_LABELS, DEFAULT_SKILL_ROW_LABELS, DEFAULT_SKILL_VIEW_TOGGLE_LABELS, DEFAULT_SUBAGENT_ROSTER_LABELS, DEFAULT_TASKS_CHROME_LABELS, DEFAULT_TASK_COLUMN_LABELS, DEFAULT_TASK_COMPOSER_LABELS, DEFAULT_TASK_PLAN_LABELS, DEFAULT_TASK_ROW_ACTIONS_LABELS, DEFAULT_TASK_RUNS_DIALOG_LABELS, DEFAULT_TUPLE_ARRAY_FIELD_LABELS, DEFAULT_UPLOAD_TASK_ITEM_LABELS, DEFAULT_UPLOAD_TASK_LIST_LABELS, DEFAULT_WORKFLOW_CONFIG_DIALOG_LABELS, EMPTY_WORKFLOW_SCOPE, GoalCriteria, LiveRunsBanner, NewTaskEmptyAction, RecurrenceBuilder, SKILL_PROMPT_FALLBACK_PLACEHOLDER, SKILL_PROMPT_LABEL, STATUS_LABELS, SchemaForm, SkillActionButton, SkillCard, SkillDetail, SkillDetailSection, SkillEditForm, SkillFilterChips, SkillGenerateForm, SkillGlobalBadge, SkillRow, SkillTile, SkillTypeBadge, SkillViewToggle, StepDetail, StepNarration, StepOutcome, StepParams, StepRow, StepSummary, StepTrace, StepTraceSummary, SubAgentLane, SubStepGroup, SubagentRoster, TRIGGER_LABELS, TaskComposer, TaskPlan, TaskRowActions, TaskRunsDialog, TasksBulkBar, TasksToolbar, TupleArrayField, UploadTaskItem, UploadTaskList, WEEKDAYS, WorkflowConfigDialog, WorkflowLauncher, agentConfigSectionToValues, agentCreatorToConfigSection, authModeFor, buildLaunch, buildRRule, composePersona, composeWorkflowPrompt, createTaskColumns, defaultInputs, defaultTaskComposerValues, deriveAgentName, describeRRule, formatElapsed, goalProgress, humanizeSection, inferType, inputsFromContext, isAgenticWorkflow, isEmptyWorkflowScope, isOutOfBounds, isValidAgentName, isWorkflowScope, isoToLocalInput, localInputToIso, nextCriterionId, parseRRule, prettifyKey, promptFieldName, skillToWorkflow, statusBadgeVariant, stripPersonaPreamble, summarizeAgent, summarizeCapabilities, taskComposerToCreateRequest, taskComposerToUpdateRequest, taskNeedsAccess, taskToComposerValues, validateInputs, workflowAccepts, workflowFromFrontmatter, workflowTaskFields, workflowsAccepting, workflowsForHost } from '../chunk-CVFBSUXL.js';
3
- import '../chunk-NUNKSZKU.js';
2
+ export { ACTION_LABELS, AgentAvatarField, AgentBar, AgentBarIconButton, AgentBarMenu, AgentBarNotes, AgentBarProbeAnswer, AgentBarQueuedNote, AgentBarStatus, AgentCard, AgentCreateView, AgentCreatedView, AgentCreator, AgentEditView, AgentGallery, AgentMainView, AgentSelect, AgentTypeSelector, CapabilityGrid, CapabilityTile, ConfigField, ConfigForm, ConsentActions, ConsentBulletList, ConsentCard, ConsentFootnote, ConsentHeader, ConsentMessage, ConsentNotice, ConsentPage, ConsentPermissionList, ConsentSection, ConsentStrong, ConsentText, CopyableUrl, DEFAULT_AGENT_AVATAR_FIELD_LABELS, DEFAULT_AGENT_BAR_LABELS, DEFAULT_AGENT_CARD_LABELS, DEFAULT_AGENT_CREATOR_LABELS, DEFAULT_AGENT_GALLERY_LABELS, DEFAULT_AGENT_SELECT_LABELS, DEFAULT_AGENT_STEPS_LABELS, DEFAULT_AGENT_TYPE_SELECTOR_LABELS, DEFAULT_AUTHORIZE_AGENT_LABELS, DEFAULT_CONFIG_FIELD_LABELS, DEFAULT_CONFIG_FORM_LABELS, DEFAULT_CONSENT_ACTIONS_LABELS, DEFAULT_COPYABLE_URL_LABELS, DEFAULT_LIVE_RUNS_BANNER_LABELS, DEFAULT_RECURRENCE, DEFAULT_RECURRENCE_BUILDER_LABELS, DEFAULT_SCHEMA_FORM_LABELS, DEFAULT_SKILL_CARD_LABELS, DEFAULT_SKILL_EDIT_FORM_LABELS, DEFAULT_SKILL_GENERATE_FORM_LABELS, DEFAULT_SKILL_GLOBAL_BADGE_LABELS, DEFAULT_SKILL_ROW_LABELS, DEFAULT_SKILL_VIEW_TOGGLE_LABELS, DEFAULT_SUBAGENT_ROSTER_LABELS, DEFAULT_TASKS_CHROME_LABELS, DEFAULT_TASK_COLUMN_LABELS, DEFAULT_TASK_COMPOSER_LABELS, DEFAULT_TASK_PLAN_LABELS, DEFAULT_TASK_ROW_ACTIONS_LABELS, DEFAULT_TASK_RUNS_DIALOG_LABELS, DEFAULT_TUPLE_ARRAY_FIELD_LABELS, DEFAULT_UPLOAD_TASK_ITEM_LABELS, DEFAULT_UPLOAD_TASK_LIST_LABELS, DEFAULT_WORKFLOW_CONFIG_DIALOG_LABELS, EMPTY_WORKFLOW_SCOPE, GoalCriteria, LiveRunsBanner, NewTaskEmptyAction, RecurrenceBuilder, SKILL_PROMPT_FALLBACK_PLACEHOLDER, SKILL_PROMPT_LABEL, STATUS_LABELS, SchemaForm, SkillActionButton, SkillCard, SkillDetail, SkillDetailSection, SkillEditForm, SkillFilterChips, SkillGenerateForm, SkillGlobalBadge, SkillRow, SkillTile, SkillTypeBadge, SkillViewToggle, StepDetail, StepNarration, StepOutcome, StepParams, StepRow, StepSummary, StepTrace, StepTraceSummary, SubAgentLane, SubStepGroup, SubagentRoster, TRIGGER_LABELS, TaskComposer, TaskPlan, TaskRowActions, TaskRunsDialog, TasksBulkBar, TasksToolbar, TupleArrayField, UploadTaskItem, UploadTaskList, WEEKDAYS, WorkflowConfigDialog, WorkflowLauncher, agentConfigSectionToValues, agentCreatorToConfigSection, authModeFor, buildLaunch, buildRRule, composePersona, composeWorkflowPrompt, createTaskColumns, defaultInputs, defaultTaskComposerValues, deriveAgentName, describeRRule, formatElapsed, goalProgress, humanizeSection, inferType, inputsFromContext, isAgenticWorkflow, isEmptyWorkflowScope, isOutOfBounds, isValidAgentName, isWorkflowScope, isoToLocalInput, localInputToIso, nextCriterionId, parseRRule, prettifyKey, promptFieldName, skillToWorkflow, statusBadgeVariant, stripPersonaPreamble, summarizeAgent, summarizeCapabilities, taskComposerToCreateRequest, taskComposerToUpdateRequest, taskNeedsAccess, taskToComposerValues, validateInputs, workflowAccepts, workflowFromFrontmatter, workflowTaskFields, workflowsAccepting, workflowsForHost } from '../chunk-D5BZVKIF.js';
3
+ import '../chunk-P6GHJSLR.js';
4
4
  import '../chunk-NJL4LIXX.js';
5
+ import '../chunk-S7PSMMRG.js';
5
6
  import '../chunk-CQCC7LE7.js';
7
+ import '../chunk-CPMNAJLF.js';
8
+ import '../chunk-TJMKFY5P.js';
9
+ import '../chunk-NUNKSZKU.js';
6
10
  import '../chunk-UBNVIIBT.js';
7
- import '../chunk-P6GHJSLR.js';
8
- import '../chunk-S7PSMMRG.js';
9
11
  import '../chunk-76JDDMSP.js';
10
- import '../chunk-CPMNAJLF.js';
11
12
  import '../chunk-NPLYHR2E.js';
12
13
  import '../chunk-OXF2IFXG.js';
13
- import '../chunk-TJMKFY5P.js';
14
14
  import '../chunk-7F6CBP3Z.js';
15
15
  //# sourceMappingURL=index.js.map
16
16
  //# sourceMappingURL=index.js.map
@@ -5,13 +5,28 @@ import type { RenderMarkdown } from './ArtifactRedlineView';
5
5
  import { type ArtifactToolbarLabels } from './ArtifactToolbar';
6
6
  import { type ArtifactVersionBarLabels, type ArtifactVersionBarTestIds } from './ArtifactVersionBar';
7
7
  import type { VersionEntry } from './VersionTimeline';
8
+ /** Whether the artifact's text is available (`ArtifactTextStatus` of `@arbidocs/react/artifacts`). */
9
+ export type ArtifactEditorStatus = 'loading' | 'parsing' | 'ready' | 'error';
10
+ export interface ArtifactEditorStatusLabels {
11
+ /** Shown while the backend is still parsing a fresh upload. */
12
+ preparing: string;
13
+ error: string;
14
+ retry: string;
15
+ }
16
+ export declare const DEFAULT_ARTIFACT_EDITOR_STATUS_LABELS: ArtifactEditorStatusLabels;
8
17
  export interface ArtifactEditorLabels {
18
+ status: Partial<ArtifactEditorStatusLabels>;
9
19
  toolbar: Partial<ArtifactToolbarLabels>;
10
20
  versions: Partial<ArtifactVersionBarLabels>;
11
21
  compare: Partial<ArtifactCompareBarLabels>;
12
22
  }
13
23
  export interface ArtifactEditorTestIds {
14
24
  root: string;
25
+ /** The "Preparing editor" state. */
26
+ preparing: string;
27
+ /** The error state and its retry button. */
28
+ error: string;
29
+ retry: string;
15
30
  compareRow: string;
16
31
  body: Partial<ArtifactEditorBodyTestIds>;
17
32
  versions: Partial<ArtifactVersionBarTestIds>;
@@ -31,6 +46,14 @@ export interface ArtifactEditorProps {
31
46
  /** The version being compared against. */
32
47
  compareId?: string | null;
33
48
  showTrackChanges: boolean;
49
+ /**
50
+ * Whether the text is available. While `loading` or `parsing` the body is a "Preparing editor"
51
+ * state (the toolbar is disabled: an editor on an empty baseline would save a blank version);
52
+ * `error` shows `labels.status.error` with Retry (`onRetry`). Default `ready`.
53
+ */
54
+ status?: ArtifactEditorStatus;
55
+ /** Ask for the text again after an `error`. */
56
+ onRetry?: () => void;
34
57
  /** The lineage, oldest first. The version bar shows only for two or more. */
35
58
  versions?: VersionEntry[];
36
59
  currentVersionId?: string;
@@ -61,4 +84,4 @@ export interface ArtifactEditorProps {
61
84
  * changes). Everything is view-model driven: a host binds state with `useArtifactSession` from
62
85
  * `@arbidocs/react/artifacts` and passes the editor and redline as slots.
63
86
  */
64
- export declare function ArtifactEditor({ content, isEditing, hasChanges, isSaving, isDraft, compact, canCompare, comparing, compareId, showTrackChanges, versions, currentVersionId, onStartEdit, onCancel, onSave, onCompare, onStopCompare, onToggleTrackChanges, onOpenVersion, formatDate, editor, redline, renderMarkdown, actions, className, labels, testIds, }: ArtifactEditorProps): import("react").JSX.Element;
87
+ export declare function ArtifactEditor({ content, isEditing, hasChanges, isSaving, isDraft, compact, canCompare, comparing, compareId, showTrackChanges, status, onRetry, versions, currentVersionId, onStartEdit, onCancel, onSave, onCompare, onStopCompare, onToggleTrackChanges, onOpenVersion, formatDate, editor, redline, renderMarkdown, actions, className, labels, testIds, }: ArtifactEditorProps): import("react").JSX.Element;
@@ -36,6 +36,8 @@ export interface ArtifactToolbarProps {
36
36
  /** Offer "Compare against the previous version". */
37
37
  canCompare: boolean;
38
38
  onStartEdit: () => void;
39
+ /** Edit is not offered yet (the text is still being prepared). */
40
+ editDisabled?: boolean;
39
41
  /** Discard the buffer and leave edit mode. */
40
42
  onCancel: () => void;
41
43
  onCompare: () => void;
@@ -50,4 +52,4 @@ export interface ArtifactToolbarProps {
50
52
  * once there is something to save; a dot marks unsaved changes and a polite status announces them.
51
53
  * Touch targets are 44px on coarse pointers.
52
54
  */
53
- export declare function ArtifactToolbar({ isEditing, isDraft, compact, hasChanges, isSaving, canCompare, onStartEdit, onCancel, onCompare, onSave, className, labels, testIds, }: ArtifactToolbarProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
55
+ export declare function ArtifactToolbar({ isEditing, isDraft, compact, hasChanges, isSaving, canCompare, editDisabled, onStartEdit, onCancel, onCompare, onSave, className, labels, testIds, }: ArtifactToolbarProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,36 @@
1
+ import type { ReactNode } from 'react';
2
+ /** `StreamedArtifactPhase` of `@arbidocs/react/artifacts`. */
3
+ export type StreamedArtifactFramePhase = 'streaming' | 'persisting' | 'parsing' | 'ready' | 'error';
4
+ export interface StreamedArtifactFrameLabels {
5
+ preparing: string;
6
+ error: string;
7
+ retry: string;
8
+ }
9
+ export declare const DEFAULT_STREAMED_ARTIFACT_FRAME_LABELS: StreamedArtifactFrameLabels;
10
+ export interface StreamedArtifactFrameTestIds {
11
+ /** The "Preparing editor" wrapper (`persisting` and `parsing`). */
12
+ preparing: string;
13
+ error: string;
14
+ retry: string;
15
+ }
16
+ export interface StreamedArtifactFrameProps {
17
+ phase: StreamedArtifactFramePhase;
18
+ /** The live canvas: shown while streaming, and kept in view under the status while preparing. */
19
+ canvas: ReactNode;
20
+ /** The editor, mounted only when `phase` is `ready`. */
21
+ children: ReactNode;
22
+ /** Why it failed (shown under the message). */
23
+ error?: string | null;
24
+ onRetry?: () => void;
25
+ className?: string;
26
+ labels?: Partial<StreamedArtifactFrameLabels>;
27
+ testIds?: Partial<StreamedArtifactFrameTestIds>;
28
+ }
29
+ /**
30
+ * The STREAM -> PERSIST -> EDIT switch of an agent-drafted artifact, presentational. The live
31
+ * `canvas` while the agent streams; "Preparing editor..." (a polite status above the canvas, so
32
+ * the draft stays readable) while the draft is stored and parsed; the editor (`children`) when it
33
+ * is ready; an alert with Retry when storing or parsing failed. The connected version is
34
+ * `StreamedArtifact` in `@arbidocs/blocks/connect`.
35
+ */
36
+ export declare function StreamedArtifactFrame({ phase, canvas, children, error, onRetry, className, labels, testIds, }: StreamedArtifactFrameProps): import("react").JSX.Element;
@@ -1,89 +1,18 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkMHVNT4J3_cjs = require('../../chunk-MHVNT4J3.cjs');
5
- var react = require('react');
6
- var editor = require('@mdxeditor/editor');
7
- var jsxRuntime = require('react/jsx-runtime');
4
+ var chunkRUNQFXPH_cjs = require('../../chunk-RUNQFXPH.cjs');
5
+ require('../../chunk-MHVNT4J3.cjs');
8
6
 
9
- function DictationSlot({
10
- render
11
- }) {
12
- const insertMarkdown = editor.usePublisher(editor.insertMarkdown$);
13
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: render(insertMarkdown) });
14
- }
15
- var DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS = {
16
- editor: "Document editor",
17
- placeholder: "Start typing\u2026"
18
- };
19
- function ArtifactMarkdownEditor({
20
- markdown,
21
- onChange,
22
- onNormalized,
23
- dictation,
24
- labels,
25
- testId
26
- }) {
27
- const l = { ...DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS, ...labels };
28
- const ref = react.useRef(null);
29
- const pendingNormalizationRef = react.useRef(true);
30
- return /* @__PURE__ */ jsxRuntime.jsx(
31
- "div",
32
- {
33
- role: "group",
34
- "aria-label": l.editor,
35
- "data-testid": chunkMHVNT4J3_cjs.testIdOr(testId, { testId: "artifact-markdown-editor" }),
36
- className: "h-full pointer-coarse:[&_[role=toolbar]_button]:min-h-11 pointer-coarse:[&_[role=toolbar]_button]:min-w-11",
37
- children: /* @__PURE__ */ jsxRuntime.jsx(
38
- editor.MDXEditor,
39
- {
40
- ref,
41
- markdown,
42
- onChange: (next) => {
43
- if (pendingNormalizationRef.current) {
44
- pendingNormalizationRef.current = false;
45
- onNormalized?.(next);
46
- }
47
- onChange(next);
48
- },
49
- contentEditableClassName: "markdown-content max-w-none px-6 py-4 outline-none min-h-full",
50
- className: "h-full overflow-auto bg-background",
51
- placeholder: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: l.placeholder }),
52
- plugins: [
53
- editor.headingsPlugin(),
54
- editor.listsPlugin(),
55
- editor.quotePlugin(),
56
- editor.thematicBreakPlugin(),
57
- editor.linkPlugin(),
58
- editor.linkDialogPlugin(),
59
- editor.tablePlugin(),
60
- editor.markdownShortcutPlugin(),
61
- editor.toolbarPlugin({
62
- toolbarContents: () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
63
- /* @__PURE__ */ jsxRuntime.jsx(editor.UndoRedo, {}),
64
- /* @__PURE__ */ jsxRuntime.jsx(editor.Separator, {}),
65
- /* @__PURE__ */ jsxRuntime.jsx(editor.BoldItalicUnderlineToggles, {}),
66
- /* @__PURE__ */ jsxRuntime.jsx(editor.Separator, {}),
67
- /* @__PURE__ */ jsxRuntime.jsx(editor.BlockTypeSelect, {}),
68
- /* @__PURE__ */ jsxRuntime.jsx(editor.ListsToggle, {}),
69
- /* @__PURE__ */ jsxRuntime.jsx(editor.Separator, {}),
70
- /* @__PURE__ */ jsxRuntime.jsx(editor.CreateLink, {}),
71
- /* @__PURE__ */ jsxRuntime.jsx(editor.InsertTable, {}),
72
- /* @__PURE__ */ jsxRuntime.jsx(editor.InsertThematicBreak, {}),
73
- dictation && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
74
- /* @__PURE__ */ jsxRuntime.jsx(editor.Separator, {}),
75
- /* @__PURE__ */ jsxRuntime.jsx(DictationSlot, { render: dictation })
76
- ] })
77
- ] })
78
- })
79
- ]
80
- }
81
- )
82
- }
83
- );
84
- }
85
7
 
86
- exports.ArtifactMarkdownEditor = ArtifactMarkdownEditor;
87
- exports.DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS = DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS;
8
+
9
+ Object.defineProperty(exports, "ArtifactMarkdownEditor", {
10
+ enumerable: true,
11
+ get: function () { return chunkRUNQFXPH_cjs.ArtifactMarkdownEditor; }
12
+ });
13
+ Object.defineProperty(exports, "DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS", {
14
+ enumerable: true,
15
+ get: function () { return chunkRUNQFXPH_cjs.DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS; }
16
+ });
88
17
  //# sourceMappingURL=index.cjs.map
89
18
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/artifacts/editor/ArtifactMarkdownEditor.tsx"],"names":["usePublisher","insertMarkdown$","jsx","Fragment","useRef","testIdOr","MDXEditor","headingsPlugin","listsPlugin","quotePlugin","thematicBreakPlugin","linkPlugin","linkDialogPlugin","tablePlugin","markdownShortcutPlugin","toolbarPlugin","jsxs","UndoRedo","Separator","BoldItalicUnderlineToggles","BlockTypeSelect","ListsToggle","CreateLink","InsertTable","InsertThematicBreak"],"mappings":"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","file":"index.cjs","sourcesContent":["import { useRef, type ReactNode } from 'react'\nimport {\n MDXEditor,\n type MDXEditorMethods,\n headingsPlugin,\n listsPlugin,\n quotePlugin,\n thematicBreakPlugin,\n linkPlugin,\n linkDialogPlugin,\n tablePlugin,\n markdownShortcutPlugin,\n toolbarPlugin,\n UndoRedo,\n BoldItalicUnderlineToggles,\n BlockTypeSelect,\n ListsToggle,\n CreateLink,\n InsertTable,\n InsertThematicBreak,\n Separator,\n insertMarkdown$,\n usePublisher,\n} from '@mdxeditor/editor'\nimport { testIdOr } from '../../chat/test-id'\n\n/** Renders the host's dictation control; `insert` puts text at the cursor. */\nfunction DictationSlot({\n render,\n}: {\n render: (insert: (markdown: string) => void) => ReactNode\n}): React.ReactElement {\n const insertMarkdown = usePublisher(insertMarkdown$)\n return <>{render(insertMarkdown)}</>\n}\n\nexport interface ArtifactMarkdownEditorLabels {\n /** The accessible name of the editor region. */\n editor: string\n placeholder: string\n}\n\nexport const DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS: ArtifactMarkdownEditorLabels = {\n editor: 'Document editor',\n placeholder: 'Start typing…',\n}\n\nexport interface ArtifactMarkdownEditorProps {\n /** Current markdown (controlled by the parent). */\n markdown: string\n /** Called with the new markdown whenever the document changes. */\n onChange: (markdown: string) => void\n /**\n * Fired exactly once per editor instance, with the markdown the editor produces on mount.\n * MDXEditor canonicalises the source as it parses (table padding, escapes, thematic-break\n * style), so the first `onChange` after mount is the round-tripped form of the input, not a\n * user edit. Use it to adopt the normalised form as the baseline so entering edit mode does\n * not look dirty. Remount via `key` to receive it for the next document.\n */\n onNormalized?: (normalized: string) => void\n /**\n * A dictation control for the toolbar (the host owns recording and transcription, for example\n * `@arbidocs/react`'s `InlineMicButton`). It gets a function that inserts text at the cursor.\n */\n dictation?: (insert: (markdown: string) => void) => ReactNode\n labels?: Partial<ArtifactMarkdownEditorLabels>\n testId?: string\n}\n\n/**\n * WYSIWYG editor for artifact documents: the user edits the rendered document directly and the\n * editor round-trips Markdown, so `onChange` always yields markdown a save can persist unchanged.\n *\n *\n * Heavy (Lexical via MDXEditor): mount it behind a lazy boundary. The host imports\n * `@mdxeditor/editor/style.css` once and, from the module that lazily imports this one, a module\n * that defines the global `Prism` FIRST (assign the prismjs core to `globalThis.Prism`):\n * `@lexical/code` reads it while it evaluates, and a library cannot order that in every bundler.\n */\nexport function ArtifactMarkdownEditor({\n markdown,\n onChange,\n onNormalized,\n dictation,\n labels,\n testId,\n}: ArtifactMarkdownEditorProps): React.ReactElement {\n const l = { ...DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS, ...labels }\n const ref = useRef<MDXEditorMethods>(null)\n // Latched until MDXEditor fires its first onChange after mount: that is the canonicalisation\n // round-trip, not a user edit.\n const pendingNormalizationRef = useRef(true)\n\n return (\n <div\n role=\"group\"\n aria-label={l.editor}\n data-testid={testIdOr(testId, { testId: 'artifact-markdown-editor' })}\n className=\"h-full pointer-coarse:[&_[role=toolbar]_button]:min-h-11 pointer-coarse:[&_[role=toolbar]_button]:min-w-11\"\n >\n <MDXEditor\n ref={ref}\n markdown={markdown}\n onChange={(next) => {\n if (pendingNormalizationRef.current) {\n pendingNormalizationRef.current = false\n onNormalized?.(next)\n }\n onChange(next)\n }}\n contentEditableClassName=\"markdown-content max-w-none px-6 py-4 outline-none min-h-full\"\n className=\"h-full overflow-auto bg-background\"\n placeholder={<span className=\"text-muted-foreground\">{l.placeholder}</span>}\n plugins={[\n headingsPlugin(),\n listsPlugin(),\n quotePlugin(),\n thematicBreakPlugin(),\n linkPlugin(),\n linkDialogPlugin(),\n tablePlugin(),\n markdownShortcutPlugin(),\n toolbarPlugin({\n toolbarContents: () => (\n <>\n <UndoRedo />\n <Separator />\n <BoldItalicUnderlineToggles />\n <Separator />\n <BlockTypeSelect />\n <ListsToggle />\n <Separator />\n <CreateLink />\n <InsertTable />\n <InsertThematicBreak />\n {dictation && (\n <>\n <Separator />\n <DictationSlot render={dictation} />\n </>\n )}\n </>\n ),\n }),\n ]}\n />\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -1,86 +1,5 @@
1
1
  "use client";
2
- import { testIdOr } from '../../chunk-7F6CBP3Z.js';
3
- import { useRef } from 'react';
4
- import { MDXEditor, headingsPlugin, listsPlugin, quotePlugin, thematicBreakPlugin, linkPlugin, linkDialogPlugin, tablePlugin, markdownShortcutPlugin, toolbarPlugin, UndoRedo, Separator, BoldItalicUnderlineToggles, BlockTypeSelect, ListsToggle, CreateLink, InsertTable, InsertThematicBreak, usePublisher, insertMarkdown$ } from '@mdxeditor/editor';
5
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
-
7
- function DictationSlot({
8
- render
9
- }) {
10
- const insertMarkdown = usePublisher(insertMarkdown$);
11
- return /* @__PURE__ */ jsx(Fragment, { children: render(insertMarkdown) });
12
- }
13
- var DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS = {
14
- editor: "Document editor",
15
- placeholder: "Start typing\u2026"
16
- };
17
- function ArtifactMarkdownEditor({
18
- markdown,
19
- onChange,
20
- onNormalized,
21
- dictation,
22
- labels,
23
- testId
24
- }) {
25
- const l = { ...DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS, ...labels };
26
- const ref = useRef(null);
27
- const pendingNormalizationRef = useRef(true);
28
- return /* @__PURE__ */ jsx(
29
- "div",
30
- {
31
- role: "group",
32
- "aria-label": l.editor,
33
- "data-testid": testIdOr(testId, { testId: "artifact-markdown-editor" }),
34
- className: "h-full pointer-coarse:[&_[role=toolbar]_button]:min-h-11 pointer-coarse:[&_[role=toolbar]_button]:min-w-11",
35
- children: /* @__PURE__ */ jsx(
36
- MDXEditor,
37
- {
38
- ref,
39
- markdown,
40
- onChange: (next) => {
41
- if (pendingNormalizationRef.current) {
42
- pendingNormalizationRef.current = false;
43
- onNormalized?.(next);
44
- }
45
- onChange(next);
46
- },
47
- contentEditableClassName: "markdown-content max-w-none px-6 py-4 outline-none min-h-full",
48
- className: "h-full overflow-auto bg-background",
49
- placeholder: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: l.placeholder }),
50
- plugins: [
51
- headingsPlugin(),
52
- listsPlugin(),
53
- quotePlugin(),
54
- thematicBreakPlugin(),
55
- linkPlugin(),
56
- linkDialogPlugin(),
57
- tablePlugin(),
58
- markdownShortcutPlugin(),
59
- toolbarPlugin({
60
- toolbarContents: () => /* @__PURE__ */ jsxs(Fragment, { children: [
61
- /* @__PURE__ */ jsx(UndoRedo, {}),
62
- /* @__PURE__ */ jsx(Separator, {}),
63
- /* @__PURE__ */ jsx(BoldItalicUnderlineToggles, {}),
64
- /* @__PURE__ */ jsx(Separator, {}),
65
- /* @__PURE__ */ jsx(BlockTypeSelect, {}),
66
- /* @__PURE__ */ jsx(ListsToggle, {}),
67
- /* @__PURE__ */ jsx(Separator, {}),
68
- /* @__PURE__ */ jsx(CreateLink, {}),
69
- /* @__PURE__ */ jsx(InsertTable, {}),
70
- /* @__PURE__ */ jsx(InsertThematicBreak, {}),
71
- dictation && /* @__PURE__ */ jsxs(Fragment, { children: [
72
- /* @__PURE__ */ jsx(Separator, {}),
73
- /* @__PURE__ */ jsx(DictationSlot, { render: dictation })
74
- ] })
75
- ] })
76
- })
77
- ]
78
- }
79
- )
80
- }
81
- );
82
- }
83
-
84
- export { ArtifactMarkdownEditor, DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS };
2
+ export { ArtifactMarkdownEditor, DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS } from '../../chunk-HSFGOA6V.js';
3
+ import '../../chunk-7F6CBP3Z.js';
85
4
  //# sourceMappingURL=index.js.map
86
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/artifacts/editor/ArtifactMarkdownEditor.tsx"],"names":[],"mappings":";;;;;AA2BA,SAAS,aAAA,CAAc;AAAA,EACrB;AACF,CAAA,EAEuB;AACrB,EAAA,MAAM,cAAA,GAAiB,aAAa,eAAe,CAAA;AACnD,EAAA,uBAAO,GAAA,CAAA,QAAA,EAAA,EAAG,QAAA,EAAA,MAAA,CAAO,cAAc,CAAA,EAAE,CAAA;AACnC;AAQO,IAAM,uCAAA,GAAwE;AAAA,EACnF,MAAA,EAAQ,iBAAA;AAAA,EACR,WAAA,EAAa;AACf;AAkCO,SAAS,sBAAA,CAAuB;AAAA,EACrC,QAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,EAAoD;AAClD,EAAA,MAAM,CAAA,GAAI,EAAE,GAAG,uCAAA,EAAyC,GAAG,MAAA,EAAO;AAClE,EAAA,MAAM,GAAA,GAAM,OAAyB,IAAI,CAAA;AAGzC,EAAA,MAAM,uBAAA,GAA0B,OAAO,IAAI,CAAA;AAE3C,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,OAAA;AAAA,MACL,cAAY,CAAA,CAAE,MAAA;AAAA,MACd,eAAa,QAAA,CAAS,MAAA,EAAQ,EAAE,MAAA,EAAQ,4BAA4B,CAAA;AAAA,MACpE,SAAA,EAAU,4GAAA;AAAA,MAEV,QAAA,kBAAA,GAAA;AAAA,QAAC,SAAA;AAAA,QAAA;AAAA,UACC,GAAA;AAAA,UACA,QAAA;AAAA,UACA,QAAA,EAAU,CAAC,IAAA,KAAS;AAClB,YAAA,IAAI,wBAAwB,OAAA,EAAS;AACnC,cAAA,uBAAA,CAAwB,OAAA,GAAU,KAAA;AAClC,cAAA,YAAA,GAAe,IAAI,CAAA;AAAA,YACrB;AACA,YAAA,QAAA,CAAS,IAAI,CAAA;AAAA,UACf,CAAA;AAAA,UACA,wBAAA,EAAyB,+DAAA;AAAA,UACzB,SAAA,EAAU,oCAAA;AAAA,UACV,6BAAa,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,uBAAA,EAAyB,YAAE,WAAA,EAAY,CAAA;AAAA,UACpE,OAAA,EAAS;AAAA,YACP,cAAA,EAAe;AAAA,YACf,WAAA,EAAY;AAAA,YACZ,WAAA,EAAY;AAAA,YACZ,mBAAA,EAAoB;AAAA,YACpB,UAAA,EAAW;AAAA,YACX,gBAAA,EAAiB;AAAA,YACjB,WAAA,EAAY;AAAA,YACZ,sBAAA,EAAuB;AAAA,YACvB,aAAA,CAAc;AAAA,cACZ,eAAA,EAAiB,sBACf,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,gCAAA,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA;AAAA,oCACT,SAAA,EAAA,EAAU,CAAA;AAAA,oCACV,0BAAA,EAAA,EAA2B,CAAA;AAAA,oCAC3B,SAAA,EAAA,EAAU,CAAA;AAAA,oCACV,eAAA,EAAA,EAAgB,CAAA;AAAA,oCAChB,WAAA,EAAA,EAAY,CAAA;AAAA,oCACZ,SAAA,EAAA,EAAU,CAAA;AAAA,oCACV,UAAA,EAAA,EAAW,CAAA;AAAA,oCACX,WAAA,EAAA,EAAY,CAAA;AAAA,oCACZ,mBAAA,EAAA,EAAoB,CAAA;AAAA,gBACpB,6BACC,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,kCAAA,GAAA,CAAC,SAAA,EAAA,EAAU,CAAA;AAAA,kCACX,GAAA,CAAC,aAAA,EAAA,EAAc,MAAA,EAAQ,SAAA,EAAW;AAAA,iBAAA,EACpC;AAAA,eAAA,EAEJ;AAAA,aAEH;AAAA;AACH;AAAA;AACF;AAAA,GACF;AAEJ","file":"index.js","sourcesContent":["import { useRef, type ReactNode } from 'react'\nimport {\n MDXEditor,\n type MDXEditorMethods,\n headingsPlugin,\n listsPlugin,\n quotePlugin,\n thematicBreakPlugin,\n linkPlugin,\n linkDialogPlugin,\n tablePlugin,\n markdownShortcutPlugin,\n toolbarPlugin,\n UndoRedo,\n BoldItalicUnderlineToggles,\n BlockTypeSelect,\n ListsToggle,\n CreateLink,\n InsertTable,\n InsertThematicBreak,\n Separator,\n insertMarkdown$,\n usePublisher,\n} from '@mdxeditor/editor'\nimport { testIdOr } from '../../chat/test-id'\n\n/** Renders the host's dictation control; `insert` puts text at the cursor. */\nfunction DictationSlot({\n render,\n}: {\n render: (insert: (markdown: string) => void) => ReactNode\n}): React.ReactElement {\n const insertMarkdown = usePublisher(insertMarkdown$)\n return <>{render(insertMarkdown)}</>\n}\n\nexport interface ArtifactMarkdownEditorLabels {\n /** The accessible name of the editor region. */\n editor: string\n placeholder: string\n}\n\nexport const DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS: ArtifactMarkdownEditorLabels = {\n editor: 'Document editor',\n placeholder: 'Start typing…',\n}\n\nexport interface ArtifactMarkdownEditorProps {\n /** Current markdown (controlled by the parent). */\n markdown: string\n /** Called with the new markdown whenever the document changes. */\n onChange: (markdown: string) => void\n /**\n * Fired exactly once per editor instance, with the markdown the editor produces on mount.\n * MDXEditor canonicalises the source as it parses (table padding, escapes, thematic-break\n * style), so the first `onChange` after mount is the round-tripped form of the input, not a\n * user edit. Use it to adopt the normalised form as the baseline so entering edit mode does\n * not look dirty. Remount via `key` to receive it for the next document.\n */\n onNormalized?: (normalized: string) => void\n /**\n * A dictation control for the toolbar (the host owns recording and transcription, for example\n * `@arbidocs/react`'s `InlineMicButton`). It gets a function that inserts text at the cursor.\n */\n dictation?: (insert: (markdown: string) => void) => ReactNode\n labels?: Partial<ArtifactMarkdownEditorLabels>\n testId?: string\n}\n\n/**\n * WYSIWYG editor for artifact documents: the user edits the rendered document directly and the\n * editor round-trips Markdown, so `onChange` always yields markdown a save can persist unchanged.\n *\n *\n * Heavy (Lexical via MDXEditor): mount it behind a lazy boundary. The host imports\n * `@mdxeditor/editor/style.css` once and, from the module that lazily imports this one, a module\n * that defines the global `Prism` FIRST (assign the prismjs core to `globalThis.Prism`):\n * `@lexical/code` reads it while it evaluates, and a library cannot order that in every bundler.\n */\nexport function ArtifactMarkdownEditor({\n markdown,\n onChange,\n onNormalized,\n dictation,\n labels,\n testId,\n}: ArtifactMarkdownEditorProps): React.ReactElement {\n const l = { ...DEFAULT_ARTIFACT_MARKDOWN_EDITOR_LABELS, ...labels }\n const ref = useRef<MDXEditorMethods>(null)\n // Latched until MDXEditor fires its first onChange after mount: that is the canonicalisation\n // round-trip, not a user edit.\n const pendingNormalizationRef = useRef(true)\n\n return (\n <div\n role=\"group\"\n aria-label={l.editor}\n data-testid={testIdOr(testId, { testId: 'artifact-markdown-editor' })}\n className=\"h-full pointer-coarse:[&_[role=toolbar]_button]:min-h-11 pointer-coarse:[&_[role=toolbar]_button]:min-w-11\"\n >\n <MDXEditor\n ref={ref}\n markdown={markdown}\n onChange={(next) => {\n if (pendingNormalizationRef.current) {\n pendingNormalizationRef.current = false\n onNormalized?.(next)\n }\n onChange(next)\n }}\n contentEditableClassName=\"markdown-content max-w-none px-6 py-4 outline-none min-h-full\"\n className=\"h-full overflow-auto bg-background\"\n placeholder={<span className=\"text-muted-foreground\">{l.placeholder}</span>}\n plugins={[\n headingsPlugin(),\n listsPlugin(),\n quotePlugin(),\n thematicBreakPlugin(),\n linkPlugin(),\n linkDialogPlugin(),\n tablePlugin(),\n markdownShortcutPlugin(),\n toolbarPlugin({\n toolbarContents: () => (\n <>\n <UndoRedo />\n <Separator />\n <BoldItalicUnderlineToggles />\n <Separator />\n <BlockTypeSelect />\n <ListsToggle />\n <Separator />\n <CreateLink />\n <InsertTable />\n <InsertThematicBreak />\n {dictation && (\n <>\n <Separator />\n <DictationSlot render={dictation} />\n </>\n )}\n </>\n ),\n }),\n ]}\n />\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}