roosterjs 9.3.0 → 9.4.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.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 9.3.0)
1
+ // Type definitions for roosterjs (Version 9.4.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -27,6 +27,16 @@ export interface ContentModelWithFormat<T extends ContentModelFormatBase> {
27
27
  format: T;
28
28
  }
29
29
 
30
+ /**
31
+ * Represent a content model with format (Readonly)
32
+ */
33
+ export interface ReadonlyContentModelWithFormat<T extends ContentModelFormatBase> {
34
+ /**
35
+ * Format of this model
36
+ */
37
+ readonly format: Readonly<T>;
38
+ }
39
+
30
40
  /**
31
41
  * Format of Table
32
42
  */
@@ -35,12 +45,32 @@ export type ContentModelTableFormat = ContentModelBlockFormat & IdFormat & Borde
35
45
  /**
36
46
  * Represents base format of an element that supports dataset and/or metadata
37
47
  */
38
- export interface ContentModelWithDataset<T> {
48
+ export type ContentModelWithDataset<T> = MutableMark & {
39
49
  /**
40
50
  * dataset of this element
41
51
  */
42
52
  dataset: DatasetFormat;
43
- }
53
+ };
54
+
55
+ /**
56
+ * Represents base format of an element that supports dataset and/or metadata (Readonly)
57
+ */
58
+ export type ReadonlyContentModelWithDataset<T> = ReadonlyMark & {
59
+ /**
60
+ * dataset of this element
61
+ */
62
+ readonly dataset: ReadonlyDatasetFormat;
63
+ };
64
+
65
+ /**
66
+ * Represents base format of an element that supports dataset and/or metadata (Readonly)
67
+ */
68
+ export type ShallowMutableContentModelWithDataset<T> = ShallowMutableMark & {
69
+ /**
70
+ * dataset of this element
71
+ */
72
+ dataset: DatasetFormat;
73
+ };
44
74
 
45
75
  /**
46
76
  * The format object for a paragraph in Content Model
@@ -832,6 +862,11 @@ export type EntityInfoFormat = {
832
862
  */
833
863
  export type DatasetFormat = Record<string, string>;
834
864
 
865
+ /**
866
+ * Represents dataset format of Content Model (Readonly)
867
+ */
868
+ export type ReadonlyDatasetFormat = Readonly<Record<string, string>>;
869
+
835
870
  /**
836
871
  * Format of table that stored as metadata
837
872
  */
@@ -1376,10 +1411,20 @@ export type ExportContentMode = /**
1376
1411
  */
1377
1412
  export type ContentModelBlock = ContentModelFormatContainer | ContentModelListItem | ContentModelGeneralBlock | ContentModelTable | ContentModelParagraph | ContentModelEntity | ContentModelDivider;
1378
1413
 
1414
+ /**
1415
+ * A union type of Content Model Block (Readonly)
1416
+ */
1417
+ export type ReadonlyContentModelBlock = ReadonlyContentModelFormatContainer | ReadonlyContentModelListItem | ReadonlyContentModelGeneralBlock | ReadonlyContentModelTable | ReadonlyContentModelParagraph | ContentModelEntity | ReadonlyContentModelDivider;
1418
+
1419
+ /**
1420
+ * A union type of Content Model Block (Shallow mutable)
1421
+ */
1422
+ export type ShallowMutableContentModelBlock = ShallowMutableContentModelFormatContainer | ShallowMutableContentModelListItem | ShallowMutableContentModelGeneralBlock | ShallowMutableContentModelTable | ShallowMutableContentModelParagraph | ContentModelEntity | ContentModelDivider;
1423
+
1379
1424
  /**
1380
1425
  * Content Model of Paragraph
1381
1426
  */
