@sofereditor/core 0.1.0 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -25,6 +25,27 @@ interface PageSettings {
25
25
  * This is purely a UI hint — it's recomputed from width/height when needed.
26
26
  */
27
27
  preset?: PagePreset;
28
+ /**
29
+ * Free-form title persisted on the document for a consumer-rendered
30
+ * "system header" (e.g. a non-editable letterhead/identification block
31
+ * drawn on page 1 via `renderPageHeader`). Stored in `docSettings` so it
32
+ * survives serialization and is visible to every client/consumer of the
33
+ * `SerializedDocument`, including headless exports.
34
+ *
35
+ * The renderer is application-defined — this field just transports the
36
+ * title string. Use it when the header content is part of the document
37
+ * (and therefore must round-trip through exports), not a UI chrome
38
+ * decoration.
39
+ */
40
+ systemHeaderTitle?: string;
41
+ /**
42
+ * Owner/author display name for the same consumer-rendered system
43
+ * header (see [[systemHeaderTitle]]). Useful when the header should
44
+ * show the document's CREATOR, not the current viewer (e.g. an author
45
+ * name on a doc viewed by a third party). Persisted in `docSettings`
46
+ * for consistent rendering across clients and headless renderers.
47
+ */
48
+ systemHeaderAuthor?: string;
28
49
  }
29
50
  /** Page sizes in CSS px @ 96dpi. */
