roosterjs-content-model-api 9.4.1 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/lib/modelApi/block/setModelAlignment.d.ts +2 -2
- package/lib/modelApi/block/setModelAlignment.js +3 -2
- package/lib/modelApi/block/setModelAlignment.js.map +1 -1
- package/lib/modelApi/block/setModelDirection.d.ts +2 -2
- package/lib/modelApi/block/setModelDirection.js +8 -6
- package/lib/modelApi/block/setModelDirection.js.map +1 -1
- package/lib/modelApi/block/setModelIndentation.js +1 -1
- package/lib/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib/modelApi/block/toggleModelBlockQuote.d.ts +2 -2
- package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib/modelApi/common/clearModelFormat.d.ts +2 -2
- package/lib/modelApi/common/clearModelFormat.js +19 -10
- package/lib/modelApi/common/clearModelFormat.js.map +1 -1
- package/lib/modelApi/common/wrapBlock.d.ts +4 -4
- package/lib/modelApi/common/wrapBlock.js +11 -7
- package/lib/modelApi/common/wrapBlock.js.map +1 -1
- package/lib/modelApi/entity/insertEntityModel.d.ts +2 -2
- package/lib/modelApi/entity/insertEntityModel.js +1 -1
- package/lib/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib/modelApi/list/setListType.d.ts +2 -2
- package/lib/modelApi/list/setListType.js +12 -11
- package/lib/modelApi/list/setListType.js.map +1 -1
- package/lib/modelApi/list/setModelListStartNumber.d.ts +2 -2
- package/lib/modelApi/list/setModelListStartNumber.js +1 -1
- package/lib/modelApi/list/setModelListStartNumber.js.map +1 -1
- package/lib/modelApi/list/setModelListStyle.d.ts +2 -2
- package/lib/modelApi/list/setModelListStyle.js +1 -1
- package/lib/modelApi/list/setModelListStyle.js.map +1 -1
- package/lib/modelApi/selection/adjustSegmentSelection.d.ts +2 -2
- package/lib/modelApi/selection/adjustSegmentSelection.js +3 -3
- package/lib/modelApi/selection/adjustSegmentSelection.js.map +1 -1
- package/lib/modelApi/selection/adjustTrailingSpaceSelection.d.ts +2 -2
- package/lib/modelApi/selection/adjustTrailingSpaceSelection.js +14 -12
- package/lib/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
- package/lib/modelApi/selection/adjustWordSelection.d.ts +2 -2
- package/lib/modelApi/selection/adjustWordSelection.js +1 -1
- package/lib/modelApi/selection/adjustWordSelection.js.map +1 -1
- package/lib/modelApi/selection/collapseTableSelection.d.ts +2 -2
- package/lib/modelApi/selection/collapseTableSelection.js +1 -1
- package/lib/modelApi/selection/collapseTableSelection.js.map +1 -1
- package/lib/modelApi/table/alignTable.d.ts +2 -2
- package/lib/modelApi/table/alignTable.js +0 -1
- package/lib/modelApi/table/alignTable.js.map +1 -1
- package/lib/modelApi/table/alignTableCell.d.ts +3 -3
- package/lib/modelApi/table/alignTableCell.js +3 -4
- package/lib/modelApi/table/alignTableCell.js.map +1 -1
- package/lib/modelApi/table/clearSelectedCells.d.ts +2 -2
- package/lib/modelApi/table/clearSelectedCells.js +3 -1
- package/lib/modelApi/table/clearSelectedCells.js.map +1 -1
- package/lib/modelApi/table/deleteTable.d.ts +2 -2
- package/lib/modelApi/table/deleteTable.js +0 -1
- package/lib/modelApi/table/deleteTable.js.map +1 -1
- package/lib/modelApi/table/deleteTableColumn.d.ts +2 -2
- package/lib/modelApi/table/deleteTableColumn.js +1 -1
- package/lib/modelApi/table/deleteTableColumn.js.map +1 -1
- package/lib/modelApi/table/deleteTableRow.d.ts +2 -2
- package/lib/modelApi/table/deleteTableRow.js +3 -3
- package/lib/modelApi/table/deleteTableRow.js.map +1 -1
- package/lib/modelApi/table/ensureFocusableParagraphForTable.d.ts +2 -2
- package/lib/modelApi/table/ensureFocusableParagraphForTable.js +2 -2
- package/lib/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
- package/lib/modelApi/table/insertTableColumn.d.ts +2 -2
- package/lib/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib/modelApi/table/insertTableRow.d.ts +2 -2
- package/lib/modelApi/table/insertTableRow.js.map +1 -1
- package/lib/modelApi/table/mergeTableCells.d.ts +2 -2
- package/lib/modelApi/table/mergeTableCells.js +3 -4
- package/lib/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib/modelApi/table/mergeTableColumn.d.ts +2 -2
- package/lib/modelApi/table/mergeTableColumn.js +5 -7
- package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib/modelApi/table/mergeTableRow.d.ts +2 -2
- package/lib/modelApi/table/mergeTableRow.js +5 -8
- package/lib/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib/modelApi/table/splitTableCellHorizontally.d.ts +2 -2
- package/lib/modelApi/table/splitTableCellHorizontally.js +3 -4
- package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
- package/lib/modelApi/table/splitTableCellVertically.d.ts +2 -2
- package/lib/modelApi/table/splitTableCellVertically.js +2 -7
- package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
- package/lib/publicApi/entity/insertEntity.js.map +1 -1
- package/lib/publicApi/image/adjustImageSelection.js +5 -2
- package/lib/publicApi/image/adjustImageSelection.js.map +1 -1
- package/lib/publicApi/link/adjustLinkSelection.js +1 -1
- package/lib/publicApi/link/adjustLinkSelection.js.map +1 -1
- package/lib/publicApi/link/insertLink.js +1 -1
- package/lib/publicApi/link/insertLink.js.map +1 -1
- package/lib/publicApi/link/removeLink.js +1 -1
- package/lib/publicApi/link/removeLink.js.map +1 -1
- package/lib/publicApi/segment/applySegmentFormat.d.ts +1 -1
- package/lib/publicApi/segment/applySegmentFormat.js.map +1 -1
- package/lib/publicApi/segment/changeFontSize.js.map +1 -1
- package/lib/publicApi/segment/setBackgroundColor.js.map +1 -1
- package/lib/publicApi/segment/setFontSize.d.ts +2 -2
- package/lib/publicApi/segment/setFontSize.js.map +1 -1
- package/lib/publicApi/table/applyTableBorderFormat.js +5 -6
- package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib/publicApi/table/formatTable.js +1 -1
- package/lib/publicApi/table/formatTable.js.map +1 -1
- package/lib/publicApi/table/setTableCellShade.js +1 -1
- package/lib/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib/publicApi/utils/formatInsertPointWithContentModel.d.ts +6 -6
- package/lib/publicApi/utils/formatInsertPointWithContentModel.js +5 -5
- package/lib/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatParagraphWithContentModel.d.ts +2 -2
- package/lib/publicApi/utils/formatParagraphWithContentModel.js +1 -1
- package/lib/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatSegmentWithContentModel.d.ts +2 -2
- package/lib/publicApi/utils/formatSegmentWithContentModel.js +1 -1
- package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatTableWithContentModel.d.ts +2 -2
- package/lib/publicApi/utils/formatTableWithContentModel.js +3 -2
- package/lib/publicApi/utils/formatTableWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +2 -2
- package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +8 -8
- package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
- package/lib-amd/modelApi/block/setModelAlignment.d.ts +2 -2
- package/lib-amd/modelApi/block/setModelAlignment.js +3 -2
- package/lib-amd/modelApi/block/setModelAlignment.js.map +1 -1
- package/lib-amd/modelApi/block/setModelDirection.d.ts +2 -2
- package/lib-amd/modelApi/block/setModelDirection.js +8 -6
- package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-amd/modelApi/block/setModelIndentation.js +1 -1
- package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.d.ts +2 -2
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-amd/modelApi/common/clearModelFormat.d.ts +2 -2
- package/lib-amd/modelApi/common/clearModelFormat.js +19 -10
- package/lib-amd/modelApi/common/clearModelFormat.js.map +1 -1
- package/lib-amd/modelApi/common/wrapBlock.d.ts +4 -4
- package/lib-amd/modelApi/common/wrapBlock.js +11 -7
- package/lib-amd/modelApi/common/wrapBlock.js.map +1 -1
- package/lib-amd/modelApi/entity/insertEntityModel.d.ts +2 -2
- package/lib-amd/modelApi/entity/insertEntityModel.js +1 -1
- package/lib-amd/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib-amd/modelApi/list/setListType.d.ts +2 -2
- package/lib-amd/modelApi/list/setListType.js +12 -11
- package/lib-amd/modelApi/list/setListType.js.map +1 -1
- package/lib-amd/modelApi/list/setModelListStartNumber.d.ts +2 -2
- package/lib-amd/modelApi/list/setModelListStartNumber.js +1 -1
- package/lib-amd/modelApi/list/setModelListStartNumber.js.map +1 -1
- package/lib-amd/modelApi/list/setModelListStyle.d.ts +2 -2
- package/lib-amd/modelApi/list/setModelListStyle.js +1 -1
- package/lib-amd/modelApi/list/setModelListStyle.js.map +1 -1
- package/lib-amd/modelApi/selection/adjustSegmentSelection.d.ts +2 -2
- package/lib-amd/modelApi/selection/adjustSegmentSelection.js +3 -3
- package/lib-amd/modelApi/selection/adjustSegmentSelection.js.map +1 -1
- package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.d.ts +2 -2
- package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js +14 -12
- package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
- package/lib-amd/modelApi/selection/adjustWordSelection.d.ts +2 -2
- package/lib-amd/modelApi/selection/adjustWordSelection.js +1 -1
- package/lib-amd/modelApi/selection/adjustWordSelection.js.map +1 -1
- package/lib-amd/modelApi/selection/collapseTableSelection.d.ts +2 -2
- package/lib-amd/modelApi/selection/collapseTableSelection.js +1 -1
- package/lib-amd/modelApi/selection/collapseTableSelection.js.map +1 -1
- package/lib-amd/modelApi/table/alignTable.d.ts +2 -2
- package/lib-amd/modelApi/table/alignTable.js +0 -1
- package/lib-amd/modelApi/table/alignTable.js.map +1 -1
- package/lib-amd/modelApi/table/alignTableCell.d.ts +3 -3
- package/lib-amd/modelApi/table/alignTableCell.js +3 -4
- package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
- package/lib-amd/modelApi/table/clearSelectedCells.d.ts +2 -2
- package/lib-amd/modelApi/table/clearSelectedCells.js +3 -1
- package/lib-amd/modelApi/table/clearSelectedCells.js.map +1 -1
- package/lib-amd/modelApi/table/deleteTable.d.ts +2 -2
- package/lib-amd/modelApi/table/deleteTable.js +0 -1
- package/lib-amd/modelApi/table/deleteTable.js.map +1 -1
- package/lib-amd/modelApi/table/deleteTableColumn.d.ts +2 -2
- package/lib-amd/modelApi/table/deleteTableColumn.js +1 -1
- package/lib-amd/modelApi/table/deleteTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/deleteTableRow.d.ts +2 -2
- package/lib-amd/modelApi/table/deleteTableRow.js +3 -3
- package/lib-amd/modelApi/table/deleteTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.d.ts +2 -2
- package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js +2 -2
- package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
- package/lib-amd/modelApi/table/insertTableColumn.d.ts +2 -2
- package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/insertTableRow.d.ts +2 -2
- package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableCells.d.ts +2 -2
- package/lib-amd/modelApi/table/mergeTableCells.js +3 -4
- package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableColumn.d.ts +2 -2
- package/lib-amd/modelApi/table/mergeTableColumn.js +5 -7
- package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableRow.d.ts +2 -2
- package/lib-amd/modelApi/table/mergeTableRow.js +5 -8
- package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/splitTableCellHorizontally.d.ts +2 -2
- package/lib-amd/modelApi/table/splitTableCellHorizontally.js +3 -4
- package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
- package/lib-amd/modelApi/table/splitTableCellVertically.d.ts +2 -2
- package/lib-amd/modelApi/table/splitTableCellVertically.js +2 -7
- package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
- package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-amd/publicApi/image/adjustImageSelection.js +5 -3
- package/lib-amd/publicApi/image/adjustImageSelection.js.map +1 -1
- package/lib-amd/publicApi/link/adjustLinkSelection.js +1 -1
- package/lib-amd/publicApi/link/adjustLinkSelection.js.map +1 -1
- package/lib-amd/publicApi/link/insertLink.js +1 -1
- package/lib-amd/publicApi/link/insertLink.js.map +1 -1
- package/lib-amd/publicApi/link/removeLink.js +1 -1
- package/lib-amd/publicApi/link/removeLink.js.map +1 -1
- package/lib-amd/publicApi/segment/applySegmentFormat.d.ts +1 -1
- package/lib-amd/publicApi/segment/applySegmentFormat.js.map +1 -1
- package/lib-amd/publicApi/segment/changeFontSize.js.map +1 -1
- package/lib-amd/publicApi/segment/setBackgroundColor.js.map +1 -1
- package/lib-amd/publicApi/segment/setFontSize.d.ts +2 -2
- package/lib-amd/publicApi/segment/setFontSize.js.map +1 -1
- package/lib-amd/publicApi/table/applyTableBorderFormat.js +5 -6
- package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-amd/publicApi/table/formatTable.js +1 -1
- package/lib-amd/publicApi/table/formatTable.js.map +1 -1
- package/lib-amd/publicApi/table/setTableCellShade.js +1 -1
- package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.d.ts +6 -6
- package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js +5 -5
- package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatParagraphWithContentModel.d.ts +2 -2
- package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js +1 -1
- package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.d.ts +2 -2
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +1 -1
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatTableWithContentModel.d.ts +2 -2
- package/lib-amd/publicApi/utils/formatTableWithContentModel.js +3 -2
- package/lib-amd/publicApi/utils/formatTableWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +2 -2
- package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +8 -8
- package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelAlignment.d.ts +2 -2
- package/lib-mjs/modelApi/block/setModelAlignment.js +4 -3
- package/lib-mjs/modelApi/block/setModelAlignment.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelDirection.d.ts +2 -2
- package/lib-mjs/modelApi/block/setModelDirection.js +9 -7
- package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelIndentation.js +1 -1
- package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.d.ts +2 -2
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-mjs/modelApi/common/clearModelFormat.d.ts +2 -2
- package/lib-mjs/modelApi/common/clearModelFormat.js +20 -11
- package/lib-mjs/modelApi/common/clearModelFormat.js.map +1 -1
- package/lib-mjs/modelApi/common/wrapBlock.d.ts +4 -4
- package/lib-mjs/modelApi/common/wrapBlock.js +12 -8
- package/lib-mjs/modelApi/common/wrapBlock.js.map +1 -1
- package/lib-mjs/modelApi/entity/insertEntityModel.d.ts +2 -2
- package/lib-mjs/modelApi/entity/insertEntityModel.js +1 -1
- package/lib-mjs/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib-mjs/modelApi/list/setListType.d.ts +2 -2
- package/lib-mjs/modelApi/list/setListType.js +13 -12
- package/lib-mjs/modelApi/list/setListType.js.map +1 -1
- package/lib-mjs/modelApi/list/setModelListStartNumber.d.ts +2 -2
- package/lib-mjs/modelApi/list/setModelListStartNumber.js +2 -2
- package/lib-mjs/modelApi/list/setModelListStartNumber.js.map +1 -1
- package/lib-mjs/modelApi/list/setModelListStyle.d.ts +2 -2
- package/lib-mjs/modelApi/list/setModelListStyle.js +2 -2
- package/lib-mjs/modelApi/list/setModelListStyle.js.map +1 -1
- package/lib-mjs/modelApi/selection/adjustSegmentSelection.d.ts +2 -2
- package/lib-mjs/modelApi/selection/adjustSegmentSelection.js +3 -3
- package/lib-mjs/modelApi/selection/adjustSegmentSelection.js.map +1 -1
- package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.d.ts +2 -2
- package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js +15 -13
- package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
- package/lib-mjs/modelApi/selection/adjustWordSelection.d.ts +2 -2
- package/lib-mjs/modelApi/selection/adjustWordSelection.js +2 -2
- package/lib-mjs/modelApi/selection/adjustWordSelection.js.map +1 -1
- package/lib-mjs/modelApi/selection/collapseTableSelection.d.ts +2 -2
- package/lib-mjs/modelApi/selection/collapseTableSelection.js +2 -2
- package/lib-mjs/modelApi/selection/collapseTableSelection.js.map +1 -1
- package/lib-mjs/modelApi/table/alignTable.d.ts +2 -2
- package/lib-mjs/modelApi/table/alignTable.js +0 -1
- package/lib-mjs/modelApi/table/alignTable.js.map +1 -1
- package/lib-mjs/modelApi/table/alignTableCell.d.ts +3 -3
- package/lib-mjs/modelApi/table/alignTableCell.js +4 -5
- package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
- package/lib-mjs/modelApi/table/clearSelectedCells.d.ts +2 -2
- package/lib-mjs/modelApi/table/clearSelectedCells.js +4 -2
- package/lib-mjs/modelApi/table/clearSelectedCells.js.map +1 -1
- package/lib-mjs/modelApi/table/deleteTable.d.ts +2 -2
- package/lib-mjs/modelApi/table/deleteTable.js +0 -1
- package/lib-mjs/modelApi/table/deleteTable.js.map +1 -1
- package/lib-mjs/modelApi/table/deleteTableColumn.d.ts +2 -2
- package/lib-mjs/modelApi/table/deleteTableColumn.js +2 -2
- package/lib-mjs/modelApi/table/deleteTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/deleteTableRow.d.ts +2 -2
- package/lib-mjs/modelApi/table/deleteTableRow.js +4 -4
- package/lib-mjs/modelApi/table/deleteTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.d.ts +2 -2
- package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js +3 -3
- package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
- package/lib-mjs/modelApi/table/insertTableColumn.d.ts +2 -2
- package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/insertTableRow.d.ts +2 -2
- package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableCells.d.ts +2 -2
- package/lib-mjs/modelApi/table/mergeTableCells.js +4 -5
- package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableColumn.d.ts +2 -2
- package/lib-mjs/modelApi/table/mergeTableColumn.js +6 -8
- package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableRow.d.ts +2 -2
- package/lib-mjs/modelApi/table/mergeTableRow.js +6 -9
- package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/splitTableCellHorizontally.d.ts +2 -2
- package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +4 -5
- package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
- package/lib-mjs/modelApi/table/splitTableCellVertically.d.ts +2 -2
- package/lib-mjs/modelApi/table/splitTableCellVertically.js +3 -8
- package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
- package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-mjs/publicApi/image/adjustImageSelection.js +5 -2
- package/lib-mjs/publicApi/image/adjustImageSelection.js.map +1 -1
- package/lib-mjs/publicApi/link/adjustLinkSelection.js +1 -1
- package/lib-mjs/publicApi/link/adjustLinkSelection.js.map +1 -1
- package/lib-mjs/publicApi/link/insertLink.js +1 -1
- package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
- package/lib-mjs/publicApi/link/removeLink.js +1 -1
- package/lib-mjs/publicApi/link/removeLink.js.map +1 -1
- package/lib-mjs/publicApi/segment/applySegmentFormat.d.ts +1 -1
- package/lib-mjs/publicApi/segment/applySegmentFormat.js.map +1 -1
- package/lib-mjs/publicApi/segment/changeFontSize.js.map +1 -1
- package/lib-mjs/publicApi/segment/setBackgroundColor.js.map +1 -1
- package/lib-mjs/publicApi/segment/setFontSize.d.ts +2 -2
- package/lib-mjs/publicApi/segment/setFontSize.js.map +1 -1
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js +6 -7
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-mjs/publicApi/table/formatTable.js +2 -2
- package/lib-mjs/publicApi/table/formatTable.js.map +1 -1
- package/lib-mjs/publicApi/table/setTableCellShade.js +2 -2
- package/lib-mjs/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.d.ts +6 -6
- package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js +6 -6
- package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.d.ts +2 -2
- package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js +1 -1
- package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.d.ts +2 -2
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +1 -1
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatTableWithContentModel.d.ts +2 -2
- package/lib-mjs/publicApi/utils/formatTableWithContentModel.js +4 -3
- package/lib-mjs/publicApi/utils/formatTableWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +2 -2
- package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +9 -9
- package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
- package/package.json +3 -3
|
@@ -31,7 +31,7 @@ define(["require", "exports", "tslib", "../../modelApi/selection/adjustTrailingS
|
|
|
31
31
|
var anchorNode_1;
|
|
32
32
|
editor.formatContentModel(function (model, context) {
|
|
33
33
|
var _a;
|
|
34
|
-
var segments = (0, roosterjs_content_model_dom_1.getSelectedSegments)(model, false /*includingFormatHolder*/);
|
|
34
|
+
var segments = (0, roosterjs_content_model_dom_1.getSelectedSegments)(model, false /*includingFormatHolder*/, true /*mutate*/);
|
|
35
35
|
var originalText = segments
|
|
36
36
|
.map(function (x) { return (x.segmentType == 'Text' ? x.text : ''); })
|
|
37
37
|
.join('');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/link/insertLink.ts"],"names":[],"mappings":";;;;IAaA,4BAA4B;IAC5B,IAAM,SAAS,GAAG,cAAc,CAAC;IACjC,wCAAwC;IACxC,IAAM,YAAY,GAAG,cAAc,CAAC;IACpC,sDAAsD;IACtD,IAAM,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;;;;;;;OAYG;IACH,SAAgB,UAAU,CACtB,MAAe,EACf,IAAY,EACZ,WAAoB,EACpB,WAAoB,EACpB,MAAe;QAEf,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,GAAG,EAAE;YACL,IAAM,UAAQ,GAAG,IAAA,qBAAS,EAAC,GAAG,CAAC,CAAC;YAChC,IAAM,SAAO,GAAG,UAAQ,CAAC,CAAC,CAAC,UAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YACzE,IAAM,OAAK,GAAuB,EAAE,CAAC;YACrC,IAAI,YAA4B,CAAC;YAEjC,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,QAAQ,GAAG,IAAA,iDAAmB,
|
|
1
|
+
{"version":3,"file":"insertLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/link/insertLink.ts"],"names":[],"mappings":";;;;IAaA,4BAA4B;IAC5B,IAAM,SAAS,GAAG,cAAc,CAAC;IACjC,wCAAwC;IACxC,IAAM,YAAY,GAAG,cAAc,CAAC;IACpC,sDAAsD;IACtD,IAAM,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;;;;;;;OAYG;IACH,SAAgB,UAAU,CACtB,MAAe,EACf,IAAY,EACZ,WAAoB,EACpB,WAAoB,EACpB,MAAe;QAEf,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,GAAG,EAAE;YACL,IAAM,UAAQ,GAAG,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aACxB,CACJ,CAAC;SACL;IACL,CAAC;IAlFD,gCAkFC;IAED,IAAM,UAAU,GAAG,UACf,GAAW,EACX,WAAoB,EACpB,MAAe,EACf,SAAyB;QAAzB,0BAAA,EAAA,gBAAyB;QAEzB,OAAO;YACH,OAAO,EAAE,EAAE;YACX,MAAM,EAAE;gBACJ,IAAI,EAAE,GAAG;gBACT,WAAW,aAAA;gBACX,MAAM,QAAA;gBACN,SAAS,EAAE,SAAS;aACvB;SACJ,CAAC;IACN,CAAC,CAAC;IAEF,SAAS,eAAe,CAAC,GAAW;QAChC,IAAI,CAAC,GAAG,EAAE;YACN,OAAO,GAAG,CAAC;SACd;QAED,4BAA4B;QAC5B,oEAAoE;QACpE,iEAAiE;QACjE,qDAAqD;QACrD,+BAA+B;QAC/B,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YAC3B,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;gBAC/B,MAAM,GAAG,SAAS,CAAC;aACtB;iBAAM,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBACnC,MAAM,GAAG,QAAQ,CAAC;aACrB;iBAAM;gBACH,sBAAsB;gBACtB,MAAM,GAAG,SAAS,CAAC;aACtB;SACJ;QAED,OAAO,MAAM,GAAG,GAAG,CAAC;IACxB,CAAC;IAED,SAAS,QAAQ,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,CAAC","sourcesContent":["import { adjustTrailingSpaceSelection } from '../../modelApi/selection/adjustTrailingSpaceSelection';\nimport { matchLink } from '../../modelApi/link/matchLink';\nimport {\n addLink,\n addSegment,\n ChangeSource,\n createContentModelDocument,\n createText,\n getSelectedSegments,\n mergeModel,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelLink, IEditor } from 'roosterjs-content-model-types';\n\n// Regex matching Uri scheme\nconst URI_REGEX = /^[a-zA-Z]+:/i;\n// Regex matching begin of email address\nconst MAILTO_REGEX = /^[\\w.%+-]+@/i;\n// Regex matching begin of ftp, i.e. ftp.microsoft.com\nconst FTP_REGEX = /^ftp\\./i;\n\n/**\n * Insert a hyperlink at cursor.\n * When there is a selection, hyperlink will be applied to the selection,\n * otherwise a hyperlink will be inserted to the cursor position.\n * @param editor Editor object\n * @param link Link address, can be http(s), mailto, notes, file, unc, ftp, news, telnet, gopher, wais.\n * When protocol is not specified, a best matched protocol will be predicted.\n * @param anchorTitle Optional alt text of the link, will be shown when hover on the link\n * @param displayText Optional display text for the link.\n * @param target Optional display target for the link (\"_blank\"|\"_self\"|\"_parent\"|\"_top\"|\"{framename}\")\n * If specified, the display text of link will be replaced with this text.\n * If not specified and there wasn't a link, the link url will be used as display text.\n */\nexport function insertLink(\n editor: IEditor,\n link: string,\n anchorTitle?: string,\n displayText?: string,\n target?: string\n) {\n editor.focus();\n\n const url = (checkXss(link) || '').trim();\n if (url) {\n const linkData = matchLink(url);\n const linkUrl = linkData ? linkData.normalizedUrl : applyLinkPrefix(url);\n const links: ContentModelLink[] = [];\n let anchorNode: Node | undefined;\n\n editor.formatContentModel(\n (model, context) => {\n const segments = getSelectedSegments(\n model,\n false /*includingFormatHolder*/,\n true /*mutate*/\n );\n const originalText = segments\n .map(x => (x.segmentType == 'Text' ? x.text : ''))\n .join('');\n const text = displayText || originalText || '';\n\n if (\n segments.some(x => x.segmentType != 'SelectionMarker') &&\n originalText == text\n ) {\n segments.forEach(x => {\n const link = createLink(\n linkUrl,\n anchorTitle,\n target,\n x.segmentType == 'Text'\n );\n addLink(x, link);\n if (x.link) {\n links.push(x.link);\n }\n });\n } else if (\n segments.every(x => x.segmentType == 'SelectionMarker') ||\n (!!text && text != originalText)\n ) {\n const segment = createText(text || (linkData ? linkData.originalUrl : url), {\n ...segments[0]?.format,\n ...editor.getPendingFormat(),\n });\n const doc = createContentModelDocument();\n const link = createLink(linkUrl, anchorTitle, target);\n\n addLink(segment, link);\n addSegment(doc, segment);\n\n if (segment.link) {\n links.push(segment.link);\n }\n\n mergeModel(model, doc, context, {\n mergeFormat: 'mergeAll',\n });\n }\n\n adjustTrailingSpaceSelection(model);\n return segments.length > 0;\n },\n {\n changeSource: ChangeSource.CreateLink,\n onNodeCreated: (modelElement, node) => {\n if (!anchorNode && links.indexOf(modelElement as ContentModelLink) >= 0) {\n anchorNode = node;\n }\n },\n getChangeData: () => anchorNode,\n apiName: 'insertLink',\n }\n );\n }\n}\n\nconst createLink = (\n url: string,\n anchorTitle?: string,\n target?: string,\n underline: boolean = true\n): ContentModelLink => {\n return {\n dataset: {},\n format: {\n href: url,\n anchorTitle,\n target,\n underline: underline,\n },\n };\n};\n\nfunction applyLinkPrefix(url: string): string {\n if (!url) {\n return url;\n }\n\n // Add link prefix per rule:\n // (a) if the url always starts with a URI scheme, leave it as it is\n // (b) if the url is an email address, xxx@... add mailto: prefix\n // (c) if the url starts with ftp., add ftp:// prefix\n // (d) rest, add http:// prefix\n let prefix = '';\n if (url.search(URI_REGEX) < 0) {\n if (url.search(MAILTO_REGEX) == 0) {\n prefix = 'mailto:';\n } else if (url.search(FTP_REGEX) == 0) {\n prefix = 'ftp://';\n } else {\n // fallback to http://\n prefix = 'http://';\n }\n }\n\n return prefix + url;\n}\n\nfunction checkXss(link: string): string {\n return link.match(/s\\n*c\\n*r\\n*i\\n*p\\n*t\\n*:/i) ? '' : link;\n}\n"]}
|
|
@@ -15,7 +15,7 @@ define(["require", "exports", "../../modelApi/selection/adjustSegmentSelection",
|
|
|
15
15
|
return target.isSelected || // Expand the selection to any link that is involved. So we can remove multiple links together
|
|
16
16
|
(!!target.link && target.link.format.href == ref.link.format.href);
|
|
17
17
|
});
|
|
18
|
-
var segments = (0, roosterjs_content_model_dom_1.getSelectedSegments)(model, false /*includingFormatHolder*/);
|
|
18
|
+
var segments = (0, roosterjs_content_model_dom_1.getSelectedSegments)(model, false /*includingFormatHolder*/, true /*mutate*/);
|
|
19
19
|
var isChanged = false;
|
|
20
20
|
segments.forEach(function (segment) {
|
|
21
21
|
if (segment.link) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/link/removeLink.ts"],"names":[],"mappings":";;;;IAIA;;;;;OAKG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAA,+CAAsB,EAClB,KAAK,EACL,UAAA,MAAM,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAApC,CAAoC,EAC9C,UAAC,MAAM,EAAE,GAAG;gBACR,OAAA,MAAM,CAAC,UAAU,IAAI,8FAA8F;oBACnH,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,IAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YADnE,CACmE,CAC1E,CAAC;YAEF,IAAM,QAAQ,GAAG,IAAA,iDAAmB,
|
|
1
|
+
{"version":3,"file":"removeLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/link/removeLink.ts"],"names":[],"mappings":";;;;IAIA;;;;;OAKG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAA,+CAAsB,EAClB,KAAK,EACL,UAAA,MAAM,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAApC,CAAoC,EAC9C,UAAC,MAAM,EAAE,GAAG;gBACR,OAAA,MAAM,CAAC,UAAU,IAAI,8FAA8F;oBACnH,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,IAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YADnE,CACmE,CAC1E,CAAC;YAEF,IAAM,QAAQ,GAAG,IAAA,iDAAmB,EAChC,KAAK,EACL,KAAK,CAAC,yBAAyB,EAC/B,IAAI,CAAC,UAAU,CAClB,CAAC;YACF,IAAI,SAAS,GAAG,KAAK,CAAC;YAEtB,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;gBACpB,IAAI,OAAO,CAAC,IAAI,EAAE;oBACd,SAAS,GAAG,IAAI,CAAC;oBAEjB,OAAO,OAAO,CAAC,IAAI,CAAC;iBACvB;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC;QACrB,CAAC,EACD;YACI,OAAO,EAAE,YAAY;SACxB,CACJ,CAAC;IACN,CAAC;IAlCD,gCAkCC","sourcesContent":["import { adjustSegmentSelection } from '../../modelApi/selection/adjustSegmentSelection';\nimport { getSelectedSegments } from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Remove link at selection. If no links at selection, do nothing.\n * If selection contains multiple links, all of the link styles will be removed.\n * If only part of a link is selected, the whole link style will be removed.\n * @param editor The editor instance\n */\nexport function removeLink(editor: IEditor) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n adjustSegmentSelection(\n model,\n target => !!target.isSelected && !!target.link,\n (target, ref) =>\n target.isSelected || // Expand the selection to any link that is involved. So we can remove multiple links together\n (!!target.link && target.link.format.href == ref.link!.format.href)\n );\n\n const segments = getSelectedSegments(\n model,\n false /*includingFormatHolder*/,\n true /*mutate*/\n );\n let isChanged = false;\n\n segments.forEach(segment => {\n if (segment.link) {\n isChanged = true;\n\n delete segment.link;\n }\n });\n\n return isChanged;\n },\n {\n apiName: 'removeLink',\n }\n );\n}\n"]}
|
|
@@ -4,4 +4,4 @@ import type { ContentModelSegmentFormat, IEditor } from 'roosterjs-content-model
|
|
|
4
4
|
* @param editor The editor to operate on
|
|
5
5
|
* @param newFormat The segment format to apply
|
|
6
6
|
*/
|
|
7
|
-
export declare function applySegmentFormat(editor: IEditor, newFormat: ContentModelSegmentFormat): void;
|
|
7
|
+
export declare function applySegmentFormat(editor: IEditor, newFormat: Readonly<ContentModelSegmentFormat>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applySegmentFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/applySegmentFormat.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACH,SAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"applySegmentFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/applySegmentFormat.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACH,SAAgB,kBAAkB,CAC9B,MAAe,EACf,SAA8C;QAE9C,IAAA,6DAA6B,EACzB,MAAM,EACN,oBAAoB,EACpB,UAAA,MAAM;YACF,MAAM,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;YACnD,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;YACzC,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;YACrC,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;YACzC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;YACjC,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;YAC/C,MAAM,CAAC,wBAAwB,GAAG,SAAS,CAAC,wBAAwB,CAAC;YACrE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;YACvC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;QAC3C,CAAC,EACD,SAAS,CAAC,4BAA4B,EACtC,IAAI,CAAC,0BAA0B,CAClC,CAAC;IACN,CAAC;IArBD,gDAqBC","sourcesContent":["import { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport type { ContentModelSegmentFormat, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Bulk apply segment format to all selected content. This is usually used for format painter.\n * @param editor The editor to operate on\n * @param newFormat The segment format to apply\n */\nexport function applySegmentFormat(\n editor: IEditor,\n newFormat: Readonly<ContentModelSegmentFormat>\n) {\n formatSegmentWithContentModel(\n editor,\n 'applySegmentFormat',\n format => {\n format.backgroundColor = newFormat.backgroundColor;\n format.fontFamily = newFormat.fontFamily;\n format.fontSize = newFormat.fontSize;\n format.fontWeight = newFormat.fontWeight;\n format.italic = newFormat.italic;\n format.strikethrough = newFormat.strikethrough;\n format.superOrSubScriptSequence = newFormat.superOrSubScriptSequence;\n format.textColor = newFormat.textColor;\n format.underline = newFormat.underline;\n },\n undefined /* segmentHasStyleCallback*/,\n true /*includingFormatHandler*/\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeFontSize.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/changeFontSize.ts"],"names":[],"mappings":";;;;IASA;;;OAGG;IACH,IAAM,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAClF,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,aAAa,GAAG,IAAI,CAAC;IAE3B;;;;;OAKG;IACH,SAAgB,cAAc,CAAC,MAAe,EAAE,MAA+B;QAC3E,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAA,6DAA6B,EACzB,MAAM,EACN,gBAAgB,EAChB,UAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,IAAK,OAAA,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAjD,CAAiD,EAC/E,SAAS,CAAC,4BAA4B,EACtC,IAAI,CAAC,0BAA0B,CAClC,CAAC;IACN,CAAC;IAVD,wCAUC;IAED,SAAS,sBAAsB,CAC3B,MAA+B,EAC/B,MAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"changeFontSize.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/changeFontSize.ts"],"names":[],"mappings":";;;;IASA;;;OAGG;IACH,IAAM,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAClF,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,aAAa,GAAG,IAAI,CAAC;IAE3B;;;;;OAKG;IACH,SAAgB,cAAc,CAAC,MAAe,EAAE,MAA+B;QAC3E,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAA,6DAA6B,EACzB,MAAM,EACN,gBAAgB,EAChB,UAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,IAAK,OAAA,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAjD,CAAiD,EAC/E,SAAS,CAAC,4BAA4B,EACtC,IAAI,CAAC,0BAA0B,CAClC,CAAC;IACN,CAAC;IAVD,wCAUC;IAED,SAAS,sBAAsB,CAC3B,MAA+B,EAC/B,MAAiC,EACjC,SAAqD;QAErD,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjB,IAAM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AC,EAAE,aAAa,CAAC,CAAC;SACxE;aAAM,IAAI,UAAU,IAAI,CAAC,EAAE;YACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACvC,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE;oBACnB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;oBAClB,MAAM;iBACT;aACJ;SACJ;aAAM;YACH,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC5C,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE;oBACnB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;oBAClB,MAAM;iBACT;aACJ;SACJ;QACD,OAAO,EAAE,CAAC;IACd,CAAC","sourcesContent":["import { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport { setFontSizeInternal } from './setFontSize';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Default font size sequence, in pt. Suggest editor UI use this sequence as your font size list,\n * So that when increase/decrease font size, the font size can match the sequence of your font size picker\n */\nconst FONT_SIZES = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72];\nconst MIN_FONT_SIZE = 1;\nconst MAX_FONT_SIZE = 1000;\n\n/**\n * Increase or decrease font size in selection\n * @param editor The editor instance\n * @param change Whether increase or decrease font size\n * @param fontSizes A sorted font size array, in pt. Default value is FONT_SIZES\n */\nexport function changeFontSize(editor: IEditor, change: 'increase' | 'decrease') {\n editor.focus();\n\n formatSegmentWithContentModel(\n editor,\n 'changeFontSize',\n (format, _, __, paragraph) => changeFontSizeInternal(change, format, paragraph),\n undefined /* segmentHasStyleCallback*/,\n true /*includingFormatHandler*/\n );\n}\n\nfunction changeFontSizeInternal(\n change: 'increase' | 'decrease',\n format: ContentModelSegmentFormat,\n paragraph: ShallowMutableContentModelParagraph | null\n) {\n if (format.fontSize) {\n const sizeInPt = parseValueWithUnit(format.fontSize, undefined /*element*/, 'pt');\n\n if (sizeInPt > 0) {\n const newSize = getNewFontSize(sizeInPt, change == 'increase' ? 1 : -1, FONT_SIZES);\n\n setFontSizeInternal(newSize + 'pt', format, paragraph);\n }\n }\n}\n\nfunction getNewFontSize(pt: number, changeBase: 1 | -1, fontSizes: number[]): number {\n pt = changeBase == 1 ? Math.floor(pt) : Math.ceil(pt);\n const last = fontSizes[fontSizes.length - 1];\n if (pt <= fontSizes[0]) {\n pt = Math.max(pt + changeBase, MIN_FONT_SIZE);\n } else if (pt > last || (pt == last && changeBase == 1)) {\n pt = pt / 10;\n pt = changeBase == 1 ? Math.floor(pt) : Math.ceil(pt);\n pt = Math.min(Math.max((pt + changeBase) * 10, last), MAX_FONT_SIZE);\n } else if (changeBase == 1) {\n for (let i = 0; i < fontSizes.length; i++) {\n if (pt < fontSizes[i]) {\n pt = fontSizes[i];\n break;\n }\n }\n } else {\n for (let i = fontSizes.length - 1; i >= 0; i--) {\n if (pt > fontSizes[i]) {\n pt = fontSizes[i];\n break;\n }\n }\n }\n return pt;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setBackgroundColor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/setBackgroundColor.ts"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,MAAe,EAAE,eAA8B;QAC9E,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"setBackgroundColor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/setBackgroundColor.ts"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,MAAe,EAAE,eAA8B;QAC9E,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAI,aAAa,GAA+C,IAAI,CAAC;QACrE,IAAI,gBAAgB,GAAW,CAAC,CAAC,CAAC;QAElC,IAAA,6DAA6B,EACzB,MAAM,EACN,oBAAoB,EACpB,UAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS;YAC1B,IAAI,eAAe,KAAK,IAAI,EAAE;gBAC1B,OAAO,MAAM,CAAC,eAAe,CAAC;aACjC;iBAAM;gBACH,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;aAC5C;YAED,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBAClE,aAAa,GAAG,SAAS,CAAC;gBAC1B,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAC9D;QACL,CAAC,EACD,SAAS,CAAC,2BAA2B,EACrC,SAAS,CAAC,yBAAyB,EACnC,UAAA,KAAK;;YACD,IAAI,aAAa,IAAI,gBAAgB,IAAI,CAAC,EAAE;gBACxC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAChC,MAAA,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,0CAAE,MAAM,CACnD,CAAC;gBAEF,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;gBAC/D,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;aACvC;QACL,CAAC,CACJ,CAAC;IACN,CAAC;IAlCD,gDAkCC","sourcesContent":["import { createSelectionMarker, setSelection } from 'roosterjs-content-model-dom';\nimport { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport type { IEditor, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * Set background color\n * @param editor The editor to operate on\n * @param backgroundColor The color to set. Pass null to remove existing color.\n */\nexport function setBackgroundColor(editor: IEditor, backgroundColor: string | null) {\n editor.focus();\n\n let lastParagraph: ShallowMutableContentModelParagraph | null = null;\n let lastSegmentIndex: number = -1;\n\n formatSegmentWithContentModel(\n editor,\n 'setBackgroundColor',\n (format, _, segment, paragraph) => {\n if (backgroundColor === null) {\n delete format.backgroundColor;\n } else {\n format.backgroundColor = backgroundColor;\n }\n\n if (segment && paragraph && segment.segmentType != 'SelectionMarker') {\n lastParagraph = paragraph;\n lastSegmentIndex = lastParagraph.segments.indexOf(segment);\n }\n },\n undefined /*segmentHasStyleCallback*/,\n undefined /*includingFormatHolder*/,\n model => {\n if (lastParagraph && lastSegmentIndex >= 0) {\n const marker = createSelectionMarker(\n lastParagraph.segments[lastSegmentIndex]?.format\n );\n\n lastParagraph.segments.splice(lastSegmentIndex + 1, 0, marker);\n setSelection(model, marker, marker);\n }\n }\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelSegmentFormat, IEditor, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Set font size
|
|
4
4
|
* @param editor The editor to operate on
|
|
@@ -9,4 +9,4 @@ export declare function setFontSize(editor: IEditor, fontSize: string): void;
|
|
|
9
9
|
* @internal
|
|
10
10
|
* Internal set font function shared by setFontSize and changeFontSize
|
|
11
11
|
*/
|
|
12
|
-
export declare function setFontSizeInternal(fontSize: string, format: ContentModelSegmentFormat, paragraph:
|
|
12
|
+
export declare function setFontSizeInternal(fontSize: string, format: ContentModelSegmentFormat, paragraph: ShallowMutableContentModelParagraph | null): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setFontSize.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/setFontSize.ts"],"names":[],"mappings":";;;;IAOA;;;;OAIG;IACH,SAAgB,WAAW,CAAC,MAAe,EAAE,QAAgB;QACzD,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAA,6DAA6B,EACzB,MAAM,EACN,aAAa,EACb,UAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,IAAK,OAAA,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAhD,CAAgD,EAC9E,SAAS,CAAC,4BAA4B,EACtC,IAAI,CAAC,0BAA0B,CAClC,CAAC;IACN,CAAC;IAVD,kCAUC;IAED;;;OAGG;IACH,SAAgB,mBAAmB,CAC/B,QAAgB,EAChB,MAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"setFontSize.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/setFontSize.ts"],"names":[],"mappings":";;;;IAOA;;;;OAIG;IACH,SAAgB,WAAW,CAAC,MAAe,EAAE,QAAgB;QACzD,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAA,6DAA6B,EACzB,MAAM,EACN,aAAa,EACb,UAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,IAAK,OAAA,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAhD,CAAgD,EAC9E,SAAS,CAAC,4BAA4B,EACtC,IAAI,CAAC,0BAA0B,CAClC,CAAC;IACN,CAAC;IAVD,kCAUC;IAED;;;OAGG;IACH,SAAgB,mBAAmB,CAC/B,QAAgB,EAChB,MAAiC,EACjC,SAAqD;;QAErD,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,iIAAiI;QACjI,IAAI,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,0CAAE,QAAQ,EAAE;YACpC,IAAM,MAAI,GAAG,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC;YAE9C,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO;gBAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE;oBAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAI,CAAC;iBAClC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC;SAC3C;IACL,CAAC;IAnBD,kDAmBC","sourcesContent":["import { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Set font size\n * @param editor The editor to operate on\n * @param fontSize The font size to set\n */\nexport function setFontSize(editor: IEditor, fontSize: string) {\n editor.focus();\n\n formatSegmentWithContentModel(\n editor,\n 'setFontSize',\n (format, _, __, paragraph) => setFontSizeInternal(fontSize, format, paragraph),\n undefined /* segmentHasStyleCallback*/,\n true /*includingFormatHandler*/\n );\n}\n\n/**\n * @internal\n * Internal set font function shared by setFontSize and changeFontSize\n */\nexport function setFontSizeInternal(\n fontSize: string,\n format: ContentModelSegmentFormat,\n paragraph: ShallowMutableContentModelParagraph | null\n) {\n format.fontSize = fontSize;\n\n // Since we have set font size to segment, it can be smaller than the one in paragraph format, so delete font size from paragraph\n if (paragraph?.segmentFormat?.fontSize) {\n const size = paragraph.segmentFormat.fontSize;\n\n paragraph.segments.forEach(segment => {\n if (!segment.format.fontSize) {\n segment.format.fontSize = size;\n }\n });\n\n delete paragraph.segmentFormat.fontSize;\n }\n}\n"]}
|
|
@@ -222,10 +222,10 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
222
222
|
//Format perimeter if necessary or possible
|
|
223
223
|
modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);
|
|
224
224
|
}
|
|
225
|
-
var tableMeta = (0, roosterjs_content_model_dom_1.
|
|
225
|
+
var tableMeta = (0, roosterjs_content_model_dom_1.getTableMetadata)(tableModel);
|
|
226
226
|
if (tableMeta) {
|
|
227
227
|
// Enforce first column format if necessary
|
|
228
|
-
(0, roosterjs_content_model_dom_1.setFirstColumnFormatBorders)(tableModel.rows, tableMeta);
|
|
228
|
+
(0, roosterjs_content_model_dom_1.setFirstColumnFormatBorders)((0, roosterjs_content_model_dom_1.mutateBlock)(tableModel).rows, tableMeta);
|
|
229
229
|
}
|
|
230
230
|
return true;
|
|
231
231
|
}
|
|
@@ -245,16 +245,15 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
245
245
|
* @param positions The positions to apply
|
|
246
246
|
*/
|
|
247
247
|
function applyBorderFormat(cell, borderFormat, positions) {
|
|
248
|
+
var mutableCell = (0, roosterjs_content_model_dom_1.mutateBlock)(cell);
|
|
248
249
|
positions.forEach(function (pos) {
|
|
249
|
-
|
|
250
|
+
mutableCell.format[pos] = borderFormat;
|
|
250
251
|
});
|
|
251
|
-
(0, roosterjs_content_model_dom_1.updateTableCellMetadata)(
|
|
252
|
+
(0, roosterjs_content_model_dom_1.updateTableCellMetadata)(mutableCell, function (metadata) {
|
|
252
253
|
metadata = metadata || {};
|
|
253
254
|
metadata.borderOverride = true;
|
|
254
255
|
return metadata;
|
|
255
256
|
});
|
|
256
|
-
// Cell was modified, so delete cached element
|
|
257
|
-
delete cell.cachedElement;
|
|
258
257
|
}
|
|
259
258
|
/**
|
|
260
259
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;;IAqCA;;;;;OAKG;IACH,SAAgB,sBAAsB,CAClC,MAAe,EACf,MAAc,EACd,SAA2B;QAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ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umnFormatBorders,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport function applyTableBorderFormat(\n editor: IEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n const tableMeta = hasMetadata(tableModel) ? getTableMetadata(tableModel) : {};\n if (tableMeta) {\n // Enforce first column format if necessary\n setFirstColumnFormatBorders(tableModel.rows, tableMeta);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;;IAqCA;;;;;OAKG;IACH,SAAgB,sBAAsB,CAClC,MAAe,EACf,MAAc,EACd,SAA2B;QAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,UAAU,CAAC,CAAC;gBACzC,IAAM,SAAS,GAAc;oBACzB,GAAG,EAAE,KAAK;oBACV,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,KAAK;iBACf,CAAC;gBAEF,mDAAmD;gBACnD,IAAI,YAAY,GAAG,EAAE,CAAC;gBACtB,IAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;gBACzB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,KAAK,GAAY,MAAM,MAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;gBACvC,IAAM,eAAe,GAAG,IAAA,iDAAmB,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC9D,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAC1C,IAAM,WAAW,GAAG,eAAe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ACD,qBAAqB;QACrB,IAAI,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YACzE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;gBACjE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;aACjF;SACJ;IACL,CAAC","sourcesContent":["import {\n extractBorderValues,\n getFirstSelectedTable,\n getSelectedCells,\n mutateBlock,\n getTableMetadata,\n parseValueWithUnit,\n setFirstColumnFormatBorders,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n Border,\n BorderOperations,\n TableSelectionCoordinates,\n ReadonlyContentModelTableCell,\n ReadonlyContentModelTable,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport function applyTableBorderFormat(\n editor: IEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n const tableMeta = getTableMetadata(tableModel);\n if (tableMeta) {\n // Enforce first column format if necessary\n setFirstColumnFormatBorders(mutateBlock(tableModel).rows, tableMeta);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ReadonlyContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n const mutableCell = mutateBlock(cell);\n\n positions.forEach(pos => {\n mutableCell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(mutableCell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
|
|
@@ -16,7 +16,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
16
16
|
// Wipe border metadata
|
|
17
17
|
tableModel.rows.forEach(function (row) {
|
|
18
18
|
row.cells.forEach(function (cell) {
|
|
19
|
-
(0, roosterjs_content_model_dom_1.updateTableCellMetadata)(cell, function (metadata) {
|
|
19
|
+
(0, roosterjs_content_model_dom_1.updateTableCellMetadata)((0, roosterjs_content_model_dom_1.mutateBlock)(cell), function (metadata) {
|
|
20
20
|
if (metadata) {
|
|
21
21
|
delete metadata.borderOverride;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"formatTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts"],"names":[],"mappings":";;;;IAQA;;;;;OAKG;IACH,SAAgB,WAAW,CAAC,MAAe,EAAE,MAA2B,EAAE,aAAuB;QAC7F,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,uBAAuB;gBACvB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBACvB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,IAAA,qDAAuB,EAAC,IAAA,yCAAW,EAAC,IAAI,CAAC,EAAE,UAAA,QAAQ;4BAC/C,IAAI,QAAQ,EAAE;gCACV,OAAO,QAAQ,CAAC,cAAc,CAAC;6BAClC;4BACD,OAAO,QAAQ,CAAC;wBACpB,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBACH,IAAA,8CAAgB,EAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;gBACpD,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC;IA7BD,kCA6BC","sourcesContent":["import {\n applyTableFormat,\n getFirstSelectedTable,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, TableMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Format current focused table with the given format\n * @param editor The editor instance\n * @param format The table format to apply\n * @param keepCellShade Whether keep existing shade color when apply format if there is a manually set shade color\n */\nexport function formatTable(editor: IEditor, format: TableMetadataFormat, keepCellShade?: boolean) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n // Wipe border metadata\n tableModel.rows.forEach(row => {\n row.cells.forEach(cell => {\n updateTableCellMetadata(mutateBlock(cell), metadata => {\n if (metadata) {\n delete metadata.borderOverride;\n }\n return metadata;\n });\n });\n });\n applyTableFormat(tableModel, format, keepCellShade);\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'formatTable',\n }\n );\n}\n"]}
|
|
@@ -15,7 +15,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
15
15
|
table.rows.forEach(function (row) {
|
|
16
16
|
return row.cells.forEach(function (cell) {
|
|
17
17
|
if ((0, roosterjs_content_model_dom_1.hasSelectionInBlockGroup)(cell)) {
|
|
18
|
-
(0, roosterjs_content_model_dom_1.setTableCellBackgroundColor)(cell, color, true /*isColorOverride*/);
|
|
18
|
+
(0, roosterjs_content_model_dom_1.setTableCellBackgroundColor)((0, roosterjs_content_model_dom_1.mutateBlock)(cell), color, true /*isColorOverride*/);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTableCellShade.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/setTableCellShade.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"setTableCellShade.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/setTableCellShade.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,iBAAiB,CAAC,MAAe,EAAE,KAAoB;QACnE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAU,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAArC,KAAK,QAAgC,CAAC;YAE7C,IAAI,KAAK,EAAE;gBACP,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,IAAI,IAAA,sDAAwB,EAAC,IAAI,CAAC,EAAE;4BAChC,IAAA,yDAA2B,EACvB,IAAA,yCAAW,EAAC,IAAI,CAAC,EACjB,KAAK,EACL,IAAI,CAAC,mBAAmB,CAC3B,CAAC;yBACL;oBACL,CAAC,CAAC;gBARF,CAQE,CACL,CAAC;gBAEF,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,mBAAmB;SAC/B,CACJ,CAAC;IACN,CAAC;IA7BD,8CA6BC","sourcesContent":["import {\n hasSelectionInBlockGroup,\n getFirstSelectedTable,\n setTableCellBackgroundColor,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set table cell shade color\n * @param editor The editor instance\n * @param color The color to set. Pass null to remove existing shade color\n */\nexport function setTableCellShade(editor: IEditor, color: string | null) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [table] = getFirstSelectedTable(model);\n\n if (table) {\n table.rows.forEach(row =>\n row.cells.forEach(cell => {\n if (hasSelectionInBlockGroup(cell)) {\n setTableCellBackgroundColor(\n mutateBlock(cell),\n color,\n true /*isColorOverride*/\n );\n }\n })\n );\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'setTableCellShade',\n }\n );\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { DOMInsertPoint, FormatContentModelOptions, IEditor, InsertPoint,
|
|
1
|
+
import type { DOMInsertPoint, FormatContentModelOptions, IEditor, InsertPoint, FormatContentModelContext, ShallowMutableContentModelDocument } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Invoke a callback to format the content in a specific position using Content Model
|
|
4
4
|
* @param editor The editor object
|
|
5
|
-
* @param insertPoint The insert
|
|
6
|
-
* @param callback The callback
|
|
7
|
-
* @param options
|
|
5
|
+
* @param insertPoint The insert position.
|
|
6
|
+
* @param callback The callback to insert the format.
|
|
7
|
+
* @param options More options, @see FormatContentModelOptions
|
|
8
8
|
*/
|
|
9
|
-
export declare function formatInsertPointWithContentModel(editor: IEditor, insertPoint: DOMInsertPoint, callback: (model:
|
|
9
|
+
export declare function formatInsertPointWithContentModel(editor: IEditor, insertPoint: DOMInsertPoint, callback: (model: ShallowMutableContentModelDocument, context: FormatContentModelContext, insertPoint?: InsertPoint) => void, options?: FormatContentModelOptions): void;
|
|
@@ -3,11 +3,11 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.formatInsertPointWithContentModel = void 0;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Invoke a callback to format the content in a specific position using Content Model
|
|
7
7
|
* @param editor The editor object
|
|
8
|
-
* @param insertPoint The insert
|
|
9
|
-
* @param callback The callback
|
|
10
|
-
* @param options
|
|
8
|
+
* @param insertPoint The insert position.
|
|
9
|
+
* @param callback The callback to insert the format.
|
|
10
|
+
* @param options More options, @see FormatContentModelOptions
|
|
11
11
|
*/
|
|
12
12
|
function formatInsertPointWithContentModel(editor, insertPoint, callback, options) {
|
|
13
13
|
var bundle = {
|
|
@@ -19,7 +19,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
19
19
|
var _a = bundle.result, paragraph = _a.paragraph, marker = _a.marker;
|
|
20
20
|
var index = paragraph.segments.indexOf(marker);
|
|
21
21
|
if (index >= 0) {
|
|
22
|
-
paragraph.segments.splice(index, 1);
|
|
22
|
+
(0, roosterjs_content_model_dom_1.mutateBlock)(paragraph).segments.splice(index, 1);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInsertPointWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatInsertPointWithContentModel.ts"],"names":[],"mappings":";;;;IAmBA;;;;;;OAMG;IACH,SAAgB,iCAAiC,CAC7C,MAAe,EACf,WAA2B,EAC3B,QAIS,EACT,OAAmC;QAEnC,IAAM,MAAM,GAAsB;YAC9B,KAAK,EAAE,WAAW;SACrB,CAAC;QAEF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAExC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;gBACV,IAAA,KAAwB,MAAM,CAAC,MAAM,EAAnC,SAAS,eAAA,EAAE,MAAM,YAAkB,CAAC;gBAC5C,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAEjD,IAAI,KAAK,IAAI,CAAC,EAAE;oBACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBACvC;aACJ;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,EACD,OAAO,EACP;YACI,iBAAiB,EAAE;gBACf,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC;gBACtC,iBAAiB,EAAE,sBAAsB,CAAC,MAAM,CAAC;aACpD;YACD,eAAe,EAAE,KAAK;SACzB,CACJ,CAAC;IACN,CAAC;IAr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AAI,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE;YACxB,MAAM,CAAC,MAAM,GAAG;gBACZ,IAAI,qDAAM,OAAO,CAAC,IAAI,SAAC;gBACvB,SAAS,EAAE,IAAI;gBACf,MAAM,QAAA;aACT,CAAC;SACL;IACL,CAAC;IAED,SAAS,yBAAyB,CAC9B,OAA0B,EAC1B,MAAyB,EACzB,gBAAsB;QAEhB,IAAA,KAAA,oBAAe,IAAA,wDAA0B,EAAC,OAAO,EAAE,gBAAgB,CAAC,IAAA,EAAnE,KAAK,QAAA,EAAE,GAAG,QAAyD,CAAC;QAC3E,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhF,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC","sourcesContent":["import {\n addSegment,\n addTextSegment,\n buildSelectionMarker,\n getRegularSelectionOffsets,\n processChildNode,\n} from 'roosterjs-content-model-dom';\nimport type {\n ElementProcessor,\n DOMInsertPoint,\n FormatContentModelOptions,\n IEditor,\n InsertPoint,\n DomToModelContext,\n ContentModelBlockGroup,\n ContentModelDocument,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Format content model at a given insert point with a callback function\n * @param editor The editor object\n * @param insertPoint The insert point to format\n * @param callback The callback function to format the content model\n * @param options Options to control the behavior of the formatting\n */\nexport function formatInsertPointWithContentModel(\n editor: IEditor,\n insertPoint: DOMInsertPoint,\n callback: (\n model: ContentModelDocument,\n context: FormatContentModelContext,\n insertPoint?: InsertPoint\n ) => void,\n options?: FormatContentModelOptions\n) {\n const bundle: InsertPointBundle = {\n input: insertPoint,\n };\n\n editor.formatContentModel(\n (model, context) => {\n callback(model, context, bundle.result);\n\n if (bundle?.result) {\n const { paragraph, marker } = bundle.result;\n const index = paragraph.segments.indexOf(marker);\n\n if (index >= 0) {\n paragraph.segments.splice(index, 1);\n }\n }\n return true;\n },\n options,\n {\n processorOverride: {\n child: getShadowChildProcessor(bundle),\n textWithSelection: getShadowTextProcessor(bundle),\n },\n tryGetFromCache: false,\n }\n );\n}\n\ninterface InsertPointBundle {\n input: DOMInsertPoint;\n result?: InsertPoint;\n}\n\ninterface DomToModelContextWithPath extends DomToModelContext {\n /**\n * Block group path of this insert point, from direct parent group to the root group\n */\n path?: ContentModelBlockGroup[];\n}\n\nfunction getShadowChildProcessor(bundle: InsertPointBundle): ElementProcessor<ParentNode> {\n return (group, parent, context) => {\n const contextWithPath = context as DomToModelContextWithPath;\n\n contextWithPath.path = contextWithPath.path || [];\n\n let shouldShiftPath = false;\n if (contextWithPath.path[0] != group) {\n contextWithPath.path.unshift(group);\n shouldShiftPath = true;\n }\n\n const offsets = getShadowSelectionOffsets(context, bundle, parent);\n let index = 0;\n\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n processChildNode(group, child, context);\n\n index++;\n }\n\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n if (shouldShiftPath) {\n contextWithPath.path.shift();\n }\n };\n}\n\nfunction handleElementShadowSelection(\n bundle: InsertPointBundle,\n index: number,\n context: DomToModelContext,\n group: ContentModelBlockGroup,\n offsets: [number, number, number],\n container?: Node\n) {\n if (\n index == offsets[2] &&\n (index <= offsets[0] || offsets[0] < 0) &&\n (index < offsets[1] || offsets[1] < 0)\n ) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[0]) {\n context.isInSelection = true;\n addSelectionMarker(group, context, container, index);\n }\n\n if (index == offsets[2] && (index < offsets[1] || offsets[1] < 0)) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[1]) {\n addSelectionMarker(group, context, container, index);\n context.isInSelection = false;\n }\n\n if (index == offsets[2]) {\n addSelectionMarker(group, context, container, index, bundle);\n }\n}\n\nconst getShadowTextProcessor = (bundle: InsertPointBundle): ElementProcessor<Text> => (\n group,\n textNode,\n context\n) => {\n let txt = textNode.nodeValue || '';\n const offsets = getShadowSelectionOffsets(context, bundle, textNode);\n const [start, end, shadow] = offsets;\n\n const handleTextSelection = (\n subtract: number,\n originalOffset: number,\n bundle?: InsertPointBundle\n ) => {\n addTextSegment(group, txt.substring(0, subtract), context);\n addSelectionMarker(group, context, textNode, originalOffset, bundle);\n\n offsets[0] -= subtract;\n offsets[1] -= subtract;\n offsets[2] = bundle ? -1 : offsets[2] - subtract;\n\n txt = txt.substring(subtract);\n };\n\n if (\n offsets[2] >= 0 &&\n (offsets[2] <= offsets[0] || offsets[0] < 0) &&\n (offsets[2] < offsets[1] || offsets[1] < 0)\n ) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[0] >= 0) {\n handleTextSelection(offsets[0], start);\n\n context.isInSelection = true;\n }\n\n if (offsets[2] >= 0 && offsets[2] > offsets[0] && (offsets[2] < offsets[1] || offsets[1] < 0)) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[1] >= 0) {\n handleTextSelection(offsets[1], end);\n\n context.isInSelection = false;\n }\n\n if (offsets[2] >= 0 && offsets[2] >= offsets[1]) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n addTextSegment(group, txt, context);\n};\n\nfunction addSelectionMarker(\n group: ContentModelBlockGroup,\n context: DomToModelContextWithPath,\n container?: Node,\n offset?: number,\n bundle?: InsertPointBundle\n) {\n const marker = buildSelectionMarker(group, context, container, offset);\n\n marker.isSelected = !bundle;\n\n const para = addSegment(group, marker, context.blockFormat, marker.format);\n\n if (bundle && context.path) {\n bundle.result = {\n path: [...context.path],\n paragraph: para,\n marker,\n };\n }\n}\n\nfunction getShadowSelectionOffsets(\n context: DomToModelContext,\n bundle: InsertPointBundle,\n currentContainer: Node\n): [number, number, number] {\n const [start, end] = getRegularSelectionOffsets(context, currentContainer);\n const shadow = bundle.input.node == currentContainer ? bundle.input.offset : -1;\n\n return [start, end, shadow];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"formatInsertPointWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatInsertPointWithContentModel.ts"],"names":[],"mappings":";;;;IAoBA;;;;;;OAMG;IACH,SAAgB,iCAAiC,CAC7C,MAAe,EACf,WAA2B,EAC3B,QAIS,EACT,OAAmC;QAEnC,IAAM,MAAM,GAAsB;YAC9B,KAAK,EAAE,WAAW;SACrB,CAAC;QAEF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAExC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;gBACV,IAAA,KAAwB,MAAM,CAAC,MAAM,EAAnC,SAAS,eAAA,EAAE,MAAM,YAAkB,CAAC;gBAC5C,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAEjD,IAAI,KAAK,IAAI,CAAC,EAAE;oBACZ,IAAA,yCAAW,EAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBACpD;aACJ;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,EACD,OAAO,EACP;YACI,iBAAiB,EAAE;gBACf,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC;gBACtC,iBAAiB,EAAE,sBAAsB,CAAC,MAAM,CAAC;aACpD;YACD,eAAe,EAAE,KAAK;SACzB,CACJ,CAAC;IACN,CAAC;IArCD,8EAqCC;IAcD,SAAS,uBAAuB,CAAC,MAAyB;QACtD,OAAO,UAAC,KAAK,EAAE,MAAM,EAAE,OAAO;YAC1B,IAAM,eAAe,GAAG,OAAoC,CAAC;YAE7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AI;gBACf,MAAM,QAAA;aACT,CAAC;SACL;IACL,CAAC;IAED,SAAS,yBAAyB,CAC9B,OAA0B,EAC1B,MAAyB,EACzB,gBAAsB;QAEhB,IAAA,KAAA,oBAAe,IAAA,wDAA0B,EAAC,OAAO,EAAE,gBAAgB,CAAC,IAAA,EAAnE,KAAK,QAAA,EAAE,GAAG,QAAyD,CAAC;QAC3E,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhF,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC","sourcesContent":["import {\n addSegment,\n addTextSegment,\n buildSelectionMarker,\n getRegularSelectionOffsets,\n mutateBlock,\n processChildNode,\n} from 'roosterjs-content-model-dom';\nimport type {\n ElementProcessor,\n DOMInsertPoint,\n FormatContentModelOptions,\n IEditor,\n InsertPoint,\n DomToModelContext,\n ContentModelBlockGroup,\n FormatContentModelContext,\n ShallowMutableContentModelDocument,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the content in a specific position using Content Model\n * @param editor The editor object\n * @param insertPoint The insert position.\n * @param callback The callback to insert the format.\n * @param options More options, @see FormatContentModelOptions\n */\nexport function formatInsertPointWithContentModel(\n editor: IEditor,\n insertPoint: DOMInsertPoint,\n callback: (\n model: ShallowMutableContentModelDocument,\n context: FormatContentModelContext,\n insertPoint?: InsertPoint\n ) => void,\n options?: FormatContentModelOptions\n) {\n const bundle: InsertPointBundle = {\n input: insertPoint,\n };\n\n editor.formatContentModel(\n (model, context) => {\n callback(model, context, bundle.result);\n\n if (bundle?.result) {\n const { paragraph, marker } = bundle.result;\n const index = paragraph.segments.indexOf(marker);\n\n if (index >= 0) {\n mutateBlock(paragraph).segments.splice(index, 1);\n }\n }\n return true;\n },\n options,\n {\n processorOverride: {\n child: getShadowChildProcessor(bundle),\n textWithSelection: getShadowTextProcessor(bundle),\n },\n tryGetFromCache: false,\n }\n );\n}\n\ninterface InsertPointBundle {\n input: DOMInsertPoint;\n result?: InsertPoint;\n}\n\ninterface DomToModelContextWithPath extends DomToModelContext {\n /**\n * Block group path of this insert point, from direct parent group to the root group\n */\n path?: ContentModelBlockGroup[];\n}\n\nfunction getShadowChildProcessor(bundle: InsertPointBundle): ElementProcessor<ParentNode> {\n return (group, parent, context) => {\n const contextWithPath = context as DomToModelContextWithPath;\n\n contextWithPath.path = contextWithPath.path || [];\n\n let shouldShiftPath = false;\n if (contextWithPath.path[0] != group) {\n contextWithPath.path.unshift(group);\n shouldShiftPath = true;\n }\n\n const offsets = getShadowSelectionOffsets(context, bundle, parent);\n let index = 0;\n\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n processChildNode(group, child, context);\n\n index++;\n }\n\n handleElementShadowSelection(bundle, index, context, group, offsets, parent);\n\n if (shouldShiftPath) {\n contextWithPath.path.shift();\n }\n };\n}\n\nfunction handleElementShadowSelection(\n bundle: InsertPointBundle,\n index: number,\n context: DomToModelContext,\n group: ContentModelBlockGroup,\n offsets: [number, number, number],\n container?: Node\n) {\n if (\n index == offsets[2] &&\n (index <= offsets[0] || offsets[0] < 0) &&\n (index < offsets[1] || offsets[1] < 0)\n ) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[0]) {\n context.isInSelection = true;\n addSelectionMarker(group, context, container, index);\n }\n\n if (index == offsets[2] && (index < offsets[1] || offsets[1] < 0)) {\n addSelectionMarker(group, context, container, index, bundle);\n offsets[2] = -1;\n }\n\n if (index == offsets[1]) {\n addSelectionMarker(group, context, container, index);\n context.isInSelection = false;\n }\n\n if (index == offsets[2]) {\n addSelectionMarker(group, context, container, index, bundle);\n }\n}\n\nconst getShadowTextProcessor = (bundle: InsertPointBundle): ElementProcessor<Text> => (\n group,\n textNode,\n context\n) => {\n let txt = textNode.nodeValue || '';\n const offsets = getShadowSelectionOffsets(context, bundle, textNode);\n const [start, end, shadow] = offsets;\n\n const handleTextSelection = (\n subtract: number,\n originalOffset: number,\n bundle?: InsertPointBundle\n ) => {\n addTextSegment(group, txt.substring(0, subtract), context);\n addSelectionMarker(group, context, textNode, originalOffset, bundle);\n\n offsets[0] -= subtract;\n offsets[1] -= subtract;\n offsets[2] = bundle ? -1 : offsets[2] - subtract;\n\n txt = txt.substring(subtract);\n };\n\n if (\n offsets[2] >= 0 &&\n (offsets[2] <= offsets[0] || offsets[0] < 0) &&\n (offsets[2] < offsets[1] || offsets[1] < 0)\n ) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[0] >= 0) {\n handleTextSelection(offsets[0], start);\n\n context.isInSelection = true;\n }\n\n if (offsets[2] >= 0 && offsets[2] > offsets[0] && (offsets[2] < offsets[1] || offsets[1] < 0)) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n if (offsets[1] >= 0) {\n handleTextSelection(offsets[1], end);\n\n context.isInSelection = false;\n }\n\n if (offsets[2] >= 0 && offsets[2] >= offsets[1]) {\n handleTextSelection(offsets[2], shadow, bundle);\n }\n\n addTextSegment(group, txt, context);\n};\n\nfunction addSelectionMarker(\n group: ContentModelBlockGroup,\n context: DomToModelContextWithPath,\n container?: Node,\n offset?: number,\n bundle?: InsertPointBundle\n) {\n const marker = buildSelectionMarker(group, context, container, offset);\n\n marker.isSelected = !bundle;\n\n const para = addSegment(group, marker, context.blockFormat, marker.format);\n\n if (bundle && context.path) {\n bundle.result = {\n path: [...context.path],\n paragraph: para,\n marker,\n };\n }\n}\n\nfunction getShadowSelectionOffsets(\n context: DomToModelContext,\n bundle: InsertPointBundle,\n currentContainer: Node\n): [number, number, number] {\n const [start, end] = getRegularSelectionOffsets(context, currentContainer);\n const shadow = bundle.input.node == currentContainer ? bundle.input.offset : -1;\n\n return [start, end, shadow];\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IEditor, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Invoke a callback to format the selected paragraph using Content Model
|
|
4
4
|
* @param editor The editor object
|
|
5
5
|
* @param apiName Name of API this calling this function. This is mostly for logging.
|
|
6
6
|
* @param setStyleCallback The callback to format the paragraph. It will be called with current selected table. If no table is selected, it will not be called.
|
|
7
7
|
*/
|
|
8
|
-
export declare function formatParagraphWithContentModel(editor: IEditor, apiName: string, setStyleCallback: (paragraph:
|
|
8
|
+
export declare function formatParagraphWithContentModel(editor: IEditor, apiName: string, setStyleCallback: (paragraph: ShallowMutableContentModelParagraph) => void): void;
|
|
@@ -10,7 +10,7 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
|
|
|
10
10
|
*/
|
|
11
11
|
function formatParagraphWithContentModel(editor, apiName, setStyleCallback) {
|
|
12
12
|
editor.formatContentModel(function (model, context) {
|
|
13
|
-
var paragraphs = (0, roosterjs_content_model_dom_1.getSelectedParagraphs)(model);
|
|
13
|
+
var paragraphs = (0, roosterjs_content_model_dom_1.getSelectedParagraphs)(model, true /*mutate*/);
|
|
14
14
|
paragraphs.forEach(setStyleCallback);
|
|
15
15
|
context.newPendingFormat = 'preserve';
|
|
16
16
|
return paragraphs.length > 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatParagraphWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatParagraphWithContentModel.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACH,SAAgB,+BAA+B,CAC3C,MAAe,EACf,OAAe,EACf,
|
|
1
|
+
{"version":3,"file":"formatParagraphWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatParagraphWithContentModel.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACH,SAAgB,+BAA+B,CAC3C,MAAe,EACf,OAAe,EACf,gBAA0E;QAE1E,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,UAAU,GAAG,IAAA,mDAAqB,EAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAEjE,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YACrC,OAAO,CAAC,gBAAgB,GAAG,UAAU,CAAC;YAEtC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACjC,CAAC,EACD;YACI,OAAO,SAAA;SACV,CACJ,CAAC;IACN,CAAC;IAlBD,0EAkBC","sourcesContent":["import { getSelectedParagraphs } from 'roosterjs-content-model-dom';\nimport type { IEditor, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected paragraph using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param setStyleCallback The callback to format the paragraph. It will be called with current selected table. If no table is selected, it will not be called.\n */\nexport function formatParagraphWithContentModel(\n editor: IEditor,\n apiName: string,\n setStyleCallback: (paragraph: ShallowMutableContentModelParagraph) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n const paragraphs = getSelectedParagraphs(model, true /*mutate*/);\n\n paragraphs.forEach(setStyleCallback);\n context.newPendingFormat = 'preserve';\n\n return paragraphs.length > 0;\n },\n {\n apiName,\n }\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelSegmentFormat, IEditor, ReadonlyContentModelDocument, ShallowMutableContentModelParagraph, ShallowMutableContentModelSegment } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Invoke a callback to format the selected segment using Content Model
|
|
4
4
|
* @param editor The editor object
|
|
@@ -8,4 +8,4 @@ import type { ContentModelDocument, ContentModelParagraph, ContentModelSegment,
|
|
|
8
8
|
* @param includingFormatHolder True to also include format holder of list item when search selected segments
|
|
9
9
|
* @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree
|
|
10
10
|
*/
|
|
11
|
-
export declare function formatSegmentWithContentModel(editor: IEditor, apiName: string, toggleStyleCallback: (format: ContentModelSegmentFormat, isTuringOn: boolean, segment:
|
|
11
|
+
export declare function formatSegmentWithContentModel(editor: IEditor, apiName: string, toggleStyleCallback: (format: ContentModelSegmentFormat, isTuringOn: boolean, segment: ShallowMutableContentModelSegment | null, paragraph: ShallowMutableContentModelParagraph | null) => void, segmentHasStyleCallback?: (format: ContentModelSegmentFormat, segment: ShallowMutableContentModelSegment | null, paragraph: ShallowMutableContentModelParagraph | null) => boolean, includingFormatHolder?: boolean, afterFormatCallback?: (model: ReadonlyContentModelDocument) => void): void;
|