1382
- export interface ContentModelParagraph extends ContentModelBlockWithCache, ContentModelBlockBase<'Paragraph'> {
1427
+ export interface ContentModelParagraph extends ContentModelParagraphCommon, ContentModelBlockBase<'Paragraph'> {
1383
1428
  /**
1384
1429
  * Segments within this paragraph
1385
1430
  */
@@ -1392,6 +1437,12 @@ export interface ContentModelParagraph extends ContentModelBlockWithCache, Conte
1392
1437
  * Decorator info for this paragraph, used by heading and P tags
1393
1438
  */
1394
1439
  decorator?: ContentModelParagraphDecorator;
1440
+ }
1441
+
1442
+ /**
1443
+ * Common part of Content Model of Paragraph
1444
+ */
1445
+ export interface ContentModelParagraphCommon {
1395
1446
  /**
1396
1447
  * Whether this block was created from a block HTML element or just some simple segment between other block elements.
1397
1448
  * True means it doesn't have a related block element, false means it was from a block element
@@ -1399,10 +1450,46 @@ export interface ContentModelParagraph extends ContentModelBlockWithCache, Conte
1399
1450
  isImplicit?: boolean;
1400
1451
  }
1401
1452
 
1453
+ /**
1454
+ * Content Model of Paragraph (Readonly)
1455
+ */
1456
+ export interface ReadonlyContentModelParagraph extends ReadonlyContentModelBlockBase<'Paragraph'>, Readonly<ContentModelParagraphCommon> {
1457
+ /**
1458
+ * Segments within this paragraph
1459
+ */
1460
+ readonly segments: ReadonlyArray<ReadonlyContentModelSegment>;
1461
+ /**
1462
+ * Segment format on this paragraph. This is mostly used for default format
1463
+ */
1464
+ readonly segmentFormat?: Readonly<ContentModelSegmentFormat>;
1465
+ /**
1466
+ * Decorator info for this paragraph, used by heading and P tags
1467
+ */
1468
+ readonly decorator?: ReadonlyContentModelParagraphDecorator;
1469
+ }
1470
+
1471
+ /**
1472
+ * Content Model of Paragraph (Shallow mutable)
1473
+ */
1474
+ export interface ShallowMutableContentModelParagraph extends ContentModelParagraphCommon, ContentModelBlockBase<'Paragraph'> {
1475
+ /**
1476
+ * Segments within this paragraph
1477
+ */
1478
+ segments: ShallowMutableContentModelSegment[];
1479
+ /**
1480
+ * Segment format on this paragraph. This is mostly used for default format
1481
+ */
1482
+ segmentFormat?: ContentModelSegmentFormat;
1483
+ /**
1484
+ * Decorator info for this paragraph, used by heading and P tags
1485
+ */
1486
+ decorator?: ContentModelParagraphDecorator;
1487
+ }
1488
+
1402
1489
  /**
1403
1490
  * Content Model of Table
1404
1491
  */
1405
- export interface ContentModelTable extends ContentModelBlockBase<'Table', ContentModelTableFormat>, ContentModelWithDataset<TableMetadataFormat>, ContentModelBlockWithCache<HTMLTableElement> {
1492
+ export interface ContentModelTable extends ContentModelBlockBase<'Table', ContentModelTableFormat, HTMLTableElement>, ContentModelWithDataset<TableMetadataFormat> {
1406
1493
  /**
1407
1494
  * Widths of each column
1408
1495
  */
@@ -1413,10 +1500,44 @@ export interface ContentModelTable extends ContentModelBlockBase<'Table', Conten
1413
1500
  rows: ContentModelTableRow[];
1414
1501
  }
1415
1502
 
1503
+ /**
1504
+ * Content Model of Table (Readonly)
1505
+ */
1506
+ export interface ReadonlyContentModelTable extends ReadonlyContentModelBlockBase<'Table', ContentModelTableFormat, HTMLTableElement>, ReadonlyContentModelWithDataset<TableMetadataFormat> {
1507
+ /**
1508
+ * Widths of each column
1509
+ */
1510
+ readonly widths: ReadonlyArray<number>;
1511
+ /**
1512
+ * Cells of this table
1513
+ */
1514
+ readonly rows: ReadonlyArray<ReadonlyContentModelTableRow>;
1515
+ }
1516
+
1517
+ /**
1518
+ * Content Model of Table (Shallow mutable)
1519
+ */
1520
+ export interface ShallowMutableContentModelTable extends ShallowMutableContentModelBlockBase<'Table', ContentModelTableFormat, HTMLTableElement>, ShallowMutableContentModelWithDataset<TableMetadataFormat> {
1521
+ /**
1522
+ * Widths of each column
1523
+ */
1524
+ widths: number[];
1525
+ /**
1526
+ * Cells of this table
1527
+ */
1528
+ rows: ShallowMutableContentModelTableRow[];
1529
+ }
1530
+
1416
1531
  /**
1417
1532
  * Content Model of horizontal divider
1418
1533
  */
1419
- export interface ContentModelDivider extends Selectable, ContentModelBlockWithCache, ContentModelBlockBase<'Divider', ContentModelDividerFormat> {
1534
+ export interface ContentModelDivider extends Selectable, ContentModelDividerCommon, ContentModelBlockBase<'Divider', ContentModelDividerFormat> {
1535
+ }
1536
+
1537
+ /**
1538
+ * Common part of Content Model of horizontal divider
1539
+ */
1540
+ export interface ContentModelDividerCommon {
1420
1541
  /**
1421
1542
  * Tag name of this element, either HR or DIV
1422
1543
  */
@@ -1427,14 +1548,38 @@ export interface ContentModelDivider extends Selectable, ContentModelBlockWithCa
1427
1548
  size?: string;
1428
1549
  }
1429
1550
 
1551
+ /**
1552
+ * Content Model of horizontal divider (Readonly)
1553
+ */
1554
+ export interface ReadonlyContentModelDivider extends ReadonlySelectable, ReadonlyContentModelBlockBase<'Divider', ContentModelDividerFormat>, Readonly<ContentModelDividerCommon> {
1555
+ }
1556
+
1430
1557
  /**
1431
1558
  * Base type of a block
1432
1559
  */
1433
- export interface ContentModelBlockBase<T extends ContentModelBlockType, TFormat extends ContentModelBlockFormat = ContentModelBlockFormat> extends ContentModelWithFormat<TFormat> {
1560
+ export interface ContentModelBlockBase<T extends ContentModelBlockType, TFormat extends ContentModelBlockFormat = ContentModelBlockFormat, TCacheElement extends HTMLElement = HTMLElement> extends MutableMark, ContentModelBlockBaseCommon<T>, ContentModelWithFormat<TFormat>, ContentModelBlockWithCache<TCacheElement> {
1561
+ }
1562
+
1563
+ /**
1564
+ * Common part of base type of a block
1565
+ */
1566
+ export interface ContentModelBlockBaseCommon<T extends ContentModelBlockType> {
1434
1567
  /**
1435
1568
  * Type of this block
1436
1569
  */
1437
- blockType: T;
1570
+ readonly blockType: T;
1571
+ }
1572
+
1573
+ /**
1574
+ * Base type of a block (Readonly)
1575
+ */
1576
+ export interface ReadonlyContentModelBlockBase<T extends ContentModelBlockType, TFormat extends ContentModelBlockFormat = ContentModelBlockFormat, TCacheElement extends HTMLElement = HTMLElement> extends ReadonlyMark, ContentModelBlockBaseCommon<T>, ReadonlyContentModelWithFormat<TFormat>, ContentModelBlockWithCache<TCacheElement> {
1577
+ }
1578
+
1579
+ /**
1580
+ * Base type of a block (Shallow mutable)
1581
+ */
1582
+ export interface ShallowMutableContentModelBlockBase<T extends ContentModelBlockType, TFormat extends ContentModelBlockFormat = ContentModelBlockFormat, TCacheElement extends HTMLElement = HTMLElement> extends ShallowMutableMark, ContentModelBlockBaseCommon<T>, ContentModelWithFormat<TFormat>, ContentModelBlockWithCache<TCacheElement> {
1438
1583
  }
1439
1584
 
1440
1585
  /**
@@ -1450,15 +1595,41 @@ export interface ContentModelBlockWithCache<TElement extends HTMLElement = HTMLE
1450
1595
  /**
1451
1596
  * Content Model of Table
1452
1597
  */
1453
- export interface ContentModelTableRow extends ContentModelBlockWithCache<HTMLTableRowElement>, ContentModelWithFormat<ContentModelBlockFormat> {
1598
+ export interface ContentModelTableRow extends MutableMark, ContentModelTableRowCommon, ContentModelBlockWithCache<HTMLTableRowElement>, ContentModelWithFormat<ContentModelBlockFormat> {
1599
+ /**
1600
+ * Cells of this table
1601
+ */
1602
+ cells: ContentModelTableCell[];
1603
+ }
1604
+
1605
+ /**
1606
+ * Common part of Content Model of Table
1607
+ */
1608
+ export interface ContentModelTableRowCommon {
1454
1609
  /**
1455
1610
  * Heights of each row
1456
1611
  */
1457
1612
  height: number;
1613
+ }
1614
+
1615
+ /**
1616
+ * Content Model of Table (Readonly)
1617
+ */
1618
+ export interface ReadonlyContentModelTableRow extends ReadonlyMark, Readonly<ContentModelTableRowCommon>, ContentModelBlockWithCache<HTMLTableRowElement>, ReadonlyContentModelWithFormat<ContentModelBlockFormat> {
1458
1619
  /**
1459
1620
  * Cells of this table
1460
1621
  */
1461
- cells: ContentModelTableCell[];
1622
+ readonly cells: ReadonlyArray<ReadonlyContentModelTableCell>;
1623
+ }
1624
+
1625
+ /**
1626
+ * Content Model of Table (Readonly)
1627
+ */
1628
+ export interface ShallowMutableContentModelTableRow extends ShallowMutableMark, ContentModelTableRowCommon, ContentModelBlockWithCache<HTMLTableRowElement>, ContentModelWithFormat<ContentModelBlockFormat> {
1629
+ /**
1630
+ * Cells of this table
1631
+ */
1632
+ cells: ReadonlyContentModelTableCell[];
1462
1633
  }
1463
1634
 
1464
1635
  /**
@@ -1478,31 +1649,81 @@ export interface ContentModelEntity extends ContentModelBlockBase<'Entity', Cont
1478
1649
  /**
1479
1650
  * Content Model document entry point
1480
1651
  */
1481
- export interface ContentModelDocument extends ContentModelBlockGroupBase<'Document'>, Partial<ContentModelWithFormat<ContentModelSegmentFormat>> {
1652
+ export interface ContentModelDocument extends ContentModelDocumentCommon, ContentModelBlockGroupBase<'Document'>, Partial<ContentModelWithFormat<ContentModelSegmentFormat>> {
1653
+ }
1654
+
1655
+ /**
1656
+ * Common part of Content Model document entry point
1657
+ */
1658
+ export interface ContentModelDocumentCommon {
1482
1659
  /**
1483
1660
  * Whether the selection in model (if any) is a revert selection (end is before start)
1484
1661
  */
1485
1662
  hasRevertedRangeSelection?: boolean;
1486
1663
  }
1487
1664
 
1665
+ /**
1666
+ * Content Model document entry point (Readonly)
1667
+ */
1668
+ export interface ReadonlyContentModelDocument extends Readonly<ContentModelDocumentCommon>, ReadonlyContentModelBlockGroupBase<'Document'>, Partial<ReadonlyContentModelWithFormat<ContentModelSegmentFormat>> {
1669
+ }
1670
+
1671
+ /**
1672
+ * Content Model document entry point (Shallow mutable)
1673
+ */
1674
+ export interface ShallowMutableContentModelDocument extends ContentModelDocumentCommon, ShallowMutableContentModelBlockGroupBase<'Document'>, Partial<ContentModelWithFormat<ContentModelSegmentFormat>> {
1675
+ }
1676
+
1488
1677
  /**
1489
1678
  * Base type of Content Model Block Group
1490
1679
  */
1491
- export interface ContentModelBlockGroupBase<T extends ContentModelBlockGroupType> {
1680
+ export interface ContentModelBlockGroupBase<T extends ContentModelBlockGroupType, TElement extends HTMLElement = HTMLElement> extends MutableMark, ContentModelBlockGroupBaseCommon<T, TElement> {
1681
+ /**
1682
+ * Blocks under this group
1683
+ */
1684
+ blocks: ContentModelBlock[];
1685
+ }
1686
+
1687
+ /**
1688
+ * Common part of base type of Content Model Block Group
1689
+ */
1690
+ export interface ContentModelBlockGroupBaseCommon<T extends ContentModelBlockGroupType, TElement extends HTMLElement = HTMLElement> extends ContentModelBlockWithCache<TElement> {
1492
1691
  /**
1493
1692
  * Type of this block group
1494
1693
  */
1495
- blockGroupType: T;
1694
+ readonly blockGroupType: T;
1695
+ }
1696
+
1697
+ /**
1698
+ * Base type of Content Model Block Group (Readonly)
1699
+ */
1700
+ export interface ReadonlyContentModelBlockGroupBase<T extends ContentModelBlockGroupType, TElement extends HTMLElement = HTMLElement> extends ReadonlyMark, ContentModelBlockGroupBaseCommon<T, TElement> {
1701
+ /**
1702
+ * Blocks under this group
1703
+ */
1704
+ readonly blocks: ReadonlyArray<ReadonlyContentModelBlock>;
1705
+ }
1706
+
1707
+ /**
1708
+ * Base type of Content Model Block Group (Shallow mutable)
1709
+ */
1710
+ export interface ShallowMutableContentModelBlockGroupBase<T extends ContentModelBlockGroupType, TElement extends HTMLElement = HTMLElement> extends ShallowMutableMark, ContentModelBlockGroupBaseCommon<T, TElement> {
1496
1711
  /**
1497
1712
  * Blocks under this group
1498
1713
  */
1499
- blocks: ContentModelBlock[];
1714
+ blocks: ReadonlyContentModelBlock[];
1500
1715
  }
1501
1716
 
1502
1717
  /**
1503
1718
  * Content Model of Format Container
1504
1719
  */
1505
- export interface ContentModelFormatContainer extends ContentModelBlockWithCache, ContentModelBlockGroupBase<'FormatContainer'>, ContentModelBlockBase<'BlockGroup', ContentModelFormatContainerFormat> {
1720
+ export interface ContentModelFormatContainer extends ContentModelFormatContainerCommon, ContentModelBlockGroupBase<'FormatContainer'>, ContentModelBlockBase<'BlockGroup', ContentModelFormatContainerFormat, HTMLElement> {
1721
+ }
1722
+
1723
+ /**
1724
+ * Common part of Content Model of Format Container
1725
+ */
1726
+ export interface ContentModelFormatContainerCommon {
1506
1727
  /**
1507
1728
  * Tag name of this container
1508
1729
  */
@@ -1514,20 +1735,78 @@ export interface ContentModelFormatContainer extends ContentModelBlockWithCache,
1514
1735
  zeroFontSize?: boolean;
1515
1736
  }
1516
1737
 
1738
+ /**
1739
+ * Content Model of Format Container (Readonly)
1740
+ */
1741
+ export interface ReadonlyContentModelFormatContainer extends Readonly<ContentModelFormatContainerCommon>, ReadonlyContentModelBlockGroupBase<'FormatContainer'>, ReadonlyContentModelBlockBase<'BlockGroup', ContentModelFormatContainerFormat, HTMLElement> {
1742
+ }
1743
+
1744
+ /**
1745
+ * Content Model of Format Container (Shallow mutable)
1746
+ */
1747
+ export interface ShallowMutableContentModelFormatContainer extends ContentModelFormatContainerCommon, ShallowMutableContentModelBlockGroupBase<'FormatContainer'>, ShallowMutableContentModelBlockBase<'BlockGroup', ContentModelFormatContainerFormat, HTMLElement> {
1748
+ }
1749
+
1517
1750
  /**
1518
1751
  * Content Model for general Block element
1519
1752
  */
1520
- export interface ContentModelGeneralBlock extends Selectable, ContentModelBlockGroupBase<'General'>, ContentModelBlockBase<'BlockGroup', ContentModelBlockFormat & ContentModelSegmentFormat> {
1753
+ export interface ContentModelGeneralBlock extends Selectable, ContentModelGeneralBlockCommon, ContentModelBlockGroupBase<'General'>, ContentModelBlockBase<'BlockGroup', ContentModelBlockFormat & ContentModelSegmentFormat> {
1754
+ }
1755
+
1756
+ /**
1757
+ * Common part of Content Model for general Block element
1758
+ */
1759
+ export interface ContentModelGeneralBlockCommon {
1521
1760
  /**
1522
1761
  * A reference to original HTML node that this model was created from
1523
1762
  */
1524
1763
  element: HTMLElement;
1525
1764
  }
1526
1765
 
1766
+ /**
1767
+ * Content Model for general Block element (Readonly)
1768
+ */
1769
+ export interface ReadonlyContentModelGeneralBlock extends ReadonlySelectable, Readonly<ContentModelGeneralBlockCommon>, ReadonlyContentModelBlockGroupBase<'General'>, ReadonlyContentModelBlockBase<'BlockGroup', ContentModelBlockFormat & ContentModelSegmentFormat> {
1770
+ }
1771
+
1772
+ /**
1773
+ * Content Model for general Block element (Shallow mutable)
1774
+ */
1775
+ export interface ShallowMutableContentModelGeneralBlock extends ShallowMutableSelectable, ContentModelGeneralBlockCommon, ShallowMutableContentModelBlockGroupBase<'General'>, ShallowMutableContentModelBlockBase<'BlockGroup', ContentModelBlockFormat & ContentModelSegmentFormat> {
1776
+ }
1777
+
1527
1778
  /**
1528
1779
  * Content Model of List Item
1529
1780
  */
1530
- export interface ContentModelListItem extends ContentModelBlockGroupBase<'ListItem'>, ContentModelBlockBase<'BlockGroup', ContentModelListItemFormat> {
1781
+ export interface ContentModelListItem extends ContentModelBlockGroupBase<'ListItem', HTMLLIElement>, ContentModelBlockBase<'BlockGroup', ContentModelListItemFormat, HTMLLIElement> {
1782
+ /**
1783
+ * Type of this list, either ordered or unordered
1784
+ */
1785
+ levels: ContentModelListLevel[];
1786
+ /**
1787
+ * A dummy segment to hold format of this list item
1788
+ */
1789
+ formatHolder: ContentModelSelectionMarker;
1790
+ }
1791
+
1792
+ /**
1793
+ * Content Model of List Item (Readonly)
1794
+ */
1795
+ export interface ReadonlyContentModelListItem extends ReadonlyContentModelBlockGroupBase<'ListItem', HTMLLIElement>, ReadonlyContentModelBlockBase<'BlockGroup', ContentModelListItemFormat, HTMLLIElement> {
1796
+ /**
1797
+ * Type of this list, either ordered or unordered
1798
+ */
1799
+ readonly levels: ReadonlyArray<ReadonlyContentModelListLevel>;
1800
+ /**
1801
+ * A dummy segment to hold format of this list item
1802
+ */
1803
+ readonly formatHolder: ReadonlyContentModelSelectionMarker;
1804
+ }
1805
+
1806
+ /**
1807
+ * Content Model of List Item (Shallow mutable)
1808
+ */
1809
+ export interface ShallowMutableContentModelListItem extends ShallowMutableContentModelBlockGroupBase<'ListItem', HTMLLIElement>, ShallowMutableContentModelBlockBase<'BlockGroup', ContentModelListItemFormat, HTMLLIElement> {
1531
1810
  /**
1532
1811
  * Type of this list, either ordered or unordered
1533
1812
  */
@@ -1541,7 +1820,13 @@ export interface ContentModelListItem extends ContentModelBlockGroupBase<'ListIt
1541
1820
  /**
1542
1821
  * Content Model of Table Cell
1543
1822
  */
1544
- export interface ContentModelTableCell extends Selectable, ContentModelBlockGroupBase<'TableCell'>, ContentModelWithFormat<ContentModelTableCellFormat>, ContentModelWithDataset<TableCellMetadataFormat>, ContentModelBlockWithCache<HTMLTableCellElement> {
1823
+ export interface ContentModelTableCell extends Selectable, ContentModelTableCellCommon, ContentModelBlockGroupBase<'TableCell', HTMLTableCellElement>, ContentModelWithFormat<ContentModelTableCellFormat>, ContentModelWithDataset<TableCellMetadataFormat> {
1824
+ }
1825
+
1826
+ /**
1827
+ * Common part of Content Model of Table Cell
1828
+ */
1829
+ export interface ContentModelTableCellCommon {
1545
1830
  /**
1546
1831
  * Whether this cell is spanned from left cell
1547
1832
  */
@@ -1556,27 +1841,73 @@ export interface ContentModelTableCell extends Selectable, ContentModelBlockGrou
1556
1841
  isHeader?: boolean;
1557
1842
  }
1558
1843
 
1844
+ /**
1845
+ * Content Model of Table Cell (Readonly)
1846
+ */
1847
+ export interface ReadonlyContentModelTableCell extends ReadonlySelectable, Readonly<ContentModelTableCellCommon>, ReadonlyContentModelBlockGroupBase<'TableCell', HTMLTableCellElement>, ReadonlyContentModelWithFormat<ContentModelTableCellFormat>, ReadonlyContentModelWithDataset<TableCellMetadataFormat> {
1848
+ }
1849
+
1850
+ /**
1851
+ * Content Model of Table Cell (Shallow mutable)
1852
+ */
1853
+ export interface ShallowMutableContentModelTableCell extends ShallowMutableSelectable, ContentModelTableCellCommon, ShallowMutableContentModelBlockGroupBase<'TableCell', HTMLTableCellElement>, ContentModelWithFormat<ContentModelTableCellFormat>, ShallowMutableContentModelWithDataset<TableCellMetadataFormat> {
1854
+ }
1855
+
1559
1856
  /**
1560
1857
  * The union type of Content Model Block Group
1561
1858
  */
1562
1859
  export type ContentModelBlockGroup = ContentModelDocument | ContentModelFormatContainer | ContentModelListItem | ContentModelTableCell | ContentModelGeneralBlock;
1563
1860
 
1861
+ /**
1862
+ * The union type of Content Model Block Group (Readonly)
1863
+ */
1864
+ export type ReadonlyContentModelBlockGroup = ReadonlyContentModelDocument | ReadonlyContentModelFormatContainer | ReadonlyContentModelListItem | ReadonlyContentModelTableCell | ReadonlyContentModelGeneralBlock;
1865
+
1866
+ /**
1867
+ * The union type of Content Model Block Group (Shallow mutable)
1868
+ */
1869
+ export type ShallowMutableContentModelBlockGroup = ShallowMutableContentModelDocument | ShallowMutableContentModelFormatContainer | ShallowMutableContentModelListItem | ShallowMutableContentModelTableCell | ShallowMutableContentModelGeneralBlock;
1870
+
1564
1871
  /**
1565
1872
  * Content Model of BR
1566
1873
  */
1567
1874
  export interface ContentModelBr extends ContentModelSegmentBase<'Br'> {
1568
1875
  }
1569
1876
 
1877
+ /**
1878
+ * Content Model of BR (Readonly)
1879
+ */
1880
+ export interface ReadonlyContentModelBr extends ReadonlyContentModelSegmentBase<'Br'> {
1881
+ }
1882
+
1570
1883
  /**
1571
1884
  * Content Model of general Segment
1572
1885
  */
1573
1886
  export interface ContentModelGeneralSegment extends ContentModelGeneralBlock, ContentModelSegmentBase<'General', ContentModelBlockFormat & ContentModelSegmentFormat> {
1574
1887
  }
1575
1888
 
1889
+ /**
1890
+ * Content Model of general Segment (Readonly)
1891
+ */
1892
+ export interface ReadonlyContentModelGeneralSegment extends ReadonlyContentModelGeneralBlock, ReadonlyContentModelSegmentBase<'General', ContentModelBlockFormat & ContentModelSegmentFormat> {
1893
+ }
1894
+
1895
+ /**
1896
+ * Content Model of general Segment (Shallow mutable)
1897
+ */
1898
+ export interface ShallowMutableContentModelGeneralSegment extends ShallowMutableContentModelGeneralBlock, ShallowMutableContentModelSegmentBase<'General', ContentModelBlockFormat & ContentModelSegmentFormat> {
1899
+ }
1900
+
1576
1901
  /**
1577
1902
  * Content Model of IMG
1578
1903
  */
1579
- export interface ContentModelImage extends ContentModelSegmentBase<'Image', ContentModelImageFormat>, ContentModelWithDataset<ImageMetadataFormat> {
1904
+ export interface ContentModelImage extends ContentModelImageCommon, ContentModelSegmentBase<'Image', ContentModelImageFormat>, ContentModelWithDataset<ImageMetadataFormat> {
1905
+ }
1906
+
1907
+ /**
1908
+ * Common part of Content Model of IMG
1909
+ */
1910
+ export interface ContentModelImageCommon {
1580
1911
  /**
1581
1912
  * Image source of this IMG element
1582
1913
  */
@@ -1595,30 +1926,88 @@ export interface ContentModelImage extends ContentModelSegmentBase<'Image', Cont
1595
1926
  isSelectedAsImageSelection?: boolean;
1596
1927
  }
1597
1928
 
1929
+ /**
1930
+ * Content Model of IMG (Readonly)
1931
+ */
1932
+ export interface ReadonlyContentModelImage extends ReadonlyContentModelSegmentBase<'Image', ContentModelImageFormat>, ReadonlyContentModelWithDataset<ImageMetadataFormat>, Readonly<ContentModelImageCommon> {
1933
+ }
1934
+
1598
1935
  /**
1599
1936
  * Content Model for Text
1600
1937
  */
1601
- export interface ContentModelText extends ContentModelSegmentBase<'Text'> {
1938
+ export interface ContentModelText extends ContentModelTextCommon, ContentModelSegmentBase<'Text'> {
1939
+ }
1940
+
1941
+ /**
1942
+ * Common port of Content Model for Text
1943
+ */
1944
+ export interface ContentModelTextCommon {
1945
+ /**
1946
+ * Text content of this segment
1947
+ */
1948
+ text: string;
1949
+ }
1950
+
1951
+ /**
1952
+ * Content Model for Text (Readonly)
1953
+ */
1954
+ export interface ReadonlyContentModelText extends ReadonlyContentModelSegmentBase<'Text'>, Readonly<ContentModelTextCommon> {
1955
+ }
1956
+
1957
+ /**
1958
+ * Content Model of Selection Marker
1959
+ */
1960
+ export interface ContentModelSelectionMarker extends ContentModelSegmentBase<'SelectionMarker'> {
1961
+ }
1962
+
1963
+ /**
1964
+ * Content Model of Selection Marker (Readonly)
1965
+ */
1966
+ export interface ReadonlyContentModelSelectionMarker extends ReadonlyContentModelSegmentBase<'SelectionMarker'> {
1967
+ }
1968
+
1969
+ /**
1970
+ * Base type of Content Model Segment
1971
+ */
1972
+ export interface ContentModelSegmentBase<T extends ContentModelSegmentType, TFormat extends ContentModelSegmentFormat = ContentModelSegmentFormat> extends MutableMark, Selectable, ContentModelWithFormat<TFormat>, ContentModelSegmentBaseCommon<T> {
1973
+ /**
1974
+ * Hyperlink info
1975
+ */
1976
+ link?: ContentModelLink;
1977
+ /**
1978
+ * Code info
1979
+ */
1980
+ code?: ContentModelCode;
1981
+ }
1982
+
1983
+ /**
1984
+ * Common part of base type of Content Model Segment
1985
+ */
1986
+ export interface ContentModelSegmentBaseCommon<T extends ContentModelSegmentType> {
1602
1987
  /**
1603
- * Text content of this segment
1988
+ * Type of this segment
1604
1989
  */
1605
- text: string;
1990
+ readonly segmentType: T;
1606
1991
  }
1607
1992
 
1608
1993
  /**
1609
- * Content Model of Selection Marker
1994
+ * Base type of Content Model Segment (Readonly)
1610
1995
  */
1611
- export interface ContentModelSelectionMarker extends ContentModelSegmentBase<'SelectionMarker'> {
1996
+ export interface ReadonlyContentModelSegmentBase<T extends ContentModelSegmentType, TFormat extends ContentModelSegmentFormat = ContentModelSegmentFormat> extends ReadonlyMark, ReadonlySelectable, ReadonlyContentModelWithFormat<TFormat>, Readonly<ContentModelSegmentBaseCommon<T>> {
1997
+ /**
1998
+ * Hyperlink info
1999
+ */
2000
+ readonly link?: ReadonlyContentModelLink;
2001
+ /**
2002
+ * Code info
2003
+ */
2004
+ readonly code?: ReadonlyContentModelCode;
1612
2005
  }
1613
2006
 
1614
2007
  /**
1615
- * Base type of Content Model Segment
2008
+ * Base type of Content Model Segment (Shallow mutable)
1616
2009
  */
1617
- export interface ContentModelSegmentBase<T extends ContentModelSegmentType, TFormat extends ContentModelSegmentFormat = ContentModelSegmentFormat> extends Selectable, ContentModelWithFormat<TFormat> {
1618
- /**
1619
- * Type of this segment
1620
- */
1621
- segmentType: T;
2010
+ export interface ShallowMutableContentModelSegmentBase<T extends ContentModelSegmentType, TFormat extends ContentModelSegmentFormat = ContentModelSegmentFormat> extends ShallowMutableMark, ShallowMutableSelectable, ContentModelWithFormat<TFormat>, ContentModelSegmentBaseCommon<T> {
1622
2011
  /**
1623
2012
  * Hyperlink info
1624
2013
  */
@@ -1634,12 +2023,30 @@ export interface ContentModelSegmentBase<T extends ContentModelSegmentType, TFor
1634
2023
  */
1635
2024
  export type ContentModelSegment = ContentModelSelectionMarker | ContentModelText | ContentModelBr | ContentModelGeneralSegment | ContentModelEntity | ContentModelImage;
1636
2025
 
2026
+ /**
2027
+ * Union type of Content Model Segment (Readonly)
2028
+ */
2029
+ export type ReadonlyContentModelSegment = ReadonlyContentModelSelectionMarker | ReadonlyContentModelText | ReadonlyContentModelBr | ReadonlyContentModelGeneralSegment | ContentModelEntity | ReadonlyContentModelImage;
2030
+
2031
+ /**
2032
+ * Union type of Content Model Segment (Shallow mutable)
2033
+ */
2034
+ export type ShallowMutableContentModelSegment = ContentModelSelectionMarker | ContentModelText | ContentModelBr | ShallowMutableContentModelGeneralSegment | ContentModelEntity | ContentModelImage;
2035
+
1637
2036
  /**
1638
2037
  * Represent code info of Content Model.
1639
2038
  * ContentModelCode is a decorator but not a standalone model type, instead it need to be put inside a ContentModelSegment
1640
2039
  * since code is also a kind of segment, with some extra information
1641
2040
  */
1642
- export interface ContentModelCode extends ContentModelWithFormat<ContentModelCodeFormat> {
2041
+ export interface ContentModelCode extends MutableMark, ContentModelWithFormat<ContentModelCodeFormat> {
2042
+ }
2043
+
2044
+ /**
2045
+ * Represent code info of Content Model. (Readonly)
2046
+ * ContentModelCode is a decorator but not a standalone model type, instead it need to be put inside a ContentModelSegment
2047
+ * since code is also a kind of segment, with some extra information
2048
+ */
2049
+ export interface ReadonlyContentModelCode extends ReadonlyMark, ReadonlyContentModelWithFormat<ContentModelCodeFormat> {
1643
2050
  }
1644
2051
 
1645
2052
  /**
@@ -1647,7 +2054,15 @@ export interface ContentModelCode extends ContentModelWithFormat<ContentModelCod
1647
2054
  * ContentModelLink is not a standalone model type, instead it need to be put inside a ContentModelSegment
1648
2055
  * since link is also a kind of segment, with some extra information
1649
2056
  */
1650
- export interface ContentModelLink extends ContentModelWithFormat<ContentModelHyperLinkFormat>, ContentModelWithDataset<null> {
2057
+ export interface ContentModelLink extends MutableMark, ContentModelWithFormat<ContentModelHyperLinkFormat>, ContentModelWithDataset<null> {
2058
+ }
2059
+
2060
+ /**
2061
+ * Represent link info of Content Model (Readonly).
2062
+ * ContentModelLink is not a standalone model type, instead it need to be put inside a ContentModelSegment
2063
+ * since link is also a kind of segment, with some extra information
2064
+ */
2065
+ export interface ReadonlyContentModelLink extends ReadonlyMark, ReadonlyContentModelWithFormat<ContentModelHyperLinkFormat>, ReadonlyContentModelWithDataset<null> {
1651
2066
  }
1652
2067
 
1653
2068
  /**
@@ -1655,38 +2070,144 @@ export interface ContentModelLink extends ContentModelWithFormat<ContentModelHyp
1655
2070
  * A decorator of paragraph can represent a heading, or a P tag that act likes a paragraph but with some extra format info
1656
2071
  * since heading is also a kind of paragraph, with some extra information
1657
2072
  */
1658
- export interface ContentModelParagraphDecorator extends ContentModelWithFormat<ContentModelSegmentFormat> {
2073
+ export interface ContentModelParagraphDecorator extends MutableMark, ContentModelParagraphDecoratorCommon, ContentModelWithFormat<ContentModelSegmentFormat> {
2074
+ }
2075
+
2076
+ /**
2077
+ * Common part of decorator for a paragraph in Content Model
2078
+ */
2079
+ export interface ContentModelParagraphDecoratorCommon {
1659
2080
  /**
1660
2081
  * Tag name of this paragraph
1661
2082
  */
1662
2083
  tagName: string;
1663
2084
  }
1664
2085
 
2086
+ /**
2087
+ * Represent decorator for a paragraph in Content Model (Readonly)
2088
+ * A decorator of paragraph can represent a heading, or a P tag that act likes a paragraph but with some extra format info
2089
+ * since heading is also a kind of paragraph, with some extra information
2090
+ */
2091
+ export interface ReadonlyContentModelParagraphDecorator extends ReadonlyMark, ReadonlyContentModelWithFormat<ContentModelSegmentFormat>, Readonly<ContentModelParagraphDecoratorCommon> {
2092
+ }
2093
+
1665
2094
  /**
1666
2095
  * Union type for segment decorators
1667
2096
  */
1668
2097
  export type ContentModelDecorator = ContentModelLink | ContentModelCode | ContentModelListLevel;
1669
2098
 
2099
+ /**
2100
+ * Union type for segment decorators (Readonly)
2101
+ */
2102
+ export type ReadonlyContentModelDecorator = ReadonlyContentModelLink | ReadonlyContentModelCode | ReadonlyContentModelListLevel;
2103
+
1670
2104
  /**
1671
2105
  * Content Model of List Level
1672
2106
  */
1673
- export interface ContentModelListLevel extends ContentModelWithFormat<ContentModelListItemLevelFormat>, ContentModelWithDataset<ListMetadataFormat> {
2107
+ export interface ContentModelListLevel extends MutableMark, ContentModelBlockWithCache<HTMLOListElement | HTMLUListElement>, ContentModelListLevelCommon, ContentModelWithFormat<ContentModelListItemLevelFormat>, ContentModelWithDataset<ListMetadataFormat> {
2108
+ }
2109
+
2110
+ /**
2111
+ * Common part of Content Model of List Level
2112
+ */
2113
+ export interface ContentModelListLevelCommon {
1674
2114
  /**
1675
2115
  * Type of a list, order (OL) or unordered (UL)
1676
2116
  */
1677
2117
  listType: 'OL' | 'UL';
1678
2118
  }
1679
2119
 
2120
+ /**
2121
+ * Content Model of List Level (Readonly)
2122
+ */
2123
+ export interface ReadonlyContentModelListLevel extends ReadonlyMark, ContentModelBlockWithCache<HTMLOListElement | HTMLUListElement>, ReadonlyContentModelWithFormat<ContentModelListItemLevelFormat>, ReadonlyContentModelWithDataset<ListMetadataFormat>, Readonly<ContentModelListLevelCommon> {
2124
+ }
2125
+
1680
2126
  /**
1681
2127
  * Represents a selectable Content Model object
1682
2128
  */
1683
- export interface Selectable {
2129
+ export interface Selectable extends MutableMark {
2130
+ /**
2131
+ * Whether this model object is selected
2132
+ */
2133
+ isSelected?: boolean;
2134
+ }
2135
+
2136
+ /**
2137
+ * Represents a selectable Content Model object (Readonly)
2138
+ */
2139
+ export interface ReadonlySelectable extends ReadonlyMark {
2140
+ /**
2141
+ * Whether this model object is selected
2142
+ */
2143
+ readonly isSelected?: boolean;
2144
+ }
2145
+
2146
+ /**
2147
+ * Represents a selectable Content Model object (Shallow mutable)
2148
+ */
2149
+ export interface ShallowMutableSelectable extends ShallowMutableMark {
1684
2150
  /**
1685
2151
  * Whether this model object is selected
1686
2152
  */
1687
2153
  isSelected?: boolean;
1688
2154
  }
1689
2155
 
2156
+ /**
2157
+ * Mark an object as mutable
2158
+ */
2159
+ export type MutableMark = {
2160
+ /**
2161
+ * The mutable marker to mark an object as mutable. When assign readonly object to a mutable type, compile will fail to build
2162
+ * due to this member does not exist from source type.
2163
+ */
2164
+ readonly dummy1?: never[];
2165
+ /**
2166
+ * The mutable marker to mark an object as mutable. When assign readonly object to a mutable type, compile will fail to build
2167
+ * due to this member does not exist from source type.
2168
+ */
2169
+ readonly dummy2?: never[];
2170
+ };
2171
+
2172
+ /**
2173
+ * Mark an object as single level mutable (child models are still readonly)
2174
+ */
2175
+ export type ShallowMutableMark = {
2176
+ /**
2177
+ * The mutable marker to mark an object as mutable. When assign readonly object to a mutable type, compile will fail to build
2178
+ * due to this member does not exist from source type.
2179
+ */
2180
+ readonly dummy1?: never[];
2181
+ /**
2182
+ * The mutable marker to mark an object as mutable. When assign readonly object to a mutable type, compile will fail to build
2183
+ * due to this member does not exist from source type.
2184
+ * This is used for preventing assigning ShallowMutableMark to MutableMark
2185
+ */
2186
+ readonly dummy2?: ReadonlyArray<never>;
2187
+ };
2188
+
2189
+ /**
2190
+ * Mark an object as readonly
2191
+ */
2192
+ export type ReadonlyMark = {
2193
+ /**
2194
+ * The mutable marker to mark an object as mutable. When assign readonly object to a mutable type, compile will fail to build
2195
+ * due to this member does not exist from source type.
2196
+ * This is used for preventing assigning ReadonlyMark to ShallowMutableMark or MutableMark
2197
+ */
2198
+ readonly dummy1?: ReadonlyArray<never>;
2199
+ /**
2200
+ * The mutable marker to mark an object as mutable. When assign readonly object to a mutable type, compile will fail to build
2201
+ * due to this member does not exist from source type.
2202
+ */
2203
+ readonly dummy2?: ReadonlyArray<never>;
2204
+ };
2205
+
2206
+ /**
2207
+ * Get mutable type from its related readonly type
2208
+ */
2209
+ export type MutableType<T> = T extends ReadonlyContentModelGeneralSegment ? ShallowMutableContentModelGeneralSegment : T extends ReadonlyContentModelSelectionMarker ? ContentModelSelectionMarker : T extends ReadonlyContentModelImage ? ContentModelImage : T extends ContentModelEntity ? ContentModelEntity : T extends ReadonlyContentModelText ? ContentModelText : T extends ReadonlyContentModelBr ? ContentModelBr : T extends ReadonlyContentModelParagraph ? ShallowMutableContentModelParagraph : T extends ReadonlyContentModelTable ? ShallowMutableContentModelTable : T extends ReadonlyContentModelTableRow ? ContentModelTableRow : T extends ReadonlyContentModelTableCell ? ShallowMutableContentModelTableCell : T extends ReadonlyContentModelFormatContainer ? ShallowMutableContentModelFormatContainer : T extends ReadonlyContentModelListItem ? ShallowMutableContentModelListItem : T extends ReadonlyContentModelListLevel ? ContentModelListLevel : T extends ReadonlyContentModelDivider ? ContentModelDivider : T extends ReadonlyContentModelDocument ? ShallowMutableContentModelDocument : T extends ReadonlyContentModelGeneralBlock ? ShallowMutableContentModelGeneralBlock : T extends ReadonlyContentModelParagraphDecorator ? ContentModelParagraphDecorator : T extends ReadonlyContentModelLink ? ContentModelLink : T extends ReadonlyContentModelCode ? ContentModelCode : never;
2210
+
1690
2211
  /**
1691
2212
  * The union type of 3 selection types
1692
2213
  */
@@ -1774,15 +2295,15 @@ export interface InsertPoint {
1774
2295
  /**
1775
2296
  * The paragraph that contains this insert point
1776
2297
  */
1777
- paragraph: ContentModelParagraph;
2298
+ paragraph: ShallowMutableContentModelParagraph;
1778
2299
  /**
1779
2300
  * Block group path of this insert point, from direct parent group to the root group
1780
2301
  */
1781
- path: ContentModelBlockGroup[];
2302
+ path: ReadonlyContentModelBlockGroup[];
1782
2303
  /**
1783
2304
  * Table context of this insert point
1784
2305
  */
1785
- tableContext?: TableSelectionContext;
2306
+ tableContext?: ReadonlyTableSelectionContext;
1786
2307
  }
1787
2308
 
1788
2309
  /**
@@ -1807,6 +2328,28 @@ export interface TableSelectionContext {
1807
2328
  isWholeTableSelected: boolean;
1808
2329
  }
1809
2330
 
2331
+ /**
2332
+ * Context object for table in a selection (Readonly)
2333
+ */
2334
+ export interface ReadonlyTableSelectionContext {
2335
+ /**
2336
+ * The table that contains the selection
2337
+ */
2338
+ table: ReadonlyContentModelTable;
2339
+ /**
2340
+ * Row Index of the selected table cell
2341
+ */
2342
+ rowIndex: number;
2343
+ /**
2344
+ * Column Index of the selected table cell
2345
+ */
2346
+ colIndex: number;
2347
+ /**
2348
+ * Whether the whole table is selected
2349
+ */
2350
+ isWholeTableSelected: boolean;
2351
+ }
2352
+
1810
2353
  /**
1811
2354
  * Coordinates of table selection
1812
2355
  */
@@ -2940,6 +3483,10 @@ export interface EditorOptions {
2940
3483
  * Color of the border of a selectedImage. Default color: '#DB626C'
2941
3484
  */
2942
3485
  imageSelectionBorderColor?: string;
3486
+ /**
3487
+ * Background color of a selected table cell. Default color: '#C6C6C6'
3488
+ */
3489
+ tableCellSelectionBackgroundColor?: string;
2943
3490
  /**
2944
3491
  * Initial Content Model
2945
3492
  */
@@ -3573,6 +4120,18 @@ export interface SelectionPluginState {
3573
4120
  * Color of the border of a selectedImage. Default color: '#DB626C'
3574
4121
  */
3575
4122
  imageSelectionBorderColor?: string;
4123
+ /**
4124
+ * Color of the border of a selectedImage in dark mode. Default color: '#DB626C'
4125
+ */
4126
+ imageSelectionBorderColorDark?: string;
4127
+ /**
4128
+ * Background color of a selected table cell. Default color: '#C6C6C6'
4129
+ */
4130
+ tableCellSelectionBackgroundColor?: string;
4131
+ /**
4132
+ * Background color of a selected table cell in dark mode. Default color: '#C6C6C6'
4133
+ */
4134
+ tableCellSelectionBackgroundColorDark?: string;
3576
4135
  }
3577
4136
 
3578
4137
  /**
@@ -4088,11 +4647,11 @@ export interface DeleteSelectionContext extends DeleteSelectionResult {
4088
4647
  /**
4089
4648
  * Last paragraph after previous step
4090
4649
  */
4091
- lastParagraph?: ContentModelParagraph;
4650
+ lastParagraph?: ShallowMutableContentModelParagraph;
4092
4651
  /**
4093
4652
  * Last table context after previous step
4094
4653
  */
4095
- lastTableContext?: TableSelectionContext;
4654
+ lastTableContext?: ReadonlyTableSelectionContext;
4096
4655
  /**
4097
4656
  * Format context provided by formatContentModel API
4098
4657
  */
@@ -4691,6 +5250,16 @@ export interface IterateSelectionsOption {
4691
5250
  includeListFormatHolder?: 'anySegment' | 'allSegments' | 'never';
4692
5251
  }
4693
5252
 
5253
+ /**
5254
+ * The callback function type for iterateSelections (Readonly)
5255
+ * @param path The block group path of current selection
5256
+ * @param tableContext Table context of current selection
5257
+ * @param block Block of current selection
5258
+ * @param segments Segments of current selection
5259
+ * @returns True to stop iterating, otherwise keep going
5260
+ */
5261
+ export type ReadonlyIterateSelectionsCallback = (path: ReadonlyContentModelBlockGroup[], tableContext?: ReadonlyTableSelectionContext, block?: ReadonlyContentModelBlock, segments?: ReadonlyContentModelSegment[]) => void | boolean;
5262
+
4694
5263
  /**
4695
5264
  * A type map from node type number to its type declaration. This is used by utility function isNodeOfType()
4696
5265
  */
@@ -4732,7 +5301,7 @@ export interface NodeTypeMap {
4732
5301
  /**
4733
5302
  * Retrieve block group type string from a given block group
4734
5303
  */
4735
- export type TypeOfBlockGroup<T extends ContentModelBlockGroup> = T extends ContentModelBlockGroupBase<infer U> ? U : never;
5304
+ export type TypeOfBlockGroup<T extends ContentModelBlockGroup | ReadonlyContentModelBlockGroup> = T extends ContentModelBlockGroupBase<infer U> | ReadonlyContentModelBlockGroupBase<infer U> ? U : never;
4736
5305
 
4737
5306
  /**
4738
5307
  * Represent a pair of parent block group and child block
@@ -4752,6 +5321,24 @@ export type OperationalBlocks<T extends ContentModelBlockGroup> = {
4752
5321
  path: ContentModelBlockGroup[];
4753
5322
  };
4754
5323
 
5324
+ /**
5325
+ * Represent a pair of parent block group and child block (Readonly)
5326
+ */
5327
+ export type ReadonlyOperationalBlocks<T extends ReadonlyContentModelBlockGroup> = {
5328
+ /**
5329
+ * The parent block group
5330
+ */
5331
+ parent: ReadonlyContentModelBlockGroup;
5332
+ /**
5333
+ * The child block
5334
+ */
5335
+ block: ReadonlyContentModelBlock | T;
5336
+ /**
5337
+ * Selection path of this block
5338
+ */
5339
+ path: ReadonlyContentModelBlockGroup[];
5340
+ };
5341
+
4755
5342
  /**
4756
5343
  * Represents a parsed table with its table cells
4757
5344
  */
@@ -5471,13 +6058,21 @@ export function buildSelectionMarker(group: ContentModelBlockGroup, context: Dom
5471
6058
  * @param definition @optional Metadata definition used for verify the metadata object
5472
6059
  * @returns The metadata object if any, or null
5473
6060
  */
5474
- export function updateMetadata<T>(model: ContentModelWithDataset<T>, callback?: (metadata: T | null) => T | null, definition?: Definition<T>): T | null;
6061
+ export function updateMetadata<T>(model: ShallowMutableContentModelWithDataset<T>, callback?: (metadata: T | null) => T | null, definition?: Definition<T>): T | null;
6062
+
6063
+ /**
6064
+ * Retrieve metadata from the given model.
6065
+ * @param model The Content Model to retrieve metadata from
6066
+ * @param definition Definition of this metadata type, used for validate the metadata object
6067
+ * @returns Metadata of the model, or null if it does not contain a valid metadata
6068
+ */
6069
+ export function getMetadata<T>(model: ReadonlyContentModelWithDataset<T>, definition?: Definition<T>): T | null;
5475
6070
 
5476
6071
  /**
5477
6072
  * Check if the given model has metadata
5478
6073
  * @param model The content model to check
5479
6074
  */
5480
- export function hasMetadata<T>(model: ContentModelWithDataset<T> | HTMLElement): boolean;
6075
+ export function hasMetadata<T>(model: ReadonlyContentModelWithDataset<T> | HTMLElement): boolean;
5481
6076
 
5482
6077
  /**
5483
6078
  * Type checker for Node. Return true if it of the specified node type
@@ -5651,21 +6246,21 @@ export function normalizeRect(clientRect: DOMRect): Rect | null;
5651
6246
  * Create a ContentModelBr model
5652
6247
  * @param format @optional The format of this model
5653
6248
  */
5654
- export function createBr(format?: ContentModelSegmentFormat): ContentModelBr;
6249
+ export function createBr(format?: Readonly<ContentModelSegmentFormat>): ContentModelBr;
5655
6250
 
5656
6251
  /**
5657
6252
  * Create a ContentModelListItem model
5658
6253
  * @param levels Existing list levels
5659
6254
  * @param format @optional The format of this model
5660
6255
  */
5661
- export function createListItem(levels: ContentModelListLevel[], format?: ContentModelSegmentFormat): ContentModelListItem;
6256
+ export function createListItem(levels: ReadonlyArray<ReadonlyContentModelListLevel>, format?: Readonly<ContentModelSegmentFormat>): ContentModelListItem;
5662
6257
 
5663
6258
  /**
5664
6259
  * Create a ContentModelFormatContainer model
5665
6260
  * @param tag Tag name of this format container, in lower case
5666
6261
  * @param format @optional The format of this model
5667
6262
  */
5668
- export function createFormatContainer(tag: Lowercase<string>, format?: ContentModelFormatContainerFormat): ContentModelFormatContainer;
6263
+ export function createFormatContainer(tag: Lowercase<string>, format?: Readonly<ContentModelFormatContainerFormat>): ContentModelFormatContainer;
5669
6264
 
5670
6265
  /**
5671
6266
  * Create a ContentModelParagraph model
@@ -5674,20 +6269,20 @@ export function createFormatContainer(tag: Lowercase<string>, format?: ContentMo
5674
6269
  * @param segmentFormat @optional Segment format applied to this block
5675
6270
  * @param decorator @optional Decorator of this paragraph
5676
6271
  */
5677
- export function createParagraph(isImplicit?: boolean, blockFormat?: ContentModelBlockFormat, segmentFormat?: ContentModelSegmentFormat, decorator?: ContentModelParagraphDecorator): ContentModelParagraph;
6272
+ export function createParagraph(isImplicit?: boolean, blockFormat?: Readonly<ContentModelBlockFormat>, segmentFormat?: Readonly<ContentModelSegmentFormat>, decorator?: ReadonlyContentModelParagraphDecorator): ContentModelParagraph;
5678
6273
 
5679
6274
  /**
5680
6275
  * Create a ContentModelSelectionMarker model
5681
6276
  * @param format @optional The format of this model
5682
6277
  */
5683
- export function createSelectionMarker(format?: ContentModelSegmentFormat): ContentModelSelectionMarker;
6278
+ export function createSelectionMarker(format?: Readonly<ContentModelSegmentFormat>): ContentModelSelectionMarker;
5684
6279
 
5685
6280
  /**
5686
6281
  * Create a ContentModelTable model
5687
6282
  * @param rowCount Count of rows of this table
5688
6283
  * @param format @optional The format of this model
5689
6284
  */
5690
- export function createTable(rowCount: number, format?: ContentModelTableFormat): ContentModelTable;
6285
+ export function createTable(rowCount: number, format?: Readonly<ContentModelTableFormat>): ContentModelTable;
5691
6286
 
5692
6287
  /**
5693
6288
  * Create a ContentModelTableCell model
@@ -5696,7 +6291,7 @@ export function createTable(rowCount: number, format?: ContentModelTableFormat):
5696
6291
  * @param isHeader @optional Whether this is a header cell @default false
5697
6292
  * @param format @optional The format of this model
5698
6293
  */
5699
- export function createTableCell(spanLeftOrColSpan?: boolean | number, spanAboveOrRowSpan?: boolean | number, isHeader?: boolean, format?: ContentModelTableCellFormat, dataset?: DatasetFormat): ContentModelTableCell;
6294
+ export function createTableCell(spanLeftOrColSpan?: boolean | number, spanAboveOrRowSpan?: boolean | number, isHeader?: boolean, format?: Readonly<ContentModelTableCellFormat>, dataset?: ReadonlyDatasetFormat): ContentModelTableCell;
5700
6295
 
5701
6296
  /**
5702
6297
  * Create a ContentModelText model
@@ -5705,34 +6300,34 @@ export function createTableCell(spanLeftOrColSpan?: boolean | number, spanAboveO
5705
6300
  * @param link @optional The link decorator
5706
6301
  * @param code @option The code decorator
5707
6302
  */
5708
- export function createText(text: string, format?: ContentModelSegmentFormat, link?: ContentModelLink, code?: ContentModelCode): ContentModelText;
6303
+ export function createText(text: string, format?: Readonly<ContentModelSegmentFormat>, link?: ReadonlyContentModelLink, code?: ReadonlyContentModelCode): ContentModelText;
5709
6304
 
5710
6305
  /**
5711
6306
  * Create a ContentModelImage model
5712
6307
  * @param src Image source
5713
6308
  * @param format @optional The format of this model
5714
6309
  */
5715
- export function createImage(src: string, format?: ContentModelImageFormat): ContentModelImage;
6310
+ export function createImage(src: string, format?: Readonly<ContentModelImageFormat>): ContentModelImage;
5716
6311
 
5717
6312
  /**
5718
6313
  * Create a ContentModelDocument model
5719
6314
  * @param defaultFormat @optional Default format of this model
5720
6315
  */
5721
- export function createContentModelDocument(defaultFormat?: ContentModelSegmentFormat): ContentModelDocument;
6316
+ export function createContentModelDocument(defaultFormat?: Readonly<ContentModelSegmentFormat>): ContentModelDocument;
5722
6317
 
5723
6318
  /**
5724
6319
  * Create a ContentModelParagraphDecorator model
5725
6320
  * @param tagName Tag name of this decorator
5726
6321
  * @param format @optional The format of this model
5727
6322
  */
5728
- export function createParagraphDecorator(tagName: string, format?: ContentModelSegmentFormat): ContentModelParagraphDecorator;
6323
+ export function createParagraphDecorator(tagName: string, format?: Readonly<ContentModelSegmentFormat>): ContentModelParagraphDecorator;
5729
6324
 
5730
6325
  /**
5731
6326
  * Create a ContentModelGeneralSegment model
5732
6327
  * @param element The original DOM element
5733
6328
  * @param format @optional The format of this model
5734
6329
  */
5735
- export function createGeneralSegment(element: HTMLElement, format?: ContentModelSegmentFormat): ContentModelGeneralSegment;
6330
+ export function createGeneralSegment(element: HTMLElement, format?: Readonly<ContentModelSegmentFormat>): ContentModelGeneralSegment;
5736
6331
 
5737
6332
  /**
5738
6333
  * Create a ContentModelGeneralBlock model
@@ -5748,14 +6343,14 @@ export function createGeneralBlock(element: HTMLElement): ContentModelGeneralBlo
5748
6343
  * @param type @optional Type of this entity
5749
6344
  * @param id @optional Id of this entity
5750
6345
  */
5751
- export function createEntity(wrapper: HTMLElement, isReadonly?: boolean, segmentFormat?: ContentModelSegmentFormat, type?: string, id?: string): ContentModelEntity;
6346
+ export function createEntity(wrapper: HTMLElement, isReadonly?: boolean, segmentFormat?: Readonly<ContentModelSegmentFormat>, type?: string, id?: string): ContentModelEntity;
5752
6347
 
5753
6348
  /**
5754
6349
  * Create a ContentModelDivider model
5755
6350
  * @param tagName Tag name of this divider. Currently only hr and div are supported
5756
6351
  * @param format @optional The format of this model
5757
6352
  */
5758
- export function createDivider(tagName: 'hr' | 'div', format?: ContentModelBlockFormat): ContentModelDivider;
6353
+ export function createDivider(tagName: 'hr' | 'div', format?: Readonly<ContentModelBlockFormat>): ContentModelDivider;
5759
6354
 
5760
6355
  /**
5761
6356
  * Create a ContentModelListLevel model
@@ -5763,27 +6358,56 @@ export function createDivider(tagName: 'hr' | 'div', format?: ContentModelBlockF
5763
6358
  * @param format @optional The format of this model
5764
6359
  * @param dataset @optional The dataset of this model
5765
6360
  */
5766
- export function createListLevel(listType: 'OL' | 'UL', format?: ContentModelListItemLevelFormat, dataset?: DatasetFormat): ContentModelListLevel;
6361
+ export function createListLevel(listType: 'OL' | 'UL', format?: Readonly<ContentModelListItemLevelFormat>, dataset?: ReadonlyDatasetFormat): ContentModelListLevel;
5767
6362
 
5768
6363
  /**
5769
6364
  * Create an empty Content Model Document with initial empty line and insert point with default format
5770
6365
  * @param format @optional The default format to be applied to this Content Model
5771
6366
  */
5772
- export function createEmptyModel(format?: ContentModelSegmentFormat): ContentModelDocument;
6367
+ export function createEmptyModel(format?: Readonly<ContentModelSegmentFormat>): ContentModelDocument;
6368
+
6369
+ /**
6370
+ * Create a ContentModelTableRow model
6371
+ * @param format @optional The format of this model
6372
+ */
6373
+ export function createTableRow(format?: Readonly<ContentModelBlockFormat>, height?: number): ContentModelTableRow;
6374
+
6375
+ /**
6376
+ * Convert a readonly block to mutable block, clear cached element if exist
6377
+ * @param block The block to convert from
6378
+ * @returns The same block object of its related mutable type
6379
+ */
6380
+ export function mutateBlock<T extends ReadonlyContentModelBlockGroup | ReadonlyContentModelBlock>(block: T): MutableType<T>;
6381
+
6382
+ /**
6383
+ * Convert segments of a readonly paragraph to be mutable.
6384
+ * Segments that are not belong to the given paragraph will be skipped
6385
+ * @param paragraph The readonly paragraph to convert from
6386
+ * @param segments The segments to convert from
6387
+ */
6388
+ export function mutateSegments(paragraph: ReadonlyContentModelParagraph, segments: ReadonlyContentModelSegment[]): [ShallowMutableContentModelParagraph, ShallowMutableContentModelSegment[], number[]];
6389
+
6390
+ /**
6391
+ * Convert a readonly segment to be mutable, together with its owner paragraph
6392
+ * If the segment does not belong to the given paragraph, return null for the segment
6393
+ * @param paragraph The readonly paragraph to convert from
6394
+ * @param segment The segment to convert from
6395
+ */
6396
+ export function mutateSegment<T extends ReadonlyContentModelSegment>(paragraph: ReadonlyContentModelParagraph, segment: T, callback?: (segment: MutableType<T>, paragraph: ShallowMutableContentModelParagraph, index: number) => void): [ShallowMutableContentModelParagraph, MutableType<T> | null, number];
5773
6397
 
5774
6398
  /**
5775
6399
  * Add a given block to block group
5776
6400
  * @param group The block group to add block into
5777
6401
  * @param block The block to add
5778
6402
  */
5779
- export function addBlock(group: ContentModelBlockGroup, block: ContentModelBlock): void;
6403
+ export function addBlock(group: ShallowMutableContentModelBlockGroup, block: ShallowMutableContentModelBlock): void;
5780
6404
 
5781
6405
  /**
5782
6406
  * Add a code decorator into segment if any
5783
6407
  * @param segment The segment to add decorator to
5784
6408
  * @param code The code decorator to add
5785
6409
  */
5786
- export function addCode(segment: ContentModelSegment, code: ContentModelCode): void;
6410
+ export function addCode(segment: ShallowMutableContentModelSegment, code: ReadonlyContentModelCode): void;
5787
6411
 
5788
6412
  /**
5789
6413
  * Add a new text segment to current paragraph
@@ -5798,7 +6422,7 @@ export function addTextSegment(group: ContentModelBlockGroup, text: string, cont
5798
6422
  * @param paragraph The paragraph to normalize
5799
6423
  * Normalize a paragraph. If it is empty, add a BR segment to make sure it can insert content
5800
6424
  */
5801
- export function normalizeParagraph(paragraph: ContentModelParagraph): void;
6425
+ export function normalizeParagraph(paragraph: ReadonlyContentModelParagraph): void;
5802
6426
 
5803
6427
  /**
5804
6428
  * For a given content model, normalize it to make the model be consistent.
@@ -5809,7 +6433,7 @@ export function normalizeParagraph(paragraph: ContentModelParagraph): void;
5809
6433
  * - For an empty block, remove it
5810
6434
  * @param group The root level block group of content model to normalize
5811
6435
  */
5812
- export function normalizeContentModel(group: ContentModelBlockGroup): void;
6436
+ export function normalizeContentModel(group: ReadonlyContentModelBlockGroup): void;
5813
6437
 
5814
6438
  /**
5815
6439
  * Check if the given block group is a general segment
@@ -5817,12 +6441,24 @@ export function normalizeContentModel(group: ContentModelBlockGroup): void;
5817
6441
  */
5818
6442
  export function isGeneralSegment(group: ContentModelBlockGroup | ContentModelGeneralSegment): group is ContentModelGeneralSegment;
5819
6443
 
6444
+ /**
6445
+ * Check if the given block group is a general segment (Shallow mutable)
6446
+ * @param group The group to check
6447
+ */
6448
+ export function isGeneralSegment(group: ShallowMutableContentModelBlockGroup | ShallowMutableContentModelGeneralSegment): group is ShallowMutableContentModelGeneralSegment;
6449
+
6450
+ /**
6451
+ * Check if the given block group is a general segment (Readonly)
6452
+ * @param group The group to check
6453
+ */
6454
+ export function isGeneralSegment(group: ReadonlyContentModelBlockGroup | ReadonlyContentModelGeneralSegment): group is ReadonlyContentModelGeneralSegment;
6455
+
5820
6456
  /**
5821
6457
  * Unwrap a given block group, move its child blocks to be under its parent group
5822
6458
  * @param parent Parent block group of the unwrapping group
5823
6459
  * @param groupToUnwrap The block group to unwrap
5824
6460
  */
5825
- export function unwrapBlock(parent: ContentModelBlockGroup | null, groupToUnwrap: ContentModelBlockGroup & ContentModelBlock): void;
6461
+ export function unwrapBlock(parent: ReadonlyContentModelBlockGroup | null, groupToUnwrap: ReadonlyContentModelBlockGroup & ReadonlyContentModelBlock): void;
5826
6462
 
5827
6463
  /**
5828
6464
  * Add a given segment into a paragraph from its parent group. If the last block of the given group is not paragraph, create a new paragraph.
@@ -5833,24 +6469,33 @@ export function unwrapBlock(parent: ContentModelBlockGroup | null, groupToUnwrap
5833
6469
  */
5834
6470
  export function addSegment(group: ContentModelBlockGroup, newSegment: ContentModelSegment, blockFormat?: ContentModelBlockFormat, segmentFormat?: ContentModelSegmentFormat): ContentModelParagraph;
5835
6471
 
6472
+ /**
6473
+ * Add a given segment into a paragraph from its parent group. If the last block of the given group is not paragraph, create a new paragraph. (Shallow mutable)
6474
+ * @param group The parent block group of the paragraph to add segment into
6475
+ * @param newSegment The segment to add
6476
+ * @param blockFormat The block format used for creating a new paragraph when need
6477
+ * @returns The parent paragraph where the segment is added to
6478
+ */
6479
+ export function addSegment(group: ShallowMutableContentModelBlockGroup, newSegment: ContentModelSegment, blockFormat?: ContentModelBlockFormat, segmentFormat?: ContentModelSegmentFormat): ShallowMutableContentModelParagraph;
6480
+
5836
6481
  /**
5837
6482
  * Get whether the model is empty.
5838
6483
  * @returns true if the model is empty.
5839
6484
  */
5840
- export function isEmpty(model: ContentModelBlock | ContentModelBlockGroup | ContentModelSegment): boolean;
6485
+ export function isEmpty(model: ReadonlyContentModelBlock | ReadonlyContentModelBlockGroup | ReadonlyContentModelSegment): boolean;
5841
6486
 
5842
6487
  /**
5843
6488
  * Normalize a given segment, make sure its spaces are correctly represented by space and non-break space
5844
6489
  * @param segment The segment to normalize
5845
6490
  * @param ignoreTrailingSpaces Whether we should ignore the trailing space of the text segment @default false
5846
6491
  */
5847
- export function normalizeSingleSegment(segment: ContentModelSegment, ignoreTrailingSpaces?: boolean): void;
6492
+ export function normalizeSingleSegment(paragraph: ReadonlyContentModelParagraph, segment: ReadonlyContentModelSegment, ignoreTrailingSpaces?: boolean): void;
5848
6493
 
5849
6494
  /**
5850
6495
  * For a given block, if it is a paragraph, set it to be not-implicit
5851
6496
  * @param block The block to check
5852
6497
  */
5853
- export function setParagraphNotImplicit(block: ContentModelBlock): void;
6498
+ export function setParagraphNotImplicit(block: ReadonlyContentModelBlock): void;
5854
6499
 
5855
6500
  /**
5856
6501
  * Get the list number for a list item according to list style type and its index number
@@ -6080,13 +6725,20 @@ export function cacheGetEventData<T, E extends PluginEvent>(event: E, key: strin
6080
6725
  */
6081
6726
  export function isBlockGroupOfType<T extends ContentModelBlockGroup>(input: ContentModelBlock | ContentModelBlockGroup | null | undefined, type: TypeOfBlockGroup<T>): input is T;
6082
6727
 
6728
+ /**
6729
+ * Check if the given content model block or block group is of the expected block group type (Readonly)
6730
+ * @param input The object to check
6731
+ * @param type The expected type
6732
+ */
6733
+ export function isBlockGroupOfType<T extends ReadonlyContentModelBlockGroup>(input: ReadonlyContentModelBlock | ReadonlyContentModelBlockGroup | null | undefined, type: TypeOfBlockGroup<T>): input is T;
6734
+
6083
6735
  /**
6084
6736
  * Get index of closest ancestor block group of the expected block group type. If not found, return -1
6085
6737
  * @param path The block group path, from the closest one to root
6086
6738
  * @param blockGroupTypes The expected block group types
6087
6739
  * @param stopTypes @optional Block group types that will cause stop searching
6088
6740
  */
6089
- export function getClosestAncestorBlockGroupIndex<T extends ContentModelBlockGroup>(path: ContentModelBlockGroup[], blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes?: ContentModelBlockGroupType[]): number;
6741
+ export function getClosestAncestorBlockGroupIndex<T extends ContentModelBlockGroup>(path: ReadonlyContentModelBlockGroup[], blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes?: ContentModelBlockGroupType[]): number;
6090
6742
 
6091
6743
  /**
6092
6744
  * Iterate all selected elements in a given model
@@ -6096,18 +6748,38 @@ export function getClosestAncestorBlockGroupIndex<T extends ContentModelBlockGro
6096
6748
  */
6097
6749
  export function iterateSelections(group: ContentModelBlockGroup, callback: IterateSelectionsCallback, option?: IterateSelectionsOption): void;
6098
6750
 
6751
+ /**
6752
+ * Iterate all selected elements in a given model (Readonly)
6753
+ * @param group The given Content Model to iterate selection from
6754
+ * @param callback The callback function to access the selected element
6755
+ * @param option Option to determine how to iterate
6756
+ */
6757
+ export function iterateSelections(group: ReadonlyContentModelBlockGroup, callback: ReadonlyIterateSelectionsCallback, option?: IterateSelectionsOption): void;
6758
+
6099
6759
  /**
6100
6760
  * Get the first selected list item from content model
6101
6761
  * @param model The Content Model to get selection from
6102
6762
  */
6103
6763
  export function getFirstSelectedListItem(model: ContentModelDocument): ContentModelListItem | undefined;
6104
6764
 
6765
+ /**
6766
+ * Get the first selected list item from content model (Readonly)
6767
+ * @param model The Content Model to get selection from
6768
+ */
6769
+ export function getFirstSelectedListItem(model: ReadonlyContentModelDocument): ReadonlyContentModelListItem | undefined;
6770
+
6105
6771
  /**
6106
6772
  * Get the first selected table from content model
6107
6773
  * @param model The Content Model to get selection from
6108
6774
  */
6109
6775
  export function getFirstSelectedTable(model: ContentModelDocument): [ContentModelTable | undefined, ContentModelBlockGroup[]];
6110
6776
 
6777
+ /**
6778
+ * Get the first selected table from content model (Readonly)
6779
+ * @param model The Content Model to get selection from
6780
+ */
6781
+ export function getFirstSelectedTable(model: ReadonlyContentModelDocument): [ReadonlyContentModelTable | undefined, ReadonlyContentModelBlockGroup[]];
6782
+
6111
6783
  /**
6112
6784
  * Get an array of block group - block pair that is of the expected block group type from selection
6113
6785
  * @param group The root block group to search
@@ -6117,12 +6789,34 @@ export function getFirstSelectedTable(model: ContentModelDocument): [ContentMode
6117
6789
  */
6118
6790
  export function getOperationalBlocks<T extends ContentModelBlockGroup>(group: ContentModelBlockGroup, blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes: ContentModelBlockGroupType[], deepFirst?: boolean): OperationalBlocks<T>[];
6119
6791
 
6792
+ /**
6793
+ * Get an array of block group - block pair that is of the expected block group type from selection (Readonly)
6794
+ * @param group The root block group to search
6795
+ * @param blockGroupTypes The expected block group types
6796
+ * @param stopTypes Block group types that will stop searching when hit
6797
+ * @param deepFirst True means search in deep first, otherwise wide first
6798
+ */
6799
+ export function getOperationalBlocks<T extends ReadonlyContentModelBlockGroup>(group: ReadonlyContentModelBlockGroup, blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes: ContentModelBlockGroupType[], deepFirst?: boolean): ReadonlyOperationalBlocks<T>[];
6800
+
6120
6801
  /**
6121
6802
  * Get any array of selected paragraphs from a content model
6122
6803
  * @param model The Content Model to get selection from
6123
6804
  */
6124
6805
  export function getSelectedParagraphs(model: ContentModelDocument): ContentModelParagraph[];
6125
6806
 
6807
+ /**
6808
+ * Get any array of selected paragraphs from a content model, return mutable paragraphs
6809
+ * @param model The Content Model to get selection from
6810
+ * @param mutate Set to true to indicate we will mutate the selected paragraphs
6811
+ */
6812
+ export function getSelectedParagraphs(model: ReadonlyContentModelDocument, mutate: true): ShallowMutableContentModelParagraph[];
6813
+
6814
+ /**
6815
+ * Get any array of selected paragraphs from a content model (Readonly)
6816
+ * @param model The Content Model to get selection from
6817
+ */
6818
+ export function getSelectedParagraphs(model: ReadonlyContentModelDocument): ReadonlyContentModelParagraph[];
6819
+
6126
6820
  /**
6127
6821
  * Get an array of selected segments from a content model
6128
6822
  * @param model The Content Model to get selection from
@@ -6130,36 +6824,77 @@ export function getSelectedParagraphs(model: ContentModelDocument): ContentModel
6130
6824
  */
6131
6825
  export function getSelectedSegments(model: ContentModelDocument, includingFormatHolder: boolean): ContentModelSegment[];
6132
6826
 
6827
+ /**
6828
+ * Get an array of selected segments from a content model, return mutable segments
6829
+ * @param model The Content Model to get selection from
6830
+ * @param includingFormatHolder True means also include format holder as segment from list item
6831
+ * @param mutate Set to true to indicate we will mutate the selected paragraphs
6832
+ */
6833
+ export function getSelectedSegments(model: ReadonlyContentModelDocument, includingFormatHolder: boolean, mutate: true): ShallowMutableContentModelSegment[];
6834
+
6835
+ /**
6836
+ * Get an array of selected segments from a content model (Readonly)
6837
+ * @param model The Content Model to get selection from
6838
+ * @param includingFormatHolder True means also include format holder as segment from list item
6839
+ */
6840
+ export function getSelectedSegments(model: ReadonlyContentModelDocument, includingFormatHolder: boolean): ReadonlyContentModelSegment[];
6841
+
6133
6842
  /**
6134
6843
  * Get an array of selected parent paragraph and child segment pair
6135
6844
  * @param model The Content Model to get selection from
6136
6845
  * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null
6846
+ * @param includingEntity True to include entity in result as well
6137
6847
  */
6138
6848
  export function getSelectedSegmentsAndParagraphs(model: ContentModelDocument, includingFormatHolder: boolean, includingEntity?: boolean): [ContentModelSegment, ContentModelParagraph | null, ContentModelBlockGroup[]][];
6139
6849
 
6850
+ /**
6851
+ * Get an array of selected parent paragraph and child segment pair, return mutable paragraph and segments
6852
+ * @param model The Content Model to get selection from
6853
+ * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null
6854
+ * @param includingEntity True to include entity in result as well
6855
+ * @param mutate Set to true to indicate we will mutate the selected paragraphs
6856
+ */
6857
+ export function getSelectedSegmentsAndParagraphs(model: ReadonlyContentModelDocument, includingFormatHolder: boolean, includingEntity: boolean, mutate: true): [
6858
+ ShallowMutableContentModelSegment,
6859
+ ContentModelParagraph | null,
6860
+ ReadonlyContentModelBlockGroup[]
6861
+ ][];
6862
+
6863
+ /**
6864
+ * Get an array of selected parent paragraph and child segment pair (Readonly)
6865
+ * @param model The Content Model to get selection from
6866
+ * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null
6867
+ * @param includingEntity True to include entity in result as well
6868
+ */
6869
+ export function getSelectedSegmentsAndParagraphs(model: ReadonlyContentModelDocument, includingFormatHolder: boolean, includingEntity?: boolean): [
6870
+ ReadonlyContentModelSegment,
6871
+ ReadonlyContentModelParagraph | null,
6872
+ ReadonlyContentModelBlockGroup[]
6873
+ ][];
6874
+
6140
6875
  /**
6141
6876
  * Get selection coordinates of a table. If there is no selection, return null
6142
6877
  * @param table The table model to get selection from
6143
6878
  */
6144
- export function getSelectedCells(table: ContentModelTable): TableSelectionCoordinates | null;
6879
+ export function getSelectedCells(table: ReadonlyContentModelTable): TableSelectionCoordinates | null;
6145
6880
 
6146
6881
  /**
6147
6882
  * Check if there is selection within the given block
6148
6883
  * @param block The block to check
6149
6884
  */
6150
- export function hasSelectionInBlock(block: ContentModelBlock): boolean;
6885
+ export function hasSelectionInBlock(block: ReadonlyContentModelBlock): boolean;
6151
6886
 
6152
6887
  /**
6153
6888
  * Check if there is selection within the given segment
6154
6889
  * @param segment The segment to check
6155
6890
  */
6156
- export function hasSelectionInSegment(segment: ContentModelSegment): boolean;
6891
+ export function hasSelectionInSegment(segment: ReadonlyContentModelSegment): boolean;
6157
6892
 
6158
6893
  /**
6159
6894
  * Check if there is selection within the given block
6160
6895
  * @param block The block to check
6161
6896
  */
6162
- export function hasSelectionInBlockGroup(group: ContentModelBlockGroup): boolean;
6897
+ export function hasSelectionInBlockGroup(group: ReadonlyContentModelBlockGroup): boolean;
6163
6898
 
6164
6899
  /**
6165
6900
  * Set selection into Content Model. If the Content Model already has selection, existing selection will be overwritten by the new one.
@@ -6167,14 +6902,14 @@ export function hasSelectionInBlockGroup(group: ContentModelBlockGroup): boolean
6167
6902
  * @param start The start selected element. If not passed, existing selection of content model will be cleared
6168
6903
  * @param end The end selected element. If not passed, only the start element will be selected. If passed, all elements between start and end elements will be selected
6169
6904
  */
6170
- export function setSelection(group: ContentModelBlockGroup, start?: Selectable, end?: Selectable): void;
6905
+ export function setSelection(group: ReadonlyContentModelBlockGroup, start?: ReadonlySelectable, end?: ReadonlySelectable): void;
6171
6906
 
6172
6907
  /**
6173
6908
  * Clone a content model
6174
6909
  * @param model The content model to clone
6175
6910
  * @param options @optional Options to specify customize the clone behavior
6176
6911
  */
6177
- export function cloneModel(model: ContentModelDocument, options?: CloneModelOptions): ContentModelDocument;
6912
+ export function cloneModel(model: ReadonlyContentModelDocument, options?: CloneModelOptions): ContentModelDocument;
6178
6913
 
6179
6914
  /**
6180
6915
  * Merge source model into target mode
@@ -6184,7 +6919,7 @@ export function cloneModel(model: ContentModelDocument, options?: CloneModelOpti
6184
6919
  * @param options More options, see MergeModelOption
6185
6920
  * @returns Insert point after merge, or null if there is no insert point
6186
6921
  */
6187
- export function mergeModel(target: ContentModelDocument, source: ContentModelDocument, context?: FormatContentModelContext, options?: MergeModelOption): InsertPoint | null;
6922
+ export function mergeModel(target: ReadonlyContentModelDocument, source: ContentModelDocument, context?: FormatContentModelContext, options?: MergeModelOption): InsertPoint | null;
6188
6923
 
6189
6924
  /**
6190
6925
  * Delete selected content from Content Model
@@ -6193,17 +6928,17 @@ export function mergeModel(target: ContentModelDocument, source: ContentModelDoc
6193
6928
  * @param formatContext @optional A context object provided by formatContentModel API
6194
6929
  * @returns A DeleteSelectionResult object to specify the deletion result
6195
6930
  */
6196
- export function deleteSelection(model: ContentModelDocument, additionalSteps?: (DeleteSelectionStep | null)[], formatContext?: FormatContentModelContext): DeleteSelectionResult;
6931
+ export function deleteSelection(model: ReadonlyContentModelDocument, additionalSteps?: (DeleteSelectionStep | null)[], formatContext?: FormatContentModelContext): DeleteSelectionResult;
6197
6932
 
6198
6933
  /**
6199
6934
  * Delete a content model segment from current selection
6200
- * @param paragraph Parent paragraph of the segment to delete
6201
- * @param segmentToDelete The segment to delete
6935
+ * @param readonlyParagraph Parent paragraph of the segment to delete
6936
+ * @param readonlySegmentToDelete The segment to delete
6202
6937
  * @param context @optional Context object provided by formatContentModel API
6203
6938
  * @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.
6204
6939
  * If not specified, only selected entity will be deleted
6205
6940
  */
6206
- export function deleteSegment(paragraph: ContentModelParagraph, segmentToDelete: ContentModelSegment, context?: FormatContentModelContext, direction?: 'forward' | 'backward'): boolean;
6941
+ export function deleteSegment(readonlyParagraph: ReadonlyContentModelParagraph, readonlySegmentToDelete: ReadonlyContentModelSegment, context?: FormatContentModelContext, direction?: 'forward' | 'backward'): boolean;
6207
6942
 
6208
6943
  /**
6209
6944
  * Delete a content model block from current selection
@@ -6214,7 +6949,7 @@ export function deleteSegment(paragraph: ContentModelParagraph, segmentToDelete:
6214
6949
  * @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.
6215
6950
  * If not specified, only selected entity will be deleted
6216
6951
  */
6217
- export function deleteBlock(blocks: ContentModelBlock[], blockToDelete: ContentModelBlock, replacement?: ContentModelBlock, context?: FormatContentModelContext, direction?: 'forward' | 'backward'): boolean;
6952
+ export function deleteBlock(blocks: ReadonlyContentModelBlock[], blockToDelete: ReadonlyContentModelBlock, replacement?: ReadonlyContentModelBlock, context?: FormatContentModelContext, direction?: 'forward' | 'backward'): boolean;
6218
6953
 
6219
6954
  /**
6220
6955
  * Apply table format from table metadata and the passed in new format
@@ -6222,20 +6957,27 @@ export function deleteBlock(blocks: ContentModelBlock[], blockToDelete: ContentM
6222
6957
  * @param newFormat @optional New format to apply. When passed, this value will be merged into existing metadata format and default format
6223
6958
  * @param keepCellShade @optional When pass true, table cells with customized shade color will not be overwritten. @default false
6224
6959
  */
6225
- export function applyTableFormat(table: ContentModelTable, newFormat?: TableMetadataFormat, keepCellShade?: boolean): void;
6960
+ export function applyTableFormat(table: ReadonlyContentModelTable, newFormat?: TableMetadataFormat, keepCellShade?: boolean): void;
6961
+
6962
+ /**
6963
+ * Set the first column format borders for the table as well as header property
6964
+ * @param rows The rows of the table
6965
+ * @param format The table metadata format
6966
+ */
6967
+ export function setFirstColumnFormatBorders(rows: ShallowMutableContentModelTableRow[], format: Partial<TableMetadataFormat>): void;
6226
6968
 
6227
6969
  /**
6228
6970
  * Normalize a Content Model table, make sure:
6229
6971
  * 1. Fist cells are not spanned
6230
- * 2. Inner cells are not header
6972
+ * 2. Only first column and row can have headers
6231
6973
  * 3. All cells have content and width
6232
6974
  * 4. Table and table row have correct width/height
6233
6975
  * 5. Spanned cell has no child blocks
6234
6976
  * 6. default format is correctly applied
6235
- * @param table The table to normalize
6977
+ * @param readonlyTable The table to normalize
6236
6978
  * @param defaultSegmentFormat @optional Default segment format to apply to cell
6237
6979
  */
6238
- export function normalizeTable(table: ContentModelTable, defaultSegmentFormat?: ContentModelSegmentFormat): void;
6980
+ export function normalizeTable(readonlyTable: ReadonlyContentModelTable, defaultSegmentFormat?: ContentModelSegmentFormat): void;
6239
6981
 
6240
6982
  /**
6241
6983
  * Minimum width for a table cell
@@ -6249,7 +6991,7 @@ export const MIN_ALLOWED_TABLE_CELL_WIDTH: number;
6249
6991
  * @param isColorOverride @optional When pass true, it means this shade color is not part of table format, so it can be preserved when apply table format
6250
6992
  * @param applyToSegments @optional When pass true, we will also apply text color from table cell to its child blocks and segments
6251
6993
  */
6252
- export function setTableCellBackgroundColor(cell: ContentModelTableCell, color: string | null | undefined, isColorOverride?: boolean, applyToSegments?: boolean): void;
6994
+ export function setTableCellBackgroundColor(cell: ShallowMutableContentModelTableCell, color: string | null | undefined, isColorOverride?: boolean, applyToSegments?: boolean): void;
6253
6995
 
6254
6996
  /**
6255
6997
  * Retrieve format state from the given Content Model
@@ -6257,7 +6999,7 @@ export function setTableCellBackgroundColor(cell: ContentModelTableCell, color:
6257
6999
  * @param pendingFormat Existing pending format, if any
6258
7000
  * @param formatState Existing format state object, used for receiving the result
6259
7001
  */
6260
- export function retrieveModelFormatState(model: ContentModelDocument, pendingFormat: ContentModelSegmentFormat | null, formatState: ContentModelFormatState): void;
7002
+ export function retrieveModelFormatState(model: ReadonlyContentModelDocument, pendingFormat: ContentModelSegmentFormat | null, formatState: ContentModelFormatState): void;
6261
7003
 
6262
7004
  /**
6263
7005
  * Gets the list style type that the bullet is part of, using the Constant record
@@ -6272,7 +7014,7 @@ export function getListStyleTypeFromString(listType: 'OL' | 'UL', bullet: string
6272
7014
  * @param segment The segment to get format from
6273
7015
  * @returns
6274
7016
  */
6275
- export function getSegmentTextFormat(segment: ContentModelSegment): ContentModelSegmentFormat;
7017
+ export function getSegmentTextFormat(segment: ReadonlyContentModelSegment): ContentModelSegmentFormat;
6276
7018
 
6277
7019
  /**
6278
7020
  * Update image metadata with a callback
@@ -6281,26 +7023,50 @@ export function getSegmentTextFormat(segment: ContentModelSegment): ContentModel
6281
7023
  */
6282
7024
  export function updateImageMetadata(image: ContentModelImage, callback?: (format: ImageMetadataFormat | null) => ImageMetadataFormat | null): ImageMetadataFormat | null;
6283
7025
 
7026
+ /**
7027
+ * Get image metadata
7028
+ * @param image The image Content Model
7029
+ */
7030
+ export function getImageMetadata(image: ReadonlyContentModelImage): ImageMetadataFormat | null;
7031
+
6284
7032
  /**
6285
7033
  * Update table cell metadata with a callback
6286
7034
  * @param cell The table cell Content Model
6287
7035
  * @param callback The callback function used for updating metadata
6288
7036
  */
6289
- export function updateTableCellMetadata(cell: ContentModelTableCell, callback?: (format: TableCellMetadataFormat | null) => TableCellMetadataFormat | null): TableCellMetadataFormat | null;
7037
+ export function updateTableCellMetadata(cell: ShallowMutableContentModelTableCell, callback?: (format: TableCellMetadataFormat | null) => TableCellMetadataFormat | null): TableCellMetadataFormat | null;
7038
+
7039
+ /**
7040
+ * Get table cell metadata
7041
+ * @param cell The table cell Content Model
7042
+ */
7043
+ export function getTableCellMetadata(cell: ReadonlyContentModelTableCell): TableCellMetadataFormat | null;
6290
7044
 
6291
7045
  /**
6292
7046
  * Update table metadata with a callback
6293
7047
  * @param table The table Content Model
6294
7048
  * @param callback The callback function used for updating metadata
6295
7049
  */
6296
- export function updateTableMetadata(table: ContentModelTable, callback?: (format: TableMetadataFormat | null) => TableMetadataFormat | null): TableMetadataFormat | null;
7050
+ export function updateTableMetadata(table: ShallowMutableContentModelTable, callback?: (format: TableMetadataFormat | null) => TableMetadataFormat | null): TableMetadataFormat | null;
7051
+
7052
+ /**
7053
+ * Get table metadata
7054
+ * @param table The table Content Model
7055
+ */
7056
+ export function getTableMetadata(table: ReadonlyContentModelTable): TableMetadataFormat | null;
6297
7057
 
6298
7058
  /**
6299
7059
  * Update list metadata with a callback
6300
7060
  * @param list The list Content Model (metadata holder)
6301
7061
  * @param callback The callback function used for updating metadata
6302
7062
  */
6303
- export function updateListMetadata(list: ContentModelWithDataset<ListMetadataFormat>, callback?: (format: ListMetadataFormat | null) => ListMetadataFormat | null): ListMetadataFormat | null;
7063
+ export function updateListMetadata(list: ShallowMutableContentModelWithDataset<ListMetadataFormat>, callback?: (format: ListMetadataFormat | null) => ListMetadataFormat | null): ListMetadataFormat | null;
7064
+
7065
+ /**
7066
+ * Get list metadata
7067
+ * @param list The list Content Model (metadata holder)
7068
+ */
7069
+ export function getListMetadata(list: ReadonlyContentModelWithDataset<ListMetadataFormat>): ListMetadataFormat | null;
6304
7070
 
6305
7071
  /**
6306
7072
  * Metadata definition for List
@@ -7266,19 +8032,26 @@ export function setModelListStyle(model: ContentModelDocument, style: ListMetada
7266
8032
  export function setModelListStartNumber(model: ContentModelDocument, value: number): boolean;
7267
8033
 
7268
8034
  /**
8035
+ * Search for all list items in the same thread as the current list item
7269
8036
  * @param model The content model
7270
8037
  * @param currentItem The current list item
7271
- * Search for all list items in the same thread as the current list item
7272
8038
  */
7273
8039
  export function findListItemsInSameThread(group: ContentModelBlockGroup, currentItem: ContentModelListItem): ContentModelListItem[];
7274
8040
 
8041
+ /**
8042
+ * Search for all list items in the same thread as the current list item (Readonly)
8043
+ * @param model The content model
8044
+ * @param currentItem The current list item
8045
+ */
8046
+ export function findListItemsInSameThread(group: ReadonlyContentModelBlockGroup, currentItem: ReadonlyContentModelListItem): ReadonlyContentModelListItem[];
8047
+
7275
8048
  /**
7276
8049
  * @param model The content model to set indentation
7277
8050
  * @param indentation The indentation type, 'indent' to indent, 'outdent' to outdent
7278
8051
  * @param length The length of indentation in pixel, default value is 40
7279
8052
  * Set indentation for selected list items or paragraphs
7280
8053
  */
7281
- export function setModelIndentation(model: ContentModelDocument, indentation: 'indent' | 'outdent', length?: number, context?: FormatContentModelContext): boolean;
8054
+ export function setModelIndentation(model: ReadonlyContentModelDocument, indentation: 'indent' | 'outdent', length?: number, context?: FormatContentModelContext): boolean;
7282
8055
 
7283
8056
  /**
7284
8057
  * Try to match a given string with link match rules, return matched link
@@ -7297,7 +8070,7 @@ export function matchLink(url: string): LinkData | null;
7297
8070
  * @param path Content model path that include the list item
7298
8071
  * @returns Announce data of current list item if any, or null
7299
8072
  */
7300
- export function getListAnnounceData(path: ContentModelBlockGroup[]): AnnounceData | null;
8073
+ export function getListAnnounceData(path: ReadonlyContentModelBlockGroup[]): AnnounceData | null;
7301
8074
 
7302
8075
  /**
7303
8076
  * TableEdit plugin, provides the ability to resize a table by drag-and-drop
@@ -7413,6 +8186,7 @@ export class EditPlugin implements EditorPlugin {
7413
8186
  private editor;
7414
8187
  private disposer;
7415
8188
  private shouldHandleNextInputEvent;
8189
+ private selectionAfterDelete;
7416
8190
  /**
7417
8191
  * Get name of this plugin
7418
8192
  */