@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.
- package/README.md +92 -6
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.cjs +508 -335
- 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 +510 -337
- package/dist/index.js.map +1 -1
- package/dist/{palette-DFTL0Han.d.cts → palette-DTE9U5si.d.cts} +76 -1
- package/dist/{palette-DFTL0Han.d.ts → palette-DTE9U5si.d.ts} +76 -1
- 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.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, ChevronRight, ChevronLeft, GripVertical, ChevronsUpDown, Check, Sun, Moon, MessageSquare, AppWindow, Home, Plus, ChevronDown, BookOpen, Undo2, Redo2, Trash2, Code2, Pencil, Send, Search, Copy, Info, CheckCircle2, LayoutGrid, ArrowUp, ArrowDown, Type, Bold, Italic, Strikethrough, Underline, Code, AtSign, Hash, List, ListOrdered, Quote, Smile, Link as Link$1 } from 'lucide-react';
|
|
3
|
+
import { X, Circle, Sparkles, FileText, AlignLeft, MousePointerClick, TextCursorInput, LayoutTemplate, Bell, Pilcrow, Image, Video, GalleryHorizontal, Table, ChartColumnBig, Container, Loader2, ExternalLink, AlertTriangle, ChevronRight, ChevronLeft, GripVertical, ChevronsUpDown, Check, Sun, Moon, MessageSquare, AppWindow, Home, Plus, ChevronDown, BookOpen, Undo2, Redo2, Trash2, Code2, Pencil, Send, Search, Copy, Info, CheckCircle2, LayoutGrid, ArrowUp, ArrowDown, Lock, Type, Bold, Italic, Strikethrough, Underline, Code, AtSign, Hash, List, ListOrdered, Quote, Smile, Link as Link$1 } from 'lucide-react';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { createContext, useContext, useState, useRef, useEffect, useCallback, useMemo, useId } from 'react';
|
|
5
|
+
import { createContext, useContext, useState, useRef, useEffect, useCallback, useMemo, useId, useSyncExternalStore, useLayoutEffect } from 'react';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1787,6 +1787,35 @@ function labelForBlockType(type) {
|
|
|
1787
1787
|
return "Data Table";
|
|
1788
1788
|
}
|
|
1789
1789
|
}
|
|
1790
|
+
function historyShortcutOf(event) {
|
|
1791
|
+
if (!(event.metaKey || event.ctrlKey) || event.altKey) {
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
const key = event.key.toLowerCase();
|
|
1795
|
+
if (key === "z") {
|
|
1796
|
+
return event.shiftKey ? "redo" : "undo";
|
|
1797
|
+
}
|
|
1798
|
+
return key === "y" ? "redo" : null;
|
|
1799
|
+
}
|
|
1800
|
+
function isTextEditingTarget(target) {
|
|
1801
|
+
if (!(target instanceof HTMLElement)) {
|
|
1802
|
+
return false;
|
|
1803
|
+
}
|
|
1804
|
+
return target.isContentEditable || // jsdom has no `isContentEditable`, so check the attribute too.
|
|
1805
|
+
target.closest('[contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]') !== null || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName);
|
|
1806
|
+
}
|
|
1807
|
+
function isApplePlatform() {
|
|
1808
|
+
if (typeof navigator === "undefined") {
|
|
1809
|
+
return false;
|
|
1810
|
+
}
|
|
1811
|
+
const { userAgentData } = navigator;
|
|
1812
|
+
return /mac|iphone|ipad|ipod/i.test(userAgentData?.platform ?? navigator.platform ?? "");
|
|
1813
|
+
}
|
|
1814
|
+
var subscribeToNothing = () => () => {
|
|
1815
|
+
};
|
|
1816
|
+
function useIsApplePlatform() {
|
|
1817
|
+
return useSyncExternalStore(subscribeToNothing, isApplePlatform, () => false);
|
|
1818
|
+
}
|
|
1790
1819
|
var Sheet = DialogPrimitive.Root;
|
|
1791
1820
|
var SheetOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1792
1821
|
DialogPrimitive.Overlay,
|
|
@@ -1868,6 +1897,16 @@ function useIsMobile() {
|
|
|
1868
1897
|
}, []);
|
|
1869
1898
|
return isMobile;
|
|
1870
1899
|
}
|
|
1900
|
+
var BlockEditorsContext = createContext([]);
|
|
1901
|
+
function BlockEditorsProvider({
|
|
1902
|
+
blockEditors,
|
|
1903
|
+
children
|
|
1904
|
+
}) {
|
|
1905
|
+
return /* @__PURE__ */ jsx(BlockEditorsContext.Provider, { value: blockEditors ?? [], children });
|
|
1906
|
+
}
|
|
1907
|
+
function useCustomBlockEditor(block) {
|
|
1908
|
+
return useContext(BlockEditorsContext).find((editor) => editor.match(block));
|
|
1909
|
+
}
|
|
1871
1910
|
var EMPTY = {
|
|
1872
1911
|
customEmojis: [],
|
|
1873
1912
|
byName: /* @__PURE__ */ new Map()
|
|
@@ -4209,6 +4248,7 @@ function Palette({
|
|
|
4209
4248
|
mode = "advanced",
|
|
4210
4249
|
defaultAdvanced = false,
|
|
4211
4250
|
onAdvancedChange,
|
|
4251
|
+
onLockedPicked,
|
|
4212
4252
|
variant = "aside"
|
|
4213
4253
|
}) {
|
|
4214
4254
|
const [query, setQuery] = useState("");
|
|
@@ -4302,7 +4342,16 @@ function Palette({
|
|
|
4302
4342
|
/* @__PURE__ */ jsx("div", { className: cn("flex flex-col", isSheet ? "px-2 pb-6" : "p-3"), children: !advanced ? (
|
|
4303
4343
|
// Simple mode: a flat list, no section headings — with this few
|
|
4304
4344
|
// rows the headings would outnumber the blocks under them.
|
|
4305
|
-
basics.map((v) => /* @__PURE__ */ jsx(
|
|
4345
|
+
basics.map((v) => /* @__PURE__ */ jsx(
|
|
4346
|
+
PaletteItem,
|
|
4347
|
+
{
|
|
4348
|
+
variant: v,
|
|
4349
|
+
onAdd: () => onAddBlock(v.factory()),
|
|
4350
|
+
onLockedPicked,
|
|
4351
|
+
mode: variant
|
|
4352
|
+
},
|
|
4353
|
+
v.id
|
|
4354
|
+
))
|
|
4306
4355
|
) : visibleSections.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-1 py-2 text-xs text-muted-foreground", children: "No blocks match." }) : visibleSections.map((section) => /* @__PURE__ */ jsx(
|
|
4307
4356
|
PaletteSection,
|
|
4308
4357
|
{
|
|
@@ -4310,6 +4359,7 @@ function Palette({
|
|
|
4310
4359
|
defaultOpen: isDefaultOpen(section.name, defaultOpenSections),
|
|
4311
4360
|
forceOpen: queryActive,
|
|
4312
4361
|
onAddBlock,
|
|
4362
|
+
onLockedPicked,
|
|
4313
4363
|
variant
|
|
4314
4364
|
},
|
|
4315
4365
|
section.name
|
|
@@ -4341,6 +4391,7 @@ function PaletteSection({
|
|
|
4341
4391
|
defaultOpen,
|
|
4342
4392
|
forceOpen,
|
|
4343
4393
|
onAddBlock,
|
|
4394
|
+
onLockedPicked,
|
|
4344
4395
|
variant = "aside"
|
|
4345
4396
|
}) {
|
|
4346
4397
|
const [open, setOpen] = useState(defaultOpen);
|
|
@@ -4372,18 +4423,32 @@ function PaletteSection({
|
|
|
4372
4423
|
]
|
|
4373
4424
|
}
|
|
4374
4425
|
),
|
|
4375
|
-
isOpen ? /* @__PURE__ */ jsx("div", { className: "mt-0.5 flex flex-col", children: section.variants.map((v) => /* @__PURE__ */ jsx(
|
|
4426
|
+
isOpen ? /* @__PURE__ */ jsx("div", { className: "mt-0.5 flex flex-col", children: section.variants.map((v) => /* @__PURE__ */ jsx(
|
|
4427
|
+
PaletteItem,
|
|
4428
|
+
{
|
|
4429
|
+
variant: v,
|
|
4430
|
+
onAdd: () => onAddBlock(v.factory()),
|
|
4431
|
+
onLockedPicked,
|
|
4432
|
+
mode: variant
|
|
4433
|
+
},
|
|
4434
|
+
v.id
|
|
4435
|
+
)) }) : null
|
|
4376
4436
|
] });
|
|
4377
4437
|
}
|
|
4378
4438
|
function PaletteItem({
|
|
4379
4439
|
variant,
|
|
4380
4440
|
onAdd,
|
|
4441
|
+
onLockedPicked,
|
|
4381
4442
|
mode = "aside"
|
|
4382
4443
|
}) {
|
|
4383
4444
|
const { attributes, listeners, setNodeRef, setActivatorNodeRef, isDragging } = useDraggable({
|
|
4384
|
-
id: `${PALETTE_DRAG_PREFIX}${variant.id}
|
|
4445
|
+
id: `${PALETTE_DRAG_PREFIX}${variant.id}`,
|
|
4446
|
+
disabled: variant.locked
|
|
4385
4447
|
});
|
|
4386
4448
|
const isSheet = mode === "sheet";
|
|
4449
|
+
if (variant.locked) {
|
|
4450
|
+
return /* @__PURE__ */ jsx(LockedPaletteItem, { variant, isSheet, onPicked: onLockedPicked });
|
|
4451
|
+
}
|
|
4387
4452
|
if (isSheet) {
|
|
4388
4453
|
return /* @__PURE__ */ jsxs(
|
|
4389
4454
|
"button",
|
|
@@ -4398,6 +4463,7 @@ function PaletteItem({
|
|
|
4398
4463
|
),
|
|
4399
4464
|
children: [
|
|
4400
4465
|
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: variant.label }),
|
|
4466
|
+
variant.badge ? /* @__PURE__ */ jsx(VariantBadge, { badge: variant.badge }) : null,
|
|
4401
4467
|
/* @__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" }) })
|
|
4402
4468
|
]
|
|
4403
4469
|
}
|
|
@@ -4421,7 +4487,11 @@ function PaletteItem({
|
|
|
4421
4487
|
...listeners,
|
|
4422
4488
|
children: [
|
|
4423
4489
|
/* @__PURE__ */ jsx(GripVertical, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
4424
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: variant.label })
|
|
4490
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: variant.label }),
|
|
4491
|
+
variant.badge ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4492
|
+
" ",
|
|
4493
|
+
/* @__PURE__ */ jsx(VariantBadge, { badge: variant.badge })
|
|
4494
|
+
] }) : null
|
|
4425
4495
|
]
|
|
4426
4496
|
}
|
|
4427
4497
|
),
|
|
@@ -4439,6 +4509,48 @@ function PaletteItem({
|
|
|
4439
4509
|
}
|
|
4440
4510
|
);
|
|
4441
4511
|
}
|
|
4512
|
+
function LockedPaletteItem({
|
|
4513
|
+
variant,
|
|
4514
|
+
isSheet,
|
|
4515
|
+
onPicked
|
|
4516
|
+
}) {
|
|
4517
|
+
const select = variant.onLockedSelect;
|
|
4518
|
+
const className = cn(
|
|
4519
|
+
"flex w-full items-center text-left text-muted-foreground",
|
|
4520
|
+
isSheet ? "min-h-11 gap-3 rounded-md px-3 py-2 text-sm font-medium" : "gap-2 rounded px-2 py-1 text-sm"
|
|
4521
|
+
);
|
|
4522
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4523
|
+
/* @__PURE__ */ jsx(Lock, { "aria-hidden": true, className: cn("shrink-0", isSheet ? "h-4 w-4" : "h-3.5 w-3.5") }),
|
|
4524
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: variant.label }),
|
|
4525
|
+
variant.badge ? /* @__PURE__ */ jsx(VariantBadge, { badge: variant.badge }) : null
|
|
4526
|
+
] });
|
|
4527
|
+
if (!select) {
|
|
4528
|
+
return /* @__PURE__ */ jsx("div", { "aria-disabled": "true", className, children: content });
|
|
4529
|
+
}
|
|
4530
|
+
return /* @__PURE__ */ jsx(
|
|
4531
|
+
"button",
|
|
4532
|
+
{
|
|
4533
|
+
type: "button",
|
|
4534
|
+
"aria-label": `${variant.label} (locked${variant.badge ? `, ${variant.badge.label}` : ""})`,
|
|
4535
|
+
onClick: () => {
|
|
4536
|
+
onPicked?.();
|
|
4537
|
+
select();
|
|
4538
|
+
},
|
|
4539
|
+
className: cn(
|
|
4540
|
+
className,
|
|
4541
|
+
"cursor-pointer appearance-none border-0 bg-transparent transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
4542
|
+
),
|
|
4543
|
+
children: content
|
|
4544
|
+
}
|
|
4545
|
+
);
|
|
4546
|
+
}
|
|
4547
|
+
function VariantBadge({ badge }) {
|
|
4548
|
+
const Icon = badge.icon;
|
|
4549
|
+
return /* @__PURE__ */ jsxs("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full border bg-background px-1.5 text-[10px] font-medium leading-4 text-muted-foreground", children: [
|
|
4550
|
+
Icon ? /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, className: "h-2.5 w-2.5 shrink-0" }) : null,
|
|
4551
|
+
badge.label
|
|
4552
|
+
] });
|
|
4553
|
+
}
|
|
4442
4554
|
function SendDialog({
|
|
4443
4555
|
open,
|
|
4444
4556
|
onOpenChange,
|
|
@@ -6258,7 +6370,7 @@ function MentionPicker({
|
|
|
6258
6370
|
const listRef = useRef(null);
|
|
6259
6371
|
const listboxId = useId();
|
|
6260
6372
|
const activeOptionId = items[activeIndex] ? `${listboxId}-${activeIndex}` : void 0;
|
|
6261
|
-
|
|
6373
|
+
useLayoutEffect(() => {
|
|
6262
6374
|
const root = editor.view.dom;
|
|
6263
6375
|
root.setAttribute("role", "combobox");
|
|
6264
6376
|
root.setAttribute("aria-autocomplete", "list");
|
|
@@ -6277,7 +6389,7 @@ function MentionPicker({
|
|
|
6277
6389
|
root.removeAttribute("aria-activedescendant");
|
|
6278
6390
|
};
|
|
6279
6391
|
}, [activeOptionId, editor, listboxId]);
|
|
6280
|
-
|
|
6392
|
+
useLayoutEffect(() => {
|
|
6281
6393
|
keyHandlerRef.current = (event) => {
|
|
6282
6394
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
6283
6395
|
if (items.length > 0) {
|
|
@@ -10367,13 +10479,15 @@ function BlockEditor({
|
|
|
10367
10479
|
onChange,
|
|
10368
10480
|
onDone
|
|
10369
10481
|
}) {
|
|
10482
|
+
const custom = useCustomBlockEditor(block);
|
|
10483
|
+
const CustomForm = custom?.component;
|
|
10370
10484
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
10371
10485
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("h3", { className: "text-sm font-semibold text-foreground", children: [
|
|
10372
10486
|
"Edit ",
|
|
10373
|
-
labelForBlockType(block.type)
|
|
10487
|
+
custom ? custom.label : labelForBlockType(block.type)
|
|
10374
10488
|
] }) }),
|
|
10375
10489
|
errors && errors.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-0.5 rounded-md border border-destructive/30 bg-destructive/5 p-2 text-xs text-destructive", children: errors.map((err, i) => /* @__PURE__ */ jsx("li", { children: err }, i)) }) : null,
|
|
10376
|
-
dispatch(block, onChange),
|
|
10490
|
+
CustomForm ? /* @__PURE__ */ jsx(CustomForm, { block, onChange }) : dispatch(block, onChange),
|
|
10377
10491
|
/* @__PURE__ */ jsx(
|
|
10378
10492
|
AdvancedIdField,
|
|
10379
10493
|
{
|
|
@@ -10471,7 +10585,8 @@ function BlockRow({
|
|
|
10471
10585
|
onReorder,
|
|
10472
10586
|
isPaletteDrag = false,
|
|
10473
10587
|
position,
|
|
10474
|
-
blockActions
|
|
10588
|
+
blockActions,
|
|
10589
|
+
renderBlockAdornment
|
|
10475
10590
|
}) {
|
|
10476
10591
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging, isOver } = useSortable({
|
|
10477
10592
|
id: builderBlock.id
|
|
@@ -10486,6 +10601,179 @@ function BlockRow({
|
|
|
10486
10601
|
const [inlineEditing, setInlineEditing] = useState(false);
|
|
10487
10602
|
const showDropIndicator = isPaletteDrag && isOver;
|
|
10488
10603
|
const preview = /* @__PURE__ */ jsx(SlackBlockPreview, { block: builderBlock.block, hooks: previewHooks, theme: previewTheme });
|
|
10604
|
+
const body = isRichText && inlineEditing ? /* @__PURE__ */ jsx(
|
|
10605
|
+
RichTextInlineEditor,
|
|
10606
|
+
{
|
|
10607
|
+
block: builderBlock.block,
|
|
10608
|
+
onSave: (next) => {
|
|
10609
|
+
onUpdate(builderBlock.id, next);
|
|
10610
|
+
setInlineEditing(false);
|
|
10611
|
+
},
|
|
10612
|
+
onCancel: () => setInlineEditing(false)
|
|
10613
|
+
}
|
|
10614
|
+
) : isRichText ? /* @__PURE__ */ jsx(
|
|
10615
|
+
"button",
|
|
10616
|
+
{
|
|
10617
|
+
type: "button",
|
|
10618
|
+
"aria-label": "Edit block",
|
|
10619
|
+
onClick: () => setInlineEditing(true),
|
|
10620
|
+
...attributes,
|
|
10621
|
+
...listeners,
|
|
10622
|
+
className: cn(
|
|
10623
|
+
"block w-full cursor-grab rounded-sm border-0 bg-transparent p-0 text-left transition-shadow hover:shadow-md focus-visible:ring-1 focus-visible:ring-ring active:cursor-grabbing",
|
|
10624
|
+
hasErrors ? "ring-1 ring-destructive/60 hover:ring-destructive" : "hover:ring-1 hover:ring-border"
|
|
10625
|
+
),
|
|
10626
|
+
children: preview
|
|
10627
|
+
}
|
|
10628
|
+
) : /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange, children: [
|
|
10629
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10630
|
+
"div",
|
|
10631
|
+
{
|
|
10632
|
+
role: "button",
|
|
10633
|
+
tabIndex: 0,
|
|
10634
|
+
"aria-label": "Edit block",
|
|
10635
|
+
...sortableA11yAttrs,
|
|
10636
|
+
...listeners,
|
|
10637
|
+
onKeyDown: (e) => {
|
|
10638
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
10639
|
+
e.preventDefault();
|
|
10640
|
+
onOpenChange?.(!isOpen);
|
|
10641
|
+
}
|
|
10642
|
+
},
|
|
10643
|
+
className: cn(
|
|
10644
|
+
"block w-full cursor-grab rounded-sm transition-shadow hover:shadow-md focus-visible:ring-1 focus-visible:ring-ring active:cursor-grabbing",
|
|
10645
|
+
hasErrors ? "ring-1 ring-destructive/60 hover:ring-destructive" : "hover:ring-1 hover:ring-border"
|
|
10646
|
+
),
|
|
10647
|
+
children: preview
|
|
10648
|
+
}
|
|
10649
|
+
) }),
|
|
10650
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[min(32rem,calc(100vw-1.5rem))] sm:w-[32rem]", align: "start", children: /* @__PURE__ */ jsx(
|
|
10651
|
+
BlockEditor,
|
|
10652
|
+
{
|
|
10653
|
+
block: builderBlock.block,
|
|
10654
|
+
errors,
|
|
10655
|
+
onChange: (next) => onUpdate(builderBlock.id, next),
|
|
10656
|
+
onDone: () => onOpenChange?.(false)
|
|
10657
|
+
}
|
|
10658
|
+
) })
|
|
10659
|
+
] });
|
|
10660
|
+
const adornment = position && renderBlockAdornment?.(position);
|
|
10661
|
+
const hoverChrome = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10662
|
+
/* @__PURE__ */ jsx("span", { className: "-translate-x-1/2 pointer-events-none absolute bottom-full left-1/2 z-10 hidden bg-background px-1.5 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 md:block", children: BLOCK_TYPE_LABELS[builderBlock.block.type] }),
|
|
10663
|
+
/* @__PURE__ */ jsxs(
|
|
10664
|
+
"div",
|
|
10665
|
+
{
|
|
10666
|
+
className: cn(
|
|
10667
|
+
// Hidden on mobile in favor of the inline row below; on desktop
|
|
10668
|
+
// reveal on hover, on keyboard focus inside the row (so Tab-stops on
|
|
10669
|
+
// the floating buttons themselves keep them visible), and when there
|
|
10670
|
+
// are validation errors worth surfacing immediately.
|
|
10671
|
+
// :focus-visible, not :focus-within — a drag leaves pointer focus on
|
|
10672
|
+
// the block, which would otherwise pin the toolbar open until a click.
|
|
10673
|
+
"absolute -top-3 right-2 z-10 hidden items-center gap-0.5 rounded-md border bg-background p-0.5 shadow-sm transition-opacity md:flex",
|
|
10674
|
+
hasErrors ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-has-[:focus-visible]:opacity-100"
|
|
10675
|
+
),
|
|
10676
|
+
children: [
|
|
10677
|
+
hasErrors ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10678
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10679
|
+
"button",
|
|
10680
|
+
{
|
|
10681
|
+
type: "button",
|
|
10682
|
+
"aria-label": `Show ${errors.length} validation ${errors.length === 1 ? "issue" : "issues"}`,
|
|
10683
|
+
onClick: () => onOpenChange?.(true),
|
|
10684
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10685
|
+
children: /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5" })
|
|
10686
|
+
}
|
|
10687
|
+
) }),
|
|
10688
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", align: "end", children: /* @__PURE__ */ jsxs("ul", { className: "flex flex-col gap-0.5", children: [
|
|
10689
|
+
errors.slice(0, 4).map((err, i) => /* @__PURE__ */ jsx("li", { children: err }, i)),
|
|
10690
|
+
errors.length > 4 ? /* @__PURE__ */ jsxs("li", { className: "text-muted-foreground", children: [
|
|
10691
|
+
"and ",
|
|
10692
|
+
errors.length - 4,
|
|
10693
|
+
" more"
|
|
10694
|
+
] }) : null
|
|
10695
|
+
] }) })
|
|
10696
|
+
] }) : null,
|
|
10697
|
+
onReorder && typeof index === "number" && typeof total === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10698
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10699
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10700
|
+
"button",
|
|
10701
|
+
{
|
|
10702
|
+
type: "button",
|
|
10703
|
+
"aria-label": "Move block up",
|
|
10704
|
+
disabled: index === 0,
|
|
10705
|
+
onClick: () => onReorder(builderBlock.id, index - 1),
|
|
10706
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
|
|
10707
|
+
children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5" })
|
|
10708
|
+
}
|
|
10709
|
+
) }),
|
|
10710
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Move up" })
|
|
10711
|
+
] }),
|
|
10712
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10713
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10714
|
+
"button",
|
|
10715
|
+
{
|
|
10716
|
+
type: "button",
|
|
10717
|
+
"aria-label": "Move block down",
|
|
10718
|
+
disabled: index >= total - 1,
|
|
10719
|
+
onClick: () => onReorder(builderBlock.id, index + 1),
|
|
10720
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
|
|
10721
|
+
children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-3.5 w-3.5" })
|
|
10722
|
+
}
|
|
10723
|
+
) }),
|
|
10724
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Move down" })
|
|
10725
|
+
] })
|
|
10726
|
+
] }) : null,
|
|
10727
|
+
/* @__PURE__ */ jsx(BlockActionButtons, { actions: blockActions, position, variant: "toolbar" }),
|
|
10728
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10729
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10730
|
+
"button",
|
|
10731
|
+
{
|
|
10732
|
+
type: "button",
|
|
10733
|
+
"aria-label": "Edit block",
|
|
10734
|
+
onClick: () => {
|
|
10735
|
+
if (isRichText) {
|
|
10736
|
+
setInlineEditing(true);
|
|
10737
|
+
} else {
|
|
10738
|
+
onOpenChange?.(true);
|
|
10739
|
+
}
|
|
10740
|
+
},
|
|
10741
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10742
|
+
children: /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5" })
|
|
10743
|
+
}
|
|
10744
|
+
) }),
|
|
10745
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Edit" })
|
|
10746
|
+
] }),
|
|
10747
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10748
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10749
|
+
"button",
|
|
10750
|
+
{
|
|
10751
|
+
type: "button",
|
|
10752
|
+
"aria-label": "Duplicate block",
|
|
10753
|
+
onClick: () => onDuplicate(builderBlock.id),
|
|
10754
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10755
|
+
children: /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" })
|
|
10756
|
+
}
|
|
10757
|
+
) }),
|
|
10758
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Duplicate" })
|
|
10759
|
+
] }),
|
|
10760
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10761
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10762
|
+
"button",
|
|
10763
|
+
{
|
|
10764
|
+
type: "button",
|
|
10765
|
+
"aria-label": "Delete block",
|
|
10766
|
+
onClick: () => onDelete(builderBlock.id),
|
|
10767
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10768
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" })
|
|
10769
|
+
}
|
|
10770
|
+
) }),
|
|
10771
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Delete" })
|
|
10772
|
+
] })
|
|
10773
|
+
]
|
|
10774
|
+
}
|
|
10775
|
+
)
|
|
10776
|
+
] });
|
|
10489
10777
|
return /* @__PURE__ */ jsxs(
|
|
10490
10778
|
"div",
|
|
10491
10779
|
{
|
|
@@ -10503,178 +10791,16 @@ function BlockRow({
|
|
|
10503
10791
|
children: /* @__PURE__ */ jsx("span", { className: "-left-1 -top-[3px] absolute h-2 w-2 rounded-full bg-primary shadow-[0_0_0_2px_var(--color-background)]" })
|
|
10504
10792
|
}
|
|
10505
10793
|
) : null,
|
|
10506
|
-
/* @__PURE__ */
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
block: builderBlock.block,
|
|
10511
|
-
onSave: (next) => {
|
|
10512
|
-
onUpdate(builderBlock.id, next);
|
|
10513
|
-
setInlineEditing(false);
|
|
10514
|
-
},
|
|
10515
|
-
onCancel: () => setInlineEditing(false)
|
|
10516
|
-
}
|
|
10517
|
-
) : isRichText ? /* @__PURE__ */ jsx(
|
|
10518
|
-
"button",
|
|
10519
|
-
{
|
|
10520
|
-
type: "button",
|
|
10521
|
-
"aria-label": "Edit block",
|
|
10522
|
-
onClick: () => setInlineEditing(true),
|
|
10523
|
-
...attributes,
|
|
10524
|
-
...listeners,
|
|
10525
|
-
className: cn(
|
|
10526
|
-
"block w-full cursor-grab rounded-sm border-0 bg-transparent p-0 text-left transition-shadow hover:shadow-md focus-visible:ring-1 focus-visible:ring-ring active:cursor-grabbing",
|
|
10527
|
-
hasErrors ? "ring-1 ring-destructive/60 hover:ring-destructive" : "hover:ring-1 hover:ring-border"
|
|
10528
|
-
),
|
|
10529
|
-
children: preview
|
|
10530
|
-
}
|
|
10531
|
-
) : /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange, children: [
|
|
10532
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10533
|
-
"div",
|
|
10534
|
-
{
|
|
10535
|
-
role: "button",
|
|
10536
|
-
tabIndex: 0,
|
|
10537
|
-
"aria-label": "Edit block",
|
|
10538
|
-
...sortableA11yAttrs,
|
|
10539
|
-
...listeners,
|
|
10540
|
-
onKeyDown: (e) => {
|
|
10541
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
10542
|
-
e.preventDefault();
|
|
10543
|
-
onOpenChange?.(!isOpen);
|
|
10544
|
-
}
|
|
10545
|
-
},
|
|
10546
|
-
className: cn(
|
|
10547
|
-
"block w-full cursor-grab rounded-sm transition-shadow hover:shadow-md focus-visible:ring-1 focus-visible:ring-ring active:cursor-grabbing",
|
|
10548
|
-
hasErrors ? "ring-1 ring-destructive/60 hover:ring-destructive" : "hover:ring-1 hover:ring-border"
|
|
10549
|
-
),
|
|
10550
|
-
children: preview
|
|
10551
|
-
}
|
|
10552
|
-
) }),
|
|
10553
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[min(32rem,calc(100vw-1.5rem))] sm:w-[32rem]", align: "start", children: /* @__PURE__ */ jsx(
|
|
10554
|
-
BlockEditor,
|
|
10555
|
-
{
|
|
10556
|
-
block: builderBlock.block,
|
|
10557
|
-
errors,
|
|
10558
|
-
onChange: (next) => onUpdate(builderBlock.id, next),
|
|
10559
|
-
onDone: () => onOpenChange?.(false)
|
|
10560
|
-
}
|
|
10561
|
-
) })
|
|
10794
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-full", children: renderBlockAdornment ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
10795
|
+
/* @__PURE__ */ jsxs("div", { className: "relative min-w-0 flex-1", children: [
|
|
10796
|
+
body,
|
|
10797
|
+
hoverChrome
|
|
10562
10798
|
] }),
|
|
10563
|
-
/* @__PURE__ */ jsx("
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
// Hidden on mobile in favor of the inline row below; on desktop
|
|
10569
|
-
// reveal on hover, on keyboard focus inside the row (so Tab-stops on
|
|
10570
|
-
// the floating buttons themselves keep them visible), and when there
|
|
10571
|
-
// are validation errors worth surfacing immediately.
|
|
10572
|
-
// :focus-visible, not :focus-within — a drag leaves pointer focus on
|
|
10573
|
-
// the block, which would otherwise pin the toolbar open until a click.
|
|
10574
|
-
"absolute -top-3 right-2 z-10 hidden items-center gap-0.5 rounded-md border bg-background p-0.5 shadow-sm transition-opacity md:flex",
|
|
10575
|
-
hasErrors ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-has-[:focus-visible]:opacity-100"
|
|
10576
|
-
),
|
|
10577
|
-
children: [
|
|
10578
|
-
hasErrors ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10579
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10580
|
-
"button",
|
|
10581
|
-
{
|
|
10582
|
-
type: "button",
|
|
10583
|
-
"aria-label": `Show ${errors.length} validation ${errors.length === 1 ? "issue" : "issues"}`,
|
|
10584
|
-
onClick: () => onOpenChange?.(true),
|
|
10585
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10586
|
-
children: /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5" })
|
|
10587
|
-
}
|
|
10588
|
-
) }),
|
|
10589
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", align: "end", children: /* @__PURE__ */ jsxs("ul", { className: "flex flex-col gap-0.5", children: [
|
|
10590
|
-
errors.slice(0, 4).map((err, i) => /* @__PURE__ */ jsx("li", { children: err }, i)),
|
|
10591
|
-
errors.length > 4 ? /* @__PURE__ */ jsxs("li", { className: "text-muted-foreground", children: [
|
|
10592
|
-
"and ",
|
|
10593
|
-
errors.length - 4,
|
|
10594
|
-
" more"
|
|
10595
|
-
] }) : null
|
|
10596
|
-
] }) })
|
|
10597
|
-
] }) : null,
|
|
10598
|
-
onReorder && typeof index === "number" && typeof total === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10599
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10600
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10601
|
-
"button",
|
|
10602
|
-
{
|
|
10603
|
-
type: "button",
|
|
10604
|
-
"aria-label": "Move block up",
|
|
10605
|
-
disabled: index === 0,
|
|
10606
|
-
onClick: () => onReorder(builderBlock.id, index - 1),
|
|
10607
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
|
|
10608
|
-
children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5" })
|
|
10609
|
-
}
|
|
10610
|
-
) }),
|
|
10611
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Move up" })
|
|
10612
|
-
] }),
|
|
10613
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10614
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10615
|
-
"button",
|
|
10616
|
-
{
|
|
10617
|
-
type: "button",
|
|
10618
|
-
"aria-label": "Move block down",
|
|
10619
|
-
disabled: index >= total - 1,
|
|
10620
|
-
onClick: () => onReorder(builderBlock.id, index + 1),
|
|
10621
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
|
|
10622
|
-
children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-3.5 w-3.5" })
|
|
10623
|
-
}
|
|
10624
|
-
) }),
|
|
10625
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Move down" })
|
|
10626
|
-
] })
|
|
10627
|
-
] }) : null,
|
|
10628
|
-
/* @__PURE__ */ jsx(BlockActionButtons, { actions: blockActions, position, variant: "toolbar" }),
|
|
10629
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10630
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10631
|
-
"button",
|
|
10632
|
-
{
|
|
10633
|
-
type: "button",
|
|
10634
|
-
"aria-label": "Edit block",
|
|
10635
|
-
onClick: () => {
|
|
10636
|
-
if (isRichText) {
|
|
10637
|
-
setInlineEditing(true);
|
|
10638
|
-
} else {
|
|
10639
|
-
onOpenChange?.(true);
|
|
10640
|
-
}
|
|
10641
|
-
},
|
|
10642
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10643
|
-
children: /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5" })
|
|
10644
|
-
}
|
|
10645
|
-
) }),
|
|
10646
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Edit" })
|
|
10647
|
-
] }),
|
|
10648
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10649
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10650
|
-
"button",
|
|
10651
|
-
{
|
|
10652
|
-
type: "button",
|
|
10653
|
-
"aria-label": "Duplicate block",
|
|
10654
|
-
onClick: () => onDuplicate(builderBlock.id),
|
|
10655
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10656
|
-
children: /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" })
|
|
10657
|
-
}
|
|
10658
|
-
) }),
|
|
10659
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Duplicate" })
|
|
10660
|
-
] }),
|
|
10661
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
10662
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10663
|
-
"button",
|
|
10664
|
-
{
|
|
10665
|
-
type: "button",
|
|
10666
|
-
"aria-label": "Delete block",
|
|
10667
|
-
onClick: () => onDelete(builderBlock.id),
|
|
10668
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10669
|
-
children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" })
|
|
10670
|
-
}
|
|
10671
|
-
) }),
|
|
10672
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: "Delete" })
|
|
10673
|
-
] })
|
|
10674
|
-
]
|
|
10675
|
-
}
|
|
10676
|
-
)
|
|
10677
|
-
] }),
|
|
10799
|
+
adornment != null && adornment !== false ? /* @__PURE__ */ jsx("div", { className: "shrink-0", children: adornment }) : null
|
|
10800
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10801
|
+
body,
|
|
10802
|
+
hoverChrome
|
|
10803
|
+
] }) }),
|
|
10678
10804
|
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center justify-between gap-2 rounded-md border border-dashed bg-muted/40 px-2 py-1 md:hidden", children: [
|
|
10679
10805
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[11px] font-medium text-muted-foreground", children: BLOCK_TYPE_LABELS[builderBlock.block.type] }),
|
|
10680
10806
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
@@ -10771,7 +10897,8 @@ function ContainerRow({
|
|
|
10771
10897
|
index,
|
|
10772
10898
|
total,
|
|
10773
10899
|
isPaletteDrag = false,
|
|
10774
|
-
blockActions
|
|
10900
|
+
blockActions,
|
|
10901
|
+
renderBlockAdornment
|
|
10775
10902
|
}) {
|
|
10776
10903
|
const { id } = builderBlock;
|
|
10777
10904
|
const block = builderBlock.block;
|
|
@@ -10785,144 +10912,156 @@ function ContainerRow({
|
|
|
10785
10912
|
const style = { transform: CSS.Transform.toString(transform), transition };
|
|
10786
10913
|
const icon = block.icon && "image_url" in block.icon ? block.icon.image_url : void 0;
|
|
10787
10914
|
const position = typeof index === "number" ? { index, childIndex: null } : void 0;
|
|
10788
|
-
|
|
10915
|
+
const adornment = position && renderBlockAdornment?.(position);
|
|
10916
|
+
const card = /* @__PURE__ */ jsxs(
|
|
10789
10917
|
"div",
|
|
10790
10918
|
{
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10919
|
+
className: cn(
|
|
10920
|
+
"overflow-hidden rounded-md border bg-card transition-shadow",
|
|
10921
|
+
hasErrors ? "border-destructive/60" : "border-border"
|
|
10922
|
+
),
|
|
10795
10923
|
children: [
|
|
10796
|
-
/* @__PURE__ */ jsxs(
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
tabIndex: 0,
|
|
10810
|
-
"aria-label": "Edit container",
|
|
10811
|
-
...sortableA11yAttrs,
|
|
10812
|
-
...listeners,
|
|
10813
|
-
onKeyDown: (e) => {
|
|
10814
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
10815
|
-
e.preventDefault();
|
|
10816
|
-
onOpenBlockChange?.(!isOpen ? id : null);
|
|
10817
|
-
}
|
|
10818
|
-
},
|
|
10819
|
-
className: "flex w-full cursor-grab items-center gap-2 border-b bg-muted/40 px-3 py-2 text-left transition-colors hover:bg-muted active:cursor-grabbing",
|
|
10820
|
-
children: [
|
|
10821
|
-
icon ? /* @__PURE__ */ jsx("img", { src: icon, alt: "", "aria-hidden": "true", className: "h-5 w-5 shrink-0 rounded object-cover" }) : null,
|
|
10822
|
-
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
10823
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-semibold text-foreground", children: containerTitleText(block) || "Container" }),
|
|
10824
|
-
block.subtitle?.text ? /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-muted-foreground", children: block.subtitle.text }) : null
|
|
10825
|
-
] }),
|
|
10826
|
-
/* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: "Container" })
|
|
10827
|
-
]
|
|
10828
|
-
}
|
|
10829
|
-
) }),
|
|
10830
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[min(32rem,calc(100vw-1.5rem))] sm:w-[32rem]", align: "start", children: /* @__PURE__ */ jsx(
|
|
10831
|
-
BlockEditor,
|
|
10832
|
-
{
|
|
10833
|
-
block,
|
|
10834
|
-
errors,
|
|
10835
|
-
onChange: (next) => onUpdate(id, next),
|
|
10836
|
-
onDone: () => onOpenBlockChange?.(null)
|
|
10837
|
-
}
|
|
10838
|
-
) })
|
|
10839
|
-
] }),
|
|
10840
|
-
/* @__PURE__ */ jsx(
|
|
10841
|
-
"div",
|
|
10842
|
-
{
|
|
10843
|
-
ref: setBodyRef,
|
|
10844
|
-
className: cn(
|
|
10845
|
-
"flex flex-col gap-2 p-3 transition-colors",
|
|
10846
|
-
isPaletteDrag && "outline-2 -outline-offset-2 outline-dashed outline-primary/40",
|
|
10847
|
-
isPaletteDrag && isBodyOver && "bg-primary/5"
|
|
10848
|
-
),
|
|
10849
|
-
children: children.length === 0 ? /* @__PURE__ */ jsx(
|
|
10850
|
-
"div",
|
|
10851
|
-
{
|
|
10852
|
-
className: cn(
|
|
10853
|
-
"flex items-center justify-center rounded-md border border-dashed px-3 py-6 text-center text-[11px] transition-colors",
|
|
10854
|
-
isBodyOver ? "border-primary/60 text-primary" : "border-border text-muted-foreground"
|
|
10855
|
-
),
|
|
10856
|
-
children: "Drag blocks here"
|
|
10857
|
-
}
|
|
10858
|
-
) : /* @__PURE__ */ jsxs(SortableContext, { items: children.map((c) => c.id), strategy: verticalListSortingStrategy, children: [
|
|
10859
|
-
children.map((child, idx) => /* @__PURE__ */ jsx(
|
|
10860
|
-
BlockRow,
|
|
10861
|
-
{
|
|
10862
|
-
builderBlock: child,
|
|
10863
|
-
previewHooks,
|
|
10864
|
-
previewTheme,
|
|
10865
|
-
errors: errorsByBlockId?.get(child.id),
|
|
10866
|
-
isOpen: openBlockId === child.id,
|
|
10867
|
-
onOpenChange: (open) => onOpenBlockChange?.(open ? child.id : null),
|
|
10868
|
-
onUpdate,
|
|
10869
|
-
onDuplicate,
|
|
10870
|
-
onDelete,
|
|
10871
|
-
index: idx,
|
|
10872
|
-
total: children.length,
|
|
10873
|
-
onReorder,
|
|
10874
|
-
isPaletteDrag,
|
|
10875
|
-
position: typeof index === "number" ? { index, childIndex: idx } : void 0,
|
|
10876
|
-
blockActions
|
|
10877
|
-
},
|
|
10878
|
-
child.id
|
|
10879
|
-
)),
|
|
10880
|
-
isPaletteDrag && isBodyOver ? /* @__PURE__ */ jsx(DropIndicator, {}) : null
|
|
10881
|
-
] })
|
|
10924
|
+
/* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: (open) => onOpenBlockChange?.(open ? id : null), children: [
|
|
10925
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
10926
|
+
"div",
|
|
10927
|
+
{
|
|
10928
|
+
role: "button",
|
|
10929
|
+
tabIndex: 0,
|
|
10930
|
+
"aria-label": "Edit container",
|
|
10931
|
+
...sortableA11yAttrs,
|
|
10932
|
+
...listeners,
|
|
10933
|
+
onKeyDown: (e) => {
|
|
10934
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
10935
|
+
e.preventDefault();
|
|
10936
|
+
onOpenBlockChange?.(!isOpen ? id : null);
|
|
10882
10937
|
}
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10938
|
+
},
|
|
10939
|
+
className: "flex w-full cursor-grab items-center gap-2 border-b bg-muted/40 px-3 py-2 text-left transition-colors hover:bg-muted active:cursor-grabbing",
|
|
10940
|
+
children: [
|
|
10941
|
+
icon ? /* @__PURE__ */ jsx("img", { src: icon, alt: "", "aria-hidden": "true", className: "h-5 w-5 shrink-0 rounded object-cover" }) : null,
|
|
10942
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
10943
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-semibold text-foreground", children: containerTitleText(block) || "Container" }),
|
|
10944
|
+
block.subtitle?.text ? /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-muted-foreground", children: block.subtitle.text }) : null
|
|
10945
|
+
] }),
|
|
10946
|
+
/* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: "Container" })
|
|
10947
|
+
]
|
|
10948
|
+
}
|
|
10949
|
+
) }),
|
|
10950
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[min(32rem,calc(100vw-1.5rem))] sm:w-[32rem]", align: "start", children: /* @__PURE__ */ jsx(
|
|
10951
|
+
BlockEditor,
|
|
10952
|
+
{
|
|
10953
|
+
block,
|
|
10954
|
+
errors,
|
|
10955
|
+
onChange: (next) => onUpdate(id, next),
|
|
10956
|
+
onDone: () => onOpenBlockChange?.(null)
|
|
10957
|
+
}
|
|
10958
|
+
) })
|
|
10959
|
+
] }),
|
|
10960
|
+
/* @__PURE__ */ jsx(
|
|
10888
10961
|
"div",
|
|
10889
10962
|
{
|
|
10963
|
+
ref: setBodyRef,
|
|
10890
10964
|
className: cn(
|
|
10891
|
-
"
|
|
10892
|
-
|
|
10965
|
+
"flex flex-col gap-2 p-3 transition-colors",
|
|
10966
|
+
isPaletteDrag && "outline-2 -outline-offset-2 outline-dashed outline-primary/40",
|
|
10967
|
+
isPaletteDrag && isBodyOver && "bg-primary/5"
|
|
10893
10968
|
),
|
|
10894
|
-
children:
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10969
|
+
children: children.length === 0 ? /* @__PURE__ */ jsx(
|
|
10970
|
+
"div",
|
|
10971
|
+
{
|
|
10972
|
+
className: cn(
|
|
10973
|
+
"flex items-center justify-center rounded-md border border-dashed px-3 py-6 text-center text-[11px] transition-colors",
|
|
10974
|
+
isBodyOver ? "border-primary/60 text-primary" : "border-border text-muted-foreground"
|
|
10975
|
+
),
|
|
10976
|
+
children: "Drag blocks here"
|
|
10977
|
+
}
|
|
10978
|
+
) : /* @__PURE__ */ jsxs(SortableContext, { items: children.map((c) => c.id), strategy: verticalListSortingStrategy, children: [
|
|
10979
|
+
children.map((child, idx) => /* @__PURE__ */ jsx(
|
|
10980
|
+
BlockRow,
|
|
10981
|
+
{
|
|
10982
|
+
builderBlock: child,
|
|
10983
|
+
previewHooks,
|
|
10984
|
+
previewTheme,
|
|
10985
|
+
errors: errorsByBlockId?.get(child.id),
|
|
10986
|
+
isOpen: openBlockId === child.id,
|
|
10987
|
+
onOpenChange: (open) => onOpenBlockChange?.(open ? child.id : null),
|
|
10988
|
+
onUpdate,
|
|
10989
|
+
onDuplicate,
|
|
10990
|
+
onDelete,
|
|
10991
|
+
index: idx,
|
|
10992
|
+
total: children.length,
|
|
10993
|
+
onReorder,
|
|
10994
|
+
isPaletteDrag,
|
|
10995
|
+
position: typeof index === "number" ? { index, childIndex: idx } : void 0,
|
|
10996
|
+
blockActions,
|
|
10997
|
+
renderBlockAdornment
|
|
10998
|
+
},
|
|
10999
|
+
child.id
|
|
11000
|
+
)),
|
|
11001
|
+
isPaletteDrag && isBodyOver ? /* @__PURE__ */ jsx(DropIndicator, {}) : null
|
|
11002
|
+
] })
|
|
10924
11003
|
}
|
|
10925
|
-
)
|
|
11004
|
+
)
|
|
11005
|
+
]
|
|
11006
|
+
}
|
|
11007
|
+
);
|
|
11008
|
+
const toolbar = /* @__PURE__ */ jsxs(
|
|
11009
|
+
"div",
|
|
11010
|
+
{
|
|
11011
|
+
className: cn(
|
|
11012
|
+
"absolute -top-3 right-2 z-10 hidden items-center gap-0.5 rounded-md border bg-background p-0.5 shadow-sm transition-opacity md:flex",
|
|
11013
|
+
hasErrors ? "opacity-100" : "opacity-0 group-hover/container:opacity-100 group-has-[:focus-visible]/container:opacity-100"
|
|
11014
|
+
),
|
|
11015
|
+
children: [
|
|
11016
|
+
hasErrors ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
11017
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
11018
|
+
"button",
|
|
11019
|
+
{
|
|
11020
|
+
type: "button",
|
|
11021
|
+
"aria-label": `Show ${errors.length} validation ${errors.length === 1 ? "issue" : "issues"}`,
|
|
11022
|
+
onClick: () => onOpenBlockChange?.(id),
|
|
11023
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
11024
|
+
children: /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5" })
|
|
11025
|
+
}
|
|
11026
|
+
) }),
|
|
11027
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", align: "end", children: /* @__PURE__ */ jsxs("ul", { className: "flex flex-col gap-0.5", children: [
|
|
11028
|
+
errors.slice(0, 4).map((err, i) => /* @__PURE__ */ jsx("li", { children: err }, i)),
|
|
11029
|
+
errors.length > 4 ? /* @__PURE__ */ jsxs("li", { className: "text-muted-foreground", children: [
|
|
11030
|
+
"and ",
|
|
11031
|
+
errors.length - 4,
|
|
11032
|
+
" more"
|
|
11033
|
+
] }) : null
|
|
11034
|
+
] }) })
|
|
11035
|
+
] }) : null,
|
|
11036
|
+
onReorder && typeof index === "number" && typeof total === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11037
|
+
/* @__PURE__ */ jsx(ToolbarButton2, { label: "Move up", disabled: index === 0, onClick: () => onReorder(id, index - 1), children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5" }) }),
|
|
11038
|
+
/* @__PURE__ */ jsx(ToolbarButton2, { label: "Move down", disabled: index >= total - 1, onClick: () => onReorder(id, index + 1), children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-3.5 w-3.5" }) })
|
|
11039
|
+
] }) : null,
|
|
11040
|
+
/* @__PURE__ */ jsx(BlockActionButtons, { actions: blockActions, position, variant: "toolbar" }),
|
|
11041
|
+
/* @__PURE__ */ jsx(ToolbarButton2, { label: "Edit", onClick: () => onOpenBlockChange?.(id), children: /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5" }) }),
|
|
11042
|
+
/* @__PURE__ */ jsx(ToolbarButton2, { label: "Duplicate", onClick: () => onDuplicate(id), children: /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" }) }),
|
|
11043
|
+
/* @__PURE__ */ jsx(ToolbarButton2, { label: "Delete", destructive: true, onClick: () => onDelete(id), children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" }) })
|
|
11044
|
+
]
|
|
11045
|
+
}
|
|
11046
|
+
);
|
|
11047
|
+
return /* @__PURE__ */ jsxs(
|
|
11048
|
+
"div",
|
|
11049
|
+
{
|
|
11050
|
+
ref: setNodeRef,
|
|
11051
|
+
style,
|
|
11052
|
+
"data-bk-block-index": index,
|
|
11053
|
+
className: cn("group/container relative mb-2 last:mb-0 hover:z-10", isDragging && "opacity-40"),
|
|
11054
|
+
children: [
|
|
11055
|
+
renderBlockAdornment ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
11056
|
+
/* @__PURE__ */ jsxs("div", { className: "relative min-w-0 flex-1", children: [
|
|
11057
|
+
card,
|
|
11058
|
+
toolbar
|
|
11059
|
+
] }),
|
|
11060
|
+
adornment != null && adornment !== false ? /* @__PURE__ */ jsx("div", { className: "shrink-0", children: adornment }) : null
|
|
11061
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11062
|
+
card,
|
|
11063
|
+
toolbar
|
|
11064
|
+
] }),
|
|
10926
11065
|
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center justify-between gap-2 rounded-md border border-dashed bg-muted/40 px-2 py-1 md:hidden", children: [
|
|
10927
11066
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[11px] font-medium text-muted-foreground", children: "Container" }),
|
|
10928
11067
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
@@ -11009,7 +11148,8 @@ function Surface({
|
|
|
11009
11148
|
onReorder,
|
|
11010
11149
|
isPaletteDrag = false,
|
|
11011
11150
|
onOpenPalette,
|
|
11012
|
-
blockActions
|
|
11151
|
+
blockActions,
|
|
11152
|
+
renderBlockAdornment
|
|
11013
11153
|
}) {
|
|
11014
11154
|
const { setNodeRef, isOver } = useDroppable({ id: SURFACE_DROPPABLE_ID });
|
|
11015
11155
|
const isDark = previewTheme === "dark";
|
|
@@ -11042,7 +11182,8 @@ function Surface({
|
|
|
11042
11182
|
total: blocks.length,
|
|
11043
11183
|
onReorder,
|
|
11044
11184
|
isPaletteDrag,
|
|
11045
|
-
blockActions
|
|
11185
|
+
blockActions,
|
|
11186
|
+
renderBlockAdornment
|
|
11046
11187
|
},
|
|
11047
11188
|
block.id
|
|
11048
11189
|
) : /* @__PURE__ */ jsx(
|
|
@@ -11062,7 +11203,8 @@ function Surface({
|
|
|
11062
11203
|
onReorder,
|
|
11063
11204
|
isPaletteDrag,
|
|
11064
11205
|
position: { index: idx, childIndex: null },
|
|
11065
|
-
blockActions
|
|
11206
|
+
blockActions,
|
|
11207
|
+
renderBlockAdornment
|
|
11066
11208
|
},
|
|
11067
11209
|
block.id
|
|
11068
11210
|
)
|
|
@@ -11336,6 +11478,7 @@ function Toolbar2({
|
|
|
11336
11478
|
canRedo = false,
|
|
11337
11479
|
onUndo,
|
|
11338
11480
|
onRedo,
|
|
11481
|
+
undoRedoShortcuts = true,
|
|
11339
11482
|
onClear,
|
|
11340
11483
|
onOpenJson,
|
|
11341
11484
|
onOpenIssues,
|
|
@@ -11369,6 +11512,7 @@ function Toolbar2({
|
|
|
11369
11512
|
const showSurfaceControl = surfaceOptions.length > 1;
|
|
11370
11513
|
const docsHref = docsLink === false ? null : docsLink?.href ?? DEFAULT_DOCS_HREF;
|
|
11371
11514
|
const docsLabel = docsLink === false ? null : docsLink?.label ?? DEFAULT_DOCS_LABEL;
|
|
11515
|
+
const isApple = useIsApplePlatform();
|
|
11372
11516
|
const [surfaceMenuOpen, setSurfaceMenuOpen] = useState(false);
|
|
11373
11517
|
const [themeMenuOpen, setThemeMenuOpen] = useState(false);
|
|
11374
11518
|
const [sendMenuOpen, setSendMenuOpen] = useState(false);
|
|
@@ -11459,7 +11603,8 @@ function Toolbar2({
|
|
|
11459
11603
|
onClick: onUndo,
|
|
11460
11604
|
disabled: !canUndo,
|
|
11461
11605
|
"aria-label": "Undo",
|
|
11462
|
-
|
|
11606
|
+
"aria-keyshortcuts": undoRedoShortcuts ? "Control+Z Meta+Z" : void 0,
|
|
11607
|
+
title: undoRedoShortcuts ? `Undo (${isApple ? "\u2318Z" : "Ctrl+Z"})` : "Undo",
|
|
11463
11608
|
className: "px-2",
|
|
11464
11609
|
children: /* @__PURE__ */ jsx(Undo2, { className: "h-3.5 w-3.5" })
|
|
11465
11610
|
}
|
|
@@ -11473,7 +11618,8 @@ function Toolbar2({
|
|
|
11473
11618
|
onClick: onRedo,
|
|
11474
11619
|
disabled: !canRedo,
|
|
11475
11620
|
"aria-label": "Redo",
|
|
11476
|
-
|
|
11621
|
+
"aria-keyshortcuts": undoRedoShortcuts ? "Control+Shift+Z Meta+Shift+Z Control+Y" : void 0,
|
|
11622
|
+
title: undoRedoShortcuts ? `Redo (${isApple ? "\u21E7\u2318Z" : "Ctrl+Shift+Z"})` : "Redo",
|
|
11477
11623
|
className: "px-2",
|
|
11478
11624
|
children: /* @__PURE__ */ jsx(Redo2, { className: "h-3.5 w-3.5" })
|
|
11479
11625
|
}
|
|
@@ -11821,6 +11967,8 @@ function BlockKitchen(props) {
|
|
|
11821
11967
|
onValidationChange,
|
|
11822
11968
|
previewHooks,
|
|
11823
11969
|
blockActions,
|
|
11970
|
+
renderBlockAdornment,
|
|
11971
|
+
blockEditors,
|
|
11824
11972
|
customEmojis,
|
|
11825
11973
|
mentions,
|
|
11826
11974
|
loadChannels,
|
|
@@ -11846,7 +11994,8 @@ function BlockKitchen(props) {
|
|
|
11846
11994
|
previewTheme: controlledPreviewTheme,
|
|
11847
11995
|
sendButtonLabel,
|
|
11848
11996
|
confirmSendLabel,
|
|
11849
|
-
theme
|
|
11997
|
+
theme,
|
|
11998
|
+
undoRedoShortcuts = true
|
|
11850
11999
|
// Widen the all-or-nothing union so the branch-specific props
|
|
11851
12000
|
// destructure as independent optionals: untyped JS consumers can still
|
|
11852
12001
|
// pass partial wiring (handled by the runtime guards below), and the
|
|
@@ -12026,7 +12175,7 @@ function BlockKitchen(props) {
|
|
|
12026
12175
|
const variantId = parsePaletteDragId(active.id);
|
|
12027
12176
|
if (variantId) {
|
|
12028
12177
|
const variant = variantById.get(variantId);
|
|
12029
|
-
if (!variant) {
|
|
12178
|
+
if (!variant || variant.locked) {
|
|
12030
12179
|
return;
|
|
12031
12180
|
}
|
|
12032
12181
|
if (target.kind === "container") {
|
|
@@ -12045,30 +12194,47 @@ function BlockKitchen(props) {
|
|
|
12045
12194
|
const handleDragCancel = useCallback(() => {
|
|
12046
12195
|
setActivePaletteVariantId(null);
|
|
12047
12196
|
}, []);
|
|
12048
|
-
const
|
|
12197
|
+
const runHistoryShortcut = useCallback(
|
|
12049
12198
|
(event) => {
|
|
12050
|
-
|
|
12199
|
+
const action = historyShortcutOf(event);
|
|
12200
|
+
if (!undoRedoShortcuts || !action || event.defaultPrevented || isTextEditingTarget(event.target)) {
|
|
12051
12201
|
return;
|
|
12052
12202
|
}
|
|
12053
|
-
|
|
12054
|
-
const isUndo = key === "z" && !event.shiftKey;
|
|
12055
|
-
const isRedo = key === "y" || key === "z" && event.shiftKey;
|
|
12056
|
-
if (!isUndo && !isRedo) {
|
|
12057
|
-
return;
|
|
12058
|
-
}
|
|
12059
|
-
const target = event.target;
|
|
12060
|
-
if (target && (target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName))) {
|
|
12203
|
+
if (action === "undo" ? !canUndo : !canRedo) {
|
|
12061
12204
|
return;
|
|
12062
12205
|
}
|
|
12063
12206
|
event.preventDefault();
|
|
12064
|
-
if (
|
|
12065
|
-
if (canRedo) redo();
|
|
12066
|
-
} else if (canUndo) {
|
|
12207
|
+
if (action === "undo") {
|
|
12067
12208
|
undo();
|
|
12209
|
+
} else {
|
|
12210
|
+
redo();
|
|
12068
12211
|
}
|
|
12069
12212
|
},
|
|
12070
|
-
[canRedo, canUndo, redo, undo]
|
|
12213
|
+
[canRedo, canUndo, redo, undo, undoRedoShortcuts]
|
|
12071
12214
|
);
|
|
12215
|
+
const rootRef = useRef(null);
|
|
12216
|
+
const lastClickInBuilderRef = useRef(false);
|
|
12217
|
+
useEffect(() => {
|
|
12218
|
+
if (!undoRedoShortcuts) {
|
|
12219
|
+
return;
|
|
12220
|
+
}
|
|
12221
|
+
const onPointerDown = () => {
|
|
12222
|
+
lastClickInBuilderRef.current = false;
|
|
12223
|
+
};
|
|
12224
|
+
const onKeyDown = (event) => {
|
|
12225
|
+
const root = rootRef.current;
|
|
12226
|
+
const focusAroundBuilder = event.target instanceof Node && root !== null && event.target.contains(root);
|
|
12227
|
+
if (focusAroundBuilder && lastClickInBuilderRef.current) {
|
|
12228
|
+
runHistoryShortcut(event);
|
|
12229
|
+
}
|
|
12230
|
+
};
|
|
12231
|
+
window.addEventListener("pointerdown", onPointerDown, true);
|
|
12232
|
+
window.addEventListener("keydown", onKeyDown);
|
|
12233
|
+
return () => {
|
|
12234
|
+
window.removeEventListener("pointerdown", onPointerDown, true);
|
|
12235
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
12236
|
+
};
|
|
12237
|
+
}, [runHistoryShortcut, undoRedoShortcuts]);
|
|
12072
12238
|
const activePaletteVariant = activePaletteVariantId ? variantById.get(activePaletteVariantId) : null;
|
|
12073
12239
|
const blockPayloads = blocks.map((b) => b.block);
|
|
12074
12240
|
return /* @__PURE__ */ jsx(BrandThemeScope, { theme, children: /* @__PURE__ */ jsx(CustomEmojiProvider, { customEmojis, children: /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 200, children: /* @__PURE__ */ jsxs(
|
|
@@ -12083,8 +12249,12 @@ function BlockKitchen(props) {
|
|
|
12083
12249
|
/* @__PURE__ */ jsxs(
|
|
12084
12250
|
"div",
|
|
12085
12251
|
{
|
|
12252
|
+
ref: rootRef,
|
|
12086
12253
|
className: "bk-root flex h-full max-h-[var(--bk-max-height,100svh)] w-full flex-col overflow-hidden rounded-md border bg-background text-foreground",
|
|
12087
|
-
onKeyDown:
|
|
12254
|
+
onKeyDown: runHistoryShortcut,
|
|
12255
|
+
onPointerDownCapture: () => {
|
|
12256
|
+
lastClickInBuilderRef.current = true;
|
|
12257
|
+
},
|
|
12088
12258
|
children: [
|
|
12089
12259
|
/* @__PURE__ */ jsx(
|
|
12090
12260
|
Toolbar2,
|
|
@@ -12093,6 +12263,7 @@ function BlockKitchen(props) {
|
|
|
12093
12263
|
canRedo,
|
|
12094
12264
|
onUndo: undo,
|
|
12095
12265
|
onRedo: redo,
|
|
12266
|
+
undoRedoShortcuts,
|
|
12096
12267
|
onClear: () => replaceAll([]),
|
|
12097
12268
|
onOpenJson: () => setJsonOpen(true),
|
|
12098
12269
|
onOpenIssues: () => setIssuesOpen(true),
|
|
@@ -12183,7 +12354,7 @@ function BlockKitchen(props) {
|
|
|
12183
12354
|
}
|
|
12184
12355
|
)
|
|
12185
12356
|
] }),
|
|
12186
|
-
/* @__PURE__ */ jsx(MentionsProvider, { mentions, children: /* @__PURE__ */ jsx(
|
|
12357
|
+
/* @__PURE__ */ jsx(MentionsProvider, { mentions, children: /* @__PURE__ */ jsx(BlockEditorsProvider, { blockEditors, children: /* @__PURE__ */ jsx(
|
|
12187
12358
|
Surface,
|
|
12188
12359
|
{
|
|
12189
12360
|
blocks,
|
|
@@ -12202,9 +12373,10 @@ function BlockKitchen(props) {
|
|
|
12202
12373
|
onReorder: reorderBlock,
|
|
12203
12374
|
isPaletteDrag: activePaletteVariant !== null,
|
|
12204
12375
|
onOpenPalette: () => setPaletteOpen(true),
|
|
12205
|
-
blockActions
|
|
12376
|
+
blockActions,
|
|
12377
|
+
renderBlockAdornment
|
|
12206
12378
|
}
|
|
12207
|
-
) })
|
|
12379
|
+
) }) })
|
|
12208
12380
|
] })
|
|
12209
12381
|
]
|
|
12210
12382
|
}
|
|
@@ -12235,6 +12407,7 @@ function BlockKitchen(props) {
|
|
|
12235
12407
|
addBlock(block);
|
|
12236
12408
|
setPaletteOpen(false);
|
|
12237
12409
|
},
|
|
12410
|
+
onLockedPicked: () => setPaletteOpen(false),
|
|
12238
12411
|
sections: paletteSections,
|
|
12239
12412
|
mode: paletteMode,
|
|
12240
12413
|
showSearch: showPaletteSearch,
|