@tightknitai/block-kitchen 0.10.23 → 0.10.25

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.
@@ -99,6 +99,30 @@ interface PaletteVariant {
99
99
  * mode, and unnecessary for a variant whose label already stands alone.
100
100
  */
101
101
  basicLabel?: string;
102
+ /**
103
+ * A short tag shown beside the label, e.g. the plan a block belongs to
104
+ * ("Enterprise"). Shown whether or not the variant is `locked`.
105
+ */
106
+ badge?: PaletteVariantBadge;
107
+ /**
108
+ * Shows the variant without letting anyone add it: it can't be dragged,
109
+ * and it has no add button. Use it to show a block the user's plan doesn't
110
+ * include, alongside a `badge` saying which one does. Picking it calls
111
+ * `onLockedSelect`.
112
+ */
113
+ locked?: boolean;
114
+ /**
115
+ * Called when the user picks a `locked` variant, e.g. to open an upgrade
116
+ * prompt. Without it a locked variant is inert.
117
+ */
118
+ onLockedSelect?: () => void;
119
+ }
120
+ /** A tag shown beside a palette variant's label. See {@link PaletteVariant.badge}. */
121
+ interface PaletteVariantBadge {
122
+ /** Visible text, e.g. `'Enterprise'`. */
123
+ label: string;
124
+ /** Optional icon shown before the text, e.g. a Lucide icon component. */
125
+ icon?: ComponentType<SVGProps<SVGSVGElement>>;
102
126
  }
103
127
  /**
104
128
  * One section in the palette. Sections group related variants under a
@@ -757,6 +781,36 @@ interface BlockAction {
757
781
  /** Called with the block's position when the button is clicked. */
758
782
  onSelect: (position: BlockPosition) => void;
759
783
  }
784
+ /** What a {@link CustomBlockEditor}'s component is rendered with. */
785
+ interface CustomBlockEditorProps {
786
+ /** The block being edited. */
787
+ block: SupportedBlock;
788
+ /**
789
+ * Replaces the block. The result must still be ordinary Block Kit: it is
790
+ * previewed, validated and sent like any other block.
791
+ */
792
+ onChange: (next: SupportedBlock) => void;
793
+ }
794
+ /**
795
+ * A host-owned form for blocks your app gives a meaning of its own, e.g. a
796
+ * "Share on LinkedIn" button whose URL is built from the post text. It
797
+ * replaces the built-in form in the block's edit popover. The block itself
798
+ * stays ordinary Block Kit, so preview, validation and sending don't change.
799
+ */
800
+ interface CustomBlockEditor {
801
+ /** Stable identifier. */
802
+ id: string;
803
+ /** Names the block in the editor's heading, e.g. "Edit Share on LinkedIn". */
804
+ label: string;
805
+ /**
806
+ * Whether this editor handles a block; the first match wins. Match on what
807
+ * the block itself holds (a URL, an `action_id`): a message loaded back
808
+ * from Slack carries nothing else.
809
+ */
810
+ match: (block: SupportedBlock) => boolean;
811
+ /** The form. Rendered as a component, so it can use hooks. */
812
+ component: ComponentType<CustomBlockEditorProps>;
813
+ }
760
814
  /**
761
815
  * A host-owned primary action for compose-only mode, rendered in the
762
816
  * toolbar slot where the built-in "Review & send" button normally sits.
@@ -1161,6 +1215,19 @@ interface BlockKitchenBaseProps {
1161
1215
  * host can find a block on the canvas to scroll to or highlight it.
1162
1216
  */
1163
1217
  blockActions?: readonly BlockAction[];