30
51
  declare const PAGE_PRESETS: {
@@ -67,6 +88,7 @@ type BlockType = "paragraph" | "heading" | "blockquote" | "codeBlock" | "listIte
67
88
  type AlignValue = "left" | "center" | "right" | "justify";
68
89
  type DirValue = "ltr" | "rtl";
69
90
  type ListKind = "bullet" | "ordered";
91
+ type ListStyleType = "decimal" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
70
92
  /** Maximum supported list nesting (0 = top level). */
71
93
  declare const MAX_LIST_LEVEL = 5;
72
94
  interface BlockAttrs {
@@ -80,6 +102,20 @@ interface BlockAttrs {
80
102
  listKind?: ListKind;
81
103
  /** Only meaningful when `type === "listItem"`. 0..MAX_LIST_LEVEL. */
82
104
  listLevel?: number;
105
+ /**
106
+ * Only meaningful when `type === "listItem"` and `listKind === "ordered"`.
107
+ * When set on a listItem, that item starts a NEW list group whose first
108
+ * `<ol>` carries `start={listStart}`. Used to renumerate questions or pick
109
+ * up an interrupted sequence.
110
+ */
111
+ listStart?: number;
112
+ /**
113
+ * Only meaningful when `type === "listItem"`. Overrides the default per-level
114
+ * CSS cycle (decimal → lower-alpha → lower-roman) with an explicit style.
115
+ * Like `listStart`, setting this on a listItem breaks the group so the new
116
+ * `<ol>` carries the requested `list-style-type`.
117
+ */
118
+ listStyle?: ListStyleType;
83
119
  /** Only meaningful when `type === "table"`. */
84
120
  rows?: number;
85
121
  /** Only meaningful when `type === "table"`. */
@@ -108,6 +144,8 @@ interface CellAttrs {
108
144
  * scheme — covered cells are placeholders, not gaps.
109
145
  */
110
146
  covered?: true;
147
+ /** Alinhamento horizontal do texto da célula. Mesmos valores de bloco. */
148
+ align?: AlignValue;
111
149
  }
112
150
  interface Position {
113
151
  blockIndex: number;
@@ -217,6 +255,8 @@ interface SerializedCell {
217
255
  attrs: CellAttrs;
218
256
  }
219
257
  interface SerializedBlock {
258
+ /** Id estável do bloco (cursores colaborativos / keying). Ausente em docs antigos. */
259
+ id?: string;
220
260
  type: BlockType;
221
261
  /** Plain concatenated text (no marks). Kept for ergonomic equality checks. */
222
262
  text: string;
@@ -254,6 +294,15 @@ declare const BLOCK_SPECS: Record<BlockType, BlockSpec>;
254
294
  declare function isKnownBlockType(t: string): t is BlockType;
255
295
  declare function defaultAttrsFor(type: BlockType): BlockAttrs;
256
296
 
297
+ /**
298
+ * Gera um id estável de bloco. Usado para ancorar cursores colaborativos
299
+ * remotos (fallback) e para keying estável no overlay. Persistido no Y.Map do
300
+ * bloco, então sobrevive a reload (binário Yjs). Docs antigos não têm — os
301
+ * helpers de cursor lidam com a ausência (caem na RelativePosition).
302
+ */
303
+ declare function newBlockId(): string;
304
+ /** Lê o id de um bloco Y.Map (undefined em docs antigos sem id). */
305
+ declare function getBlockId(block: Y.Map<unknown>): string | undefined;
257
306
  /**
258
307
  * Y.js-backed document.
259
308
  *
@@ -346,6 +395,23 @@ declare function createCell(attrs?: CellAttrs): Y.Map<unknown>;
346
395
  /** Coerce a `rowspan`/`colspan` attribute value into a positive integer. */
347
396
  declare function spanOf(value: unknown): number;
348
397
 
398
+ interface EncodedCursorPoint {
399
+ /** base64 de Y.encodeRelativePosition — rastreia o caractere exato. */
400
+ rel: string;
401
+ /** Fallback: id do bloco original (ancora no início se o char sumiu). */
402
+ blockId?: string;
403
+ /** Fallback: célula da tabela, se aplicável. */
404
+ cellIndex?: number;
405
+ }
406
+ interface EncodedCursor {
407
+ anchor: EncodedCursorPoint;
408
+ focus: EncodedCursorPoint;
409
+ }
410
+ /** Codifica a seleção local em um descritor portável (para o awareness). */
411
+ declare function encodeSelection(doc: EditorDocument, sel: Selection): EncodedCursor | null;
412
+ /** Decodifica um descritor remoto para uma seleção absoluta no doc atual. */
413
+ declare function decodeSelection(doc: EditorDocument, enc: EncodedCursor): Selection | null;
414
+
349
415
  declare function isCollapsed(sel: Selection): boolean;
350
416
  declare function positionsEqual(a: Position, b: Position): boolean;
351
417
  declare function comparePositions(a: Position, b: Position): number;
@@ -361,6 +427,12 @@ declare function collapsedSelection(pos: Position): Selection;
361
427
  */
362
428
  declare function sameTextRun(a: Position, b: Position): boolean;
363
429
 
430
+ /**
431
+ * Attributes object that explicitly clears every mark (sets each to `null`).
432
+ * Spread your desired marks on top to insert text carrying EXACTLY those marks,
433
+ * overriding any formatting Y.Text would otherwise inherit from an adjacent run.
434
+ */
435
+ declare const CLEAR_ALL_MARKS: Record<string, null>;
364
436
  /**
365
437
  * Returns the marks observed across `[start, end)`. For each mark name encountered:
366
438
  * - if every covered character has the same value, returns that value
@@ -376,6 +448,28 @@ declare function deltaLength(delta: DeltaOp[]): number;
376
448
  */
377
449
  declare function sliceDelta(delta: DeltaOp[], start: number, end: number): DeltaOp[];
378
450
 
451
+ /** MIME custom que carrega o slice serializado no clipboard. */
452
+ declare const SOFER_MIME = "application/x-sofer-slice";
453
+ interface ClipboardSlice {
454
+ /** 1..n blocos; cada delta carrega marks + embeds de imagem. */
455
+ blocks: SerializedBlock[];
456
+ /** 1º bloco é fragmento parcial → mescla inline no alvo da colagem. */
457
+ openStart: boolean;
458
+ /** último bloco é fragmento parcial → conteúdo após o caret continua nele. */
459
+ openEnd: boolean;
460
+ }
461
+ /**
462
+ * Lê a seleção e produz um ClipboardSlice, ou null se:
463
+ * - colapsada; - âncora/foco em células diferentes; - multi-bloco com tabela.
464
+ */
465
+ declare function serializeSelection(doc: EditorDocument, sel: Selection): ClipboardSlice | null;
466
+ /** Fallback texto puro: textos dos blocos unidos por "\n". */
467
+ declare function sliceToText(slice: ClipboardSlice): string;
468
+ /** Achata o slice num único delta inline (para colar dentro de uma célula).
469
+ * Fronteiras de bloco viram quebra de linha "\n" (células renderizam pre-wrap),
470
+ * para não grudar palavras de parágrafos distintos. */
471
+ declare function sliceToInlineDelta(slice: ClipboardSlice): DeltaOp[];
472
+
379
473
  declare const COMMAND_ORIGIN: unique symbol;
380
474
  interface CommandContext {
381
475
  doc: EditorDocument;
@@ -419,6 +513,26 @@ declare function setBlockType(ctx: CommandContext, type: BlockType, attrs?: Bloc
419
513
  * Passing `value === null` deletes the key.
420
514
  */
421
515
  declare function setBlockAttr<K extends keyof BlockAttrs>(ctx: CommandContext, key: K, value: BlockAttrs[K] | null): void;
516
+ /**
517
+ * Set a single attribute on the table cell(s) under the selection.
518
+ * - Caret numa única célula → essa célula (tableRectSelection retorna null
519
+ * para seleção colapsada (ou âncora/foco no mesmo owner), então usamos
520
+ * a célula focada (redirecionada ao owner real).
521
+ * - Seleção retangular de várias células → todas as células reais do rect.
522
+ * Células `covered` são puladas. `value === null` apaga a key.
523
+ * No-op se a seleção não estiver dentro de uma tabela.
524
+ */
525
+ declare function setCellAttr<K extends keyof CellAttrs>(ctx: CommandContext, key: K, value: CellAttrs[K] | null): void;
526
+ /** Delete the current selection range and collapse the caret. Used by cut. */
527
+ declare function deleteSelection(ctx: CommandContext): void;
528
+ /**
529
+ * Replace the current selection with a clipboard slice (A1).
530
+ * - Single-block slice → inline splice (Dhead + S0 + Dtail), target keeps its type.
531
+ * - Multi-block slice → openStart merges S0 inline; middle/last blocks inserted
532
+ * discretely; openEnd appends the post-caret tail onto the last pasted block.
533
+ * - Target inside a table cell → slice flattened to inline (no block structure).
534
+ */
535
+ declare function insertSlice(ctx: CommandContext, slice: ClipboardSlice): void;
422
536
  /**
423
537
  * Convert every block in the selection to/from a `listItem` of `kind`.
424
538
  * If every covered block is already a `listItem` of `kind` → convert them all to paragraphs.
@@ -587,6 +701,24 @@ declare function insertImage(ctx: CommandContext, embed: ImageEmbed): void;
587
701
  * around it (CSS float only flows text that comes AFTER the float in DOM order).
588
702
  */
589
703
  declare function setImageAttrs(ctx: CommandContext, blockIndex: number, embedOffset: number, partial: Partial<ImageEmbed>, cellIndex?: number, newOffset?: number): void;
704
+ /** Location of an embed in the model (block or table cell). */
705
+ interface EmbedLoc {
706
+ blockIndex: number;
707
+ offset: number;
708
+ cellIndex?: number;
709
+ }
710
+ /**
711
+ * Move a floating image embed from `from` to `to` in a SINGLE Y.Doc
712
+ * transaction, applying new positional offsets. Atomic delete+insert keeps the
713
+ * CRDT consistent for collab peers and coalesces into one undo step.
714
+ *
715
+ * Guard: only non-inline (re-anchorable) image embeds are moved; everything
716
+ * else is a no-op. When `from` and `to` resolve to the SAME Y.Text, the insert
717
+ * index is adjusted for the prior delete (mirrors `setImageAttrs`'s clamp at
718
+ * lines 1709-1714). Sets the selection to the embed's new 1-char home so the
719
+ * resize overlay stays attached.
720
+ */
721
+ declare function moveEmbedAnchor(ctx: CommandContext, from: EmbedLoc, to: EmbedLoc, newOffsetX: number, newOffsetY: number): void;
590
722
  declare function isCommandOrigin(origin: unknown): boolean;
591
723
  declare const TRACKED_ORIGINS: Set<unknown>;
592
724
 
@@ -598,4 +730,4 @@ declare class EditorHistory {
598
730
  destroy(): void;
599
731
  }
600
732
 
601
- export { type AlignValue, BLOCK_SPECS, type BlockAttrs, type BlockType, COMMAND_ORIGIN, type CellAttrs, type CommandContext, type CommentAttr, DEFAULT_PAGE_SETTINGS, type DeltaOp, type DirValue, EditorDocument, EditorHistory, type ImageEmbed, type ImageLayout, type InsertContent, type LegacySerializedDocument, type LinkAttr, type ListKind, MARGIN_PRESETS, MAX_LIST_LEVEL, type MarkAttrs, type MarkName, type MarkValue, PAGE_PRESETS, type PagePreset, type PageSettings, type Position, type Selection, type SerializedBlock, type SerializedCell, type SerializedDocument, TRACKED_ORIGINS, type TableLocation, type TableRect, cellsInRect, clearRectCells, collapsedSelection, comparePositions, createBlock, createCell, createTableBlock, dedentList, defaultAttrsFor, deleteBackward, deleteForward, deleteTable, deleteTableColumn, deleteTableRow, deltaLength, detectPreset, expandTableRect, getMarksInRange, indentList, insertImage, insertParagraph, insertTable, insertTableColumn, insertTableRow, insertText, isCollapsed, isCommandOrigin, isImageEmbed, isKnownBlockType, isLegacySerializedDocument, isMarkUniformInRange, mergeDown, mergeRight, mergeSelection, mmToPx, moveToNextCell, moveToPrevCell, orderedRange, positionsEqual, pxToMm, removeMark, sameTextRun, setBlockAttr, setBlockType, setColumnWidth, setImageAttrs, setMark, sliceDelta, spanOf, splitCell, splitListItem, tableLocationOf, tableRectSelection, toggleList, toggleMark, withDefaults };
733
+ export { type AlignValue, BLOCK_SPECS, type BlockAttrs, type BlockType, CLEAR_ALL_MARKS, COMMAND_ORIGIN, type CellAttrs, type ClipboardSlice, type CommandContext, type CommentAttr, DEFAULT_PAGE_SETTINGS, type DeltaOp, type DirValue, EditorDocument, EditorHistory, type EmbedLoc, type EncodedCursor, type EncodedCursorPoint, type ImageEmbed, type ImageLayout, type InsertContent, type LegacySerializedDocument, type LinkAttr, type ListKind, type ListStyleType, MARGIN_PRESETS, MAX_LIST_LEVEL, type MarkAttrs, type MarkName, type MarkValue, PAGE_PRESETS, type PagePreset, type PageSettings, type Position, SOFER_MIME, type Selection, type SerializedBlock, type SerializedCell, type SerializedDocument, TRACKED_ORIGINS, type TableLocation, type TableRect, cellsInRect, clearRectCells, collapsedSelection, comparePositions, createBlock, createCell, createTableBlock, decodeSelection, dedentList, defaultAttrsFor, deleteBackward, deleteForward, deleteSelection, deleteTable, deleteTableColumn, deleteTableRow, deltaLength, detectPreset, encodeSelection, expandTableRect, getBlockId, getMarksInRange, indentList, insertImage, insertParagraph, insertSlice, insertTable, insertTableColumn, insertTableRow, insertText, isCollapsed, isCommandOrigin, isImageEmbed, isKnownBlockType, isLegacySerializedDocument, isMarkUniformInRange, mergeDown, mergeRight, mergeSelection, mmToPx, moveEmbedAnchor, moveToNextCell, moveToPrevCell, newBlockId, orderedRange, positionsEqual, pxToMm, removeMark, sameTextRun, serializeSelection, setBlockAttr, setBlockType, setCellAttr, setColumnWidth, setImageAttrs, setMark, sliceDelta, sliceToInlineDelta, sliceToText, spanOf, splitCell, splitListItem, tableLocationOf, tableRectSelection, toggleList, toggleMark, withDefaults };
package/dist/index.d.ts CHANGED
@@ -25,6 +25,27 @@ interface PageSettings {
25
25
  * This is purely a UI hint — it's recomputed from width/height when needed.
26
26
  */
27
27
  preset?: PagePreset;
28
+ /**
29
+ * Free-form title persisted on the document for a consumer-rendered
30
+ * "system header" (e.g. a non-editable letterhead/identification block
31
+ * drawn on page 1 via `renderPageHeader`). Stored in `docSettings` so it
32
+ * survives serialization and is visible to every client/consumer of the
33
+ * `SerializedDocument`, including headless exports.
34
+ *
35
+ * The renderer is application-defined — this field just transports the
36
+ * title string. Use it when the header content is part of the document
37
+ * (and therefore must round-trip through exports), not a UI chrome
38
+ * decoration.
39
+ */
40
+ systemHeaderTitle?: string;
41
+ /**
42
+ * Owner/author display name for the same consumer-rendered system
43
+ * header (see [[systemHeaderTitle]]). Useful when the header should
44
+ * show the document's CREATOR, not the current viewer (e.g. an author
45
+ * name on a doc viewed by a third party). Persisted in `docSettings`
46
+ * for consistent rendering across clients and headless renderers.
47
+ */
48
+ systemHeaderAuthor?: string;
28
49
  }
29
50
  /** Page sizes in CSS px @ 96dpi. */
30
51
  declare const PAGE_PRESETS: {
@@ -67,6 +88,7 @@ type BlockType = "paragraph" | "heading" | "blockquote" | "codeBlock" | "listIte
67
88
  type AlignValue = "left" | "center" | "right" | "justify";
68
89
  type DirValue = "ltr" | "rtl";
69
90
  type ListKind = "bullet" | "ordered";
91
+ type ListStyleType = "decimal" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
70
92
  /** Maximum supported list nesting (0 = top level). */
71
93
  declare const MAX_LIST_LEVEL = 5;
72
94
  interface BlockAttrs {
@@ -80,6 +102,20 @@ interface BlockAttrs {
80
102
  listKind?: ListKind;
81
103
  /** Only meaningful when `type === "listItem"`. 0..MAX_LIST_LEVEL. */
82
104
  listLevel?: number;
105
+ /**
106
+ * Only meaningful when `type === "listItem"` and `listKind === "ordered"`.
107
+ * When set on a listItem, that item starts a NEW list group whose first
108
+ * `<ol>` carries `start={listStart}`. Used to renumerate questions or pick
109
+ * up an interrupted sequence.
110
+ */
111
+ listStart?: number;
112
+ /**
113
+ * Only meaningful when `type === "listItem"`. Overrides the default per-level
114
+ * CSS cycle (decimal → lower-alpha → lower-roman) with an explicit style.
115
+ * Like `listStart`, setting this on a listItem breaks the group so the new
116
+ * `<ol>` carries the requested `list-style-type`.
117
+ */
118
+ listStyle?: ListStyleType;
83
119
  /** Only meaningful when `type === "table"`. */
84
120
  rows?: number;
85
121
  /** Only meaningful when `type === "table"`. */
@@ -108,6 +144,8 @@ interface CellAttrs {
108
144
  * scheme — covered cells are placeholders, not gaps.
109
145
  */
110
146
  covered?: true;
147
+ /** Alinhamento horizontal do texto da célula. Mesmos valores de bloco. */
148
+ align?: AlignValue;
111
149
  }
112
150
  interface Position {
113
151
  blockIndex: number;
@@ -217,6 +255,8 @@ interface SerializedCell {
217
255
  attrs: CellAttrs;
218
256
  }
219
257
  interface SerializedBlock {
258
+ /** Id estável do bloco (cursores colaborativos / keying). Ausente em docs antigos. */
259
+ id?: string;
220
260
  type: BlockType;
221
261
  /** Plain concatenated text (no marks). Kept for ergonomic equality checks. */
222
262
  text: string;
@@ -254,6 +294,15 @@ declare const BLOCK_SPECS: Record<BlockType, BlockSpec>;
254
294
  declare function isKnownBlockType(t: string): t is BlockType;
255
295
  declare function defaultAttrsFor(type: BlockType): BlockAttrs;
256
296
 
297
+ /**
298
+ * Gera um id estável de bloco. Usado para ancorar cursores colaborativos
299
+ * remotos (fallback) e para keying estável no overlay. Persistido no Y.Map do
300
+ * bloco, então sobrevive a reload (binário Yjs). Docs antigos não têm — os
301
+ * helpers de cursor lidam com a ausência (caem na RelativePosition).
302
+ */
303
+ declare function newBlockId(): string;
304
+ /** Lê o id de um bloco Y.Map (undefined em docs antigos sem id). */
305
+ declare function getBlockId(block: Y.Map<unknown>): string | undefined;
257
306
  /**
258
307
  * Y.js-backed document.
259
308
  *
@@ -346,6 +395,23 @@ declare function createCell(attrs?: CellAttrs): Y.Map<unknown>;
346
395
  /** Coerce a `rowspan`/`colspan` attribute value into a positive integer. */
347
396
  declare function spanOf(value: unknown): number;
348
397
 
398
+ interface EncodedCursorPoint {
399
+ /** base64 de Y.encodeRelativePosition — rastreia o caractere exato. */
400
+ rel: string;
401
+ /** Fallback: id do bloco original (ancora no início se o char sumiu). */
402
+ blockId?: string;
403
+ /** Fallback: célula da tabela, se aplicável. */
404
+ cellIndex?: number;
405
+ }
406
+ interface EncodedCursor {
407
+ anchor: EncodedCursorPoint;
408
+ focus: EncodedCursorPoint;
409
+ }
410
+ /** Codifica a seleção local em um descritor portável (para o awareness). */
411
+ declare function encodeSelection(doc: EditorDocument, sel: Selection): EncodedCursor | null;
412
+ /** Decodifica um descritor remoto para uma seleção absoluta no doc atual. */
413
+ declare function decodeSelection(doc: EditorDocument, enc: EncodedCursor): Selection | null;
414
+
349
415
  declare function isCollapsed(sel: Selection): boolean;
350
416
  declare function positionsEqual(a: Position, b: Position): boolean;
351
417
  declare function comparePositions(a: Position, b: Position): number;
@@ -361,6 +427,12 @@ declare function collapsedSelection(pos: Position): Selection;
361
427
  */
362
428
  declare function sameTextRun(a: Position, b: Position): boolean;
363
429
 
430
+ /**
431
+ * Attributes object that explicitly clears every mark (sets each to `null`).
432
+ * Spread your desired marks on top to insert text carrying EXACTLY those marks,
433
+ * overriding any formatting Y.Text would otherwise inherit from an adjacent run.
434
+ */
435
+ declare const CLEAR_ALL_MARKS: Record<string, null>;
364
436
  /**
365
437
  * Returns the marks observed across `[start, end)`. For each mark name encountered:
366
438
  * - if every covered character has the same value, returns that value
@@ -376,6 +448,28 @@ declare function deltaLength(delta: DeltaOp[]): number;
376
448
  */
377
449
  declare function sliceDelta(delta: DeltaOp[], start: number, end: number): DeltaOp[];
378
450
 
451
+ /** MIME custom que carrega o slice serializado no clipboard. */
452
+ declare const SOFER_MIME = "application/x-sofer-slice";
453
+ interface ClipboardSlice {
454
+ /** 1..n blocos; cada delta carrega marks + embeds de imagem. */
455
+ blocks: SerializedBlock[];
456
+ /** 1º bloco é fragmento parcial → mescla inline no alvo da colagem. */
457
+ openStart: boolean;
458
+ /** último bloco é fragmento parcial → conteúdo após o caret continua nele. */
459
+ openEnd: boolean;
460
+ }
461
+ /**
462
+ * Lê a seleção e produz um ClipboardSlice, ou null se:
463
+ * - colapsada; - âncora/foco em células diferentes; - multi-bloco com tabela.
464
+ */
465
+ declare function serializeSelection(doc: EditorDocument, sel: Selection): ClipboardSlice | null;
466
+ /** Fallback texto puro: textos dos blocos unidos por "\n". */
467
+ declare function sliceToText(slice: ClipboardSlice): string;
468
+ /** Achata o slice num único delta inline (para colar dentro de uma célula).
469
+ * Fronteiras de bloco viram quebra de linha "\n" (células renderizam pre-wrap),
470
+ * para não grudar palavras de parágrafos distintos. */
471
+ declare function sliceToInlineDelta(slice: ClipboardSlice): DeltaOp[];
472
+
379
473
  declare const COMMAND_ORIGIN: unique symbol;
380
474
  interface CommandContext {
381
475
  doc: EditorDocument;
@@ -419,6 +513,26 @@ declare function setBlockType(ctx: CommandContext, type: BlockType, attrs?: Bloc
419
513
  * Passing `value === null` deletes the key.
420
514
  */
421
515
  declare function setBlockAttr<K extends keyof BlockAttrs>(ctx: CommandContext, key: K, value: BlockAttrs[K] | null): void;
516
+ /**
517
+ * Set a single attribute on the table cell(s) under the selection.
518
+ * - Caret numa única célula → essa célula (tableRectSelection retorna null
519
+ * para seleção colapsada (ou âncora/foco no mesmo owner), então usamos
520
+ * a célula focada (redirecionada ao owner real).
521
+ * - Seleção retangular de várias células → todas as células reais do rect.
522
+ * Células `covered` são puladas. `value === null` apaga a key.
523
+ * No-op se a seleção não estiver dentro de uma tabela.
524
+ */
525
+ declare function setCellAttr<K extends keyof CellAttrs>(ctx: CommandContext, key: K, value: CellAttrs[K] | null): void;
526
+ /** Delete the current selection range and collapse the caret. Used by cut. */
527
+ declare function deleteSelection(ctx: CommandContext): void;
528
+ /**
529
+ * Replace the current selection with a clipboard slice (A1).
530
+ * - Single-block slice → inline splice (Dhead + S0 + Dtail), target keeps its type.
531
+ * - Multi-block slice → openStart merges S0 inline; middle/last blocks inserted
532
+ * discretely; openEnd appends the post-caret tail onto the last pasted block.
533
+ * - Target inside a table cell → slice flattened to inline (no block structure).
534
+ */
535
+ declare function insertSlice(ctx: CommandContext, slice: ClipboardSlice): void;
422
536
  /**
423
537
  * Convert every block in the selection to/from a `listItem` of `kind`.
424
538
  * If every covered block is already a `listItem` of `kind` → convert them all to paragraphs.
@@ -587,6 +701,24 @@ declare function insertImage(ctx: CommandContext, embed: ImageEmbed): void;
587
701
  * around it (CSS float only flows text that comes AFTER the float in DOM order).
588
702
  */
589
703
  declare function setImageAttrs(ctx: CommandContext, blockIndex: number, embedOffset: number, partial: Partial<ImageEmbed>, cellIndex?: number, newOffset?: number): void;
704
+ /** Location of an embed in the model (block or table cell). */
705
+ interface EmbedLoc {
706
+ blockIndex: number;
707
+ offset: number;
708
+ cellIndex?: number;
709
+ }
710
+ /**
711
+ * Move a floating image embed from `from` to `to` in a SINGLE Y.Doc
712
+ * transaction, applying new positional offsets. Atomic delete+insert keeps the
713
+ * CRDT consistent for collab peers and coalesces into one undo step.
714
+ *
715
+ * Guard: only non-inline (re-anchorable) image embeds are moved; everything
716
+ * else is a no-op. When `from` and `to` resolve to the SAME Y.Text, the insert
717
+ * index is adjusted for the prior delete (mirrors `setImageAttrs`'s clamp at
718
+ * lines 1709-1714). Sets the selection to the embed's new 1-char home so the
719
+ * resize overlay stays attached.
720
+ */
721
+ declare function moveEmbedAnchor(ctx: CommandContext, from: EmbedLoc, to: EmbedLoc, newOffsetX: number, newOffsetY: number): void;
590
722
  declare function isCommandOrigin(origin: unknown): boolean;
591
723
  declare const TRACKED_ORIGINS: Set<unknown>;
592
724
 
@@ -598,4 +730,4 @@ declare class EditorHistory {
598
730
  destroy(): void;
599
731
  }
600
732
 
601
- export { type AlignValue, BLOCK_SPECS, type BlockAttrs, type BlockType, COMMAND_ORIGIN, type CellAttrs, type CommandContext, type CommentAttr, DEFAULT_PAGE_SETTINGS, type DeltaOp, type DirValue, EditorDocument, EditorHistory, type ImageEmbed, type ImageLayout, type InsertContent, type LegacySerializedDocument, type LinkAttr, type ListKind, MARGIN_PRESETS, MAX_LIST_LEVEL, type MarkAttrs, type MarkName, type MarkValue, PAGE_PRESETS, type PagePreset, type PageSettings, type Position, type Selection, type SerializedBlock, type SerializedCell, type SerializedDocument, TRACKED_ORIGINS, type TableLocation, type TableRect, cellsInRect, clearRectCells, collapsedSelection, comparePositions, createBlock, createCell, createTableBlock, dedentList, defaultAttrsFor, deleteBackward, deleteForward, deleteTable, deleteTableColumn, deleteTableRow, deltaLength, detectPreset, expandTableRect, getMarksInRange, indentList, insertImage, insertParagraph, insertTable, insertTableColumn, insertTableRow, insertText, isCollapsed, isCommandOrigin, isImageEmbed, isKnownBlockType, isLegacySerializedDocument, isMarkUniformInRange, mergeDown, mergeRight, mergeSelection, mmToPx, moveToNextCell, moveToPrevCell, orderedRange, positionsEqual, pxToMm, removeMark, sameTextRun, setBlockAttr, setBlockType, setColumnWidth, setImageAttrs, setMark, sliceDelta, spanOf, splitCell, splitListItem, tableLocationOf, tableRectSelection, toggleList, toggleMark, withDefaults };
733
+ export { type AlignValue, BLOCK_SPECS, type BlockAttrs, type BlockType, CLEAR_ALL_MARKS, COMMAND_ORIGIN, type CellAttrs, type ClipboardSlice, type CommandContext, type CommentAttr, DEFAULT_PAGE_SETTINGS, type DeltaOp, type DirValue, EditorDocument, EditorHistory, type EmbedLoc, type EncodedCursor, type EncodedCursorPoint, type ImageEmbed, type ImageLayout, type InsertContent, type LegacySerializedDocument, type LinkAttr, type ListKind, type ListStyleType, MARGIN_PRESETS, MAX_LIST_LEVEL, type MarkAttrs, type MarkName, type MarkValue, PAGE_PRESETS, type PagePreset, type PageSettings, type Position, SOFER_MIME, type Selection, type SerializedBlock, type SerializedCell, type SerializedDocument, TRACKED_ORIGINS, type TableLocation, type TableRect, cellsInRect, clearRectCells, collapsedSelection, comparePositions, createBlock, createCell, createTableBlock, decodeSelection, dedentList, defaultAttrsFor, deleteBackward, deleteForward, deleteSelection, deleteTable, deleteTableColumn, deleteTableRow, deltaLength, detectPreset, encodeSelection, expandTableRect, getBlockId, getMarksInRange, indentList, insertImage, insertParagraph, insertSlice, insertTable, insertTableColumn, insertTableRow, insertText, isCollapsed, isCommandOrigin, isImageEmbed, isKnownBlockType, isLegacySerializedDocument, isMarkUniformInRange, mergeDown, mergeRight, mergeSelection, mmToPx, moveEmbedAnchor, moveToNextCell, moveToPrevCell, newBlockId, orderedRange, positionsEqual, pxToMm, removeMark, sameTextRun, serializeSelection, setBlockAttr, setBlockType, setCellAttr, setColumnWidth, setImageAttrs, setMark, sliceDelta, sliceToInlineDelta, sliceToText, spanOf, splitCell, splitListItem, tableLocationOf, tableRectSelection, toggleList, toggleMark, withDefaults };