docblocks-react-ui 0.7.0 → 0.8.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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # docblocks-react-ui
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ce42093: **fix:** the HTML paste and the whole-document import keep a bare `br`
8
+ between the block's text nodes as the soft line break (the `htmlToBlocks`'
9
+ edge whitespace drop no longer erases the line break — the non-browser
10
+ serializers stand the `<br>` between the blockquote's text nodes without
11
+ the `p`'s wrapper).
12
+ - **changed:** the database's filter value's date / datetime stand over the
13
+ house's `DatePicker` / `DateTimePicker` (the raw's native's `<input
14
+ type="date">` / `<input type="datetime-local">`'s stands are gone — the
15
+ commit stands the cell's same wire's format: the "YYYY-MM-DD" the
16
+ midnight's zero, the "THH:MM"[:SS] over the time's; the datetime's
17
+ commit stands on the popover's close).
18
+
19
+ ## 0.8.0
20
+
21
+ ### Minor Changes
22
+
23
+ - 4e4eb46: The headless whole-document import: `importDocument(doc, source, kind)`
24
+ (`kind: "markdown" | "html"`) fills a FRESH document (the empty root) from
25
+ a markdown or HTML payload — the consumer-side pre-attach write (the
26
+ content stands in the first full-state bootstrap the attach sends, so the
27
+ first wire sync persists it). The parsed blocks materialize over the paste
28
+ parsers' shared insertion in ONE `doc.transact` (one undo step, one wire
29
+ update). The indents stand the parser's absolute nesting (there is no caret
30
+ to re-base to) over the sequence's jump-rule clamp (the first block anchors
31
+ at indent 0; the rest are capped at the predecessor's +1 — the parser's
32
+ dropped-parent gap cannot roll back the import). An empty (or
33
+ whitespace-only) payload is a no-op (nothing is written, no transaction);
34
+ a non-fresh document (the root already has children) throws the typed
35
+ `ImportDocumentError`. The paste path is unchanged.
36
+
3
37
  ## 0.7.0
4
38
 
5
39
  ### Minor Changes
@@ -5406,6 +5406,50 @@ function PopoverDescription({ className, ...props }) {
5406
5406
  });
5407
5407
  }
5408
5408
  //#endregion
5409
+ //#region src/shared/ui/DatePicker.tsx
5410
+ /**
5411
+ * The single-date picker: the trigger stands the calendar icon + the
5412
+ * formatted date (the `PPP` long form) or the placeholder (the empty
5413
+ * state), and the calendar stands in the portaled popover content.
5414
+ *
5415
+ * The component is controlled: the `value` is a local-calendar `Date`
5416
+ * (the consumer converts the cell / doc value to it), and `onSelect`
5417
+ * fires on a day pick (picking the selected day again clears it — the
5418
+ * day-picker's toggle) and the popover closes on the pick (the cell's
5419
+ * focus stands back on the trigger). The extra props stand on the trigger
5420
+ * button (the `data-*` hooks included; the native `value` / `onSelect`
5421
+ * button props are omitted — they stand the picker's own contract).
5422
+ */
5423
+ function DatePicker({ value, onSelect, className, placeholder = "—", ...triggerProps }) {
5424
+ const [open, setOpen] = React.useState(false);
5425
+ const onDateSelect = (date) => {
5426
+ setOpen(false);
5427
+ onSelect(date ?? null);
5428
+ };
5429
+ return /* @__PURE__ */ jsxs(Popover, {
5430
+ open,
5431
+ onOpenChange: setOpen,
5432
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
5433
+ asChild: true,
5434
+ children: /* @__PURE__ */ jsxs(Button, {
5435
+ type: "button",
5436
+ variant: "outline",
5437
+ "data-empty": value ? void 0 : true,
5438
+ className: cn("justify-start text-left font-normal data-[empty=true]:text-muted-foreground", className),
5439
+ ...triggerProps,
5440
+ children: [/* @__PURE__ */ jsx(CalendarIcon, {}), value ? format(value, "PPP") : /* @__PURE__ */ jsx("span", { children: placeholder })]
5441
+ })
5442
+ }), /* @__PURE__ */ jsx(PopoverContent, {
5443
+ className: "w-auto p-0",
5444
+ children: /* @__PURE__ */ jsx(Calendar, {
5445
+ mode: "single",
5446
+ selected: value ?? void 0,
5447
+ onSelect: onDateSelect
5448
+ })
5449
+ })]
5450
+ });
5451
+ }
5452
+ //#endregion
5409
5453
  //#region src/shared/ui/Separator.tsx
5410
5454
  function Separator({ className, orientation = "horizontal", decorative = true, ...props }) {
5411
5455
  return /* @__PURE__ */ jsx(SeparatorPrimitive.Root, {
@@ -5594,6 +5638,98 @@ function TimeSegmentsInner({ id, value, onChange, disabled, clearable, className
5594
5638
  });
5595
5639
  }
5596
5640
  //#endregion
5641
+ //#region src/shared/ui/DateTimePicker.tsx
5642
+ /** The trigger's label: the compact date, + the time when it is not the
5643
+ * midnight zero (the seconds stand only when they are not zero). */
5644
+ function labelOf(value) {
5645
+ const base = format(value, "dd.MM.yyyy");
5646
+ if (value.getHours() === 0 && value.getMinutes() === 0 && value.getSeconds() === 0) return base;
5647
+ const label = format(value, "HH:mm");
5648
+ return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
5649
+ }
5650
+ function hasTime$1(value) {
5651
+ return value !== null && (value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0);
5652
+ }
5653
+ function datePart(value) {
5654
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
5655
+ }
5656
+ /**
5657
+ * The date-and-time picker: the `DatePicker`'s calendar + the `TimeSegments`
5658
+ * box in one portaled popover.
5659
+ *
5660
+ * The component is controlled: the `value` is a local-calendar `Date`, and
5661
+ * `onSelect` commits the picked date + the typed time (the commit stands on
5662
+ * the popover close — the escape / the outside press / an explicit close —
5663
+ * as one step; a no-op close stands no commit). The drafts stand from the
5664
+ * value at the open (the in-flight draft stands the mid-session value
5665
+ * changes), the day pick edits the draft date (the same-day toggle stands no
5666
+ * reset — the deferred commit's contract), the time box edits the draft
5667
+ * time; the extra props stand on the
5668
+ * trigger button (the `data-*` hooks included; the native `value` /
5669
+ * `onSelect` button props are omitted — they stand the picker's contract).
5670
+ */
5671
+ function DateTimePicker({ value, onSelect, className, placeholder = "—", ...triggerProps }) {
5672
+ const [open, setOpen] = React.useState(false);
5673
+ const [draftDate, setDraftDate] = React.useState(null);
5674
+ const [draftTime, setDraftTime] = React.useState(null);
5675
+ const timeSegmentsId = React.useId();
5676
+ const handleOpenChange = (next) => {
5677
+ if (next) {
5678
+ setDraftDate(value !== null ? datePart(value) : null);
5679
+ setDraftTime(value !== null && hasTime$1(value) ? format(value, "HH:mm:ss") : null);
5680
+ setOpen(true);
5681
+ return;
5682
+ }
5683
+ setOpen(false);
5684
+ const committed = draftDate === null ? null : datePart(draftDate);
5685
+ if (draftTime !== null && committed !== null) {
5686
+ const [hours, minutes, seconds] = draftTime.split(":");
5687
+ committed.setHours(Number(hours), Number(minutes), Number(seconds));
5688
+ }
5689
+ if ((value?.getTime() ?? null) === (committed?.getTime() ?? null)) return;
5690
+ onSelect(committed);
5691
+ };
5692
+ const onDraftDateSelect = (date) => {
5693
+ if (date === void 0 || date === null) return;
5694
+ setDraftDate(datePart(date));
5695
+ };
5696
+ return /* @__PURE__ */ jsxs(Popover, {
5697
+ open,
5698
+ onOpenChange: handleOpenChange,
5699
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
5700
+ asChild: true,
5701
+ children: /* @__PURE__ */ jsxs(Button, {
5702
+ type: "button",
5703
+ variant: "outline",
5704
+ "data-empty": value ? void 0 : true,
5705
+ className: cn("justify-start text-left font-normal data-[empty=true]:text-muted-foreground", className),
5706
+ ...triggerProps,
5707
+ children: [/* @__PURE__ */ jsx(CalendarIcon, {}), value ? labelOf(value) : /* @__PURE__ */ jsx("span", { children: placeholder })]
5708
+ })
5709
+ }), /* @__PURE__ */ jsxs(PopoverContent, {
5710
+ className: "w-auto p-0",
5711
+ children: [
5712
+ /* @__PURE__ */ jsx(Calendar, {
5713
+ mode: "single",
5714
+ selected: draftDate ?? void 0,
5715
+ ...value !== null ? { defaultMonth: value } : {},
5716
+ onSelect: onDraftDateSelect
5717
+ }),
5718
+ /* @__PURE__ */ jsx(Separator, {}),
5719
+ /* @__PURE__ */ jsx("div", {
5720
+ className: "p-2",
5721
+ children: /* @__PURE__ */ jsx(TimeSegments, {
5722
+ id: timeSegmentsId,
5723
+ value: draftTime,
5724
+ onChange: setDraftTime,
5725
+ clearable: true
5726
+ })
5727
+ })
5728
+ ]
5729
+ })]
5730
+ });
5731
+ }
5732
+ //#endregion
5597
5733
  //#region src/shared/ui/Datalist.tsx
5598
5734
  function Datalist({ className, ...props }) {
5599
5735
  return /* @__PURE__ */ jsx("datalist", {
@@ -7493,6 +7629,163 @@ function validateProtocolDescriptor(descriptor) {
7493
7629
  for (const capability of BASELINE_CAPABILITIES) if (!capabilities.has(capability)) throw new BridgeError("protocol_mismatch", `The bridge lacks the required protocol capability "${capability}".`);
7494
7630
  return capabilities;
7495
7631
  }
7632
+ //#endregion
7633
+ //#region src/database/grid/utils.ts
7634
+ /** The database grid's pure helpers: the visible-column derivation, the
7635
+ * number column's display attributes / input step, the cell's selection
7636
+ * key, and the date/datetime value parsing + labels. */
7637
+ /** The full known id order: explicit ids first, then new schema columns. */
7638
+ function normalizeColumnOrder(columns, columnOrder) {
7639
+ const byId = new Map((columns ?? []).map((column) => [column.id, column]));
7640
+ const ordered = [];
7641
+ for (const id of columnOrder ?? []) {
7642
+ if (!byId.has(id) || ordered.includes(id)) continue;
7643
+ ordered.push(id);
7644
+ byId.delete(id);
7645
+ }
7646
+ for (const column of byId.values()) ordered.push(column.id);
7647
+ return ordered;
7648
+ }
7649
+ /** The block's visible columns: the full order minus the hidden ids. */
7650
+ function visibleColumns(columns, columnOrder, hiddenColumns) {
7651
+ const byId = new Map((columns ?? []).map((column) => [column.id, column]));
7652
+ const hidden = new Set(hiddenColumns ?? []);
7653
+ return normalizeColumnOrder(columns, columnOrder).flatMap((id) => {
7654
+ const column = byId.get(id);
7655
+ return column === void 0 || hidden.has(id) ? [] : [column];
7656
+ });
7657
+ }
7658
+ /** One immutable list move; an invalid or identity move returns the input. */
7659
+ function reorderItems(items, fromIndex, toIndex) {
7660
+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return items;
7661
+ const next = [...items];
7662
+ const [moved] = next.splice(fromIndex, 1);
7663
+ if (moved === void 0) return items;
7664
+ next.splice(toIndex, 0, moved);
7665
+ return next;
7666
+ }
7667
+ /** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
7668
+ function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
7669
+ const fullOrder = normalizeColumnOrder(columns, columnOrder);
7670
+ const visibleIds = visibleColumns(columns, columnOrder, hiddenColumns).map((column) => column.id);
7671
+ const stationary = visibleIds.filter((id) => id !== columnId);
7672
+ if (stationary.length === visibleIds.length || toIndex < 0 || toIndex > stationary.length) return fullOrder;
7673
+ const next = fullOrder.filter((id) => id !== columnId);
7674
+ const targetId = stationary[toIndex];
7675
+ if (targetId !== void 0) {
7676
+ next.splice(next.indexOf(targetId), 0, columnId);
7677
+ return next;
7678
+ }
7679
+ const anchorId = stationary.at(-1);
7680
+ if (anchorId === void 0) return fullOrder;
7681
+ next.splice(next.indexOf(anchorId) + 1, 0, columnId);
7682
+ return next;
7683
+ }
7684
+ /** The number input's step stand: the explicit `decimals` stands the
7685
+ * `10^-decimals` step; the absent stand follows the integer types only
7686
+ * (the float types stand no step — the 0.5 must be typeable). */
7687
+ function numberStepFor(column) {
7688
+ if (column.decimals !== void 0) {
7689
+ const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
7690
+ return decimals === 0 ? "1" : String(10 ** -decimals);
7691
+ }
7692
+ const base = column.type.replace(/\[\]$/, "").trim();
7693
+ return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
7694
+ }
7695
+ /** The display's attributes stand: the explicit `decimals` (or the
7696
+ * integer stand) takes the fixed-digit format; the float types without
7697
+ * the explicit digits stand the RAW value (no rounding — the display
7698
+ * must not lose the value's own stand). */
7699
+ function numberDisplayAttrs(column) {
7700
+ const base = column.type.replace(/\[\]$/, "").trim();
7701
+ return {
7702
+ decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
7703
+ thousands: column.thousands,
7704
+ prefix: column.prefix,
7705
+ suffix: column.suffix
7706
+ };
7707
+ }
7708
+ /** The cell's selection/editing key (the row id + the column id). */
7709
+ const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
7710
+ /** The cell's clipboard text: the TSV's flat stand (the tab / the
7711
+ * newline stand the space — the TSV's shape stands; the row-link's array
7712
+ * joins over the comma — the label's stand, never the id). */
7713
+ function cellTextOf(value) {
7714
+ if (value === void 0 || value === null) return "";
7715
+ if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
7716
+ return String(value).replace(/[\t\n\r]/g, " ");
7717
+ }
7718
+ /** The TSV's parse (the clipboard's plain text over the grid's paste):
7719
+ * the rows over the newline (the carriage return stands the newline),
7720
+ * the cells over the tab; the trailing empty row stands no stand (the
7721
+ * clipboard's trailing newline). An empty text stands no grid. */
7722
+ function parseClipboardTsv(text) {
7723
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
7724
+ if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
7725
+ if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
7726
+ return lines.map((line) => line.split(" "));
7727
+ }
7728
+ /** The local-calendar day (the year / month / date stand, the time is
7729
+ * dropped) — the picker's draft stand. */
7730
+ function dateOnly(value) {
7731
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
7732
+ }
7733
+ /** The time stand (the hours / minutes / the seconds are not all zero). */
7734
+ function hasTime(value) {
7735
+ return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
7736
+ }
7737
+ /** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
7738
+ * part) parsed to the local-calendar Date; null when absent / invalid. */
7739
+ function parseCellDateTime(value) {
7740
+ const raw = value === void 0 || value === null ? "" : String(value);
7741
+ if (raw === "") return null;
7742
+ if (raw.includes("T")) {
7743
+ const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
7744
+ const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
7745
+ return Number.isNaN(result.getTime()) ? null : result;
7746
+ }
7747
+ const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
7748
+ return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
7749
+ }
7750
+ /** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
7751
+ * only when they are not zero; the midnight zero stands the date only). */
7752
+ function dateTimeLabel(value) {
7753
+ const base = format(value, "dd.MM.yyyy");
7754
+ if (!hasTime(value)) return base;
7755
+ const label = format(value, "HH:mm");
7756
+ return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
7757
+ }
7758
+ /** The datetime's committed wire value (the "YYYY-MM-DD" base; the
7759
+ * "THH:MM" part when the time is not the midnight zero; the ":SS" only
7760
+ * when the seconds are not zero) — the cell's commit and the filter's
7761
+ * value stand the same format (the bridge's match runs over the stored
7762
+ * cell's strings). */
7763
+ function formatCellDateTime(value) {
7764
+ if (value === null) return null;
7765
+ const base = format(value, "yyyy-MM-dd");
7766
+ if (!hasTime(value)) return base;
7767
+ const time = format(value, "HH:mm");
7768
+ return value.getSeconds() !== 0 ? `${base}T${time}:${format(value, "ss")}` : `${base}T${time}`;
7769
+ }
7770
+ /** The form draft over a catalog entry (the name prefills the type's
7771
+ * label — the create's commit takes the input's name). */
7772
+ function emptyColumnForm(entry) {
7773
+ return {
7774
+ key: entry.key,
7775
+ type: entry.type,
7776
+ name: entry.label,
7777
+ numberKind: entry.numberKind,
7778
+ decimals: entry.numberKind === "decimal" ? 2 : 0,
7779
+ thousands: false,
7780
+ prefix: "",
7781
+ suffix: "",
7782
+ allowNegative: true,
7783
+ refKind: entry.refKind,
7784
+ refMany: entry.refMany,
7785
+ refPick: "",
7786
+ newTableName: ""
7787
+ };
7788
+ }
7496
7789
  /** The cursor's continuation's retry bound (the `cursor_expired` over
7497
7790
  * the concurrent commit stands the fresh snapshot; the bound stands the
7498
7791
  * churn's livelock — over it the partial page set stands the lenient
@@ -7988,21 +8281,17 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
7988
8281
  })
7989
8282
  ]
7990
8283
  });
7991
- case "date": return /* @__PURE__ */ jsx(Input, {
7992
- type: "date",
7993
- size: "sm",
8284
+ case "date": return /* @__PURE__ */ jsx(DatePicker, {
7994
8285
  "data-slot": "docblocks/filter-value",
7995
- className: "min-w-0 flex-1 border-input",
7996
- value: value === void 0 || value === null ? "" : String(value),
7997
- onChange: onScalarChange
8286
+ className: "h-8 min-w-0 flex-1 px-2 py-0.5",
8287
+ value: parseCellDateTime(value),
8288
+ onSelect: (date) => onChange(formatCellDateTime(date) ?? void 0)
7998
8289
  });
7999
- case "datetime": return /* @__PURE__ */ jsx(Input, {
8000
- type: "datetime-local",
8001
- size: "sm",
8290
+ case "datetime": return /* @__PURE__ */ jsx(DateTimePicker, {
8002
8291
  "data-slot": "docblocks/filter-value",
8003
- className: "min-w-0 flex-1 border-input",
8004
- value: value === void 0 || value === null ? "" : String(value),
8005
- onChange: onScalarChange
8292
+ className: "h-8 min-w-0 flex-1 px-2 py-0.5",
8293
+ value: parseCellDateTime(value),
8294
+ onSelect: (date) => onChange(formatCellDateTime(date) ?? void 0)
8006
8295
  });
8007
8296
  case "enum":
8008
8297
  case "row-link": {
@@ -9152,151 +9441,6 @@ function useDatabaseTable(bridge, tableId, filter) {
9152
9441
  };
9153
9442
  }
9154
9443
  //#endregion
9155
- //#region src/database/grid/utils.ts
9156
- /** The database grid's pure helpers: the visible-column derivation, the
9157
- * number column's display attributes / input step, the cell's selection
9158
- * key, and the date/datetime value parsing + labels. */
9159
- /** The full known id order: explicit ids first, then new schema columns. */
9160
- function normalizeColumnOrder(columns, columnOrder) {
9161
- const byId = new Map((columns ?? []).map((column) => [column.id, column]));
9162
- const ordered = [];
9163
- for (const id of columnOrder ?? []) {
9164
- if (!byId.has(id) || ordered.includes(id)) continue;
9165
- ordered.push(id);
9166
- byId.delete(id);
9167
- }
9168
- for (const column of byId.values()) ordered.push(column.id);
9169
- return ordered;
9170
- }
9171
- /** The block's visible columns: the full order minus the hidden ids. */
9172
- function visibleColumns(columns, columnOrder, hiddenColumns) {
9173
- const byId = new Map((columns ?? []).map((column) => [column.id, column]));
9174
- const hidden = new Set(hiddenColumns ?? []);
9175
- return normalizeColumnOrder(columns, columnOrder).flatMap((id) => {
9176
- const column = byId.get(id);
9177
- return column === void 0 || hidden.has(id) ? [] : [column];
9178
- });
9179
- }
9180
- /** One immutable list move; an invalid or identity move returns the input. */
9181
- function reorderItems(items, fromIndex, toIndex) {
9182
- if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return items;
9183
- const next = [...items];
9184
- const [moved] = next.splice(fromIndex, 1);
9185
- if (moved === void 0) return items;
9186
- next.splice(toIndex, 0, moved);
9187
- return next;
9188
- }
9189
- /** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
9190
- function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
9191
- const fullOrder = normalizeColumnOrder(columns, columnOrder);
9192
- const visibleIds = visibleColumns(columns, columnOrder, hiddenColumns).map((column) => column.id);
9193
- const stationary = visibleIds.filter((id) => id !== columnId);
9194
- if (stationary.length === visibleIds.length || toIndex < 0 || toIndex > stationary.length) return fullOrder;
9195
- const next = fullOrder.filter((id) => id !== columnId);
9196
- const targetId = stationary[toIndex];
9197
- if (targetId !== void 0) {
9198
- next.splice(next.indexOf(targetId), 0, columnId);
9199
- return next;
9200
- }
9201
- const anchorId = stationary.at(-1);
9202
- if (anchorId === void 0) return fullOrder;
9203
- next.splice(next.indexOf(anchorId) + 1, 0, columnId);
9204
- return next;
9205
- }
9206
- /** The number input's step stand: the explicit `decimals` stands the
9207
- * `10^-decimals` step; the absent stand follows the integer types only
9208
- * (the float types stand no step — the 0.5 must be typeable). */
9209
- function numberStepFor(column) {
9210
- if (column.decimals !== void 0) {
9211
- const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
9212
- return decimals === 0 ? "1" : String(10 ** -decimals);
9213
- }
9214
- const base = column.type.replace(/\[\]$/, "").trim();
9215
- return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
9216
- }
9217
- /** The display's attributes stand: the explicit `decimals` (or the
9218
- * integer stand) takes the fixed-digit format; the float types without
9219
- * the explicit digits stand the RAW value (no rounding — the display
9220
- * must not lose the value's own stand). */
9221
- function numberDisplayAttrs(column) {
9222
- const base = column.type.replace(/\[\]$/, "").trim();
9223
- return {
9224
- decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
9225
- thousands: column.thousands,
9226
- prefix: column.prefix,
9227
- suffix: column.suffix
9228
- };
9229
- }
9230
- /** The cell's selection/editing key (the row id + the column id). */
9231
- const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
9232
- /** The cell's clipboard text: the TSV's flat stand (the tab / the
9233
- * newline stand the space — the TSV's shape stands; the row-link's array
9234
- * joins over the comma — the label's stand, never the id). */
9235
- function cellTextOf(value) {
9236
- if (value === void 0 || value === null) return "";
9237
- if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
9238
- return String(value).replace(/[\t\n\r]/g, " ");
9239
- }
9240
- /** The TSV's parse (the clipboard's plain text over the grid's paste):
9241
- * the rows over the newline (the carriage return stands the newline),
9242
- * the cells over the tab; the trailing empty row stands no stand (the
9243
- * clipboard's trailing newline). An empty text stands no grid. */
9244
- function parseClipboardTsv(text) {
9245
- const lines = text.replace(/\r\n?/g, "\n").split("\n");
9246
- if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
9247
- if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
9248
- return lines.map((line) => line.split(" "));
9249
- }
9250
- /** The local-calendar day (the year / month / date stand, the time is
9251
- * dropped) — the picker's draft stand. */
9252
- function dateOnly(value) {
9253
- return new Date(value.getFullYear(), value.getMonth(), value.getDate());
9254
- }
9255
- /** The time stand (the hours / minutes / the seconds are not all zero). */
9256
- function hasTime(value) {
9257
- return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
9258
- }
9259
- /** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
9260
- * part) parsed to the local-calendar Date; null when absent / invalid. */
9261
- function parseCellDateTime(value) {
9262
- const raw = value === void 0 || value === null ? "" : String(value);
9263
- if (raw === "") return null;
9264
- if (raw.includes("T")) {
9265
- const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
9266
- const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
9267
- return Number.isNaN(result.getTime()) ? null : result;
9268
- }
9269
- const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
9270
- return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
9271
- }
9272
- /** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
9273
- * only when they are not zero; the midnight zero stands the date only). */
9274
- function dateTimeLabel(value) {
9275
- const base = format(value, "dd.MM.yyyy");
9276
- if (!hasTime(value)) return base;
9277
- const label = format(value, "HH:mm");
9278
- return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
9279
- }
9280
- /** The form draft over a catalog entry (the name prefills the type's
9281
- * label — the create's commit takes the input's name). */
9282
- function emptyColumnForm(entry) {
9283
- return {
9284
- key: entry.key,
9285
- type: entry.type,
9286
- name: entry.label,
9287
- numberKind: entry.numberKind,
9288
- decimals: entry.numberKind === "decimal" ? 2 : 0,
9289
- thousands: false,
9290
- prefix: "",
9291
- suffix: "",
9292
- allowNegative: true,
9293
- refKind: entry.refKind,
9294
- refMany: entry.refMany,
9295
- refPick: "",
9296
- newTableName: ""
9297
- };
9298
- }
9299
- //#endregion
9300
9444
  //#region src/database/grid/ColumnManager.tsx
9301
9445
  function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragStart, onDragEnd }) {
9302
9446
  const { t } = useTranslation("database");
@@ -10335,16 +10479,7 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
10335
10479
  committed.setHours(Number(hours), Number(minutes), Number(seconds));
10336
10480
  }
10337
10481
  if ((committed?.getTime() ?? null) === (openDateRef.current?.getTime() ?? null)) return;
10338
- let iso;
10339
- if (committed === null) iso = null;
10340
- else {
10341
- const base = format(committed, "yyyy-MM-dd");
10342
- if (!hasTime(committed)) iso = base;
10343
- else {
10344
- const time = format(committed, "HH:mm");
10345
- iso = committed.getSeconds() !== 0 ? `${base}T${time}:${format(committed, "ss")}` : `${base}T${time}`;
10346
- }
10347
- }
10482
+ const iso = formatCellDateTime(committed);
10348
10483
  if (iso === committedIsoRef.current) return;
10349
10484
  committedIsoRef.current = iso;
10350
10485
  onChange(iso, openRevisionRef.current);
@@ -15555,6 +15690,7 @@ function runsOf(node, inherited, raw) {
15555
15690
  const roots = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? Array.from(node.childNodes) : [node];
15556
15691
  for (const root of roots) visit(root, raw ? {} : inherited);
15557
15692
  if (node.nodeType === Node.TEXT_NODE) return runs;
15693
+ if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toUpperCase() === "BR") return runs;
15558
15694
  return dropEdgeWhitespaceRuns(runs);
15559
15695
  }
15560
15696
  /** The table's rows (the parser hoists the tr into the implicit tbody). */
@@ -31338,4 +31474,4 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
31338
31474
  });
31339
31475
  }
31340
31476
  //#endregion
31341
- export { SelectValue as $, useBlock as A, CardFooter as At, DEFAULT_EMBED_SANDBOX as B, AlertTitle as Bt, isBridgeError as C, PopoverTrigger as Ct, parseCellValue as D, CardAction as Dt, conditionMatches as E, Card as Et, useSelection as F, BareSelect as Ft, SelectContent as G, Eye as Gt, SegmentSelector as H, INLINE_CODE_CLASS as Ht, useSelectionView as I, Badge as It, SelectLabel as J, createMemoryBlobStore as Jt, SelectGroup as K, CodeXml as Kt, useText as L, badgeVariants as Lt, useMeta as M, CardTitle as Mt, usePresence as N, Button as Nt, TEXT_TYPES as O, CardContent as Ot, usePresenceSharing as P, buttonVariants as Pt, SelectTrigger as Q, EditorProvider as R, Alert as Rt, BridgeError as S, PopoverTitle as St, toBridgeError as T, Checkbox as Tt, ScrollArea as U, renderRuns as Ut, Skeleton as V, DocblocksI18nProvider as Vt, Select as W, Pen as Wt, SelectScrollUpButton as X, SelectScrollDownButton as Y, SelectSeparator as Z, BASELINE_CAPABILITIES as _, Popover as _t, SHAPE_FONT_STACKS as a, DropdownMenuItem as at, validateProtocolDescriptor as b, PopoverDescription as bt, textOf as c, DropdownMenuRadioGroup as ct, useDatabaseTable as d, DropdownMenuShortcut as dt, Label as et, cellValueEqual as f, DropdownMenuSub as ft, filterIsComplete as g, Separator as gt, emptyFilter as h, DropdownMenuTrigger as ht, SHAPE_FONT_OPTIONS as i, DropdownMenuGroup as it, useDoc as j, CardHeader as jt, columnAnnotation as k, CardDescription as kt, markToggleAction as l, DropdownMenuRadioItem as lt, FilterBuilder as m, DropdownMenuSubTrigger as mt, childrenSlot as n, DropdownMenuCheckboxItem as nt, TextBlock as o, DropdownMenuLabel as ot, newMutationContext as p, DropdownMenuSubContent as pt, SelectItem as q, BookOpen as qt, CodeHeader as r, DropdownMenuContent as rt, FORMAT_PALETTE as s, DropdownMenuPortal as st, Editor as t, DropdownMenu as tt, GridBody as u, DropdownMenuSeparator as ut, PROTOCOL_VERSION as v, PopoverAnchor as vt, isBridgeErrorCode as w, Input as wt, BRIDGE_ERROR_CODES as x, PopoverHeader as xt, isDatabaseBridge as y, PopoverContent as yt, useEditorContext as z, AlertDescription as zt };
31477
+ export { SelectScrollUpButton as $, parseCellValue as A, CardAction as At, useText as B, badgeVariants as Bt, validateProtocolDescriptor as C, PopoverDescription as Ct, isBridgeErrorCode as D, Input as Dt, isBridgeError as E, PopoverTrigger as Et, useMeta as F, CardTitle as Ft, SegmentSelector as G, INLINE_CODE_CLASS as Gt, useEditorContext as H, AlertDescription as Ht, usePresence as I, Button as It, SelectContent as J, Eye as Jt, ScrollArea as K, renderRuns as Kt, usePresenceSharing as L, buttonVariants as Lt, columnAnnotation as M, CardDescription as Mt, useBlock as N, CardFooter as Nt, toBridgeError as O, Checkbox as Ot, useDoc as P, CardHeader as Pt, SelectScrollDownButton as Q, useSelection as R, BareSelect as Rt, isDatabaseBridge as S, PopoverContent as St, BridgeError as T, PopoverTitle as Tt, DEFAULT_EMBED_SANDBOX as U, AlertTitle as Ut, EditorProvider as V, Alert as Vt, Skeleton as W, DocblocksI18nProvider as Wt, SelectItem as X, BookOpen as Xt, SelectGroup as Y, CodeXml as Yt, SelectLabel as Z, createMemoryBlobStore as Zt, FilterBuilder as _, DropdownMenuSubTrigger as _t, SHAPE_FONT_STACKS as a, DropdownMenuCheckboxItem as at, BASELINE_CAPABILITIES as b, Popover as bt, textOf as c, DropdownMenuItem as ct, insertNative as d, DropdownMenuRadioGroup as dt, SelectSeparator as et, mdToBlocks as f, DropdownMenuRadioItem as ft, newMutationContext as g, DropdownMenuSubContent as gt, cellValueEqual as h, DropdownMenuSub as ht, SHAPE_FONT_OPTIONS as i, DropdownMenu as it, TEXT_TYPES as j, CardContent as jt, conditionMatches as k, Card as kt, markToggleAction as l, DropdownMenuLabel as lt, useDatabaseTable as m, DropdownMenuShortcut as mt, childrenSlot as n, SelectValue as nt, TextBlock as o, DropdownMenuContent as ot, GridBody as p, DropdownMenuSeparator as pt, Select as q, Pen as qt, CodeHeader as r, Label as rt, FORMAT_PALETTE as s, DropdownMenuGroup as st, Editor as t, SelectTrigger as tt, htmlToBlocks as u, DropdownMenuPortal as ut, emptyFilter as v, DropdownMenuTrigger as vt, BRIDGE_ERROR_CODES as w, PopoverHeader as wt, PROTOCOL_VERSION as x, PopoverAnchor as xt, filterIsComplete as y, Separator as yt, useSelectionView as z, Badge as zt };
package/dist/index.d.mts CHANGED
@@ -259,6 +259,21 @@ declare function markToggleAction(doc: Doc, blockId: BlockId, from: number, to:
259
259
  * through the editor's `formatPalette` prop — a `string[]` of hex or var). */
260
260
  declare const FORMAT_PALETTE: readonly string[];
261
261
  //#endregion
262
+ //#region src/editing/import.d.ts
263
+ /** The import payload kind (the parser dispatch). */
264
+ type ImportKind = "markdown" | "html";
265
+ /** The document is not fresh: the import requires the empty root. */
266
+ declare class ImportDocumentError extends Error {
267
+ constructor(message: string);
268
+ }
269
+ /**
270
+ * Import a markdown / HTML payload into a fresh document (the empty root):
271
+ * the parsed blocks fill the root in one transaction (one undo step, one
272
+ * wire update). An empty (or whitespace-only) payload is a no-op. Throws
273
+ * `ImportDocumentError` when the root already has children.
274
+ */
275
+ declare function importDocument(doc: Doc, source: string, kind: ImportKind): void;
276
+ //#endregion
262
277
  //#region src/text/runs.d.ts
263
278
  /**
264
279
  * Render inline text runs with their marks (lenient reader contract:
@@ -322,7 +337,7 @@ declare function AlertDescription({ className, ...props }: React.ComponentProps<
322
337
  //#endregion
323
338
  //#region src/shared/ui/Badge.d.ts
324
339
  declare const badgeVariants: (props?: ({
325
- variant?: "default" | "destructive" | "outline" | "secondary" | "custom" | null | undefined;
340
+ variant?: "default" | "custom" | "secondary" | "destructive" | "outline" | null | undefined;
326
341
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
327
342
  declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
328
343
  asChild?: boolean;
@@ -333,7 +348,7 @@ declare function BareSelect({ className, children, ...props }: React.ComponentPr
333
348
  //#endregion
334
349
  //#region src/shared/ui/Button.d.ts
335
350
  declare const buttonVariants: (props?: ({
336
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
351
+ variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
337
352
  size?: "default" | "icon" | "sm" | "lg" | "xl" | null | undefined;
338
353
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
339
354
  declare function Button({ className, variant, size, asChild, type, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
@@ -467,4 +482,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
467
482
  //#region src/shared/ui/cn.d.ts
468
483
  declare function cn(...inputs: ClassValue[]): string;
469
484
  //#endregion
470
- export { type AccessLevel, Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, type BatchOp, type BlobMeta, type BlobRef, type BlobStore, type BlockRenderer, type BlockRendererMap, type BlockRendererProps, type BridgeColumn, type BridgeColumnAnnotation, BridgeError, type BridgeErrorCode, type BridgeTableDescription, type BridgeValueInput, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellMap, type CellValueParse, Checkbox, type Column, DEFAULT_EMBED_SANDBOX, type DatabaseBridge, DatabaseTable, type DatabaseTablePhase, type DatabaseTableProps, type DatabaseTableRow, type DatabaseTableView, DocHeader, DocblocksI18nProvider, type DocblocksI18nProviderProps, type DomainEvent, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, type EditorContextValue, type EditorMode, EditorProvider, type EditorProviderProps, type EditorView, type EmbedSandboxPolicy, FORMAT_PALETTE, FilterBuilder, type FilterConditionInput, type FilterInput, type FormatMark, type Id, Input, type IsoInstant, Label, MONO_FONT_STACK, type MentionEntry, type MentionInteractions, type MentionMark, type MentionProvider, type MutationContext, type MutationReceipt, type OperationStatus, PROTOCOL_VERSION, type PageQuery, type PageSnapshot, type PdfPreview, type PdfPreviewProps, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, type PresenceConfig, type PresenceCrypto, type PresenceIdentity, type PresencePeer, type PresenceSharing, type PresenceSharingMode, type ProtocolCapability, type ProtocolDescriptor, type ProtocolLimits, type QueryOperator, type QuerySemantics, type Revision, type RowPage, type RowWire, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, type SortInput, type SubscriptionHandle, type SubscriptionObserver, type SubscriptionStatus, type SyncEmbedRef, type SyncEmbedResolver, TEXT_TYPES, type TableDescription, type TableEnvelopeBase, type TableEvent, type TableRef, type TableSnapshot, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, type UseDatabaseTable, type UseTableList, badgeVariants, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, usePresenceSharing, useSelection, useSelectionView, useTableList, useText, validateProtocolDescriptor };
485
+ export { type AccessLevel, Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, type BatchOp, type BlobMeta, type BlobRef, type BlobStore, type BlockRenderer, type BlockRendererMap, type BlockRendererProps, type BridgeColumn, type BridgeColumnAnnotation, BridgeError, type BridgeErrorCode, type BridgeTableDescription, type BridgeValueInput, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellMap, type CellValueParse, Checkbox, type Column, DEFAULT_EMBED_SANDBOX, type DatabaseBridge, DatabaseTable, type DatabaseTablePhase, type DatabaseTableProps, type DatabaseTableRow, type DatabaseTableView, DocHeader, DocblocksI18nProvider, type DocblocksI18nProviderProps, type DomainEvent, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, type EditorContextValue, type EditorMode, EditorProvider, type EditorProviderProps, type EditorView, type EmbedSandboxPolicy, FORMAT_PALETTE, FilterBuilder, type FilterConditionInput, type FilterInput, type FormatMark, type Id, ImportDocumentError, Input, type IsoInstant, Label, MONO_FONT_STACK, type MentionEntry, type MentionInteractions, type MentionMark, type MentionProvider, type MutationContext, type MutationReceipt, type OperationStatus, PROTOCOL_VERSION, type PageQuery, type PageSnapshot, type PdfPreview, type PdfPreviewProps, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, type PresenceConfig, type PresenceCrypto, type PresenceIdentity, type PresencePeer, type PresenceSharing, type PresenceSharingMode, type ProtocolCapability, type ProtocolDescriptor, type ProtocolLimits, type QueryOperator, type QuerySemantics, type Revision, type RowPage, type RowWire, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, type SortInput, type SubscriptionHandle, type SubscriptionObserver, type SubscriptionStatus, type SyncEmbedRef, type SyncEmbedResolver, TEXT_TYPES, type TableDescription, type TableEnvelopeBase, type TableEvent, type TableRef, type TableSnapshot, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, type UseDatabaseTable, type UseTableList, badgeVariants, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, importDocument, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, usePresenceSharing, useSelection, useSelectionView, useTableList, useText, validateProtocolDescriptor };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SelectValue, A as useBlock, At as CardFooter, B as DEFAULT_EMBED_SANDBOX, Bt as AlertTitle, C as isBridgeError, Ct as PopoverTrigger, D as parseCellValue, Dt as CardAction, E as conditionMatches, Et as Card, F as useSelection, Ft as BareSelect, G as SelectContent, Gt as Eye, H as SegmentSelector, I as useSelectionView, It as Badge, J as SelectLabel, Jt as createMemoryBlobStore, K as SelectGroup, L as useText, Lt as badgeVariants, M as useMeta, Mt as CardTitle, N as usePresence, Nt as Button, O as TEXT_TYPES, Ot as CardContent, P as usePresenceSharing, Pt as buttonVariants, Q as SelectTrigger, R as EditorProvider, Rt as Alert, S as BridgeError, St as PopoverTitle, T as toBridgeError, Tt as Checkbox, U as ScrollArea, Ut as renderRuns, V as Skeleton, Vt as DocblocksI18nProvider, W as Select, Wt as Pen, X as SelectScrollUpButton, Y as SelectScrollDownButton, Z as SelectSeparator, _ as BASELINE_CAPABILITIES, _t as Popover, a as SHAPE_FONT_STACKS, at as DropdownMenuItem, b as validateProtocolDescriptor, bt as PopoverDescription, ct as DropdownMenuRadioGroup, d as useDatabaseTable, dt as DropdownMenuShortcut, et as Label, f as cellValueEqual, ft as DropdownMenuSub, g as filterIsComplete, gt as Separator, h as emptyFilter, ht as DropdownMenuTrigger, i as SHAPE_FONT_OPTIONS, it as DropdownMenuGroup, j as useDoc, jt as CardHeader, k as columnAnnotation, kt as CardDescription, l as markToggleAction, lt as DropdownMenuRadioItem, m as FilterBuilder, mt as DropdownMenuSubTrigger, nt as DropdownMenuCheckboxItem, ot as DropdownMenuLabel, p as newMutationContext, pt as DropdownMenuSubContent, q as SelectItem, qt as BookOpen, rt as DropdownMenuContent, s as FORMAT_PALETTE, st as DropdownMenuPortal, t as Editor, tt as DropdownMenu, u as GridBody, ut as DropdownMenuSeparator, v as PROTOCOL_VERSION, vt as PopoverAnchor, w as isBridgeErrorCode, wt as Input, x as BRIDGE_ERROR_CODES, xt as PopoverHeader, y as isDatabaseBridge, yt as PopoverContent, z as useEditorContext, zt as AlertDescription } from "./Editor-BM6-5TFS.mjs";
1
+ import { $ as SelectScrollUpButton, A as parseCellValue, At as CardAction, B as useText, Bt as badgeVariants, C as validateProtocolDescriptor, Ct as PopoverDescription, D as isBridgeErrorCode, Dt as Input, E as isBridgeError, Et as PopoverTrigger, F as useMeta, Ft as CardTitle, G as SegmentSelector, H as useEditorContext, Ht as AlertDescription, I as usePresence, It as Button, J as SelectContent, Jt as Eye, K as ScrollArea, Kt as renderRuns, L as usePresenceSharing, Lt as buttonVariants, M as columnAnnotation, Mt as CardDescription, N as useBlock, Nt as CardFooter, O as toBridgeError, Ot as Checkbox, P as useDoc, Pt as CardHeader, Q as SelectScrollDownButton, R as useSelection, Rt as BareSelect, S as isDatabaseBridge, St as PopoverContent, T as BridgeError, Tt as PopoverTitle, U as DEFAULT_EMBED_SANDBOX, Ut as AlertTitle, V as EditorProvider, Vt as Alert, W as Skeleton, Wt as DocblocksI18nProvider, X as SelectItem, Xt as BookOpen, Y as SelectGroup, Z as SelectLabel, Zt as createMemoryBlobStore, _ as FilterBuilder, _t as DropdownMenuSubTrigger, a as SHAPE_FONT_STACKS, at as DropdownMenuCheckboxItem, b as BASELINE_CAPABILITIES, bt as Popover, ct as DropdownMenuItem, d as insertNative, dt as DropdownMenuRadioGroup, et as SelectSeparator, f as mdToBlocks, ft as DropdownMenuRadioItem, g as newMutationContext, gt as DropdownMenuSubContent, h as cellValueEqual, ht as DropdownMenuSub, i as SHAPE_FONT_OPTIONS, it as DropdownMenu, j as TEXT_TYPES, jt as CardContent, k as conditionMatches, kt as Card, l as markToggleAction, lt as DropdownMenuLabel, m as useDatabaseTable, mt as DropdownMenuShortcut, nt as SelectValue, ot as DropdownMenuContent, p as GridBody, pt as DropdownMenuSeparator, q as Select, qt as Pen, rt as Label, s as FORMAT_PALETTE, st as DropdownMenuGroup, t as Editor, tt as SelectTrigger, u as htmlToBlocks, ut as DropdownMenuPortal, v as emptyFilter, vt as DropdownMenuTrigger, w as BRIDGE_ERROR_CODES, wt as PopoverHeader, x as PROTOCOL_VERSION, xt as PopoverAnchor, y as filterIsComplete, yt as Separator, z as useSelectionView, zt as Badge } from "./Editor-ByjnrYiw.mjs";
2
2
  import { a as preventDefault, s as cn } from "./constants-D8PSgkwi.mjs";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -712,6 +712,45 @@ function DocHeaderInner({ doc, view, onViewChange, accessLevel = "editor", mode
712
712
  });
713
713
  }
714
714
  //#endregion
715
+ //#region src/editing/import.ts
716
+ /** The document is not fresh: the import requires the empty root. */
717
+ var ImportDocumentError = class extends Error {
718
+ constructor(message) {
719
+ super(message);
720
+ this.name = "ImportDocumentError";
721
+ }
722
+ };
723
+ /**
724
+ * Import a markdown / HTML payload into a fresh document (the empty root):
725
+ * the parsed blocks fill the root in one transaction (one undo step, one
726
+ * wire update). An empty (or whitespace-only) payload is a no-op. Throws
727
+ * `ImportDocumentError` when the root already has children.
728
+ */
729
+ function importDocument(doc, source, kind) {
730
+ const rootId = doc.meta.id;
731
+ const existing = doc.getChildren(rootId);
732
+ if (existing.length > 0) throw new ImportDocumentError(`importDocument: the document is not fresh (the root has ${existing.length} children) — the import requires the empty root.`);
733
+ const parsed = kind === "markdown" ? mdToBlocks(source) : htmlToBlocks(source);
734
+ if (parsed.length === 0) return;
735
+ doc.transact(() => materializeImport(doc, parsed));
736
+ }
737
+ /**
738
+ * The materialization into the root: the blocks append in the parser's
739
+ * order (each after the previous), the indents absolute (the jump-rule
740
+ * clamp only — the insertion's `after` chain makes every landing a tail
741
+ * append, so no block is displaced).
742
+ */
743
+ function materializeImport(doc, parsed) {
744
+ const rootId = doc.meta.id;
745
+ let after;
746
+ let prevIndent = 0;
747
+ for (const block of parsed) {
748
+ const indent = after === void 0 ? 0 : Math.min(block.indent, prevIndent + 1);
749
+ after = insertNative(doc, block, rootId, after, indent);
750
+ prevIndent = indent;
751
+ }
752
+ }
753
+ //#endregion
715
754
  //#region src/fonts.ts
716
755
  /**
717
756
  * The package's font subsystem — the single place for the package's fonts.
@@ -756,4 +795,4 @@ const UI_FONT_STACK = "'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif
756
795
  */
757
796
  const MONO_FONT_STACK = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
758
797
  //#endregion
759
- export { Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, BridgeError, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DEFAULT_EMBED_SANDBOX, DatabaseTable, DocHeader, DocblocksI18nProvider, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, EditorProvider, FORMAT_PALETTE, FilterBuilder, Input, Label, MONO_FONT_STACK, PROTOCOL_VERSION, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, TEXT_TYPES, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, badgeVariants, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, usePresenceSharing, useSelection, useSelectionView, useTableList, useText, validateProtocolDescriptor };
798
+ export { Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, BridgeError, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DEFAULT_EMBED_SANDBOX, DatabaseTable, DocHeader, DocblocksI18nProvider, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, EditorProvider, FORMAT_PALETTE, FilterBuilder, ImportDocumentError, Input, Label, MONO_FONT_STACK, PROTOCOL_VERSION, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, TEXT_TYPES, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, badgeVariants, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, importDocument, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, usePresenceSharing, useSelection, useSelectionView, useTableList, useText, validateProtocolDescriptor };
@@ -1,4 +1,4 @@
1
- import { Bt as AlertTitle, Gt as Eye, H as SegmentSelector, Ht as INLINE_CODE_CLASS, Kt as CodeXml, Rt as Alert, V as Skeleton, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader, z as useEditorContext, zt as AlertDescription } from "../Editor-BM6-5TFS.mjs";
1
+ import { G as SegmentSelector, Gt as INLINE_CODE_CLASS, H as useEditorContext, Ht as AlertDescription, Jt as Eye, Ut as AlertTitle, Vt as Alert, W as Skeleton, Yt as CodeXml, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader } from "../Editor-ByjnrYiw.mjs";
2
2
  import { f as LoaderCircle, l as TriangleAlert } from "../constants-D8PSgkwi.mjs";
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docblocks-react-ui",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "React rendering + editing layer for docblocks: hooks, block renderers, caret/selection, keyboard, clipboard.",
5
5
  "type": "module",
6
6
  "license": "MIT",