1218
+ /**
1219
+ * Opt-in host content shown beside every block, at its right edge, all the
1220
+ * time (unlike `blockActions`, which show on hover): e.g. a count of
1221
+ * comments on the block. Called with the block's position (see
1222
+ * {@link BlockPosition}); return `null` for a block with nothing to show.
1223
+ */
1224
+ renderBlockAdornment?: (position: BlockPosition) => ReactNode;
1225
+ /**
1226
+ * Opt-in host forms that replace the built-in editor for the blocks they
1227
+ * match. See {@link CustomBlockEditor}. Expected to be referentially
1228
+ * stable across renders (define at module scope or wrap in `useMemo`).
1229
+ */
1230
+ blockEditors?: readonly CustomBlockEditor[];
1164
1231
  /**
1165
1232
  * Workspace custom emoji (`emoji.list`) the preview should resolve. Entries
1166
1233
  * with a non-null `url` render as the workspace image; alias entries fall
@@ -1311,6 +1378,14 @@ interface BlockKitchenBaseProps {
1311
1378
  href?: string;
1312
1379
  label?: string;
1313
1380
  };
1381
+ /**
1382
+ * Whether Ctrl/Cmd+Z undoes and Ctrl/Cmd+Shift+Z (or Ctrl+Y) redoes, like
1383
+ * the toolbar's Undo / Redo buttons. Defaults to `true`. They act while
1384
+ * focus is in the builder, or while nothing on the page has focus and the
1385
+ * last click landed in the builder, and never in a text field. Pass `false`
1386
+ * to leave those keys entirely to the host.
1387
+ */
1388
+ undoRedoShortcuts?: boolean;
1314
1389
  /**
1315
1390
  * Initial preview theme (uncontrolled). Defaults to `'light'`. Pass the
1316
1391
  * host app's current theme (e.g. from `next-themes` or your own theme
@@ -1461,4 +1536,4 @@ interface BlockKitchenComposeOnlyProps {
1461
1536
  */
1462
1537
  type BlockKitchenProps = BlockKitchenBaseProps & (BlockKitchenSendProps | BlockKitchenComposeOnlyProps);
1463
1538
 
1464
- export { type PaletteMode as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomEmoji as D, type DataTableActionCell as E, type DataTableBlock as F, type DataTableCell as G, type DataTableRawNumberCell as H, type DataVisualizationBlock as I, type EditableVia as J, type FeedbackButtonSubobject as K, type FeedbackButtonsElement as L, type HeaderLevel as M, type IconButtonElement as N, type IconButtonIcon as O, type PreviewSurface as P, type InputBlock as Q, type LoadMessageInput as R, type SupportedBlock as S, type Template as T, type LoadResult as U, type LoadedMessage as V, type LoadingConfig as W, type MarkdownBlock as X, type MentionChannel as Y, type MentionUser as Z, type MentionsConfig as _, type SendAsUserStatus as a, type PaletteSection as a0, type PaletteVariant as a1, type PieChart as a2, type PieChartSegment as a3, type PlanBlock as a4, type PreviewHooks as a5, type PrimaryActionConfig as a6, type PrimaryActionContext as a7, type RecentMessage as a8, type SendResult as a9, type SupportedBlockType as aa, type SupportedHeaderBlock as ab, type TableBlock as ac, type TableCell as ad, type TableColumnSetting as ae, type TableRawTextCell as af, type TaskCardBlock as ag, type TaskCardStatus as ah, type UpdatePayload as ai, type UpdateResult as aj, type UrlSourceElement as ak, type ValidationSummary as al, type VideoBlock as am, defaultPalette as an, extraAlertVariant as ao, legacyInputVariants as ap, buildVariantById as aq, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };
1539
+ export { type MentionUser as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomBlockEditor as D, type CustomBlockEditorProps as E, type CustomEmoji as F, type DataTableActionCell as G, type DataTableBlock as H, type DataTableCell as I, type DataTableRawNumberCell as J, type DataVisualizationBlock as K, type EditableVia as L, type FeedbackButtonSubobject as M, type FeedbackButtonsElement as N, type HeaderLevel as O, type PreviewSurface as P, type IconButtonElement as Q, type IconButtonIcon as R, type SupportedBlock as S, type Template as T, type InputBlock as U, type LoadMessageInput as V, type LoadResult as W, type LoadedMessage as X, type LoadingConfig as Y, type MarkdownBlock as Z, type MentionChannel as _, type SendAsUserStatus as a, type MentionsConfig as a0, type PaletteMode as a1, type PaletteSection as a2, type PaletteVariant as a3, type PaletteVariantBadge as a4, type PieChart as a5, type PieChartSegment as a6, type PlanBlock as a7, type PreviewHooks as a8, type PrimaryActionConfig as a9, type PrimaryActionContext as aa, type RecentMessage as ab, type SendResult as ac, type SupportedBlockType as ad, type SupportedHeaderBlock as ae, type TableBlock as af, type TableCell as ag, type TableColumnSetting as ah, type TableRawTextCell as ai, type TaskCardBlock as aj, type TaskCardStatus as ak, type UpdatePayload as al, type UpdateResult as am, type UrlSourceElement as an, type ValidationSummary as ao, type VideoBlock as ap, defaultPalette as aq, extraAlertVariant as ar, legacyInputVariants as as, buildVariantById as at, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };
@@ -99,6 +99,30 @@ interface PaletteVariant {
99
99
  * mode, and unnecessary for a variant whose label already stands alone.
100
100
  */
101
101
  basicLabel?: string;
102
+ /**
103
+ * A short tag shown beside the label, e.g. the plan a block belongs to
104
+ * ("Enterprise"). Shown whether or not the variant is `locked`.
105
+ */
106
+ badge?: PaletteVariantBadge;
107
+ /**
108
+ * Shows the variant without letting anyone add it: it can't be dragged,
109
+ * and it has no add button. Use it to show a block the user's plan doesn't
110
+ * include, alongside a `badge` saying which one does. Picking it calls
111
+ * `onLockedSelect`.
112
+ */
113
+ locked?: boolean;
114
+ /**
115
+ * Called when the user picks a `locked` variant, e.g. to open an upgrade
116
+ * prompt. Without it a locked variant is inert.
117
+ */
118
+ onLockedSelect?: () => void;
119
+ }
120
+ /** A tag shown beside a palette variant's label. See {@link PaletteVariant.badge}. */
121
+ interface PaletteVariantBadge {
122
+ /** Visible text, e.g. `'Enterprise'`. */
123
+ label: string;
124
+ /** Optional icon shown before the text, e.g. a Lucide icon component. */
125
+ icon?: ComponentType<SVGProps<SVGSVGElement>>;
102
126
  }
