roosterjs-content-model-api 0.27.0 → 9.0.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 +47 -37
- package/lib/index.d.ts +48 -42
- package/lib/index.js +56 -43
- package/lib/index.js.map +1 -1
- package/lib/modelApi/block/setModelAlignment.js +2 -2
- package/lib/modelApi/block/setModelAlignment.js.map +1 -1
- package/lib/modelApi/block/setModelDirection.js +5 -5
- package/lib/modelApi/block/setModelDirection.js.map +1 -1
- package/lib/modelApi/block/setModelIndentation.js +6 -7
- package/lib/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib/modelApi/block/toggleModelBlockQuote.js +3 -4
- package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib/modelApi/common/clearModelFormat.js +6 -7
- package/lib/modelApi/common/clearModelFormat.js.map +1 -1
- package/lib/modelApi/common/reducedModelChildProcessor.d.ts +20 -0
- package/lib/modelApi/common/reducedModelChildProcessor.js +64 -0
- package/lib/modelApi/common/reducedModelChildProcessor.js.map +1 -0
- package/lib/modelApi/common/wrapBlock.js.map +1 -1
- package/lib/modelApi/entity/insertEntityModel.d.ts +2 -2
- package/lib/modelApi/entity/insertEntityModel.js +19 -10
- package/lib/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib/modelApi/image/applyImageBorderFormat.d.ts +1 -1
- package/lib/modelApi/image/applyImageBorderFormat.js +3 -3
- package/lib/modelApi/image/applyImageBorderFormat.js.map +1 -1
- package/lib/modelApi/link/matchLink.d.ts +1 -18
- package/lib/modelApi/link/matchLink.js +0 -1
- package/lib/modelApi/link/matchLink.js.map +1 -1
- package/lib/modelApi/list/findListItemsInSameThread.js.map +1 -1
- package/lib/modelApi/list/setListType.js +3 -4
- package/lib/modelApi/list/setListType.js.map +1 -1
- package/lib/modelApi/list/setModelListStartNumber.d.ts +7 -0
- package/lib/modelApi/list/setModelListStartNumber.js +22 -0
- package/lib/modelApi/list/setModelListStartNumber.js.map +1 -0
- package/lib/modelApi/list/setModelListStyle.d.ts +7 -0
- package/lib/modelApi/list/setModelListStyle.js +26 -0
- package/lib/modelApi/list/setModelListStyle.js.map +1 -0
- package/lib/modelApi/selection/adjustSegmentSelection.js +3 -3
- package/lib/modelApi/selection/adjustSegmentSelection.js.map +1 -1
- package/lib/modelApi/selection/adjustTrailingSpaceSelection.js +1 -2
- package/lib/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
- package/lib/modelApi/selection/adjustWordSelection.js +3 -4
- package/lib/modelApi/selection/adjustWordSelection.js.map +1 -1
- package/lib/modelApi/selection/collapseTableSelection.js.map +1 -1
- package/lib/modelApi/table/alignTable.js.map +1 -1
- package/lib/modelApi/table/alignTableCell.js +3 -3
- package/lib/modelApi/table/alignTableCell.js.map +1 -1
- package/lib/modelApi/table/canMergeCells.js.map +1 -1
- package/lib/modelApi/table/clearSelectedCells.js +2 -2
- package/lib/modelApi/table/clearSelectedCells.js.map +1 -1
- package/lib/modelApi/table/createTableStructure.js.map +1 -1
- package/lib/modelApi/table/deleteTable.js.map +1 -1
- package/lib/modelApi/table/deleteTableColumn.js +2 -2
- package/lib/modelApi/table/deleteTableColumn.js.map +1 -1
- package/lib/modelApi/table/deleteTableRow.js +2 -2
- package/lib/modelApi/table/deleteTableRow.js.map +1 -1
- package/lib/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
- package/lib/modelApi/table/insertTableColumn.js +1 -2
- package/lib/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib/modelApi/table/insertTableRow.js +1 -2
- package/lib/modelApi/table/insertTableRow.js.map +1 -1
- package/lib/modelApi/table/mergeTableCells.js +2 -2
- package/lib/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib/modelApi/table/mergeTableColumn.js +2 -2
- package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib/modelApi/table/mergeTableRow.js +2 -2
- package/lib/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib/modelApi/table/splitTableCellHorizontally.js +1 -2
- package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
- package/lib/modelApi/table/splitTableCellVertically.js +1 -2
- package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
- package/lib/publicApi/block/setAlignment.d.ts +1 -1
- package/lib/publicApi/block/setAlignment.js +2 -1
- package/lib/publicApi/block/setAlignment.js.map +1 -1
- package/lib/publicApi/block/setDirection.d.ts +1 -1
- package/lib/publicApi/block/setDirection.js +2 -1
- package/lib/publicApi/block/setDirection.js.map +1 -1
- package/lib/publicApi/block/setHeadingLevel.d.ts +1 -1
- package/lib/publicApi/block/setHeadingLevel.js +2 -1
- package/lib/publicApi/block/setHeadingLevel.js.map +1 -1
- package/lib/publicApi/block/setIndentation.d.ts +1 -1
- package/lib/publicApi/block/setIndentation.js +2 -1
- package/lib/publicApi/block/setIndentation.js.map +1 -1
- package/lib/publicApi/block/setParagraphMargin.d.ts +1 -1
- package/lib/publicApi/block/setParagraphMargin.js +2 -1
- package/lib/publicApi/block/setParagraphMargin.js.map +1 -1
- package/lib/publicApi/block/setSpacing.d.ts +1 -1
- package/lib/publicApi/block/setSpacing.js +2 -1
- package/lib/publicApi/block/setSpacing.js.map +1 -1
- package/lib/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib/publicApi/block/toggleBlockQuote.js +2 -1
- package/lib/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib/publicApi/entity/insertEntity.d.ts +3 -3
- package/lib/publicApi/entity/insertEntity.js +19 -12
- package/lib/publicApi/entity/insertEntity.js.map +1 -1
- package/lib/publicApi/format/clearFormat.d.ts +1 -1
- package/lib/publicApi/format/clearFormat.js +2 -1
- package/lib/publicApi/format/clearFormat.js.map +1 -1
- package/lib/publicApi/format/getFormatState.d.ts +1 -1
- package/lib/publicApi/format/getFormatState.js +13 -4
- package/lib/publicApi/format/getFormatState.js.map +1 -1
- package/lib/publicApi/image/adjustImageSelection.d.ts +1 -1
- package/lib/publicApi/image/adjustImageSelection.js +2 -1
- package/lib/publicApi/image/adjustImageSelection.js.map +1 -1
- package/lib/publicApi/image/changeImage.d.ts +1 -1
- package/lib/publicApi/image/changeImage.js +6 -5
- package/lib/publicApi/image/changeImage.js.map +1 -1
- package/lib/publicApi/image/insertImage.d.ts +1 -1
- package/lib/publicApi/image/insertImage.js +4 -4
- package/lib/publicApi/image/insertImage.js.map +1 -1
- package/lib/publicApi/image/setImageAltText.d.ts +1 -1
- package/lib/publicApi/image/setImageAltText.js +3 -2
- package/lib/publicApi/image/setImageAltText.js.map +1 -1
- package/lib/publicApi/image/setImageBorder.d.ts +1 -1
- package/lib/publicApi/image/setImageBorder.js +4 -3
- package/lib/publicApi/image/setImageBorder.js.map +1 -1
- package/lib/publicApi/image/setImageBoxShadow.d.ts +1 -1
- package/lib/publicApi/image/setImageBoxShadow.js +3 -2
- package/lib/publicApi/image/setImageBoxShadow.js.map +1 -1
- package/lib/publicApi/link/adjustLinkSelection.d.ts +1 -1
- package/lib/publicApi/link/adjustLinkSelection.js +5 -4
- package/lib/publicApi/link/adjustLinkSelection.js.map +1 -1
- package/lib/publicApi/link/insertLink.d.ts +1 -1
- package/lib/publicApi/link/insertLink.js +5 -5
- package/lib/publicApi/link/insertLink.js.map +1 -1
- package/lib/publicApi/link/removeLink.d.ts +1 -1
- package/lib/publicApi/link/removeLink.js +4 -3
- package/lib/publicApi/link/removeLink.js.map +1 -1
- package/lib/publicApi/list/setListStartNumber.d.ts +1 -1
- package/lib/publicApi/list/setListStartNumber.js +4 -11
- package/lib/publicApi/list/setListStartNumber.js.map +1 -1
- package/lib/publicApi/list/setListStyle.d.ts +1 -1
- package/lib/publicApi/list/setListStyle.js +4 -18
- package/lib/publicApi/list/setListStyle.js.map +1 -1
- package/lib/publicApi/list/toggleBullet.d.ts +1 -1
- package/lib/publicApi/list/toggleBullet.js +2 -1
- package/lib/publicApi/list/toggleBullet.js.map +1 -1
- package/lib/publicApi/list/toggleNumbering.d.ts +1 -1
- package/lib/publicApi/list/toggleNumbering.js +2 -1
- package/lib/publicApi/list/toggleNumbering.js.map +1 -1
- package/lib/publicApi/segment/applySegmentFormat.d.ts +1 -1
- package/lib/publicApi/segment/applySegmentFormat.js +2 -1
- package/lib/publicApi/segment/applySegmentFormat.js.map +1 -1
- package/lib/publicApi/segment/changeCapitalization.d.ts +1 -1
- package/lib/publicApi/segment/changeCapitalization.js +2 -1
- package/lib/publicApi/segment/changeCapitalization.js.map +1 -1
- package/lib/publicApi/segment/changeFontSize.d.ts +1 -1
- package/lib/publicApi/segment/changeFontSize.js +2 -1
- package/lib/publicApi/segment/changeFontSize.js.map +1 -1
- package/lib/publicApi/segment/setBackgroundColor.d.ts +1 -1
- package/lib/publicApi/segment/setBackgroundColor.js +3 -3
- package/lib/publicApi/segment/setBackgroundColor.js.map +1 -1
- package/lib/publicApi/segment/setFontName.d.ts +1 -1
- package/lib/publicApi/segment/setFontName.js +2 -1
- package/lib/publicApi/segment/setFontName.js.map +1 -1
- package/lib/publicApi/segment/setFontSize.d.ts +1 -1
- package/lib/publicApi/segment/setFontSize.js +2 -2
- package/lib/publicApi/segment/setFontSize.js.map +1 -1
- package/lib/publicApi/segment/setTextColor.d.ts +1 -1
- package/lib/publicApi/segment/setTextColor.js +2 -1
- package/lib/publicApi/segment/setTextColor.js.map +1 -1
- package/lib/publicApi/segment/toggleBold.d.ts +1 -1
- package/lib/publicApi/segment/toggleBold.js +4 -3
- package/lib/publicApi/segment/toggleBold.js.map +1 -1
- package/lib/publicApi/segment/toggleCode.d.ts +1 -1
- package/lib/publicApi/segment/toggleCode.js +2 -1
- package/lib/publicApi/segment/toggleCode.js.map +1 -1
- package/lib/publicApi/segment/toggleItalic.d.ts +1 -1
- package/lib/publicApi/segment/toggleItalic.js +2 -1
- package/lib/publicApi/segment/toggleItalic.js.map +1 -1
- package/lib/publicApi/segment/toggleStrikethrough.d.ts +1 -1
- package/lib/publicApi/segment/toggleStrikethrough.js +2 -1
- package/lib/publicApi/segment/toggleStrikethrough.js.map +1 -1
- package/lib/publicApi/segment/toggleSubscript.d.ts +1 -1
- package/lib/publicApi/segment/toggleSubscript.js +2 -1
- package/lib/publicApi/segment/toggleSubscript.js.map +1 -1
- package/lib/publicApi/segment/toggleSuperscript.d.ts +1 -1
- package/lib/publicApi/segment/toggleSuperscript.js +2 -1
- package/lib/publicApi/segment/toggleSuperscript.js.map +1 -1
- package/lib/publicApi/segment/toggleUnderline.d.ts +1 -1
- package/lib/publicApi/segment/toggleUnderline.js +2 -1
- package/lib/publicApi/segment/toggleUnderline.js.map +1 -1
- package/lib/publicApi/table/applyTableBorderFormat.d.ts +1 -1
- package/lib/publicApi/table/applyTableBorderFormat.js +6 -6
- package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib/publicApi/table/editTable.d.ts +1 -1
- package/lib/publicApi/table/editTable.js +2 -1
- package/lib/publicApi/table/editTable.js.map +1 -1
- package/lib/publicApi/table/formatTable.d.ts +1 -1
- package/lib/publicApi/table/formatTable.js +6 -5
- package/lib/publicApi/table/formatTable.js.map +1 -1
- package/lib/publicApi/table/insertTable.d.ts +1 -1
- package/lib/publicApi/table/insertTable.js +8 -8
- package/lib/publicApi/table/insertTable.js.map +1 -1
- package/lib/publicApi/table/setTableCellShade.d.ts +1 -1
- package/lib/publicApi/table/setTableCellShade.js +7 -6
- package/lib/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib/publicApi/utils/formatImageWithContentModel.d.ts +5 -2
- package/lib/publicApi/utils/formatImageWithContentModel.js +6 -2
- package/lib/publicApi/utils/formatImageWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -0
- package/lib/publicApi/utils/formatInsertPointWithContentModel.js +127 -0
- package/lib/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -0
- package/lib/publicApi/utils/formatParagraphWithContentModel.d.ts +4 -1
- package/lib/publicApi/utils/formatParagraphWithContentModel.js +6 -3
- package/lib/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatSegmentWithContentModel.d.ts +7 -1
- package/lib/publicApi/utils/formatSegmentWithContentModel.js +9 -3
- package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- package/lib/publicApi/utils/formatTableWithContentModel.js +5 -6
- package/lib/publicApi/utils/formatTableWithContentModel.js.map +1 -1
- package/lib-amd/index.d.ts +48 -42
- package/lib-amd/index.js +50 -44
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/modelApi/block/setModelAlignment.js +2 -2
- package/lib-amd/modelApi/block/setModelAlignment.js.map +1 -1
- package/lib-amd/modelApi/block/setModelDirection.js +5 -5
- package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-amd/modelApi/block/setModelIndentation.js +6 -6
- package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js +3 -3
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-amd/modelApi/common/clearModelFormat.js +7 -7
- package/lib-amd/modelApi/common/clearModelFormat.js.map +1 -1
- package/lib-amd/modelApi/common/reducedModelChildProcessor.d.ts +20 -0
- package/lib-amd/modelApi/common/reducedModelChildProcessor.js +64 -0
- package/lib-amd/modelApi/common/reducedModelChildProcessor.js.map +1 -0
- 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 +20 -10
- package/lib-amd/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib-amd/modelApi/image/applyImageBorderFormat.d.ts +1 -1
- package/lib-amd/modelApi/image/applyImageBorderFormat.js +4 -3
- package/lib-amd/modelApi/image/applyImageBorderFormat.js.map +1 -1
- package/lib-amd/modelApi/link/matchLink.d.ts +1 -18
- package/lib-amd/modelApi/link/matchLink.js +0 -1
- package/lib-amd/modelApi/link/matchLink.js.map +1 -1
- package/lib-amd/modelApi/list/findListItemsInSameThread.js.map +1 -1
- package/lib-amd/modelApi/list/setListType.js +4 -4
- package/lib-amd/modelApi/list/setListType.js.map +1 -1
- package/lib-amd/modelApi/list/setModelListStartNumber.d.ts +7 -0
- package/lib-amd/modelApi/list/setModelListStartNumber.js +23 -0
- package/lib-amd/modelApi/list/setModelListStartNumber.js.map +1 -0
- package/lib-amd/modelApi/list/setModelListStyle.d.ts +7 -0
- package/lib-amd/modelApi/list/setModelListStyle.js +26 -0
- package/lib-amd/modelApi/list/setModelListStyle.js.map +1 -0
- 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.js +2 -2
- package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
- package/lib-amd/modelApi/selection/adjustWordSelection.js +4 -4
- package/lib-amd/modelApi/selection/adjustWordSelection.js.map +1 -1
- package/lib-amd/modelApi/selection/collapseTableSelection.js.map +1 -1
- package/lib-amd/modelApi/table/alignTable.js.map +1 -1
- package/lib-amd/modelApi/table/alignTableCell.js +3 -3
- package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
- package/lib-amd/modelApi/table/canMergeCells.js.map +1 -1
- package/lib-amd/modelApi/table/clearSelectedCells.js +2 -2
- package/lib-amd/modelApi/table/clearSelectedCells.js.map +1 -1
- package/lib-amd/modelApi/table/createTableStructure.js.map +1 -1
- package/lib-amd/modelApi/table/deleteTable.js.map +1 -1
- package/lib-amd/modelApi/table/deleteTableColumn.js +2 -2
- package/lib-amd/modelApi/table/deleteTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/deleteTableRow.js +2 -2
- package/lib-amd/modelApi/table/deleteTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
- package/lib-amd/modelApi/table/insertTableColumn.js +2 -2
- package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/insertTableRow.js +2 -2
- package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableCells.js +2 -2
- package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableColumn.js +2 -2
- package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableRow.js +2 -2
- package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/splitTableCellHorizontally.js +2 -2
- package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
- package/lib-amd/modelApi/table/splitTableCellVertically.js +2 -2
- package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
- package/lib-amd/publicApi/block/setAlignment.d.ts +1 -1
- package/lib-amd/publicApi/block/setAlignment.js +2 -1
- package/lib-amd/publicApi/block/setAlignment.js.map +1 -1
- package/lib-amd/publicApi/block/setDirection.d.ts +1 -1
- package/lib-amd/publicApi/block/setDirection.js +2 -1
- package/lib-amd/publicApi/block/setDirection.js.map +1 -1
- package/lib-amd/publicApi/block/setHeadingLevel.d.ts +1 -1
- package/lib-amd/publicApi/block/setHeadingLevel.js +2 -1
- package/lib-amd/publicApi/block/setHeadingLevel.js.map +1 -1
- package/lib-amd/publicApi/block/setIndentation.d.ts +1 -1
- package/lib-amd/publicApi/block/setIndentation.js +2 -1
- package/lib-amd/publicApi/block/setIndentation.js.map +1 -1
- package/lib-amd/publicApi/block/setParagraphMargin.d.ts +1 -1
- package/lib-amd/publicApi/block/setParagraphMargin.js +2 -1
- package/lib-amd/publicApi/block/setParagraphMargin.js.map +1 -1
- package/lib-amd/publicApi/block/setSpacing.d.ts +1 -1
- package/lib-amd/publicApi/block/setSpacing.js +2 -1
- package/lib-amd/publicApi/block/setSpacing.js.map +1 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.js +2 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib-amd/publicApi/entity/insertEntity.d.ts +3 -3
- package/lib-amd/publicApi/entity/insertEntity.js +19 -12
- package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-amd/publicApi/format/clearFormat.d.ts +1 -1
- package/lib-amd/publicApi/format/clearFormat.js +2 -1
- package/lib-amd/publicApi/format/clearFormat.js.map +1 -1
- package/lib-amd/publicApi/format/getFormatState.d.ts +1 -1
- package/lib-amd/publicApi/format/getFormatState.js +12 -4
- package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
- package/lib-amd/publicApi/image/adjustImageSelection.d.ts +1 -1
- package/lib-amd/publicApi/image/adjustImageSelection.js +2 -1
- package/lib-amd/publicApi/image/adjustImageSelection.js.map +1 -1
- package/lib-amd/publicApi/image/changeImage.d.ts +1 -1
- package/lib-amd/publicApi/image/changeImage.js +6 -5
- package/lib-amd/publicApi/image/changeImage.js.map +1 -1
- package/lib-amd/publicApi/image/insertImage.d.ts +1 -1
- package/lib-amd/publicApi/image/insertImage.js +5 -4
- package/lib-amd/publicApi/image/insertImage.js.map +1 -1
- package/lib-amd/publicApi/image/setImageAltText.d.ts +1 -1
- package/lib-amd/publicApi/image/setImageAltText.js +3 -2
- package/lib-amd/publicApi/image/setImageAltText.js.map +1 -1
- package/lib-amd/publicApi/image/setImageBorder.d.ts +1 -1
- package/lib-amd/publicApi/image/setImageBorder.js +4 -3
- package/lib-amd/publicApi/image/setImageBorder.js.map +1 -1
- package/lib-amd/publicApi/image/setImageBoxShadow.d.ts +1 -1
- package/lib-amd/publicApi/image/setImageBoxShadow.js +3 -2
- package/lib-amd/publicApi/image/setImageBoxShadow.js.map +1 -1
- package/lib-amd/publicApi/link/adjustLinkSelection.d.ts +1 -1
- package/lib-amd/publicApi/link/adjustLinkSelection.js +5 -4
- package/lib-amd/publicApi/link/adjustLinkSelection.js.map +1 -1
- package/lib-amd/publicApi/link/insertLink.d.ts +1 -1
- package/lib-amd/publicApi/link/insertLink.js +6 -5
- package/lib-amd/publicApi/link/insertLink.js.map +1 -1
- package/lib-amd/publicApi/link/removeLink.d.ts +1 -1
- package/lib-amd/publicApi/link/removeLink.js +4 -3
- package/lib-amd/publicApi/link/removeLink.js.map +1 -1
- package/lib-amd/publicApi/list/setListStartNumber.d.ts +1 -1
- package/lib-amd/publicApi/list/setListStartNumber.js +4 -11
- package/lib-amd/publicApi/list/setListStartNumber.js.map +1 -1
- package/lib-amd/publicApi/list/setListStyle.d.ts +1 -1
- package/lib-amd/publicApi/list/setListStyle.js +4 -17
- package/lib-amd/publicApi/list/setListStyle.js.map +1 -1
- package/lib-amd/publicApi/list/toggleBullet.d.ts +1 -1
- package/lib-amd/publicApi/list/toggleBullet.js +2 -1
- package/lib-amd/publicApi/list/toggleBullet.js.map +1 -1
- package/lib-amd/publicApi/list/toggleNumbering.d.ts +1 -1
- package/lib-amd/publicApi/list/toggleNumbering.js +2 -1
- package/lib-amd/publicApi/list/toggleNumbering.js.map +1 -1
- package/lib-amd/publicApi/segment/applySegmentFormat.d.ts +1 -1
- package/lib-amd/publicApi/segment/applySegmentFormat.js +2 -1
- package/lib-amd/publicApi/segment/applySegmentFormat.js.map +1 -1
- package/lib-amd/publicApi/segment/changeCapitalization.d.ts +1 -1
- package/lib-amd/publicApi/segment/changeCapitalization.js +2 -1
- package/lib-amd/publicApi/segment/changeCapitalization.js.map +1 -1
- package/lib-amd/publicApi/segment/changeFontSize.d.ts +1 -1
- package/lib-amd/publicApi/segment/changeFontSize.js +2 -1
- package/lib-amd/publicApi/segment/changeFontSize.js.map +1 -1
- package/lib-amd/publicApi/segment/setBackgroundColor.d.ts +1 -1
- package/lib-amd/publicApi/segment/setBackgroundColor.js +4 -3
- package/lib-amd/publicApi/segment/setBackgroundColor.js.map +1 -1
- package/lib-amd/publicApi/segment/setFontName.d.ts +1 -1
- package/lib-amd/publicApi/segment/setFontName.js +2 -1
- package/lib-amd/publicApi/segment/setFontName.js.map +1 -1
- package/lib-amd/publicApi/segment/setFontSize.d.ts +1 -1
- package/lib-amd/publicApi/segment/setFontSize.js +2 -2
- package/lib-amd/publicApi/segment/setFontSize.js.map +1 -1
- package/lib-amd/publicApi/segment/setTextColor.d.ts +1 -1
- package/lib-amd/publicApi/segment/setTextColor.js +2 -1
- package/lib-amd/publicApi/segment/setTextColor.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleBold.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleBold.js +4 -3
- package/lib-amd/publicApi/segment/toggleBold.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleCode.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleCode.js +2 -1
- package/lib-amd/publicApi/segment/toggleCode.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleItalic.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleItalic.js +2 -1
- package/lib-amd/publicApi/segment/toggleItalic.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleStrikethrough.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleStrikethrough.js +2 -1
- package/lib-amd/publicApi/segment/toggleStrikethrough.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleSubscript.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleSubscript.js +2 -1
- package/lib-amd/publicApi/segment/toggleSubscript.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleSuperscript.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleSuperscript.js +2 -1
- package/lib-amd/publicApi/segment/toggleSuperscript.js.map +1 -1
- package/lib-amd/publicApi/segment/toggleUnderline.d.ts +1 -1
- package/lib-amd/publicApi/segment/toggleUnderline.js +2 -1
- package/lib-amd/publicApi/segment/toggleUnderline.js.map +1 -1
- package/lib-amd/publicApi/table/applyTableBorderFormat.d.ts +1 -1
- package/lib-amd/publicApi/table/applyTableBorderFormat.js +7 -6
- package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-amd/publicApi/table/editTable.d.ts +1 -1
- package/lib-amd/publicApi/table/editTable.js +2 -1
- package/lib-amd/publicApi/table/editTable.js.map +1 -1
- package/lib-amd/publicApi/table/formatTable.d.ts +1 -1
- package/lib-amd/publicApi/table/formatTable.js +6 -5
- package/lib-amd/publicApi/table/formatTable.js.map +1 -1
- package/lib-amd/publicApi/table/insertTable.d.ts +1 -1
- package/lib-amd/publicApi/table/insertTable.js +8 -7
- package/lib-amd/publicApi/table/insertTable.js.map +1 -1
- package/lib-amd/publicApi/table/setTableCellShade.d.ts +1 -1
- package/lib-amd/publicApi/table/setTableCellShade.js +7 -6
- package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
- package/lib-amd/publicApi/utils/formatImageWithContentModel.d.ts +5 -2
- package/lib-amd/publicApi/utils/formatImageWithContentModel.js +6 -2
- package/lib-amd/publicApi/utils/formatImageWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -0
- package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js +127 -0
- package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -0
- package/lib-amd/publicApi/utils/formatParagraphWithContentModel.d.ts +4 -1
- package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js +6 -3
- package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.d.ts +7 -1
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +9 -3
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- package/lib-amd/publicApi/utils/formatTableWithContentModel.js +6 -6
- package/lib-amd/publicApi/utils/formatTableWithContentModel.js.map +1 -1
- package/lib-mjs/index.d.ts +48 -42
- package/lib-mjs/index.js +48 -42
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelAlignment.js +1 -1
- package/lib-mjs/modelApi/block/setModelAlignment.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelDirection.js +1 -1
- package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelIndentation.js +1 -2
- package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js +1 -2
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-mjs/modelApi/common/clearModelFormat.js +1 -2
- package/lib-mjs/modelApi/common/clearModelFormat.js.map +1 -1
- package/lib-mjs/modelApi/common/reducedModelChildProcessor.d.ts +20 -0
- package/lib-mjs/modelApi/common/reducedModelChildProcessor.js +60 -0
- package/lib-mjs/modelApi/common/reducedModelChildProcessor.js.map +1 -0
- 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 +18 -9
- package/lib-mjs/modelApi/entity/insertEntityModel.js.map +1 -1
- package/lib-mjs/modelApi/image/applyImageBorderFormat.d.ts +1 -1
- package/lib-mjs/modelApi/image/applyImageBorderFormat.js +2 -3
- package/lib-mjs/modelApi/image/applyImageBorderFormat.js.map +1 -1
- package/lib-mjs/modelApi/link/matchLink.d.ts +1 -18
- package/lib-mjs/modelApi/link/matchLink.js +0 -1
- package/lib-mjs/modelApi/link/matchLink.js.map +1 -1
- package/lib-mjs/modelApi/list/findListItemsInSameThread.js.map +1 -1
- package/lib-mjs/modelApi/list/setListType.js +1 -2
- package/lib-mjs/modelApi/list/setListType.js.map +1 -1
- package/lib-mjs/modelApi/list/setModelListStartNumber.d.ts +7 -0
- package/lib-mjs/modelApi/list/setModelListStartNumber.js +18 -0
- package/lib-mjs/modelApi/list/setModelListStartNumber.js.map +1 -0
- package/lib-mjs/modelApi/list/setModelListStyle.d.ts +7 -0
- package/lib-mjs/modelApi/list/setModelListStyle.js +22 -0
- package/lib-mjs/modelApi/list/setModelListStyle.js.map +1 -0
- package/lib-mjs/modelApi/selection/adjustSegmentSelection.js +1 -1
- package/lib-mjs/modelApi/selection/adjustSegmentSelection.js.map +1 -1
- package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js +1 -2
- package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
- package/lib-mjs/modelApi/selection/adjustWordSelection.js +1 -2
- package/lib-mjs/modelApi/selection/adjustWordSelection.js.map +1 -1
- package/lib-mjs/modelApi/selection/collapseTableSelection.js.map +1 -1
- package/lib-mjs/modelApi/table/alignTable.js.map +1 -1
- package/lib-mjs/modelApi/table/alignTableCell.js +1 -1
- package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
- package/lib-mjs/modelApi/table/canMergeCells.js.map +1 -1
- package/lib-mjs/modelApi/table/clearSelectedCells.js +1 -1
- package/lib-mjs/modelApi/table/clearSelectedCells.js.map +1 -1
- package/lib-mjs/modelApi/table/createTableStructure.js.map +1 -1
- package/lib-mjs/modelApi/table/deleteTable.js.map +1 -1
- package/lib-mjs/modelApi/table/deleteTableColumn.js +1 -1
- package/lib-mjs/modelApi/table/deleteTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/deleteTableRow.js +1 -1
- package/lib-mjs/modelApi/table/deleteTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
- package/lib-mjs/modelApi/table/insertTableColumn.js +1 -2
- package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/insertTableRow.js +1 -2
- package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableCells.js +1 -1
- package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableColumn.js +1 -1
- package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableRow.js +1 -1
- package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +1 -2
- package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
- package/lib-mjs/modelApi/table/splitTableCellVertically.js +1 -2
- package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
- package/lib-mjs/publicApi/block/setAlignment.d.ts +1 -1
- package/lib-mjs/publicApi/block/setAlignment.js +1 -1
- package/lib-mjs/publicApi/block/setAlignment.js.map +1 -1
- package/lib-mjs/publicApi/block/setDirection.d.ts +1 -1
- package/lib-mjs/publicApi/block/setDirection.js +1 -1
- package/lib-mjs/publicApi/block/setDirection.js.map +1 -1
- package/lib-mjs/publicApi/block/setHeadingLevel.d.ts +1 -1
- package/lib-mjs/publicApi/block/setHeadingLevel.js +1 -1
- package/lib-mjs/publicApi/block/setHeadingLevel.js.map +1 -1
- package/lib-mjs/publicApi/block/setIndentation.d.ts +1 -1
- package/lib-mjs/publicApi/block/setIndentation.js +1 -1
- package/lib-mjs/publicApi/block/setIndentation.js.map +1 -1
- package/lib-mjs/publicApi/block/setParagraphMargin.d.ts +1 -1
- package/lib-mjs/publicApi/block/setParagraphMargin.js +1 -1
- package/lib-mjs/publicApi/block/setParagraphMargin.js.map +1 -1
- package/lib-mjs/publicApi/block/setSpacing.d.ts +1 -1
- package/lib-mjs/publicApi/block/setSpacing.js +1 -1
- package/lib-mjs/publicApi/block/setSpacing.js.map +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.js +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib-mjs/publicApi/entity/insertEntity.d.ts +3 -3
- package/lib-mjs/publicApi/entity/insertEntity.js +18 -12
- package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-mjs/publicApi/format/clearFormat.d.ts +1 -1
- package/lib-mjs/publicApi/format/clearFormat.js +1 -1
- package/lib-mjs/publicApi/format/clearFormat.js.map +1 -1
- package/lib-mjs/publicApi/format/getFormatState.d.ts +1 -1
- package/lib-mjs/publicApi/format/getFormatState.js +12 -4
- package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
- package/lib-mjs/publicApi/image/adjustImageSelection.d.ts +1 -1
- package/lib-mjs/publicApi/image/adjustImageSelection.js +1 -1
- package/lib-mjs/publicApi/image/adjustImageSelection.js.map +1 -1
- package/lib-mjs/publicApi/image/changeImage.d.ts +1 -1
- package/lib-mjs/publicApi/image/changeImage.js +3 -3
- package/lib-mjs/publicApi/image/changeImage.js.map +1 -1
- package/lib-mjs/publicApi/image/insertImage.d.ts +1 -1
- package/lib-mjs/publicApi/image/insertImage.js +2 -3
- package/lib-mjs/publicApi/image/insertImage.js.map +1 -1
- package/lib-mjs/publicApi/image/setImageAltText.d.ts +1 -1
- package/lib-mjs/publicApi/image/setImageAltText.js +2 -2
- package/lib-mjs/publicApi/image/setImageAltText.js.map +1 -1
- package/lib-mjs/publicApi/image/setImageBorder.d.ts +1 -1
- package/lib-mjs/publicApi/image/setImageBorder.js +3 -3
- package/lib-mjs/publicApi/image/setImageBorder.js.map +1 -1
- package/lib-mjs/publicApi/image/setImageBoxShadow.d.ts +1 -1
- package/lib-mjs/publicApi/image/setImageBoxShadow.js +2 -2
- package/lib-mjs/publicApi/image/setImageBoxShadow.js.map +1 -1
- package/lib-mjs/publicApi/link/adjustLinkSelection.d.ts +1 -1
- package/lib-mjs/publicApi/link/adjustLinkSelection.js +2 -2
- package/lib-mjs/publicApi/link/adjustLinkSelection.js.map +1 -1
- package/lib-mjs/publicApi/link/insertLink.d.ts +1 -1
- package/lib-mjs/publicApi/link/insertLink.js +2 -3
- package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
- package/lib-mjs/publicApi/link/removeLink.d.ts +1 -1
- package/lib-mjs/publicApi/link/removeLink.js +2 -2
- package/lib-mjs/publicApi/link/removeLink.js.map +1 -1
- package/lib-mjs/publicApi/list/setListStartNumber.d.ts +1 -1
- package/lib-mjs/publicApi/list/setListStartNumber.js +3 -11
- package/lib-mjs/publicApi/list/setListStartNumber.js.map +1 -1
- package/lib-mjs/publicApi/list/setListStyle.d.ts +1 -1
- package/lib-mjs/publicApi/list/setListStyle.js +3 -18
- package/lib-mjs/publicApi/list/setListStyle.js.map +1 -1
- package/lib-mjs/publicApi/list/toggleBullet.d.ts +1 -1
- package/lib-mjs/publicApi/list/toggleBullet.js +1 -1
- package/lib-mjs/publicApi/list/toggleBullet.js.map +1 -1
- package/lib-mjs/publicApi/list/toggleNumbering.d.ts +1 -1
- package/lib-mjs/publicApi/list/toggleNumbering.js +1 -1
- package/lib-mjs/publicApi/list/toggleNumbering.js.map +1 -1
- package/lib-mjs/publicApi/segment/applySegmentFormat.d.ts +1 -1
- package/lib-mjs/publicApi/segment/applySegmentFormat.js +1 -1
- package/lib-mjs/publicApi/segment/applySegmentFormat.js.map +1 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.d.ts +1 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.js +1 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.js.map +1 -1
- package/lib-mjs/publicApi/segment/changeFontSize.d.ts +1 -1
- package/lib-mjs/publicApi/segment/changeFontSize.js +1 -1
- package/lib-mjs/publicApi/segment/changeFontSize.js.map +1 -1
- package/lib-mjs/publicApi/segment/setBackgroundColor.d.ts +1 -1
- package/lib-mjs/publicApi/segment/setBackgroundColor.js +2 -3
- package/lib-mjs/publicApi/segment/setBackgroundColor.js.map +1 -1
- package/lib-mjs/publicApi/segment/setFontName.d.ts +1 -1
- package/lib-mjs/publicApi/segment/setFontName.js +1 -1
- package/lib-mjs/publicApi/segment/setFontName.js.map +1 -1
- package/lib-mjs/publicApi/segment/setFontSize.d.ts +1 -1
- package/lib-mjs/publicApi/segment/setFontSize.js +1 -1
- package/lib-mjs/publicApi/segment/setFontSize.js.map +1 -1
- package/lib-mjs/publicApi/segment/setTextColor.d.ts +1 -1
- package/lib-mjs/publicApi/segment/setTextColor.js +1 -1
- package/lib-mjs/publicApi/segment/setTextColor.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleBold.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleBold.js +2 -2
- package/lib-mjs/publicApi/segment/toggleBold.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleCode.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleCode.js +1 -1
- package/lib-mjs/publicApi/segment/toggleCode.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleItalic.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleItalic.js +1 -1
- package/lib-mjs/publicApi/segment/toggleItalic.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleStrikethrough.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleStrikethrough.js +1 -1
- package/lib-mjs/publicApi/segment/toggleStrikethrough.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleSubscript.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleSubscript.js +1 -1
- package/lib-mjs/publicApi/segment/toggleSubscript.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleSuperscript.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleSuperscript.js +1 -1
- package/lib-mjs/publicApi/segment/toggleSuperscript.js.map +1 -1
- package/lib-mjs/publicApi/segment/toggleUnderline.d.ts +1 -1
- package/lib-mjs/publicApi/segment/toggleUnderline.js +1 -1
- package/lib-mjs/publicApi/segment/toggleUnderline.js.map +1 -1
- package/lib-mjs/publicApi/table/applyTableBorderFormat.d.ts +1 -1
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js +2 -3
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-mjs/publicApi/table/editTable.d.ts +1 -1
- package/lib-mjs/publicApi/table/editTable.js +1 -1
- package/lib-mjs/publicApi/table/editTable.js.map +1 -1
- package/lib-mjs/publicApi/table/formatTable.d.ts +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/insertTable.d.ts +1 -1
- package/lib-mjs/publicApi/table/insertTable.js +2 -3
- package/lib-mjs/publicApi/table/insertTable.js.map +1 -1
- package/lib-mjs/publicApi/table/setTableCellShade.d.ts +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/formatImageWithContentModel.d.ts +5 -2
- package/lib-mjs/publicApi/utils/formatImageWithContentModel.js +5 -2
- package/lib-mjs/publicApi/utils/formatImageWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -0
- package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js +123 -0
- package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -0
- package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.d.ts +4 -1
- package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js +5 -2
- package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.d.ts +7 -1
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +8 -2
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- package/lib-mjs/publicApi/utils/formatTableWithContentModel.js +1 -2
- package/lib-mjs/publicApi/utils/formatTableWithContentModel.js.map +1 -1
- package/package.json +4 -5
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { areSameFormats, createFormatContainer, unwrapBlock } from 'roosterjs-content-model-dom';
|
|
2
|
-
import { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';
|
|
3
1
|
import { wrapBlockStep1, wrapBlockStep2 } from '../common/wrapBlock';
|
|
2
|
+
import { getOperationalBlocks, isBlockGroupOfType, areSameFormats, createFormatContainer, unwrapBlock, } from 'roosterjs-content-model-dom';
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,WAAW,GACd,MAAM,6BAA6B,CAAC;AAYrC;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACjC,KAA2B,EAC3B,SAA4C,EAC5C,SAA4C;IAE5C,IAAM,gBAAgB,GAAG,oBAAoB,CAE3C,KAAK,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAE7E,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,EAAE;QACrC,+DAA+D;QAC/D,gBAAgB,CAAC,OAAO,CAAC,UAAC,EAAiB;gBAAf,KAAK,WAAA,EAAE,MAAM,YAAA;YACrC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;KACN;SAAM;QACH,IAAM,cAAY,GAAwD,EAAE,CAAC;QAC7E,IAAM,SAAO,GAAG,UAAC,KAAc;YAC3B,OAAA,qBAAqB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAAlE,CAAkE,CAAC;QACvE,IAAM,UAAQ,GAAG,UACb,KAAc,EACd,MAAyB,EACzB,OAAqC;YAErC,OAAA,aAAa,CAAC,MAAM,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAAzE,CAAyE,CAAC;QAE9E,gBAAgB,CAAC,OAAO,CAAC,UAAC,EAAiB;gBAAf,KAAK,WAAA,EAAE,MAAM,YAAA;YACrC,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;gBAChB,0BAA0B;aAC7B;iBAAM;gBACH,cAAc,CAAC,cAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAO,EAAE,UAAQ,CAAC,CAAC;aAClE;QACL,CAAC,CAAC,CAAC;QAEH,cAAc,CAAC,cAAY,EAAE,UAAQ,CAAC,CAAC;KAC1C;IAED,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,aAAa,CAClB,MAAyB,EACzB,MAAyC;IAEzC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,OAAO,CAAC,KAAwB;IACrC,OAAO,CACH,kBAAkB,CAA8B,KAAK,EAAE,iBAAiB,CAAC;QACzE,KAAK,CAAC,OAAO,IAAI,YAAY,CAChC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CACtB,eAAwF;IAMxF,OAAO,eAAe,CAAC,KAAK,CAAC,UAAA,cAAc,IAAI,OAAA,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import { wrapBlockStep1, wrapBlockStep2 } from '../common/wrapBlock';\nimport {\n getOperationalBlocks,\n isBlockGroupOfType,\n areSameFormats,\n createFormatContainer,\n unwrapBlock,\n} from 'roosterjs-content-model-dom';\nimport type { WrapBlockStep1Result } from '../common/wrapBlock';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelFormatContainerFormat,\n ContentModelListItem,\n OperationalBlocks,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function toggleModelBlockQuote(\n model: ContentModelDocument,\n formatLtr: ContentModelFormatContainerFormat,\n formatRtl: ContentModelFormatContainerFormat\n): boolean {\n const paragraphOfQuote = getOperationalBlocks<\n ContentModelFormatContainer | ContentModelListItem\n >(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/);\n\n if (areAllBlockQuotes(paragraphOfQuote)) {\n // All selections are already in quote, we need to unquote them\n paragraphOfQuote.forEach(({ block, parent }) => {\n unwrapBlock(parent, block);\n });\n } else {\n const step1Results: WrapBlockStep1Result<ContentModelFormatContainer>[] = [];\n const creator = (isRtl: boolean) =>\n createFormatContainer('blockquote', isRtl ? formatRtl : formatLtr);\n const canMerge = (\n isRtl: boolean,\n target: ContentModelBlock,\n current?: ContentModelFormatContainer\n ): target is ContentModelFormatContainer =>\n canMergeQuote(target, current?.format || (isRtl ? formatRtl : formatLtr));\n\n paragraphOfQuote.forEach(({ block, parent }) => {\n if (isQuote(block)) {\n // Already in quote, no op\n } else {\n wrapBlockStep1(step1Results, parent, block, creator, canMerge);\n }\n });\n\n wrapBlockStep2(step1Results, canMerge);\n }\n\n return paragraphOfQuote.length > 0;\n}\n\nfunction canMergeQuote(\n target: ContentModelBlock,\n format: ContentModelFormatContainerFormat\n): target is ContentModelFormatContainer {\n return isQuote(target) && areSameFormats(format, target.format);\n}\n\nfunction isQuote(block: ContentModelBlock): block is ContentModelFormatContainer {\n return (\n isBlockGroupOfType<ContentModelFormatContainer>(block, 'FormatContainer') &&\n block.tagName == 'blockquote'\n );\n}\n\nfunction areAllBlockQuotes(\n blockAndParents: OperationalBlocks<ContentModelFormatContainer | ContentModelListItem>[]\n): blockAndParents is {\n block: ContentModelFormatContainer;\n parent: ContentModelBlockGroup;\n path: ContentModelBlockGroup[];\n}[] {\n return blockAndParents.every(blockAndParent => isQuote(blockAndParent.block));\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { adjustWordSelection } from '../selection/adjustWordSelection';
|
|
3
|
-
import { createFormatContainer } from 'roosterjs-content-model-dom';
|
|
4
|
-
import { iterateSelections, applyTableFormat, getClosestAncestorBlockGroupIndex, updateTableCellMetadata, updateTableMetadata, } from 'roosterjs-content-model-core';
|
|
3
|
+
import { applyTableFormat, createFormatContainer, getClosestAncestorBlockGroupIndex, iterateSelections, updateTableCellMetadata, updateTableMetadata, } from 'roosterjs-content-model-dom';
|
|
5
4
|
/**
|
|
6
5
|
* @internal
|
|
7
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clearModelFormat.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/clearModelFormat.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EACH,iBAAiB,EACjB,gBAAgB,EAChB,iCAAiC,EACjC,uBAAuB,EACvB,mBAAmB,GACtB,MAAM,8BAA8B,CAAC;AActC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC5B,KAA2B,EAC3B,aAA8D,EAC9D,eAAsC,EACtC,aAA6C;IAE7C,iBAAiB,CACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ;QAChC,IAAI,QAAQ,EAAE;YACV,eAAe,CAAC,IAAI,OAApB,eAAe,2BAAS,QAAQ,WAAE;SACrC;QAED,IAAI,KAAK,EAAE;YACP,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;SACrC;aAAM,IAAI,YAAY,EAAE;YACrB,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;SACrD;IACL,CAAC,EACD;QACI,4FAA4F;QAC5F,6CAA6C;QAC7C,4FAA4F;QAC5F,2FAA2F;Q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C,KAAwB;IAClD,OAAO,CACF,KAAoB,CAAC,UAAU;QAChC,CAAC,KAAK,CAAC,SAAS,IAAI,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAC,CAAC,CAC9E,CAAC;AACN,CAAC","sourcesContent":["import { adjustWordSelection } from '../selection/adjustWordSelection';\nimport { createFormatContainer } from 'roosterjs-content-model-dom';\nimport {\n iterateSelections,\n applyTableFormat,\n getClosestAncestorBlockGroupIndex,\n updateTableCellMetadata,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelListItem,\n ContentModelSegment,\n ContentModelSegmentFormat,\n ContentModelTable,\n Selectable,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function clearModelFormat(\n model: ContentModelDocument,\n blocksToClear: [ContentModelBlockGroup[], ContentModelBlock][],\n segmentsToClear: ContentModelSegment[],\n tablesToClear: [ContentModelTable, boolean][]\n) {\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n if (segments) {\n segmentsToClear.push(...segments);\n }\n\n if (block) {\n blocksToClear.push([path, block]);\n } else if (tableContext) {\n clearTableCellFormat(tableContext, tablesToClear);\n }\n },\n {\n // When there is a default format to apply, we know how to handle segment format under list.\n // So no need to clear format of list number.\n // Otherwise, we will clear all format of selected text. And since they are under LI tag, we\n // also need to clear the format of LI (format holder) so that the format is really cleared\n includeListFormatHolder: model.format ? 'never' : 'anySegment',\n }\n );\n\n const marker = segmentsToClear[0];\n\n // 2. If selection is collapsed, add selection to whole word to clear if any\n if (\n blocksToClear.length == 1 &&\n isOnlySelectionMarkerSelected(blocksToClear[0][1]) &&\n blocksToClear.length == 1\n ) {\n segmentsToClear.splice(0, segmentsToClear.length, ...adjustWordSelection(model, marker));\n clearListFormat(blocksToClear[0][0]);\n } else if (blocksToClear.length > 1 || blocksToClear.some(x => isWholeBlockSelected(x[1]))) {\n // 2. If a full block or multiple blocks are selected, clear block format\n for (let i = blocksToClear.length - 1; i >= 0; i--) {\n const [path, block] = blocksToClear[i];\n\n clearBlockFormat(path, block);\n clearListFormat(path);\n clearContainerFormat(path, block);\n }\n }\n\n // 3. Finally clear format for segments\n clearSegmentsFormat(segmentsToClear, model.format);\n\n // 4. Clear format for table if any\n createTablesFormat(tablesToClear);\n}\n\nfunction createTablesFormat(tablesToClear: [ContentModelTable, boolean][]) {\n tablesToClear.forEach(x => {\n const [table, isWholeTableSelected] = x;\n if (isWholeTableSelected) {\n table.format = {\n useBorderBox: table.format.useBorderBox,\n borderCollapse: table.format.borderCollapse,\n };\n updateTableMetadata(table, () => null);\n }\n\n applyTableFormat(table, undefined /*newFormat*/, true);\n });\n}\n\nfunction clearSegmentsFormat(\n segmentsToClear: ContentModelSegment[],\n defaultSegmentFormat: ContentModelSegmentFormat | undefined\n) {\n segmentsToClear.forEach(x => {\n x.format = { ...(defaultSegmentFormat || {}) };\n\n if (x.link) {\n delete x.link.format.textColor;\n }\n\n delete x.code;\n });\n}\n\nfunction clearTableCellFormat(\n tableContext: TableSelectionContext | undefined,\n tablesToClear: [ContentModelTable, boolean][]\n) {\n if (tableContext) {\n const { table, colIndex, rowIndex, isWholeTableSelected } = tableContext;\n const cell = table.rows[rowIndex].cells[colIndex];\n\n if (cell.isSelected) {\n updateTableCellMetadata(cell, () => null);\n cell.isHeader = false;\n cell.format = {\n useBorderBox: cell.format.useBorderBox,\n };\n }\n\n if (!tablesToClear.find(x => x[0] == table)) {\n tablesToClear.push([table, isWholeTableSelected]);\n }\n }\n}\n\nfunction clearContainerFormat(path: ContentModelBlockGroup[], block: ContentModelBlock) {\n const containerPathIndex = getClosestAncestorBlockGroupIndex(\n path,\n ['FormatContainer'],\n ['TableCell']\n );\n\n if (containerPathIndex >= 0 && containerPathIndex < path.length - 1) {\n const container = path[containerPathIndex] as ContentModelFormatContainer;\n const containerIndex = path[containerPathIndex + 1].blocks.indexOf(container);\n const blockIndex = container.blocks.indexOf(block);\n\n if (blockIndex >= 0 && containerIndex >= 0) {\n const newContainer = createFormatContainer(container.tagName, container.format);\n\n container.blocks.splice(blockIndex, 1);\n newContainer.blocks = container.blocks.splice(blockIndex);\n\n path[containerPathIndex + 1].blocks.splice(containerIndex + 1, 0, block, newContainer);\n }\n }\n}\n\nfunction clearListFormat(path: ContentModelBlockGroup[]) {\n const listItem = path[getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell'])] as\n | ContentModelListItem\n | undefined;\n\n if (listItem) {\n listItem.levels = [];\n }\n}\n\nfunction clearBlockFormat(path: ContentModelBlockGroup[], block: ContentModelBlock) {\n if (block.blockType == 'Divider') {\n const index = path[0].blocks.indexOf(block);\n\n if (index >= 0) {\n path[0].blocks.splice(index, 1);\n }\n } else if (block.blockType == 'Paragraph') {\n block.format = {};\n delete block.decorator;\n }\n}\n\nfunction isOnlySelectionMarkerSelected(block: ContentModelBlock) {\n const segments = block.blockType == 'Paragraph' ? block.segments.filter(x => x.isSelected) : [];\n\n return segments.length == 1 && segments[0].segmentType == 'SelectionMarker';\n}\n\nfunction isWholeBlockSelected(block: ContentModelBlock) {\n return (\n (block as Selectable).isSelected ||\n (block.blockType == 'Paragraph' && block.segments.every(x => x.isSelected))\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"clearModelFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/common/clearModelFormat.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EACH,gBAAgB,EAChB,qBAAqB,EACrB,iCAAiC,EACjC,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,GACtB,MAAM,6BAA6B,CAAC;AAcrC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC5B,KAA2B,EAC3B,aAA8D,EAC9D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,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,SAAS,CAAC;KAC1B;AACL,CAAC;AAED,SAAS,6BAA6B,CAAC,KAAwB;IAC3D,IAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEhG,OAAO,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;AAChF,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAwB;IAClD,OAAO,CACF,KAAoB,CAAC,UAAU;QAChC,CAAC,KAAK,CAAC,SAAS,IAAI,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAC,CAAC,CAC9E,CAAC;AACN,CAAC","sourcesContent":["import { adjustWordSelection } from '../selection/adjustWordSelection';\nimport {\n applyTableFormat,\n createFormatContainer,\n getClosestAncestorBlockGroupIndex,\n iterateSelections,\n updateTableCellMetadata,\n updateTableMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelListItem,\n ContentModelSegment,\n ContentModelSegmentFormat,\n ContentModelTable,\n Selectable,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function clearModelFormat(\n model: ContentModelDocument,\n blocksToClear: [ContentModelBlockGroup[], ContentModelBlock][],\n segmentsToClear: ContentModelSegment[],\n tablesToClear: [ContentModelTable, boolean][]\n) {\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n if (segments) {\n segmentsToClear.push(...segments);\n }\n\n if (block) {\n blocksToClear.push([path, block]);\n } else if (tableContext) {\n clearTableCellFormat(tableContext, tablesToClear);\n }\n },\n {\n // When there is a default format to apply, we know how to handle segment format under list.\n // So no need to clear format of list number.\n // Otherwise, we will clear all format of selected text. And since they are under LI tag, we\n // also need to clear the format of LI (format holder) so that the format is really cleared\n includeListFormatHolder: model.format ? 'never' : 'anySegment',\n }\n );\n\n const marker = segmentsToClear[0];\n\n // 2. If selection is collapsed, add selection to whole word to clear if any\n if (\n blocksToClear.length == 1 &&\n isOnlySelectionMarkerSelected(blocksToClear[0][1]) &&\n blocksToClear.length == 1\n ) {\n segmentsToClear.splice(0, segmentsToClear.length, ...adjustWordSelection(model, marker));\n clearListFormat(blocksToClear[0][0]);\n } else if (blocksToClear.length > 1 || blocksToClear.some(x => isWholeBlockSelected(x[1]))) {\n // 2. If a full block or multiple blocks are selected, clear block format\n for (let i = blocksToClear.length - 1; i >= 0; i--) {\n const [path, block] = blocksToClear[i];\n\n clearBlockFormat(path, block);\n clearListFormat(path);\n clearContainerFormat(path, block);\n }\n }\n\n // 3. Finally clear format for segments\n clearSegmentsFormat(segmentsToClear, model.format);\n\n // 4. Clear format for table if any\n createTablesFormat(tablesToClear);\n}\n\nfunction createTablesFormat(tablesToClear: [ContentModelTable, boolean][]) {\n tablesToClear.forEach(x => {\n const [table, isWholeTableSelected] = x;\n if (isWholeTableSelected) {\n table.format = {\n useBorderBox: table.format.useBorderBox,\n borderCollapse: table.format.borderCollapse,\n };\n updateTableMetadata(table, () => null);\n }\n\n applyTableFormat(table, undefined /*newFormat*/, true);\n });\n}\n\nfunction clearSegmentsFormat(\n segmentsToClear: ContentModelSegment[],\n defaultSegmentFormat: ContentModelSegmentFormat | undefined\n) {\n segmentsToClear.forEach(x => {\n x.format = { ...(defaultSegmentFormat || {}) };\n\n if (x.link) {\n delete x.link.format.textColor;\n }\n\n delete x.code;\n });\n}\n\nfunction clearTableCellFormat(\n tableContext: TableSelectionContext | undefined,\n tablesToClear: [ContentModelTable, boolean][]\n) {\n if (tableContext) {\n const { table, colIndex, rowIndex, isWholeTableSelected } = tableContext;\n const cell = table.rows[rowIndex].cells[colIndex];\n\n if (cell.isSelected) {\n updateTableCellMetadata(cell, () => null);\n cell.isHeader = false;\n cell.format = {\n useBorderBox: cell.format.useBorderBox,\n };\n }\n\n if (!tablesToClear.find(x => x[0] == table)) {\n tablesToClear.push([table, isWholeTableSelected]);\n }\n }\n}\n\nfunction clearContainerFormat(path: ContentModelBlockGroup[], block: ContentModelBlock) {\n const containerPathIndex = getClosestAncestorBlockGroupIndex(\n path,\n ['FormatContainer'],\n ['TableCell']\n );\n\n if (containerPathIndex >= 0 && containerPathIndex < path.length - 1) {\n const container = path[containerPathIndex] as ContentModelFormatContainer;\n const containerIndex = path[containerPathIndex + 1].blocks.indexOf(container);\n const blockIndex = container.blocks.indexOf(block);\n\n if (blockIndex >= 0 && containerIndex >= 0) {\n const newContainer = createFormatContainer(container.tagName, container.format);\n\n container.blocks.splice(blockIndex, 1);\n newContainer.blocks = container.blocks.splice(blockIndex);\n\n path[containerPathIndex + 1].blocks.splice(containerIndex + 1, 0, block, newContainer);\n }\n }\n}\n\nfunction clearListFormat(path: ContentModelBlockGroup[]) {\n const listItem = path[getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell'])] as\n | ContentModelListItem\n | undefined;\n\n if (listItem) {\n listItem.levels = [];\n }\n}\n\nfunction clearBlockFormat(path: ContentModelBlockGroup[], block: ContentModelBlock) {\n if (block.blockType == 'Divider') {\n const index = path[0].blocks.indexOf(block);\n\n if (index >= 0) {\n path[0].blocks.splice(index, 1);\n }\n } else if (block.blockType == 'Paragraph') {\n block.format = {};\n delete block.decorator;\n }\n}\n\nfunction isOnlySelectionMarkerSelected(block: ContentModelBlock) {\n const segments = block.blockType == 'Paragraph' ? block.segments.filter(x => x.isSelected) : [];\n\n return segments.length == 1 && segments[0].segmentType == 'SelectionMarker';\n}\n\nfunction isWholeBlockSelected(block: ContentModelBlock) {\n return (\n (block as Selectable).isSelected ||\n (block.blockType == 'Paragraph' && block.segments.every(x => x.isSelected))\n );\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ContentModelBlockGroup, DomToModelContext } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
interface FormatStateContext extends DomToModelContext {
|
|
6
|
+
/**
|
|
7
|
+
* An optional stack of parent elements to process. When provided, the child nodes of current parent element will be ignored,
|
|
8
|
+
* but use the top element in this stack instead in childProcessor.
|
|
9
|
+
*/
|
|
10
|
+
nodeStack?: Node[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* In order to get format, we can still use the regular child processor. However, to improve performance, we don't need to create
|
|
15
|
+
* content model for the whole doc, instead we only need to traverse the tree path that can arrive current selected node.
|
|
16
|
+
* This "reduced" child processor will first create a node stack that stores DOM node from root to current common ancestor node of selection,
|
|
17
|
+
* then use this stack as a faked DOM tree to create a reduced content model which we can use to retrieve format state
|
|
18
|
+
*/
|
|
19
|
+
export declare function reducedModelChildProcessor(group: ContentModelBlockGroup, parent: ParentNode, context: FormatStateContext): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { getRegularSelectionOffsets, getSelectionRootNode, handleRegularSelection, isNodeOfType, processChildNode, } from 'roosterjs-content-model-dom';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* In order to get format, we can still use the regular child processor. However, to improve performance, we don't need to create
|
|
6
|
+
* content model for the whole doc, instead we only need to traverse the tree path that can arrive current selected node.
|
|
7
|
+
* This "reduced" child processor will first create a node stack that stores DOM node from root to current common ancestor node of selection,
|
|
8
|
+
* then use this stack as a faked DOM tree to create a reduced content model which we can use to retrieve format state
|
|
9
|
+
*/
|
|
10
|
+
export function reducedModelChildProcessor(group, parent, context) {
|
|
11
|
+
if (!context.nodeStack) {
|
|
12
|
+
var selectionRootNode = getSelectionRootNode(context.selection);
|
|
13
|
+
context.nodeStack = selectionRootNode ? createNodeStack(parent, selectionRootNode) : [];
|
|
14
|
+
}
|
|
15
|
+
var stackChild = context.nodeStack.pop();
|
|
16
|
+
if (stackChild) {
|
|
17
|
+
var _a = __read(getRegularSelectionOffsets(context, parent), 2), nodeStartOffset = _a[0], nodeEndOffset = _a[1];
|
|
18
|
+
// If selection is not on this node, skip getting node index to save some time since we don't need it here
|
|
19
|
+
var index = nodeStartOffset >= 0 || nodeEndOffset >= 0 ? getChildIndex(parent, stackChild) : -1;
|
|
20
|
+
if (index >= 0) {
|
|
21
|
+
handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);
|
|
22
|
+
}
|
|
23
|
+
processChildNode(group, stackChild, context);
|
|
24
|
+
if (index >= 0) {
|
|
25
|
+
handleRegularSelection(index + 1, context, group, nodeStartOffset, nodeEndOffset);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// No child node from node stack, that means we have reached the deepest node of selection.
|
|
30
|
+
// Now we can use default child processor to perform full sub tree scanning for content model,
|
|
31
|
+
// So that all selected node will be included.
|
|
32
|
+
context.defaultElementProcessors.child(group, parent, context);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function createNodeStack(root, startNode) {
|
|
36
|
+
var result = [];
|
|
37
|
+
var node = startNode;
|
|
38
|
+
while (node && root != node && root.contains(node)) {
|
|
39
|
+
if (isNodeOfType(node, 'ELEMENT_NODE') && node.tagName == 'TABLE') {
|
|
40
|
+
// For table, we can't do a reduced model creation since we need to handle their cells and indexes,
|
|
41
|
+
// so clean up whatever we already have, and just put table into the stack
|
|
42
|
+
result.splice(0, result.length, node);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
result.push(node);
|
|
46
|
+
}
|
|
47
|
+
node = node.parentNode;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
function getChildIndex(parent, stackChild) {
|
|
52
|
+
var index = 0;
|
|
53
|
+
var child = parent.firstChild;
|
|
54
|
+
while (child && child != stackChild) {
|
|
55
|
+
index++;
|
|
56
|
+
child = child.nextSibling;
|
|
57
|
+
}
|
|
58
|
+
return index;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=reducedModelChildProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducedModelChildProcessor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/common/reducedModelChildProcessor.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AAcrC;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACtC,KAA6B,EAC7B,MAAkB,EAClB,OAA2B;IAE3B,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;QACpB,IAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAClE,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3F;IAED,IAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAE3C,IAAI,UAAU,EAAE;QACN,IAAA,KAAA,OAAmC,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,IAAA,EAA7E,eAAe,QAAA,EAAE,aAAa,QAA+C,CAAC;QAErF,0GAA0G;QAC1G,IAAM,KAAK,GACP,eAAe,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExF,IAAI,KAAK,IAAI,CAAC,EAAE;YACZ,sBAA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AC,WAAW,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import {\n getRegularSelectionOffsets,\n getSelectionRootNode,\n handleRegularSelection,\n isNodeOfType,\n processChildNode,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelBlockGroup, DomToModelContext } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\ninterface FormatStateContext extends DomToModelContext {\n /**\n * An optional stack of parent elements to process. When provided, the child nodes of current parent element will be ignored,\n * but use the top element in this stack instead in childProcessor.\n */\n nodeStack?: Node[];\n}\n\n/**\n * @internal\n * In order to get format, we can still use the regular child processor. However, to improve performance, we don't need to create\n * content model for the whole doc, instead we only need to traverse the tree path that can arrive current selected node.\n * This \"reduced\" child processor will first create a node stack that stores DOM node from root to current common ancestor node of selection,\n * then use this stack as a faked DOM tree to create a reduced content model which we can use to retrieve format state\n */\nexport function reducedModelChildProcessor(\n group: ContentModelBlockGroup,\n parent: ParentNode,\n context: FormatStateContext\n) {\n if (!context.nodeStack) {\n const selectionRootNode = getSelectionRootNode(context.selection);\n context.nodeStack = selectionRootNode ? createNodeStack(parent, selectionRootNode) : [];\n }\n\n const stackChild = context.nodeStack.pop();\n\n if (stackChild) {\n const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, parent);\n\n // If selection is not on this node, skip getting node index to save some time since we don't need it here\n const index =\n nodeStartOffset >= 0 || nodeEndOffset >= 0 ? getChildIndex(parent, stackChild) : -1;\n\n if (index >= 0) {\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n }\n\n processChildNode(group, stackChild, context);\n\n if (index >= 0) {\n handleRegularSelection(index + 1, context, group, nodeStartOffset, nodeEndOffset);\n }\n } else {\n // No child node from node stack, that means we have reached the deepest node of selection.\n // Now we can use default child processor to perform full sub tree scanning for content model,\n // So that all selected node will be included.\n context.defaultElementProcessors.child(group, parent, context);\n }\n}\n\nfunction createNodeStack(root: Node, startNode: Node): Node[] {\n const result: Node[] = [];\n let node: Node | null = startNode;\n\n while (node && root != node && root.contains(node)) {\n if (isNodeOfType(node, 'ELEMENT_NODE') && node.tagName == 'TABLE') {\n // For table, we can't do a reduced model creation since we need to handle their cells and indexes,\n // so clean up whatever we already have, and just put table into the stack\n result.splice(0, result.length, node);\n } else {\n result.push(node);\n }\n\n node = node.parentNode;\n }\n\n return result;\n}\n\nfunction getChildIndex(parent: ParentNode, stackChild: Node) {\n let index = 0;\n let child = parent.firstChild;\n\n while (child && child != stackChild) {\n index++;\n child = child.nextSibling;\n }\n return index;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapBlock.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"wrapBlock.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/common/wrapBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAWhF;;GAEG;AACH,MAAM,UAAU,cAAc,CAC1B,WAAsC,EACtC,MAAqC,EACrC,WAA8B,EAC9B,OAA8B,EAC9B,QAAoE;;IAEpE,IAAM,KAAK,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,mCAAI,CAAC,CAAC,CAAC;IAExD,IAAI,MAAM,IAAI,KAAK,IAAI,CAAC,EAAE;QACtB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE/B,IAAM,SAAS,GAAsB,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC;QACpD,IAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;YACtC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,YAAY,CAA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AC;AACjB,CAAC","sourcesContent":["import { addBlock, setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { ContentModelBlock, ContentModelBlockGroup } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport interface WrapBlockStep1Result<T extends ContentModelBlockGroup & ContentModelBlock> {\n parent: ContentModelBlockGroup;\n wrapper: T;\n}\n\n/**\n * @internal\n */\nexport function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(\n step1Result: WrapBlockStep1Result<T>[],\n parent: ContentModelBlockGroup | null,\n blockToWrap: ContentModelBlock,\n creator: (isRtl: boolean) => T,\n canMerge: (isRtl: boolean, target: ContentModelBlock) => target is T\n) {\n const index = parent?.blocks.indexOf(blockToWrap) ?? -1;\n\n if (parent && index >= 0) {\n parent.blocks.splice(index, 1);\n\n const prevBlock: ContentModelBlock = parent.blocks[index - 1];\n const isRtl = blockToWrap.format.direction == 'rtl';\n const wrapper = canMerge(isRtl, prevBlock)\n ? prevBlock\n : createAndAdd(parent, index, creator, isRtl);\n\n setParagraphNotImplicit(blockToWrap);\n addBlock(wrapper, blockToWrap);\n\n // Use reverse order, so that we can merge from last to first to avoid modifying unmerged quotes\n step1Result.unshift({ parent, wrapper });\n }\n}\n\n/**\n * @internal\n */\nexport function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(\n step1Result: WrapBlockStep1Result<T>[],\n canMerge: (isRtl: boolean, target: ContentModelBlock, current: T) => target is T\n) {\n step1Result.forEach(({ parent, wrapper }) => {\n const index = parent.blocks.indexOf(wrapper);\n const nextBlock = parent.blocks[index + 1];\n const isRtl = wrapper.format.direction == 'rtl';\n\n if (index >= 0 && canMerge(isRtl, nextBlock, wrapper)) {\n wrapper.blocks.forEach(setParagraphNotImplicit);\n wrapper.blocks.push(...nextBlock.blocks);\n parent.blocks.splice(index + 1, 1);\n }\n });\n}\n\nfunction createAndAdd<T extends ContentModelBlockGroup & ContentModelBlock>(\n parent: ContentModelBlockGroup,\n index: number,\n creator: (isRtl: boolean) => T,\n isRtl: boolean\n): T {\n const block = creator(isRtl);\n\n parent.blocks.splice(index, 0, block);\n return block;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContentModelDocument, ContentModelEntity, FormatContentModelContext, InsertEntityPosition } from 'roosterjs-content-model-types';
|
|
1
|
+
import type { ContentModelDocument, ContentModelEntity, FormatContentModelContext, InsertEntityPosition, InsertPoint } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function insertEntityModel(model: ContentModelDocument, entityModel: ContentModelEntity, position: InsertEntityPosition, isBlock: boolean, focusAfterEntity?: boolean, context?: FormatContentModelContext): void;
|
|
5
|
+
export declare function insertEntityModel(model: ContentModelDocument, entityModel: ContentModelEntity, position: InsertEntityPosition, isBlock: boolean, focusAfterEntity?: boolean, context?: FormatContentModelContext, insertPointOverride?: InsertPoint): void;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
|
-
import { deleteSelection, getClosestAncestorBlockGroupIndex, setSelection, } from 'roosterjs-content-model-
|
|
3
|
-
import { createBr, createParagraph, createSelectionMarker, normalizeContentModel, } from 'roosterjs-content-model-dom';
|
|
2
|
+
import { createBr, createParagraph, createSelectionMarker, normalizeContentModel, deleteSelection, getClosestAncestorBlockGroupIndex, setSelection, } from 'roosterjs-content-model-dom';
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
7
|
-
export function insertEntityModel(model, entityModel, position, isBlock, focusAfterEntity, context) {
|
|
6
|
+
export function insertEntityModel(model, entityModel, position, isBlock, focusAfterEntity, context, insertPointOverride) {
|
|
8
7
|
var _a;
|
|
9
8
|
var _b;
|
|
10
9
|
var blockParent;
|
|
11
10
|
var blockIndex = -1;
|
|
12
|
-
var
|
|
11
|
+
var insertPoint;
|
|
13
12
|
if (position == 'begin' || position == 'end') {
|
|
14
13
|
blockParent = model;
|
|
15
14
|
blockIndex = position == 'begin' ? 0 : model.blocks.length;
|
|
@@ -17,11 +16,8 @@ export function insertEntityModel(model, entityModel, position, isBlock, focusAf
|
|
|
17
16
|
Object.assign(entityModel.format, model.format);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
else if ((
|
|
21
|
-
var
|
|
22
|
-
if (deleteResult.deleteResult == 'range') {
|
|
23
|
-
normalizeContentModel(model);
|
|
24
|
-
}
|
|
19
|
+
else if ((insertPoint = getInsertPoint(model, insertPointOverride, context))) {
|
|
20
|
+
var marker = insertPoint.marker, paragraph = insertPoint.paragraph, path = insertPoint.path;
|
|
25
21
|
if (!isBlock) {
|
|
26
22
|
var index = paragraph.segments.indexOf(marker);
|
|
27
23
|
Object.assign(entityModel.format, marker.format);
|
|
@@ -73,4 +69,17 @@ export function insertEntityModel(model, entityModel, position, isBlock, focusAf
|
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
}
|
|
72
|
+
function getInsertPoint(model, insertPointOverride, context) {
|
|
73
|
+
if (insertPointOverride) {
|
|
74
|
+
return insertPointOverride;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
var deleteResult = deleteSelection(model, [], context);
|
|
78
|
+
var insertPoint = deleteResult.insertPoint;
|
|
79
|
+
if (deleteResult.deleteResult == 'range') {
|
|
80
|
+
normalizeContentModel(model);
|
|
81
|
+
}
|
|
82
|
+
return insertPoint;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
76
85
|
//# sourceMappingURL=insertEntityModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EAC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AC,WAAW,CAAC;QAE7C,IAAI,YAAY,CAAC,YAAY,IAAI,OAAO,EAAE;YACtC,qBAAqB,CAAC,KAAK,CAAC,CAAC;SAChC;QAED,OAAO,WAAW,CAAC;KACtB;AACL,CAAC","sourcesContent":["import {\n createBr,\n createParagraph,\n createSelectionMarker,\n normalizeContentModel,\n deleteSelection,\n getClosestAncestorBlockGroupIndex,\n setSelection,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelEntity,\n ContentModelParagraph,\n FormatContentModelContext,\n InsertEntityPosition,\n InsertPoint,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function insertEntityModel(\n model: ContentModelDocument,\n entityModel: ContentModelEntity,\n position: InsertEntityPosition,\n isBlock: boolean,\n focusAfterEntity?: boolean,\n context?: FormatContentModelContext,\n insertPointOverride?: InsertPoint\n) {\n let blockParent: ContentModelBlockGroup | undefined;\n let blockIndex = -1;\n let insertPoint: InsertPoint | null;\n\n if (position == 'begin' || position == 'end') {\n blockParent = model;\n blockIndex = position == 'begin' ? 0 : model.blocks.length;\n\n if (!isBlock) {\n Object.assign(entityModel.format, model.format);\n }\n } else if ((insertPoint = getInsertPoint(model, insertPointOverride, context))) {\n const { marker, paragraph, path } = insertPoint;\n\n if (!isBlock) {\n const index = paragraph.segments.indexOf(marker);\n\n Object.assign(entityModel.format, marker.format);\n\n if (index >= 0) {\n paragraph.segments.splice(focusAfterEntity ? index : index + 1, 0, entityModel);\n }\n } else {\n const pathIndex =\n position == 'root'\n ? getClosestAncestorBlockGroupIndex(path, ['TableCell', 'Document'])\n : 0;\n blockParent = path[pathIndex];\n const child = path[pathIndex - 1];\n const directChild: ContentModelBlock =\n child?.blockGroupType == 'FormatContainer' ||\n child?.blockGroupType == 'General' ||\n child?.blockGroupType == 'ListItem'\n ? child\n : paragraph;\n const childIndex = blockParent.blocks.indexOf(directChild);\n blockIndex = childIndex >= 0 ? childIndex + 1 : -1;\n }\n }\n\n if (blockIndex >= 0 && blockParent) {\n const blocksToInsert: ContentModelBlock[] = [];\n let nextParagraph: ContentModelParagraph | undefined;\n\n if (isBlock) {\n const nextBlock = blockParent.blocks[blockIndex];\n\n blocksToInsert.push(entityModel);\n\n if (nextBlock?.blockType == 'Paragraph') {\n nextParagraph = nextBlock;\n } else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {\n nextParagraph = createParagraph(false /*isImplicit*/, {}, model.format);\n nextParagraph.segments.push(createBr(model.format));\n blocksToInsert.push(nextParagraph);\n }\n } else {\n nextParagraph = createParagraph(\n false /*isImplicit*/,\n undefined /*format*/,\n model.format\n );\n\n nextParagraph.segments.push(entityModel);\n blocksToInsert.push(nextParagraph);\n }\n\n blockParent.blocks.splice(blockIndex, 0, ...blocksToInsert);\n\n if (focusAfterEntity && nextParagraph) {\n const marker = createSelectionMarker(nextParagraph.segments[0]?.format || model.format);\n const segments = nextParagraph.segments;\n\n isBlock ? segments.unshift(marker) : segments.push(marker);\n setSelection(model, marker, marker);\n }\n }\n}\n\nfunction getInsertPoint(\n model: ContentModelDocument,\n insertPointOverride?: InsertPoint,\n context?: FormatContentModelContext\n): InsertPoint | null {\n if (insertPointOverride) {\n return insertPointOverride;\n } else {\n const deleteResult = deleteSelection(model, [], context);\n const insertPoint = deleteResult.insertPoint;\n\n if (deleteResult.deleteResult == 'range') {\n normalizeContentModel(model);\n }\n\n return insertPoint;\n }\n}\n"]}
|
|
@@ -2,4 +2,4 @@ import type { Border, ContentModelImage } from 'roosterjs-content-model-types';
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export declare function applyImageBorderFormat(image: ContentModelImage, border: Border | null, borderRadius?: string): void;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { extractBorderValues } from 'roosterjs-content-model-
|
|
2
|
-
import { parseValueWithUnit } from 'roosterjs-content-model-dom';
|
|
1
|
+
import { extractBorderValues, parseValueWithUnit } from 'roosterjs-content-model-dom';
|
|
3
2
|
/**
|
|
4
3
|
* @internal
|
|
5
4
|
*/
|
|
6
|
-
export
|
|
5
|
+
export function applyImageBorderFormat(image, border, borderRadius) {
|
|
7
6
|
if (border) {
|
|
8
7
|
var format = image.format;
|
|
9
8
|
var width = border.width, style = border.style, color = border.color;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyImageBorderFormat.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"applyImageBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/image/applyImageBorderFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGtF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAClC,KAAwB,EACxB,MAAqB,EACrB,YAAqB;IAErB,IAAI,MAAM,EAAE;QACR,IAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QACpB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,KAAK,GAAY,MAAM,MAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;QACvC,IAAM,SAAS,GAAG,WAAW,CAAC;QAC9B,IAAM,eAAe,GAAG,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/D,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;QAC1C,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;QAC1C,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;QAC1C,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,IAAI,KAAK,EAAE;YACP,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;SACnD;aAAM,IAAI,WAAW,EAAE;YACpB,YAAY,GAAG,WAAW,CAAC;SAC9B;aAAM;YACH,YAAY,GAAG,KAAK,CAAC;SACxB;QAED,IAAI,KAAK,EAAE;YACP,YAAY,GAAM,YAAY,SAAI,KAAO,CAAC;SAC7C;aAAM,IAAI,WAAW,EAAE;YACpB,YAAY,GAAM,YAAY,SAAI,WAAa,CAAC;SACnD;aAAM;YACH,YAAY,GAAM,YAAY,WAAQ,CAAC;SAC1C;QAED,IAAI,KAAK,EAAE;YACP,YAAY,GAAM,YAAY,SAAI,KAAO,CAAC;SAC7C;aAAM,IAAI,WAAW,EAAE;YACpB,YAAY,GAAM,YAAY,SAAI,WAAa,CAAC;SACnD;QACD,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,YAAY,CAAC;QACvC,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC;QACtC,KAAK,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QACzC,KAAK,CAAC,MAAM,CAAC,WAAW,GAAG,YAAY,CAAC;KAC3C;SAAM;QACH,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;QAC/B,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;QAC9B,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;QACjC,OAAO,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;KACnC;IAED,IAAI,YAAY,EAAE;QACd,KAAK,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;KAC5C;AACL,CAAC","sourcesContent":["import { extractBorderValues, parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport type { Border, ContentModelImage } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function applyImageBorderFormat(\n image: ContentModelImage,\n border: Border | null,\n borderRadius?: string\n) {\n if (border) {\n const format = image.format;\n const { width, style, color } = border;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n let borderFormat = '';\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 image.format.borderLeft = borderFormat;\n image.format.borderTop = borderFormat;\n image.format.borderBottom = borderFormat;\n image.format.borderRight = borderFormat;\n } else {\n delete image.format.borderLeft;\n delete image.format.borderTop;\n delete image.format.borderBottom;\n delete image.format.borderRight;\n }\n\n if (borderRadius) {\n image.format.borderRadius = borderRadius;\n }\n}\n"]}
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
+
import type { LinkData } from 'roosterjs-content-model-types';
|
|
1
2
|
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export interface LinkData {
|
|
5
|
-
/**
|
|
6
|
-
* Schema of a hyperlink
|
|
7
|
-
*/
|
|
8
|
-
scheme: string;
|
|
9
|
-
/**
|
|
10
|
-
* Original url of a hyperlink
|
|
11
|
-
*/
|
|
12
|
-
originalUrl: string;
|
|
13
|
-
/**
|
|
14
|
-
* Normalized url of a hyperlink
|
|
15
|
-
*/
|
|
16
|
-
normalizedUrl: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
3
|
* Try to match a given string with link match rules, return matched link
|
|
21
4
|
* @param url Input url to match
|
|
22
5
|
* @param option Link match option, exact or partial. If it is exact match, we need
|
|
@@ -51,7 +51,6 @@ var linkMatchRules = {
|
|
|
51
51
|
wais: { match: new RegExp("^wais:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* @internal
|
|
55
54
|
* Try to match a given string with link match rules, return matched link
|
|
56
55
|
* @param url Input url to match
|
|
57
56
|
* @param option Link match option, exact or partial. If it is exact match, we need
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchLink.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"matchLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAS5D,8BAA8B;AAC9B,sDAAsD;AACtD,0HAA0H;AAC1H,yCAAyC;AACzC,yFAAyF;AACzF,iGAAiG;AACjG,sFAAsF;AACtF,+HAA+H;AAC/H,mFAAmF;AACnF,2EAA2E;AAC3E,iFAAiF;AACjF,kDAAkD;AAClD,0DAA0D;AAC1D,kEAAkE;AAClE,mDAAmD;AACnD,gDAAgD;AAChD,uEAAuE;AACvE,0DAA0D;AAC1D,yCAAyC;AACzC,IAAM,gBAAgB,GAAG,qGAAqG,CAAC;AAE/H,iDAAiD;AACjD,IAAM,UAAU,GAAG,iCAAiC,CAAC,CAAC,2EAA2E;AACjI,IAAM,eAAe,GAAG,QAAM,UAAU,aAAQ,UAAY,CAAC;AAC7D,IAAM,eAAe,GAAM,eAAe,mBAAgB,CAAC;AAC3D,IAAM,sBAAsB,GAAM,eAAe,sBAAmB,CAAC;AAErE,IAAM,cAAc,GAAkC;IAClD,IAAI,EAAE;QACF,KAAK,EAAE,IAAI,MAAM,CACb,qCAAmC,sBAAsB,eAAU,sBAAwB,EAC3F,GAAG,CACN;QACD,MAAM,EAAE,gBAAgB;QACxB,YAAY,EAAE,UAAA,GAAG;YACb,OAAA,IAAI,MAAM,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;QAArF,CAAqF;KAC5F;IACD,KAAK,EAAE;QACH,KAAK,EAAE,IAAI,MAAM,CAAC,sCAA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cAAc,CAAC,CAAA,gBAAA,4BAAE;gBAA/C,IAAM,MAAM,WAAA;gBACb,IAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;gBACpC,IAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtC,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC1E,OAAO;wBACH,MAAM,EAAE,MAAM;wBACd,WAAW,EAAE,GAAG;wBAChB,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;qBAClE,CAAC;iBACL;aACJ;;;;;;;;;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport type { LinkData } from 'roosterjs-content-model-types';\n\ninterface LinkMatchRule {\n match: RegExp;\n except?: RegExp;\n normalizeUrl?: (url: string) => string;\n}\n\n// http exclude matching regex\n// invalid URL example (in particular on IE and Edge):\n// - http://www.bing.com%00, %00 before ? (question mark) is considered invalid. IE/Edge throws invalid argument exception\n// - http://www.bing.com%1, %1 is invalid\n// - http://www.bing.com%g, %g is invalid (IE and Edge expects a two hex value after a %)\n// - http://www.bing.com%, % as ending is invalid (IE and Edge expects a two hex value after a %)\n// All above % cases if they're after ? (question mark) is then considered valid again\n// Similar for @, it needs to be after / (forward slash), or ? (question mark). Otherwise IE/Edge will throw security exception\n// - http://www.bing.com@name, @name before ? (question mark) is considered invalid\n// - http://www.bing.com/@name, is valid sine it is after / (forward slash)\n// - http://www.bing.com?@name, is also valid since it is after ? (question mark)\n// The regex below is essentially a break down of:\n// ^[^?]+%[^0-9a-f]+ => to exclude URL like www.bing.com%%\n// ^[^?]+%[0-9a-f][^0-9a-f]+ => to exclude URL like www.bing.com%1\n// ^[^?]+%00 => to exclude URL like www.bing.com%00\n// ^[^?]+%$ => to exclude URL like www.bing.com%\n// ^https?:\\/\\/[^?\\/]+@ => to exclude URL like http://www.bing.com@name\n// ^www\\.[^?\\/]+@ => to exclude URL like www.bing.com@name\n// , => to exclude url like www.bing,,com\nconst httpExcludeRegEx = /^[^?]+%[^0-9a-f]+|^[^?]+%[0-9a-f][^0-9a-f]+|^[^?]+%00|^[^?]+%$|^https?:\\/\\/[^?\\/]+@|^www\\.[^?\\/]+@/i;\n\n// via https://tools.ietf.org/html/rfc1035 Page 7\nconst labelRegEx = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'; // We're using case insensitive regexps below so don't bother including A-Z\nconst domainNameRegEx = `(?:${labelRegEx}\\\\.)*${labelRegEx}`;\nconst domainPortRegEx = `${domainNameRegEx}(?:\\\\:[0-9]+)?`;\nconst domainPortWithUrlRegEx = `${domainPortRegEx}(?:[\\\\/\\\\?]\\\\S*)?`;\n\nconst linkMatchRules: Record<string, LinkMatchRule> = {\n http: {\n match: new RegExp(\n `^(?:microsoft-edge:)?http:\\\\/\\\\/${domainPortWithUrlRegEx}|www\\\\.${domainPortWithUrlRegEx}`,\n 'i'\n ),\n except: httpExcludeRegEx,\n normalizeUrl: url =>\n new RegExp('^(?:microsoft-edge:)?http:\\\\/\\\\/', 'i').test(url) ? url : 'http://' + url,\n },\n https: {\n match: new RegExp(`^(?:microsoft-edge:)?https:\\\\/\\\\/${domainPortWithUrlRegEx}`, 'i'),\n except: httpExcludeRegEx,\n },\n mailto: { match: new RegExp('^mailto:\\\\S+@\\\\S+\\\\.\\\\S+', 'i') },\n notes: { match: new RegExp('^notes:\\\\/\\\\/\\\\S+', 'i') },\n file: { match: new RegExp('^file:\\\\/\\\\/\\\\/?\\\\S+', 'i') },\n unc: { match: new RegExp('^\\\\\\\\\\\\\\\\\\\\S+', 'i') },\n ftp: {\n match: new RegExp(\n `^ftp:\\\\/\\\\/${domainPortWithUrlRegEx}|ftp\\\\.${domainPortWithUrlRegEx}`,\n 'i'\n ),\n normalizeUrl: url => (new RegExp('^ftp:\\\\/\\\\/', 'i').test(url) ? url : 'ftp://' + url),\n },\n news: { match: new RegExp(`^news:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n telnet: { match: new RegExp(`^telnet:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n gopher: { match: new RegExp(`^gopher:\\\\/\\\\/${domainPortWithUrlRegEx}`, 'i') },\n wais: { match: new RegExp(`^wais:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n};\n\n/**\n * Try to match a given string with link match rules, return matched link\n * @param url Input url to match\n * @param option Link match option, exact or partial. If it is exact match, we need\n * to check the length of matched link and url\n * @param rules Optional link match rules, if not passed, only the default link match\n * rules will be applied\n * @returns The matched link data, or null if no match found.\n * The link data includes an original url and a normalized url\n */\nexport function matchLink(url: string): LinkData | null {\n if (url) {\n for (const schema of getObjectKeys(linkMatchRules)) {\n const rule = linkMatchRules[schema];\n const matches = url.match(rule.match);\n if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {\n return {\n scheme: schema,\n originalUrl: url,\n normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,\n };\n }\n }\n }\n\n return null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findListItemsInSameThread.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"findListItemsInSameThread.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/findListItemsInSameThread.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACrC,KAA2B,EAC3B,WAAiC;IAEjC,IAAM,KAAK,GAAoC,EAAE,CAAC;IAElD,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAE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C;YAEtB,IAAI,CAAC,IAAI,EAAE;gBACP,IAAI,aAAa,EAAE;oBACf,SAAS;iBACZ;qBAAM;oBACH,MAAM;iBACT;aACJ;YAED,IAAM,mBAAmB,GAAG,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAEtE,IAAI,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,mBAAmB,EAAE;gBACxE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACrB;iBAAM,IAAI,CAAC,aAAa,IAAI,mBAAmB,EAAE;gBAC9C,MAAM;aACT;SACJ;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,sBAAsB,CAC3B,SAA0C,EAC1C,YAAoB,EACpB,cAAsB;IAEtB,IAAM,aAAa,GAAG,SAAS,CAAC,YAAY,CAAE,CAAC,MAAM,CAAC;IACtD,IAAM,eAAe,GAAG,SAAS,CAAC,cAAc,CAAE,CAAC,MAAM,CAAC;IAE1D,OAAO,CACH,aAAa,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM;QAC9C,aAAa,CAAC,KAAK,CACf,UAAC,YAAY,EAAE,CAAC,IAAK,OAAA,YAAY,CAAC,QAAQ,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAApD,CAAoD,CAC5E,CACJ,CAAC;AACN,CAAC;AAED,SAAS,sBAAsB,CAAC,IAA0B,EAAE,WAAmB;IAC3E,OAAO,IAAI,CAAC,MAAM;SACb,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;SACrB,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,CAAC,mBAAmB,KAAK,SAAS,EAA9C,CAA8C,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type {\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * @param model The content model\n * @param currentItem The current list item\n * Search for all list items in the same thread as the current list item\n */\nexport function findListItemsInSameThread(\n model: ContentModelDocument,\n currentItem: ContentModelListItem\n): ContentModelListItem[] {\n const items: (ContentModelListItem | null)[] = [];\n\n findListItems(model, items);\n\n return filterListItems(items, currentItem);\n}\n\nfunction findListItems(group: ContentModelBlockGroup, result: (ContentModelListItem | null)[]) {\n group.blocks.forEach(block => {\n switch (block.blockType) {\n case 'BlockGroup':\n if (block.blockGroupType == 'ListItem') {\n result.push(block);\n } else {\n pushNullIfNecessary(result);\n findListItems(block, result);\n pushNullIfNecessary(result);\n }\n break;\n\n case 'Paragraph':\n pushNullIfNecessary(result);\n\n block.segments.forEach(segment => {\n if (segment.segmentType == 'General') {\n findListItems(segment, result);\n }\n });\n\n pushNullIfNecessary(result);\n break;\n\n case 'Table':\n pushNullIfNecessary(result);\n\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n findListItems(cell, result);\n })\n );\n pushNullIfNecessary(result);\n\n break;\n }\n });\n}\n\nfunction pushNullIfNecessary(result: (ContentModelListItem | null)[]) {\n const last = result[result.length - 1];\n\n if (!last || last !== null) {\n result.push(null);\n }\n}\n\nfunction filterListItems(\n items: (ContentModelListItem | null)[],\n currentItem: ContentModelListItem\n) {\n const result: ContentModelListItem[] = [];\n const currentIndex = items.indexOf(currentItem);\n const levelLength = currentItem.levels.length;\n const isOrderedList = currentItem.levels[levelLength - 1]?.listType == 'OL';\n\n if (currentIndex >= 0) {\n for (let i = currentIndex; i >= 0; i--) {\n const item = items[i];\n\n if (!item) {\n if (isOrderedList) {\n continue;\n } else {\n break;\n }\n }\n\n const startNumberOverride = hasStartNumberOverride(item, levelLength);\n\n if (areListTypesCompatible(items, currentIndex, i)) {\n result.unshift(item);\n\n if (isOrderedList && startNumberOverride) {\n break;\n }\n } else if (!isOrderedList || startNumberOverride) {\n break;\n }\n }\n\n for (let i = currentIndex + 1; i < items.length; i++) {\n const item = items[i];\n\n if (!item) {\n if (isOrderedList) {\n continue;\n } else {\n break;\n }\n }\n\n const startNumberOverride = hasStartNumberOverride(item, levelLength);\n\n if (areListTypesCompatible(items, currentIndex, i) && !startNumberOverride) {\n result.push(item);\n } else if (!isOrderedList || startNumberOverride) {\n break;\n }\n }\n }\n\n return result;\n}\n\nfunction areListTypesCompatible(\n listItems: (ContentModelListItem | null)[],\n currentIndex: number,\n compareToIndex: number\n): boolean {\n const currentLevels = listItems[currentIndex]!.levels;\n const compareToLevels = listItems[compareToIndex]!.levels;\n\n return (\n currentLevels.length <= compareToLevels.length &&\n currentLevels.every(\n (currentLevel, i) => currentLevel.listType == compareToLevels[i].listType\n )\n );\n}\n\nfunction hasStartNumberOverride(item: ContentModelListItem, levelLength: number): boolean {\n return item.levels\n .slice(0, levelLength)\n .some(level => level.format.startNumberOverride !== undefined);\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-
|
|
2
|
-
import { createListItem, createListLevel, normalizeContentModel, setParagraphNotImplicit, } from 'roosterjs-content-model-dom';
|
|
1
|
+
import { createListItem, createListLevel, getOperationalBlocks, isBlockGroupOfType, normalizeContentModel, setParagraphNotImplicit, } from 'roosterjs-content-model-dom';
|
|
3
2
|
/**
|
|
4
3
|
* Set a list type to content model
|
|
5
4
|
* @param model the model document
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,GAC1B,MAAM,6BAA6B,CAAC;AAOrC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACvB,KAA2B,EAC3B,QAAqB,EACrB,aAA8B;IAA9B,8BAAA,EAAA,qBAA8B;IAE9B,IAAM,oBAAo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AAY,GAAG,KAAK,CAAC,EAAzC,CAAyC,CAAC,CAAC;oBAC1E,iBAAiB,GAAG,EAAE,CAAC;iBAC1B;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;IAEH,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAE7B,OAAO,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAwB;IAC/C,QAAQ,KAAK,CAAC,SAAS,EAAE;QACrB,KAAK,OAAO;YACR,OAAO,KAAK,CAAC;QACjB,KAAK,WAAW;YACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CACvB,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAA3D,CAA2D,CACnE,CAAC;QACN;YACI,OAAO,IAAI,CAAC;KACnB;AACL,CAAC","sourcesContent":["import {\n createListItem,\n createListLevel,\n getOperationalBlocks,\n isBlockGroupOfType,\n normalizeContentModel,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelDocument,\n ContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * Set a list type to content model\n * @param model the model document\n * @param listType the list type OL | UL\n * @param removeMargins true to remove margins, false to keep margins @default false\n */\nexport function setListType(\n model: ContentModelDocument,\n listType: 'OL' | 'UL',\n removeMargins: boolean = false\n) {\n const paragraphOrListItems = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n [] // Set stop types to be empty so we can find list items even cross the boundary of table, then we can always operation on the list item if any\n );\n const alreadyInExpectedType = paragraphOrListItems.every(({ block }) =>\n isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')\n ? block.levels[block.levels.length - 1]?.listType == listType\n : shouldIgnoreBlock(block)\n );\n let existingListItems: ContentModelListItem[] = [];\n\n paragraphOrListItems.forEach(({ block, parent }, itemIndex) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const level = block.levels.pop();\n\n if (!alreadyInExpectedType && level) {\n level.listType = listType;\n block.levels.push(level);\n } else if (block.blocks.length == 1) {\n setParagraphNotImplicit(block.blocks[0]);\n }\n\n if (alreadyInExpectedType) {\n //if the list item has margins or textAlign, we need to apply them to the block to preserve the indention and alignment\n block.blocks.forEach(x => {\n if (block.format.marginLeft) {\n x.format.marginLeft = block.format.marginLeft;\n }\n\n if (block.format.marginRight) {\n x.format.marginRight = block.format.marginRight;\n }\n\n if (block.format.textAlign) {\n x.format.textAlign = block.format.textAlign;\n }\n });\n }\n } else {\n const index = parent.blocks.indexOf(block);\n\n if (index >= 0) {\n if (paragraphOrListItems.length == 1 || !shouldIgnoreBlock(block)) {\n const prevBlock = parent.blocks[index - 1];\n const segmentFormat =\n (block.blockType == 'Paragraph' && block.segments[0]?.format) || {};\n const newListItem = createListItem(\n [\n createListLevel(listType, {\n startNumberOverride:\n itemIndex > 0 ||\n (prevBlock?.blockType == 'BlockGroup' &&\n prevBlock.blockGroupType == 'ListItem' &&\n prevBlock.levels[0]?.listType == 'OL')\n ? undefined\n : 1,\n direction: block.format.direction,\n textAlign: block.format.textAlign,\n marginBottom: removeMargins ? '0px' : undefined,\n marginTop: removeMargins ? '0px' : undefined,\n }),\n ],\n // For list bullet, we only want to carry over these formats from segments:\n {\n fontFamily: segmentFormat.fontFamily,\n fontSize: segmentFormat.fontSize,\n textColor: segmentFormat.textColor,\n }\n );\n\n if (block.blockType == 'Paragraph') {\n setParagraphNotImplicit(block);\n }\n\n newListItem.blocks.push(block);\n\n if (block.format.marginRight) {\n newListItem.format.marginRight = block.format.marginRight;\n block.format.marginRight = undefined;\n }\n\n if (block.format.marginLeft) {\n newListItem.format.marginLeft = block.format.marginLeft;\n block.format.marginLeft = undefined;\n }\n\n if (block.format.textAlign) {\n newListItem.format.textAlign = block.format.textAlign;\n }\n\n parent.blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n } else {\n existingListItems.forEach(x => (x.levels[0].format.marginBottom = '0px'));\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ContentModelBlock) {\n switch (block.blockType) {\n case 'Table':\n return false;\n case 'Paragraph':\n return block.segments.every(\n x => x.segmentType == 'Br' || x.segmentType == 'SelectionMarker'\n );\n default:\n return true;\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContentModelDocument } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Set start number of a list item
|
|
4
|
+
* @param model The model document
|
|
5
|
+
* @param value The number to set to, must be equal or greater than 1
|
|
6
|
+
*/
|
|
7
|
+
export declare function setModelListStartNumber(model: ContentModelDocument, value: number): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getFirstSelectedListItem } from 'roosterjs-content-model-dom';
|
|
2
|
+
/**
|
|
3
|
+
* Set start number of a list item
|
|
4
|
+
* @param model The model document
|
|
5
|
+
* @param value The number to set to, must be equal or greater than 1
|
|
6
|
+
*/
|
|
7
|
+
export function setModelListStartNumber(model, value) {
|
|
8
|
+
var listItem = getFirstSelectedListItem(model);
|
|
9
|
+
var level = listItem === null || listItem === void 0 ? void 0 : listItem.levels[(listItem === null || listItem === void 0 ? void 0 : listItem.levels.length) - 1];
|
|
10
|
+
if (level) {
|
|
11
|
+
level.format.startNumberOverride = value;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=setModelListStartNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setModelListStartNumber.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/setModelListStartNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAA2B,EAAE,KAAa;IAC9E,IAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACjD,IAAM,KAAK,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,MAAM,IAAG,CAAC,CAAC,CAAC;IAE5D,IAAI,KAAK,EAAE;QACP,KAAK,CAAC,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC;QAEzC,OAAO,IAAI,CAAC;KACf;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { getFirstSelectedListItem } from 'roosterjs-content-model-dom';\nimport type { ContentModelDocument } from 'roosterjs-content-model-types';\n\n/**\n * Set start number of a list item\n * @param model The model document\n * @param value The number to set to, must be equal or greater than 1\n */\nexport function setModelListStartNumber(model: ContentModelDocument, value: number) {\n const listItem = getFirstSelectedListItem(model);\n const level = listItem?.levels[listItem?.levels.length - 1];\n\n if (level) {\n level.format.startNumberOverride = value;\n\n return true;\n } else {\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContentModelDocument, ListMetadataFormat } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Set style of list items with in same thread of current item
|
|
4
|
+
* @param model The model document
|
|
5
|
+
* @param style The style to set
|
|
6
|
+
*/
|
|
7
|
+
export declare function setModelListStyle(model: ContentModelDocument, style: ListMetadataFormat): boolean;
|