@djangocfg/ui-tools 2.1.376 → 2.1.377

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/dist/index.d.cts CHANGED
@@ -1927,6 +1927,14 @@ interface UseChatComposerOptions {
1927
1927
  * exactly as before. Plan64.
1928
1928
  */
1929
1929
  persistKey?: string;
1930
+ /**
1931
+ * Skip pre-submit draft sanitation (trim + line-ending normalise +
1932
+ * zero-width strip). Default `false` — sanitation matches what
1933
+ * ChatGPT / Claude / Telegram ship and is what consumers want 99% of
1934
+ * the time. Set to `true` for niche flows that need byte-perfect
1935
+ * passthrough (clipboard inspector, raw-prompt debug tool).
1936
+ */
1937
+ preserveExactValue?: boolean;
1930
1938
  }
1931
1939
  interface UseChatComposerReturn {
1932
1940
  value: string;
@@ -2425,6 +2433,60 @@ declare function isStringValue(v: unknown): v is string;
2425
2433
  /** Walk the conversation and collect image attachments in chronological order. */
2426
2434
  declare function collectImageAttachments(messages: ChatMessage[]): ChatAttachment[];
2427
2435
 
2436
+ /**
2437
+ * sanitizeDraft — minimal pre-submit cleanup for chat-composer drafts.
2438
+ *
2439
+ * Mirrors the conservative behaviour ChatGPT / Claude / Telegram
2440
+ * actually ship: clean the obvious junk the user didn't intend to
2441
+ * send, touch nothing that *could* be intentional.
2442
+ *
2443
+ * **What we DO touch:**
2444
+ *
2445
+ * 1. Trim leading/trailing whitespace (spaces, tabs, newlines,
2446
+ * NBSP). The user typing `\n\n hello \n` meant `hello`.
2447
+ * 2. Normalise line endings — `\r\n` / `\r` → `\n`. Pasted Windows
2448
+ * / old-mac text gets the same internal shape, so the LLM
2449
+ * tokeniser and markdown renderer see one canonical form.
2450
+ * 3. Strip zero-width / invisible characters that web-paste
2451
+ * smuggles in: ZWSP (U+200B), ZWNJ (U+200C), ZWJ (U+200D),
2452
+ * BOM / ZWNBSP (U+FEFF). They're invisible, break LLM
2453
+ * tokenisation, and the user never meant to type them.
2454
+ *
2455
+ * **What we DO NOT touch (and why):**
2456
+ *
2457
+ * - **Internal whitespace runs** (3+ spaces, tabs, blank lines).
2458
+ * Code indentation depends on these. ChatGPT preserves them as
2459
+ * typed — " if (x):\n return" stays four-space-indented.
2460
+ * Collapsing them is the path to subtly broken code snippets.
2461
+ *
2462
+ * - **Bidi override marks** (U+200E LRM, U+200F RLM, U+202A..U+202E).
2463
+ * Legitimately used in Arabic / Hebrew / mixed-direction text.
2464
+ * Stripping silently breaks RTL users. If a specific deployment
2465
+ * wants to block them as a security measure, do it at that layer
2466
+ * with explicit user-visible feedback.
2467
+ *
2468
+ * - **Tabs vs spaces** beyond rule 1. Could be either code or
2469
+ * prose; without parsing markdown we can't tell.
2470
+ *
2471
+ * - **Emoji, mentions, URLs, code spans** — passthrough text.
2472
+ *
2473
+ * The function is intentionally tiny — every rule earns its keep
2474
+ * with a concrete "user pasted X from Y, got nonsense" story.
2475
+ *
2476
+ * **Idempotent**: `sanitizeDraft(sanitizeDraft(x)) === sanitizeDraft(x)`.
2477
+ */
2478
+ declare function sanitizeDraft(input: string): string;
2479
+ /**
2480
+ * Convenience predicate: true when the draft is non-empty AFTER
2481
+ * sanitation. Use to gate Send buttons / Enter submits so an empty
2482
+ * or whitespace-only draft never produces a real message.
2483
+ *
2484
+ * Cheaper than sanitizeDraft(input).length > 0 only marginally —
2485
+ * we still allocate the cleaned string. Kept as a named helper for
2486
+ * call-site clarity.
2487
+ */
2488
+ declare function isSubmittableDraft(input: string): boolean;
2489
+
2428
2490
  /**
2429
2491
  * Chat dev logger.
2430
2492
  *
@@ -3466,8 +3528,27 @@ interface MarkdownEditorProps {
3466
3528
  mentions?: MentionConfig;
3467
3529
  /** Called when mentioned IDs change */
3468
3530
  onMentionIdsChange?: (ids: string[]) => void;
3531
+ /**
3532
+ * Called when the user presses Enter (without Shift, no IME
3533
+ * composition, no mention popover open). When set, Enter submits
3534
+ * and Shift+Enter inserts a newline — ChatGPT / Telegram chat
3535
+ * behaviour. When omitted, Enter behaves as Tiptap default
3536
+ * (HardBreak).
3537
+ *
3538
+ * Implementation lives in `submitOnEnter.ts` — it's a Tiptap
3539
+ * keymap extension, NOT a React wrapper handler. Wrapper-level
3540
+ * onKeyDown fires AFTER ProseMirror's keymap commits HardBreak in
3541
+ * the same tick; routing through the extension lets us intercept
3542
+ * before HardBreak runs.
3543
+ *
3544
+ * Return value (optional): truthy / undefined = consume the key
3545
+ * (default). Return `false` from onSubmit to let Tiptap fall
3546
+ * through to HardBreak — useful for guards like "don't submit an
3547
+ * empty draft".
3548
+ */
3549
+ onSubmit?: () => boolean | void;
3469
3550
  }
