@tightknitai/block-kitchen 0.10.7 → 0.10.9
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/README.md +9 -3
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.cjs +168 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +169 -34
- package/dist/index.js.map +1 -1
- package/dist/{palette-QbOx7kAa.d.cts → palette-CvSGn2z6.d.cts} +13 -6
- package/dist/{palette-QbOx7kAa.d.ts → palette-CvSGn2z6.d.ts} +13 -6
- package/dist/palette.cjs +10 -2
- package/dist/palette.cjs.map +1 -1
- package/dist/palette.d.cts +1 -1
- package/dist/palette.d.ts +1 -1
- package/dist/palette.js +10 -2
- package/dist/palette.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-
|
|
4
|
-
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-
|
|
3
|
+
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-CvSGn2z6.cjs';
|
|
4
|
+
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-CvSGn2z6.cjs';
|
|
5
5
|
export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.cjs';
|
|
6
6
|
import 'slack-web-api-client';
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-
|
|
4
|
-
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-
|
|
3
|
+
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-CvSGn2z6.js';
|
|
4
|
+
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-CvSGn2z6.js';
|
|
5
5
|
export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.js';
|
|
6
6
|
import 'slack-web-api-client';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useSensors, useSensor, PointerSensor, TouchSensor, KeyboardSensor, pointerWithin, closestCenter, DndContext, DragOverlay, useDroppable, useDraggable } from '@dnd-kit/core';
|
|
2
2
|
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
3
|
-
import { X, Circle, Sparkles, FileText, AlignLeft, MousePointerClick, TextCursorInput, LayoutTemplate, Bell, Pilcrow, Image, Video, GalleryHorizontal, Table, ChartColumnBig, Container, Loader2, ExternalLink, AlertTriangle, GripVertical, Sun, Moon, MessageSquare, AppWindow, Home, Plus, ChevronDown, BookOpen, Undo2, Redo2, Trash2, Code2, Pencil, Send, Search, Check, Copy, Info, CheckCircle2,
|
|
3
|
+
import { X, Circle, Sparkles, FileText, AlignLeft, MousePointerClick, TextCursorInput, LayoutTemplate, Bell, Pilcrow, Image, Video, GalleryHorizontal, Table, ChartColumnBig, Container, Loader2, ExternalLink, AlertTriangle, ChevronRight, ChevronLeft, GripVertical, Sun, Moon, MessageSquare, AppWindow, Home, Plus, ChevronDown, BookOpen, Undo2, Redo2, Trash2, Code2, Pencil, Send, Search, Check, Copy, Info, CheckCircle2, LayoutGrid, ArrowUp, ArrowDown, Type, Bold, Italic, Strikethrough, Underline, Code, List, ListOrdered, Quote, Smile, Link as Link$1 } from 'lucide-react';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { createContext, useState, useRef, useEffect, useCallback, useMemo, useId, useContext } from 'react';
|
|
6
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
6
|
import { clsx } from 'clsx';
|
|
9
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
10
10
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
11
11
|
import { validateBlockKit, CARD_ACTIONS_MAX } from '@tightknitai/slack-block-kit-validator';
|
|
12
12
|
import { nanoid } from 'nanoid';
|
|
@@ -23,6 +23,9 @@ import { Node, ReactNodeViewRenderer, mergeAttributes, NodeViewWrapper, useEdito
|
|
|
23
23
|
import StarterKit from '@tiptap/starter-kit';
|
|
24
24
|
|
|
25
25
|
// src/components/block-kitchen.tsx
|
|
26
|
+
function cn(...inputs) {
|
|
27
|
+
return twMerge(clsx(inputs));
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
// src/lib/container-blocks.ts
|
|
28
31
|
var CONTAINER_CHILD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -704,6 +707,7 @@ var defaultPalette = [
|
|
|
704
707
|
{
|
|
705
708
|
id: "structure_header",
|
|
706
709
|
label: "Header",
|
|
710
|
+
basic: true,
|
|
707
711
|
factory: () => ({
|
|
708
712
|
type: "header",
|
|
709
713
|
text: { type: "plain_text", text: "Heading text", emoji: true }
|
|
@@ -712,6 +716,7 @@ var defaultPalette = [
|
|
|
712
716
|
{
|
|
713
717
|
id: "structure_divider",
|
|
714
718
|
label: "Divider",
|
|
719
|
+
basic: true,
|
|
715
720
|
factory: () => ({ type: "divider" })
|
|
716
721
|
},
|
|
717
722
|
{
|
|
@@ -819,8 +824,9 @@ var defaultPalette = [
|
|
|
819
824
|
{
|
|
820
825
|
id: "rich_text_section",
|
|
821
826
|
label: "Rich Text Section",
|
|
822
|
-
// The
|
|
823
|
-
//
|
|
827
|
+
// The block a message is mostly made of, and so one of the handful
|
|
828
|
+
// simple mode offers — listed there without its section heading,
|
|
829
|
+
// hence the self-describing label.
|
|
824
830
|
basic: true,
|
|
825
831
|
factory: () => ({
|
|
826
832
|
type: "rich_text",
|
|
@@ -857,6 +863,11 @@ var defaultPalette = [
|
|
|
857
863
|
{
|
|
858
864
|
id: "image_no_title",
|
|
859
865
|
label: "No title",
|
|
866
|
+
// The plain image is the one an ordinary message reaches for, so it
|
|
867
|
+
// carries simple mode's image slot — under its own name there, with
|
|
868
|
+
// no "Image" heading overhead to lend "No title" its meaning.
|
|
869
|
+
basic: true,
|
|
870
|
+
basicLabel: "Image",
|
|
860
871
|
factory: () => ({
|
|
861
872
|
type: "image",
|
|
862
873
|
image_url: "https://placehold.co/600x300?text=Image",
|
|
@@ -1679,9 +1690,6 @@ function labelForBlockType(type) {
|
|
|
1679
1690
|
return "Container";
|
|
1680
1691
|
}
|
|
1681
1692
|
}
|
|
1682
|
-
function cn(...inputs) {
|
|
1683
|
-
return twMerge(clsx(inputs));
|
|
1684
|
-
}
|
|
1685
1693
|
var Sheet = DialogPrimitive.Root;
|
|
1686
1694
|
var SheetOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1687
1695
|
DialogPrimitive.Overlay,
|
|
@@ -3782,14 +3790,14 @@ function isDefaultOpen(sectionName, config) {
|
|
|
3782
3790
|
return config.includes(sectionName);
|
|
3783
3791
|
}
|
|
3784
3792
|
var PALETTE_TITLE = "Message Elements";
|
|
3785
|
-
var ADVANCED_HELP = "Browse every Slack block type \u2014 sections, images, buttons, inputs, tables and more
|
|
3786
|
-
var BASIC_HELP = "Go back to the short list:
|
|
3793
|
+
var ADVANCED_HELP = "Browse every Slack block type \u2014 sections, images, buttons, inputs, tables and more.";
|
|
3794
|
+
var BASIC_HELP = "Go back to the short list: the few blocks an ordinary message is made of.";
|
|
3787
3795
|
function basicVariants(sections) {
|
|
3788
3796
|
const out = [];
|
|
3789
3797
|
for (const section of sections) {
|
|
3790
3798
|
for (const variant of section.variants) {
|
|
3791
3799
|
if (variant.basic) {
|
|
3792
|
-
out.push(variant);
|
|
3800
|
+
out.push(variant.basicLabel ? { ...variant, label: variant.basicLabel } : variant);
|
|
3793
3801
|
}
|
|
3794
3802
|
}
|
|
3795
3803
|
}
|
|
@@ -3818,10 +3826,12 @@ function Palette({
|
|
|
3818
3826
|
showSearch = true,
|
|
3819
3827
|
searchPlaceholder = "Search blocks\u2026",
|
|
3820
3828
|
mode = "advanced",
|
|
3829
|
+
defaultAdvanced = false,
|
|
3830
|
+
onAdvancedChange,
|
|
3821
3831
|
variant = "aside"
|
|
3822
3832
|
}) {
|
|
3823
3833
|
const [query, setQuery] = useState("");
|
|
3824
|
-
const [advancedOpen, setAdvancedOpen] = useState(
|
|
3834
|
+
const [advancedOpen, setAdvancedOpen] = useState(defaultAdvanced);
|
|
3825
3835
|
const [prevMode, setPrevMode] = useState(mode);
|
|
3826
3836
|
if (prevMode !== mode) {
|
|
3827
3837
|
setPrevMode(mode);
|
|
@@ -3843,7 +3853,7 @@ function Palette({
|
|
|
3843
3853
|
{
|
|
3844
3854
|
className: cn(
|
|
3845
3855
|
"flex min-h-0 flex-col overflow-x-hidden overflow-y-auto",
|
|
3846
|
-
isSheet ? "w-full flex-1 bg-background" : "w-
|
|
3856
|
+
isSheet ? "w-full flex-1 bg-background" : "w-56 shrink-0 border-r bg-muted/20"
|
|
3847
3857
|
),
|
|
3848
3858
|
children: [
|
|
3849
3859
|
offersSimple || searchVisible ? (
|
|
@@ -3876,7 +3886,9 @@ function Palette({
|
|
|
3876
3886
|
isSheet,
|
|
3877
3887
|
onToggle: () => {
|
|
3878
3888
|
setQuery("");
|
|
3879
|
-
|
|
3889
|
+
const next = !advancedOpen;
|
|
3890
|
+
setAdvancedOpen(next);
|
|
3891
|
+
onAdvancedChange?.(next);
|
|
3880
3892
|
}
|
|
3881
3893
|
}
|
|
3882
3894
|
)
|
|
@@ -4004,8 +4016,8 @@ function PaletteItem({
|
|
|
4004
4016
|
isDragging && "opacity-50"
|
|
4005
4017
|
),
|
|
4006
4018
|
children: [
|
|
4007
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
4008
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
4019
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: variant.label }),
|
|
4020
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground transition-colors group-hover:bg-primary/10 group-hover:text-primary", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
|
|
4009
4021
|
]
|
|
4010
4022
|
}
|
|
4011
4023
|
);
|
|
@@ -4015,7 +4027,7 @@ function PaletteItem({
|
|
|
4015
4027
|
{
|
|
4016
4028
|
ref: setNodeRef,
|
|
4017
4029
|
className: cn(
|
|
4018
|
-
"group flex items-center gap-2 rounded px-2 py-1
|
|
4030
|
+
"group flex items-center gap-2 rounded px-2 py-1 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground has-[:focus-visible]:bg-accent has-[:focus-visible]:text-foreground",
|
|
4019
4031
|
isDragging && "opacity-50"
|
|
4020
4032
|
),
|
|
4021
4033
|
children: [
|
|
@@ -4023,7 +4035,7 @@ function PaletteItem({
|
|
|
4023
4035
|
"div",
|
|
4024
4036
|
{
|
|
4025
4037
|
ref: setActivatorNodeRef,
|
|
4026
|
-
className: "-my-1
|
|
4038
|
+
className: "-my-1 flex min-w-0 flex-1 cursor-grab items-center gap-2 rounded py-1 active:cursor-grabbing focus-visible:outline-none",
|
|
4027
4039
|
...attributes,
|
|
4028
4040
|
...listeners,
|
|
4029
4041
|
children: [
|
|
@@ -6070,12 +6082,44 @@ function HeaderEditor({ block, onChange }) {
|
|
|
6070
6082
|
] });
|
|
6071
6083
|
}
|
|
6072
6084
|
function ImageEditor({ block, onChange }) {
|
|
6073
|
-
|
|
6074
|
-
return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "This image references a Slack file. Not editable in the visual builder." });
|
|
6075
|
-
}
|
|
6085
|
+
const source = "slack_file" in block ? "slack_file" : "url";
|
|
6076
6086
|
const titleText = block.title?.text ?? "";
|
|
6087
|
+
const setSource = (next) => {
|
|
6088
|
+
if (next === source) {
|
|
6089
|
+
return;
|
|
6090
|
+
}
|
|
6091
|
+
if (next === "url") {
|
|
6092
|
+
const { slack_file: _omit, ...rest } = block;
|
|
6093
|
+
onChange({ image_url: "", ...rest });
|
|
6094
|
+
} else {
|
|
6095
|
+
const { image_url: _omit, ...rest } = block;
|
|
6096
|
+
onChange({ slack_file: { id: "" }, ...rest });
|
|
6097
|
+
}
|
|
6098
|
+
};
|
|
6077
6099
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
6078
|
-
/* @__PURE__ */ jsx(
|
|
6100
|
+
/* @__PURE__ */ jsx(
|
|
6101
|
+
EditorField,
|
|
6102
|
+
{
|
|
6103
|
+
label: "Image source",
|
|
6104
|
+
help: "Where the image comes from: a public URL, or a file already uploaded to your Slack workspace.",
|
|
6105
|
+
children: /* @__PURE__ */ jsx(
|
|
6106
|
+
RadioGroup,
|
|
6107
|
+
{
|
|
6108
|
+
value: source,
|
|
6109
|
+
onValueChange: (v) => setSource(v),
|
|
6110
|
+
className: "flex flex-row flex-wrap gap-3",
|
|
6111
|
+
children: [
|
|
6112
|
+
["url", "Public URL"],
|
|
6113
|
+
["slack_file", "Slack file"]
|
|
6114
|
+
].map(([value, label]) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
6115
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { value, id: `img-source-${value}` }),
|
|
6116
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `img-source-${value}`, className: "text-xs", children: label })
|
|
6117
|
+
] }, value))
|
|
6118
|
+
}
|
|
6119
|
+
)
|
|
6120
|
+
}
|
|
6121
|
+
),
|
|
6122
|
+
"slack_file" in block ? /* @__PURE__ */ jsx(SlackFileFields, { block, onChange }) : /* @__PURE__ */ jsx(EditorField, { label: "Image URL", help: "A publicly accessible image URL (PNG, JPG, GIF).", htmlFor: "img-url", children: /* @__PURE__ */ jsx(
|
|
6079
6123
|
Input,
|
|
6080
6124
|
{
|
|
6081
6125
|
id: "img-url",
|
|
@@ -6119,6 +6163,51 @@ function ImageEditor({ block, onChange }) {
|
|
|
6119
6163
|
) })
|
|
6120
6164
|
] });
|
|
6121
6165
|
}
|
|
6166
|
+
function SlackFileFields({
|
|
6167
|
+
block,
|
|
6168
|
+
onChange
|
|
6169
|
+
}) {
|
|
6170
|
+
const fileId = "id" in block.slack_file ? block.slack_file.id : "";
|
|
6171
|
+
const fileUrl = "url" in block.slack_file ? block.slack_file.url : "";
|
|
6172
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6173
|
+
/* @__PURE__ */ jsx("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "References a file already uploaded to your Slack workspace. The preview can't render workspace files \u2014 switch the source to Public URL to see the image here." }),
|
|
6174
|
+
/* @__PURE__ */ jsx(
|
|
6175
|
+
EditorField,
|
|
6176
|
+
{
|
|
6177
|
+
label: "File ID",
|
|
6178
|
+
help: "The Slack file's ID. Slack accepts an ID or a URL, not both, so filling this clears File URL.",
|
|
6179
|
+
htmlFor: "img-file-id",
|
|
6180
|
+
children: /* @__PURE__ */ jsx(
|
|
6181
|
+
Input,
|
|
6182
|
+
{
|
|
6183
|
+
id: "img-file-id",
|
|
6184
|
+
value: fileId,
|
|
6185
|
+
placeholder: "e.g. F0123456789",
|
|
6186
|
+
onChange: (e) => onChange({ ...block, slack_file: { id: e.target.value } })
|
|
6187
|
+
}
|
|
6188
|
+
)
|
|
6189
|
+
}
|
|
6190
|
+
),
|
|
6191
|
+
/* @__PURE__ */ jsx(
|
|
6192
|
+
EditorField,
|
|
6193
|
+
{
|
|
6194
|
+
label: "File URL",
|
|
6195
|
+
help: "The file's Slack-hosted URL. Filling this clears File ID.",
|
|
6196
|
+
htmlFor: "img-file-url",
|
|
6197
|
+
children: /* @__PURE__ */ jsx(
|
|
6198
|
+
Input,
|
|
6199
|
+
{
|
|
6200
|
+
id: "img-file-url",
|
|
6201
|
+
type: "url",
|
|
6202
|
+
value: fileUrl,
|
|
6203
|
+
placeholder: "e.g. https://files.slack.com/files-pri/T0123-F0123/image.png",
|
|
6204
|
+
onChange: (e) => onChange({ ...block, slack_file: { url: e.target.value } })
|
|
6205
|
+
}
|
|
6206
|
+
)
|
|
6207
|
+
}
|
|
6208
|
+
)
|
|
6209
|
+
] });
|
|
6210
|
+
}
|
|
6122
6211
|
function InputEditor({ block, onChange }) {
|
|
6123
6212
|
const updateElement = (next) => {
|
|
6124
6213
|
onChange({ ...block, element: next });
|
|
@@ -10000,7 +10089,7 @@ function Toolbar2({
|
|
|
10000
10089
|
variant: "ghost",
|
|
10001
10090
|
size: "sm",
|
|
10002
10091
|
onClick: onOpenPalette,
|
|
10003
|
-
className: "md:hidden",
|
|
10092
|
+
className: "gap-1 md:hidden",
|
|
10004
10093
|
"aria-label": "Add a block",
|
|
10005
10094
|
children: [
|
|
10006
10095
|
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
@@ -10556,12 +10645,20 @@ function BlockKitchen(props) {
|
|
|
10556
10645
|
useNotifyOnChange(activeEditTarget, loadedMessageKey, loading?.onLoadedMessageChange);
|
|
10557
10646
|
const [issuesOpen, setIssuesOpen] = useState(false);
|
|
10558
10647
|
const [paletteOpen, setPaletteOpen] = useState(false);
|
|
10648
|
+
const [paletteCollapsed, setPaletteCollapsed] = useState(false);
|
|
10649
|
+
const [paletteAdvanced, setPaletteAdvanced] = useState(false);
|
|
10650
|
+
const [prevPaletteMode, setPrevPaletteMode] = useState(paletteMode);
|
|
10651
|
+
if (prevPaletteMode !== paletteMode) {
|
|
10652
|
+
setPrevPaletteMode(paletteMode);
|
|
10653
|
+
setPaletteAdvanced(false);
|
|
10654
|
+
}
|
|
10559
10655
|
const [openBlockId, setOpenBlockId] = useState(null);
|
|
10560
10656
|
const [uncontrolledPreviewTheme, setUncontrolledPreviewTheme] = useState(defaultPreviewTheme);
|
|
10561
10657
|
const isPreviewThemeControlled = controlledPreviewTheme !== void 0;
|
|
10562
10658
|
const previewTheme = controlledPreviewTheme ?? uncontrolledPreviewTheme;
|
|
10563
10659
|
const [previewSurface, setPreviewSurface] = useState(allowedSurfaces[0]);
|
|
10564
10660
|
const [activePaletteVariantId, setActivePaletteVariantId] = useState(null);
|
|
10661
|
+
const paletteSheetRef = useRef(null);
|
|
10565
10662
|
const isMobile = useIsMobile();
|
|
10566
10663
|
const mergedPreviewHooks = useMemo(() => {
|
|
10567
10664
|
if (!customEmojis || customEmojis.length === 0) {
|
|
@@ -10745,17 +10842,48 @@ function BlockKitchen(props) {
|
|
|
10745
10842
|
}
|
|
10746
10843
|
),
|
|
10747
10844
|
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 items-stretch", children: [
|
|
10748
|
-
/* @__PURE__ */
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10845
|
+
/* @__PURE__ */ jsxs("div", { className: "relative hidden min-h-0 shrink-0 md:flex", children: [
|
|
10846
|
+
/* @__PURE__ */ jsx("div", { hidden: paletteCollapsed, className: cn("min-h-0", !paletteCollapsed && "flex"), children: /* @__PURE__ */ jsx(
|
|
10847
|
+
Palette,
|
|
10848
|
+
{
|
|
10849
|
+
onAddBlock: (block) => addBlock(block),
|
|
10850
|
+
sections: paletteSections,
|
|
10851
|
+
mode: paletteMode,
|
|
10852
|
+
showSearch: showPaletteSearch,
|
|
10853
|
+
searchPlaceholder: paletteSearchPlaceholder,
|
|
10854
|
+
defaultOpenSections,
|
|
10855
|
+
defaultAdvanced: paletteAdvanced,
|
|
10856
|
+
onAdvancedChange: setPaletteAdvanced
|
|
10857
|
+
}
|
|
10858
|
+
) }),
|
|
10859
|
+
paletteCollapsed ? (
|
|
10860
|
+
// In a host that hands the builder no height of its own,
|
|
10861
|
+
// the rail is what the shell takes its height from (see
|
|
10862
|
+
// the shell's `max-h` note above) — so hiding it would
|
|
10863
|
+
// shrink the whole frame to the height of the message and
|
|
10864
|
+
// grow it back on the way out. This stands in for the rail
|
|
10865
|
+
// at no width. Inert to everything but layout.
|
|
10866
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: "w-0 shrink-0 md:h-[var(--bk-max-height,100svh)]" })
|
|
10867
|
+
) : null,
|
|
10868
|
+
/* @__PURE__ */ jsx(
|
|
10869
|
+
"button",
|
|
10870
|
+
{
|
|
10871
|
+
type: "button",
|
|
10872
|
+
onClick: () => setPaletteCollapsed((v) => !v),
|
|
10873
|
+
"aria-expanded": !paletteCollapsed,
|
|
10874
|
+
"aria-label": paletteCollapsed ? "Show block palette" : "Hide block palette",
|
|
10875
|
+
title: paletteCollapsed ? "Show block palette" : "Hide block palette",
|
|
10876
|
+
className: cn(
|
|
10877
|
+
// A hairline outline in the rail's own border color, so
|
|
10878
|
+
// the handle reads as part of the edge it rides rather
|
|
10879
|
+
// than a chevron floating loose over the border line.
|
|
10880
|
+
"absolute top-1/2 z-10 flex h-10 w-4 -translate-y-1/2 cursor-pointer appearance-none items-center justify-center rounded-sm border bg-background p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10881
|
+
paletteCollapsed ? "left-0" : "right-0 translate-x-1/2"
|
|
10882
|
+
),
|
|
10883
|
+
children: paletteCollapsed ? /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4", strokeWidth: 1.5 }) : /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4", strokeWidth: 1.5 })
|
|
10884
|
+
}
|
|
10885
|
+
)
|
|
10886
|
+
] }),
|
|
10759
10887
|
/* @__PURE__ */ jsx(
|
|
10760
10888
|
Surface,
|
|
10761
10889
|
{
|
|
@@ -10788,8 +10916,13 @@ function BlockKitchen(props) {
|
|
|
10788
10916
|
/* @__PURE__ */ jsx(Sheet, { open: paletteOpen && isMobile, onOpenChange: setPaletteOpen, children: /* @__PURE__ */ jsxs(
|
|
10789
10917
|
SheetContent,
|
|
10790
10918
|
{
|
|
10919
|
+
ref: paletteSheetRef,
|
|
10791
10920
|
side: "bottom",
|
|
10792
10921
|
className: "bk-portal-content flex h-[85svh] max-h-[85svh] flex-col gap-3 p-0 sm:max-w-none",
|
|
10922
|
+
onOpenAutoFocus: (e) => {
|
|
10923
|
+
e.preventDefault();
|
|
10924
|
+
paletteSheetRef.current?.focus();
|
|
10925
|
+
},
|
|
10793
10926
|
children: [
|
|
10794
10927
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 px-4 pt-5", children: [
|
|
10795
10928
|
/* @__PURE__ */ jsx(SheetTitle, { children: "Add a block" }),
|
|
@@ -10807,6 +10940,8 @@ function BlockKitchen(props) {
|
|
|
10807
10940
|
showSearch: showPaletteSearch,
|
|
10808
10941
|
searchPlaceholder: paletteSearchPlaceholder,
|
|
10809
10942
|
defaultOpenSections,
|
|
10943
|
+
defaultAdvanced: paletteAdvanced,
|
|
10944
|
+
onAdvancedChange: setPaletteAdvanced,
|
|
10810
10945
|
variant: "sheet"
|
|
10811
10946
|
}
|
|
10812
10947
|
) })
|