composeai 0.1.5 → 0.1.7

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
@@ -30,6 +30,8 @@ interface ComposerIcons {
30
30
  stop: IconComponent;
31
31
  /** Toolbar: attach any file. */
32
32
  attach: IconComponent;
33
+ /** Compact variant: the "+" trigger that opens the quick-actions popover. */
34
+ plus: IconComponent;
33
35
  /** Toolbar: pick an image. */
34
36
  image: IconComponent;
35
37
  /** Voice plugin: start recording. */
@@ -303,6 +305,12 @@ interface MentionConfig {
303
305
  }
304
306
  interface SlashConfig {
305
307
  items: SlashCommand[] | ((query: string) => SlashCommand[] | Promise<SlashCommand[]>);
308
+ /**
309
+ * The symbol that opens this menu. Defaults to `"/"`. Any single character
310
+ * works — `"/"` for commands, `"#"` for issues/tags, `":"` for emoji, etc.
311
+ * When registering {@link ComposerFeatures.slashCommands | multiple configs},
312
+ * give each a DISTINCT trigger.
313
+ */
306
314
  trigger?: string;
307
315
  maxItems?: number;
308
316
  }
@@ -523,16 +531,101 @@ interface GhostedAutoCompleteConfig {
523
531
  */
524
532
  minLength?: number;
525
533
  }
534
+ /**
535
+ * Editor helpers handed to a {@link CustomAction} when it's clicked, so a
536
+ * custom toolbar button can mutate the composer the same way a slash command
537
+ * can. All three are safe to call outside any Lexical update scope — they wrap
538
+ * `editor.update(...)` internally.
539
+ */
540
+ interface CustomActionContext {
541
+ /** Insert plain text at the current selection. */
542
+ insertText: (text: string) => void;
543
+ /**
544
+ * Insert markdown at the current selection. Multi-line aware: each newline
545
+ * becomes a real paragraph break so fences / lists / headings form.
546
+ */
547
+ insertMarkdown: (markdown: string) => void;
548
+ /** Submit the composer immediately (same pipeline as the Send button). */
549
+ submit: () => void;
550
+ }
551
+ /**
552
+ * A consumer-defined toolbar action. Renders as a button in the `full`
553
+ * variant's toolbar and as a row in the compact variant's "+" popover, placed
554
+ * between the built-in actions and `toolbarExtras`.
555
+ *
556
+ * @example
557
+ * ```tsx
558
+ * features={{
559
+ * custom: [
560
+ * {
561
+ * title: "Insert template",
562
+ * icon: <FileIcon />,
563
+ * onClick: ({ insertMarkdown }) => insertMarkdown("## Summary\n- "),
564
+ * },
565
+ * {
566
+ * title: "Formal tone",
567
+ * icon: <WandIcon />,
568
+ * active: tone === "formal",
569
+ * onClick: () => setTone((t) => (t === "formal" ? "neutral" : "formal")),
570
+ * },
571
+ * ],
572
+ * }}
573
+ * ```
574
+ */
575
+ interface CustomAction {
576
+ /** Stable identifier (React key). Falls back to the array index if omitted. */
577
+ id?: string;
578
+ /** Tooltip text and accessible label for the control. */
579
+ title: string;
580
+ /** Leading icon — the toolbar button glyph / the menu-row icon. */
581
+ icon: ReactNode;
582
+ /** Click handler. Receives editor helpers ({@link CustomActionContext}). */
583
+ onClick: (ctx: CustomActionContext) => void;
584
+ /** Render in a pressed / highlighted state — for toggle-style actions. */
585
+ active?: boolean;
586
+ /** Disable the control (greyed out, not clickable). */
587
+ disabled?: boolean;
588
+ }
526
589
  interface ComposerFeatures {
527
590
  /** `true` (default) → hybrid mode. Pass a {@link MarkdownConfig} to opt
528
591
  * into `"live"` (Notion-style) or otherwise customise behaviour. */
529
592
  markdown?: boolean | MarkdownConfig;
530
593
  attachments?: boolean | AttachmentsConfig;
531
594
  mentions?: false | MentionConfig;
532
- slashCommands?: false | SlashConfig;
595
+ /**
596
+ * Trigger-driven command menus. Each {@link SlashConfig} binds a trigger
597
+ * symbol (`trigger`, default `"/"`) to a list of {@link SlashCommand}s, and
598
+ * every command runs a callback action via `onSelect(ctx)` when chosen.
599
+ *
600
+ * Pass a SINGLE config for one trigger, or an ARRAY to register **multiple
601
+ * trigger symbols at once** — each with its own menu and actions. This lets a
602
+ * consumer wire, say, `"/"` → commands AND `"#"` → issues side-by-side
603
+ * (alongside the separate `@` mentions menu). Give each config a distinct
604
+ * `trigger`.
605
+ *
606
+ * @example
607
+ * ```tsx
608
+ * features={{
609
+ * slashCommands: [
610
+ * { trigger: "/", items: commands }, // each command's onSelect runs an action
611
+ * { trigger: "#", items: issues }, // insert a link, etc.
612
+ * ],
613
+ * }}
614
+ * ```
615
+ */
616
+ slashCommands?: false | SlashConfig | SlashConfig[];
533
617
  voice?: boolean;
534
618
  mermaid?: boolean | MermaidConfig;
535
619
  web?: boolean;
620
+ /**
621
+ * Consumer-defined toolbar actions. Each entry ({@link CustomAction})
622
+ * renders as a button in the `full` variant's toolbar and as a row in the
623
+ * compact variant's "+" popover, between the built-in actions and
624
+ * `toolbarExtras`. The click handler receives editor helpers
625
+ * ({@link CustomActionContext}) so it can insert text/markdown or submit.
626
+ * Defaults to `[]` (no custom actions).
627
+ */
628
+ custom?: CustomAction[];
536
629
  /**
537
630
  * Inline ghost-text autocomplete suggested from a list. Accepts a plain
538
631
  * `string[]` shorthand or a {@link GhostedAutoCompleteConfig} for
@@ -719,6 +812,27 @@ interface ComposerProps {
719
812
  * `mode` and work in both.
720
813
  */
721
814
  mode?: "markdown" | "text";
815
+ /**
816
+ * Visual layout of the composer card.
817
+ *
818
+ * - `"compact"` (default): a slim chat-bar that reads as a single line
819
+ * and grows as the user types or presses **Shift+Enter**. The quick
820
+ * actions that would otherwise sit in the toolbar (attach, image, web,
821
+ * and any `toolbarExtras`) collapse behind a single **"+"** button that
822
+ * opens a popover; the voice button floats to the right, beside Send.
823
+ * This keeps the resting state to one tidy row while still exposing
824
+ * everything one tap away.
825
+ *
826
+ * - `"full"`: the classic layout — a multi-line editor area with a full
827
+ * toolbar row (all action buttons visible) above the Send button.
828
+ * Honours `multiline` exactly as before (`multiline: false` collapses
829
+ * it to the inline single-row bar).
830
+ *
831
+ * Independent of `multiline`: `variant` controls the *chrome layout*, while
832
+ * `multiline` controls whether newlines are allowed. The compact variant
833
+ * defaults to `multiline: true` so Shift+Enter can grow it.
834
+ */
835
+ variant?: "compact" | "full";
722
836
  /** Toggle / configure built-in plugins. */
723
837
  features?: ComposerFeatures;
724
838
  /** Extra controls rendered after the built-in toolbar buttons. */
@@ -745,24 +859,24 @@ interface ComposerProps {
745
859
  */
746
860
  submitOnEnter?: boolean;
747
861
  /**
748
- * Smart "context-aware" Enter behavior. Defaults to `true`. Only takes
749
- * effect when `multiline` is `true`.
862
+ * Smart list continuation on Enter. Defaults to `true`. Only takes
863
+ * effect in markdown mode when `multiline` is `true`.
864
+ *
865
+ * When the cursor sits inside a list paragraph (`- `, `* `, `+ `, or
866
+ * `N. `), Enter continues the list with the next marker (bullet
867
+ * character preserved, numbers auto-incremented). Pressing Enter on an
868
+ * empty list item exits the list — the marker is cleared and the cursor
869
+ * stays on the now-plain line, where the next Enter sends.
750
870
  *
751
- * - While the editor holds a single line, Enter submits as usual
752
- * (subject to `submitOnEnter`).
753
- * - As soon as the editor contains more than one line, Enter inserts
754
- * a newline instead of submitting, and the user must press
755
- * Cmd/Ctrl+Enter (or click Send) to submit. This prevents
756
- * accidental sends while composing longer messages.
757
- * - In markdown mode, when the cursor sits inside a list paragraph
758
- * (`- `, `* `, `+ `, or `N. `), Enter continues the list with the
759
- * next marker (bullet character preserved, numbers
760
- * auto-incremented). Pressing Enter on an empty list item exits
761
- * the list — the marker is cleared and the cursor stays on the
762
- * now-plain line.
871
+ * This is the ONLY case where plain Enter inserts a line rather than
872
+ * submitting. Everywhere else Enter sends (subject to `submitOnEnter`)
873
+ * regardless of how many lines the draft already holds, and Shift+Enter
874
+ * is the newline gesture. Set to `false` to disable list continuation so
875
+ * Enter inside a bullet sends like anywhere else.
763
876
  *
764
- * Set to `false` to keep Enter's behavior fixed regardless of how many
765
- * lines the user has typed or whether they're inside a list.
877
+ * NOTE: earlier versions also blocked Enter from submitting once the
878
+ * editor held more than one line (forcing Cmd/Ctrl+Enter). That rule was
879
+ * removed — Enter now sends whether the draft is one line or many.
766
880
  */
767
881
  smartNewline?: boolean;
768
882
  /**
@@ -902,4 +1016,4 @@ interface SuggestionRowProps {
902
1016
  }
903
1017
  declare function SuggestionRow({ items, onSelect, className }: SuggestionRowProps): react.JSX.Element;
904
1018
 
905
- export { type Attachment, type AttachmentKind, type AttachmentOptions, type AttachmentStatus, type AttachmentTypeOption, type AttachmentsConfig, Composer, type ComposerFeatures, type ComposerHandle, type ComposerIcons, type ComposerPromptBehavior, type ComposerPromptsConfig, type ComposerProps, type ComposerSlot, type ComposerSlotClassNames, type ComposerSlots, type ComposerSubmitPayload, type ComposerSxMap, type ComposerSxValue, type ComposerTokens, type DiagramRenderer, type GhostedAutoCompleteConfig, type IconComponent, type IconProps, type MarkdownConfig, type MarkdownMode, type MentionConfig, type MentionItem, type MentionRef, type MermaidConfig, type SendButtonRenderProps, type SlashCommand, type SlashCommandContext, type SlashConfig, type StopButtonRenderProps, SuggestionRow, type SuggestionRowProps };
1019
+ export { type Attachment, type AttachmentKind, type AttachmentOptions, type AttachmentStatus, type AttachmentTypeOption, type AttachmentsConfig, Composer, type ComposerFeatures, type ComposerHandle, type ComposerIcons, type ComposerPromptBehavior, type ComposerPromptsConfig, type ComposerProps, type ComposerSlot, type ComposerSlotClassNames, type ComposerSlots, type ComposerSubmitPayload, type ComposerSxMap, type ComposerSxValue, type ComposerTokens, type CustomAction, type CustomActionContext, type DiagramRenderer, type GhostedAutoCompleteConfig, type IconComponent, type IconProps, type MarkdownConfig, type MarkdownMode, type MentionConfig, type MentionItem, type MentionRef, type MermaidConfig, type SendButtonRenderProps, type SlashCommand, type SlashCommandContext, type SlashConfig, type StopButtonRenderProps, SuggestionRow, type SuggestionRowProps };
package/dist/index.d.ts CHANGED
@@ -30,6 +30,8 @@ interface ComposerIcons {
30
30
  stop: IconComponent;
31
31
  /** Toolbar: attach any file. */
32
32
  attach: IconComponent;
33
+ /** Compact variant: the "+" trigger that opens the quick-actions popover. */
34
+ plus: IconComponent;
33
35
  /** Toolbar: pick an image. */
34
36
  image: IconComponent;
35
37
  /** Voice plugin: start recording. */
@@ -303,6 +305,12 @@ interface MentionConfig {
303
305
  }
304
306
  interface SlashConfig {
305
307
  items: SlashCommand[] | ((query: string) => SlashCommand[] | Promise<SlashCommand[]>);
308
+ /**
309
+ * The symbol that opens this menu. Defaults to `"/"`. Any single character
310
+ * works — `"/"` for commands, `"#"` for issues/tags, `":"` for emoji, etc.
311
+ * When registering {@link ComposerFeatures.slashCommands | multiple configs},
312
+ * give each a DISTINCT trigger.
313
+ */
306
314
  trigger?: string;
307
315
  maxItems?: number;
308
316
  }
@@ -523,16 +531,101 @@ interface GhostedAutoCompleteConfig {
523
531
  */
524
532
  minLength?: number;
525
533
  }
534
+ /**
535
+ * Editor helpers handed to a {@link CustomAction} when it's clicked, so a
536
+ * custom toolbar button can mutate the composer the same way a slash command
537
+ * can. All three are safe to call outside any Lexical update scope — they wrap
538
+ * `editor.update(...)` internally.
539
+ */
540
+ interface CustomActionContext {
541
+ /** Insert plain text at the current selection. */
542
+ insertText: (text: string) => void;
543
+ /**
544
+ * Insert markdown at the current selection. Multi-line aware: each newline
545
+ * becomes a real paragraph break so fences / lists / headings form.
546
+ */
547
+ insertMarkdown: (markdown: string) => void;
548
+ /** Submit the composer immediately (same pipeline as the Send button). */
549
+ submit: () => void;
550
+ }
551
+ /**
552
+ * A consumer-defined toolbar action. Renders as a button in the `full`
553
+ * variant's toolbar and as a row in the compact variant's "+" popover, placed
554
+ * between the built-in actions and `toolbarExtras`.
555
+ *
556
+ * @example
557
+ * ```tsx
558
+ * features={{
559
+ * custom: [
560
+ * {
561
+ * title: "Insert template",
562
+ * icon: <FileIcon />,
563
+ * onClick: ({ insertMarkdown }) => insertMarkdown("## Summary\n- "),
564
+ * },
565
+ * {
566
+ * title: "Formal tone",
567
+ * icon: <WandIcon />,
568
+ * active: tone === "formal",
569
+ * onClick: () => setTone((t) => (t === "formal" ? "neutral" : "formal")),
570
+ * },
571
+ * ],
572
+ * }}
573
+ * ```
574
+ */
575
+ interface CustomAction {
576
+ /** Stable identifier (React key). Falls back to the array index if omitted. */
577
+ id?: string;
578
+ /** Tooltip text and accessible label for the control. */
579
+ title: string;
580
+ /** Leading icon — the toolbar button glyph / the menu-row icon. */
581
+ icon: ReactNode;
582
+ /** Click handler. Receives editor helpers ({@link CustomActionContext}). */
583
+ onClick: (ctx: CustomActionContext) => void;
584
+ /** Render in a pressed / highlighted state — for toggle-style actions. */
585
+ active?: boolean;
586
+ /** Disable the control (greyed out, not clickable). */
587
+ disabled?: boolean;
588
+ }
526
589
  interface ComposerFeatures {
527
590
  /** `true` (default) → hybrid mode. Pass a {@link MarkdownConfig} to opt
528
591
  * into `"live"` (Notion-style) or otherwise customise behaviour. */
529
592
  markdown?: boolean | MarkdownConfig;
530
593
  attachments?: boolean | AttachmentsConfig;
531
594
  mentions?: false | MentionConfig;
532
- slashCommands?: false | SlashConfig;
595
+ /**
596
+ * Trigger-driven command menus. Each {@link SlashConfig} binds a trigger
597
+ * symbol (`trigger`, default `"/"`) to a list of {@link SlashCommand}s, and
598
+ * every command runs a callback action via `onSelect(ctx)` when chosen.
599
+ *
600
+ * Pass a SINGLE config for one trigger, or an ARRAY to register **multiple
601
+ * trigger symbols at once** — each with its own menu and actions. This lets a
602
+ * consumer wire, say, `"/"` → commands AND `"#"` → issues side-by-side
603
+ * (alongside the separate `@` mentions menu). Give each config a distinct
604
+ * `trigger`.
605
+ *
606
+ * @example
607
+ * ```tsx
608
+ * features={{
609
+ * slashCommands: [
610
+ * { trigger: "/", items: commands }, // each command's onSelect runs an action
611
+ * { trigger: "#", items: issues }, // insert a link, etc.
612
+ * ],
613
+ * }}
614
+ * ```
615
+ */
616
+ slashCommands?: false | SlashConfig | SlashConfig[];
533
617
  voice?: boolean;
534
618
  mermaid?: boolean | MermaidConfig;
535
619
  web?: boolean;
620
+ /**
621
+ * Consumer-defined toolbar actions. Each entry ({@link CustomAction})
622
+ * renders as a button in the `full` variant's toolbar and as a row in the
623
+ * compact variant's "+" popover, between the built-in actions and
624
+ * `toolbarExtras`. The click handler receives editor helpers
625
+ * ({@link CustomActionContext}) so it can insert text/markdown or submit.
626
+ * Defaults to `[]` (no custom actions).
627
+ */
628
+ custom?: CustomAction[];
536
629
  /**
537
630
  * Inline ghost-text autocomplete suggested from a list. Accepts a plain
538
631
  * `string[]` shorthand or a {@link GhostedAutoCompleteConfig} for
@@ -719,6 +812,27 @@ interface ComposerProps {
719
812
  * `mode` and work in both.
720
813
  */
721
814
  mode?: "markdown" | "text";
815
+ /**
816
+ * Visual layout of the composer card.
817
+ *
818
+ * - `"compact"` (default): a slim chat-bar that reads as a single line
819
+ * and grows as the user types or presses **Shift+Enter**. The quick
820
+ * actions that would otherwise sit in the toolbar (attach, image, web,
821
+ * and any `toolbarExtras`) collapse behind a single **"+"** button that
822
+ * opens a popover; the voice button floats to the right, beside Send.
823
+ * This keeps the resting state to one tidy row while still exposing
824
+ * everything one tap away.
825
+ *
826
+ * - `"full"`: the classic layout — a multi-line editor area with a full
827
+ * toolbar row (all action buttons visible) above the Send button.
828
+ * Honours `multiline` exactly as before (`multiline: false` collapses
829
+ * it to the inline single-row bar).
830
+ *
831
+ * Independent of `multiline`: `variant` controls the *chrome layout*, while
832
+ * `multiline` controls whether newlines are allowed. The compact variant
833
+ * defaults to `multiline: true` so Shift+Enter can grow it.
834
+ */
835
+ variant?: "compact" | "full";
722
836
  /** Toggle / configure built-in plugins. */
723
837
  features?: ComposerFeatures;
724
838
  /** Extra controls rendered after the built-in toolbar buttons. */
@@ -745,24 +859,24 @@ interface ComposerProps {
745
859
  */
746
860
  submitOnEnter?: boolean;
747
861
  /**
748
- * Smart "context-aware" Enter behavior. Defaults to `true`. Only takes
749
- * effect when `multiline` is `true`.
862
+ * Smart list continuation on Enter. Defaults to `true`. Only takes
863
+ * effect in markdown mode when `multiline` is `true`.
864
+ *
865
+ * When the cursor sits inside a list paragraph (`- `, `* `, `+ `, or
866
+ * `N. `), Enter continues the list with the next marker (bullet
867
+ * character preserved, numbers auto-incremented). Pressing Enter on an
868
+ * empty list item exits the list — the marker is cleared and the cursor
869
+ * stays on the now-plain line, where the next Enter sends.
750
870
  *
751
- * - While the editor holds a single line, Enter submits as usual
752
- * (subject to `submitOnEnter`).
753
- * - As soon as the editor contains more than one line, Enter inserts
754
- * a newline instead of submitting, and the user must press
755
- * Cmd/Ctrl+Enter (or click Send) to submit. This prevents
756
- * accidental sends while composing longer messages.
757
- * - In markdown mode, when the cursor sits inside a list paragraph
758
- * (`- `, `* `, `+ `, or `N. `), Enter continues the list with the
759
- * next marker (bullet character preserved, numbers
760
- * auto-incremented). Pressing Enter on an empty list item exits
761
- * the list — the marker is cleared and the cursor stays on the
762
- * now-plain line.
871
+ * This is the ONLY case where plain Enter inserts a line rather than
872
+ * submitting. Everywhere else Enter sends (subject to `submitOnEnter`)
873
+ * regardless of how many lines the draft already holds, and Shift+Enter
874
+ * is the newline gesture. Set to `false` to disable list continuation so
875
+ * Enter inside a bullet sends like anywhere else.
763
876
  *
764
- * Set to `false` to keep Enter's behavior fixed regardless of how many
765
- * lines the user has typed or whether they're inside a list.
877
+ * NOTE: earlier versions also blocked Enter from submitting once the
878
+ * editor held more than one line (forcing Cmd/Ctrl+Enter). That rule was
879
+ * removed — Enter now sends whether the draft is one line or many.
766
880
  */
767
881
  smartNewline?: boolean;
768
882
  /**
@@ -902,4 +1016,4 @@ interface SuggestionRowProps {
902
1016
  }
903
1017
  declare function SuggestionRow({ items, onSelect, className }: SuggestionRowProps): react.JSX.Element;
904
1018
 
905
- export { type Attachment, type AttachmentKind, type AttachmentOptions, type AttachmentStatus, type AttachmentTypeOption, type AttachmentsConfig, Composer, type ComposerFeatures, type ComposerHandle, type ComposerIcons, type ComposerPromptBehavior, type ComposerPromptsConfig, type ComposerProps, type ComposerSlot, type ComposerSlotClassNames, type ComposerSlots, type ComposerSubmitPayload, type ComposerSxMap, type ComposerSxValue, type ComposerTokens, type DiagramRenderer, type GhostedAutoCompleteConfig, type IconComponent, type IconProps, type MarkdownConfig, type MarkdownMode, type MentionConfig, type MentionItem, type MentionRef, type MermaidConfig, type SendButtonRenderProps, type SlashCommand, type SlashCommandContext, type SlashConfig, type StopButtonRenderProps, SuggestionRow, type SuggestionRowProps };
1019
+ export { type Attachment, type AttachmentKind, type AttachmentOptions, type AttachmentStatus, type AttachmentTypeOption, type AttachmentsConfig, Composer, type ComposerFeatures, type ComposerHandle, type ComposerIcons, type ComposerPromptBehavior, type ComposerPromptsConfig, type ComposerProps, type ComposerSlot, type ComposerSlotClassNames, type ComposerSlots, type ComposerSubmitPayload, type ComposerSxMap, type ComposerSxValue, type ComposerTokens, type CustomAction, type CustomActionContext, type DiagramRenderer, type GhostedAutoCompleteConfig, type IconComponent, type IconProps, type MarkdownConfig, type MarkdownMode, type MentionConfig, type MentionItem, type MentionRef, type MermaidConfig, type SendButtonRenderProps, type SlashCommand, type SlashCommandContext, type SlashConfig, type StopButtonRenderProps, SuggestionRow, type SuggestionRowProps };