3470
- declare function MarkdownEditor({ value, onChange, placeholder, minHeight, className, disabled, showToolbar, mentions, onMentionIdsChange, }: MarkdownEditorProps): react_jsx_runtime.JSX.Element;
3551
+ declare function MarkdownEditor({ value, onChange, placeholder, minHeight, className, disabled, showToolbar, mentions, onMentionIdsChange, onSubmit, }: MarkdownEditorProps): react_jsx_runtime.JSX.Element;
3471
3552
 
3472
3553
  /**
3473
3554
  * Built-in serializers for the `MentionConfig.renderMarkdown` callback.
@@ -3676,4 +3757,4 @@ declare function useBlobUrlCleanup(key: string | null): void;
3676
3757
  */
3677
3758
  declare function generateContentKey(content: ArrayBuffer): string;
3678
3759
 
3679
- export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type Focusable, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListHandle, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseAutoFocusOnStreamEndOptions, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, useAudioCache, useAutoFocusOnStreamEnd, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useRegisterComposer, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
3760
+ export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type Focusable, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListHandle, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseAutoFocusOnStreamEndOptions, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isSubmittableDraft, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, sanitizeDraft, useAudioCache, useAutoFocusOnStreamEnd, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useRegisterComposer, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
package/dist/index.d.ts CHANGED
@@ -1927,6 +1927,14 @@ interface UseChatComposerOptions {
1927
1927
  * exactly as before. Plan64.
1928
1928
  */
1929
1929
  persistKey?: string;
1930
+ /**
1931
+ * Skip pre-submit draft sanitation (trim + line-ending normalise +
1932
+ * zero-width strip). Default `false` — sanitation matches what
1933
+ * ChatGPT / Claude / Telegram ship and is what consumers want 99% of
1934
+ * the time. Set to `true` for niche flows that need byte-perfect
1935
+ * passthrough (clipboard inspector, raw-prompt debug tool).
1936
+ */
1937
+ preserveExactValue?: boolean;
1930
1938
  }
