@sofereditor/core 0.2.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.cjs +384 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.js +371 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -144,6 +144,8 @@ interface CellAttrs {
|
|
|
144
144
|
* scheme — covered cells are placeholders, not gaps.
|
|
145
145
|
*/
|
|
146
146
|
covered?: true;
|
|
147
|
+
/** Alinhamento horizontal do texto da célula. Mesmos valores de bloco. */
|
|
148
|
+
align?: AlignValue;
|
|
147
149
|
}
|
|
148
150
|
interface Position {
|
|
149
151
|
blockIndex: number;
|
|
@@ -253,6 +255,8 @@ interface SerializedCell {
|
|
|
253
255
|
attrs: CellAttrs;
|
|
254
256
|
}
|
|
255
257
|
interface SerializedBlock {
|
|
258
|
+
/** Id estável do bloco (cursores colaborativos / keying). Ausente em docs antigos. */
|
|
259
|
+
id?: string;
|
|
256
260
|
type: BlockType;
|
|
257
261
|
/** Plain concatenated text (no marks). Kept for ergonomic equality checks. */
|
|
258
262
|
text: string;
|
|
@@ -290,6 +294,15 @@ declare const BLOCK_SPECS: Record<BlockType, BlockSpec>;
|
|
|
290
294
|
declare function isKnownBlockType(t: string): t is BlockType;
|
|
291
295
|
declare function defaultAttrsFor(type: BlockType): BlockAttrs;
|
|
292
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;
|
|
293
306
|
/**
|
|
294
307
|
* Y.js-backed document.
|
|
295
308
|
*
|
|
@@ -382,6 +395,23 @@ declare function createCell(attrs?: CellAttrs): Y.Map<unknown>;
|
|
|
382
395
|
/** Coerce a `rowspan`/`colspan` attribute value into a positive integer. */
|
|
383
396
|
declare function spanOf(value: unknown): number;
|
|
384
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
|
+
|
|
385
415
|
declare function isCollapsed(sel: Selection): boolean;
|
|
386
416
|
declare function positionsEqual(a: Position, b: Position): boolean;
|
|
387
417
|
declare function comparePositions(a: Position, b: Position): number;
|
|
@@ -397,6 +427,12 @@ declare function collapsedSelection(pos: Position): Selection;
|
|
|
397
427
|
*/
|
|
398
428
|
declare function sameTextRun(a: Position, b: Position): boolean;
|
|
399
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>;
|
|
400
436
|
/**
|
|
401
437
|
* Returns the marks observed across `[start, end)`. For each mark name encountered:
|
|
402
438
|
* - if every covered character has the same value, returns that value
|
|
@@ -412,6 +448,28 @@ declare function deltaLength(delta: DeltaOp[]): number;
|
|
|
412
448
|
*/
|
|
413
449
|
declare function sliceDelta(delta: DeltaOp[], start: number, end: number): DeltaOp[];
|
|
414
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
|
+
|
|
415
473
|
declare const COMMAND_ORIGIN: unique symbol;
|
|
416
474
|
interface CommandContext {
|
|
417
475
|
doc: EditorDocument;
|
|
@@ -455,6 +513,26 @@ declare function setBlockType(ctx: CommandContext, type: BlockType, attrs?: Bloc
|
|
|
455
513
|
* Passing `value === null` deletes the key.
|
|
456
514
|
*/
|
|
457
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;
|
|
458
536
|
/**
|
|
459
537
|
* Convert every block in the selection to/from a `listItem` of `kind`.
|
|
460
538
|
* If every covered block is already a `listItem` of `kind` → convert them all to paragraphs.
|
|
@@ -623,6 +701,24 @@ declare function insertImage(ctx: CommandContext, embed: ImageEmbed): void;
|
|
|
623
701
|
* around it (CSS float only flows text that comes AFTER the float in DOM order).
|
|
624
702
|
*/
|
|
625
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;
|
|
626
722
|
declare function isCommandOrigin(origin: unknown): boolean;
|
|
627
723
|
declare const TRACKED_ORIGINS: Set<unknown>;
|
|
628
724
|
|
|
@@ -634,4 +730,4 @@ declare class EditorHistory {
|
|
|
634
730
|
destroy(): void;
|
|
635
731
|
}
|
|
636
732
|
|
|
637
|
-
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, type ListStyleType, 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
|
@@ -144,6 +144,8 @@ interface CellAttrs {
|
|
|
144
144
|
* scheme — covered cells are placeholders, not gaps.
|
|
145
145
|
*/
|
|
146
146
|
covered?: true;
|
|
147
|
+
/** Alinhamento horizontal do texto da célula. Mesmos valores de bloco. */
|
|
148
|
+
align?: AlignValue;
|
|
147
149
|
}
|
|
148
150
|
interface Position {
|
|
149
151
|
blockIndex: number;
|
|
@@ -253,6 +255,8 @@ interface SerializedCell {
|
|
|
253
255
|
attrs: CellAttrs;
|
|
254
256
|
}
|
|
255
257
|
interface SerializedBlock {
|
|
258
|
+
/** Id estável do bloco (cursores colaborativos / keying). Ausente em docs antigos. */
|
|
259
|
+
id?: string;
|
|
256
260
|
type: BlockType;
|
|
257
261
|
/** Plain concatenated text (no marks). Kept for ergonomic equality checks. */
|
|
258
262
|
text: string;
|
|
@@ -290,6 +294,15 @@ declare const BLOCK_SPECS: Record<BlockType, BlockSpec>;
|
|
|
290
294
|
declare function isKnownBlockType(t: string): t is BlockType;
|
|
291
295
|
declare function defaultAttrsFor(type: BlockType): BlockAttrs;
|
|
292
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;
|
|
293
306
|
/**
|
|
294
307
|
* Y.js-backed document.
|
|
295
308
|
*
|
|
@@ -382,6 +395,23 @@ declare function createCell(attrs?: CellAttrs): Y.Map<unknown>;
|
|
|
382
395
|
/** Coerce a `rowspan`/`colspan` attribute value into a positive integer. */
|
|
383
396
|
declare function spanOf(value: unknown): number;
|
|
384
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
|
+
|
|
385
415
|
declare function isCollapsed(sel: Selection): boolean;
|
|
386
416
|
declare function positionsEqual(a: Position, b: Position): boolean;
|
|
387
417
|
declare function comparePositions(a: Position, b: Position): number;
|
|
@@ -397,6 +427,12 @@ declare function collapsedSelection(pos: Position): Selection;
|
|
|
397
427
|
*/
|
|
398
428
|
declare function sameTextRun(a: Position, b: Position): boolean;
|
|
399
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>;
|
|
400
436
|
/**
|
|
401
437
|
* Returns the marks observed across `[start, end)`. For each mark name encountered:
|
|
402
438
|
* - if every covered character has the same value, returns that value
|
|
@@ -412,6 +448,28 @@ declare function deltaLength(delta: DeltaOp[]): number;
|
|
|
412
448
|
*/
|
|
413
449
|
declare function sliceDelta(delta: DeltaOp[], start: number, end: number): DeltaOp[];
|
|
414
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
|
+
|
|
415
473
|
declare const COMMAND_ORIGIN: unique symbol;
|
|
416
474
|
interface CommandContext {
|
|
417
475
|
doc: EditorDocument;
|
|
@@ -455,6 +513,26 @@ declare function setBlockType(ctx: CommandContext, type: BlockType, attrs?: Bloc
|
|
|
455
513
|
* Passing `value === null` deletes the key.
|
|
456
514
|
*/
|
|
457
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;
|
|
458
536
|
/**
|
|
459
537
|
* Convert every block in the selection to/from a `listItem` of `kind`.
|
|
460
538
|
* If every covered block is already a `listItem` of `kind` → convert them all to paragraphs.
|
|
@@ -623,6 +701,24 @@ declare function insertImage(ctx: CommandContext, embed: ImageEmbed): void;
|
|
|
623
701
|
* around it (CSS float only flows text that comes AFTER the float in DOM order).
|
|
624
702
|
*/
|
|
625
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;
|
|
626
722
|
declare function isCommandOrigin(origin: unknown): boolean;
|
|
627
723
|
declare const TRACKED_ORIGINS: Set<unknown>;
|
|
628
724
|
|
|
@@ -634,4 +730,4 @@ declare class EditorHistory {
|
|
|
634
730
|
destroy(): void;
|
|
635
731
|
}
|
|
636
732
|
|
|
637
|
-
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, type ListStyleType, 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 };
|