@tightknitai/block-kitchen 0.9.1 → 0.9.3
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/helpers.cjs +10 -0
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +10 -0
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +32 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1887,6 +1887,10 @@ function sanitizeImageSrc(value) {
|
|
|
1887
1887
|
// src/lib/sanitize-blocks.ts
|
|
1888
1888
|
var HREF_KEYS = /* @__PURE__ */ new Set(["url"]);
|
|
1889
1889
|
var IMAGE_KEYS = /* @__PURE__ */ new Set(["image_url"]);
|
|
1890
|
+
var RETRIEVAL_ONLY_KEYS = /* @__PURE__ */ new Map([
|
|
1891
|
+
// Covers both the image block and the image element — both `type: 'image'`.
|
|
1892
|
+
["image", /* @__PURE__ */ new Set(["image_width", "image_height", "image_bytes", "fallback", "is_animated"])]
|
|
1893
|
+
]);
|
|
1890
1894
|
function sanitizeValue(value) {
|
|
1891
1895
|
if (value === null || typeof value !== "object") {
|
|
1892
1896
|
return value;
|
|
@@ -1904,8 +1908,14 @@ function sanitizeValue(value) {
|
|
|
1904
1908
|
return changed ? out : value;
|
|
1905
1909
|
}
|
|
1906
1910
|
const src = value;
|
|
1911
|
+
const dropKeys = typeof src.type === "string" ? RETRIEVAL_ONLY_KEYS.get(src.type) : void 0;
|
|
1907
1912
|
let copy = null;
|
|
1908
1913
|
for (const key of Object.keys(src)) {
|
|
1914
|
+
if (dropKeys?.has(key)) {
|
|
1915
|
+
copy ??= { ...src };
|
|
1916
|
+
delete copy[key];
|
|
1917
|
+
continue;
|
|
1918
|
+
}
|
|
1909
1919
|
const original = src[key];
|
|
1910
1920
|
let next = original;
|
|
1911
1921
|
if (typeof original === "string") {
|
|
@@ -1929,6 +1939,18 @@ function sanitizeValue(value) {
|
|
|
1929
1939
|
function sanitizeBlock(block) {
|
|
1930
1940
|
return sanitizeValue(block);
|
|
1931
1941
|
}
|
|
1942
|
+
function sanitizeBlocks(blocks) {
|
|
1943
|
+
let changed = false;
|
|
1944
|
+
const out = new Array(blocks.length);
|
|
1945
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
1946
|
+
const next = sanitizeBlock(blocks[i]);
|
|
1947
|
+
if (next !== blocks[i]) {
|
|
1948
|
+
changed = true;
|
|
1949
|
+
}
|
|
1950
|
+
out[i] = next;
|
|
1951
|
+
}
|
|
1952
|
+
return changed ? out : blocks;
|
|
1953
|
+
}
|
|
1932
1954
|
|
|
1933
1955
|
// src/lib/to-slack-blocks.ts
|
|
1934
1956
|
function toSlackBlocks(blocks) {
|
|
@@ -2186,7 +2208,7 @@ function useBlockKitchenState({
|
|
|
2186
2208
|
});
|
|
2187
2209
|
}, []);
|
|
2188
2210
|
const replaceAll = useCallback((newBlocks) => {
|
|
2189
|
-
setBlocks(newBlocks.map(wrap));
|
|
2211
|
+
setBlocks(sanitizeBlocks(newBlocks).map(wrap));
|
|
2190
2212
|
}, []);
|
|
2191
2213
|
return {
|
|
2192
2214
|
blocks,
|
|
@@ -2922,7 +2944,7 @@ function LoadMessageDialog({
|
|
|
2922
2944
|
children: [
|
|
2923
2945
|
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
2924
2946
|
/* @__PURE__ */ jsx(DialogTitle, { children: "Edit an existing message" }),
|
|
2925
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1.5", children: [
|
|
2947
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1.5 text-left", children: [
|
|
2926
2948
|
/* @__PURE__ */ jsx(DialogDescription, { children: hasRecent ? "Paste a Slack message link, or pick a recent message your app posted." : `Paste a Slack message link (Slack's "Copy link") to load its blocks for editing.` }),
|
|
2927
2949
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
2928
2950
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
@@ -2944,7 +2966,7 @@ function LoadMessageDialog({
|
|
|
2944
2966
|
] })
|
|
2945
2967
|
] })
|
|
2946
2968
|
] }),
|
|
2947
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
2969
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [
|
|
2948
2970
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2949
2971
|
/* @__PURE__ */ jsx(Label, { htmlFor: "message-link", children: "Message link" }),
|
|
2950
2972
|
/* @__PURE__ */ jsx(
|
|
@@ -2989,7 +3011,7 @@ function LoadMessageDialog({
|
|
|
2989
3011
|
}
|
|
2990
3012
|
)
|
|
2991
3013
|
] }),
|
|
2992
|
-
hasRecent && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3014
|
+
hasRecent && /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
2993
3015
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
2994
3016
|
/* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-border" }),
|
|
2995
3017
|
"or pick a recent message",
|
|
@@ -3021,22 +3043,19 @@ function LoadMessageDialog({
|
|
|
3021
3043
|
channelId && recent === null && !recentError && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Loading recent messages\u2026" }),
|
|
3022
3044
|
channelId && recentError && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: recentError }),
|
|
3023
3045
|
channelId && recent && recent.length === 0 && !recentError && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "No recent messages from this app in this channel." }),
|
|
3024
|
-
channelId && recent && recent.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex max-h-48 flex-col gap-1 overflow-y-auto", children: recent.map((m) => {
|
|
3046
|
+
channelId && recent && recent.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex max-h-48 min-w-0 flex-col gap-1 overflow-y-auto", children: recent.map((m) => {
|
|
3025
3047
|
const asUser = (m.editableVia ?? "bot") === "user";
|
|
3026
3048
|
return /* @__PURE__ */ jsxs(
|
|
3027
3049
|
"button",
|
|
3028
3050
|
{
|
|
3029
3051
|
type: "button",
|
|
3030
3052
|
onClick: () => onLoaded(recentToResult(m)),
|
|
3031
|
-
className: "flex flex-col gap-0.5 rounded-md border border-input bg-background px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
3053
|
+
className: "flex min-w-0 flex-col gap-0.5 rounded-md border border-input bg-background px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
3032
3054
|
children: [
|
|
3033
|
-
/* @__PURE__ */ jsxs("span", { className: "flex items-baseline justify-between gap-2", children: [
|
|
3034
|
-
/* @__PURE__ */
|
|
3035
|
-
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: m.channelName ? `#${m.channelName}` : m.channelId }),
|
|
3036
|
-
/* @__PURE__ */ jsx("span", { className: "shrink-0 rounded border px-1 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: asUser ? "You" : "Bot" })
|
|
3037
|
-
] }),
|
|
3055
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-baseline justify-between gap-2", children: [
|
|
3056
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 rounded border px-1 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: asUser ? "You" : "Bot" }),
|
|
3038
3057
|
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
|
|
3039
|
-
new Date(Number(m.ts) * 1e3).toLocaleString(),
|
|
3058
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: new Date(Number(m.ts) * 1e3).toLocaleString() }),
|
|
3040
3059
|
" ",
|
|
3041
3060
|
/* @__PURE__ */ jsxs("span", { className: "font-mono", children: [
|
|
3042
3061
|
"(",
|
|
@@ -3045,7 +3064,7 @@ function LoadMessageDialog({
|
|
|
3045
3064
|
] })
|
|
3046
3065
|
] })
|
|
3047
3066
|
] }),
|
|
3048
|
-
m.label && /* @__PURE__ */ jsx("span", { className: "truncate text-
|
|
3067
|
+
m.label && /* @__PURE__ */ jsx("span", { className: "truncate text-sm text-muted-foreground", children: m.label })
|
|
3049
3068
|
]
|
|
3050
3069
|
},
|
|
3051
3070
|
`${m.channelId}:${m.ts}`
|