docblocks-react-ui 0.4.6 → 0.5.0

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.
@@ -15,9 +15,9 @@ import * as PopoverPrimitive from "@radix-ui/react-popover";
15
15
  import * as SeparatorPrimitive from "@radix-ui/react-separator";
16
16
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
17
17
  import * as SelectPrimitive from "@radix-ui/react-select";
18
+ import { AnimatePresence, Reorder, useDragControls } from "framer-motion";
18
19
  import { createStore } from "zustand/vanilla";
19
20
  import hljs from "highlight.js/lib/core";
20
- import { AnimatePresence, Reorder, useDragControls } from "framer-motion";
21
21
  //#region src/blob-store.ts
22
22
  /** Derive the subtype from the file's mime (the consumer's `meta.subtype` wins). */
23
23
  function blobSubtypeOf(file) {
@@ -755,10 +755,21 @@ function caretOffsetIn(root, node, offset) {
755
755
  * line).
756
756
  */
757
757
  function locatePosition(root, flatOffset) {
758
- if (flatOffset <= 0) return {
759
- node: root,
760
- offset: 0
761
- };
758
+ if (flatOffset <= 0) {
759
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
760
+ let current = walker.nextNode();
761
+ while (current !== null) {
762
+ if (!isLineAnchor$1(current)) return {
763
+ node: current,
764
+ offset: 0
765
+ };
766
+ current = walker.nextNode();
767
+ }
768
+ return {
769
+ node: root,
770
+ offset: 0
771
+ };
772
+ }
762
773
  const anchor = lineAnchorOf(root);
763
774
  if (anchor !== null && root.lastElementChild === anchor && flatOffset >= textLengthOf(root)) return {
764
775
  node: root,
@@ -909,8 +920,9 @@ function liveScope(scope) {
909
920
  * structural gesture (the element must be rendered); `scope` confines the
910
921
  * lookup to one editor root (a page can render the same doc in several).
911
922
  */
912
- function focusCaretIn(blockId, offset, scope = document) {
923
+ function focusCaretIn(blockId, offset, scope = document, guard) {
913
924
  afterFrame(() => {
925
+ if (guard !== void 0 && !guard()) return;
914
926
  const el = Array.from(liveScope(scope).querySelectorAll(`[data-block-id="${CSS.escape(blockId)}"][data-slot="docblocks/block-content"]`)).find((candidate) => !candidate.closest("[data-slot=\"docblocks/frame-window-content\"]")) ?? null;
915
927
  if (el === null || !el.isConnected) return;
916
928
  el.focus();
@@ -976,6 +988,23 @@ function seatedIn(el) {
976
988
  return inOrOn(sel.anchorNode) && inOrOn(sel.focusNode);
977
989
  }
978
990
  /**
991
+ * Whether the DOM selection sits in the element AT the requested flat
992
+ * offsets (a collapsed caret at `from`, a span over [from, to)). A
993
+ * selection inside the element at a different seat (a competing re-seat's
994
+ * transient — the container's re-seat lands at the block's edge while
995
+ * the history's seat is the pre-gesture's) is not the gesture's seat:
996
+ * the watch re-seats over it instead of stopping.
997
+ */
998
+ function seatedAt(el, from, to) {
999
+ if (!seatedIn(el)) return false;
1000
+ const sel = window.getSelection();
1001
+ if (sel === null || sel.rangeCount === 0 || sel.anchorNode === null || sel.focusNode === null) return false;
1002
+ const anchorOffset = caretOffsetIn(el, sel.anchorNode, sel.anchorOffset);
1003
+ if (to === null) return anchorOffset === from;
1004
+ const focusOffset = caretOffsetIn(el, sel.focusNode, sel.focusOffset);
1005
+ return anchorOffset === from && focusOffset === to || anchorOffset === to && focusOffset === from;
1006
+ }
1007
+ /**
979
1008
  * Restore a text range (a caret when `to` is null) inside a block's inner
980
1009
  * editable after a structural gesture (a Tab/Shift+Tab indent, a list-type
981
1010
  * swap) that remounts the block's subtree: the old editable is gone and
@@ -1021,7 +1050,7 @@ function restoreSelectionIn(doc, blockId, from, to, scope = document, exclude =
1021
1050
  function attempt() {
1022
1051
  const inners = Array.from(liveScope(scope).querySelectorAll(selector)).filter((el) => el.isConnected).filter((el) => el !== exclude).filter((el) => expectedParent === null || domParentBlockIdOf(el) === expectedParent).filter((el) => isSurvivorInner(el, blockType)).filter((el) => logicalTextOf(el) === doc.getText(blockId));
1023
1052
  const el = inners.length === 1 ? inners[0] : null;
1024
- if (el !== null && seatedIn(el)) {
1053
+ if (el !== null && seatedAt(el, from, to)) {
1025
1054
  el.focus();
1026
1055
  stop();
1027
1056
  return;
@@ -1807,7 +1836,7 @@ function Badge({ className, variant, asChild = false, ...props }) {
1807
1836
  function BareSelect({ className, children, ...props }) {
1808
1837
  return /* @__PURE__ */ jsx("select", {
1809
1838
  "data-slot": "select-bare",
1810
- className: cn("h-8 rounded-md border border-border bg-transparent px-2 text-sm text-foreground outline-none", className),
1839
+ className: cn("h-8 rounded-md border border-input bg-transparent px-2 text-sm text-foreground outline-none dark:bg-input/30", className),
1811
1840
  ...props,
1812
1841
  children
1813
1842
  });
@@ -4129,985 +4158,1002 @@ function probeFor(entry) {
4129
4158
  return el;
4130
4159
  }
4131
4160
  //#endregion
4132
- //#region src/i18n/locales/en/blocks.json
4133
- var blocks_default$1 = {
4134
- row: {
4135
- "selectBlock": "Select block",
4136
- "addBlockBelow": "Add block below",
4137
- "deleteBlock": "Delete block"
4138
- },
4139
- task: {
4140
- "markDone": "Mark task as done",
4141
- "markNotDone": "Mark task as not done"
4142
- },
4143
- collapse: {
4144
- "expand": "Expand children",
4145
- "collapse": "Collapse children"
4146
- },
4147
- caption: {
4148
- "placeholder": "Write a caption…",
4149
- "edit": "Edit the caption",
4150
- "add": "Add a caption",
4151
- "aria": "Caption",
4152
- "imageAria": "Image caption"
4153
- },
4154
- code: {
4155
- "language": "Code language",
4156
- "chooseLanguage": "Choose the code language",
4157
- "searchPlaceholder": "Search language…",
4158
- "searchAria": "Search language",
4159
- "languages": "Languages",
4160
- "copy": "Copy the code",
4161
- "expand": "Expand the code",
4162
- "collapse": "Collapse the code",
4163
- "expandTitle": "Expand",
4164
- "collapseTitle": "Collapse",
4165
- "options": "Code options",
4166
- "lineNumbers": "Line numbers",
4167
- "wrap": "Wrap long lines",
4168
- "rendering": "rendering…",
4169
- "pdfPreviewUnavailable": "PDF preview unavailable ({error}). Showing the built-in viewer.",
4170
- "pdfLoading": "loading preview…",
4171
- "pdfPrevPage": "Previous page",
4172
- "pdfNextPage": "Next page",
4173
- "pdfFullscreen": "Expand to fullscreen",
4174
- "pdfCloseFullscreen": "Close fullscreen"
4175
- },
4176
- image: {
4177
- "placeholder": "image",
4178
- "document": "document",
4179
- "resize": "Resize the image",
4180
- "download": "Download the image",
4181
- "downloadTitle": "Download"
4182
- },
4183
- embed: {
4184
- "zoomIn": "Zoom in",
4185
- "zoomOut": "Zoom out",
4186
- "zoomReset": "Reset zoom",
4187
- "resizeHeight": "Resize embed height",
4188
- "editUrl": "Edit URL",
4189
- "saveUrl": "Save URL",
4190
- "cancelEdit": "Cancel",
4191
- "srcPlaceholder": "Embed URL (https://…)",
4192
- "unsafeHint": "Only absolute http(s):// URLs are supported."
4193
- },
4194
- syncEmbed: {
4195
- "broken": "The master document for this synced block is unavailable.",
4196
- "cycle": "Circular synced block reference."
4197
- },
4198
- align: {
4199
- "left": "Align left",
4200
- "center": "Align center",
4201
- "right": "Align right"
4202
- },
4203
- rowCount_one: "row",
4204
- rowCount_few: "rows",
4205
- rowCount_many: "rows",
4206
- rowCount_other: "rows",
4207
- error: { "render": "Could not be rendered" }
4208
- };
4209
- //#endregion
4210
- //#region src/i18n/locales/en/canvas.json
4211
- var canvas_default$1 = {
4212
- view: { "label": "Canvas" },
4213
- dock: {
4214
- "toolbar": "Canvas tools",
4215
- "modeSelect": "Switch to the select mode",
4216
- "modePan": "Switch to the pan mode",
4217
- "shapes": "Shapes",
4218
- "shapesMenu": "Shapes menu",
4219
- "text": "Text",
4220
- "frame": "Frame",
4221
- "container": "Container",
4222
- "connector": "Connector",
4223
- "pen": "Pen"
4224
- },
4225
- shapes: {
4226
- "rect": "Rectangle",
4227
- "rounded": "Rounded Rectangle",
4228
- "ellipse": "Ellipse",
4229
- "diamond": "Diamond",
4230
- "cylinder": "Cylinder",
4231
- "cloud": "Cloud"
4232
- },
4233
- item: {
4234
- "shape": "Shape block",
4235
- "text": "Text block",
4236
- "frame": "Frame block",
4237
- "group": "Group block",
4238
- "connector": "Connector block",
4239
- "other": "{type} block"
4240
- },
4241
- zoom: {
4242
- "toolbar": "Canvas zoom",
4243
- "fit": "Fit to screen",
4244
- "out": "Zoom out",
4245
- "in": "Zoom in",
4246
- "reset": "Reset zoom"
4247
- },
4248
- connector: {
4249
- "toolbar": "Connector options",
4250
- "labelEdit": "Connector label",
4251
- "straight": "Straight line",
4252
- "orthogonal": "Orthogonal line",
4253
- "curved": "Curved line",
4254
- "lineColor": "Line color",
4255
- "lineWidth": "Line width",
4256
- "lineWidthTitle": "Line width (1–4 px)",
4257
- "solid": "Solid line",
4258
- "dashed": "Dashed line",
4259
- "arrowheadStart": "Start arrowhead",
4260
- "arrowheadEnd": "End arrowhead",
4261
- "arrowheadsStart": "Start arrowheads",
4262
- "arrowheadsEnd": "End arrowheads",
4263
- "arrowheadArrow": "Arrow",
4264
- "arrowheadCircle": "Circle",
4265
- "arrowheadNone": "None",
4266
- "arrange": "Arrange line"
4267
- },
4268
- shape: {
4269
- "toolbar": "Shape options",
4270
- "type": "Shape type",
4271
- "types": "Shape types",
4272
- "addText": "Add text",
4273
- "addTextTitle": "Add text (or double-click the shape)",
4274
- "fillColor": "Shape fill color",
4275
- "strokeColor": "Shape stroke color",
4276
- "borderWidth": "Shape border width",
4277
- "borderWidthTitle": "Border width (1–4 px)",
4278
- "borderStyle": "Shape border style",
4279
- "borderStyleTitle": "Border style",
4280
- "borderStyles": "Border styles",
4281
- "solid": "Solid line",
4282
- "dashed": "Dashed",
4283
- "borderNone": "No border",
4284
- "arrange": "Arrange shape"
4285
- },
4286
- zorder: {
4287
- "title": "Arrange (z-order)",
4288
- "bringForward": "Bring forward",
4289
- "bringToFront": "Bring to front",
4290
- "sendBackward": "Send backward",
4291
- "sendToBack": "Send to back"
4292
- },
4293
- text: {
4294
- "toolbar": "Text options",
4295
- "arrange": "Arrange text",
4296
- "fontFamily": "Text font family",
4297
- "color": "Text color",
4298
- "style": "Text style",
4299
- "fontSize": "Text font size",
4300
- "alignLeft": "Align left",
4301
- "alignCenter": "Align center",
4302
- "alignRight": "Align right"
4303
- },
4304
- titleChip: {
4305
- "button": "Title",
4306
- "setContainerTitle": "Set container title",
4307
- "setFrameTitle": "Set frame title",
4308
- "containerTitle": "Container title",
4309
- "frameTitle": "Frame title"
4310
- },
4311
- colorHex: "{label} hex value"
4312
- };
4313
- //#endregion
4314
- //#region src/i18n/locales/en/common.json
4315
- var common_default$1 = {
4316
- copy: "Copy",
4317
- "delete": "Delete",
4318
- rename: "Rename",
4319
- clear: "Clear",
4320
- duplicate: "Duplicate",
4321
- paste: "Paste",
4322
- options: "Options",
4323
- moreOptions: "More options",
4324
- untitled: "Untitled",
4325
- noMatches: "No matches",
4326
- noOptions: "No options.",
4327
- newTable: "New table…",
4328
- search: "Search…",
4329
- color: {
4330
- "custom": "Custom color",
4331
- "none": "No color"
4332
- },
4333
- access: {
4334
- "notPublished": "This document has not been published yet.",
4335
- "notPublishedHint": "Readers see the document only after it has been published."
4336
- },
4337
- colorPicker: {
4338
- "aria": "Color picker",
4339
- "hexAria": "Hex color value"
4340
- }
4341
- };
4342
- //#endregion
4343
- //#region src/i18n/locales/en/database.json
4344
- var database_default$1 = {
4345
- state: {
4346
- "loading": "Loading the table…",
4347
- "notFound": "Table not found",
4348
- "unknownTable": "The table \"{tableId}\" is unknown to the bridge.",
4349
- "retry": "Retry"
4350
- },
4351
- rowCount_one: "row",
4352
- rowCount_few: "rows",
4353
- rowCount_many: "rows",
4354
- rowCount_other: "rows",
4355
- toolbar: {
4356
- "undo": "Undo",
4357
- "redo": "Redo",
4358
- "filter": "Filter",
4359
- "apply": "Apply"
4360
- },
4361
- columnTypes: {
4362
- "text": "Text",
4363
- "integer": "Integer",
4364
- "decimal": "Decimal",
4365
- "checkbox": "Checkbox",
4366
- "date": "Date",
4367
- "datetime": "Date & time",
4368
- "enum": "Enum",
4369
- "multiEnum": "Multi-enum",
4370
- "rowLink": "Row link",
4371
- "rowLinks": "Row links"
4372
- },
4373
- form: {
4374
- "name": "Name",
4375
- "decimals": "Decimals",
4376
- "thousandsSeparator": "Thousands' separator",
4377
- "prefix": "Prefix",
4378
- "suffix": "Suffix",
4379
- "allowNegative": "Allow negative",
4380
- "table": "Table",
4381
- "selectTable": "— Select a table —",
4382
- "newTableName": "New table name",
4383
- "save": "Save",
4384
- "addColumn": "Add column"
4385
- },
4386
- "enum": {
4387
- "options": "Options",
4388
- "optionColor": "Option's color",
4389
- "optionColorAria": "option color",
4390
- "optionPlaceholder": "Option",
4391
- "addOption": "+ Add option"
4392
- },
4393
- header: {
4394
- "editOptions": "Edit options",
4395
- "show": "Show column",
4396
- "hide": "Hide column",
4397
- "delete": "Delete column"
4398
- },
4399
- row: {
4400
- "moveUp": "Move up",
4401
- "moveDown": "Move down",
4402
- "delete": "Delete row"
4403
- },
4404
- rows: {
4405
- "loadMore": "Load more rows",
4406
- "none": "No rows.",
4407
- "noneFiltered": "No rows match the filter.",
4408
- "add": "+ Add row"
4409
- },
4410
- filter: {
4411
- "empty": "No columns to filter on.",
4412
- "logic": "Filter logic",
4413
- "matchAll": "match all of the conditions",
4414
- "matchAny": "match any of the conditions",
4415
- "nestedGroup": "{logic} nested group",
4416
- "removeGroup": "Remove group",
4417
- "condition": "+ Condition",
4418
- "group": "+ Group",
4419
- "valuePlaceholder": "value, value"
4420
- },
4421
- picker: {
4422
- "searchOptions": "Search options",
4423
- "searchRows": "Search rows"
4424
- },
4425
- disconnected: {
4426
- "name": "Database",
4427
- "note": "database not connected"
4428
- }
4429
- };
4430
- //#endregion
4431
- //#region src/i18n/locales/en/editor.json
4432
- var editor_default$1 = {
4433
- docHeader: {
4434
- "pageView": "Page view",
4435
- "canvasView": "Canvas view",
4436
- "documentViewAria": "Document view",
4437
- "editMode": "Edit mode",
4438
- "viewMode": "View mode",
4439
- "published": "Published",
4440
- "documentModeAria": "Document mode",
4441
- "documentAvatarAria": "Document avatar",
4442
- "editAvatarAria": "Edit the document avatar",
4443
- "editAvatar": "Edit the avatar",
4444
- "documentTitleAria": "Document title",
4445
- "editTitleAria": "Edit the document title",
4446
- "editTitle": "Edit the title"
4447
- },
4448
- formatToolbar: {
4449
- "aria": "Text formatting",
4450
- "marks": {
4451
- "bold": "Bold",
4452
- "code": "Monospace",
4453
- "italic": "Italic",
4454
- "underline": "Underline",
4455
- "strike": "Strikethrough"
4456
- },
4457
- "align": {
4458
- "left": "Align left",
4459
- "center": "Align center",
4460
- "right": "Align right"
4461
- },
4462
- "listType": "List type",
4463
- "lists": {
4464
- "bullet": "Bullet list",
4465
- "number": "Numbered list",
4466
- "task": "To-do list",
4467
- "quote": "Quote",
4468
- "paragraph": "Text"
4469
- },
4470
- "callout": {
4471
- "typeAria": "Callout type",
4472
- "variant": "{variant} callout",
4473
- "iconAria": "Callout icon"
4474
- },
4475
- "color": {
4476
- "trigger": "Text and background color",
4477
- "targetGroupAria": "Color target",
4478
- "highlightAria": "Highlight the background",
4479
- "textAria": "Color the text",
4480
- "highlightLabel": "bg",
4481
- "textLabel": "text"
4161
+ //#region src/i18n/instance.ts
4162
+ /** The i18next init's options over the package's catalogs (the inline resources resolve synchronously — the instance is ready by the first render). */
4163
+ const INIT_OPTIONS = {
4164
+ resources: {
4165
+ en: {
4166
+ blocks: {
4167
+ row: {
4168
+ "selectBlock": "Select block",
4169
+ "addBlockBelow": "Add block below",
4170
+ "deleteBlock": "Delete block"
4171
+ },
4172
+ task: {
4173
+ "markDone": "Mark task as done",
4174
+ "markNotDone": "Mark task as not done"
4175
+ },
4176
+ collapse: {
4177
+ "expand": "Expand children",
4178
+ "collapse": "Collapse children"
4179
+ },
4180
+ caption: {
4181
+ "placeholder": "Write a caption…",
4182
+ "edit": "Edit the caption",
4183
+ "add": "Add a caption",
4184
+ "aria": "Caption",
4185
+ "imageAria": "Image caption"
4186
+ },
4187
+ code: {
4188
+ "language": "Code language",
4189
+ "chooseLanguage": "Choose the code language",
4190
+ "searchPlaceholder": "Search language…",
4191
+ "searchAria": "Search language",
4192
+ "languages": "Languages",
4193
+ "copy": "Copy the code",
4194
+ "expand": "Expand the code",
4195
+ "collapse": "Collapse the code",
4196
+ "expandTitle": "Expand",
4197
+ "collapseTitle": "Collapse",
4198
+ "options": "Code options",
4199
+ "lineNumbers": "Line numbers",
4200
+ "wrap": "Wrap long lines",
4201
+ "rendering": "rendering…",
4202
+ "pdfPreviewUnavailable": "PDF preview unavailable ({error}). Showing the built-in viewer.",
4203
+ "pdfLoading": "loading preview…",
4204
+ "pdfPrevPage": "Previous page",
4205
+ "pdfNextPage": "Next page",
4206
+ "pdfFullscreen": "Expand to fullscreen",
4207
+ "pdfCloseFullscreen": "Close fullscreen"
4208
+ },
4209
+ image: {
4210
+ "placeholder": "image",
4211
+ "document": "document",
4212
+ "resize": "Resize the image",
4213
+ "download": "Download the image",
4214
+ "downloadTitle": "Download"
4215
+ },
4216
+ embed: {
4217
+ "zoomIn": "Zoom in",
4218
+ "zoomOut": "Zoom out",
4219
+ "zoomReset": "Reset zoom",
4220
+ "resizeHeight": "Resize embed height",
4221
+ "editUrl": "Edit URL",
4222
+ "saveUrl": "Save URL",
4223
+ "cancelEdit": "Cancel",
4224
+ "srcPlaceholder": "Embed URL (https://…)",
4225
+ "unsafeHint": "Only absolute http(s):// URLs are supported."
4226
+ },
4227
+ syncEmbed: {
4228
+ "broken": "The master document for this synced block is unavailable.",
4229
+ "cycle": "Circular synced block reference."
4230
+ },
4231
+ align: {
4232
+ "left": "Align left",
4233
+ "center": "Align center",
4234
+ "right": "Align right"
4235
+ },
4236
+ rowCount_one: "row",
4237
+ rowCount_few: "rows",
4238
+ rowCount_many: "rows",
4239
+ rowCount_other: "rows",
4240
+ error: { "render": "Could not be rendered" }
4241
+ },
4242
+ canvas: {
4243
+ view: { "label": "Canvas" },
4244
+ dock: {
4245
+ "toolbar": "Canvas tools",
4246
+ "modeSelect": "Switch to the select mode",
4247
+ "modePan": "Switch to the pan mode",
4248
+ "shapes": "Shapes",
4249
+ "shapesMenu": "Shapes menu",
4250
+ "text": "Text",
4251
+ "frame": "Frame",
4252
+ "container": "Container",
4253
+ "connector": "Connector",
4254
+ "pen": "Pen"
4255
+ },
4256
+ shapes: {
4257
+ "rect": "Rectangle",
4258
+ "rounded": "Rounded Rectangle",
4259
+ "ellipse": "Ellipse",
4260
+ "diamond": "Diamond",
4261
+ "cylinder": "Cylinder",
4262
+ "cloud": "Cloud"
4263
+ },
4264
+ item: {
4265
+ "shape": "Shape block",
4266
+ "text": "Text block",
4267
+ "frame": "Frame block",
4268
+ "group": "Group block",
4269
+ "connector": "Connector block",
4270
+ "other": "{type} block"
4271
+ },
4272
+ zoom: {
4273
+ "toolbar": "Canvas zoom",
4274
+ "fit": "Fit to screen",
4275
+ "out": "Zoom out",
4276
+ "in": "Zoom in",
4277
+ "reset": "Reset zoom"
4278
+ },
4279
+ connector: {
4280
+ "toolbar": "Connector options",
4281
+ "labelEdit": "Connector label",
4282
+ "straight": "Straight line",
4283
+ "orthogonal": "Orthogonal line",
4284
+ "curved": "Curved line",
4285
+ "lineColor": "Line color",
4286
+ "lineWidth": "Line width",
4287
+ "lineWidthTitle": "Line width (1–4 px)",
4288
+ "solid": "Solid line",
4289
+ "dashed": "Dashed line",
4290
+ "arrowheadStart": "Start arrowhead",
4291
+ "arrowheadEnd": "End arrowhead",
4292
+ "arrowheadsStart": "Start arrowheads",
4293
+ "arrowheadsEnd": "End arrowheads",
4294
+ "arrowheadArrow": "Arrow",
4295
+ "arrowheadCircle": "Circle",
4296
+ "arrowheadNone": "None",
4297
+ "arrange": "Arrange line"
4298
+ },
4299
+ shape: {
4300
+ "toolbar": "Shape options",
4301
+ "type": "Shape type",
4302
+ "types": "Shape types",
4303
+ "addText": "Add text",
4304
+ "addTextTitle": "Add text (or double-click the shape)",
4305
+ "fillColor": "Shape fill color",
4306
+ "strokeColor": "Shape stroke color",
4307
+ "borderWidth": "Shape border width",
4308
+ "borderWidthTitle": "Border width (1–4 px)",
4309
+ "borderStyle": "Shape border style",
4310
+ "borderStyleTitle": "Border style",
4311
+ "borderStyles": "Border styles",
4312
+ "solid": "Solid line",
4313
+ "dashed": "Dashed",
4314
+ "borderNone": "No border",
4315
+ "arrange": "Arrange shape"
4316
+ },
4317
+ zorder: {
4318
+ "title": "Arrange (z-order)",
4319
+ "bringForward": "Bring forward",
4320
+ "bringToFront": "Bring to front",
4321
+ "sendBackward": "Send backward",
4322
+ "sendToBack": "Send to back"
4323
+ },
4324
+ text: {
4325
+ "toolbar": "Text options",
4326
+ "arrange": "Arrange text",
4327
+ "fontFamily": "Text font family",
4328
+ "color": "Text color",
4329
+ "style": "Text style",
4330
+ "fontSize": "Text font size",
4331
+ "alignLeft": "Align left",
4332
+ "alignCenter": "Align center",
4333
+ "alignRight": "Align right"
4334
+ },
4335
+ titleChip: {
4336
+ "button": "Title",
4337
+ "setContainerTitle": "Set container title",
4338
+ "setFrameTitle": "Set frame title",
4339
+ "containerTitle": "Container title",
4340
+ "frameTitle": "Frame title"
4341
+ },
4342
+ colorHex: "{label} hex value"
4343
+ },
4344
+ common: {
4345
+ copy: "Copy",
4346
+ "delete": "Delete",
4347
+ rename: "Rename",
4348
+ clear: "Clear",
4349
+ duplicate: "Duplicate",
4350
+ paste: "Paste",
4351
+ options: "Options",
4352
+ moreOptions: "More options",
4353
+ untitled: "Untitled",
4354
+ noMatches: "No matches",
4355
+ noOptions: "No options.",
4356
+ newTable: "New table…",
4357
+ search: "Search…",
4358
+ color: {
4359
+ "custom": "Custom color",
4360
+ "none": "No color"
4361
+ },
4362
+ access: {
4363
+ "notPublished": "This document has not been published yet.",
4364
+ "notPublishedHint": "Readers see the document only after it has been published."
4365
+ },
4366
+ colorPicker: {
4367
+ "aria": "Color picker",
4368
+ "hexAria": "Hex color value"
4369
+ }
4370
+ },
4371
+ database: {
4372
+ state: {
4373
+ "loading": "Loading the table…",
4374
+ "notFound": "Table not found",
4375
+ "unknownTable": "The table \"{tableId}\" is unknown to the bridge.",
4376
+ "retry": "Retry"
4377
+ },
4378
+ rowCount_one: "row",
4379
+ rowCount_few: "rows",
4380
+ rowCount_many: "rows",
4381
+ rowCount_other: "rows",
4382
+ toolbar: {
4383
+ "undo": "Undo",
4384
+ "redo": "Redo",
4385
+ "filter": "Filter",
4386
+ "columns": "Columns",
4387
+ "apply": "Apply"
4388
+ },
4389
+ columns: {
4390
+ "move": "Move {name}",
4391
+ "visibility": "Show {name}"
4392
+ },
4393
+ columnTypes: {
4394
+ "text": "Text",
4395
+ "integer": "Integer",
4396
+ "decimal": "Decimal",
4397
+ "checkbox": "Checkbox",
4398
+ "date": "Date",
4399
+ "datetime": "Date & time",
4400
+ "enum": "Enum",
4401
+ "multiEnum": "Multi-enum",
4402
+ "rowLink": "Row link",
4403
+ "rowLinks": "Row links"
4404
+ },
4405
+ form: {
4406
+ "name": "Name",
4407
+ "decimals": "Decimals",
4408
+ "thousandsSeparator": "Thousands' separator",
4409
+ "prefix": "Prefix",
4410
+ "suffix": "Suffix",
4411
+ "allowNegative": "Allow negative",
4412
+ "table": "Table",
4413
+ "selectTable": "— Select a table —",
4414
+ "newTableName": "New table name",
4415
+ "save": "Save",
4416
+ "addColumn": "Add column"
4417
+ },
4418
+ "enum": {
4419
+ "options": "Options",
4420
+ "optionColor": "Option's color",
4421
+ "optionColorAria": "option color",
4422
+ "optionPlaceholder": "Option",
4423
+ "addOption": "+ Add option"
4424
+ },
4425
+ header: {
4426
+ "editOptions": "Edit options",
4427
+ "show": "Show column",
4428
+ "hide": "Hide column",
4429
+ "delete": "Delete column"
4430
+ },
4431
+ row: {
4432
+ "moveUp": "Move up",
4433
+ "moveDown": "Move down",
4434
+ "delete": "Delete row"
4435
+ },
4436
+ rows: {
4437
+ "loadMore": "Load more rows",
4438
+ "none": "No rows.",
4439
+ "noneFiltered": "No rows match the filter.",
4440
+ "add": "+ Add row"
4441
+ },
4442
+ filter: {
4443
+ "empty": "No columns to filter on.",
4444
+ "logic": "Filter logic",
4445
+ "and": "AND",
4446
+ "or": "OR",
4447
+ "matchAll": "match all of the conditions",
4448
+ "matchAny": "match any of the conditions",
4449
+ "removeGroup": "Remove group",
4450
+ "condition": "+ Condition",
4451
+ "group": "+ Group",
4452
+ "groupHeader": "Group {index}",
4453
+ "removeCondition": "Remove condition",
4454
+ "valuePlaceholder": "value, value"
4455
+ },
4456
+ picker: {
4457
+ "searchOptions": "Search options",
4458
+ "searchRows": "Search rows"
4459
+ },
4460
+ disconnected: {
4461
+ "name": "Database",
4462
+ "note": "database not connected"
4463
+ }
4464
+ },
4465
+ editor: {
4466
+ docHeader: {
4467
+ "pageView": "Page view",
4468
+ "canvasView": "Canvas view",
4469
+ "documentViewAria": "Document view",
4470
+ "editMode": "Edit mode",
4471
+ "viewMode": "View mode",
4472
+ "published": "Published",
4473
+ "documentModeAria": "Document mode",
4474
+ "documentAvatarAria": "Document avatar",
4475
+ "editAvatarAria": "Edit the document avatar",
4476
+ "editAvatar": "Edit the avatar",
4477
+ "documentTitleAria": "Document title",
4478
+ "editTitleAria": "Edit the document title",
4479
+ "editTitle": "Edit the title"
4480
+ },
4481
+ formatToolbar: {
4482
+ "aria": "Text formatting",
4483
+ "marks": {
4484
+ "bold": "Bold",
4485
+ "code": "Monospace",
4486
+ "italic": "Italic",
4487
+ "underline": "Underline",
4488
+ "strike": "Strikethrough"
4489
+ },
4490
+ "align": {
4491
+ "left": "Align left",
4492
+ "center": "Align center",
4493
+ "right": "Align right"
4494
+ },
4495
+ "listType": "List type",
4496
+ "lists": {
4497
+ "bullet": "Bullet list",
4498
+ "number": "Numbered list",
4499
+ "task": "To-do list",
4500
+ "quote": "Quote",
4501
+ "paragraph": "Text"
4502
+ },
4503
+ "callout": {
4504
+ "typeAria": "Callout type",
4505
+ "variant": "{variant} callout",
4506
+ "iconAria": "Callout icon"
4507
+ },
4508
+ "color": {
4509
+ "trigger": "Text and background color",
4510
+ "targetGroupAria": "Color target",
4511
+ "highlightAria": "Highlight the background",
4512
+ "textAria": "Color the text",
4513
+ "highlightLabel": "bg",
4514
+ "textLabel": "text"
4515
+ },
4516
+ "palette": {
4517
+ "callout": "callout",
4518
+ "highlight": "highlight",
4519
+ "text": "text"
4520
+ }
4521
+ },
4522
+ mention: {
4523
+ "searching": "Searching…",
4524
+ "people": "People",
4525
+ "documents": "Documents",
4526
+ "error": "Couldn't load mention results.",
4527
+ "retry": "Retry"
4528
+ },
4529
+ shared: {
4530
+ "swatch": "{label} color {index}",
4531
+ "emojiPickerGroup": "Avatar emoji",
4532
+ "removeAvatar": "Remove avatar",
4533
+ "clearTime": "Clear the time"
4534
+ }
4535
+ },
4536
+ frame: { page: {
4537
+ "missing": "Frame not found",
4538
+ "windowLabel": "Frame",
4539
+ "windowTitle": "Frame: {title}"
4540
+ } },
4541
+ slash: {
4542
+ blocks: {
4543
+ "text": "Text",
4544
+ "heading1": "Heading 1",
4545
+ "heading2": "Heading 2",
4546
+ "heading3": "Heading 3",
4547
+ "quote": "Quote",
4548
+ "callout": "Callout",
4549
+ "code": "Code block",
4550
+ "codeMermaid": "Code block (mermaid)",
4551
+ "divider": "Divider",
4552
+ "file": "File",
4553
+ "embed": "Embed",
4554
+ "database": "Database",
4555
+ "frame": "Frame",
4556
+ "table": "Table"
4557
+ },
4558
+ lists: {
4559
+ "bulleted": "Bulleted list",
4560
+ "numbered": "Numbered list",
4561
+ "task": "Task list"
4562
+ },
4563
+ database: {
4564
+ "newTable": "New table",
4565
+ "namePlaceholder": "New table name",
4566
+ "searchPlaceholder": "Search tables…",
4567
+ "loading": "Loading the tables…",
4568
+ "noMatch": "No tables match",
4569
+ "empty": "No tables yet — create one above."
4570
+ },
4571
+ frame: {
4572
+ "fallback": "Frame",
4573
+ "searchAria": "Search frames",
4574
+ "searchPlaceholder": "Search frames...",
4575
+ "noMatch": "No frames match",
4576
+ "empty": "No frames on the canvas yet"
4577
+ },
4578
+ embed: {
4579
+ "urlPlaceholder": "Embed URL (https://…)",
4580
+ "unsafeHint": "Only absolute http(s):// URLs are supported."
4581
+ }
4582
+ },
4583
+ table: {
4584
+ handle: {
4585
+ "columnOptions": "Column {index} options",
4586
+ "rowOptions": "Row {index} options",
4587
+ "columnMenu": "Column options",
4588
+ "rowMenu": "Row options"
4589
+ },
4590
+ menu: {
4591
+ "background": "Background",
4592
+ "backgroundSwatch": "Background {color}",
4593
+ "removeBackground": "Remove background",
4594
+ "insertRight": "Insert right",
4595
+ "insertLeft": "Insert left",
4596
+ "insertBelow": "Insert below",
4597
+ "insertAbove": "Insert above",
4598
+ "moveRight": "Move right",
4599
+ "moveLeft": "Move left",
4600
+ "moveDown": "Move down",
4601
+ "moveUp": "Move up",
4602
+ "clearContent": "Clear content"
4603
+ },
4604
+ resize: { "column": "Resize column {index}" },
4605
+ add: {
4606
+ "column": "Add column",
4607
+ "row": "Add row"
4608
+ },
4609
+ cell: { "options": "Cell options" }
4610
+ }
4482
4611
  },
4483
- "palette": {
4484
- "callout": "callout",
4485
- "highlight": "highlight",
4486
- "text": "text"
4612
+ ru: {
4613
+ blocks: {
4614
+ row: {
4615
+ "selectBlock": "Выбрать блок",
4616
+ "addBlockBelow": "Добавить блок ниже",
4617
+ "deleteBlock": "Удалить блок"
4618
+ },
4619
+ task: {
4620
+ "markDone": "Отметить задачу выполненной",
4621
+ "markNotDone": "Снять отметку о выполнении"
4622
+ },
4623
+ collapse: {
4624
+ "expand": "Развернуть вложенные блоки",
4625
+ "collapse": "Свернуть вложенные блоки"
4626
+ },
4627
+ caption: {
4628
+ "placeholder": "Напишите подпись…",
4629
+ "edit": "Изменить подпись",
4630
+ "add": "Добавить подпись",
4631
+ "aria": "Подпись",
4632
+ "imageAria": "Подпись к изображению"
4633
+ },
4634
+ code: {
4635
+ "language": "Язык кода",
4636
+ "chooseLanguage": "Выбрать язык кода",
4637
+ "searchPlaceholder": "Поиск языка…",
4638
+ "searchAria": "Поиск языка",
4639
+ "languages": "Языки",
4640
+ "copy": "Копировать код",
4641
+ "expand": "Развернуть код",
4642
+ "collapse": "Свернуть код",
4643
+ "expandTitle": "Развернуть",
4644
+ "collapseTitle": "Свернуть",
4645
+ "options": "Настройки кода",
4646
+ "lineNumbers": "Номера строк",
4647
+ "wrap": "Переносить длинные строки",
4648
+ "rendering": "Рисование…",
4649
+ "pdfPreviewUnavailable": "Превью PDF недоступно ({error}). Показан встроенный просмотрщик.",
4650
+ "pdfLoading": "Загрузка превью…",
4651
+ "pdfPrevPage": "Предыдущая страница",
4652
+ "pdfNextPage": "Следующая страница",
4653
+ "pdfFullscreen": "Развернуть на весь экран",
4654
+ "pdfCloseFullscreen": "Закрыть полноэкранный режим"
4655
+ },
4656
+ image: {
4657
+ "placeholder": "изображение",
4658
+ "document": "документ",
4659
+ "resize": "Изменить размер изображения",
4660
+ "download": "Скачать изображение",
4661
+ "downloadTitle": "Скачать"
4662
+ },
4663
+ embed: {
4664
+ "zoomIn": "Приблизить",
4665
+ "zoomOut": "Отдалить",
4666
+ "zoomReset": "Сбросить масштаб",
4667
+ "resizeHeight": "Изменить высоту встраивания",
4668
+ "editUrl": "Изменить ссылку",
4669
+ "saveUrl": "Сохранить ссылку",
4670
+ "cancelEdit": "Отмена",
4671
+ "srcPlaceholder": "URL встраивания (https://…)",
4672
+ "unsafeHint": "Поддерживаются только абсолютные URL http(s)://."
4673
+ },
4674
+ syncEmbed: {
4675
+ "broken": "Мастер-документ для этого синхронизируемого блока недоступен.",
4676
+ "cycle": "Циклическая ссылка синхронизируемого блока."
4677
+ },
4678
+ align: {
4679
+ "left": "Выровнять по левому краю",
4680
+ "center": "Выровнять по центру",
4681
+ "right": "Выровнять по правому краю"
4682
+ },
4683
+ rowCount_one: "строка",
4684
+ rowCount_few: "строки",
4685
+ rowCount_many: "строк",
4686
+ rowCount_other: "строк",
4687
+ error: { "render": "Не удалось отобразить" }
4688
+ },
4689
+ canvas: {
4690
+ view: { "label": "Холст" },
4691
+ dock: {
4692
+ "toolbar": "Инструменты холста",
4693
+ "modeSelect": "Переключиться в режим выделения",
4694
+ "modePan": "Переключиться в режим перемещения",
4695
+ "shapes": "Фигуры",
4696
+ "shapesMenu": "Меню фигур",
4697
+ "text": "Текст",
4698
+ "frame": "Фрейм",
4699
+ "container": "Контейнер",
4700
+ "connector": "Соединитель",
4701
+ "pen": "Ручка"
4702
+ },
4703
+ shapes: {
4704
+ "rect": "Прямоугольник",
4705
+ "rounded": "Скруглённый прямоугольник",
4706
+ "ellipse": "Эллипс",
4707
+ "diamond": "Ромб",
4708
+ "cylinder": "Цилиндр",
4709
+ "cloud": "Облако"
4710
+ },
4711
+ item: {
4712
+ "shape": "Фигура",
4713
+ "text": "Текст",
4714
+ "frame": "Фрейм",
4715
+ "group": "Группа",
4716
+ "connector": "Соединитель",
4717
+ "other": "Блок {type}"
4718
+ },
4719
+ zoom: {
4720
+ "toolbar": "Масштаб холста",
4721
+ "fit": "Вписать в экран",
4722
+ "out": "Уменьшить масштаб",
4723
+ "in": "Увеличить масштаб",
4724
+ "reset": "Сбросить масштаб"
4725
+ },
4726
+ connector: {
4727
+ "toolbar": "Настройки соединителя",
4728
+ "labelEdit": "Подпись соединителя",
4729
+ "straight": "Прямая линия",
4730
+ "orthogonal": "Ортогональная линия",
4731
+ "curved": "Кривая линия",
4732
+ "lineColor": "Цвет линии",
4733
+ "lineWidth": "Толщина линии",
4734
+ "lineWidthTitle": "Толщина линии (1–4 px)",
4735
+ "solid": "Сплошная линия",
4736
+ "dashed": "Пунктирная линия",
4737
+ "arrowheadStart": "Стрелка начала",
4738
+ "arrowheadEnd": "Стрелка конца",
4739
+ "arrowheadsStart": "Стрелки начала",
4740
+ "arrowheadsEnd": "Стрелки конца",
4741
+ "arrowheadArrow": "Стрела",
4742
+ "arrowheadCircle": "Круг",
4743
+ "arrowheadNone": "Нет",
4744
+ "arrange": "Упорядочить линию"
4745
+ },
4746
+ shape: {
4747
+ "toolbar": "Настройки фигуры",
4748
+ "type": "Тип фигуры",
4749
+ "types": "Типы фигур",
4750
+ "addText": "Добавить текст",
4751
+ "addTextTitle": "Добавить текст (или двойной клик по фигуре)",
4752
+ "fillColor": "Цвет заливки фигуры",
4753
+ "strokeColor": "Цвет обводки фигуры",
4754
+ "borderWidth": "Толщина рамки фигуры",
4755
+ "borderWidthTitle": "Толщина рамки (1–4 px)",
4756
+ "borderStyle": "Стиль рамки фигуры",
4757
+ "borderStyleTitle": "Стиль рамки",
4758
+ "borderStyles": "Стили рамки",
4759
+ "solid": "Сплошная линия",
4760
+ "dashed": "Пунктир",
4761
+ "borderNone": "Без рамки",
4762
+ "arrange": "Упорядочить фигуру"
4763
+ },
4764
+ zorder: {
4765
+ "title": "Порядок (z-order)",
4766
+ "bringForward": "Выше",
4767
+ "bringToFront": "На передний план",
4768
+ "sendBackward": "Ниже",
4769
+ "sendToBack": "На задний план"
4770
+ },
4771
+ text: {
4772
+ "toolbar": "Настройки текста",
4773
+ "arrange": "Упорядочить текст",
4774
+ "fontFamily": "Шрифт текста",
4775
+ "color": "Цвет текста",
4776
+ "style": "Стиль текста",
4777
+ "fontSize": "Размер шрифта",
4778
+ "alignLeft": "Выровнять по левому краю",
4779
+ "alignCenter": "Выровнять по центру",
4780
+ "alignRight": "Выровнять по правому краю"
4781
+ },
4782
+ titleChip: {
4783
+ "button": "Заголовок",
4784
+ "setContainerTitle": "Установить заголовок контейнера",
4785
+ "setFrameTitle": "Установить заголовок фрейма",
4786
+ "containerTitle": "Заголовок контейнера",
4787
+ "frameTitle": "Заголовок фрейма"
4788
+ },
4789
+ colorHex: "{label} — HEX-значение"
4790
+ },
4791
+ common: {
4792
+ copy: "Копировать",
4793
+ "delete": "Удалить",
4794
+ rename: "Переименовать",
4795
+ clear: "Очистить",
4796
+ duplicate: "Дублировать",
4797
+ paste: "Вставить",
4798
+ options: "Параметры",
4799
+ moreOptions: "Ещё",
4800
+ untitled: "Без названия",
4801
+ noMatches: "Нет совпадений",
4802
+ noOptions: "Нет вариантов.",
4803
+ newTable: "Новая таблица…",
4804
+ search: "Поиск…",
4805
+ color: {
4806
+ "custom": "Свой цвет",
4807
+ "none": "Без цвета"
4808
+ },
4809
+ access: {
4810
+ "notPublished": "Документ ещё не опубликован.",
4811
+ "notPublishedHint": "Читатели увидят документ только после публикации."
4812
+ },
4813
+ colorPicker: {
4814
+ "aria": "Выбор цвета",
4815
+ "hexAria": "Цвет в hex-формате"
4816
+ }
4817
+ },
4818
+ database: {
4819
+ state: {
4820
+ "loading": "Загрузка таблицы…",
4821
+ "notFound": "Таблица не найдена",
4822
+ "unknownTable": "Таблица \"{tableId}\" не найдена в базе данных.",
4823
+ "retry": "Повторить"
4824
+ },
4825
+ rowCount_one: "строка",
4826
+ rowCount_few: "строки",
4827
+ rowCount_many: "строк",
4828
+ rowCount_other: "строк",
4829
+ toolbar: {
4830
+ "undo": "Отменить",
4831
+ "redo": "Повторить",
4832
+ "filter": "Фильтр",
4833
+ "columns": "Колонки",
4834
+ "apply": "Применить"
4835
+ },
4836
+ columns: {
4837
+ "move": "Переместить {name}",
4838
+ "visibility": "Показать {name}"
4839
+ },
4840
+ columnTypes: {
4841
+ "text": "Текст",
4842
+ "integer": "Целое",
4843
+ "decimal": "Дробное",
4844
+ "checkbox": "Флажок",
4845
+ "date": "Дата",
4846
+ "datetime": "Дата и время",
4847
+ "enum": "Перечисление",
4848
+ "multiEnum": "Множественное перечисление",
4849
+ "rowLink": "Ссылка на строку",
4850
+ "rowLinks": "Ссылки на строки"
4851
+ },
4852
+ form: {
4853
+ "name": "Название",
4854
+ "decimals": "Десятичные знаки",
4855
+ "thousandsSeparator": "Разделитель тысяч",
4856
+ "prefix": "Префикс",
4857
+ "suffix": "Суффикс",
4858
+ "allowNegative": "Разрешить отрицательные",
4859
+ "table": "Таблица",
4860
+ "selectTable": "— Выберите таблицу —",
4861
+ "newTableName": "Название новой таблицы",
4862
+ "save": "Сохранить",
4863
+ "addColumn": "Добавить столбец"
4864
+ },
4865
+ "enum": {
4866
+ "options": "Варианты",
4867
+ "optionColor": "Цвет варианта",
4868
+ "optionColorAria": "цвет варианта",
4869
+ "optionPlaceholder": "Вариант",
4870
+ "addOption": "+ Добавить вариант"
4871
+ },
4872
+ header: {
4873
+ "editOptions": "Изменить варианты",
4874
+ "show": "Показать столбец",
4875
+ "hide": "Скрыть столбец",
4876
+ "delete": "Удалить столбец"
4877
+ },
4878
+ row: {
4879
+ "moveUp": "Переместить вверх",
4880
+ "moveDown": "Переместить вниз",
4881
+ "delete": "Удалить строку"
4882
+ },
4883
+ rows: {
4884
+ "loadMore": "Загрузить ещё строки",
4885
+ "none": "Нет строк.",
4886
+ "noneFiltered": "Строки не соответствуют фильтру.",
4887
+ "add": "+ Добавить строку"
4888
+ },
4889
+ filter: {
4890
+ "empty": "Нет столбцов для фильтрации.",
4891
+ "logic": "Логика фильтра",
4892
+ "and": "И",
4893
+ "or": "ИЛИ",
4894
+ "matchAll": "выполнены все условия",
4895
+ "matchAny": "выполнено любое из условий",
4896
+ "removeGroup": "Удалить группу",
4897
+ "condition": "+ Условие",
4898
+ "group": "+ Группа",
4899
+ "groupHeader": "Группа {index}",
4900
+ "removeCondition": "Удалить условие",
4901
+ "valuePlaceholder": "значение, значение"
4902
+ },
4903
+ picker: {
4904
+ "searchOptions": "Поиск вариантов",
4905
+ "searchRows": "Поиск строк"
4906
+ },
4907
+ disconnected: {
4908
+ "name": "База данных",
4909
+ "note": "база данных не подключена"
4910
+ }
4911
+ },
4912
+ editor: {
4913
+ docHeader: {
4914
+ "pageView": "Вид страницы",
4915
+ "canvasView": "Вид холста",
4916
+ "documentViewAria": "Вид документа",
4917
+ "editMode": "Режим редактирования",
4918
+ "viewMode": "Режим просмотра",
4919
+ "published": "Опубликовано",
4920
+ "documentModeAria": "Режим документа",
4921
+ "documentAvatarAria": "Аватар документа",
4922
+ "editAvatarAria": "Изменить аватар документа",
4923
+ "editAvatar": "Изменить аватар",
4924
+ "documentTitleAria": "Заголовок документа",
4925
+ "editTitleAria": "Изменить заголовок документа",
4926
+ "editTitle": "Изменить заголовок"
4927
+ },
4928
+ formatToolbar: {
4929
+ "aria": "Форматирование текста",
4930
+ "marks": {
4931
+ "bold": "Жирный",
4932
+ "code": "Моноширинный",
4933
+ "italic": "Курсив",
4934
+ "underline": "Подчёркнутый",
4935
+ "strike": "Зачёркнутый"
4936
+ },
4937
+ "align": {
4938
+ "left": "Выровнять по левому краю",
4939
+ "center": "Выровнять по центру",
4940
+ "right": "Выровнять по правому краю"
4941
+ },
4942
+ "listType": "Тип списка",
4943
+ "lists": {
4944
+ "bullet": "Маркированный список",
4945
+ "number": "Нумерованный список",
4946
+ "task": "Список задач",
4947
+ "quote": "Цитата",
4948
+ "paragraph": "Текст"
4949
+ },
4950
+ "callout": {
4951
+ "typeAria": "Тип выноски",
4952
+ "variant": "Выноска: {variant}",
4953
+ "iconAria": "Иконка выноски"
4954
+ },
4955
+ "color": {
4956
+ "trigger": "Цвет текста и фона",
4957
+ "targetGroupAria": "Объект изменения цвета",
4958
+ "highlightAria": "Выделить фон",
4959
+ "textAria": "Окрасить текст",
4960
+ "highlightLabel": "фон",
4961
+ "textLabel": "текст"
4962
+ },
4963
+ "palette": {
4964
+ "callout": "выноска",
4965
+ "highlight": "выделение",
4966
+ "text": "текст"
4967
+ }
4968
+ },
4969
+ mention: {
4970
+ "searching": "Поиск…",
4971
+ "people": "Люди",
4972
+ "documents": "Документы",
4973
+ "error": "Не удалось загрузить результаты упоминаний.",
4974
+ "retry": "Повторить"
4975
+ },
4976
+ shared: {
4977
+ "swatch": "{label}: цвет {index}",
4978
+ "emojiPickerGroup": "Эмодзи аватара",
4979
+ "removeAvatar": "Удалить аватар",
4980
+ "clearTime": "Очистить время"
4981
+ }
4982
+ },
4983
+ frame: { page: {
4984
+ "missing": "Фрейм не найден",
4985
+ "windowLabel": "Фрейм",
4986
+ "windowTitle": "Фрейм: {title}"
4987
+ } },
4988
+ slash: {
4989
+ blocks: {
4990
+ "text": "Текст",
4991
+ "heading1": "Заголовок 1",
4992
+ "heading2": "Заголовок 2",
4993
+ "heading3": "Заголовок 3",
4994
+ "quote": "Цитата",
4995
+ "callout": "Выноска",
4996
+ "code": "Блок кода",
4997
+ "codeMermaid": "Блок кода (mermaid)",
4998
+ "divider": "Разделитель",
4999
+ "file": "Файл",
5000
+ "embed": "Встраивание",
5001
+ "database": "База данных",
5002
+ "frame": "Фрейм",
5003
+ "table": "Таблица"
5004
+ },
5005
+ lists: {
5006
+ "bulleted": "Маркированный список",
5007
+ "numbered": "Нумерованный список",
5008
+ "task": "Список задач"
5009
+ },
5010
+ database: {
5011
+ "newTable": "Новая таблица",
5012
+ "namePlaceholder": "Название таблицы",
5013
+ "searchPlaceholder": "Поиск таблиц…",
5014
+ "loading": "Загрузка таблиц…",
5015
+ "noMatch": "Таблицы не найдены",
5016
+ "empty": "Таблиц пока нет — создайте новую выше."
5017
+ },
5018
+ frame: {
5019
+ "fallback": "Фрейм",
5020
+ "searchAria": "Поиск фреймов",
5021
+ "searchPlaceholder": "Поиск фреймов…",
5022
+ "noMatch": "Фреймы не найдены",
5023
+ "empty": "На холсте пока нет фреймов"
5024
+ },
5025
+ embed: {
5026
+ "urlPlaceholder": "URL встраивания (https://…)",
5027
+ "unsafeHint": "Поддерживаются только абсолютные URL http(s)://."
5028
+ }
5029
+ },
5030
+ table: {
5031
+ handle: {
5032
+ "columnOptions": "Настройки столбца {index}",
5033
+ "rowOptions": "Настройки строки {index}",
5034
+ "columnMenu": "Настройки столбца",
5035
+ "rowMenu": "Настройки строки"
5036
+ },
5037
+ menu: {
5038
+ "background": "Фон",
5039
+ "backgroundSwatch": "Фон {color}",
5040
+ "removeBackground": "Убрать фон",
5041
+ "insertRight": "Вставить справа",
5042
+ "insertLeft": "Вставить слева",
5043
+ "insertBelow": "Вставить ниже",
5044
+ "insertAbove": "Вставить выше",
5045
+ "moveRight": "Переместить вправо",
5046
+ "moveLeft": "Переместить влево",
5047
+ "moveDown": "Переместить вниз",
5048
+ "moveUp": "Переместить вверх",
5049
+ "clearContent": "Очистить содержимое"
5050
+ },
5051
+ resize: { "column": "Изменить ширину столбца {index}" },
5052
+ add: {
5053
+ "column": "Добавить столбец",
5054
+ "row": "Добавить строку"
5055
+ },
5056
+ cell: { "options": "Настройки ячейки" }
5057
+ }
4487
5058
  }
4488
5059
  },
4489
- mention: {
4490
- "searching": "Searching…",
4491
- "people": "People",
4492
- "documents": "Documents",
4493
- "error": "Couldn't load mention results.",
4494
- "retry": "Retry"
4495
- },
4496
- shared: {
4497
- "swatch": "{label} color {index}",
4498
- "emojiPickerGroup": "Avatar emoji",
4499
- "removeAvatar": "Remove avatar",
4500
- "clearTime": "Clear the time"
4501
- }
4502
- };
4503
- //#endregion
4504
- //#region src/i18n/locales/en/frame.json
4505
- var frame_default$1 = { page: {
4506
- "missing": "Frame not found",
4507
- "windowLabel": "Frame",
4508
- "windowTitle": "Frame: {title}"
4509
- } };
4510
- //#endregion
4511
- //#region src/i18n/locales/en/slash.json
4512
- var slash_default$1 = {
4513
- blocks: {
4514
- "text": "Text",
4515
- "heading1": "Heading 1",
4516
- "heading2": "Heading 2",
4517
- "heading3": "Heading 3",
4518
- "quote": "Quote",
4519
- "callout": "Callout",
4520
- "code": "Code block",
4521
- "codeMermaid": "Code block (mermaid)",
4522
- "divider": "Divider",
4523
- "file": "File",
4524
- "embed": "Embed",
4525
- "database": "Database",
4526
- "frame": "Frame",
4527
- "table": "Table"
4528
- },
4529
- lists: {
4530
- "bulleted": "Bulleted list",
4531
- "numbered": "Numbered list",
4532
- "task": "Task list"
4533
- },
4534
- database: {
4535
- "newTable": "New table",
4536
- "namePlaceholder": "New table name",
4537
- "searchPlaceholder": "Search tables…",
4538
- "loading": "Loading the tables…",
4539
- "noMatch": "No tables match",
4540
- "empty": "No tables yet — create one above."
4541
- },
4542
- frame: {
4543
- "fallback": "Frame",
4544
- "searchAria": "Search frames",
4545
- "searchPlaceholder": "Search frames...",
4546
- "noMatch": "No frames match",
4547
- "empty": "No frames on the canvas yet"
4548
- },
4549
- embed: {
4550
- "urlPlaceholder": "Embed URL (https://…)",
4551
- "unsafeHint": "Only absolute http(s):// URLs are supported."
4552
- }
4553
- };
4554
- //#endregion
4555
- //#region src/i18n/locales/en/table.json
4556
- var table_default$1 = {
4557
- handle: {
4558
- "columnOptions": "Column {index} options",
4559
- "rowOptions": "Row {index} options",
4560
- "columnMenu": "Column options",
4561
- "rowMenu": "Row options"
4562
- },
4563
- menu: {
4564
- "background": "Background",
4565
- "backgroundSwatch": "Background {color}",
4566
- "removeBackground": "Remove background",
4567
- "insertRight": "Insert right",
4568
- "insertLeft": "Insert left",
4569
- "insertBelow": "Insert below",
4570
- "insertAbove": "Insert above",
4571
- "moveRight": "Move right",
4572
- "moveLeft": "Move left",
4573
- "moveDown": "Move down",
4574
- "moveUp": "Move up",
4575
- "clearContent": "Clear content"
4576
- },
4577
- resize: { "column": "Resize column {index}" },
4578
- add: {
4579
- "column": "Add column",
4580
- "row": "Add row"
5060
+ fallbackLng: "en",
5061
+ supportedLngs: ["en", "ru"],
5062
+ interpolation: {
5063
+ escapeValue: false,
5064
+ prefix: "{",
5065
+ suffix: "}"
4581
5066
  },
4582
- cell: { "options": "Cell options" }
5067
+ returnNull: false
4583
5068
  };
5069
+ /** The supported-set's resolution over a raw language string (the prefix's normalization — `ru-RU` is `ru`, `en-US` is `en`): the absent / unknown language falls back to `en`. */
5070
+ function toDocblocksLang(lang) {
5071
+ return lang.trim().toLowerCase().startsWith("ru") ? "ru" : "en";
5072
+ }
5073
+ /**
5074
+ * Normalizes a consumer-passed locale over the supported set (the same
5075
+ * rules as the `<html lang>`'s read): the `ru*` prefix is `ru`, the `en*`
5076
+ * and the unknown / empty's values fall back to `en`.
5077
+ */
5078
+ function normalizeDocblocksLocale(locale) {
5079
+ return toDocblocksLang(locale);
5080
+ }
5081
+ /**
5082
+ * The document's language over the supported set (the `<html lang>`
5083
+ * attribute's read — the legacy uncontrolled mode's source): the absent /
5084
+ * unknown language falls back to `en`.
5085
+ */
5086
+ function resolveDocblocksLang() {
5087
+ return toDocblocksLang(typeof document === "undefined" ? "" : document.documentElement.lang ?? "");
5088
+ }
5089
+ /**
5090
+ * Creates a package's i18next instance over the given language: the
5091
+ * controlled mode's instance (one per provider over its normalized locale —
5092
+ * no shared cache over a mutable language, no mutation of the legacy
5093
+ * singleton), isolated from the consumer's i18next setup. `init` over the
5094
+ * inline resources runs synchronously (its Promise is not awaited — the
5095
+ * instance is ready by the first render), so the returned value is the
5096
+ * instance itself, not the init's Promise.
5097
+ */
5098
+ function createDocblocksI18nInstance(lng) {
5099
+ const instance = createInstance().use(initReactI18next);
5100
+ instance.init({
5101
+ ...INIT_OPTIONS,
5102
+ lng
5103
+ });
5104
+ return instance;
5105
+ }
5106
+ /**
5107
+ * The package's OWN i18next instance (not the global singleton): the legacy
5108
+ * uncontrolled mode's seat — it is initialized over the package's shipped
5109
+ * en+ru catalogs, starts on the `<html lang>`'s read (the `en`'s fallback
5110
+ * over the server's render, no document), and never touches the consumer's
5111
+ * i18next setup (the `I18nextProvider` over the docblocks' subtree routes
5112
+ * `useTranslation` here).
5113
+ */
5114
+ const docblocksI18n = createDocblocksI18nInstance(resolveDocblocksLang());
5115
+ if (typeof document !== "undefined") new MutationObserver(() => {
5116
+ const lng = resolveDocblocksLang();
5117
+ if (docblocksI18n.language !== lng) docblocksI18n.changeLanguage(lng);
5118
+ }).observe(document.documentElement, {
5119
+ attributes: true,
5120
+ attributeFilter: ["lang"]
5121
+ });
4584
5122
  //#endregion
4585
- //#region src/i18n/locales/ru/blocks.json
4586
- var blocks_default = {
4587
- row: {
4588
- "selectBlock": "Выбрать блок",
4589
- "addBlockBelow": "Добавить блок ниже",
4590
- "deleteBlock": "Удалить блок"
4591
- },
4592
- task: {
4593
- "markDone": "Отметить задачу выполненной",
4594
- "markNotDone": "Снять отметку о выполнении"
4595
- },
4596
- collapse: {
4597
- "expand": "Развернуть вложенные блоки",
4598
- "collapse": "Свернуть вложенные блоки"
4599
- },
4600
- caption: {
4601
- "placeholder": "Напишите подпись…",
4602
- "edit": "Изменить подпись",
4603
- "add": "Добавить подпись",
4604
- "aria": "Подпись",
4605
- "imageAria": "Подпись к изображению"
4606
- },
4607
- code: {
4608
- "language": "Язык кода",
4609
- "chooseLanguage": "Выбрать язык кода",
4610
- "searchPlaceholder": "Поиск языка…",
4611
- "searchAria": "Поиск языка",
4612
- "languages": "Языки",
4613
- "copy": "Копировать код",
4614
- "expand": "Развернуть код",
4615
- "collapse": "Свернуть код",
4616
- "expandTitle": "Развернуть",
4617
- "collapseTitle": "Свернуть",
4618
- "options": "Настройки кода",
4619
- "lineNumbers": "Номера строк",
4620
- "wrap": "Переносить длинные строки",
4621
- "rendering": "Рисование…",
4622
- "pdfPreviewUnavailable": "Превью PDF недоступно ({error}). Показан встроенный просмотрщик.",
4623
- "pdfLoading": "Загрузка превью…",
4624
- "pdfPrevPage": "Предыдущая страница",
4625
- "pdfNextPage": "Следующая страница",
4626
- "pdfFullscreen": "Развернуть на весь экран",
4627
- "pdfCloseFullscreen": "Закрыть полноэкранный режим"
4628
- },
4629
- image: {
4630
- "placeholder": "изображение",
4631
- "document": "документ",
4632
- "resize": "Изменить размер изображения",
4633
- "download": "Скачать изображение",
4634
- "downloadTitle": "Скачать"
4635
- },
4636
- embed: {
4637
- "zoomIn": "Приблизить",
4638
- "zoomOut": "Отдалить",
4639
- "zoomReset": "Сбросить масштаб",
4640
- "resizeHeight": "Изменить высоту встраивания",
4641
- "editUrl": "Изменить ссылку",
4642
- "saveUrl": "Сохранить ссылку",
4643
- "cancelEdit": "Отмена",
4644
- "srcPlaceholder": "URL встраивания (https://…)",
4645
- "unsafeHint": "Поддерживаются только абсолютные URL http(s)://."
4646
- },
4647
- syncEmbed: {
4648
- "broken": "Мастер-документ для этого синхронизируемого блока недоступен.",
4649
- "cycle": "Циклическая ссылка синхронизируемого блока."
4650
- },
4651
- align: {
4652
- "left": "Выровнять по левому краю",
4653
- "center": "Выровнять по центру",
4654
- "right": "Выровнять по правому краю"
4655
- },
4656
- rowCount_one: "строка",
4657
- rowCount_few: "строки",
4658
- rowCount_many: "строк",
4659
- rowCount_other: "строк",
4660
- error: { "render": "Не удалось отобразить" }
4661
- };
4662
- //#endregion
4663
- //#region src/i18n/locales/ru/canvas.json
4664
- var canvas_default = {
4665
- view: { "label": "Холст" },
4666
- dock: {
4667
- "toolbar": "Инструменты холста",
4668
- "modeSelect": "Переключиться в режим выделения",
4669
- "modePan": "Переключиться в режим перемещения",
4670
- "shapes": "Фигуры",
4671
- "shapesMenu": "Меню фигур",
4672
- "text": "Текст",
4673
- "frame": "Фрейм",
4674
- "container": "Контейнер",
4675
- "connector": "Соединитель",
4676
- "pen": "Ручка"
4677
- },
4678
- shapes: {
4679
- "rect": "Прямоугольник",
4680
- "rounded": "Скруглённый прямоугольник",
4681
- "ellipse": "Эллипс",
4682
- "diamond": "Ромб",
4683
- "cylinder": "Цилиндр",
4684
- "cloud": "Облако"
4685
- },
4686
- item: {
4687
- "shape": "Фигура",
4688
- "text": "Текст",
4689
- "frame": "Фрейм",
4690
- "group": "Группа",
4691
- "connector": "Соединитель",
4692
- "other": "Блок {type}"
4693
- },
4694
- zoom: {
4695
- "toolbar": "Масштаб холста",
4696
- "fit": "Вписать в экран",
4697
- "out": "Уменьшить масштаб",
4698
- "in": "Увеличить масштаб",
4699
- "reset": "Сбросить масштаб"
4700
- },
4701
- connector: {
4702
- "toolbar": "Настройки соединителя",
4703
- "labelEdit": "Подпись соединителя",
4704
- "straight": "Прямая линия",
4705
- "orthogonal": "Ортогональная линия",
4706
- "curved": "Кривая линия",
4707
- "lineColor": "Цвет линии",
4708
- "lineWidth": "Толщина линии",
4709
- "lineWidthTitle": "Толщина линии (1–4 px)",
4710
- "solid": "Сплошная линия",
4711
- "dashed": "Пунктирная линия",
4712
- "arrowheadStart": "Стрелка начала",
4713
- "arrowheadEnd": "Стрелка конца",
4714
- "arrowheadsStart": "Стрелки начала",
4715
- "arrowheadsEnd": "Стрелки конца",
4716
- "arrowheadArrow": "Стрела",
4717
- "arrowheadCircle": "Круг",
4718
- "arrowheadNone": "Нет",
4719
- "arrange": "Упорядочить линию"
4720
- },
4721
- shape: {
4722
- "toolbar": "Настройки фигуры",
4723
- "type": "Тип фигуры",
4724
- "types": "Типы фигур",
4725
- "addText": "Добавить текст",
4726
- "addTextTitle": "Добавить текст (или двойной клик по фигуре)",
4727
- "fillColor": "Цвет заливки фигуры",
4728
- "strokeColor": "Цвет обводки фигуры",
4729
- "borderWidth": "Толщина рамки фигуры",
4730
- "borderWidthTitle": "Толщина рамки (1–4 px)",
4731
- "borderStyle": "Стиль рамки фигуры",
4732
- "borderStyleTitle": "Стиль рамки",
4733
- "borderStyles": "Стили рамки",
4734
- "solid": "Сплошная линия",
4735
- "dashed": "Пунктир",
4736
- "borderNone": "Без рамки",
4737
- "arrange": "Упорядочить фигуру"
4738
- },
4739
- zorder: {
4740
- "title": "Порядок (z-order)",
4741
- "bringForward": "Выше",
4742
- "bringToFront": "На передний план",
4743
- "sendBackward": "Ниже",
4744
- "sendToBack": "На задний план"
4745
- },
4746
- text: {
4747
- "toolbar": "Настройки текста",
4748
- "arrange": "Упорядочить текст",
4749
- "fontFamily": "Шрифт текста",
4750
- "color": "Цвет текста",
4751
- "style": "Стиль текста",
4752
- "fontSize": "Размер шрифта",
4753
- "alignLeft": "Выровнять по левому краю",
4754
- "alignCenter": "Выровнять по центру",
4755
- "alignRight": "Выровнять по правому краю"
4756
- },
4757
- titleChip: {
4758
- "button": "Заголовок",
4759
- "setContainerTitle": "Установить заголовок контейнера",
4760
- "setFrameTitle": "Установить заголовок фрейма",
4761
- "containerTitle": "Заголовок контейнера",
4762
- "frameTitle": "Заголовок фрейма"
4763
- },
4764
- colorHex: "{label} — HEX-значение"
4765
- };
4766
- //#endregion
4767
- //#region src/i18n/locales/ru/common.json
4768
- var common_default = {
4769
- copy: "Копировать",
4770
- "delete": "Удалить",
4771
- rename: "Переименовать",
4772
- clear: "Очистить",
4773
- duplicate: "Дублировать",
4774
- paste: "Вставить",
4775
- options: "Параметры",
4776
- moreOptions: "Ещё",
4777
- untitled: "Без названия",
4778
- noMatches: "Нет совпадений",
4779
- noOptions: "Нет вариантов.",
4780
- newTable: "Новая таблица…",
4781
- search: "Поиск…",
4782
- color: {
4783
- "custom": "Свой цвет",
4784
- "none": "Без цвета"
4785
- },
4786
- access: {
4787
- "notPublished": "Документ ещё не опубликован.",
4788
- "notPublishedHint": "Читатели увидят документ только после публикации."
4789
- },
4790
- colorPicker: {
4791
- "aria": "Выбор цвета",
4792
- "hexAria": "Цвет в hex-формате"
4793
- }
4794
- };
4795
- //#endregion
4796
- //#region src/i18n/locales/ru/database.json
4797
- var database_default = {
4798
- state: {
4799
- "loading": "Загрузка таблицы…",
4800
- "notFound": "Таблица не найдена",
4801
- "unknownTable": "Таблица \"{tableId}\" не найдена в базе данных.",
4802
- "retry": "Повторить"
4803
- },
4804
- rowCount_one: "строка",
4805
- rowCount_few: "строки",
4806
- rowCount_many: "строк",
4807
- rowCount_other: "строк",
4808
- toolbar: {
4809
- "undo": "Отменить",
4810
- "redo": "Повторить",
4811
- "filter": "Фильтр",
4812
- "apply": "Применить"
4813
- },
4814
- columnTypes: {
4815
- "text": "Текст",
4816
- "integer": "Целое",
4817
- "decimal": "Дробное",
4818
- "checkbox": "Флажок",
4819
- "date": "Дата",
4820
- "datetime": "Дата и время",
4821
- "enum": "Перечисление",
4822
- "multiEnum": "Множественное перечисление",
4823
- "rowLink": "Ссылка на строку",
4824
- "rowLinks": "Ссылки на строки"
4825
- },
4826
- form: {
4827
- "name": "Название",
4828
- "decimals": "Десятичные знаки",
4829
- "thousandsSeparator": "Разделитель тысяч",
4830
- "prefix": "Префикс",
4831
- "suffix": "Суффикс",
4832
- "allowNegative": "Разрешить отрицательные",
4833
- "table": "Таблица",
4834
- "selectTable": "— Выберите таблицу —",
4835
- "newTableName": "Название новой таблицы",
4836
- "save": "Сохранить",
4837
- "addColumn": "Добавить столбец"
4838
- },
4839
- "enum": {
4840
- "options": "Варианты",
4841
- "optionColor": "Цвет варианта",
4842
- "optionColorAria": "цвет варианта",
4843
- "optionPlaceholder": "Вариант",
4844
- "addOption": "+ Добавить вариант"
4845
- },
4846
- header: {
4847
- "editOptions": "Изменить варианты",
4848
- "show": "Показать столбец",
4849
- "hide": "Скрыть столбец",
4850
- "delete": "Удалить столбец"
4851
- },
4852
- row: {
4853
- "moveUp": "Переместить вверх",
4854
- "moveDown": "Переместить вниз",
4855
- "delete": "Удалить строку"
4856
- },
4857
- rows: {
4858
- "loadMore": "Загрузить ещё строки",
4859
- "none": "Нет строк.",
4860
- "noneFiltered": "Строки не соответствуют фильтру.",
4861
- "add": "+ Добавить строку"
4862
- },
4863
- filter: {
4864
- "empty": "Нет столбцов для фильтрации.",
4865
- "logic": "Логика фильтра",
4866
- "matchAll": "выполнены все условия",
4867
- "matchAny": "выполнено любое из условий",
4868
- "nestedGroup": "Вложенная группа ({logic})",
4869
- "removeGroup": "Удалить группу",
4870
- "condition": "+ Условие",
4871
- "group": "+ Группа",
4872
- "valuePlaceholder": "значение, значение"
4873
- },
4874
- picker: {
4875
- "searchOptions": "Поиск вариантов",
4876
- "searchRows": "Поиск строк"
4877
- },
4878
- disconnected: {
4879
- "name": "База данных",
4880
- "note": "база данных не подключена"
4881
- }
4882
- };
4883
- //#endregion
4884
- //#region src/i18n/locales/ru/editor.json
4885
- var editor_default = {
4886
- docHeader: {
4887
- "pageView": "Вид страницы",
4888
- "canvasView": "Вид холста",
4889
- "documentViewAria": "Вид документа",
4890
- "editMode": "Режим редактирования",
4891
- "viewMode": "Режим просмотра",
4892
- "published": "Опубликовано",
4893
- "documentModeAria": "Режим документа",
4894
- "documentAvatarAria": "Аватар документа",
4895
- "editAvatarAria": "Изменить аватар документа",
4896
- "editAvatar": "Изменить аватар",
4897
- "documentTitleAria": "Заголовок документа",
4898
- "editTitleAria": "Изменить заголовок документа",
4899
- "editTitle": "Изменить заголовок"
4900
- },
4901
- formatToolbar: {
4902
- "aria": "Форматирование текста",
4903
- "marks": {
4904
- "bold": "Жирный",
4905
- "code": "Моноширинный",
4906
- "italic": "Курсив",
4907
- "underline": "Подчёркнутый",
4908
- "strike": "Зачёркнутый"
4909
- },
4910
- "align": {
4911
- "left": "Выровнять по левому краю",
4912
- "center": "Выровнять по центру",
4913
- "right": "Выровнять по правому краю"
4914
- },
4915
- "listType": "Тип списка",
4916
- "lists": {
4917
- "bullet": "Маркированный список",
4918
- "number": "Нумерованный список",
4919
- "task": "Список задач",
4920
- "quote": "Цитата",
4921
- "paragraph": "Текст"
4922
- },
4923
- "callout": {
4924
- "typeAria": "Тип выноски",
4925
- "variant": "Выноска: {variant}",
4926
- "iconAria": "Иконка выноски"
4927
- },
4928
- "color": {
4929
- "trigger": "Цвет текста и фона",
4930
- "targetGroupAria": "Объект изменения цвета",
4931
- "highlightAria": "Выделить фон",
4932
- "textAria": "Окрасить текст",
4933
- "highlightLabel": "фон",
4934
- "textLabel": "текст"
4935
- },
4936
- "palette": {
4937
- "callout": "выноска",
4938
- "highlight": "выделение",
4939
- "text": "текст"
4940
- }
4941
- },
4942
- mention: {
4943
- "searching": "Поиск…",
4944
- "people": "Люди",
4945
- "documents": "Документы",
4946
- "error": "Не удалось загрузить результаты упоминаний.",
4947
- "retry": "Повторить"
4948
- },
4949
- shared: {
4950
- "swatch": "{label}: цвет {index}",
4951
- "emojiPickerGroup": "Эмодзи аватара",
4952
- "removeAvatar": "Удалить аватар",
4953
- "clearTime": "Очистить время"
4954
- }
4955
- };
4956
- //#endregion
4957
- //#region src/i18n/locales/ru/frame.json
4958
- var frame_default = { page: {
4959
- "missing": "Фрейм не найден",
4960
- "windowLabel": "Фрейм",
4961
- "windowTitle": "Фрейм: {title}"
4962
- } };
4963
- //#endregion
4964
- //#region src/i18n/locales/ru/slash.json
4965
- var slash_default = {
4966
- blocks: {
4967
- "text": "Текст",
4968
- "heading1": "Заголовок 1",
4969
- "heading2": "Заголовок 2",
4970
- "heading3": "Заголовок 3",
4971
- "quote": "Цитата",
4972
- "callout": "Выноска",
4973
- "code": "Блок кода",
4974
- "codeMermaid": "Блок кода (mermaid)",
4975
- "divider": "Разделитель",
4976
- "file": "Файл",
4977
- "embed": "Встраивание",
4978
- "database": "База данных",
4979
- "frame": "Фрейм",
4980
- "table": "Таблица"
4981
- },
4982
- lists: {
4983
- "bulleted": "Маркированный список",
4984
- "numbered": "Нумерованный список",
4985
- "task": "Список задач"
4986
- },
4987
- database: {
4988
- "newTable": "Новая таблица",
4989
- "namePlaceholder": "Название таблицы",
4990
- "searchPlaceholder": "Поиск таблиц…",
4991
- "loading": "Загрузка таблиц…",
4992
- "noMatch": "Таблицы не найдены",
4993
- "empty": "Таблиц пока нет — создайте новую выше."
4994
- },
4995
- frame: {
4996
- "fallback": "Фрейм",
4997
- "searchAria": "Поиск фреймов",
4998
- "searchPlaceholder": "Поиск фреймов…",
4999
- "noMatch": "Фреймы не найдены",
5000
- "empty": "На холсте пока нет фреймов"
5001
- },
5002
- embed: {
5003
- "urlPlaceholder": "URL встраивания (https://…)",
5004
- "unsafeHint": "Поддерживаются только абсолютные URL http(s)://."
5005
- }
5006
- };
5007
- //#endregion
5008
- //#region src/i18n/locales/ru/table.json
5009
- var table_default = {
5010
- handle: {
5011
- "columnOptions": "Настройки столбца {index}",
5012
- "rowOptions": "Настройки строки {index}",
5013
- "columnMenu": "Настройки столбца",
5014
- "rowMenu": "Настройки строки"
5015
- },
5016
- menu: {
5017
- "background": "Фон",
5018
- "backgroundSwatch": "Фон {color}",
5019
- "removeBackground": "Убрать фон",
5020
- "insertRight": "Вставить справа",
5021
- "insertLeft": "Вставить слева",
5022
- "insertBelow": "Вставить ниже",
5023
- "insertAbove": "Вставить выше",
5024
- "moveRight": "Переместить вправо",
5025
- "moveLeft": "Переместить влево",
5026
- "moveDown": "Переместить вниз",
5027
- "moveUp": "Переместить вверх",
5028
- "clearContent": "Очистить содержимое"
5029
- },
5030
- resize: { "column": "Изменить ширину столбца {index}" },
5031
- add: {
5032
- "column": "Добавить столбец",
5033
- "row": "Добавить строку"
5034
- },
5035
- cell: { "options": "Настройки ячейки" }
5036
- };
5037
- //#endregion
5038
- //#region src/i18n/instance.ts
5039
- /**
5040
- * The document's language over the supported set (the prefix's stand —
5041
- * `ru-RU` stands `ru`, `en-US` stands `en`): the absent / unknown language
5042
- * falls back to `en`. The library language is consumer-driven — the only
5043
- * source is the `<html lang>` attribute (no locale prop).
5044
- */
5045
- function resolveDocblocksLang() {
5046
- return (typeof document === "undefined" ? "" : document.documentElement.lang ?? "").trim().toLowerCase().startsWith("ru") ? "ru" : "en";
5047
- }
5048
- /**
5049
- * The package's OWN i18next instance (not the global singleton): it is
5050
- * initialized over the package's shipped en+ru catalogs and never touches
5051
- * the consumer's i18next setup (the `I18nextProvider` over the docblocks'
5052
- * subtree routes `useTranslation` here). The inline resources resolve
5053
- * synchronously, so the instance is ready by the first render.
5054
- */
5055
- const docblocksI18n = createInstance().use(initReactI18next);
5056
- docblocksI18n.init({
5057
- resources: {
5058
- en: {
5059
- blocks: blocks_default$1,
5060
- canvas: canvas_default$1,
5061
- common: common_default$1,
5062
- database: database_default$1,
5063
- editor: editor_default$1,
5064
- frame: frame_default$1,
5065
- slash: slash_default$1,
5066
- table: table_default$1
5067
- },
5068
- ru: {
5069
- blocks: blocks_default,
5070
- canvas: canvas_default,
5071
- common: common_default,
5072
- database: database_default,
5073
- editor: editor_default,
5074
- frame: frame_default,
5075
- slash: slash_default,
5076
- table: table_default
5077
- }
5078
- },
5079
- lng: resolveDocblocksLang(),
5080
- fallbackLng: "en",
5081
- supportedLngs: ["en", "ru"],
5082
- interpolation: {
5083
- escapeValue: false,
5084
- prefix: "{",
5085
- suffix: "}"
5086
- },
5087
- returnNull: false
5088
- });
5089
- if (typeof document !== "undefined") new MutationObserver(() => {
5090
- const lng = resolveDocblocksLang();
5091
- if (docblocksI18n.language !== lng) docblocksI18n.changeLanguage(lng);
5092
- }).observe(document.documentElement, {
5093
- attributes: true,
5094
- attributeFilter: ["lang"]
5095
- });
5096
- //#endregion
5097
- //#region src/i18n/provider.tsx
5098
- /**
5099
- * The docblocks' i18n scope: the package's own i18next instance over the
5100
- * subtree — the docblocks' `useTranslation` resolves against it and never
5101
- * conflicts with the consumer's global i18next singleton (the instance's
5102
- * isolation). The `EditorProvider` and the consumer-placed `DocHeader`
5103
- * both wrap over it.
5104
- */
5105
- function DocblocksI18nProvider({ children }) {
5106
- return /* @__PURE__ */ jsx(I18nextProvider, {
5107
- i18n: docblocksI18n,
5108
- children
5109
- });
5110
- }
5123
+ //#region src/i18n/provider.tsx
5124
+ /** The inherited controlled instance (the nested uncontrolled provider takes the outer one — the package's internal wrappers keep the consumer's locale without threading it through each component). */
5125
+ const ControlledI18nContext = createContext(null);
5126
+ /**
5127
+ * The docblocks' i18n scope: the package's own i18next instance over the
5128
+ * subtree — the docblocks' `useTranslation` resolves against it and never
5129
+ * conflicts with the consumer's global i18next singleton (the instance's
5130
+ * isolation). The `EditorProvider` and the consumer-placed `DocHeader`
5131
+ * both wrap over it.
5132
+ *
5133
+ * The optional `locale` prop is the controlled mode: the provider creates
5134
+ * its own synchronously initialized instance over the normalized locale
5135
+ * (one per provider, keyed by the normalized value — a locale change
5136
+ * selects the new instance and re-renders the subtree). The controlled
5137
+ * mode never mutates the legacy singleton and never calls
5138
+ * `changeLanguage` on it, so the concurrent subtrees over different
5139
+ * locales stay isolated. The provider without a locale inherits the
5140
+ * outer's controlled instance when nested over one; outside a controlled
5141
+ * provider it keeps the legacy behavior — the module-level instance
5142
+ * driven by the `<html lang>` attribute and its runtime flip.
5143
+ */
5144
+ function DocblocksI18nProvider({ locale, children }) {
5145
+ const inherited = useContext(ControlledI18nContext);
5146
+ const normalized = locale === void 0 ? null : normalizeDocblocksLocale(locale);
5147
+ const controlled = useMemo(() => normalized === null ? null : createDocblocksI18nInstance(normalized), [normalized]);
5148
+ const effective = controlled ?? inherited ?? docblocksI18n;
5149
+ return /* @__PURE__ */ jsx(ControlledI18nContext.Provider, {
5150
+ value: controlled ?? inherited,
5151
+ children: /* @__PURE__ */ jsx(I18nextProvider, {
5152
+ i18n: effective,
5153
+ children
5154
+ })
5155
+ });
5156
+ }
5111
5157
  //#endregion
5112
5158
  //#region src/shared/ui/ColorPicker.tsx
5113
5159
  /**
@@ -5988,9 +6034,11 @@ function SelectScrollDownButton({ className, ...props }) {
5988
6034
  * the value and the `onChange` behavior (the no-op-on-current guard is the
5989
6035
  * caller's). The pill's travel runs a back-out easing (a slight overshoot
5990
6036
  * that settles into the measured stand — the end position stands exact,
5991
- * the overshoot is the animation only).
6037
+ * the overshoot is the animation only). The pill's fill runs a theme
6038
+ * variant: `accent` (the default's soft highlight) or `primary` (the
6039
+ * prominent fill — the active label stands the `primary-foreground`).
5992
6040
  */
5993
- function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot, buttonAttrName, size = "icon" }) {
6041
+ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot, buttonAttrName, size = "icon", pillTheme = "accent" }) {
5994
6042
  const listRef = useRef(null);
5995
6043
  /** The sliding pill's geometry (the active button's position and size in the list). */
5996
6044
  const [pill, setPill] = useState(null);
@@ -6017,6 +6065,10 @@ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot,
6017
6065
  return () => observer.disconnect();
6018
6066
  }, [value, buttonAttrName]);
6019
6067
  const selectOption = (value) => () => onChange(value);
6068
+ /** The active button's label stand (over the pill's fill): the `primary`
6069
+ * pill's stand reads the `primary-foreground`, the `accent` pill's stand
6070
+ * reads the `foreground`. */
6071
+ const activeLabelClass = pillTheme === "primary" ? "text-primary-foreground" : "text-foreground";
6020
6072
  return /* @__PURE__ */ jsxs("div", {
6021
6073
  ref: listRef,
6022
6074
  role: "group",
@@ -6026,7 +6078,10 @@ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot,
6026
6078
  children: [pill !== null && /* @__PURE__ */ jsx("span", {
6027
6079
  "data-slot": pillSlot,
6028
6080
  "aria-hidden": true,
6029
- className: "\n absolute top-0 left-0 rounded-md bg-accent shadow-sm transition-[transform,width,height] duration-200\n ease-[cubic-bezier(0.34,1.56,0.64,1)]\n dark:bg-ring\n ",
6081
+ className: cn(`
6082
+ absolute top-0 left-0 rounded-md shadow-sm transition-[transform,width,height] duration-200
6083
+ ease-[cubic-bezier(0.34,1.56,0.64,1)]
6084
+ `, pillTheme === "primary" ? "bg-primary" : "bg-accent dark:bg-ring"),
6030
6085
  style: {
6031
6086
  transform: `translate(${pill.left}px, ${pill.top}px)`,
6032
6087
  width: pill.width,
@@ -6045,7 +6100,7 @@ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot,
6045
6100
  hover:bg-transparent
6046
6101
  focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1
6047
6102
  focus-visible:outline-ring
6048
- `, size === "icon" ? "size-6" : "h-6 px-2 text-xs", value === option.value ? "text-foreground" : "hover:text-foreground", option.disabled && "cursor-not-allowed text-muted-foreground/50 hover:text-muted-foreground/50"),
6103
+ `, size === "icon" ? "size-6" : "h-6 px-2 text-xs", value === option.value ? activeLabelClass : "hover:text-foreground", option.disabled && "cursor-not-allowed text-muted-foreground/50 hover:text-muted-foreground/50"),
6049
6104
  onClick: selectOption(option.value),
6050
6105
  children: size === "text" ? option.label : option.icon
6051
6106
  }, option.value))]
@@ -6246,21 +6301,21 @@ function filterIsComplete(payload, columns) {
6246
6301
  //#region src/database/filter-builder/FilterBuilder.tsx
6247
6302
  /**
6248
6303
  * The recursive and/or filter editor: the top-level FilterBuilder renders a
6249
- * FilterGroup (the group card), which renders the condition rows
6250
- * (FilterConditionRow) + the nested groups; each condition's value is a
6251
- * ValueInput over the column's annotation.
6252
- */
6253
- /** The recursive and/or filter editor (the group card). */
6254
- const FILTER_LOGIC_OPTIONS = [{
6255
- value: "and",
6256
- label: "AND"
6257
- }, {
6258
- value: "or",
6259
- label: "OR"
6260
- }];
6304
+ * FilterGroup (the logic selector + the gutter body), which renders the
6305
+ * condition rows (FilterConditionRow) + the nested groups (FilterGroupCard);
6306
+ * each condition's value is a ValueInput over the column's annotation.
6307
+ * Every body item draws its share of the group's vertical connector line
6308
+ * (the thin left line that binds the conditions and the groups into one
6309
+ * tree — the last item stops the line at its tick).
6310
+ */
6311
+ const FILTER_LOGIC_VALUES = ["and", "or"];
6261
6312
  function FilterBuilder({ value, columns, onChange, refTableData }) {
6262
6313
  const { t } = useTranslation("database");
6263
6314
  const payload = value ?? emptyFilter();
6315
+ const logicOptions = FILTER_LOGIC_VALUES.map((entry) => ({
6316
+ value: entry,
6317
+ label: t(`filter.${entry}`)
6318
+ }));
6264
6319
  return /* @__PURE__ */ jsx("div", {
6265
6320
  "data-slot": "docblocks/filter-builder",
6266
6321
  className: "flex max-h-80 flex-col gap-2 overflow-y-auto",
@@ -6272,13 +6327,15 @@ function FilterBuilder({ value, columns, onChange, refTableData }) {
6272
6327
  payload,
6273
6328
  columns,
6274
6329
  depth: 0,
6330
+ logicOptions,
6275
6331
  onChange,
6276
6332
  refTableData
6277
6333
  })
6278
6334
  });
6279
6335
  }
6280
- function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6336
+ function FilterGroup({ payload, columns, depth, logicOptions, onChange, refTableData }) {
6281
6337
  const { t } = useTranslation("database");
6338
+ const groups = payload.groups ?? [];
6282
6339
  const setLogic = (logic) => onChange({
6283
6340
  ...payload,
6284
6341
  logic
@@ -6293,15 +6350,15 @@ function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6293
6350
  });
6294
6351
  const setGroup = (index, group) => onChange({
6295
6352
  ...payload,
6296
- groups: (payload.groups ?? []).map((entry, at) => at === index ? group : entry)
6353
+ groups: groups.map((entry, at) => at === index ? group : entry)
6297
6354
  });
6298
6355
  const removeGroup = (index) => onChange({
6299
6356
  ...payload,
6300
- groups: (payload.groups ?? []).filter((_, at) => at !== index)
6357
+ groups: groups.filter((_, at) => at !== index)
6301
6358
  });
6302
6359
  const addGroup = () => onChange({
6303
6360
  ...payload,
6304
- groups: [...payload.groups ?? [], emptyFilter()]
6361
+ groups: [...groups, emptyFilter()]
6305
6362
  });
6306
6363
  const addCondition = () => {
6307
6364
  const column = columns[0];
@@ -6322,60 +6379,53 @@ function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6322
6379
  const conditionRemove = (index) => () => removeCondition(index);
6323
6380
  const removeGroupAt = (index) => () => removeGroup(index);
6324
6381
  const groupChange = (index) => (next) => setGroup(index, next);
6382
+ const isLastCondition = (index) => index === payload.conditions.length - 1 && groups.length === 0;
6383
+ const isLastGroup = (index) => index === groups.length - 1;
6325
6384
  return /* @__PURE__ */ jsxs("div", {
6326
6385
  "data-slot": "docblocks/filter-group",
6327
6386
  "data-logic": payload.logic,
6328
- className: "flex flex-col gap-2 rounded-md border border-border p-2",
6387
+ className: "flex flex-col gap-2",
6329
6388
  children: [
6330
6389
  /* @__PURE__ */ jsxs("div", {
6331
6390
  className: "flex items-center gap-2",
6332
6391
  children: [/* @__PURE__ */ jsx(SegmentSelector, {
6333
- options: FILTER_LOGIC_OPTIONS,
6392
+ options: logicOptions,
6334
6393
  value: payload.logic,
6335
6394
  onChange: onLogicChange,
6336
6395
  ariaLabel: t("filter.logic"),
6337
6396
  slot: "docblocks/filter-logic",
6338
6397
  pillSlot: "docblocks/filter-logic-pill",
6339
6398
  buttonAttrName: "filter-logic",
6340
- size: "text"
6399
+ size: "text",
6400
+ pillTheme: "primary"
6341
6401
  }), /* @__PURE__ */ jsx("span", {
6342
6402
  className: "text-xs text-muted-foreground",
6343
6403
  children: payload.logic === "and" ? t("filter.matchAll") : t("filter.matchAny")
6344
6404
  })]
6345
6405
  }),
6346
- payload.conditions.map((condition, index) => /* @__PURE__ */ jsx(FilterConditionRow, {
6347
- condition,
6348
- columns,
6349
- onChange: conditionChange(index),
6350
- onRemove: conditionRemove(index),
6351
- refTableData
6352
- }, index)),
6353
- (payload.groups ?? []).map((group, index) => /* @__PURE__ */ jsxs("div", {
6354
- className: "flex flex-col gap-1",
6355
- "data-slot": "docblocks/filter-nested",
6356
- children: [/* @__PURE__ */ jsxs("div", {
6357
- className: "flex items-center gap-1 text-xs text-muted-foreground",
6358
- children: [/* @__PURE__ */ jsx("span", {
6359
- "data-slot": "docblocks/filter-connector",
6360
- children: t("filter.nestedGroup", { logic: payload.logic === "and" ? "AND" : "OR" })
6361
- }), /* @__PURE__ */ jsx(Button, {
6362
- type: "button",
6363
- variant: "outline",
6364
- size: "sm",
6365
- "data-slot": "docblocks/filter-remove-group",
6366
- onClick: removeGroupAt(index),
6367
- children: t("filter.removeGroup")
6368
- })]
6369
- }), /* @__PURE__ */ jsx(FilterGroup, {
6406
+ /* @__PURE__ */ jsxs("div", {
6407
+ className: "flex flex-col gap-2 pl-5",
6408
+ children: [payload.conditions.map((condition, index) => /* @__PURE__ */ jsx(FilterConditionRow, {
6409
+ condition,
6410
+ columns,
6411
+ onChange: conditionChange(index),
6412
+ onRemove: conditionRemove(index),
6413
+ refTableData,
6414
+ isLast: isLastCondition(index)
6415
+ }, index)), groups.map((group, index) => /* @__PURE__ */ jsx(FilterGroupCard, {
6416
+ index,
6370
6417
  payload: group,
6371
6418
  columns,
6372
6419
  depth: depth + 1,
6420
+ logicOptions,
6373
6421
  onChange: groupChange(index),
6374
- refTableData
6375
- })]
6376
- }, index)),
6422
+ onRemove: removeGroupAt(index),
6423
+ refTableData,
6424
+ isLast: isLastGroup(index)
6425
+ }, index))]
6426
+ }),
6377
6427
  /* @__PURE__ */ jsxs("div", {
6378
- className: "flex gap-2",
6428
+ className: "flex gap-2 pl-5",
6379
6429
  children: [/* @__PURE__ */ jsx(Button, {
6380
6430
  type: "button",
6381
6431
  variant: "outline",
@@ -6395,7 +6445,8 @@ function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6395
6445
  ]
6396
6446
  });
6397
6447
  }
6398
- function FilterConditionRow({ condition, columns, onChange, onRemove, refTableData }) {
6448
+ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableData, isLast }) {
6449
+ const { t } = useTranslation("database");
6399
6450
  const column = columns.find((entry) => entry.id === condition.columnId) ?? columns[0];
6400
6451
  if (column === void 0) return null;
6401
6452
  const annotation = columnAnnotation(column);
@@ -6425,10 +6476,19 @@ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableDa
6425
6476
  "data-slot": "docblocks/filter-condition",
6426
6477
  "data-column-id": condition.columnId,
6427
6478
  "data-op": operator,
6428
- className: "flex flex-wrap items-center gap-2",
6479
+ className: "relative flex items-center gap-2",
6429
6480
  children: [
6481
+ /* @__PURE__ */ jsx("span", {
6482
+ "aria-hidden": true,
6483
+ className: "absolute bottom-4 -left-5 h-px w-5 bg-border"
6484
+ }),
6485
+ /* @__PURE__ */ jsx("span", {
6486
+ "aria-hidden": true,
6487
+ className: cn("absolute top-0 -left-5 w-px bg-border", isLast ? "bottom-4" : "-bottom-2")
6488
+ }),
6430
6489
  /* @__PURE__ */ jsx(BareSelect, {
6431
6490
  "data-slot": "docblocks/filter-column",
6491
+ className: "max-w-60 min-w-35",
6432
6492
  value: column.id,
6433
6493
  onChange: onColumnChange,
6434
6494
  children: columns.map((entry) => /* @__PURE__ */ jsx("option", {
@@ -6454,16 +6514,69 @@ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableDa
6454
6514
  }),
6455
6515
  /* @__PURE__ */ jsx(Button, {
6456
6516
  type: "button",
6457
- variant: "outline",
6458
- size: "sm",
6517
+ variant: "ghost",
6518
+ size: "icon",
6459
6519
  "data-slot": "docblocks/filter-remove-condition",
6520
+ "aria-label": t("filter.removeCondition"),
6521
+ className: "size-8 shrink-0",
6460
6522
  onClick: onRemove,
6461
- children: "×"
6523
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
6524
+ })
6525
+ ]
6526
+ });
6527
+ }
6528
+ /** The nested filter group: the bordered card with the ordinal header and
6529
+ * the remove, and the recursive `FilterGroup` inside. Draws its share of
6530
+ * the parent group's connector line (the border-less wrapper is the line's
6531
+ * positioning context). */
6532
+ function FilterGroupCard({ index, payload, columns, depth, logicOptions, onChange, onRemove, refTableData, isLast }) {
6533
+ const { t } = useTranslation("database");
6534
+ return /* @__PURE__ */ jsxs("div", {
6535
+ "data-slot": "docblocks/filter-nested",
6536
+ className: "relative",
6537
+ children: [
6538
+ /* @__PURE__ */ jsx("span", {
6539
+ "aria-hidden": true,
6540
+ className: "absolute top-6 -left-5 h-px w-5 bg-border"
6541
+ }),
6542
+ /* @__PURE__ */ jsx("span", {
6543
+ "aria-hidden": true,
6544
+ className: cn("absolute top-0 -left-5 w-px bg-border", isLast ? "h-6" : "-bottom-2")
6545
+ }),
6546
+ /* @__PURE__ */ jsxs("div", {
6547
+ className: "flex flex-col gap-2 rounded-md border border-border p-2",
6548
+ children: [/* @__PURE__ */ jsxs("div", {
6549
+ className: "flex items-center justify-between gap-2",
6550
+ children: [/* @__PURE__ */ jsx("span", {
6551
+ "data-slot": "docblocks/filter-group-header",
6552
+ className: "text-xs font-medium text-muted-foreground",
6553
+ children: t("filter.groupHeader", { index: index + 1 })
6554
+ }), /* @__PURE__ */ jsx(Button, {
6555
+ type: "button",
6556
+ variant: "ghost",
6557
+ size: "icon",
6558
+ "data-slot": "docblocks/filter-remove-group",
6559
+ "aria-label": t("filter.removeGroup"),
6560
+ className: "size-8 shrink-0",
6561
+ onClick: onRemove,
6562
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
6563
+ })]
6564
+ }), /* @__PURE__ */ jsx(FilterGroup, {
6565
+ payload,
6566
+ columns,
6567
+ depth,
6568
+ logicOptions,
6569
+ onChange,
6570
+ refTableData
6571
+ })]
6462
6572
  })
6463
6573
  ]
6464
6574
  });
6465
6575
  }
6466
- /** The value input per the annotation (the `in` / `not in` multi-value is a comma list). */
6576
+ /** The value input per the annotation (the `in` / `not in` multi-value is a
6577
+ * comma list). The input stands the row's leftover (the field / the
6578
+ * operator take their content width, the value fills the rest — the
6579
+ * single line's stand). */
6467
6580
  function ValueInput({ column, operator, value, onChange, refTableData }) {
6468
6581
  const { t } = useTranslation("database");
6469
6582
  const multiValue = operator === "in" || operator === "not in";
@@ -6481,7 +6594,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6481
6594
  type: "text",
6482
6595
  size: "sm",
6483
6596
  "data-slot": "docblocks/filter-value",
6484
- className: "w-auto",
6597
+ className: "min-w-0 flex-1 border-input",
6485
6598
  placeholder: t("filter.valuePlaceholder"),
6486
6599
  value: text,
6487
6600
  onChange: onMultiChange
@@ -6492,12 +6605,13 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6492
6605
  type: "number",
6493
6606
  size: "sm",
6494
6607
  "data-slot": "docblocks/filter-value",
6495
- className: "w-auto",
6608
+ className: "min-w-0 flex-1 border-input",
6496
6609
  value: value === void 0 || value === null ? "" : String(value),
6497
6610
  onChange: onNumberChange
6498
6611
  });
6499
6612
  case "boolean": return /* @__PURE__ */ jsxs(BareSelect, {
6500
6613
  "data-slot": "docblocks/filter-value",
6614
+ className: "min-w-0 flex-1",
6501
6615
  value: value === void 0 || value === null ? "" : String(value),
6502
6616
  onChange: onBooleanChange,
6503
6617
  children: [
@@ -6519,7 +6633,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6519
6633
  type: "date",
6520
6634
  size: "sm",
6521
6635
  "data-slot": "docblocks/filter-value",
6522
- className: "w-auto",
6636
+ className: "min-w-0 flex-1 border-input",
6523
6637
  value: value === void 0 || value === null ? "" : String(value),
6524
6638
  onChange: onScalarChange
6525
6639
  });
@@ -6527,7 +6641,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6527
6641
  type: "datetime-local",
6528
6642
  size: "sm",
6529
6643
  "data-slot": "docblocks/filter-value",
6530
- className: "w-auto",
6644
+ className: "min-w-0 flex-1 border-input",
6531
6645
  value: value === void 0 || value === null ? "" : String(value),
6532
6646
  onChange: onScalarChange
6533
6647
  });
@@ -6540,6 +6654,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6540
6654
  const entries = refTable?.rowIds ?? [];
6541
6655
  return /* @__PURE__ */ jsxs(BareSelect, {
6542
6656
  "data-slot": "docblocks/filter-value",
6657
+ className: "min-w-0 flex-1",
6543
6658
  value: value === void 0 || value === null ? "" : String(value),
6544
6659
  onChange: onScalarChange,
6545
6660
  children: [/* @__PURE__ */ jsx("option", {
@@ -6555,7 +6670,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6555
6670
  type: "text",
6556
6671
  size: "sm",
6557
6672
  "data-slot": "docblocks/filter-value",
6558
- className: "w-auto",
6673
+ className: "min-w-0 flex-1 border-input",
6559
6674
  value: value === void 0 || value === null ? "" : String(value),
6560
6675
  onChange: onScalarChange
6561
6676
  });
@@ -6689,6 +6804,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6689
6804
  const [phase, setPhase] = useState("loading");
6690
6805
  const [table, setTable] = useState(null);
6691
6806
  const [rows, setRows] = useState([]);
6807
+ const [pendingRow, setPendingRow] = useState(null);
6692
6808
  const [nextCursor, setNextCursor] = useState(null);
6693
6809
  const [error, setError] = useState(null);
6694
6810
  const [errorCode, setErrorCode] = useState(null);
@@ -6697,6 +6813,8 @@ function useDatabaseTable(bridge, tableId, filter) {
6697
6813
  const [, setStackVersion] = useState(0);
6698
6814
  const rowsRef = useRef(rows);
6699
6815
  rowsRef.current = rows;
6816
+ const pendingRowRef = useRef(pendingRow);
6817
+ pendingRowRef.current = pendingRow;
6700
6818
  const descriptionRef = useRef(null);
6701
6819
  const revisionsRef = useRef(/* @__PURE__ */ new Map());
6702
6820
  const pageRef = useRef({
@@ -6748,12 +6866,17 @@ function useDatabaseTable(bridge, tableId, filter) {
6748
6866
  columns: snapshot.columns.map((column) => ({ ...column })),
6749
6867
  schemaRevision: snapshot.schemaRevision
6750
6868
  };
6869
+ const visibleIds = new Set(snapshot.page.rows.map((row) => row.id));
6870
+ const pendingBefore = pendingRowRef.current;
6871
+ const pendingRevision = pendingBefore === null ? void 0 : revisionsRef.current.get(pendingBefore.rowId);
6751
6872
  revisionsRef.current = new Map(snapshot.page.rows.map((row) => [row.id, row.revision]));
6873
+ if (pendingBefore !== null && !visibleIds.has(pendingBefore.rowId) && pendingRevision !== void 0) revisionsRef.current.set(pendingBefore.rowId, pendingRevision);
6752
6874
  setTable(descriptionToGrid(snapshot));
6753
6875
  setRows(snapshot.page.rows.map((row) => ({
6754
6876
  rowId: row.id,
6755
6877
  cells: { ...row.cells }
6756
6878
  })));
6879
+ setPendingRow((current) => current !== null && visibleIds.has(current.rowId) ? null : current);
6757
6880
  setNextCursor(snapshot.page.nextCursor);
6758
6881
  if (clearError) {
6759
6882
  setError(null);
@@ -6762,12 +6885,14 @@ function useDatabaseTable(bridge, tableId, filter) {
6762
6885
  setPhase("ready");
6763
6886
  };
6764
6887
  useEffect(() => {
6888
+ setPendingRow(null);
6765
6889
  let disposed = false;
6766
6890
  let handle = null;
6767
6891
  let lastSeenSeq = null;
6768
6892
  const seenSeqs = /* @__PURE__ */ new Set();
6769
6893
  const die = (operationError) => {
6770
6894
  setRows([]);
6895
+ setPendingRow(null);
6771
6896
  setNextCursor(null);
6772
6897
  revisionsRef.current = /* @__PURE__ */ new Map();
6773
6898
  if (handle !== null) handle.unsubscribe();
@@ -6865,7 +6990,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6865
6990
  redoStackRef.current = [];
6866
6991
  bump();
6867
6992
  }, [bump]);
6868
- const refresh = useCallback(() => {
6993
+ const refresh = useCallback((onApplied) => {
6869
6994
  (async () => {
6870
6995
  const token = ++loadTokenRef.current;
6871
6996
  try {
@@ -6875,6 +7000,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6875
7000
  });
6876
7001
  if (token !== loadTokenRef.current) return;
6877
7002
  applySnapshot(snapshot);
7003
+ onApplied?.(snapshot);
6878
7004
  } catch {}
6879
7005
  })();
6880
7006
  }, [
@@ -6890,6 +7016,8 @@ function useDatabaseTable(bridge, tableId, filter) {
6890
7016
  };
6891
7017
  const insertRow = useCallback(async (cells = {}) => {
6892
7018
  let liveRowId;
7019
+ let createdCells = {};
7020
+ let createdRevision;
6893
7021
  try {
6894
7022
  const receipt = await bridge.batchRows(tableId, { ops: [{
6895
7023
  op: "create",
@@ -6899,6 +7027,8 @@ function useDatabaseTable(bridge, tableId, filter) {
6899
7027
  const created = receipt.result.rows[0];
6900
7028
  if (created === void 0) throw new BridgeError("unavailable", "The insert's receipt carries no created row.");
6901
7029
  liveRowId = created.id;
7030
+ createdCells = { ...created.cells };
7031
+ createdRevision = created.revision;
6902
7032
  for (const [id, revision] of Object.entries(receipt.revisions)) revisionsRef.current.set(id, revision);
6903
7033
  } catch (operationError) {
6904
7034
  noteError(operationError);
@@ -6921,7 +7051,17 @@ function useDatabaseTable(bridge, tableId, filter) {
6921
7051
  }] }, newMutationContext());
6922
7052
  }
6923
7053
  }, bridge, tableId);
6924
- refresh();
7054
+ const insertedRowId = liveRowId;
7055
+ refresh((snapshot) => {
7056
+ if (snapshot.page.rows.some((row) => row.id === insertedRowId)) return;
7057
+ if (createdRevision !== void 0) revisionsRef.current.set(insertedRowId, createdRevision);
7058
+ const inserted = {
7059
+ rowId: insertedRowId,
7060
+ cells: { ...createdCells }
7061
+ };
7062
+ pendingRowRef.current = inserted;
7063
+ setPendingRow(inserted);
7064
+ });
6925
7065
  return liveRowId;
6926
7066
  }, [
6927
7067
  bridge,
@@ -6934,6 +7074,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6934
7074
  rowId: row.rowId,
6935
7075
  cells: { ...row.cells }
6936
7076
  }));
7077
+ const pendingSnapshot = pendingRowRef.current;
6937
7078
  const current = rowsRef.current.find((row) => row.rowId === rowId);
6938
7079
  const cleaned = {};
6939
7080
  for (const [key, value] of Object.entries(cells)) if (value !== void 0) cleaned[key] = value;
@@ -6945,6 +7086,13 @@ function useDatabaseTable(bridge, tableId, filter) {
6945
7086
  ...cleaned
6946
7087
  }
6947
7088
  } : row));
7089
+ setPendingRow((current) => current?.rowId === rowId ? {
7090
+ ...current,
7091
+ cells: {
7092
+ ...current.cells,
7093
+ ...cleaned
7094
+ }
7095
+ } : current);
6948
7096
  try {
6949
7097
  const receipt = await bridge.batchRows(tableId, { ops: [{
6950
7098
  op: "update",
@@ -6978,6 +7126,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6978
7126
  refresh();
6979
7127
  } catch (operationError) {
6980
7128
  setRows(snapshot);
7129
+ setPendingRow(pendingSnapshot);
6981
7130
  noteError(operationError);
6982
7131
  refresh();
6983
7132
  throw toBridgeError(operationError);
@@ -6994,6 +7143,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6994
7143
  rowId: row.rowId,
6995
7144
  cells: { ...row.cells }
6996
7145
  }));
7146
+ const pendingSnapshot = pendingRowRef.current;
6997
7147
  const before = new Map(rowsRef.current.map((row) => [row.rowId, row.cells]));
6998
7148
  const cleaned = updates.map(({ rowId, cells }) => {
6999
7149
  const patch = {};
@@ -7018,6 +7168,17 @@ function useDatabaseTable(bridge, tableId, filter) {
7018
7168
  }
7019
7169
  };
7020
7170
  }));
7171
+ setPendingRow((current) => {
7172
+ if (current === null) return null;
7173
+ const patch = byId.get(current.rowId);
7174
+ return patch === void 0 ? current : {
7175
+ ...current,
7176
+ cells: {
7177
+ ...current.cells,
7178
+ ...patch
7179
+ }
7180
+ };
7181
+ });
7021
7182
  try {
7022
7183
  const receipt = await bridge.batchRows(tableId, { ops: cleaned.map(({ rowId, cells }) => ({
7023
7184
  op: "update",
@@ -7058,6 +7219,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7058
7219
  refresh();
7059
7220
  } catch (operationError) {
7060
7221
  setRows(snapshot);
7222
+ setPendingRow(pendingSnapshot);
7061
7223
  noteError(operationError);
7062
7224
  refresh();
7063
7225
  throw toBridgeError(operationError);
@@ -7078,6 +7240,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7078
7240
  rowId,
7079
7241
  ...casOf(rowId)
7080
7242
  }] }, newMutationContext());
7243
+ setPendingRow((current) => current?.rowId === rowId ? null : current);
7081
7244
  if (row !== void 0 && capabilitiesRef.current.includes("rowRestore")) pushUndo({
7082
7245
  label: `remove row ${rowId}`,
7083
7246
  forward: async () => {
@@ -7169,6 +7332,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7169
7332
  rowId: row.rowId,
7170
7333
  cells: { ...row.cells }
7171
7334
  }));
7335
+ const pendingSnapshot = pendingRowRef.current;
7172
7336
  const before = new Map(rowsRef.current.map((row) => [row.rowId, row.cells]));
7173
7337
  const cleaned = updates.map(({ rowId, cells }) => {
7174
7338
  const patch = {};
@@ -7195,6 +7359,17 @@ function useDatabaseTable(bridge, tableId, filter) {
7195
7359
  }
7196
7360
  };
7197
7361
  }));
7362
+ setPendingRow((current) => {
7363
+ if (current === null) return null;
7364
+ const patch = byId.get(current.rowId);
7365
+ return patch === void 0 ? current : {
7366
+ ...current,
7367
+ cells: {
7368
+ ...current.cells,
7369
+ ...patch
7370
+ }
7371
+ };
7372
+ });
7198
7373
  }
7199
7374
  let liveRowIds = [];
7200
7375
  try {
@@ -7254,7 +7429,10 @@ function useDatabaseTable(bridge, tableId, filter) {
7254
7429
  refresh();
7255
7430
  return liveRowIds;
7256
7431
  } catch (operationError) {
7257
- if (updatesChanged) setRows(snapshot);
7432
+ if (updatesChanged) {
7433
+ setRows(snapshot);
7434
+ setPendingRow(pendingSnapshot);
7435
+ }
7258
7436
  noteError(operationError);
7259
7437
  refresh();
7260
7438
  throw toBridgeError(operationError);
@@ -7370,10 +7548,159 @@ function useDatabaseTable(bridge, tableId, filter) {
7370
7548
  if (hasNumberPatch) wirePatch.numberDisplay = numberDisplay;
7371
7549
  return Object.keys(wirePatch).length > 0 ? wirePatch : null;
7372
7550
  };
7551
+ const updateColumn = useCallback(async (columnId, patch) => {
7552
+ const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7553
+ const wirePatch = columnPatchOf(columnId, patch);
7554
+ if (current === void 0 || wirePatch === null) return;
7555
+ const previous = {
7556
+ ...current.operators !== void 0 ? { operators: [...current.operators] } : {},
7557
+ ...current.reference !== void 0 ? { reference: { ...current.reference } } : {},
7558
+ ...current.numberDisplay !== void 0 ? { numberDisplay: { ...current.numberDisplay } } : {}
7559
+ };
7560
+ try {
7561
+ await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7562
+ pushUndo({
7563
+ label: `update column ${columnId}`,
7564
+ forward: async () => {
7565
+ await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7566
+ },
7567
+ inverse: async () => {
7568
+ const restore = {};
7569
+ for (const key of Object.keys(wirePatch)) {
7570
+ const value = previous[key];
7571
+ if (value !== void 0) restore[key] = value;
7572
+ }
7573
+ await bridge.updateColumn(tableId, columnId, restore, newMutationContext());
7574
+ }
7575
+ }, bridge, tableId);
7576
+ } catch (operationError) {
7577
+ noteError(operationError);
7578
+ throw toBridgeError(operationError);
7579
+ }
7580
+ }, [
7581
+ bridge,
7582
+ tableId,
7583
+ pushUndo
7584
+ ]);
7585
+ const deleteColumn = useCallback(async (columnId) => {
7586
+ if (descriptionRef.current?.columns.some((entry) => entry.id === columnId) !== true) return;
7587
+ try {
7588
+ await bridge.deleteColumn(tableId, columnId, newMutationContext());
7589
+ if (capabilitiesRef.current.includes("columnRestore")) pushUndo({
7590
+ label: `delete column ${columnId}`,
7591
+ forward: async () => {
7592
+ await bridge.deleteColumn(tableId, columnId, newMutationContext());
7593
+ },
7594
+ inverse: async () => {
7595
+ await bridge.restoreDeletedColumn(tableId, columnId, newMutationContext());
7596
+ }
7597
+ }, bridge, tableId);
7598
+ } catch (operationError) {
7599
+ noteError(operationError);
7600
+ throw toBridgeError(operationError);
7601
+ }
7602
+ }, [
7603
+ bridge,
7604
+ tableId,
7605
+ pushUndo
7606
+ ]);
7607
+ const renameColumn = useCallback(async (columnId, name) => {
7608
+ const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7609
+ if (current === void 0 || current.name === name) return;
7610
+ try {
7611
+ await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7612
+ pushUndo({
7613
+ label: `rename column ${columnId}`,
7614
+ forward: async () => {
7615
+ await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7616
+ },
7617
+ inverse: async () => {
7618
+ await bridge.updateColumn(tableId, columnId, { name: current.name }, newMutationContext());
7619
+ }
7620
+ }, bridge, tableId);
7621
+ } catch (operationError) {
7622
+ noteError(operationError);
7623
+ throw toBridgeError(operationError);
7624
+ }
7625
+ }, [
7626
+ bridge,
7627
+ tableId,
7628
+ pushUndo
7629
+ ]);
7630
+ const renameTable = useCallback(async (name) => {
7631
+ const previous = descriptionRef.current?.table.name;
7632
+ if (previous === void 0 || previous === name) return;
7633
+ try {
7634
+ await bridge.renameTable(tableId, { name }, newMutationContext());
7635
+ pushUndo({
7636
+ label: `rename table to ${name}`,
7637
+ forward: async () => {
7638
+ await bridge.renameTable(tableId, { name }, newMutationContext());
7639
+ },
7640
+ inverse: async () => {
7641
+ await bridge.renameTable(tableId, { name: previous }, newMutationContext());
7642
+ }
7643
+ }, bridge, tableId);
7644
+ } catch (operationError) {
7645
+ noteError(operationError);
7646
+ throw toBridgeError(operationError);
7647
+ }
7648
+ }, [
7649
+ bridge,
7650
+ tableId,
7651
+ pushUndo
7652
+ ]);
7653
+ const loadMore = useCallback(async () => {
7654
+ if (nextCursor === null) return;
7655
+ const token = loadTokenRef.current;
7656
+ const { asOfSeq, fingerprint } = pageRef.current;
7657
+ try {
7658
+ const page = await bridge.queryNextPage(tableId, {
7659
+ cursor: nextCursor,
7660
+ asOfSeq,
7661
+ queryFingerprint: fingerprint
7662
+ });
7663
+ if (token !== loadTokenRef.current) return;
7664
+ pageRef.current = {
7665
+ asOfSeq: page.asOfSeq,
7666
+ fingerprint: page.queryFingerprint
7667
+ };
7668
+ for (const row of page.rows) revisionsRef.current.set(row.id, row.revision);
7669
+ setRows((rows) => {
7670
+ const known = new Set(rows.map((row) => row.rowId));
7671
+ const appended = page.rows.filter((row) => !known.has(row.id)).map((row) => ({
7672
+ rowId: row.id,
7673
+ cells: { ...row.cells }
7674
+ }));
7675
+ return [...rows, ...appended];
7676
+ });
7677
+ setNextCursor(page.nextCursor);
7678
+ } catch (operationError) {
7679
+ if (token !== loadTokenRef.current) return;
7680
+ if (isBridgeError(operationError) && operationError.code === "cursor_expired") {
7681
+ refresh();
7682
+ return;
7683
+ }
7684
+ noteError(operationError);
7685
+ }
7686
+ }, [
7687
+ bridge,
7688
+ tableId,
7689
+ nextCursor,
7690
+ refresh
7691
+ ]);
7692
+ const retry = useCallback(() => setLoadVersion((version) => version + 1), []);
7373
7693
  return {
7374
7694
  phase,
7375
7695
  table,
7376
7696
  rows,
7697
+ pendingRow,
7698
+ dismissPendingRow: useCallback((rowId) => {
7699
+ setPendingRow((current) => {
7700
+ if (current === null || rowId !== void 0 && current.rowId !== rowId) return current;
7701
+ return null;
7702
+ });
7703
+ }, []),
7377
7704
  revisionOf,
7378
7705
  nextCursor,
7379
7706
  error,
@@ -7384,153 +7711,18 @@ function useDatabaseTable(bridge, tableId, filter) {
7384
7711
  removeRow,
7385
7712
  moveRow,
7386
7713
  addColumn,
7387
- updateColumn: useCallback(async (columnId, patch) => {
7388
- const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7389
- const wirePatch = columnPatchOf(columnId, patch);
7390
- if (current === void 0 || wirePatch === null) return;
7391
- const previous = {
7392
- ...current.operators !== void 0 ? { operators: [...current.operators] } : {},
7393
- ...current.reference !== void 0 ? { reference: { ...current.reference } } : {},
7394
- ...current.numberDisplay !== void 0 ? { numberDisplay: { ...current.numberDisplay } } : {}
7395
- };
7396
- try {
7397
- await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7398
- pushUndo({
7399
- label: `update column ${columnId}`,
7400
- forward: async () => {
7401
- await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7402
- },
7403
- inverse: async () => {
7404
- const restore = {};
7405
- for (const key of Object.keys(wirePatch)) {
7406
- const value = previous[key];
7407
- if (value !== void 0) restore[key] = value;
7408
- }
7409
- await bridge.updateColumn(tableId, columnId, restore, newMutationContext());
7410
- }
7411
- }, bridge, tableId);
7412
- } catch (operationError) {
7413
- noteError(operationError);
7414
- throw toBridgeError(operationError);
7415
- }
7416
- }, [
7417
- bridge,
7418
- tableId,
7419
- pushUndo
7420
- ]),
7421
- deleteColumn: useCallback(async (columnId) => {
7422
- if (descriptionRef.current?.columns.some((entry) => entry.id === columnId) !== true) return;
7423
- try {
7424
- await bridge.deleteColumn(tableId, columnId, newMutationContext());
7425
- if (capabilitiesRef.current.includes("columnRestore")) pushUndo({
7426
- label: `delete column ${columnId}`,
7427
- forward: async () => {
7428
- await bridge.deleteColumn(tableId, columnId, newMutationContext());
7429
- },
7430
- inverse: async () => {
7431
- await bridge.restoreDeletedColumn(tableId, columnId, newMutationContext());
7432
- }
7433
- }, bridge, tableId);
7434
- } catch (operationError) {
7435
- noteError(operationError);
7436
- throw toBridgeError(operationError);
7437
- }
7438
- }, [
7439
- bridge,
7440
- tableId,
7441
- pushUndo
7442
- ]),
7443
- renameColumn: useCallback(async (columnId, name) => {
7444
- const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7445
- if (current === void 0 || current.name === name) return;
7446
- try {
7447
- await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7448
- pushUndo({
7449
- label: `rename column ${columnId}`,
7450
- forward: async () => {
7451
- await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7452
- },
7453
- inverse: async () => {
7454
- await bridge.updateColumn(tableId, columnId, { name: current.name }, newMutationContext());
7455
- }
7456
- }, bridge, tableId);
7457
- } catch (operationError) {
7458
- noteError(operationError);
7459
- throw toBridgeError(operationError);
7460
- }
7461
- }, [
7462
- bridge,
7463
- tableId,
7464
- pushUndo
7465
- ]),
7466
- renameTable: useCallback(async (name) => {
7467
- const previous = descriptionRef.current?.table.name;
7468
- if (previous === void 0 || previous === name) return;
7469
- try {
7470
- await bridge.renameTable(tableId, { name }, newMutationContext());
7471
- pushUndo({
7472
- label: `rename table to ${name}`,
7473
- forward: async () => {
7474
- await bridge.renameTable(tableId, { name }, newMutationContext());
7475
- },
7476
- inverse: async () => {
7477
- await bridge.renameTable(tableId, { name: previous }, newMutationContext());
7478
- }
7479
- }, bridge, tableId);
7480
- } catch (operationError) {
7481
- noteError(operationError);
7482
- throw toBridgeError(operationError);
7483
- }
7484
- }, [
7485
- bridge,
7486
- tableId,
7487
- pushUndo
7488
- ]),
7489
- loadMore: useCallback(async () => {
7490
- if (nextCursor === null) return;
7491
- const token = loadTokenRef.current;
7492
- const { asOfSeq, fingerprint } = pageRef.current;
7493
- try {
7494
- const page = await bridge.queryNextPage(tableId, {
7495
- cursor: nextCursor,
7496
- asOfSeq,
7497
- queryFingerprint: fingerprint
7498
- });
7499
- if (token !== loadTokenRef.current) return;
7500
- pageRef.current = {
7501
- asOfSeq: page.asOfSeq,
7502
- fingerprint: page.queryFingerprint
7503
- };
7504
- for (const row of page.rows) revisionsRef.current.set(row.id, row.revision);
7505
- setRows((rows) => {
7506
- const known = new Set(rows.map((row) => row.rowId));
7507
- const appended = page.rows.filter((row) => !known.has(row.id)).map((row) => ({
7508
- rowId: row.id,
7509
- cells: { ...row.cells }
7510
- }));
7511
- return [...rows, ...appended];
7512
- });
7513
- setNextCursor(page.nextCursor);
7514
- } catch (operationError) {
7515
- if (token !== loadTokenRef.current) return;
7516
- if (isBridgeError(operationError) && operationError.code === "cursor_expired") {
7517
- refresh();
7518
- return;
7519
- }
7520
- noteError(operationError);
7521
- }
7522
- }, [
7523
- bridge,
7524
- tableId,
7525
- nextCursor,
7526
- refresh
7527
- ]),
7528
- retry: useCallback(() => setLoadVersion((version) => version + 1), []),
7714
+ updateColumn,
7715
+ deleteColumn,
7716
+ renameColumn,
7717
+ renameTable,
7718
+ loadMore,
7719
+ retry,
7529
7720
  undo: useCallback(async () => {
7530
7721
  if (historyInFlightRef.current) return;
7531
7722
  const ops = undoStackRef.current;
7532
7723
  const op = ops[ops.length - 1];
7533
7724
  if (op === void 0) return;
7725
+ setPendingRow(null);
7534
7726
  const identity = {
7535
7727
  bridge: historyRef.current.bridge,
7536
7728
  tableId: historyRef.current.tableId
@@ -7564,6 +7756,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7564
7756
  const ops = redoStackRef.current;
7565
7757
  const op = ops[ops.length - 1];
7566
7758
  if (op === void 0) return;
7759
+ setPendingRow(null);
7567
7760
  const identity = {
7568
7761
  bridge: historyRef.current.bridge,
7569
7762
  tableId: historyRef.current.tableId
@@ -7600,6 +7793,290 @@ function useDatabaseTable(bridge, tableId, filter) {
7600
7793
  };
7601
7794
  }
7602
7795
  //#endregion
7796
+ //#region src/database/grid/utils.ts
7797
+ /** The database grid's pure helpers: the visible-column derivation, the
7798
+ * number column's display attributes / input step, the cell's selection
7799
+ * key, and the date/datetime value parsing + labels. */
7800
+ /** The full known id order: explicit ids first, then new schema columns. */
7801
+ function normalizeColumnOrder(columns, columnOrder) {
7802
+ const byId = new Map((columns ?? []).map((column) => [column.id, column]));
7803
+ const ordered = [];
7804
+ for (const id of columnOrder ?? []) {
7805
+ if (!byId.has(id) || ordered.includes(id)) continue;
7806
+ ordered.push(id);
7807
+ byId.delete(id);
7808
+ }
7809
+ for (const column of byId.values()) ordered.push(column.id);
7810
+ return ordered;
7811
+ }
7812
+ /** The block's visible columns: the full order minus the hidden ids. */
7813
+ function visibleColumns(columns, columnOrder, hiddenColumns) {
7814
+ const byId = new Map((columns ?? []).map((column) => [column.id, column]));
7815
+ const hidden = new Set(hiddenColumns ?? []);
7816
+ return normalizeColumnOrder(columns, columnOrder).flatMap((id) => {
7817
+ const column = byId.get(id);
7818
+ return column === void 0 || hidden.has(id) ? [] : [column];
7819
+ });
7820
+ }
7821
+ /** One immutable list move; an invalid or identity move returns the input. */
7822
+ function reorderItems(items, fromIndex, toIndex) {
7823
+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return items;
7824
+ const next = [...items];
7825
+ const [moved] = next.splice(fromIndex, 1);
7826
+ if (moved === void 0) return items;
7827
+ next.splice(toIndex, 0, moved);
7828
+ return next;
7829
+ }
7830
+ /** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
7831
+ function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
7832
+ const fullOrder = normalizeColumnOrder(columns, columnOrder);
7833
+ const visibleIds = visibleColumns(columns, columnOrder, hiddenColumns).map((column) => column.id);
7834
+ const stationary = visibleIds.filter((id) => id !== columnId);
7835
+ if (stationary.length === visibleIds.length || toIndex < 0 || toIndex > stationary.length) return fullOrder;
7836
+ const next = fullOrder.filter((id) => id !== columnId);
7837
+ const targetId = stationary[toIndex];
7838
+ if (targetId !== void 0) {
7839
+ next.splice(next.indexOf(targetId), 0, columnId);
7840
+ return next;
7841
+ }
7842
+ const anchorId = stationary.at(-1);
7843
+ if (anchorId === void 0) return fullOrder;
7844
+ next.splice(next.indexOf(anchorId) + 1, 0, columnId);
7845
+ return next;
7846
+ }
7847
+ /** The number input's step stand: the explicit `decimals` stands the
7848
+ * `10^-decimals` step; the absent stand follows the integer types only
7849
+ * (the float types stand no step — the 0.5 must be typeable). */
7850
+ function numberStepFor(column) {
7851
+ if (column.decimals !== void 0) {
7852
+ const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
7853
+ return decimals === 0 ? "1" : String(10 ** -decimals);
7854
+ }
7855
+ const base = column.type.replace(/\[\]$/, "").trim();
7856
+ return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
7857
+ }
7858
+ /** The display's attributes stand: the explicit `decimals` (or the
7859
+ * integer stand) takes the fixed-digit format; the float types without
7860
+ * the explicit digits stand the RAW value (no rounding — the display
7861
+ * must not lose the value's own stand). */
7862
+ function numberDisplayAttrs(column) {
7863
+ const base = column.type.replace(/\[\]$/, "").trim();
7864
+ return {
7865
+ decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
7866
+ thousands: column.thousands,
7867
+ prefix: column.prefix,
7868
+ suffix: column.suffix
7869
+ };
7870
+ }
7871
+ /** The cell's selection/editing key (the row id + the column id). */
7872
+ const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
7873
+ /** The cell's clipboard text: the TSV's flat stand (the tab / the
7874
+ * newline stand the space — the TSV's shape stands; the row-link's array
7875
+ * joins over the comma — the label's stand, never the id). */
7876
+ function cellTextOf(value) {
7877
+ if (value === void 0 || value === null) return "";
7878
+ if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
7879
+ return String(value).replace(/[\t\n\r]/g, " ");
7880
+ }
7881
+ /** The TSV's parse (the clipboard's plain text over the grid's paste):
7882
+ * the rows over the newline (the carriage return stands the newline),
7883
+ * the cells over the tab; the trailing empty row stands no stand (the
7884
+ * clipboard's trailing newline). An empty text stands no grid. */
7885
+ function parseClipboardTsv(text) {
7886
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
7887
+ if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
7888
+ if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
7889
+ return lines.map((line) => line.split(" "));
7890
+ }
7891
+ /** The local-calendar day (the year / month / date stand, the time is
7892
+ * dropped) — the picker's draft stand. */
7893
+ function dateOnly(value) {
7894
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
7895
+ }
7896
+ /** The time stand (the hours / minutes / the seconds are not all zero). */
7897
+ function hasTime(value) {
7898
+ return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
7899
+ }
7900
+ /** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
7901
+ * part) parsed to the local-calendar Date; null when absent / invalid. */
7902
+ function parseCellDateTime(value) {
7903
+ const raw = value === void 0 || value === null ? "" : String(value);
7904
+ if (raw === "") return null;
7905
+ if (raw.includes("T")) {
7906
+ const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
7907
+ const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
7908
+ return Number.isNaN(result.getTime()) ? null : result;
7909
+ }
7910
+ const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
7911
+ return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
7912
+ }
7913
+ /** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
7914
+ * only when they are not zero; the midnight zero stands the date only). */
7915
+ function dateTimeLabel(value) {
7916
+ const base = format(value, "dd.MM.yyyy");
7917
+ if (!hasTime(value)) return base;
7918
+ const label = format(value, "HH:mm");
7919
+ return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
7920
+ }
7921
+ /** The form draft over a catalog entry (the name prefills the type's
7922
+ * label — the create's commit takes the input's name). */
7923
+ function emptyColumnForm(entry) {
7924
+ return {
7925
+ key: entry.key,
7926
+ type: entry.type,
7927
+ name: entry.label,
7928
+ numberKind: entry.numberKind,
7929
+ decimals: entry.numberKind === "decimal" ? 2 : 0,
7930
+ thousands: false,
7931
+ prefix: "",
7932
+ suffix: "",
7933
+ allowNegative: true,
7934
+ refKind: entry.refKind,
7935
+ refMany: entry.refMany,
7936
+ refPick: "",
7937
+ newTableName: ""
7938
+ };
7939
+ }
7940
+ //#endregion
7941
+ //#region src/database/grid/ColumnManager.tsx
7942
+ function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragStart, onDragEnd }) {
7943
+ const { t } = useTranslation("database");
7944
+ const dragControls = useDragControls();
7945
+ const onGripPointerDown = (event) => {
7946
+ if (event.button !== 0) return;
7947
+ dragControls.start(event);
7948
+ };
7949
+ const onGripKeyDown = (event) => {
7950
+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
7951
+ event.preventDefault();
7952
+ event.stopPropagation();
7953
+ onMove(column.id, event.key === "ArrowUp" ? -1 : 1);
7954
+ };
7955
+ const onVisibilityChange = () => onToggle(column.id);
7956
+ const onReorderEnd = () => onDragEnd(column.id);
7957
+ return /* @__PURE__ */ jsxs(Reorder.Item, {
7958
+ as: "div",
7959
+ value: column.id,
7960
+ dragListener: false,
7961
+ dragControls,
7962
+ onDragStart,
7963
+ onDragEnd: onReorderEnd,
7964
+ className: "flex items-center gap-1 rounded-sm px-1 py-0.5 text-sm",
7965
+ children: [
7966
+ /* @__PURE__ */ jsx(Button, {
7967
+ type: "button",
7968
+ variant: "ghost",
7969
+ size: "icon",
7970
+ "data-slot": "docblocks/database-column-move",
7971
+ "data-column-id": column.id,
7972
+ "aria-label": t("columns.move", { name: column.name }),
7973
+ className: "size-6 shrink-0 cursor-grab text-muted-foreground active:cursor-grabbing",
7974
+ onPointerDown: onGripPointerDown,
7975
+ onKeyDown: onGripKeyDown,
7976
+ children: /* @__PURE__ */ jsx(GripVertical, { className: "size-3.5" })
7977
+ }),
7978
+ /* @__PURE__ */ jsx("span", {
7979
+ className: cn("min-w-0 flex-1 truncate px-1", hidden && "text-muted-foreground"),
7980
+ children: column.name
7981
+ }),
7982
+ /* @__PURE__ */ jsx(Checkbox, {
7983
+ "data-slot": "docblocks/database-column-visibility",
7984
+ "data-column-id": column.id,
7985
+ "aria-label": t("columns.visibility", { name: column.name }),
7986
+ checked: !hidden,
7987
+ disabled: hideDisabled,
7988
+ onCheckedChange: onVisibilityChange
7989
+ })
7990
+ ]
7991
+ });
7992
+ }
7993
+ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, triggerClassName, onViewChange }) {
7994
+ const { t } = useTranslation("database");
7995
+ const [open, setOpen] = useState(false);
7996
+ const [draftOrder, setDraftOrder] = useState(null);
7997
+ const dragStartOrderRef = useRef(null);
7998
+ const normalizedOrder = normalizeColumnOrder(columns, columnOrder);
7999
+ const order = draftOrder ?? normalizedOrder;
8000
+ const hidden = new Set(hiddenColumns ?? []);
8001
+ const hiddenCount = columns.filter((column) => hidden.has(column.id)).length;
8002
+ const visibleCount = columns.length - hiddenCount;
8003
+ const onOpenChange = (nextOpen) => {
8004
+ setOpen(nextOpen);
8005
+ if (!nextOpen) setDraftOrder(null);
8006
+ };
8007
+ const commitOrder = (columnId, nextOrder, previousOrder) => {
8008
+ if (nextOrder.every((id, index) => id === previousOrder[index])) return;
8009
+ const previousVisible = visibleColumns(columns, previousOrder, hiddenColumns).map((column) => column.id);
8010
+ const nextVisible = visibleColumns(columns, nextOrder, hiddenColumns).map((column) => column.id);
8011
+ const fromIndex = previousVisible.indexOf(columnId);
8012
+ const toIndex = nextVisible.indexOf(columnId);
8013
+ onViewChange({
8014
+ columnOrder: nextOrder,
8015
+ ...columnWidths !== void 0 ? { columnWidths: reorderItems(columnWidths, fromIndex, toIndex) } : {}
8016
+ });
8017
+ setDraftOrder(nextOrder);
8018
+ };
8019
+ const onDragStart = () => {
8020
+ dragStartOrderRef.current = order;
8021
+ };
8022
+ const onDragEnd = (columnId) => {
8023
+ const previousOrder = dragStartOrderRef.current ?? order;
8024
+ dragStartOrderRef.current = null;
8025
+ if (draftOrder !== null) commitOrder(columnId, draftOrder, previousOrder);
8026
+ };
8027
+ const onMove = (columnId, delta) => {
8028
+ const fromIndex = order.indexOf(columnId);
8029
+ const toIndex = fromIndex + delta;
8030
+ if (fromIndex < 0 || toIndex < 0 || toIndex >= order.length) return;
8031
+ commitOrder(columnId, reorderItems(order, fromIndex, toIndex), order);
8032
+ };
8033
+ const onToggle = (columnId) => {
8034
+ const isHidden = hidden.has(columnId);
8035
+ if (!isHidden && visibleCount === 1) return;
8036
+ onViewChange({ hiddenColumns: isHidden ? [...hidden].filter((id) => id !== columnId) : [...hidden, columnId] });
8037
+ };
8038
+ return /* @__PURE__ */ jsxs(Popover, {
8039
+ open,
8040
+ onOpenChange,
8041
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
8042
+ asChild: true,
8043
+ children: /* @__PURE__ */ jsxs(Button, {
8044
+ "data-slot": "docblocks/database-columns",
8045
+ variant: "outline",
8046
+ size: "sm",
8047
+ "data-active": hiddenCount > 0 ? "true" : void 0,
8048
+ className: triggerClassName,
8049
+ children: [t("toolbar.columns"), hiddenCount > 0 ? " •" : ""]
8050
+ })
8051
+ }), /* @__PURE__ */ jsx(PopoverContent, {
8052
+ "data-slot": "docblocks/database-columns-content",
8053
+ "aria-label": t("toolbar.columns"),
8054
+ align: "end",
8055
+ className: "w-72 p-2",
8056
+ children: /* @__PURE__ */ jsx(Reorder.Group, {
8057
+ as: "div",
8058
+ axis: "y",
8059
+ values: order,
8060
+ onReorder: setDraftOrder,
8061
+ className: "flex max-h-80 scrollbar-thin flex-col gap-0.5 overflow-y-auto",
8062
+ children: order.map((columnId) => {
8063
+ const column = columns.find((entry) => entry.id === columnId);
8064
+ if (column === void 0) return null;
8065
+ return /* @__PURE__ */ jsx(ColumnRow, {
8066
+ column,
8067
+ hidden: hidden.has(column.id),
8068
+ hideDisabled: !hidden.has(column.id) && visibleCount === 1,
8069
+ onToggle,
8070
+ onMove,
8071
+ onDragStart,
8072
+ onDragEnd
8073
+ }, column.id);
8074
+ })
8075
+ })
8076
+ })]
8077
+ });
8078
+ }
8079
+ //#endregion
7603
8080
  //#region src/database/grid/EnumOptionsEditor.tsx
7604
8081
  /** The enum's options editor (the create / the edit's form stand): the
7605
8082
  * option's rows over the draft (the grip's press-drag stands the live
@@ -7836,8 +8313,6 @@ const CELL_WRAP = "flex min-h-6 min-w-0 items-center overflow-hidden border-(--d
7836
8313
  * edit's stand). */
7837
8314
  const CELL_INPUT = "select-text rounded-(--docblocks-radius) border-0 bg-transparent px-1 text-(length:--docblocks-font-size) focus:bg-(--docblocks-selected-background)/50 dark:bg-transparent";
7838
8315
  const GRID_DRAG_TRANSITION = "transform 120ms ease-out";
7839
- /** The undo / redo button's frame stand (the disabled's off). */
7840
- const GRID_HISTORY_BUTTON = "h-auto px-2 py-0.5 text-xs font-normal shadow-none disabled:cursor-default disabled:opacity-40";
7841
8316
  //#endregion
7842
8317
  //#region src/database/grid/HeaderCell.tsx
7843
8318
  /** The grid's header cell (the column's name + the press menu + the
@@ -8005,161 +8480,45 @@ function CellEditInput({ draft, kind, min, step, alignRight, onDraftChange, onEn
8005
8480
  min,
8006
8481
  step,
8007
8482
  className: cn(CELL_INPUT, alignRight && "text-right"),
8008
- value: draft,
8009
- onChange: onInputChange,
8010
- onBlur: onEnd,
8011
- onKeyDown: onInputKeyDown
8012
- });
8013
- }
8014
- //#endregion
8015
- //#region src/database/number-format.ts
8016
- /** The digit count after the point (the explicit `null` = the raw stand; the absent / invalid stand is 0; the cap is 10). */
8017
- function decimalsOf(attrs) {
8018
- if (attrs.decimals === null) return null;
8019
- const parsed = Math.trunc(Number(attrs.decimals));
8020
- if (!Number.isFinite(parsed)) return 0;
8021
- return Math.max(0, Math.min(10, parsed));
8022
- }
8023
- /** The integer part's thousands grouping (the regular space every 3 digits). */
8024
- function groupThousands(part) {
8025
- return part.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
8026
- }
8027
- /**
8028
- * Formats the number's display value. The rounding stands on
8029
- * `toFixed` (the fixed digit count) — the raw stand (the explicit
8030
- * `null` decimals) stands the value's own string. The negative stand
8031
- * keeps the sign on the integer part, the numerically-zero negative
8032
- * (`-0.4` at 0 decimals) stands the bare zero.
8033
- */
8034
- function formatNumberValue(value, attrs) {
8035
- const decimals = decimalsOf(attrs);
8036
- const [integer = "", fraction] = (decimals === null ? String(Math.abs(value)) : Math.abs(value).toFixed(decimals)).split(".");
8037
- let formatted = attrs.thousands ? groupThousands(integer) : integer;
8038
- if (fraction !== void 0) formatted += `.${fraction}`;
8039
- if (formatted === "0" && value < 0) return `${frame(attrs.prefix)}0${frame(attrs.suffix, true)}`;
8040
- const sign = value < 0 ? "-" : "";
8041
- return `${frame(attrs.prefix)}${sign}${formatted}${frame(attrs.suffix, true)}`;
8042
- }
8043
- /** The frame's space join (the absent / empty frame stands bare). */
8044
- function frame(frameText, trailing = false) {
8045
- if (frameText === void 0 || frameText === "") return "";
8046
- return trailing ? ` ${frameText}` : `${frameText} `;
8047
- }
8048
- //#endregion
8049
- //#region src/database/grid/utils.ts
8050
- /** The database grid's pure helpers: the visible-column derivation, the
8051
- * number column's display attributes / input step, the cell's selection
8052
- * key, and the date/datetime value parsing + labels. */
8053
- /** The block's visible columns: the `columnOrder` attr first (the
8054
- * additive columns not listed keep the schema order), the hidden
8055
- * columns dropped. */
8056
- function visibleColumns(columns, columnOrder, hiddenColumns) {
8057
- const all = columns ?? [];
8058
- const hidden = new Set(hiddenColumns ?? []);
8059
- const byId = new Map(all.filter((column) => !hidden.has(column.id)).map((column) => [column.id, column]));
8060
- const ordered = [];
8061
- if (columnOrder !== void 0) for (const id of columnOrder) {
8062
- const column = byId.get(id);
8063
- if (column !== void 0) {
8064
- ordered.push(column);
8065
- byId.delete(id);
8066
- }
8067
- }
8068
- for (const column of byId.values()) ordered.push(column);
8069
- return ordered;
8070
- }
8071
- /** The number input's step stand: the explicit `decimals` stands the
8072
- * `10^-decimals` step; the absent stand follows the integer types only
8073
- * (the float types stand no step — the 0.5 must be typeable). */
8074
- function numberStepFor(column) {
8075
- if (column.decimals !== void 0) {
8076
- const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
8077
- return decimals === 0 ? "1" : String(10 ** -decimals);
8078
- }
8079
- const base = column.type.replace(/\[\]$/, "").trim();
8080
- return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
8081
- }
8082
- /** The display's attributes stand: the explicit `decimals` (or the
8083
- * integer stand) takes the fixed-digit format; the float types without
8084
- * the explicit digits stand the RAW value (no rounding — the display
8085
- * must not lose the value's own stand). */
8086
- function numberDisplayAttrs(column) {
8087
- const base = column.type.replace(/\[\]$/, "").trim();
8088
- return {
8089
- decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
8090
- thousands: column.thousands,
8091
- prefix: column.prefix,
8092
- suffix: column.suffix
8093
- };
8094
- }
8095
- /** The cell's selection/editing key (the row id + the column id). */
8096
- const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
8097
- /** The cell's clipboard text: the TSV's flat stand (the tab / the
8098
- * newline stand the space — the TSV's shape stands; the row-link's array
8099
- * joins over the comma — the label's stand, never the id). */
8100
- function cellTextOf(value) {
8101
- if (value === void 0 || value === null) return "";
8102
- if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
8103
- return String(value).replace(/[\t\n\r]/g, " ");
8104
- }
8105
- /** The TSV's parse (the clipboard's plain text over the grid's paste):
8106
- * the rows over the newline (the carriage return stands the newline),
8107
- * the cells over the tab; the trailing empty row stands no stand (the
8108
- * clipboard's trailing newline). An empty text stands no grid. */
8109
- function parseClipboardTsv(text) {
8110
- const lines = text.replace(/\r\n?/g, "\n").split("\n");
8111
- if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
8112
- if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
8113
- return lines.map((line) => line.split(" "));
8114
- }
8115
- /** The local-calendar day (the year / month / date stand, the time is
8116
- * dropped) — the picker's draft stand. */
8117
- function dateOnly(value) {
8118
- return new Date(value.getFullYear(), value.getMonth(), value.getDate());
8483
+ value: draft,
8484
+ onChange: onInputChange,
8485
+ onBlur: onEnd,
8486
+ onKeyDown: onInputKeyDown
8487
+ });
8119
8488
  }
8120
- /** The time stand (the hours / minutes / the seconds are not all zero). */
8121
- function hasTime(value) {
8122
- return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
8489
+ //#endregion
8490
+ //#region src/database/number-format.ts
8491
+ /** The digit count after the point (the explicit `null` = the raw stand; the absent / invalid stand is 0; the cap is 10). */
8492
+ function decimalsOf(attrs) {
8493
+ if (attrs.decimals === null) return null;
8494
+ const parsed = Math.trunc(Number(attrs.decimals));
8495
+ if (!Number.isFinite(parsed)) return 0;
8496
+ return Math.max(0, Math.min(10, parsed));
8123
8497
  }
8124
- /** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
8125
- * part) parsed to the local-calendar Date; null when absent / invalid. */
8126
- function parseCellDateTime(value) {
8127
- const raw = value === void 0 || value === null ? "" : String(value);
8128
- if (raw === "") return null;
8129
- if (raw.includes("T")) {
8130
- const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
8131
- const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
8132
- return Number.isNaN(result.getTime()) ? null : result;
8133
- }
8134
- const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
8135
- return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
8498
+ /** The integer part's thousands grouping (the regular space every 3 digits). */
8499
+ function groupThousands(part) {
8500
+ return part.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
8136
8501
  }
8137
- /** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
8138
- * only when they are not zero; the midnight zero stands the date only). */
8139
- function dateTimeLabel(value) {
8140
- const base = format(value, "dd.MM.yyyy");
8141
- if (!hasTime(value)) return base;
8142
- const label = format(value, "HH:mm");
8143
- return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
8502
+ /**
8503
+ * Formats the number's display value. The rounding stands on
8504
+ * `toFixed` (the fixed digit count) — the raw stand (the explicit
8505
+ * `null` decimals) stands the value's own string. The negative stand
8506
+ * keeps the sign on the integer part, the numerically-zero negative
8507
+ * (`-0.4` at 0 decimals) stands the bare zero.
8508
+ */
8509
+ function formatNumberValue(value, attrs) {
8510
+ const decimals = decimalsOf(attrs);
8511
+ const [integer = "", fraction] = (decimals === null ? String(Math.abs(value)) : Math.abs(value).toFixed(decimals)).split(".");
8512
+ let formatted = attrs.thousands ? groupThousands(integer) : integer;
8513
+ if (fraction !== void 0) formatted += `.${fraction}`;
8514
+ if (formatted === "0" && value < 0) return `${frame(attrs.prefix)}0${frame(attrs.suffix, true)}`;
8515
+ const sign = value < 0 ? "-" : "";
8516
+ return `${frame(attrs.prefix)}${sign}${formatted}${frame(attrs.suffix, true)}`;
8144
8517
  }
8145
- /** The form draft over a catalog entry (the name prefills the type's
8146
- * label — the create's commit takes the input's name). */
8147
- function emptyColumnForm(entry) {
8148
- return {
8149
- key: entry.key,
8150
- type: entry.type,
8151
- name: entry.label,
8152
- numberKind: entry.numberKind,
8153
- decimals: entry.numberKind === "decimal" ? 2 : 0,
8154
- thousands: false,
8155
- prefix: "",
8156
- suffix: "",
8157
- allowNegative: true,
8158
- refKind: entry.refKind,
8159
- refMany: entry.refMany,
8160
- refPick: "",
8161
- newTableName: ""
8162
- };
8518
+ /** The frame's space join (the absent / empty frame stands bare). */
8519
+ function frame(frameText, trailing = false) {
8520
+ if (frameText === void 0 || frameText === "") return "";
8521
+ return trailing ? ` ${frameText}` : `${frameText} `;
8163
8522
  }
8164
8523
  //#endregion
8165
8524
  //#region src/database/grid/cells/constants.ts
@@ -8540,7 +8899,7 @@ function RowLinkPicker({ rowIds, displays, current, open, onPick, onClear, onEdi
8540
8899
  * placeholder, no trigger chrome): the pickers open on the double press
8541
8900
  * over the cell itself.
8542
8901
  */
8543
- function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, first, lastRow, dragDx, dragShifted, selected, singleSelected, editing, onChange, onPointerDown, onEditStart, onEditEnd, booleanPress, refTableData }) {
8902
+ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, first, lastRow, filterPending, dragDx, dragShifted, selected, singleSelected, editing, onChange, onPointerDown, onEditStart, onEditEnd, booleanPress, refTableData }) {
8544
8903
  const annotation = columnAnnotation(column);
8545
8904
  const empty = value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
8546
8905
  const isDate = annotation.valueInput === "date";
@@ -8561,6 +8920,14 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
8561
8920
  const openValueRef = useRef(null);
8562
8921
  const openDateRef = useRef(null);
8563
8922
  const openRevisionRef = useRef(void 0);
8923
+ useEffect(() => {
8924
+ if (!editing || !isText && !isNumber || openValueRef.current !== null) return;
8925
+ textCancelledRef.current = false;
8926
+ textSettledRef.current = false;
8927
+ openValueRef.current = rawValue;
8928
+ openRevisionRef.current = revision;
8929
+ setTextDraft(rawValue);
8930
+ }, [editing]);
8564
8931
  const multiLineSeatRef = useRef(null);
8565
8932
  useEffect(() => {
8566
8933
  if (!editing) multiLineSeatRef.current = null;
@@ -8828,6 +9195,8 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
8828
9195
  const cell = /* @__PURE__ */ jsx("div", {
8829
9196
  "data-slot": "docblocks/database-cell",
8830
9197
  "data-key": cellKeyOf(rowId, column.id),
9198
+ "data-row-id": rowId,
9199
+ "data-filter-pending": filterPending ? "true" : void 0,
8831
9200
  "data-row": rowIndex,
8832
9201
  "data-col": colIndex,
8833
9202
  "data-column-id": column.id,
@@ -8888,11 +9257,13 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
8888
9257
  /** The grid's row-menu track (the trailing grid column: the move / the
8889
9258
  * delete row affordances). */
8890
9259
  /** The row's menu track (the trailing grid column). */
8891
- function RowMenuCell({ row, rowMenu, setRowMenu, canMoveUp, canMoveDown, onMoveUp, onMoveDown, onRemove, lastRow }) {
9260
+ function RowMenuCell({ row, rowMenu, setRowMenu, canMoveUp, canMoveDown, onMoveUp, onMoveDown, onRemove, lastRow, filterPending }) {
8892
9261
  const { t } = useTranslation("database");
8893
9262
  const onRowMenuChange = (open) => setRowMenu(open ? row.rowId : null);
8894
9263
  return /* @__PURE__ */ jsx("div", {
8895
9264
  "data-slot": "docblocks/database-row-menu",
9265
+ "data-row-id": row.rowId,
9266
+ "data-filter-pending": filterPending ? "true" : void 0,
8896
9267
  className: cn(`
8897
9268
  flex w-10 items-center justify-center border-l-(length:--docblocks-table-border-width)
8898
9269
  border-(--docblocks-table-border-color)
@@ -9246,7 +9617,7 @@ function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = fals
9246
9617
  * columns against the press-time snapshot — a peer restructure stands no
9247
9618
  * commit), and the cancel. The preview's state stands in the hook (the view
9248
9619
  * reads the dragged column's live dx + the parting shift). */
9249
- function useGridColumnDrag({ columns, updateView, tableRef }) {
9620
+ function useGridColumnDrag({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, updateView, tableRef }) {
9250
9621
  const [drag, setDrag] = useState(null);
9251
9622
  const dragSession = useRef(null);
9252
9623
  const onColumnPointerDown = (column, event) => {
@@ -9258,6 +9629,7 @@ function useGridColumnDrag({ columns, updateView, tableRef }) {
9258
9629
  index,
9259
9630
  startX: event.clientX,
9260
9631
  ids: columns.map((entry) => entry.id),
9632
+ order: normalizeColumnOrder(allColumns, columnOrder),
9261
9633
  started: false,
9262
9634
  startWidth: event.currentTarget.getBoundingClientRect().width
9263
9635
  };
@@ -9304,11 +9676,13 @@ function useGridColumnDrag({ columns, updateView, tableRef }) {
9304
9676
  if (!session.started) return;
9305
9677
  setDrag(null);
9306
9678
  if (!columns.map((entry) => entry.id).every((value, i) => session.ids[i] === value)) return;
9679
+ if (!normalizeColumnOrder(allColumns, columnOrder).every((value, i) => session.order[i] === value)) return;
9307
9680
  const toIndex = columnDropIndexAt(event.clientX, session.columnId);
9308
9681
  if (toIndex === null || toIndex === session.index) return;
9309
- const ids = session.ids.filter((value) => value !== session.columnId);
9310
- ids.splice(toIndex, 0, session.columnId);
9311
- updateView({ columnOrder: ids });
9682
+ updateView({
9683
+ columnOrder: moveVisibleColumn(allColumns, columnOrder, hiddenColumns, session.columnId, toIndex),
9684
+ ...columnWidths !== void 0 ? { columnWidths: reorderItems(columnWidths, session.index, toIndex) } : {}
9685
+ });
9312
9686
  };
9313
9687
  return {
9314
9688
  drag,
@@ -9723,6 +10097,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9723
10097
  };
9724
10098
  const [nameDraft, setNameDraft] = useState(null);
9725
10099
  const tableRef = useRef(null);
10100
+ const pendingDismissTimerRef = useRef(null);
9726
10101
  const columns = visibleColumns(data.table?.columns, columnOrder, hiddenColumns);
9727
10102
  const updateView = (patch) => {
9728
10103
  onViewChange(patch);
@@ -9734,6 +10109,10 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9734
10109
  });
9735
10110
  const { drag, onColumnPointerDown, onColumnPointerMove, onColumnPointerUp } = useGridColumnDrag({
9736
10111
  columns,
10112
+ allColumns: data.table?.columns,
10113
+ columnOrder,
10114
+ hiddenColumns,
10115
+ columnWidths,
9737
10116
  updateView,
9738
10117
  tableRef
9739
10118
  });
@@ -9744,7 +10123,10 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9744
10123
  return (index < dragFrom ? index >= to ? 1 : 0 : index - 1 < to ? -1 : 0) * drag.startWidth;
9745
10124
  };
9746
10125
  const displayName = data.table?.name ?? tableId;
9747
- const rows = data.rows;
10126
+ const showName = blockId !== void 0;
10127
+ const pendingRow = data.pendingRow !== null && !data.rows.some((row) => row.rowId === data.pendingRow?.rowId) ? data.pendingRow : null;
10128
+ const pendingRowId = pendingRow?.rowId ?? null;
10129
+ const rows = pendingRow === null ? data.rows : [...data.rows, pendingRow];
9748
10130
  const { editingCell, setEditingCell, selectedCells, booleanPressRef, onCellPointerDown, onTableKeyDown, onTablePaste } = useGridCellInteraction({
9749
10131
  rows,
9750
10132
  columns,
@@ -9752,6 +10134,40 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9752
10134
  tableRef,
9753
10135
  readOnly
9754
10136
  });
10137
+ const pendingEditKey = pendingRowId !== null && columns[0] !== void 0 ? cellKeyOf(pendingRowId, columns[0].id) : null;
10138
+ useEffect(() => {
10139
+ if (pendingEditKey !== null) setEditingCell(pendingEditKey);
10140
+ }, [pendingEditKey, setEditingCell]);
10141
+ const dismissPending = useCallback(() => {
10142
+ if (pendingRowId === null) return;
10143
+ setEditingCell(null);
10144
+ if (pendingDismissTimerRef.current !== null) window.clearTimeout(pendingDismissTimerRef.current);
10145
+ pendingDismissTimerRef.current = window.setTimeout(() => {
10146
+ data.dismissPendingRow(pendingRowId);
10147
+ pendingDismissTimerRef.current = null;
10148
+ }, 0);
10149
+ }, [
10150
+ pendingRowId,
10151
+ data.dismissPendingRow,
10152
+ setEditingCell
10153
+ ]);
10154
+ useEffect(() => {
10155
+ if (pendingRowId === null) return;
10156
+ const onDown = (event) => {
10157
+ const target = event.target instanceof Element ? event.target : null;
10158
+ if (target === null) return;
10159
+ if (target.closest("[data-radix-popper-content-wrapper], [data-filter-pending='true']") !== null) return;
10160
+ dismissPending();
10161
+ };
10162
+ document.addEventListener("pointerdown", onDown, true);
10163
+ return () => {
10164
+ document.removeEventListener("pointerdown", onDown, true);
10165
+ if (pendingDismissTimerRef.current !== null) {
10166
+ window.clearTimeout(pendingDismissTimerRef.current);
10167
+ pendingDismissTimerRef.current = null;
10168
+ }
10169
+ };
10170
+ }, [pendingRowId, dismissPending]);
9755
10171
  if (data.phase === "loading") return /* @__PURE__ */ jsx(Card, {
9756
10172
  "data-slot": "docblocks/block",
9757
10173
  "data-block-type": "database",
@@ -9830,7 +10246,10 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9830
10246
  const columnMenuChange = (column) => (open) => setColumnMenu(open ? column.id : null);
9831
10247
  const columnRename = (column) => (renameName) => void data.renameColumn(column.id, renameName).catch(() => void 0);
9832
10248
  const columnEditOptions = (column) => column.refKind === "enum" && column.refTableId !== void 0 ? () => openColumnFormEdit(column) : void 0;
9833
- const columnHide = (column) => () => updateView({ hiddenColumns: [...hiddenColumns ?? [], column.id] });
10249
+ const columnHide = (column) => () => {
10250
+ if (columns.length <= 1) return;
10251
+ updateView({ hiddenColumns: [...hiddenColumns ?? [], column.id] });
10252
+ };
9834
10253
  const columnShow = (column) => () => updateView({ hiddenColumns: (hiddenColumns ?? []).filter((entryId) => entryId !== column.id) });
9835
10254
  const columnDelete = (column) => () => void data.deleteColumn(column.id).catch(() => void 0);
9836
10255
  const columnPointerDown = (column) => (event) => {
@@ -9850,6 +10269,14 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9850
10269
  setEditingCell(cellKey);
9851
10270
  };
9852
10271
  const cellEditEnd = () => setEditingCell(null);
10272
+ const onTableBlur = (event) => {
10273
+ if (pendingRowId === null) return;
10274
+ const next = event.relatedTarget;
10275
+ if (!(next instanceof Node)) return;
10276
+ if (tableRef.current?.contains(next)) return;
10277
+ if (next instanceof Element && next.closest("[data-radix-popper-content-wrapper]") !== null) return;
10278
+ dismissPending();
10279
+ };
9853
10280
  const rowMoveUp = (row) => () => {
9854
10281
  const index = rows.indexOf(row);
9855
10282
  if (index > 0) data.moveRow(row.rowId, rows[index - 1].rowId).catch(() => void 0);
@@ -9864,6 +10291,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9864
10291
  "data-block-type": "database",
9865
10292
  "data-block-id": blockId,
9866
10293
  "data-state": "ready",
10294
+ contentEditable: false,
9867
10295
  className: "\n my-(--docblocks-block-spacing) flex min-h-0 flex-1 flex-col rounded-(--docblocks-radius)\n border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) outline-none\n ",
9868
10296
  children: /* @__PURE__ */ jsxs(CardContent, {
9869
10297
  "data-slot": "docblocks/database",
@@ -9873,10 +10301,13 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9873
10301
  "data-slot": "docblocks/database-toolbar",
9874
10302
  className: "flex flex-wrap items-center gap-2",
9875
10303
  children: [
9876
- nameDraft !== null ? /* @__PURE__ */ jsx(Input, {
10304
+ showName && (nameDraft !== null ? /* @__PURE__ */ jsx(Input, {
9877
10305
  size: "sm",
9878
10306
  "data-slot": "docblocks/database-name-input",
9879
- className: cn(GRID_CHROME_FRAME, "h-auto min-w-32 px-1 py-0.5 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)"),
10307
+ className: cn(GRID_CHROME_FRAME, `
10308
+ h-auto min-w-32 px-1 py-0.5 text-(length:--docblocks-font-size)
10309
+ font-(--docblocks-heading-font-weight)
10310
+ `),
9880
10311
  value: nameDraft,
9881
10312
  autoFocus: true,
9882
10313
  onChange: onNameChange,
@@ -9894,81 +10325,88 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9894
10325
  className: " h-auto cursor-text border-0 bg-transparent px-1 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight) hover:bg-transparent hover:opacity-70 hover:text-inherit dark:bg-transparent dark:hover:bg-transparent",
9895
10326
  onClick: beginNameEdit,
9896
10327
  children: displayName
9897
- }),
10328
+ })),
9898
10329
  /* @__PURE__ */ jsxs(Badge, {
9899
10330
  "data-slot": "docblocks/database-count",
9900
10331
  variant: "secondary",
9901
10332
  children: [
9902
- rows.length,
10333
+ data.rows.length,
9903
10334
  " ",
9904
- t("rowCount", { count: rows.length })
10335
+ t("rowCount", { count: data.rows.length })
9905
10336
  ]
9906
10337
  }),
9907
10338
  /* @__PURE__ */ jsxs("div", {
9908
10339
  className: "ml-auto flex items-center gap-2",
9909
- children: [readOnly ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
9910
- "data-slot": "docblocks/database-undo",
9911
- variant: "outline",
9912
- size: "sm",
9913
- "data-disabled": data.canUndo ? void 0 : true,
9914
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, GRID_HISTORY_BUTTON),
9915
- disabled: !data.canUndo,
9916
- onClick: undoStep,
9917
- children: t("toolbar.undo")
9918
- }), /* @__PURE__ */ jsx(Button, {
9919
- "data-slot": "docblocks/database-redo",
9920
- variant: "outline",
9921
- size: "sm",
9922
- "data-disabled": data.canRedo ? void 0 : true,
9923
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, GRID_HISTORY_BUTTON),
9924
- disabled: !data.canRedo,
9925
- onClick: redoStep,
9926
- children: t("toolbar.redo")
9927
- })] }), readOnly ? null : /* @__PURE__ */ jsxs(Popover, {
9928
- open: filterOpen,
9929
- onOpenChange: onFilterOpenChange,
9930
- children: [/* @__PURE__ */ jsx(PopoverTrigger, {
9931
- asChild: true,
9932
- children: /* @__PURE__ */ jsxs(Button, {
9933
- "data-slot": "docblocks/database-filter",
9934
- variant: "outline",
9935
- size: "sm",
9936
- "data-active": filter !== void 0 && filter.conditions.length > 0 ? "true" : void 0,
9937
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, "h-auto px-2 py-0.5 text-xs font-normal shadow-none"),
9938
- children: [t("toolbar.filter"), filter !== void 0 && filter.conditions.length > 0 ? " •" : ""]
9939
- })
9940
- }), /* @__PURE__ */ jsx(PopoverContent, {
9941
- align: "end",
9942
- className: "w-96",
9943
- children: /* @__PURE__ */ jsxs("div", {
9944
- className: "flex flex-col gap-(--docblocks-block-spacing)",
9945
- children: [/* @__PURE__ */ jsx(FilterBuilder, {
9946
- value: filterDraft,
9947
- columns: data.table.columns,
9948
- onChange: setFilterDraft,
9949
- refTableData
9950
- }), /* @__PURE__ */ jsxs("div", {
9951
- className: "flex items-center justify-between gap-2",
9952
- children: [/* @__PURE__ */ jsx(Button, {
9953
- "data-slot": "docblocks/filter-clear",
9954
- variant: "outline",
9955
- size: "sm",
9956
- className: "\n cursor-pointer bg-transparent px-2 py-1 text-xs font-normal shadow-none\n hover:bg-transparent hover:opacity-70\n dark:bg-transparent\n dark:hover:bg-transparent\n ",
9957
- onClick: resetFilterDraft,
9958
- children: t("common:clear")
9959
- }), /* @__PURE__ */ jsx(Button, {
9960
- "data-slot": "docblocks/filter-apply",
9961
- variant: "outline",
9962
- size: "sm",
9963
- disabled: !filterIsComplete(filterDraft, data.table.columns),
9964
- className: "\n cursor-pointer bg-accent px-2 py-1 text-xs font-normal\n hover:opacity-70\n disabled:cursor-default disabled:opacity-40\n ",
9965
- onClick: applyFilter,
9966
- children: t("toolbar.apply")
10340
+ children: [
10341
+ readOnly ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
10342
+ "data-slot": "docblocks/database-undo",
10343
+ variant: "outline",
10344
+ size: "sm",
10345
+ "data-disabled": data.canUndo ? void 0 : true,
10346
+ disabled: !data.canUndo,
10347
+ onClick: undoStep,
10348
+ children: t("toolbar.undo")
10349
+ }), /* @__PURE__ */ jsx(Button, {
10350
+ "data-slot": "docblocks/database-redo",
10351
+ variant: "outline",
10352
+ size: "sm",
10353
+ "data-disabled": data.canRedo ? void 0 : true,
10354
+ disabled: !data.canRedo,
10355
+ onClick: redoStep,
10356
+ children: t("toolbar.redo")
10357
+ })] }),
10358
+ readOnly ? null : /* @__PURE__ */ jsx(ColumnManager, {
10359
+ columns: data.table.columns,
10360
+ columnOrder,
10361
+ hiddenColumns,
10362
+ columnWidths,
10363
+ onViewChange: updateView
10364
+ }),
10365
+ readOnly ? null : /* @__PURE__ */ jsxs(Popover, {
10366
+ open: filterOpen,
10367
+ onOpenChange: onFilterOpenChange,
10368
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
10369
+ asChild: true,
10370
+ children: /* @__PURE__ */ jsxs(Button, {
10371
+ "data-slot": "docblocks/database-filter",
10372
+ variant: "outline",
10373
+ size: "sm",
10374
+ "data-active": filter !== void 0 && filter.conditions.length > 0 ? "true" : void 0,
10375
+ children: [t("toolbar.filter"), filter !== void 0 && filter.conditions.length > 0 ? " •" : ""]
10376
+ })
10377
+ }), /* @__PURE__ */ jsx(PopoverContent, {
10378
+ align: "end",
10379
+ className: "w-fit max-w-xl min-w-110",
10380
+ children: /* @__PURE__ */ jsxs("div", {
10381
+ className: "flex flex-col gap-(--docblocks-block-spacing)",
10382
+ children: [/* @__PURE__ */ jsx(FilterBuilder, {
10383
+ value: filterDraft,
10384
+ columns: data.table.columns,
10385
+ onChange: setFilterDraft,
10386
+ refTableData
10387
+ }), /* @__PURE__ */ jsxs("div", {
10388
+ "data-slot": "docblocks/filter-footer",
10389
+ className: "flex items-center gap-2 border-t border-border pt-2",
10390
+ children: [/* @__PURE__ */ jsx(Button, {
10391
+ "data-slot": "docblocks/filter-clear",
10392
+ variant: "outline",
10393
+ size: "sm",
10394
+ onClick: resetFilterDraft,
10395
+ children: t("common:clear")
10396
+ }), /* @__PURE__ */ jsx(Button, {
10397
+ "data-slot": "docblocks/filter-apply",
10398
+ variant: "outline",
10399
+ size: "sm",
10400
+ disabled: !filterIsComplete(filterDraft, data.table.columns),
10401
+ className: "bg-accent text-accent-foreground",
10402
+ onClick: applyFilter,
10403
+ children: t("toolbar.apply")
10404
+ })]
9967
10405
  })]
9968
- })]
9969
- })
9970
- })]
9971
- })]
10406
+ })
10407
+ })]
10408
+ })
10409
+ ]
9972
10410
  })
9973
10411
  ]
9974
10412
  }),
@@ -9982,6 +10420,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9982
10420
  className: "grid w-full outline-none select-none",
9983
10421
  onKeyDown: onTableKeyDown,
9984
10422
  onPaste: onTablePaste,
10423
+ onBlur: onTableBlur,
9985
10424
  style: {
9986
10425
  gridTemplateRows: "auto",
9987
10426
  gridAutoRows: "var(--docblocks-database-row-height)",
@@ -10180,6 +10619,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10180
10619
  colIndex: index,
10181
10620
  first: index === 0,
10182
10621
  lastRow: row.rowId === lastRowId,
10622
+ filterPending: row.rowId === pendingRowId,
10183
10623
  dragDx: drag !== null && drag.id === column.id ? drag.dx : dragShiftOf(index),
10184
10624
  dragShifted: drag !== null && drag.id !== column.id,
10185
10625
  selected: selectedCells.has(key),
@@ -10197,6 +10637,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10197
10637
  }, column.id);
10198
10638
  }), readOnly ? /* @__PURE__ */ jsx("div", {
10199
10639
  "data-slot": "docblocks/database-row-menu",
10640
+ "data-filter-pending": row.rowId === pendingRowId ? "true" : void 0,
10200
10641
  className: cn(`
10201
10642
  flex w-10 items-center justify-center border-l-(length:--docblocks-table-border-width)
10202
10643
  border-(--docblocks-table-border-color)
@@ -10205,12 +10646,13 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10205
10646
  row,
10206
10647
  rowMenu,
10207
10648
  setRowMenu,
10208
- canMoveUp: rows.indexOf(row) > 0,
10209
- canMoveDown: rows.indexOf(row) < rows.length - 1,
10649
+ canMoveUp: row.rowId !== pendingRowId && rows.indexOf(row) > 0,
10650
+ canMoveDown: row.rowId !== pendingRowId && rows.indexOf(row) < rows.length - 1 && rows[rows.indexOf(row) + 1]?.rowId !== pendingRowId,
10210
10651
  onMoveUp: rowMoveUp(row),
10211
10652
  onMoveDown: rowMoveDown(row),
10212
10653
  onRemove: rowRemove(row),
10213
- lastRow: row.rowId === lastRowId
10654
+ lastRow: row.rowId === lastRowId,
10655
+ filterPending: row.rowId === pendingRowId
10214
10656
  })] }, row.rowId)),
10215
10657
  data.nextCursor !== null && /* @__PURE__ */ jsx("div", {
10216
10658
  "data-slot": "docblocks/database-load-more-row",
@@ -12871,6 +13313,7 @@ function DatabaseBlock({ id, block }) {
12871
13313
  "data-slot": "docblocks/block",
12872
13314
  "data-block-type": "database",
12873
13315
  "data-block-id": id,
13316
+ contentEditable: false,
12874
13317
  className: "\n my-(--docblocks-block-spacing) rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color) outline-none\n ",
12875
13318
  children: /* @__PURE__ */ jsxs(CardContent, {
12876
13319
  "data-slot": "docblocks/database",
@@ -13284,6 +13727,7 @@ function EmbedBlock({ id, block }) {
13284
13727
  "data-block-type": "embed",
13285
13728
  "data-block-id": id,
13286
13729
  "data-kind": kind,
13730
+ contentEditable: false,
13287
13731
  className: "\n group relative my-(--docblocks-block-spacing) h-(--docblocks-embed-height) overflow-hidden\n rounded-(--docblocks-radius) border-(length:--docblocks-divider-border-width)\n border-(--docblocks-divider-border-color) outline-none\n ",
13288
13732
  style: {
13289
13733
  ...height !== null ? { height: Math.max(height, tokenMin) } : {},
@@ -14668,6 +15112,202 @@ function insertParagraphAfter(doc, after, parent, indent, scope) {
14668
15112
  }
14669
15113
  }
14670
15114
  //#endregion
15115
+ //#region src/editing/page-surface.tsx
15116
+ /**
15117
+ * The page surface's input dispatch over the single page editable.
15118
+ *
15119
+ * The page container is one contenteditable (edit mode): the native DOM
15120
+ * selection crosses the blocks' boundaries natively (the highlight is
15121
+ * continuous in every engine — the WebKit family's cross-editable
15122
+ * clamp only applies between SIBLING editables, and the blocks are
15123
+ * nested inside the shared editable region). The price: every
15124
+ * keyboard/input event of the page surface targets the container (the
15125
+ * focused element), never a block's inner — the per-block handlers
15126
+ * (the input gestures, the commit) are registered per block in the
15127
+ * surface registry and dispatched from the container's handlers over
15128
+ * the block the live DOM selection's anchor stands in.
15129
+ *
15130
+ * The isolated surfaces (the table's and the database's cells, the
15131
+ * sync-embed's nested editor) sit behind a contenteditable="false"
15132
+ * boundary: the browser focuses their own inner there, so their keys
15133
+ * and inputs target themselves (their own handlers stand) and never
15134
+ * reach this dispatcher (its handlers stand only for events targeted
15135
+ * at the container).
15136
+ */
15137
+ const PageSurfaceContext = createContext(null);
15138
+ /**
15139
+ * The page surface's registry provider: one handlers map per editor
15140
+ * instance (the sync-embed's nested editor stands its own instance over
15141
+ * its own subtree). The map is created by the editor component (its
15142
+ * dispatch binding reads the same map directly — the dispatch hook runs
15143
+ * OUTSIDE the provider's subtree, so a context read there would stand
15144
+ * the default null) and is identity-stable over the instance's
15145
+ * lifetime; the entries update in place.
15146
+ */
15147
+ function PageSurfaceProvider({ map, children }) {
15148
+ const registry = useMemo(() => ({
15149
+ handlers: map,
15150
+ register: (id, handlers) => {
15151
+ map.set(id, handlers);
15152
+ },
15153
+ unregister: (id) => {
15154
+ map.delete(id);
15155
+ }
15156
+ }), [map]);
15157
+ return /* @__PURE__ */ jsx(PageSurfaceContext.Provider, {
15158
+ value: registry,
15159
+ children
15160
+ });
15161
+ }
15162
+ /** The current editor instance's surface registry (null outside the provider). */
15163
+ function usePageSurface() {
15164
+ return useContext(PageSurfaceContext);
15165
+ }
15166
+ /**
15167
+ * Whether the inner is a PAGE-SURFACE text block of its own editor scope:
15168
+ * not inside a contenteditable="false" island of the same scope (the
15169
+ * island's cells stand their own focused inner). An island OUTSIDE the
15170
+ * inner's editor root (the sync-embed's wrapper around the nested
15171
+ * editor) is not a boundary for that scope.
15172
+ */
15173
+ function isPageSurfaceInner(inner) {
15174
+ const island = inner.closest("[contenteditable=\"false\"]");
15175
+ if (island === null) return true;
15176
+ const scope = inner.closest("[data-slot=\"docblocks/editor\"]");
15177
+ return scope === null || scope.contains(island) === false;
15178
+ }
15179
+ /**
15180
+ * The page-surface inner (if any) that contains the selection's anchor:
15181
+ * the dispatch target over the container-targeted event.
15182
+ */
15183
+ function surfaceInnerOf(container, anchorNode) {
15184
+ if (anchorNode === null) return null;
15185
+ const inner = (anchorNode.nodeType === Node.ELEMENT_NODE ? anchorNode : anchorNode.parentElement ?? null)?.closest("[data-slot=\"docblocks/block-content\"]") ?? null;
15186
+ if (inner === null || !container.contains(inner) || isPageSurfaceInner(inner) === false) return null;
15187
+ return inner;
15188
+ }
15189
+ /**
15190
+ * The page-surface inners of one container in DOM order (the reseat's
15191
+ * candidates).
15192
+ */
15193
+ function surfaceInnersOf(container) {
15194
+ return Array.from(container.querySelectorAll("[data-slot=\"docblocks/block-content\"]")).filter((inner) => isPageSurfaceInner(inner));
15195
+ }
15196
+ /**
15197
+ * Re-seat a caret stranded at a pure page-container position (between
15198
+ * the block rows — the transient the browser's auto-seat leaves over
15199
+ * some gesture paths) into the nearest block's edge: the preceding
15200
+ * block's end or the following block's start, by the vertical distance
15201
+ * (the caret's y over the range's rect, the gap's midline when the
15202
+ * rect is degenerate). One DOM selection write (the next
15203
+ * selectionchange's mapping reads the seated caret).
15204
+ */
15205
+ function reseatContainerCaret(container, scope, doc) {
15206
+ const selection = window.getSelection();
15207
+ if (selection === null || selection.rangeCount === 0 || !selection.isCollapsed) return;
15208
+ const range = selection.getRangeAt(0);
15209
+ if (surfaceInnerOf(container, range.startContainer) !== null) return;
15210
+ const inners = surfaceInnersOf(container);
15211
+ let previous = null;
15212
+ let following = null;
15213
+ for (const inner of inners) {
15214
+ const innerStart = document.createRange();
15215
+ innerStart.setStart(inner, 0);
15216
+ innerStart.collapse(true);
15217
+ if (range.compareBoundaryPoints(Range.END_TO_START, innerStart) === -1) {
15218
+ if (following === null) following = inner;
15219
+ } else if (previous === null || previous !== inner) previous = inner;
15220
+ }
15221
+ if (previous === null && following === null) return;
15222
+ let caretY = null;
15223
+ const caretRect = range.getBoundingClientRect();
15224
+ if (caretRect.height > 0) caretY = caretRect.top + caretRect.height / 2;
15225
+ else if (previous !== null && following !== null) caretY = (previous.getBoundingClientRect().bottom + following.getBoundingClientRect().top) / 2;
15226
+ let target = previous;
15227
+ if (previous !== null && following !== null && caretY !== null) {
15228
+ const previousBottom = previous.getBoundingClientRect().bottom;
15229
+ const followingTop = following.getBoundingClientRect().top;
15230
+ if (Math.abs(followingTop - caretY) < Math.abs(caretY - previousBottom)) target = following;
15231
+ } else if (previous === null) target = following;
15232
+ if (target === null) return;
15233
+ const targetId = target.dataset.blockId;
15234
+ focusCaretIn(targetId, target === previous ? doc.getTextLength(targetId) : 0, scope, () => {
15235
+ return containerCaretNeedsReseat(container, window.getSelection()?.anchorNode ?? null);
15236
+ });
15237
+ }
15238
+ /**
15239
+ * Whether the caret's anchor sits in a pure page-container position that
15240
+ * needs the re-seat: inside the container's own editable flow (its
15241
+ * nearest contenteditable is the container) and not inside a page-surface
15242
+ * inner (a block's text inner is a valid caret seat, not a transient).
15243
+ */
15244
+ function containerCaretNeedsReseat(container, anchorNode) {
15245
+ if (anchorNode === null || container.contains(anchorNode) === false) return false;
15246
+ const host = anchorNode.nodeType === Node.ELEMENT_NODE ? anchorNode : anchorNode.parentElement ?? null;
15247
+ if (host?.matches("input, textarea") === true) return false;
15248
+ if (host?.closest("[contenteditable=\"false\"]") !== null) return false;
15249
+ if ((host?.closest("[contenteditable=\"true\"]") ?? null) !== container) return false;
15250
+ return surfaceInnerOf(container, anchorNode) === null;
15251
+ }
15252
+ /**
15253
+ * The container-level dispatch of the page surface's per-block handlers
15254
+ * + the container-caret's guard: a beforeinput targeted at the container
15255
+ * itself (the input over a pure container position — the chromium's
15256
+ * bare-div's materialization) is suppressed and the caret re-seats into
15257
+ * the nearest block's edge.
15258
+ */
15259
+ function usePageSurfaceDispatch(containerRef, doc, handlers) {
15260
+ const dispatch = useCallback((event, kind) => {
15261
+ const container = containerRef.current;
15262
+ if (container === null || event.target !== container) return;
15263
+ const inner = surfaceInnerOf(container, window.getSelection()?.anchorNode ?? null);
15264
+ if (inner === null) return;
15265
+ const blockHandlers = handlers.get(inner.dataset.blockId);
15266
+ if (blockHandlers === void 0) return;
15267
+ if (kind === "keydown") blockHandlers.onKeydown(event);
15268
+ else if (kind === "paste") blockHandlers.onPaste(event);
15269
+ else blockHandlers.onInput();
15270
+ }, [containerRef, handlers]);
15271
+ useEffect(() => {
15272
+ const container = containerRef.current;
15273
+ if (container === null) return;
15274
+ const onBeforeInput = (event) => {
15275
+ if (event.target !== container) return;
15276
+ const selection = window.getSelection();
15277
+ if (containerCaretNeedsReseat(container, selection?.anchorNode ?? null) === false) return;
15278
+ event.preventDefault();
15279
+ const scope = container.closest("[data-slot=\"docblocks/editor\"]") ?? document;
15280
+ reseatContainerCaret(container, scope, doc);
15281
+ };
15282
+ container.addEventListener("beforeinput", onBeforeInput);
15283
+ return () => container.removeEventListener("beforeinput", onBeforeInput);
15284
+ }, [containerRef, doc]);
15285
+ return useMemo(() => ({
15286
+ onKeyDown: (event) => {
15287
+ dispatch(event, "keydown");
15288
+ },
15289
+ onInput: (event) => {
15290
+ dispatch(event, "input");
15291
+ },
15292
+ onPaste: (event) => {
15293
+ dispatch(event, "paste");
15294
+ }
15295
+ }), [dispatch]);
15296
+ }
15297
+ /**
15298
+ * Park the editor root's focus over the anchor's editor instance: the
15299
+ * selection keys' reach when the focus stands outside the editor (the
15300
+ * gutter's click, the drag's release). A focus already inside the editor
15301
+ * stands as is (no selection change, the keys bubble from it to the root).
15302
+ */
15303
+ function parkEditorFocus(anchor) {
15304
+ const root = anchor.closest("[data-slot=\"docblocks/editor\"]");
15305
+ if (root === null) return;
15306
+ const active = document.activeElement;
15307
+ if (active !== null && root.contains(active)) return;
15308
+ root.focus();
15309
+ }
15310
+ //#endregion
14671
15311
  //#region src/editing/use-delete-block.ts
14672
15312
  /** The page row's delete affordance (the hover's trash icon): the shared
14673
15313
  * click gesture.
@@ -16487,16 +17127,22 @@ function syncDomSelection(root, doc, view) {
16487
17127
  if (!selectionsEqual(next, view.get())) view.set(next);
16488
17128
  }
16489
17129
  /**
16490
- * Whether the DOM selection's endpoints stand inside a contenteditable
17130
+ * Whether the DOM selection's endpoints stand inside a block's editable
16491
17131
  * (of any editor root): the caret is live in an editable, so the
16492
17132
  * selection's mapping expresses a real edit position. A selection
16493
17133
  * collapsed outside the editables (the chrome, the stale residue) does
16494
- * not — the mapping must not clobber a `blocks` view there.
17134
+ * not — the mapping must not clobber a `blocks` view there. Neither does
17135
+ * a caret parked at a pure page-container position (the page's single
17136
+ * editable container is an editable, but the caret stands in no block —
17137
+ * the reseat's transient, the gutter's focus park).
16495
17138
  */
16496
17139
  function domSelectionInEditable(domSelection) {
16497
- const anchor = editableOfNode(domSelection?.anchorNode ?? null);
16498
- const focus = editableOfNode(domSelection?.focusNode ?? null);
16499
- return anchor !== null && focus !== null;
17140
+ const inText = (node) => {
17141
+ const editable = editableOfNode(node);
17142
+ if (editable === null) return false;
17143
+ return editable.getAttribute("data-slot") !== "docblocks/page";
17144
+ };
17145
+ return inText(domSelection?.anchorNode ?? null) && inText(domSelection?.focusNode ?? null);
16500
17146
  }
16501
17147
  /** The contenteditable that owns a node (the node's element or its parent's), or null. */
16502
17148
  function editableOfNode(node) {
@@ -17108,7 +17754,8 @@ function useBlockInput({ id, blockType, context, innerRef, wrapperRef, declareLo
17108
17754
  const selection = window.getSelection();
17109
17755
  if (selection === null || selection.rangeCount === 0) return;
17110
17756
  const range = selection.getRangeAt(0);
17111
- const el = event.currentTarget;
17757
+ const el = innerRef.current;
17758
+ if (el === null) return;
17112
17759
  if (!el.contains(range.startContainer) || !el.contains(range.endContainer)) return;
17113
17760
  const anchor = caretOffsetIn(el, range.startContainer, range.startOffset);
17114
17761
  const focus = caretOffsetIn(el, range.endContainer, range.endOffset);
@@ -17171,6 +17818,29 @@ function useBlockInput({ id, blockType, context, innerRef, wrapperRef, declareLo
17171
17818
  selection = view.get();
17172
17819
  root = mappedRoot;
17173
17820
  }
17821
+ if (isPageSurfaceInner(inner) && !event.ctrlKey && !event.metaKey && !event.altKey && (event.key === "Home" || event.key === "End") && selection.kind === "text" && (selection.to === null || selection.to.blockId === selection.from.blockId)) {
17822
+ const homeDom = window.getSelection();
17823
+ if (homeDom !== null && homeDom.rangeCount > 0) {
17824
+ const logical = logicalTextOf(inner);
17825
+ const endpoint = homeDom.isCollapsed ? {
17826
+ node: homeDom.anchorNode,
17827
+ offset: homeDom.anchorOffset
17828
+ } : effectiveFocusEnd(homeDom);
17829
+ if (endpoint !== null) {
17830
+ const caret = caretOffsetIn(inner, endpoint.node, endpoint.offset);
17831
+ const lineStart = logical.lastIndexOf("\n", caret - 1) + 1;
17832
+ const breakIndex = logical.indexOf("\n", caret);
17833
+ const lineEnd = breakIndex === -1 ? logical.length : breakIndex;
17834
+ const target = event.key === "Home" ? lineStart : lineEnd;
17835
+ event.preventDefault();
17836
+ if (event.shiftKey) {
17837
+ const anchorFlat = caretOffsetIn(inner, homeDom.anchorNode, homeDom.anchorOffset);
17838
+ restoreSelection(inner, Math.min(anchorFlat, target), Math.max(anchorFlat, target));
17839
+ } else restoreSelection(inner, target, null);
17840
+ return;
17841
+ }
17842
+ }
17843
+ }
17174
17844
  if (selection.kind === "text" && selection.to !== null && selection.to.blockId !== selection.from.blockId) {
17175
17845
  if (root !== null && handleCrossRangeKey(doc, view, selection, root, event)) return;
17176
17846
  }
@@ -17207,7 +17877,7 @@ function useBlockInput({ id, blockType, context, innerRef, wrapperRef, declareLo
17207
17877
  ids: [nextId],
17208
17878
  anchorId: nextId
17209
17879
  });
17210
- (wrapperRef.current?.closest("[data-slot=\"docblocks/editor\"]"))?.querySelector(`[data-block-id="${CSS.escape(nextId)}"]`)?.focus();
17880
+ if (wrapperRef.current !== null) parkEditorFocus(wrapperRef.current);
17211
17881
  }
17212
17882
  }
17213
17883
  }
@@ -17313,6 +17983,24 @@ function useBlockInput({ id, blockType, context, innerRef, wrapperRef, declareLo
17313
17983
  if (newId !== null) focusCaretIn(newId, 0, editorRootOf(inner));
17314
17984
  return;
17315
17985
  }
17986
+ if ((event.key === "Backspace" || event.key === "Delete") && !event.nativeEvent.isComposing) {
17987
+ const rangeSelection = window.getSelection();
17988
+ if (rangeSelection !== null && rangeSelection.rangeCount > 0 && !rangeSelection.isCollapsed) {
17989
+ const range = rangeSelection.getRangeAt(0);
17990
+ if (inner.contains(range.startContainer) && inner.contains(range.endContainer)) {
17991
+ const anchor = caretOffsetIn(inner, range.startContainer, range.startOffset);
17992
+ const focus = caretOffsetIn(inner, range.endContainer, range.endOffset);
17993
+ const from = Math.min(anchor, focus);
17994
+ const to = Math.max(anchor, focus);
17995
+ if (from !== to) {
17996
+ event.preventDefault();
17997
+ doc.deleteText(id, from, to);
17998
+ restoreSelection(inner, from, null);
17999
+ }
18000
+ return;
18001
+ }
18002
+ }
18003
+ }
17316
18004
  if (event.key === "Backspace" && !event.nativeEvent.isComposing) {
17317
18005
  const domSelection = window.getSelection();
17318
18006
  if (domSelection === null || domSelection.rangeCount === 0 || !domSelection.isCollapsed) return;
@@ -17328,10 +18016,19 @@ function useBlockInput({ id, blockType, context, innerRef, wrapperRef, declareLo
17328
18016
  }
17329
18017
  return;
17330
18018
  }
17331
- if (inCell) return;
17332
- if ((blockType === "quote" || blockType === "callout" || blockType === "code") && doc.getTextLength(id) > 0) return;
18019
+ if (inCell) {
18020
+ event.preventDefault();
18021
+ return;
18022
+ }
18023
+ if ((blockType === "quote" || blockType === "callout" || blockType === "code") && doc.getTextLength(id) > 0) {
18024
+ event.preventDefault();
18025
+ return;
18026
+ }
17333
18027
  const merged = mergeWithPrevious(doc, id, context.parentId);
17334
- if (merged === null) return;
18028
+ if (merged === null) {
18029
+ event.preventDefault();
18030
+ return;
18031
+ }
17335
18032
  event.preventDefault();
17336
18033
  focusCaretIn(merged.blockId, merged.offset, editorRootOf(inner));
17337
18034
  return;
@@ -17855,6 +18552,22 @@ function useTextInner({ id, block, blockType, context, wrapperRef }) {
17855
18552
  appliedRef.current = block;
17856
18553
  }
17857
18554
  });
18555
+ useEffect(() => {
18556
+ const el = innerRef.current;
18557
+ if (el === null) return;
18558
+ const update = () => {
18559
+ const anchor = window.getSelection()?.anchorNode ?? null;
18560
+ el.toggleAttribute("data-caret-inside", anchor !== null && el.contains(anchor));
18561
+ };
18562
+ update();
18563
+ document.addEventListener("selectionchange", update);
18564
+ return () => document.removeEventListener("selectionchange", update);
18565
+ }, []);
18566
+ usePageSurfaceRegistration(id, innerRef, {
18567
+ onKeydown,
18568
+ onInput: commitDomDelta,
18569
+ onPaste
18570
+ });
17858
18571
  return {
17859
18572
  innerRef,
17860
18573
  onInput: commitDomDelta,
@@ -17862,6 +18575,35 @@ function useTextInner({ id, block, blockType, context, wrapperRef }) {
17862
18575
  onKeydown
17863
18576
  };
17864
18577
  }
18578
+ /**
18579
+ * The page surface's registration: the per-block handlers stand in the
18580
+ * editor instance's surface registry (the container-level dispatch's
18581
+ * source) while the inner is a page-surface text block (the isolated
18582
+ * surfaces — the cells, the nested editors — keep their own inner-bound
18583
+ * handlers and stand no registration over the outer scope). The entry
18584
+ * updates over every handler's identity change; the unmount unregisters.
18585
+ */
18586
+ function usePageSurfaceRegistration(id, innerRef, handlers) {
18587
+ const registry = usePageSurface();
18588
+ const { onKeydown, onInput, onPaste } = handlers;
18589
+ useEffect(() => {
18590
+ const inner = innerRef.current;
18591
+ if (registry === null || inner === null || isPageSurfaceInner(inner) === false) return;
18592
+ registry.register(id, {
18593
+ onKeydown,
18594
+ onInput,
18595
+ onPaste
18596
+ });
18597
+ return () => registry.unregister(id);
18598
+ }, [
18599
+ registry,
18600
+ id,
18601
+ innerRef,
18602
+ onKeydown,
18603
+ onInput,
18604
+ onPaste
18605
+ ]);
18606
+ }
17865
18607
  //#endregion
17866
18608
  //#region src/editing/format-toolbar/constants.ts
17867
18609
  /** The default format palette: the shared palette's seven pastel theme
@@ -18597,6 +19339,7 @@ function CalloutBlockMenu({ id, block }) {
18597
19339
  "data-slot": "docblocks/callout-icon",
18598
19340
  className: "absolute flex items-center justify-center",
18599
19341
  style: iconStyle,
19342
+ contentEditable: false,
18600
19343
  children: /* @__PURE__ */ jsxs(Popover, {
18601
19344
  modal: false,
18602
19345
  open: menuOpen,
@@ -18764,6 +19507,7 @@ function BlockCaption({ id, caption, slot, ariaLabel, placeholder }) {
18764
19507
  if (viewMode) return /* @__PURE__ */ jsx("span", {
18765
19508
  "data-slot": slot,
18766
19509
  "aria-label": ariaLabel,
19510
+ contentEditable: false,
18767
19511
  className: "\n mx-auto my-1 block w-[90%] text-center text-[0.8125em] text-muted-foreground\n dark:text-muted-foreground\n ",
18768
19512
  children: caption
18769
19513
  });
@@ -19199,7 +19943,7 @@ function TextBlock({ id, block, tag, nested, collapsible = false, flat = false,
19199
19943
  ids: [id],
19200
19944
  anchorId: id
19201
19945
  });
19202
- wrapperRef.current?.focus();
19946
+ if (wrapperRef.current !== null) parkEditorFocus(wrapperRef.current);
19203
19947
  }, [
19204
19948
  blockContext,
19205
19949
  doc,
@@ -19372,7 +20116,6 @@ function TextBlock({ id, block, tag, nested, collapsible = false, flat = false,
19372
20116
  "data-align": alignOf(block),
19373
20117
  "data-depth": block.type === "list-item" ? cycle : void 0,
19374
20118
  "data-selected": selected ? "true" : void 0,
19375
- tabIndex: 0,
19376
20119
  className: cn("group", wrapperClass),
19377
20120
  style: calloutStyle,
19378
20121
  onKeyDown: onKeydown,
@@ -19428,6 +20171,7 @@ function TextBlock({ id, block, tag, nested, collapsible = false, flat = false,
19428
20171
  block.type === "quote" && /* @__PURE__ */ jsx("div", {
19429
20172
  "data-slot": "docblocks/quote-rule",
19430
20173
  "aria-hidden": true,
20174
+ contentEditable: false,
19431
20175
  className: "\n pointer-events-none absolute top-0 bottom-0 left-0 w-(--docblocks-quote-border-width)\n bg-(--docblocks-quote-border-color)\n "
19432
20176
  }),
19433
20177
  block.type === "callout" && /* @__PURE__ */ jsx(CalloutBlockMenu, {
@@ -19438,6 +20182,8 @@ function TextBlock({ id, block, tag, nested, collapsible = false, flat = false,
19438
20182
  "data-slot": "docblocks/row-marker",
19439
20183
  "data-cycle": cycle,
19440
20184
  "data-kind": block.attrs.list,
20185
+ contentEditable: false,
20186
+ className: "select-none",
19441
20187
  children: flatMarkerIsNumber && number !== void 0 ? numberMarkerLabel(number, cycle) : null
19442
20188
  }),
19443
20189
  collapsible && /* @__PURE__ */ jsx(Button, {
@@ -19854,6 +20600,7 @@ function PlaceholderBlock({ type }) {
19854
20600
  return /* @__PURE__ */ jsx(Card, {
19855
20601
  "data-slot": "docblocks/placeholder",
19856
20602
  "data-block-type": type,
20603
+ contentEditable: false,
19857
20604
  className: "my-(--docblocks-block-spacing) outline-none",
19858
20605
  children: /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(Badge, {
19859
20606
  variant: "secondary",
@@ -23315,7 +24062,7 @@ function ShapeText({ id, block, box }) {
23315
24062
  contentEditable: true,
23316
24063
  "data-slot": "docblocks/shape-text-edit",
23317
24064
  suppressContentEditableWarning: true,
23318
- className: "w-full outline-none",
24065
+ className: "min-h-[1em] w-full outline-none",
23319
24066
  onKeyDown: onEditKeyDown,
23320
24067
  onBlur: commitText
23321
24068
  }) : /* @__PURE__ */ jsx("div", {
@@ -23767,6 +24514,7 @@ function FramePageBlock({ id }) {
23767
24514
  "data-slot": "docblocks/frame-page-missing",
23768
24515
  "data-block-type": "frame",
23769
24516
  "data-block-id": id,
24517
+ contentEditable: false,
23770
24518
  className: "\n mx-0 my-(--docblocks-block-spacing) rounded-(--docblocks-radius)\n border-(length:--docblocks-table-border-width) border-dashed border-(--docblocks-table-border-color)\n outline-none\n ",
23771
24519
  children: /* @__PURE__ */ jsx(CardContent, {
23772
24520
  className: "flex items-center justify-center text-sm text-muted-foreground",
@@ -23827,6 +24575,7 @@ function FramePageWindow({ id, frameId, surfaceId, referenced }) {
23827
24575
  "data-block-id": id,
23828
24576
  tabIndex: 0,
23829
24577
  onMouseDown: preventDefault,
24578
+ contentEditable: false,
23830
24579
  className: "\n my-(--docblocks-block-spacing) outline-none\n focus-visible:outline-(length:--docblocks-canvas-selection-border-width) focus-visible:outline-offset-1\n focus-visible:outline-(--docblocks-canvas-selection-border-color) focus-visible:outline-dashed\n ",
23831
24580
  children: /* @__PURE__ */ jsx("div", {
23832
24581
  "data-slot": "docblocks/frame-page-window",
@@ -24151,6 +24900,7 @@ function ImageFigure({ id, block, url, name }) {
24151
24900
  "data-align": align,
24152
24901
  "data-selected": selected ? "true" : void 0,
24153
24902
  tabIndex: 0,
24903
+ contentEditable: false,
24154
24904
  className: cn("group relative", alignClass, "outline-none", selected && "outline-(length:--docblocks-canvas-selection-border-width) outline-offset-1 outline-(--docblocks-canvas-selection-border-color) outline-solid", `
24155
24905
  focus-visible:outline-(length:--docblocks-canvas-selection-border-width) focus-visible:outline-offset-1
24156
24906
  focus-visible:outline-(--docblocks-canvas-selection-border-color) focus-visible:outline-dashed
@@ -24332,6 +25082,7 @@ function SyncEmbedBlock({ id, block }) {
24332
25082
  "data-block-id": id,
24333
25083
  "data-state": state,
24334
25084
  "data-doc-id": ref.docId,
25085
+ contentEditable: false,
24335
25086
  className: "\n my-(--docblocks-block-spacing) rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color) outline-none\n ",
24336
25087
  children: [state === "resolved" && master !== null && /* @__PURE__ */ jsx(SyncEmbedContent, {
24337
25088
  master,
@@ -24477,6 +25228,17 @@ function languageLabel(language) {
24477
25228
  function CodeHeader({ id, block, center }) {
24478
25229
  const { t } = useTranslation("blocks");
24479
25230
  const { doc, store, viewMode } = useEditorContext();
25231
+ const [caretInside, setCaretInside] = useState(false);
25232
+ useEffect(() => {
25233
+ const onChange = () => {
25234
+ const anchor = window.getSelection()?.anchorNode ?? null;
25235
+ const inner = (anchor instanceof Element ? anchor : anchor?.parentElement ?? null)?.closest(`[data-block-id="${CSS.escape(id)}"] [data-slot="docblocks/block-content"]`) ?? null;
25236
+ setCaretInside(inner !== null);
25237
+ };
25238
+ onChange();
25239
+ document.addEventListener("selectionchange", onChange);
25240
+ return () => document.removeEventListener("selectionchange", onChange);
25241
+ }, [id]);
24480
25242
  const [languageOpen, setLanguageOpen] = useState(false);
24481
25243
  const [query, setQuery] = useState("");
24482
25244
  const [moreOpen, setMoreOpen] = useState(false);
@@ -24532,11 +25294,8 @@ function CodeHeader({ id, block, center }) {
24532
25294
  const controlClass = menuOpen ? "opacity-100 transition-opacity" : "pointer-events-none opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within/code:pointer-events-auto group-focus-within/code:opacity-100";
24533
25295
  return /* @__PURE__ */ jsxs("div", {
24534
25296
  "data-slot": "docblocks/code-header",
24535
- className: cn(`
24536
- group/code mb-1 flex items-center justify-between gap-2 border-b border-transparent pb-1 text-[0.8125em]
24537
- group-focus-within:border-border
24538
- group-hover:border-border
24539
- `, menuOpen && "border-border"),
25297
+ contentEditable: false,
25298
+ className: cn("group/code mb-1 flex items-center justify-between gap-2 border-b pb-1 text-[0.8125em]", caretInside || menuOpen ? "border-border" : "border-transparent group-focus-within:border-border group-hover:border-border"),
24540
25299
  onMouseDown: preventDefault,
24541
25300
  children: [/* @__PURE__ */ jsxs("div", {
24542
25301
  className: cn("flex items-center gap-1.5", controlClass),
@@ -24872,7 +25631,7 @@ function HandleMenu({ kind, index, visible, left, top, open, onOpenChange, dragg
24872
25631
  style: {
24873
25632
  left: left + dragDx,
24874
25633
  top: top + dragDy,
24875
- ...dragTransition !== void 0 ? { transition: HANDLE_DRAG_TRANSITION } : {}
25634
+ ...dragTransition !== void 0 && !dragging ? { transition: HANDLE_DRAG_TRANSITION } : {}
24876
25635
  },
24877
25636
  onPointerDown,
24878
25637
  onPointerMove,
@@ -25085,6 +25844,7 @@ function CellActivation({ cellId }) {
25085
25844
  };
25086
25845
  const onKeyDown = (event) => {
25087
25846
  if (event.key === "Enter" && !event.nativeEvent.isComposing) event.preventDefault();
25847
+ if (event.key === "Backspace") event.preventDefault();
25088
25848
  };
25089
25849
  return /* @__PURE__ */ jsx("div", {
25090
25850
  ref,
@@ -25100,23 +25860,30 @@ function CellActivation({ cellId }) {
25100
25860
  }
25101
25861
  //#endregion
25102
25862
  //#region src/blocks/table/TableCell.tsx
25103
- /** The table's cell renderer (the drag transform, the column/row
25104
- * background stands) + the cell's own-content layer. */
25863
+ /** The table's cell renderer (the row / column drag's transform — the cell
25864
+ * is the transform's element: the `<tr>` is not a CSS transformable
25865
+ * element, so the row's drag applies over the row's cells; the dragged
25866
+ * cell's card background; the column/row's background is kept) + the cell's
25867
+ * own-content layer. */
25105
25868
  /** One cell: its flat content sequence renders through the flat sequence renderer. */
25106
- const TableCell = memo(function TableCell({ id, dragX, dragShifted }) {
25869
+ const TableCell = memo(function TableCell({ id, dragX, dragShifted, rowDy, rowShifted }) {
25107
25870
  const cell = useBlock(id);
25108
25871
  const { viewMode } = useEditorContext();
25109
25872
  const children = cell !== void 0 && cell.type === "table-cell" ? cell.children ?? EMPTY_IDS : EMPTY_IDS;
25110
25873
  const contextValue = useBlockContextValue(id, children, "table-cell");
25111
25874
  if (cell === void 0 || cell.type !== "table-cell") return null;
25112
25875
  const background = cell.attrs?.columnColor ?? cell.attrs?.rowColor;
25876
+ const hasDrag = dragX !== 0 || rowDy !== 0;
25877
+ const dragged = hasDrag && !dragShifted && !rowShifted;
25113
25878
  const style = {
25114
25879
  ...background !== void 0 ? { background } : {},
25115
- ...dragX !== 0 ? {
25116
- transform: `translateX(${dragX}px)`,
25880
+ ...dragged && background === void 0 ? { background: "var(--docblocks-table-drag-background, transparent)" } : {},
25881
+ ...dragged ? { boxShadow: "var(--docblocks-table-drag-shadow, none), inset 0 0 0 var(--docblocks-table-border-width) var(--docblocks-table-border-color)" } : {},
25882
+ ...hasDrag ? {
25883
+ transform: `translate(${dragX}px, ${rowDy}px)`,
25117
25884
  position: "relative",
25118
- zIndex: dragShifted ? void 0 : 10,
25119
- transition: dragShifted ? DRAG_TRANSITION : void 0
25885
+ zIndex: dragged ? 10 : void 0,
25886
+ transition: dragged ? void 0 : DRAG_TRANSITION
25120
25887
  } : {}
25121
25888
  };
25122
25889
  const hasOwnText = (cell.content ?? []).some((run) => run.text !== "");
@@ -25130,7 +25897,12 @@ const TableCell = memo(function TableCell({ id, dragX, dragShifted }) {
25130
25897
  children: [hasOwnText ? /* @__PURE__ */ jsx(CellContent, {
25131
25898
  id,
25132
25899
  block: cell
25133
- }) : null, children.length === 0 && !hasOwnText && !viewMode ? /* @__PURE__ */ jsx(CellActivation, { cellId: id }) : /* @__PURE__ */ jsx(BlockGroups, { ids: children })]
25900
+ }) : null, children.length === 0 && !hasOwnText ? viewMode ? /* @__PURE__ */ jsx("span", {
25901
+ "aria-hidden": true,
25902
+ "data-slot": "docblocks/cell-empty",
25903
+ className: "my-(--docblocks-block-spacing) block whitespace-pre-wrap",
25904
+ children: "​"
25905
+ }) : /* @__PURE__ */ jsx(CellActivation, { cellId: id }) : /* @__PURE__ */ jsx(BlockGroups, { ids: children })]
25134
25906
  })
25135
25907
  });
25136
25908
  });
@@ -25192,31 +25964,26 @@ function CellContent({ id, block }) {
25192
25964
  //#endregion
25193
25965
  //#region src/blocks/table/TableRow.tsx
25194
25966
  /** The table's row renderer: the cell ids come from the row's own
25195
- * snapshot; the row / column drag transforms stand the inline styles. */
25967
+ * snapshot; the row / column drag transforms apply over the row's cells
25968
+ * (the `<tr>` is not a CSS transformable element — the row's drag's dy is
25969
+ * the per-cell transform's part). */
25196
25970
  /** One row: the cell ids come from the row's own snapshot. */
25197
25971
  const TableRow = memo(function TableRow({ id, rowTransform, columnTransforms, dimmed }) {
25198
25972
  const row = useBlock(id);
25199
25973
  const cells = row !== void 0 && row.type === "table-row" ? row.children ?? EMPTY_IDS : EMPTY_IDS;
25200
25974
  const contextValue = useBlockContextValue(id, cells, "table-row");
25201
25975
  if (row === void 0 || row.type !== "table-row") return null;
25202
- const dragging = rowTransform.dy !== 0;
25203
25976
  return /* @__PURE__ */ jsx("tr", {
25204
25977
  "data-block-id": id,
25205
- style: dragging || dimmed ? {
25206
- ...dragging ? {
25207
- transform: `translateY(${rowTransform.dy}px)`,
25208
- position: "relative",
25209
- zIndex: rowTransform.shifted ? void 0 : 10,
25210
- transition: rowTransform.shifted ? DRAG_TRANSITION : void 0
25211
- } : {},
25212
- ...dimmed ? { opacity: .4 } : {}
25213
- } : void 0,
25978
+ style: dimmed ? { opacity: .4 } : void 0,
25214
25979
  children: /* @__PURE__ */ jsx(BlockContext.Provider, {
25215
25980
  value: contextValue,
25216
25981
  children: cells.map((cellId, cellIndex) => /* @__PURE__ */ jsx(TableCell, {
25217
25982
  id: cellId,
25218
25983
  dragX: columnTransforms[cellIndex]?.dx ?? 0,
25219
- dragShifted: columnTransforms[cellIndex]?.shifted ?? false
25984
+ dragShifted: columnTransforms[cellIndex]?.shifted ?? false,
25985
+ rowDy: rowTransform.dy,
25986
+ rowShifted: rowTransform.shifted
25220
25987
  }, cellId))
25221
25988
  })
25222
25989
  });
@@ -25539,9 +26306,11 @@ function useTableSeamResize({ docWidths, doc, id, resizeSessionRef }) {
25539
26306
  *
25540
26307
  * The row/column handles: hovering a cell reveals the column handle (above
25541
26308
  * the column) and the row handle (left of the row). A press and drag
25542
- * reorders (the live preview is a transform on the dragged row/cell; the
25543
- * release commits moveTableRow / moveTableColumn — one command; a stale
25544
- * drop issues none). A press without a drag opens the handle's menu (the
26309
+ * reorders (the live preview is a transform on the dragged row/column's
26310
+ * cells — the `<tr>` is not a CSS transformable element — with the card's
26311
+ * background over the uncolored cells; the release commits moveTableRow /
26312
+ * moveTableColumn — one command; a stale drop issues none). A press without
26313
+ * a drag opens the handle's menu (the
25545
26314
  * background color palette with the conditional remove, insert / move /
25546
26315
  * duplicate / clear / delete). The add-row / add-column chips
25547
26316
  * (hover/focus-revealed, like the code header's controls) drive the core's
@@ -25882,6 +26651,7 @@ function TableBlock({ id, block }) {
25882
26651
  return /* @__PURE__ */ jsxs("div", {
25883
26652
  ref: frameRef,
25884
26653
  "data-slot": "docblocks/table-scroll",
26654
+ contentEditable: false,
25885
26655
  className: "group relative my-(--docblocks-block-spacing)",
25886
26656
  children: [
25887
26657
  /* @__PURE__ */ jsx("div", {
@@ -26190,6 +26960,7 @@ function dispatchBuiltIn(id, block, nested, collapsible, flat, number) {
26190
26960
  "data-slot": "docblocks/divider",
26191
26961
  "data-block-type": "divider",
26192
26962
  "data-block-id": id,
26963
+ contentEditable: false,
26193
26964
  className: "\n m-(--docblocks-divider-margin) border-0 border-t-(length:--docblocks-divider-border-width)\n border-t-(--docblocks-divider-border-color)\n "
26194
26965
  });
26195
26966
  case "image": return /* @__PURE__ */ jsx(ImageBlock, {
@@ -28381,8 +29152,17 @@ function useCrossDrag(rootRef, doc) {
28381
29152
  const root = rootRef.current;
28382
29153
  if (session === null || root === null || event.pointerId !== session.pointerId) return;
28383
29154
  sessionRef.current = null;
28384
- if (session.moved && session.last !== null) seatCrossSelection(session.anchor, session.last);
28385
- else if (!session.moved) window.getSelection()?.setBaseAndExtent(session.anchor.node, session.anchor.offset, session.anchor.node, session.anchor.offset);
29155
+ const seat = () => {
29156
+ if (session.moved && session.last !== null) seatCrossSelection(session.anchor, session.last);
29157
+ else window.getSelection()?.setBaseAndExtent(session.anchor.node, session.anchor.offset, session.anchor.node, session.anchor.offset);
29158
+ };
29159
+ seat();
29160
+ const seatNode = window.getSelection()?.anchorNode ?? session.anchor.node;
29161
+ const editable = (seatNode instanceof Element ? seatNode : seatNode.parentElement ?? null)?.closest("[contenteditable=\"true\"]") ?? null;
29162
+ if (editable !== null && document.activeElement !== editable) {
29163
+ editable.focus();
29164
+ seat();
29165
+ }
28386
29166
  window.removeEventListener("pointermove", move);
28387
29167
  window.removeEventListener("pointerup", end);
28388
29168
  window.removeEventListener("pointercancel", end);
@@ -28440,6 +29220,30 @@ function useCrossDrag(rootRef, doc) {
28440
29220
  window.addEventListener("pointercancel", handlers.end);
28441
29221
  window.addEventListener("mousedown", handlers.mousedown, true);
28442
29222
  }, [doc, rootRef]);
29223
+ useEffect(() => {
29224
+ const guard = (event) => {
29225
+ const root = rootRef.current;
29226
+ if (root === null || event.button !== 0) return;
29227
+ const target = event.target instanceof Element ? event.target : null;
29228
+ if (target === null || !root.contains(target)) return;
29229
+ if (document.activeElement instanceof HTMLIFrameElement) return;
29230
+ if (target.closest("[data-slot=\"docblocks/page\"]") === null) return;
29231
+ if (target.closest("input, textarea, select, button") !== null) return;
29232
+ const island = target.closest("[contenteditable=\"false\"]");
29233
+ const editable = target.closest("[contenteditable=\"true\"]");
29234
+ if (island !== null && editable !== null && island.contains(editable)) return;
29235
+ const active = document.activeElement;
29236
+ const activeIsland = active instanceof HTMLElement ? active.closest("[contenteditable=\"false\"]") : null;
29237
+ const activeEditable = active instanceof HTMLElement ? active.closest("[contenteditable=\"true\"]") : null;
29238
+ if (active instanceof HTMLElement && (active.matches("input, textarea") || activeIsland !== null && activeEditable !== null && activeIsland.contains(activeEditable))) return;
29239
+ if (island === null && editable instanceof HTMLElement && isPageSurfaceInner(editable)) return;
29240
+ event.preventDefault();
29241
+ const a = document.activeElement;
29242
+ if (root !== null && (a === null || !root.contains(a))) root.focus();
29243
+ };
29244
+ window.addEventListener("mousedown", guard, true);
29245
+ return () => window.removeEventListener("mousedown", guard, true);
29246
+ }, [rootRef]);
28443
29247
  useEffect(() => {
28444
29248
  const triple = (event) => {
28445
29249
  const root = rootRef.current;
@@ -28502,7 +29306,8 @@ function scheduleHistoryReseat(doc, view, root) {
28502
29306
  const unsubscribe = view.onChange((selection) => {
28503
29307
  if (!alive) return;
28504
29308
  if (selection.kind !== "text") return;
28505
- run();
29309
+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => alive && run());
29310
+ else window.setTimeout(() => alive && run(), 0);
28506
29311
  });
28507
29312
  window.setTimeout(() => {
28508
29313
  alive = false;
@@ -28531,11 +29336,21 @@ function useEditing() {
28531
29336
  const root = rootRef.current;
28532
29337
  const view = selectionRef.view;
28533
29338
  if (root === null || view === null) return;
29339
+ const pageContainer = root.querySelector("[data-slot='docblocks/page']");
29340
+ const pageSelection = window.getSelection();
29341
+ if (pageContainer !== null && view.get().kind !== "blocks" && Date.now() >= selectionRef.reseatUntil.current && pageSelection !== null && pageSelection.isCollapsed && containerCaretNeedsReseat(pageContainer, pageSelection.anchorNode)) {
29342
+ reseatContainerCaret(pageContainer, root, doc);
29343
+ return;
29344
+ }
28534
29345
  const next = mapDomSelection(root, window.getSelection(), doc);
28535
29346
  if (view.get().kind === "blocks" && !domSelectionInEditable(window.getSelection())) return;
28536
29347
  const anchorNode = window.getSelection()?.anchorNode ?? null;
28537
29348
  if ((anchorNode instanceof Element ? anchorNode : anchorNode?.parentElement ?? null)?.closest("[data-slot=\"docblocks/page-card\"]") !== null) return;
28538
29349
  if (next.kind !== "text" && Date.now() < selectionRef.reseatUntil.current) return;
29350
+ if (next.kind === "text" && Date.now() < selectionRef.reseatUntil.current) {
29351
+ const anchor = window.getSelection()?.anchorNode ?? null;
29352
+ if (anchor === null || anchor.nodeType !== Node.TEXT_NODE) return;
29353
+ }
28539
29354
  if (!selectionsEqual(next, view.get())) view.set(next);
28540
29355
  };
28541
29356
  document.addEventListener("selectionchange", onSelectionChange);
@@ -28583,6 +29398,40 @@ function useEditing() {
28583
29398
  view.set({ kind: "none" });
28584
29399
  return;
28585
29400
  }
29401
+ if (root !== null) {
29402
+ const pageContainer = root.querySelector("[data-slot='docblocks/page']");
29403
+ if ((event.target === root || event.target === pageContainer) && (event.metaKey || event.ctrlKey) && event.shiftKey && (event.key === "ArrowUp" || event.key === "ArrowDown") && selection.ids.length === 1 && selection.ids[0] !== void 0) {
29404
+ const id = selection.ids[0];
29405
+ const siblings = doc.getChildren(rootBlockId);
29406
+ if (siblings.includes(id)) {
29407
+ const segment = segmentRange(doc, rootBlockId, id);
29408
+ if (segment !== null) {
29409
+ const length = segment.end - segment.start;
29410
+ const isSurface = (candidate) => doc.getBlock(candidate)?.type === "surface";
29411
+ let target = null;
29412
+ if (event.key === "ArrowUp") {
29413
+ let i = segment.start - 1;
29414
+ while (i >= 0 && isSurface(siblings[i])) i -= 1;
29415
+ if (i >= 0) target = i;
29416
+ } else {
29417
+ let j = segment.end;
29418
+ while (j < siblings.length && isSurface(siblings[j])) j += 1;
29419
+ if (j < siblings.length) target = j + 1;
29420
+ }
29421
+ if (target !== null) {
29422
+ event.preventDefault();
29423
+ moveSegmentInSequence(doc, rootBlockId, segment.start, length, target);
29424
+ view.set({
29425
+ kind: "blocks",
29426
+ ids: [id],
29427
+ anchorId: id
29428
+ });
29429
+ return;
29430
+ }
29431
+ }
29432
+ }
29433
+ }
29434
+ }
28586
29435
  }
28587
29436
  }
28588
29437
  if (!(event.metaKey || event.ctrlKey)) return;
@@ -28912,7 +29761,7 @@ const RowItem = memo(function RowItem({ node, layoutSlide, isDragged, animated,
28912
29761
  ids: [id],
28913
29762
  anchorId: id
28914
29763
  });
28915
- rowRef.current?.focus();
29764
+ if (rowRef.current !== null) parkEditorFocus(rowRef.current);
28916
29765
  }, [
28917
29766
  blockContext,
28918
29767
  doc,
@@ -28941,7 +29790,6 @@ const RowItem = memo(function RowItem({ node, layoutSlide, isDragged, animated,
28941
29790
  "data-slot": "docblocks/row",
28942
29791
  "data-selected": selected ? "true" : void 0,
28943
29792
  value: node.id,
28944
- tabIndex: 0,
28945
29793
  initial: animated ? ENTER : false,
28946
29794
  animate: ANIMATE,
28947
29795
  exit: EXIT,
@@ -28971,6 +29819,7 @@ const RowItem = memo(function RowItem({ node, layoutSlide, isDragged, animated,
28971
29819
  "aria-label": t("row.selectBlock"),
28972
29820
  variant: "ghost",
28973
29821
  size: "icon",
29822
+ contentEditable: false,
28974
29823
  onClick: onGutterClick,
28975
29824
  onMouseDown: onHandleMouseDown,
28976
29825
  className: cn("absolute top-[calc((var(--docblocks-line-box-height)-var(--docblocks-gutter-size))/2)]", "cursor-pointer rounded-full opacity-0 group-hover:opacity-100", "text-(--docblocks-gutter-color)", "size-5", selected && "opacity-100"),
@@ -29113,6 +29962,16 @@ const RowList = memo(function RowList({ order, nodesById, layoutSlide, draggingK
29113
29962
  * gate (rows that mount before the first text input stand up instantly).
29114
29963
  */
29115
29964
  /**
29965
+ * Whether the event's target is a text-editing surface of the page model:
29966
+ * the page's single editable container (the shared-editable's keys/inputs
29967
+ * target it, never a block's inner) or a block's own inner (the isolated
29968
+ * surfaces' cells stand their own focused inner).
29969
+ */
29970
+ function isPageTextTarget(target) {
29971
+ if (target === null) return false;
29972
+ return target.closest("[data-slot=\"docblocks/page\"]") !== null || target.closest("[data-slot=\"docblocks/block-content\"]") !== null;
29973
+ }
29974
+ /**
29116
29975
  * The grip typing flag: the editor root holds `data-docblocks-typing` from
29117
29976
  * the first text keypress in its own content until the first pointer move
29118
29977
  * or the focus leaving the editor — the stylesheet's unlayered rule hides
@@ -29131,7 +29990,7 @@ function useTypingFlag(rootRef) {
29131
29990
  const onKeydown = (event) => {
29132
29991
  const target = event.target instanceof Element ? event.target : null;
29133
29992
  if (target === null || target.closest("[data-slot=\"docblocks/editor\"]") !== root) return;
29134
- if (target.closest("[data-slot=\"docblocks/block-content\"]") === null) return;
29993
+ if (isPageTextTarget(target) === false) return;
29135
29994
  if (event.key.length !== 1 || event.key === " " || event.metaKey || event.ctrlKey || event.altKey) return;
29136
29995
  setTyping(true);
29137
29996
  };
@@ -29169,7 +30028,7 @@ function useEnterAnimationGate(rootRef) {
29169
30028
  const target = event.target instanceof Element ? event.target : null;
29170
30029
  if (target === null) return false;
29171
30030
  if (target.closest("[data-slot=\"docblocks/editor\"]") !== root) return false;
29172
- return target.closest("[data-slot=\"docblocks/block-content\"]") !== null;
30031
+ return isPageTextTarget(target);
29173
30032
  };
29174
30033
  const onKeydown = (event) => {
29175
30034
  if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey) return;
@@ -29460,6 +30319,8 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
29460
30319
  const slideTimerRef = useRef(null);
29461
30320
  const prevKeysRef = useRef(rowKeys);
29462
30321
  const entryContainerRef = useRef(null);
30322
+ const movedRef = useRef(false);
30323
+ const preDragSeatRef = useRef(null);
29463
30324
  /**
29464
30325
  * Keep the layout slide armed for the settle window after a drag or a
29465
30326
  * structural change, then release it so in-place content changes
@@ -29537,6 +30398,36 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
29537
30398
  previewIndent,
29538
30399
  layoutSlide,
29539
30400
  onRowDragStart: useCallback((id) => {
30401
+ movedRef.current = false;
30402
+ const selection = window.getSelection();
30403
+ let seat = null;
30404
+ if (selection !== null && selection.rangeCount > 0) {
30405
+ const range = selection.getRangeAt(0);
30406
+ const anchorInner = textBlockOfNode(range.startContainer);
30407
+ const focusInner = textBlockOfNode(range.endContainer);
30408
+ if (anchorInner !== null && anchorInner === focusInner) {
30409
+ const blockId = anchorInner.dataset.blockId;
30410
+ if (blockId !== void 0) seat = {
30411
+ blockId,
30412
+ from: caretOffsetIn(anchorInner, range.startContainer, range.startOffset),
30413
+ to: selection.isCollapsed ? null : caretOffsetIn(anchorInner, range.endContainer, range.endOffset)
30414
+ };
30415
+ }
30416
+ }
30417
+ preDragSeatRef.current = seat;
30418
+ const suppress = (click) => {
30419
+ if (!movedRef.current) return;
30420
+ const target = click.target instanceof Element ? click.target : null;
30421
+ if (target !== null && target.closest("[data-slot=\"docblocks/block-content\"]") !== null) return;
30422
+ movedRef.current = false;
30423
+ click.preventDefault();
30424
+ click.stopPropagation();
30425
+ };
30426
+ window.addEventListener("click", suppress, {
30427
+ capture: true,
30428
+ once: true
30429
+ });
30430
+ window.setTimeout(() => window.removeEventListener("click", suppress, true), 2e3);
29540
30431
  armSlide();
29541
30432
  setDraggingKey(id);
29542
30433
  setPreviewIndent(null);
@@ -29550,6 +30441,7 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
29550
30441
  rootBlockId
29551
30442
  ]),
29552
30443
  onRowDragMove: useCallback((id, event) => {
30444
+ movedRef.current = true;
29553
30445
  const pointerY = pointerYOf(event);
29554
30446
  if (pointerY === null) return;
29555
30447
  const candidate = seamCandidateAt(id, pointerY);
@@ -29557,9 +30449,19 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
29557
30449
  setPreviewIndent(candidate);
29558
30450
  }, [seamCandidateAt]),
29559
30451
  onRowDragEnd: useCallback((id, event) => {
30452
+ movedRef.current = false;
29560
30453
  armSlide();
29561
30454
  setDraggingKey(null);
29562
- rootRef.current?.focus({ preventScroll: true });
30455
+ const seat = preDragSeatRef.current;
30456
+ preDragSeatRef.current = null;
30457
+ if (seat !== null) {
30458
+ const scope = rootRef.current ?? document;
30459
+ const inner = Array.from(scope.querySelectorAll(`[data-block-id="${CSS.escape(seat.blockId)}"][data-slot="docblocks/block-content"]`)).find((candidate) => !candidate.closest("[data-slot=\"docblocks/frame-window-content\"]")) ?? null;
30460
+ if (inner !== null && inner.isConnected) {
30461
+ inner.focus();
30462
+ restoreSelection(inner, seat.from, seat.to);
30463
+ } else rootRef.current?.focus({ preventScroll: true });
30464
+ } else rootRef.current?.focus({ preventScroll: true });
29563
30465
  const pointerY = pointerYOf(event);
29564
30466
  setPreviewIndent(null);
29565
30467
  if (pointerY === null) return;
@@ -29610,6 +30512,10 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
29610
30512
  function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
29611
30513
  const { doc, store, rootBlockId, viewMode } = useEditorContext();
29612
30514
  const rootChildren = useStore(store, (state) => state.rootChildren);
30515
+ const pageRef = useRef(null);
30516
+ const surfaceMapRef = useRef(null);
30517
+ if (surfaceMapRef.current === null) surfaceMapRef.current = /* @__PURE__ */ new Map();
30518
+ const surface = usePageSurfaceDispatch(pageRef, doc, surfaceMapRef.current);
29613
30519
  const seqStamp = useStore(store, (state) => state.seqStamp);
29614
30520
  const collapsedIds = useStore(store, (state) => state.collapsedIds);
29615
30521
  const pageChildren = useMemo(() => rootChildren.filter((id) => store.getState().blocks[id]?.type !== "surface"), [
@@ -29698,20 +30604,29 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
29698
30604
  value: formatPalette,
29699
30605
  children: /* @__PURE__ */ jsxs(BlockContext.Provider, {
29700
30606
  value: rootContext,
29701
- children: [view === "canvas" ? /* @__PURE__ */ jsx(CanvasView, {}) : /* @__PURE__ */ jsx("div", {
29702
- "data-slot": "docblocks/page",
29703
- className: "\n mx-auto w-full max-w-(--docblocks-page-column-max-width) px-(--docblocks-page-padding-x)\n ",
29704
- children: /* @__PURE__ */ jsx(RowList, {
29705
- order,
29706
- nodesById,
29707
- layoutSlide: layoutSlide || draggingKey !== null,
29708
- draggingKey,
29709
- previewIndent,
29710
- animated: enterGate.current,
29711
- onReorder: onRowReorder,
29712
- onDragStart: onRowDragStart,
29713
- onDragMove: onRowDragMove,
29714
- onDragEnd: onRowDragEnd
30607
+ children: [view === "canvas" ? /* @__PURE__ */ jsx(CanvasView, {}) : /* @__PURE__ */ jsx(PageSurfaceProvider, {
30608
+ map: surfaceMapRef.current,
30609
+ children: /* @__PURE__ */ jsx("div", {
30610
+ ref: pageRef,
30611
+ "data-slot": "docblocks/page",
30612
+ contentEditable: !viewMode,
30613
+ suppressContentEditableWarning: true,
30614
+ onKeyDown: surface.onKeyDown,
30615
+ onInput: surface.onInput,
30616
+ onPaste: surface.onPaste,
30617
+ className: "\n mx-auto w-full max-w-(--docblocks-page-column-max-width) px-(--docblocks-page-padding-x)\n ",
30618
+ children: /* @__PURE__ */ jsx(RowList, {
30619
+ order,
30620
+ nodesById,
30621
+ layoutSlide: layoutSlide || draggingKey !== null,
30622
+ draggingKey,
30623
+ previewIndent,
30624
+ animated: enterGate.current,
30625
+ onReorder: onRowReorder,
30626
+ onDragStart: onRowDragStart,
30627
+ onDragMove: onRowDragMove,
30628
+ onDragEnd: onRowDragEnd
30629
+ })
29715
30630
  })
29716
30631
  }), viewMode ? null : /* @__PURE__ */ jsx(PresenceCaretOverlay, { rootRef })]
29717
30632
  })