103
127
  /**
104
128
  * One section in the palette. Sections group related variants under a
@@ -757,6 +781,36 @@ interface BlockAction {
757
781
  /** Called with the block's position when the button is clicked. */
758
782
  onSelect: (position: BlockPosition) => void;
759
783
  }
784
+ /** What a {@link CustomBlockEditor}'s component is rendered with. */
785
+ interface CustomBlockEditorProps {
786
+ /** The block being edited. */
787
+ block: SupportedBlock;
788
+ /**
789
+ * Replaces the block. The result must still be ordinary Block Kit: it is
790
+ * previewed, validated and sent like any other block.
791
+ */
792
+ onChange: (next: SupportedBlock) => void;
793
+ }
794
+ /**
795
+ * A host-owned form for blocks your app gives a meaning of its own, e.g. a
796
+ * "Share on LinkedIn" button whose URL is built from the post text. It
797
+ * replaces the built-in form in the block's edit popover. The block itself
798
+ * stays ordinary Block Kit, so preview, validation and sending don't change.
799
+ */
800
+ interface CustomBlockEditor {
801
+ /** Stable identifier. */
802
+ id: string;
803
+ /** Names the block in the editor's heading, e.g. "Edit Share on LinkedIn". */
804
+ label: string;
805
+ /**
806
+ * Whether this editor handles a block; the first match wins. Match on what
807
+ * the block itself holds (a URL, an `action_id`): a message loaded back
808
+ * from Slack carries nothing else.
809
+ */
810
+ match: (block: SupportedBlock) => boolean;
811
+ /** The form. Rendered as a component, so it can use hooks. */
812
+ component: ComponentType<CustomBlockEditorProps>;
813
+ }
760
814
  /**
761
815
  * A host-owned primary action for compose-only mode, rendered in the
762
816
  * toolbar slot where the built-in "Review & send" button normally sits.
@@ -1161,6 +1215,19 @@ interface BlockKitchenBaseProps {
1161
1215
  * host can find a block on the canvas to scroll to or highlight it.
1162
1216
  */
1163
1217
  blockActions?: readonly BlockAction[];
