docblocks-react-ui 0.9.1 → 0.10.1
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/CHANGELOG.md +73 -0
- package/dist/{Editor-DEHzA7Mt.mjs → Editor-DKO25suc.mjs} +240 -332
- package/dist/{index-DmC2uQ2K.d.mts → index-DzYwo6Px.d.mts} +71 -28
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/mermaid/index.mjs +1 -1
- package/dist/pdf/index.d.mts +1 -1
- package/dist/styles.css +3 -15
- package/package.json +1 -1
|
@@ -3806,10 +3806,6 @@ const INIT_OPTIONS = {
|
|
|
3806
3806
|
access: {
|
|
3807
3807
|
"notPublished": "This document has not been published yet.",
|
|
3808
3808
|
"notPublishedHint": "Readers see the document only after it has been published."
|
|
3809
|
-
},
|
|
3810
|
-
colorPicker: {
|
|
3811
|
-
"aria": "Color picker",
|
|
3812
|
-
"hexAria": "Hex color value"
|
|
3813
3809
|
}
|
|
3814
3810
|
},
|
|
3815
3811
|
database: {
|
|
@@ -3948,7 +3944,8 @@ const INIT_OPTIONS = {
|
|
|
3948
3944
|
"callout": {
|
|
3949
3945
|
"typeAria": "Callout type",
|
|
3950
3946
|
"variant": "{variant} callout",
|
|
3951
|
-
"iconAria": "Callout icon"
|
|
3947
|
+
"iconAria": "Callout icon",
|
|
3948
|
+
"hexAria": "Background hex value"
|
|
3952
3949
|
},
|
|
3953
3950
|
"color": {
|
|
3954
3951
|
"trigger": "Text and background color",
|
|
@@ -4007,7 +4004,7 @@ const INIT_OPTIONS = {
|
|
|
4007
4004
|
"listAddAria": "Add a line to {name}",
|
|
4008
4005
|
"listLineAria": "Line {index} of {name}",
|
|
4009
4006
|
"listLineRemoveAria": "Remove line {index}",
|
|
4010
|
-
"
|
|
4007
|
+
"addTag": "Add a tag",
|
|
4011
4008
|
"addTagAria": "Add a tag",
|
|
4012
4009
|
"uploadCoverAria": "Upload the cover",
|
|
4013
4010
|
"removeCoverAria": "Remove the cover",
|
|
@@ -4073,8 +4070,6 @@ const INIT_OPTIONS = {
|
|
|
4073
4070
|
},
|
|
4074
4071
|
menu: {
|
|
4075
4072
|
"background": "Background",
|
|
4076
|
-
"backgroundSwatch": "Background {color}",
|
|
4077
|
-
"removeBackground": "Remove background",
|
|
4078
4073
|
"insertRight": "Insert right",
|
|
4079
4074
|
"insertLeft": "Insert left",
|
|
4080
4075
|
"insertBelow": "Insert below",
|
|
@@ -4304,10 +4299,6 @@ const INIT_OPTIONS = {
|
|
|
4304
4299
|
access: {
|
|
4305
4300
|
"notPublished": "Документ ещё не опубликован.",
|
|
4306
4301
|
"notPublishedHint": "Читатели увидят документ только после публикации."
|
|
4307
|
-
},
|
|
4308
|
-
colorPicker: {
|
|
4309
|
-
"aria": "Выбор цвета",
|
|
4310
|
-
"hexAria": "Цвет в hex-формате"
|
|
4311
4302
|
}
|
|
4312
4303
|
},
|
|
4313
4304
|
database: {
|
|
@@ -4446,7 +4437,8 @@ const INIT_OPTIONS = {
|
|
|
4446
4437
|
"callout": {
|
|
4447
4438
|
"typeAria": "Тип выноски",
|
|
4448
4439
|
"variant": "Выноска: {variant}",
|
|
4449
|
-
"iconAria": "Иконка выноски"
|
|
4440
|
+
"iconAria": "Иконка выноски",
|
|
4441
|
+
"hexAria": "Цвет фона в hex-формате"
|
|
4450
4442
|
},
|
|
4451
4443
|
"color": {
|
|
4452
4444
|
"trigger": "Цвет текста и фона",
|
|
@@ -4505,7 +4497,7 @@ const INIT_OPTIONS = {
|
|
|
4505
4497
|
"listAddAria": "Добавить строку в {name}",
|
|
4506
4498
|
"listLineAria": "Строка {index} ключа {name}",
|
|
4507
4499
|
"listLineRemoveAria": "Удалить строку {index}",
|
|
4508
|
-
"
|
|
4500
|
+
"addTag": "Добавить тег",
|
|
4509
4501
|
"addTagAria": "Добавить тег",
|
|
4510
4502
|
"uploadCoverAria": "Загрузить обложку",
|
|
4511
4503
|
"removeCoverAria": "Удалить обложку",
|
|
@@ -4571,8 +4563,6 @@ const INIT_OPTIONS = {
|
|
|
4571
4563
|
},
|
|
4572
4564
|
menu: {
|
|
4573
4565
|
"background": "Фон",
|
|
4574
|
-
"backgroundSwatch": "Фон {color}",
|
|
4575
|
-
"removeBackground": "Убрать фон",
|
|
4576
4566
|
"insertRight": "Вставить справа",
|
|
4577
4567
|
"insertLeft": "Вставить слева",
|
|
4578
4568
|
"insertBelow": "Вставить ниже",
|
|
@@ -6490,168 +6480,35 @@ function probeFor(entry) {
|
|
|
6490
6480
|
return el;
|
|
6491
6481
|
}
|
|
6492
6482
|
//#endregion
|
|
6493
|
-
//#region src/shared/ui/
|
|
6483
|
+
//#region src/shared/ui/ColorChip.tsx
|
|
6494
6484
|
/**
|
|
6495
|
-
* The
|
|
6496
|
-
*
|
|
6497
|
-
*
|
|
6498
|
-
*
|
|
6499
|
-
*
|
|
6500
|
-
*
|
|
6501
|
-
*
|
|
6502
|
-
*
|
|
6503
|
-
* own classes merge through `cn` (width, focus background, or padding
|
|
6504
|
-
* overrides win over the size's stand).
|
|
6485
|
+
* The color chip's preview — the trigger's current-color stand, the shared
|
|
6486
|
+
* language over every color trigger (the page's format buttons, the canvas
|
|
6487
|
+
* toolbars, the table's handles). The `fill` mode's square is filled with
|
|
6488
|
+
* the current hex; the `stroke` mode's square is hollow with the current
|
|
6489
|
+
* hex's border (the stroke's preview). The none's stand is the X over the
|
|
6490
|
+
* theme's muted frame. The frame's border reads the canvas chrome's token
|
|
6491
|
+
* over the canvas toolbars and the standard's `--border` elsewhere (the
|
|
6492
|
+
* token's fallback).
|
|
6505
6493
|
*/
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
size: {
|
|
6516
|
-
default: `
|
|
6517
|
-
border-input px-3 py-1 text-base shadow-xs
|
|
6518
|
-
focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40
|
|
6519
|
-
aria-invalid:border-destructive aria-invalid:ring-destructive/20
|
|
6520
|
-
md:text-sm
|
|
6521
|
-
dark:aria-invalid:ring-destructive/40
|
|
6522
|
-
`,
|
|
6523
|
-
sm: `h-8 border-border px-2 py-0.5 text-sm`
|
|
6494
|
+
function ColorChip({ value, mode = "fill", className }) {
|
|
6495
|
+
const none = value === void 0 || value === null || value === "";
|
|
6496
|
+
const stroke = mode === "stroke" && !none;
|
|
6497
|
+
return /* @__PURE__ */ jsx("span", {
|
|
6498
|
+
"data-slot": "docblocks/color-chip",
|
|
6499
|
+
className: cn("relative size-3 shrink-0 rounded-(--docblocks-radius)", className),
|
|
6500
|
+
style: none ? { border: "1px solid var(--docblocks-formatbar-border-color, var(--border, #888))" } : stroke ? { border: `2px solid ${value}` } : {
|
|
6501
|
+
background: value,
|
|
6502
|
+
border: "1px solid var(--docblocks-formatbar-border-color, var(--border, #888))"
|
|
6524
6503
|
},
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
dark:bg-transparent
|
|
6532
|
-
`
|
|
6533
|
-
}
|
|
6534
|
-
},
|
|
6535
|
-
defaultVariants: {
|
|
6536
|
-
size: "default",
|
|
6537
|
-
variant: "default"
|
|
6538
|
-
}
|
|
6539
|
-
});
|
|
6540
|
-
function Input({ className, size, variant, type, ...props }) {
|
|
6541
|
-
return /* @__PURE__ */ jsx("input", {
|
|
6542
|
-
type,
|
|
6543
|
-
"data-slot": "input",
|
|
6544
|
-
className: cn(inputVariants({
|
|
6545
|
-
size,
|
|
6546
|
-
variant,
|
|
6547
|
-
className
|
|
6548
|
-
})),
|
|
6549
|
-
...props
|
|
6550
|
-
});
|
|
6551
|
-
}
|
|
6552
|
-
//#endregion
|
|
6553
|
-
//#region src/shared/ui/ColorPicker.tsx
|
|
6554
|
-
/**
|
|
6555
|
-
* The custom color's picker body (the callout menu's custom swatch opens it
|
|
6556
|
-
* as an inline section): the native `input type="color"` (the live scrub —
|
|
6557
|
-
* no doc write over the scrub) and the hex field (the strict `#rrggbb`).
|
|
6558
|
-
* The doc write stands one `onCommit` per pick (one undo step, one wire
|
|
6559
|
-
* update — the swatch pick's parity): the native dialog's commit (`change`),
|
|
6560
|
-
* the field's valid Enter / blur. An invalid field value resets to the
|
|
6561
|
-
* draft on blur (the picker stands the last valid stand). The close without
|
|
6562
|
-
* an explicit commit (the Esc / the toggle / the menu's dismiss) commits the
|
|
6563
|
-
* last scrubbed value (the picker's unmount commits it); an untouched
|
|
6564
|
-
* picker commits nothing.
|
|
6565
|
-
*/
|
|
6566
|
-
/** The absent value's stand: the native input's neutral default. */
|
|
6567
|
-
const DEFAULT_HEX = "#808080";
|
|
6568
|
-
/** The strict hex field's stand: `#` + six hex digits. */
|
|
6569
|
-
const STRICT_HEX_RE = /^#([0-9a-f]{6})$/i;
|
|
6570
|
-
function ColorPickerInner({ value, onCommit, onClose }) {
|
|
6571
|
-
const { t } = useTranslation("common");
|
|
6572
|
-
const [draft, setDraft] = useState(value ?? DEFAULT_HEX);
|
|
6573
|
-
const [field, setField] = useState(value ?? DEFAULT_HEX);
|
|
6574
|
-
const valueRef = useRef(value);
|
|
6575
|
-
valueRef.current = value;
|
|
6576
|
-
const onCommitRef = useRef(onCommit);
|
|
6577
|
-
onCommitRef.current = onCommit;
|
|
6578
|
-
const onCloseRef = useRef(onClose);
|
|
6579
|
-
onCloseRef.current = onClose;
|
|
6580
|
-
const draftRef = useRef(draft);
|
|
6581
|
-
draftRef.current = draft;
|
|
6582
|
-
const touchedRef = useRef(false);
|
|
6583
|
-
const committedRef = useRef(false);
|
|
6584
|
-
useEffect(() => {
|
|
6585
|
-
return () => {
|
|
6586
|
-
if (!touchedRef.current || committedRef.current) return;
|
|
6587
|
-
const committed = normalizeHex$1(draftRef.current);
|
|
6588
|
-
const current = valueRef.current === null ? null : normalizeHex$1(valueRef.current);
|
|
6589
|
-
if (committed !== null && committed !== current) onCommitRef.current(committed);
|
|
6590
|
-
};
|
|
6591
|
-
}, []);
|
|
6592
|
-
const nativeRef = useRef(null);
|
|
6593
|
-
useEffect(() => {
|
|
6594
|
-
const el = nativeRef.current;
|
|
6595
|
-
if (el === null) return;
|
|
6596
|
-
const onChange = (event) => {
|
|
6597
|
-
committedRef.current = true;
|
|
6598
|
-
const committed = normalizeHex$1(event.target.value);
|
|
6599
|
-
const current = valueRef.current === null ? null : normalizeHex$1(valueRef.current);
|
|
6600
|
-
if (committed !== null && committed !== current) onCommitRef.current(committed);
|
|
6601
|
-
onCloseRef.current();
|
|
6602
|
-
};
|
|
6603
|
-
el.addEventListener("change", onChange);
|
|
6604
|
-
return () => el.removeEventListener("change", onChange);
|
|
6605
|
-
}, []);
|
|
6606
|
-
/** The field's commit gesture (the Enter / the valid blur): write + close. */
|
|
6607
|
-
const commitField = (raw) => {
|
|
6608
|
-
const match = raw.trim().match(STRICT_HEX_RE);
|
|
6609
|
-
if (match === null) return false;
|
|
6610
|
-
committedRef.current = true;
|
|
6611
|
-
const hex = `#${match[1].toLowerCase()}`;
|
|
6612
|
-
setDraft(hex);
|
|
6613
|
-
setField(hex);
|
|
6614
|
-
if (hex !== (valueRef.current === null ? null : normalizeHex$1(valueRef.current))) onCommitRef.current(hex);
|
|
6615
|
-
onCloseRef.current();
|
|
6616
|
-
return true;
|
|
6617
|
-
};
|
|
6618
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
6619
|
-
className: "flex flex-col gap-2",
|
|
6620
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
6621
|
-
ref: nativeRef,
|
|
6622
|
-
type: "color",
|
|
6623
|
-
value: draft,
|
|
6624
|
-
onInput: (event) => {
|
|
6625
|
-
touchedRef.current = true;
|
|
6626
|
-
setDraft(event.currentTarget.value);
|
|
6627
|
-
},
|
|
6628
|
-
"aria-label": t("colorPicker.aria"),
|
|
6629
|
-
className: "h-8 w-8 cursor-pointer rounded-xs border border-(--border) bg-transparent p-0.5"
|
|
6630
|
-
}), /* @__PURE__ */ jsx(Input, {
|
|
6631
|
-
value: field,
|
|
6632
|
-
size: "sm",
|
|
6633
|
-
"aria-label": t("colorPicker.hexAria"),
|
|
6634
|
-
placeholder: "#rrggbb",
|
|
6635
|
-
className: "font-(family-name:--docblocks-mono-font-family)",
|
|
6636
|
-
onChange: (event) => setField(event.target.value),
|
|
6637
|
-
onKeyDown: (event) => {
|
|
6638
|
-
if (event.key === "Enter") {
|
|
6639
|
-
event.preventDefault();
|
|
6640
|
-
commitField(field);
|
|
6641
|
-
}
|
|
6642
|
-
},
|
|
6643
|
-
onBlur: () => {
|
|
6644
|
-
if (!commitField(field)) setField(draft);
|
|
6645
|
-
}
|
|
6646
|
-
})]
|
|
6504
|
+
"aria-hidden": true,
|
|
6505
|
+
children: none && /* @__PURE__ */ jsx(X, {
|
|
6506
|
+
className: "absolute inset-0 m-auto size-2.5 text-muted-foreground",
|
|
6507
|
+
strokeWidth: 2.5,
|
|
6508
|
+
"aria-hidden": true
|
|
6509
|
+
})
|
|
6647
6510
|
});
|
|
6648
6511
|
}
|
|
6649
|
-
/** The palette's i18n scope: the package's instance stands the provider's
|
|
6650
|
-
* seat over the picker (the primitive stands also outside the editor's
|
|
6651
|
-
* scope — the ColorSwatches' parity). */
|
|
6652
|
-
function ColorPicker(props) {
|
|
6653
|
-
return /* @__PURE__ */ jsx(DocblocksI18nProvider, { children: /* @__PURE__ */ jsx(ColorPickerInner, { ...props }) });
|
|
6654
|
-
}
|
|
6655
6512
|
//#endregion
|
|
6656
6513
|
//#region src/shared/ui/ColorSwatches.tsx
|
|
6657
6514
|
/**
|
|
@@ -7443,6 +7300,66 @@ function DropdownMenuSubContent({ className, ...props }) {
|
|
|
7443
7300
|
});
|
|
7444
7301
|
}
|
|
7445
7302
|
//#endregion
|
|
7303
|
+
//#region src/shared/ui/Input.tsx
|
|
7304
|
+
/**
|
|
7305
|
+
* The text input primitive: the standard field control for the editor's
|
|
7306
|
+
* chrome forms. Two sizes: `default` (the standard h-9 field — the header
|
|
7307
|
+
* and the portaled forms; the `--input` token frame + the focus ring) and
|
|
7308
|
+
* `sm` (the compact h-8 grid-control look the database grid, the filter
|
|
7309
|
+
* builder, and the portaled pickers stand — the `--border` token frame,
|
|
7310
|
+
* no ring). Two looks: `default` (the framed field) and `inline` (the
|
|
7311
|
+
* row's flat field — the in-row editor: no frame / the background / the
|
|
7312
|
+
* shadow over the rest, the focus's border stand only). The call site's
|
|
7313
|
+
* own classes merge through `cn` (width, focus background, or padding
|
|
7314
|
+
* overrides win over the size's stand).
|
|
7315
|
+
*/
|
|
7316
|
+
const inputVariants = cva(`
|
|
7317
|
+
h-9 w-full min-w-0 rounded-md border bg-transparent transition-[color,box-shadow] duration-300 outline-none
|
|
7318
|
+
selection:bg-primary selection:text-primary-foreground
|
|
7319
|
+
file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground
|
|
7320
|
+
placeholder:text-muted-foreground
|
|
7321
|
+
disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
|
|
7322
|
+
dark:bg-input/30
|
|
7323
|
+
`, {
|
|
7324
|
+
variants: {
|
|
7325
|
+
size: {
|
|
7326
|
+
default: `
|
|
7327
|
+
border-input px-3 py-1 text-base shadow-xs
|
|
7328
|
+
focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40
|
|
7329
|
+
aria-invalid:border-destructive aria-invalid:ring-destructive/20
|
|
7330
|
+
md:text-sm
|
|
7331
|
+
dark:aria-invalid:ring-destructive/40
|
|
7332
|
+
`,
|
|
7333
|
+
sm: `h-8 border-border px-2 py-0.5 text-sm`
|
|
7334
|
+
},
|
|
7335
|
+
variant: {
|
|
7336
|
+
default: ``,
|
|
7337
|
+
inline: `
|
|
7338
|
+
h-8 border-transparent bg-transparent px-1.5 py-0.5 text-sm shadow-none
|
|
7339
|
+
focus-visible:border-ring focus-visible:ring-0
|
|
7340
|
+
aria-invalid:border-destructive
|
|
7341
|
+
dark:bg-transparent
|
|
7342
|
+
`
|
|
7343
|
+
}
|
|
7344
|
+
},
|
|
7345
|
+
defaultVariants: {
|
|
7346
|
+
size: "default",
|
|
7347
|
+
variant: "default"
|
|
7348
|
+
}
|
|
7349
|
+
});
|
|
7350
|
+
function Input({ className, size, variant, type, ...props }) {
|
|
7351
|
+
return /* @__PURE__ */ jsx("input", {
|
|
7352
|
+
type,
|
|
7353
|
+
"data-slot": "input",
|
|
7354
|
+
className: cn(inputVariants({
|
|
7355
|
+
size,
|
|
7356
|
+
variant,
|
|
7357
|
+
className
|
|
7358
|
+
})),
|
|
7359
|
+
...props
|
|
7360
|
+
});
|
|
7361
|
+
}
|
|
7362
|
+
//#endregion
|
|
7446
7363
|
//#region src/shared/ui/InlineEditInput.tsx
|
|
7447
7364
|
/**
|
|
7448
7365
|
* The inline edit's input (the document meta's inline editors — the
|
|
@@ -20094,6 +20011,7 @@ function FormatToolbar({ rootRef, palette }) {
|
|
|
20094
20011
|
const alignActive = (align) => range.kind === "cross" ? uniformAlignOfRange(doc, range.cross) === align : alignOfBlock(single) === align;
|
|
20095
20012
|
const paletteActive = (value) => range.kind === "cross" ? uniformMarkValueRange(doc, range.cross, target) === value : uniformMarkValue(single, range.from, range.to, target) === value;
|
|
20096
20013
|
const currentMarkValue = range.kind === "cross" ? uniformMarkValueRange(doc, range.cross, target) : uniformMarkValue(single, range.from, range.to, target);
|
|
20014
|
+
const chipValue = currentMarkValue !== null && currentMarkValue !== "mixed" ? currentMarkValue : null;
|
|
20097
20015
|
const listValue = block !== void 0 && block.type === "list-item" ? block.attrs.list : block !== void 0 && block.type === "paragraph" ? "paragraph" : block !== void 0 && block.type === "quote" ? "quote" : "";
|
|
20098
20016
|
const toggleMarkAt = (mark) => () => onToggleMark(mark);
|
|
20099
20017
|
const alignAt = (align) => () => onAlign(align);
|
|
@@ -20190,7 +20108,10 @@ function FormatToolbar({ rootRef, palette }) {
|
|
|
20190
20108
|
title: t("formatToolbar.color.trigger"),
|
|
20191
20109
|
"aria-label": t("formatToolbar.color.trigger"),
|
|
20192
20110
|
className: "data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
20193
|
-
children: /* @__PURE__ */
|
|
20111
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
20112
|
+
className: "flex items-center gap-1",
|
|
20113
|
+
children: [/* @__PURE__ */ jsx(Baseline, { className: "size-4" }), /* @__PURE__ */ jsx(ColorChip, { value: chipValue })]
|
|
20114
|
+
})
|
|
20194
20115
|
})
|
|
20195
20116
|
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
20196
20117
|
align: "start",
|
|
@@ -20299,29 +20220,27 @@ function calloutIconName(icon, variant) {
|
|
|
20299
20220
|
/**
|
|
20300
20221
|
* The callout's management affordance — the marker-zone icon stands a
|
|
20301
20222
|
* button; its click opens the block's management menu (the type presets /
|
|
20302
|
-
* the background palette over the custom
|
|
20303
|
-
*
|
|
20304
|
-
*
|
|
20305
|
-
*
|
|
20306
|
-
*
|
|
20223
|
+
* the background palette over the custom hex / the icon catalog) beside the
|
|
20224
|
+
* icon. The menu manages the block's attrs, not the selection's marks, so
|
|
20225
|
+
* it stands for an empty callout (no text selection needed). The read-only
|
|
20226
|
+
* stands (view / published) render the icon without a button — no pointer
|
|
20227
|
+
* events, the editing-surface parity.
|
|
20307
20228
|
*
|
|
20308
20229
|
* The menu is a non-modal portaled popover: the content's mousedown guard
|
|
20309
20230
|
* keeps the editor's text selection alive over the open (the format
|
|
20310
|
-
* toolbar's menu parity — the guard yields over the
|
|
20311
|
-
*
|
|
20312
|
-
*
|
|
20313
|
-
*
|
|
20314
|
-
*
|
|
20315
|
-
* dismiss) applies the last scrubbed value (the picker's unmount commits
|
|
20316
|
-
* it; the grid's custom swatch carries a non-preset current value as its
|
|
20317
|
-
* own dot).
|
|
20231
|
+
* toolbar's menu parity — the guard yields over the hex's input, its focus
|
|
20232
|
+
* stands the gesture). The pick's stand closes the menu over the color and
|
|
20233
|
+
* the icon's apply (the type preset stays open). The custom's stand is the
|
|
20234
|
+
* rainbow's swatch (the dot over the non-preset current) + the hex's input
|
|
20235
|
+
* (the shared mechanism — the canvas's palette's parity).
|
|
20318
20236
|
*/
|
|
20319
20237
|
function CalloutBlockMenu({ id, block }) {
|
|
20320
20238
|
const { t } = useTranslation("editor");
|
|
20321
20239
|
const { doc, viewMode } = useEditorContext();
|
|
20322
20240
|
const palette = useFormatPalette();
|
|
20323
20241
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
20324
|
-
const [
|
|
20242
|
+
const [hexDraft, setHexDraft] = useState("");
|
|
20243
|
+
const hexRef = useRef(null);
|
|
20325
20244
|
const variant = block.attrs?.variant ?? "info";
|
|
20326
20245
|
const color = block.attrs?.color ?? null;
|
|
20327
20246
|
const icon = block.attrs?.icon ?? null;
|
|
@@ -20350,6 +20269,16 @@ function CalloutBlockMenu({ id, block }) {
|
|
|
20350
20269
|
if (color === hex) return;
|
|
20351
20270
|
doc.updateBlock(id, { color: hex });
|
|
20352
20271
|
};
|
|
20272
|
+
useEffect(() => {
|
|
20273
|
+
if (!menuOpen) setHexDraft("");
|
|
20274
|
+
}, [menuOpen]);
|
|
20275
|
+
const commitHexDraft = () => {
|
|
20276
|
+
const normalized = normalizeHex$1(hexDraft);
|
|
20277
|
+
if (normalized !== null) {
|
|
20278
|
+
onColorCommit(normalized);
|
|
20279
|
+
setMenuOpen(false);
|
|
20280
|
+
}
|
|
20281
|
+
};
|
|
20353
20282
|
const onIconPick = (name) => {
|
|
20354
20283
|
setMenuOpen(false);
|
|
20355
20284
|
if (icon === name) return;
|
|
@@ -20384,10 +20313,7 @@ function CalloutBlockMenu({ id, block }) {
|
|
|
20384
20313
|
children: /* @__PURE__ */ jsxs(Popover, {
|
|
20385
20314
|
modal: false,
|
|
20386
20315
|
open: menuOpen,
|
|
20387
|
-
onOpenChange:
|
|
20388
|
-
setMenuOpen(next);
|
|
20389
|
-
setPickerOpen(false);
|
|
20390
|
-
},
|
|
20316
|
+
onOpenChange: setMenuOpen,
|
|
20391
20317
|
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
20392
20318
|
asChild: true,
|
|
20393
20319
|
children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -20451,15 +20377,24 @@ function CalloutBlockMenu({ id, block }) {
|
|
|
20451
20377
|
noneActive: color === null,
|
|
20452
20378
|
onSelectNone: onColorNone,
|
|
20453
20379
|
allowCustom: true,
|
|
20454
|
-
onCustom: () =>
|
|
20455
|
-
}),
|
|
20380
|
+
onCustom: () => hexRef.current?.focus()
|
|
20381
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
20382
|
+
ref: hexRef,
|
|
20383
|
+
type: "text",
|
|
20384
|
+
size: "sm",
|
|
20456
20385
|
"data-slot": "docblocks/callout-color-picker",
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
|
|
20386
|
+
"aria-label": t("formatToolbar.callout.hexAria"),
|
|
20387
|
+
className: "mt-2 h-7 font-mono text-xs",
|
|
20388
|
+
placeholder: "#rrggbb",
|
|
20389
|
+
value: hexDraft,
|
|
20390
|
+
onChange: (event) => setHexDraft(event.target.value),
|
|
20391
|
+
onKeyDown: (event) => {
|
|
20392
|
+
if (event.key === "Enter") {
|
|
20393
|
+
event.preventDefault();
|
|
20394
|
+
commitHexDraft();
|
|
20395
|
+
}
|
|
20396
|
+
},
|
|
20397
|
+
onBlur: commitHexDraft
|
|
20463
20398
|
})]
|
|
20464
20399
|
}),
|
|
20465
20400
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -22890,11 +22825,14 @@ function onToolbarBodyMouseDown(event) {
|
|
|
22890
22825
|
/** One color section of the shape toolbar (the fill or the stroke). The
|
|
22891
22826
|
* open state is the toolbar's (the sections are mutually exclusive — the
|
|
22892
22827
|
* non-modal popover does not close on an outside click, so a per-section
|
|
22893
|
-
* state would let both palettes stand open at once).
|
|
22894
|
-
|
|
22828
|
+
* state would let both palettes stand open at once). The custom's stand is
|
|
22829
|
+
* the rainbow's swatch (the dot over the current custom's value) + the hex
|
|
22830
|
+
* input (the shared mechanism — the native dialog's no-stand). */
|
|
22831
|
+
function ColorSection({ target, label, current, mode = "fill", icon, open, onOpenChange, onApply, allowNone = true, slotPrefix = "docblocks/shape" }) {
|
|
22895
22832
|
const { t } = useTranslation("canvas");
|
|
22896
22833
|
const palette = useFormatPalette();
|
|
22897
22834
|
const [draft, setDraft] = useState("");
|
|
22835
|
+
const hexRef = useRef(null);
|
|
22898
22836
|
const none = allowNone && (current === void 0 || current === "none");
|
|
22899
22837
|
const lower = current?.toLowerCase();
|
|
22900
22838
|
useEffect(() => {
|
|
@@ -22935,13 +22873,9 @@ function ColorSection({ target, label, current, chipStyle, icon, open, onOpenCha
|
|
|
22935
22873
|
className: "data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
22936
22874
|
children: /* @__PURE__ */ jsxs("span", {
|
|
22937
22875
|
className: "flex items-center gap-1",
|
|
22938
|
-
children: [icon,
|
|
22939
|
-
|
|
22940
|
-
|
|
22941
|
-
...chipStyle,
|
|
22942
|
-
border: "1px solid var(--docblocks-formatbar-border-color, #888)"
|
|
22943
|
-
},
|
|
22944
|
-
"aria-hidden": true
|
|
22876
|
+
children: [icon, /* @__PURE__ */ jsx(ColorChip, {
|
|
22877
|
+
value: current,
|
|
22878
|
+
mode
|
|
22945
22879
|
})]
|
|
22946
22880
|
})
|
|
22947
22881
|
})
|
|
@@ -22961,8 +22895,11 @@ function ColorSection({ target, label, current, chipStyle, icon, open, onOpenCha
|
|
|
22961
22895
|
label: target,
|
|
22962
22896
|
allowNone,
|
|
22963
22897
|
noneActive: none,
|
|
22964
|
-
onSelectNone: allowNone ? selectNone : void 0
|
|
22898
|
+
onSelectNone: allowNone ? selectNone : void 0,
|
|
22899
|
+
allowCustom: true,
|
|
22900
|
+
onCustom: () => hexRef.current?.focus()
|
|
22965
22901
|
}), /* @__PURE__ */ jsx(Input, {
|
|
22902
|
+
ref: hexRef,
|
|
22966
22903
|
size: "sm",
|
|
22967
22904
|
"data-slot": `${slotPrefix}-${target}-hex`,
|
|
22968
22905
|
"aria-label": t("colorHex", { label }),
|
|
@@ -23124,7 +23061,7 @@ function ConnectorToolbar({ id, variant, strokeColor, strokeWidth, strokeStyle,
|
|
|
23124
23061
|
target: "stroke",
|
|
23125
23062
|
label: t("connector.lineColor"),
|
|
23126
23063
|
current: strokeColor,
|
|
23127
|
-
|
|
23064
|
+
mode: "stroke",
|
|
23128
23065
|
icon: /* @__PURE__ */ jsx(Stroke, { className: "size-4" }),
|
|
23129
23066
|
open: openSection === "stroke",
|
|
23130
23067
|
onOpenChange: openStrokeSection,
|
|
@@ -24653,7 +24590,6 @@ function ShapeTextControls({ slotPrefix, sizeListId, fontFamily, textColor, text
|
|
|
24653
24590
|
target: "text",
|
|
24654
24591
|
label: t("text.color"),
|
|
24655
24592
|
current: textColor,
|
|
24656
|
-
chipStyle: { background: textColor ?? "transparent" },
|
|
24657
24593
|
icon: /* @__PURE__ */ jsx(Palette, { className: "size-4" }),
|
|
24658
24594
|
open: textColorOpen,
|
|
24659
24595
|
onOpenChange: onTextColorOpenChange,
|
|
@@ -24916,7 +24852,6 @@ function ShapeToolbar({ id, fill, stroke, strokeWidth, strokeStyle, variant, tex
|
|
|
24916
24852
|
target: "fill",
|
|
24917
24853
|
label: t("shape.fillColor"),
|
|
24918
24854
|
current: fill,
|
|
24919
|
-
chipStyle: { background: fill ?? "transparent" },
|
|
24920
24855
|
icon: /* @__PURE__ */ jsx(Fill, { className: "size-4" }),
|
|
24921
24856
|
open: openSection === "fill",
|
|
24922
24857
|
onOpenChange: openFillSection,
|
|
@@ -24926,7 +24861,7 @@ function ShapeToolbar({ id, fill, stroke, strokeWidth, strokeStyle, variant, tex
|
|
|
24926
24861
|
target: "stroke",
|
|
24927
24862
|
label: t("shape.strokeColor"),
|
|
24928
24863
|
current: stroke,
|
|
24929
|
-
|
|
24864
|
+
mode: "stroke",
|
|
24930
24865
|
icon: /* @__PURE__ */ jsx(Stroke, { className: "size-4" }),
|
|
24931
24866
|
open: openSection === "stroke",
|
|
24932
24867
|
onOpenChange: openStrokeSection,
|
|
@@ -26665,13 +26600,13 @@ function HandleMenu({ kind, index, visible, left, top, open, onOpenChange, dragg
|
|
|
26665
26600
|
})]
|
|
26666
26601
|
});
|
|
26667
26602
|
}
|
|
26668
|
-
/** The handle's menu items (in the fixed order: the background palette
|
|
26669
|
-
*
|
|
26670
|
-
* items; the edge moves are disabled). The
|
|
26671
|
-
* color is read from the store (a primitive selector: the menu
|
|
26672
|
-
* when the row/column's cells gain or lose the color — a cell
|
|
26673
|
-
* does not touch the table block, so the block's own
|
|
26674
|
-
* fire). */
|
|
26603
|
+
/** The handle's menu items (in the fixed order: the background palette (the
|
|
26604
|
+
* shared's swatches — the none's swatch stands the clear), the insert / move
|
|
26605
|
+
* / duplicate / clear / delete items; the edge moves are disabled). The
|
|
26606
|
+
* background color is read from the store (a primitive selector: the menu
|
|
26607
|
+
* re-renders when the row/column's cells gain or lose the color — a cell
|
|
26608
|
+
* color change does not touch the table block, so the block's own
|
|
26609
|
+
* subscription does not fire). */
|
|
26675
26610
|
function HandleMenuItems({ tableId, kind, index, palette, atStart, atEnd, onAction, onColor }) {
|
|
26676
26611
|
const { t } = useTranslation("table");
|
|
26677
26612
|
const { store } = useEditorContext();
|
|
@@ -26706,35 +26641,21 @@ function HandleMenuItems({ tableId, kind, index, palette, atStart, atEnd, onActi
|
|
|
26706
26641
|
const selectClear = () => onAction("clear");
|
|
26707
26642
|
const selectRemove = () => onAction("remove");
|
|
26708
26643
|
const clearColor = () => onColor(null);
|
|
26709
|
-
const selectSwatch = (swatch) => (event) => {
|
|
26710
|
-
const hex = resolveColorToHex(swatch, event.currentTarget);
|
|
26711
|
-
if (hex !== null) onColor(hex);
|
|
26712
|
-
};
|
|
26713
26644
|
const column = kind === "column";
|
|
26714
26645
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
26715
|
-
/* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { children: [/* @__PURE__ */ jsx("
|
|
26716
|
-
|
|
26717
|
-
|
|
26718
|
-
|
|
26719
|
-
|
|
26720
|
-
|
|
26721
|
-
|
|
26722
|
-
|
|
26723
|
-
|
|
26724
|
-
|
|
26725
|
-
|
|
26726
|
-
|
|
26727
|
-
title: swatch,
|
|
26728
|
-
className: "size-6",
|
|
26729
|
-
style: { background: swatch },
|
|
26730
|
-
onClick: selectSwatch(swatch)
|
|
26731
|
-
}, swatch))
|
|
26646
|
+
/* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { children: [/* @__PURE__ */ jsx(ColorChip, { value: color }), t("menu.background")] }), /* @__PURE__ */ jsx(DropdownMenuSubContent, {
|
|
26647
|
+
"data-slot": "docblocks/table-color-palette",
|
|
26648
|
+
className: "w-auto p-2",
|
|
26649
|
+
children: /* @__PURE__ */ jsx(ColorSwatches, {
|
|
26650
|
+
colors: palette,
|
|
26651
|
+
current: color,
|
|
26652
|
+
onSelect: (hex) => onColor(hex),
|
|
26653
|
+
label: t("menu.background"),
|
|
26654
|
+
allowNone: true,
|
|
26655
|
+
noneActive: color === void 0,
|
|
26656
|
+
onSelectNone: clearColor
|
|
26657
|
+
})
|
|
26732
26658
|
})] }),
|
|
26733
|
-
color !== void 0 && /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
26734
|
-
"data-slot": "docblocks/table-remove-color",
|
|
26735
|
-
onSelect: clearColor,
|
|
26736
|
-
children: t("menu.removeBackground")
|
|
26737
|
-
}),
|
|
26738
26659
|
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
26739
26660
|
onSelect: selectInsertAfter,
|
|
26740
26661
|
children: column ? t("menu.insertRight") : t("menu.insertBelow")
|
|
@@ -27580,6 +27501,7 @@ function TableBlock({ id, block }) {
|
|
|
27580
27501
|
if (kind === "column") doc.setTableColumnColor(id, index, color);
|
|
27581
27502
|
else doc.setTableRowColor(id, rowId, color);
|
|
27582
27503
|
} catch {}
|
|
27504
|
+
setMenu(null);
|
|
27583
27505
|
};
|
|
27584
27506
|
const columnCenters = [];
|
|
27585
27507
|
{
|
|
@@ -30216,7 +30138,7 @@ function publishedStandKey(doc) {
|
|
|
30216
30138
|
* its own. Safe under StrictMode double-mount: the cleanup detaches every
|
|
30217
30139
|
* subscription and destroys the view between the two mounts.
|
|
30218
30140
|
*/
|
|
30219
|
-
function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databaseBridge, syncEmbedResolver, pdfPreview, mentionProvider, mentionInteractions, embedSandbox, rootBlockId, commandPalettePlaceholder, accessLevel, mode, publishedDoc, presence, hiddenAttributes,
|
|
30141
|
+
function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databaseBridge, syncEmbedResolver, pdfPreview, mentionProvider, mentionInteractions, embedSandbox, rootBlockId, commandPalettePlaceholder, accessLevel, mode, publishedDoc, presence, hiddenAttributes, renderAttribute, attributeTypePicker, docTags, children }) {
|
|
30220
30142
|
const rootId = rootBlockId ?? doc.meta.id;
|
|
30221
30143
|
const [store] = useState(() => createEditorStore(doc, rootId));
|
|
30222
30144
|
const docRef = useRef(doc);
|
|
@@ -30369,9 +30291,9 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databas
|
|
|
30369
30291
|
mentionProvider: mentionProvider ?? parent?.mentionProvider ?? null,
|
|
30370
30292
|
mentionInteractions: mentionInteractions ?? parent?.mentionInteractions ?? null,
|
|
30371
30293
|
hiddenAttributes: hiddenAttributes ?? parent?.hiddenAttributes ?? [],
|
|
30372
|
-
tagEditor: tagEditor ?? parent?.tagEditor ?? null,
|
|
30373
30294
|
renderAttribute: renderAttribute ?? parent?.renderAttribute ?? null,
|
|
30374
30295
|
attributeTypePicker: attributeTypePicker ?? parent?.attributeTypePicker ?? null,
|
|
30296
|
+
docTags: docTags ?? parent?.docTags ?? null,
|
|
30375
30297
|
embedSandbox: embedSandbox ?? parent?.embedSandbox ?? defaultEmbedSandbox,
|
|
30376
30298
|
rootBlockId: rootId,
|
|
30377
30299
|
ancestorDocIds: parent ? [...parent.ancestorDocIds, parent.doc.meta.id] : [],
|
|
@@ -30400,9 +30322,9 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databas
|
|
|
30400
30322
|
effectiveMode,
|
|
30401
30323
|
presence,
|
|
30402
30324
|
hiddenAttributes,
|
|
30403
|
-
tagEditor,
|
|
30404
30325
|
renderAttribute,
|
|
30405
|
-
attributeTypePicker
|
|
30326
|
+
attributeTypePicker,
|
|
30327
|
+
docTags
|
|
30406
30328
|
]);
|
|
30407
30329
|
const inheritedPublishedStand = parentContext !== null && parentContext.mode === "published";
|
|
30408
30330
|
const rendered = effectiveAccessLevel === "viewer" && parentContext === null ? children : effectiveMode === "published" ? publishedDoc !== void 0 && publishedDoc !== null ? /* @__PURE__ */ jsx(EditorProvider, {
|
|
@@ -30545,10 +30467,10 @@ function AttributeRow({ attributeKey, label, removable, onRemove, removeAria, to
|
|
|
30545
30467
|
return /* @__PURE__ */ jsxs("div", {
|
|
30546
30468
|
"data-slot": "docblocks/attribute-row",
|
|
30547
30469
|
"data-attribute-key": attributeKey,
|
|
30548
|
-
className: "flex
|
|
30470
|
+
className: "flex items-center gap-3",
|
|
30549
30471
|
children: [
|
|
30550
30472
|
/* @__PURE__ */ jsx("span", {
|
|
30551
|
-
className: cn("w-
|
|
30473
|
+
className: cn("w-32 shrink-0 truncate text-sm text-muted-foreground", topAlign && "self-start", labelClassName),
|
|
30552
30474
|
children: label
|
|
30553
30475
|
}),
|
|
30554
30476
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -31088,64 +31010,57 @@ function DraggableAttributeRow({ attributeKey, onDragStart, onDragEnd, topAlign,
|
|
|
31088
31010
|
rounded-full text-(--docblocks-gutter-color) opacity-0
|
|
31089
31011
|
group-hover:opacity-100
|
|
31090
31012
|
active:cursor-grabbing
|
|
31091
|
-
`, topAlign ? "top-
|
|
31013
|
+
`, topAlign ? "top-1.5" : "top-1/2 -translate-y-1/2"),
|
|
31092
31014
|
children: /* @__PURE__ */ jsx(GripVertical, { className: "size-4" })
|
|
31093
31015
|
}), children]
|
|
31094
31016
|
});
|
|
31095
31017
|
}
|
|
31096
31018
|
//#endregion
|
|
31097
|
-
//#region src/attributes/
|
|
31098
|
-
/** The tags
|
|
31099
|
-
*
|
|
31100
|
-
|
|
31101
|
-
* border only). */
|
|
31102
|
-
function TagsEditor({ tags, readOnly, onTagsChange }) {
|
|
31019
|
+
//#region src/attributes/TagsZone.tsx
|
|
31020
|
+
/** The tags zone's props (the panel's pass-through over the `docTags`'s
|
|
31021
|
+
* contract + the read-only stand). */
|
|
31022
|
+
function TagsZone({ tags, readOnly, onTagAdd, onTagRemove, onTagClick }) {
|
|
31103
31023
|
const { t } = useTranslation("editor");
|
|
31104
|
-
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
|
|
31108
|
-
|
|
31109
|
-
|
|
31110
|
-
|
|
31111
|
-
|
|
31112
|
-
|
|
31113
|
-
|
|
31024
|
+
if (tags.length === 0) {
|
|
31025
|
+
if (readOnly || onTagAdd === void 0) return /* @__PURE__ */ jsx("span", {
|
|
31026
|
+
className: "text-sm text-muted-foreground",
|
|
31027
|
+
children: t("attributes.notSet")
|
|
31028
|
+
});
|
|
31029
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
31030
|
+
type: "button",
|
|
31031
|
+
"data-slot": "docblocks/attributes-tag-add",
|
|
31032
|
+
"aria-label": t("attributes.addTagAria"),
|
|
31033
|
+
className: "\n flex items-center gap-1 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground\n hover:bg-muted/50 hover:text-foreground\n ",
|
|
31034
|
+
onClick: () => onTagAdd(),
|
|
31035
|
+
children: [/* @__PURE__ */ jsx(Plus, { className: "size-3" }), t("attributes.addTag")]
|
|
31036
|
+
});
|
|
31037
|
+
}
|
|
31114
31038
|
return /* @__PURE__ */ jsxs("div", {
|
|
31115
31039
|
"data-slot": "docblocks/attributes-tags",
|
|
31116
31040
|
className: "flex flex-wrap items-center gap-1.5",
|
|
31117
31041
|
children: [tags.map((tag) => /* @__PURE__ */ jsxs("span", {
|
|
31118
31042
|
"data-slot": "docblocks/attributes-tag",
|
|
31119
|
-
|
|
31120
|
-
|
|
31043
|
+
"data-tag-id": tag.id,
|
|
31044
|
+
className: cn("inline-flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs", onTagClick !== void 0 && "cursor-pointer"),
|
|
31045
|
+
onClick: onTagClick !== void 0 ? (event) => onTagClick(tag, event.nativeEvent) : void 0,
|
|
31046
|
+
children: [tag.label, readOnly || onTagRemove === void 0 ? null : /* @__PURE__ */ jsx("button", {
|
|
31121
31047
|
type: "button",
|
|
31122
31048
|
"data-slot": "docblocks/attributes-tag-remove",
|
|
31123
|
-
"aria-label": tag,
|
|
31049
|
+
"aria-label": t("attributes.removeAria", { name: tag.label }),
|
|
31124
31050
|
className: "text-muted-foreground hover:text-foreground",
|
|
31125
|
-
onClick: () =>
|
|
31051
|
+
onClick: (event) => {
|
|
31052
|
+
event.stopPropagation();
|
|
31053
|
+
onTagRemove(tag);
|
|
31054
|
+
},
|
|
31126
31055
|
children: /* @__PURE__ */ jsx(X, { className: "size-3" })
|
|
31127
31056
|
})]
|
|
31128
|
-
}, tag)), readOnly ? null : /* @__PURE__ */
|
|
31129
|
-
|
|
31057
|
+
}, tag.id)), readOnly || onTagAdd === void 0 ? null : /* @__PURE__ */ jsxs("button", {
|
|
31058
|
+
type: "button",
|
|
31059
|
+
"data-slot": "docblocks/attributes-tag-add",
|
|
31130
31060
|
"aria-label": t("attributes.addTagAria"),
|
|
31131
|
-
|
|
31132
|
-
|
|
31133
|
-
|
|
31134
|
-
value: draft,
|
|
31135
|
-
onChange: (event) => setDraft(event.target.value),
|
|
31136
|
-
onKeyDown: (event) => {
|
|
31137
|
-
if (event.key === "Enter" || event.key === ",") {
|
|
31138
|
-
event.preventDefault();
|
|
31139
|
-
addTag(draft);
|
|
31140
|
-
setDraft("");
|
|
31141
|
-
} else if (event.key === "Backspace" && draft === "" && tags.length > 0) commit(tags.slice(0, -1));
|
|
31142
|
-
},
|
|
31143
|
-
onBlur: () => {
|
|
31144
|
-
if (draft.trim() !== "") {
|
|
31145
|
-
addTag(draft);
|
|
31146
|
-
setDraft("");
|
|
31147
|
-
}
|
|
31148
|
-
}
|
|
31061
|
+
className: "\n flex items-center gap-1 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground\n hover:bg-muted/50 hover:text-foreground\n ",
|
|
31062
|
+
onClick: () => onTagAdd(),
|
|
31063
|
+
children: [/* @__PURE__ */ jsx(Plus, { className: "size-3" }), t("attributes.addTag")]
|
|
31149
31064
|
})]
|
|
31150
31065
|
});
|
|
31151
31066
|
}
|
|
@@ -31163,8 +31078,10 @@ function TagsEditor({ tags, readOnly, onTagsChange }) {
|
|
|
31163
31078
|
* record — the typed value's stand). Over the read-only stands (the
|
|
31164
31079
|
* view / published's modes) every row stands display-only.
|
|
31165
31080
|
* `hiddenAttributes` hides the named rows (the preset and the custom
|
|
31166
|
-
* keys, the system rows); `
|
|
31167
|
-
* `
|
|
31081
|
+
* keys, the system rows); the `tags` row is the consumer-owned stand (the
|
|
31082
|
+
* `docTags`'s prop: the chips over the passed list + the add affordance's
|
|
31083
|
+
* click over the consumer's own creation's UI + the chip's removal/click
|
|
31084
|
+
* events — the tags are never document data); `renderAttribute` replaces a row's value zone over its key; the
|
|
31168
31085
|
* custom-attribute add's entry stands over the list's tail (the button —
|
|
31169
31086
|
* the popover's type pick + the name's draft + the commit; the row's
|
|
31170
31087
|
* creation over the type's initial form), and `attributeTypePicker`
|
|
@@ -31180,7 +31097,7 @@ function TagsEditor({ tags, readOnly, onTagsChange }) {
|
|
|
31180
31097
|
*
|
|
31181
31098
|
* The row's unit files stand the pieces (the convention's one-component
|
|
31182
31099
|
* files): `AttributeRow` (the row's frame), `DraggableAttributeRow` (the
|
|
31183
|
-
* drag's wrapper), `DisplayValue` (the display's stand), `
|
|
31100
|
+
* drag's wrapper), `DisplayValue` (the display's stand), `TagsZone` /
|
|
31184
31101
|
* `ListEditor` / `CoverEditor` (the preset's editors),
|
|
31185
31102
|
* `AddAttributePopover` (the add's entry), `value-utils` (the value's
|
|
31186
31103
|
* pure reads).
|
|
@@ -31189,7 +31106,7 @@ function TagsEditor({ tags, readOnly, onTagsChange }) {
|
|
|
31189
31106
|
* over the editor's subtree only). */
|
|
31190
31107
|
function AttributesPanel() {
|
|
31191
31108
|
const { t, i18n } = useTranslation("editor");
|
|
31192
|
-
const { store, doc, viewMode, hiddenAttributes,
|
|
31109
|
+
const { store, doc, viewMode, hiddenAttributes, renderAttribute, attributeTypePicker, docTags } = useEditorContext();
|
|
31193
31110
|
const meta = useStore(store, (state) => state.meta);
|
|
31194
31111
|
useStore(store, (state) => state.changeStamp);
|
|
31195
31112
|
const [open, setOpen] = useState(false);
|
|
@@ -31261,8 +31178,10 @@ function AttributesPanel() {
|
|
|
31261
31178
|
});
|
|
31262
31179
|
return node === null ? defaultZone : node;
|
|
31263
31180
|
};
|
|
31264
|
-
const
|
|
31265
|
-
|
|
31181
|
+
const notSet = /* @__PURE__ */ jsx("span", {
|
|
31182
|
+
className: "text-sm text-muted-foreground",
|
|
31183
|
+
children: t("attributes.notSet")
|
|
31184
|
+
});
|
|
31266
31185
|
const customKeysAll = Object.keys(attributes).filter((key) => !isPresetKey(key));
|
|
31267
31186
|
const derivedCustomOrder = orderedCustomKeys(meta.attributesOrder, customKeysAll);
|
|
31268
31187
|
const [dragOrder, setDragOrder] = useState(null);
|
|
@@ -31304,7 +31223,6 @@ function AttributesPanel() {
|
|
|
31304
31223
|
doc.reorderAttributes(nextFull);
|
|
31305
31224
|
} catch {}
|
|
31306
31225
|
};
|
|
31307
|
-
const TagEditor = tagEditor;
|
|
31308
31226
|
const locale = i18n.language;
|
|
31309
31227
|
const inlineEdit = (key, slot, label, initial, commit, placeholder) => /* @__PURE__ */ jsx(InlineEditInput, {
|
|
31310
31228
|
initial,
|
|
@@ -31326,10 +31244,6 @@ function AttributesPanel() {
|
|
|
31326
31244
|
},
|
|
31327
31245
|
children: display
|
|
31328
31246
|
}) : null;
|
|
31329
|
-
const notSet = /* @__PURE__ */ jsx("span", {
|
|
31330
|
-
className: "text-muted-foreground",
|
|
31331
|
-
children: t("attributes.notSet")
|
|
31332
|
-
});
|
|
31333
31247
|
/** The custom row's stand (the key's rename's entry over the key's
|
|
31334
31248
|
* column; the value zone's editors over the type's stand). */
|
|
31335
31249
|
/** The custom value's commit (the type's parsing's stand: the empty's
|
|
@@ -31423,7 +31337,7 @@ function AttributesPanel() {
|
|
|
31423
31337
|
children: [/* @__PURE__ */ jsx(ChevronDown, { className: cn("size-3.5 transition-transform", !open && "-rotate-90") }), t("attributes.title")]
|
|
31424
31338
|
}), open ? /* @__PURE__ */ jsxs("div", {
|
|
31425
31339
|
"data-slot": "docblocks/attributes-body",
|
|
31426
|
-
className: "mt-1 border-t border-muted pt-1.5",
|
|
31340
|
+
className: "mt-1 flex flex-col gap-1 border-t border-muted pt-1.5",
|
|
31427
31341
|
children: [
|
|
31428
31342
|
hidden.has("id") ? null : /* @__PURE__ */ jsx(AttributeRow, {
|
|
31429
31343
|
attributeKey: "id",
|
|
@@ -31467,21 +31381,17 @@ function AttributesPanel() {
|
|
|
31467
31381
|
hidden.has("tags") ? null : /* @__PURE__ */ jsx(AttributeRow, {
|
|
31468
31382
|
attributeKey: "tags",
|
|
31469
31383
|
label: t("attributes.tags"),
|
|
31470
|
-
removable:
|
|
31471
|
-
|
|
31472
|
-
|
|
31473
|
-
|
|
31474
|
-
|
|
31475
|
-
|
|
31476
|
-
|
|
31477
|
-
|
|
31478
|
-
|
|
31479
|
-
|
|
31480
|
-
|
|
31481
|
-
if (tags.length === 0) remove("tags");
|
|
31482
|
-
else set("tags", tags);
|
|
31483
|
-
}
|
|
31484
|
-
}))
|
|
31384
|
+
removable: false,
|
|
31385
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
31386
|
+
className: "flex min-w-0 flex-1 items-center px-1.5 py-1",
|
|
31387
|
+
children: docTags === null ? notSet : /* @__PURE__ */ jsx(TagsZone, {
|
|
31388
|
+
tags: docTags.tags,
|
|
31389
|
+
readOnly: viewMode,
|
|
31390
|
+
onTagAdd: docTags.onTagAdd,
|
|
31391
|
+
onTagRemove: docTags.onTagRemove,
|
|
31392
|
+
onTagClick: docTags.onTagClick
|
|
31393
|
+
})
|
|
31394
|
+
})
|
|
31485
31395
|
}, "tags"),
|
|
31486
31396
|
hidden.has("createdBy") ? null : /* @__PURE__ */ jsx(AttributeRow, {
|
|
31487
31397
|
attributeKey: "createdBy",
|
|
@@ -31517,21 +31427,19 @@ function AttributesPanel() {
|
|
|
31517
31427
|
hidden.has("publishedAt") ? null : /* @__PURE__ */ jsx(AttributeRow, {
|
|
31518
31428
|
attributeKey: "publishedAt",
|
|
31519
31429
|
label: t("attributes.publishedAt"),
|
|
31520
|
-
removable:
|
|
31521
|
-
onRemove: () => remove("publishedAt"),
|
|
31522
|
-
removeAria: t("attributes.removeAria", { name: t("attributes.publishedAt") }),
|
|
31430
|
+
removable: false,
|
|
31523
31431
|
children: (() => {
|
|
31524
31432
|
const raw = stringValue("publishedAt");
|
|
31525
|
-
|
|
31526
|
-
|
|
31527
|
-
|
|
31528
|
-
|
|
31529
|
-
else set("publishedAt", next);
|
|
31433
|
+
return valueZone("publishedAt", /* @__PURE__ */ jsx("span", {
|
|
31434
|
+
"data-slot": "docblocks/attributes-published-at",
|
|
31435
|
+
className: "block truncate px-1.5 py-1 text-sm",
|
|
31436
|
+
children: raw === void 0 || raw === "" ? notSet : displayPublishedDate(raw, locale)
|
|
31530
31437
|
}));
|
|
31531
31438
|
})()
|
|
31532
31439
|
}, "publishedAt"),
|
|
31533
31440
|
viewMode ? /* @__PURE__ */ jsx("div", {
|
|
31534
31441
|
"data-slot": "docblocks/attributes-custom",
|
|
31442
|
+
className: "flex flex-col gap-1",
|
|
31535
31443
|
children: displayCustomKeys.map((key) => renderCustomRow(key))
|
|
31536
31444
|
}) : /* @__PURE__ */ jsx(Reorder.Group, {
|
|
31537
31445
|
as: "div",
|
|
@@ -31539,7 +31447,7 @@ function AttributesPanel() {
|
|
|
31539
31447
|
axis: "y",
|
|
31540
31448
|
values: displayCustomKeys,
|
|
31541
31449
|
onReorder: (next) => setDragOrder(next),
|
|
31542
|
-
className: "flex flex-col",
|
|
31450
|
+
className: "flex flex-col gap-1",
|
|
31543
31451
|
children: displayCustomKeys.map((key) => /* @__PURE__ */ jsx(DraggableAttributeRow, {
|
|
31544
31452
|
attributeKey: key,
|
|
31545
31453
|
topAlign: isListCustom(key),
|
|
@@ -31989,7 +31897,7 @@ function useEditing() {
|
|
|
31989
31897
|
if (inner === null) return;
|
|
31990
31898
|
const position = locatePosition(inner, event.key === "Home" ? 0 : doc.getTextLength(targetId));
|
|
31991
31899
|
applyDomSelection(position.node, position.offset, position.node, position.offset);
|
|
31992
|
-
(position.node instanceof Element ? position.node : position.node.parentElement)?.scrollIntoView({ block: event.key === "Home" ? "start" : "end" });
|
|
31900
|
+
(position.node instanceof Element ? position.node : position.node.parentElement)?.scrollIntoView?.({ block: event.key === "Home" ? "start" : "end" });
|
|
31993
31901
|
return;
|
|
31994
31902
|
}
|
|
31995
31903
|
if (viewMode) return;
|
|
@@ -33210,4 +33118,4 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
|
33210
33118
|
});
|
|
33211
33119
|
}
|
|
33212
33120
|
//#endregion
|
|
33213
|
-
export {
|
|
33121
|
+
export { DropdownMenuSubTrigger as $, BookOpen as $t, SelectItem as A, Card as At, DropdownMenu as B, useDoc as Bt, emptyFilter as C, isBridgeErrorCode as Ct, Select as D, TEXT_TYPES as Dt, ScrollArea as E, parseCellValue as Et, SelectTrigger as F, CardHeader as Ft, DropdownMenuLabel as G, useSelectionView as Gt, DropdownMenuContent as H, usePresence as Ht, SelectValue as I, CardTitle as It, DropdownMenuRadioItem as J, INLINE_CODE_CLASS as Jt, DropdownMenuPortal as K, useText as Kt, Label as L, Badge as Lt, SelectScrollDownButton as M, CardContent as Mt, SelectScrollUpButton as N, CardDescription as Nt, SelectContent as O, columnAnnotation as Ot, SelectSeparator as P, CardFooter as Pt, DropdownMenuSubContent as Q, CodeXml as Qt, InlineEditInput as R, badgeVariants as Rt, FilterBuilder as S, isBridgeError as St, SegmentSelector as T, conditionMatches as Tt, DropdownMenuGroup as U, usePresenceSharing as Ut, DropdownMenuCheckboxItem as V, useMeta as Vt, DropdownMenuItem as W, useSelection as Wt, DropdownMenuShortcut as X, Pen as Xt, DropdownMenuSeparator as Y, renderRuns as Yt, DropdownMenuSub as Z, Eye as Zt, parseFrontmatter as _, PROTOCOL_VERSION as _t, childrenSlot as a, PopoverDescription as at, cellValueEqual as b, BRIDGE_ERROR_CODES as bt, SHAPE_FONT_STACKS as c, PopoverTrigger as ct, textOf as d, buttonVariants as dt, createMemoryBlobStore as en, DropdownMenuTrigger as et, markToggleAction as f, BareSelect as ft, mapFrontmatter as g, BASELINE_CAPABILITIES as gt, mdToBlocks as h, AlertTitle as ht, DEFAULT_EMBED_SANDBOX as i, PopoverContent as it, SelectLabel as j, CardAction as jt, SelectGroup as k, Skeleton as kt, TextBlock as l, Checkbox as lt, insertNative as m, AlertDescription as mt, EditorProvider as n, Popover as nt, CodeHeader as o, PopoverHeader as ot, htmlToBlocks as p, Alert as pt, DropdownMenuRadioGroup as q, DocblocksI18nProvider as qt, useEditorContext as r, PopoverAnchor as rt, SHAPE_FONT_OPTIONS as s, PopoverTitle as st, Editor as t, Separator as tt, FORMAT_PALETTE as u, Button as ut, GridBody as v, isDatabaseBridge as vt, filterIsComplete as w, toBridgeError as wt, newMutationContext as x, BridgeError as xt, useDatabaseTable as y, validateProtocolDescriptor as yt, Input as z, useBlock as zt };
|