1931
1939
  interface UseChatComposerReturn {
1932
1940
  value: string;
@@ -2425,6 +2433,60 @@ declare function isStringValue(v: unknown): v is string;
2425
2433
  /** Walk the conversation and collect image attachments in chronological order. */
2426
2434
  declare function collectImageAttachments(messages: ChatMessage[]): ChatAttachment[];
2427
2435
 
2436
+ /**
2437
+ * sanitizeDraft — minimal pre-submit cleanup for chat-composer drafts.
2438
+ *
2439
+ * Mirrors the conservative behaviour ChatGPT / Claude / Telegram
2440
+ * actually ship: clean the obvious junk the user didn't intend to
2441
+ * send, touch nothing that *could* be intentional.
2442
+ *
2443
+ * **What we DO touch:**
2444
+ *
2445
+ * 1. Trim leading/trailing whitespace (spaces, tabs, newlines,
2446
+ * NBSP). The user typing `\n\n hello \n` meant `hello`.
2447
+ * 2. Normalise line endings — `\r\n` / `\r` → `\n`. Pasted Windows
2448
+ * / old-mac text gets the same internal shape, so the LLM
2449
+ * tokeniser and markdown renderer see one canonical form.
2450
+ * 3. Strip zero-width / invisible characters that web-paste
2451
+ * smuggles in: ZWSP (U+200B), ZWNJ (U+200C), ZWJ (U+200D),
2452
+ * BOM / ZWNBSP (U+FEFF). They're invisible, break LLM
2453
+ * tokenisation, and the user never meant to type them.
2454
+ *
2455
+ * **What we DO NOT touch (and why):**
2456
+ *
2457
+ * - **Internal whitespace runs** (3+ spaces, tabs, blank lines).
2458
+ * Code indentation depends on these. ChatGPT preserves them as
2459
+ * typed — " if (x):\n return" stays four-space-indented.
2460
+ * Collapsing them is the path to subtly broken code snippets.
2461
+ *
2462
+ * - **Bidi override marks** (U+200E LRM, U+200F RLM, U+202A..U+202E).
2463
+ * Legitimately used in Arabic / Hebrew / mixed-direction text.
2464
+ * Stripping silently breaks RTL users. If a specific deployment
2465
+ * wants to block them as a security measure, do it at that layer
2466
+ * with explicit user-visible feedback.
2467
+ *
2468
+ * - **Tabs vs spaces** beyond rule 1. Could be either code or
2469
+ * prose; without parsing markdown we can't tell.
2470
+ *
2471
+ * - **Emoji, mentions, URLs, code spans** — passthrough text.
2472
+ *
2473
+ * The function is intentionally tiny — every rule earns its keep
2474
+ * with a concrete "user pasted X from Y, got nonsense" story.
2475
+ *
2476
+ * **Idempotent**: `sanitizeDraft(sanitizeDraft(x)) === sanitizeDraft(x)`.
2477
+ */
2478
+ declare function sanitizeDraft(input: string): string;
2479
+ /**
2480
+ * Convenience predicate: true when the draft is non-empty AFTER
2481
+ * sanitation. Use to gate Send buttons / Enter submits so an empty
2482
+ * or whitespace-only draft never produces a real message.
2483
+ *
2484
+ * Cheaper than sanitizeDraft(input).length > 0 only marginally —
2485
+ * we still allocate the cleaned string. Kept as a named helper for
2486
+ * call-site clarity.
2487
+ */
2488
+ declare function isSubmittableDraft(input: string): boolean;
2489
+
2428
2490
  /**
2429
2491
  * Chat dev logger.
2430
2492
  *
@@ -3466,8 +3528,27 @@ interface MarkdownEditorProps {
3466
3528
  mentions?: MentionConfig;
3467
3529
  /** Called when mentioned IDs change */
3468
3530
  onMentionIdsChange?: (ids: string[]) => void;
3531
+ /**
3532
+ * Called when the user presses Enter (without Shift, no IME
3533
+ * composition, no mention popover open). When set, Enter submits
3534
+ * and Shift+Enter inserts a newline — ChatGPT / Telegram chat
3535
+ * behaviour. When omitted, Enter behaves as Tiptap default
3536
+ * (HardBreak).
3537
+ *
3538
+ * Implementation lives in `submitOnEnter.ts` — it's a Tiptap
3539
+ * keymap extension, NOT a React wrapper handler. Wrapper-level
3540
+ * onKeyDown fires AFTER ProseMirror's keymap commits HardBreak in
3541
+ * the same tick; routing through the extension lets us intercept
3542
+ * before HardBreak runs.
3543
+ *
3544
+ * Return value (optional): truthy / undefined = consume the key
3545
+ * (default). Return `false` from onSubmit to let Tiptap fall
3546
+ * through to HardBreak — useful for guards like "don't submit an
3547
+ * empty draft".
3548
+ */
3549
+ onSubmit?: () => boolean | void;
3469
3550
  }
3470
- declare function MarkdownEditor({ value, onChange, placeholder, minHeight, className, disabled, showToolbar, mentions, onMentionIdsChange, }: MarkdownEditorProps): react_jsx_runtime.JSX.Element;
3551
+ declare function MarkdownEditor({ value, onChange, placeholder, minHeight, className, disabled, showToolbar, mentions, onMentionIdsChange, onSubmit, }: MarkdownEditorProps): react_jsx_runtime.JSX.Element;
3471
3552
 
3472
3553
  /**
3473
3554
  * Built-in serializers for the `MentionConfig.renderMarkdown` callback.
@@ -3676,4 +3757,4 @@ declare function useBlobUrlCleanup(key: string | null): void;
3676
3757
  */
3677
3758
  declare function generateContentKey(content: ArrayBuffer): string;
3678
3759
 
3679
- export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type Focusable, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListHandle, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseAutoFocusOnStreamEndOptions, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, useAudioCache, useAutoFocusOnStreamEnd, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useRegisterComposer, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
3760
+ export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type Focusable, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListHandle, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseAutoFocusOnStreamEndOptions, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isSubmittableDraft, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, sanitizeDraft, useAudioCache, useAutoFocusOnStreamEnd, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useRegisterComposer, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
package/dist/index.mjs CHANGED
@@ -5,8 +5,8 @@ export { NativeProvider, StreamProvider, VideoControls, VideoErrorFallback, Vide
5
5
  export { ImageViewer } from './chunk-OBRSGM64.mjs';
6
6
  export { generateContentKey, useAudioCache, useBlobUrlCleanup, useImageCache, useMediaCacheStore, useVideoCache, useVideoPlayerSettings } from './chunk-C6GXVH5J.mjs';
7
7
  export { CronSchedulerProvider, CustomInput, DayChips, MonthDayGrid, SchedulePreview, ScheduleTypeSelector, TimeSelector, buildCron, humanizeCron, isValidCron, parseCron, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays } from './chunk-PVAX67JG.mjs';
8
- import { LIMITS, createId, useChatContextOptional, useChatAudioPrefs } from './chunk-JXBEKSNT.mjs';
9
- export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout } from './chunk-JXBEKSNT.mjs';
8
+ import { LIMITS, createId, useChatContextOptional, useChatAudioPrefs } from './chunk-BDWVCSM5.mjs';
9
+ export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, isSubmittableDraft, reducer, resolvePersona, sanitizeDraft, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout } from './chunk-BDWVCSM5.mjs';
10
10
  export { TreeError, TreeSkeleton, createDemoTree } from './chunk-B6IR5KSC.mjs';
11
11
  export { DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, TreeRoot as Tree, TreeChevron, TreeContent, TreeEmpty, TreeIcon, TreeIndentGuides, TreeLabel, TreeProvider, TreeRoot, TreeRow, TreeSearchInput, appearanceToStyle, clearTreeState, createChildCache, flattenTree, loadTreeState, resolveAppearance, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead } from './chunk-ZL7FH4NW.mjs';
12
12
  import { PlaygroundProvider } from './chunk-Y6UTOBF6.mjs';
@@ -28,6 +28,7 @@ import Placeholder from '@tiptap/extension-placeholder';
28
28
  import Mention from '@tiptap/extension-mention';
29
29
  import { Markdown } from '@tiptap/markdown';
30
30
  import { autoUpdate, computePosition, offset, flip, shift } from '@floating-ui/dom';
31
+ import { Extension } from '@tiptap/core';
31
32
 
32
33
  function Spinner({ className }) {
33
34
  const t = useAppT();
@@ -348,7 +349,7 @@ var LazyTree = createLazyComponent(
348
349
  }
349
350
  );
350
351
  var LazyChat = createLazyComponent(
351
- () => import('./ChatRoot-T7D7QRCH.mjs').then((m) => ({ default: m.ChatRoot })),
352
+ () => import('./ChatRoot-VJKOAVPQ.mjs').then((m) => ({ default: m.ChatRoot })),
352
353
  {
353
354
  displayName: "LazyChat",
354
355
  fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
@@ -1805,6 +1806,33 @@ var mentionPresets = {
1805
1806
  /** Inline HTML span — for products that consume markdown with raw HTML allowed. */
1806
1807
  htmlSpan: /* @__PURE__ */ __name((className = "mention") => ({ label, id }) => `<span class="${className}" data-mention-id="${encodeURIComponent(id)}">@${escapeMd(label || id)}</span>`, "htmlSpan")
1807
1808
  };
1809
+ var SubmitOnEnter = Extension.create({
1810
+ name: "submitOnEnter",
1811
+ addOptions() {
1812
+ return {
1813
+ // Default no-op — explicit consumer must override. We never
1814
+ // intercept Enter unless an onSubmit is wired, so leaving the
1815
+ // extension installed with no handler is safe.
1816
+ onSubmit: /* @__PURE__ */ __name(() => false, "onSubmit")
1817
+ };
1818
+ },
1819
+ addKeyboardShortcuts() {
1820
+ return {
1821
+ Enter: /* @__PURE__ */ __name(() => {
1822
+ if (typeof document !== "undefined" && document.querySelector(".markdown-mention-list")) {
1823
+ return false;
1824
+ }
1825
+ const result = this.options.onSubmit();
1826
+ return result !== false;
1827
+ }, "Enter"),
1828
+ // Shift+Enter — always insert a newline. Tiptap's StarterKit
1829
+ // already binds this to HardBreak; we re-bind to `false` (not
1830
+ // handled) so the chain falls through cleanly even if other
1831
+ // extensions try to grab Shift+Enter.
1832
+ "Shift-Enter": /* @__PURE__ */ __name(() => false, "Shift-Enter")
1833
+ };
1834
+ }
1835
+ });
1808
1836
  function getMarkdown(editor) {
1809
1837
  const storage = editor.storage.markdown;
1810
1838
  if (!storage?.manager) return editor.getText();
@@ -1830,8 +1858,11 @@ function MarkdownEditor({
1830
1858
  disabled = false,
1831
1859
  showToolbar = true,
1832
1860
  mentions,
1833
- onMentionIdsChange
1861
+ onMentionIdsChange,
1862
+ onSubmit
1834
1863
  }) {
1864
+ const onSubmitRef = useRef(onSubmit);
1865
+ onSubmitRef.current = onSubmit;
1835
1866
  const isExternalUpdate = useRef(false);
1836
1867
  const initialMentionsDefinedRef = useRef(mentions !== void 0);
1837
1868
  const warnedRef = useRef(false);
@@ -1845,7 +1876,19 @@ function MarkdownEditor({
1845
1876
  const exts = [
1846
1877
  StarterKit.configure({ heading: { levels: [1, 2, 3] } }),
1847
1878
  Placeholder.configure({ placeholder }),
1848
- Markdown
1879
+ Markdown,
1880
+ // SubmitOnEnter — when the consumer wired an onSubmit, intercept
1881
+ // Enter at the keymap level (before StarterKit's HardBreak).
1882
+ // The extension calls through `onSubmitRef.current` so handler
1883
+ // identity changes don't require an editor rebuild. See
1884
+ // submitOnEnter.ts for the keymap-vs-wrapper-handler rationale.
1885
+ SubmitOnEnter.configure({
1886
+ onSubmit: /* @__PURE__ */ __name(() => {
1887
+ const h = onSubmitRef.current;
1888
+ if (!h) return false;
1889
+ return h();
1890
+ }, "onSubmit")
1891
+ })
1849
1892
  ];
1850
1893
  if (mentions) {
1851
1894
  const renderMarkdown = mentions.renderMarkdown ?? mentionPresets.plainAt;