1218
+ /**
1219
+ * Opt-in host content shown beside every block, at its right edge, all the
1220
+ * time (unlike `blockActions`, which show on hover): e.g. a count of
1221
+ * comments on the block. Called with the block's position (see
1222
+ * {@link BlockPosition}); return `null` for a block with nothing to show.
1223
+ */
1224
+ renderBlockAdornment?: (position: BlockPosition) => ReactNode;
1225
+ /**
1226
+ * Opt-in host forms that replace the built-in editor for the blocks they
1227
+ * match. See {@link CustomBlockEditor}. Expected to be referentially
1228
+ * stable across renders (define at module scope or wrap in `useMemo`).
1229
+ */
1230
+ blockEditors?: readonly CustomBlockEditor[];
1164
1231
  /**
1165
1232
  * Workspace custom emoji (`emoji.list`) the preview should resolve. Entries
1166
1233
  * with a non-null `url` render as the workspace image; alias entries fall
@@ -1311,6 +1378,14 @@ interface BlockKitchenBaseProps {
1311
1378
  href?: string;
1312
1379
  label?: string;
1313
1380
  };
1381
+ /**
1382
+ * Whether Ctrl/Cmd+Z undoes and Ctrl/Cmd+Shift+Z (or Ctrl+Y) redoes, like
1383
+ * the toolbar's Undo / Redo buttons. Defaults to `true`. They act while
1384
+ * focus is in the builder, or while nothing on the page has focus and the
1385
+ * last click landed in the builder, and never in a text field. Pass `false`
1386
+ * to leave those keys entirely to the host.
1387
+ */
1388
+ undoRedoShortcuts?: boolean;
1314
1389
  /**
1315
1390
  * Initial preview theme (uncontrolled). Defaults to `'light'`. Pass the
1316
1391
  * host app's current theme (e.g. from `next-themes` or your own theme
@@ -1461,4 +1536,4 @@ interface BlockKitchenComposeOnlyProps {
1461
1536
  */
1462
1537
  type BlockKitchenProps = BlockKitchenBaseProps & (BlockKitchenSendProps | BlockKitchenComposeOnlyProps);
1463
1538
 
1464
- export { type PaletteMode as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomEmoji as D, type DataTableActionCell as E, type DataTableBlock as F, type DataTableCell as G, type DataTableRawNumberCell as H, type DataVisualizationBlock as I, type EditableVia as J, type FeedbackButtonSubobject as K, type FeedbackButtonsElement as L, type HeaderLevel as M, type IconButtonElement as N, type IconButtonIcon as O, type PreviewSurface as P, type InputBlock as Q, type LoadMessageInput as R, type SupportedBlock as S, type Template as T, type LoadResult as U, type LoadedMessage as V, type LoadingConfig as W, type MarkdownBlock as X, type MentionChannel as Y, type MentionUser as Z, type MentionsConfig as _, type SendAsUserStatus as a, type PaletteSection as a0, type PaletteVariant as a1, type PieChart as a2, type PieChartSegment as a3, type PlanBlock as a4, type PreviewHooks as a5, type PrimaryActionConfig as a6, type PrimaryActionContext as a7, type RecentMessage as a8, type SendResult as a9, type SupportedBlockType as aa, type SupportedHeaderBlock as ab, type TableBlock as ac, type TableCell as ad, type TableColumnSetting as ae, type TableRawTextCell as af, type TaskCardBlock as ag, type TaskCardStatus as ah, type UpdatePayload as ai, type UpdateResult as aj, type UrlSourceElement as ak, type ValidationSummary as al, type VideoBlock as am, defaultPalette as an, extraAlertVariant as ao, legacyInputVariants as ap, buildVariantById as aq, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };
1539
+ export { type MentionUser as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomBlockEditor as D, type CustomBlockEditorProps as E, type CustomEmoji as F, type DataTableActionCell as G, type DataTableBlock as H, type DataTableCell as I, type DataTableRawNumberCell as J, type DataVisualizationBlock as K, type EditableVia as L, type FeedbackButtonSubobject as M, type FeedbackButtonsElement as N, type HeaderLevel as O, type PreviewSurface as P, type IconButtonElement as Q, type IconButtonIcon as R, type SupportedBlock as S, type Template as T, type InputBlock as U, type LoadMessageInput as V, type LoadResult as W, type LoadedMessage as X, type LoadingConfig as Y, type MarkdownBlock as Z, type MentionChannel as _, type SendAsUserStatus as a, type MentionsConfig as a0, type PaletteMode as a1, type PaletteSection as a2, type PaletteVariant as a3, type PaletteVariantBadge as a4, type PieChart as a5, type PieChartSegment as a6, type PlanBlock as a7, type PreviewHooks as a8, type PrimaryActionConfig as a9, type PrimaryActionContext as aa, type RecentMessage as ab, type SendResult as ac, type SupportedBlockType as ad, type SupportedHeaderBlock as ae, type TableBlock as af, type TableCell as ag, type TableColumnSetting as ah, type TableRawTextCell as ai, type TaskCardBlock as aj, type TaskCardStatus as ak, type UpdatePayload as al, type UpdateResult as am, type UrlSourceElement as an, type ValidationSummary as ao, type VideoBlock as ap, defaultPalette as aq, extraAlertVariant as ar, legacyInputVariants as as, buildVariantById as at, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };