roosterjs-content-model-api 9.6.0 → 9.8.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/lib/index.d.ts +1 -0
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/modelApi/list/setListType.js +9 -0
- package/lib/modelApi/list/setListType.js.map +1 -1
- package/lib/publicApi/segment/splitTextSegment.d.ts +10 -0
- package/lib/publicApi/segment/splitTextSegment.js +31 -0
- package/lib/publicApi/segment/splitTextSegment.js.map +1 -0
- package/lib-amd/index.d.ts +1 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/modelApi/list/setListType.js +9 -0
- package/lib-amd/modelApi/list/setListType.js.map +1 -1
- package/lib-amd/publicApi/segment/splitTextSegment.d.ts +10 -0
- package/lib-amd/publicApi/segment/splitTextSegment.js +31 -0
- package/lib-amd/publicApi/segment/splitTextSegment.js.map +1 -0
- package/lib-mjs/index.d.ts +1 -0
- package/lib-mjs/index.js +1 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/modelApi/list/setListType.js +10 -1
- package/lib-mjs/modelApi/list/setListType.js.map +1 -1
- package/lib-mjs/publicApi/segment/splitTextSegment.d.ts +10 -0
- package/lib-mjs/publicApi/segment/splitTextSegment.js +27 -0
- package/lib-mjs/publicApi/segment/splitTextSegment.js.map +1 -0
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { setTextColor } from './publicApi/segment/setTextColor';
|
|
|
18
18
|
export { changeFontSize } from './publicApi/segment/changeFontSize';
|
|
19
19
|
export { applySegmentFormat } from './publicApi/segment/applySegmentFormat';
|
|
20
20
|
export { changeCapitalization } from './publicApi/segment/changeCapitalization';
|
|
21
|
+
export { splitTextSegment } from './publicApi/segment/splitTextSegment';
|
|
21
22
|
export { insertImage } from './publicApi/image/insertImage';
|
|
22
23
|
export { setListStyle } from './publicApi/list/setListStyle';
|
|
23
24
|
export { setListStartNumber } from './publicApi/list/setListStartNumber';
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.getListAnnounceData = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = void 0;
|
|
3
|
+
exports.formatSegmentWithContentModel = exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.clearSelectedCells = exports.insertTableColumn = exports.insertTableRow = exports.insertEntity = exports.toggleCode = exports.setParagraphMargin = exports.adjustImageSelection = exports.setImageAltText = exports.adjustLinkSelection = exports.removeLink = exports.insertLink = exports.clearFormat = exports.getFormatState = exports.changeImage = exports.setImageBoxShadow = exports.setImageBorder = exports.setSpacing = exports.toggleBlockQuote = exports.setHeadingLevel = exports.setDirection = exports.setAlignment = exports.setIndentation = exports.setListStartNumber = exports.setListStyle = exports.insertImage = exports.splitTextSegment = exports.changeCapitalization = exports.applySegmentFormat = exports.changeFontSize = exports.setTextColor = exports.setFontSize = exports.setFontName = exports.setBackgroundColor = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleUnderline = exports.toggleItalic = exports.toggleBold = exports.toggleNumbering = exports.toggleBullet = exports.applyTableBorderFormat = exports.editTable = exports.setTableCellShade = exports.formatTable = exports.insertTable = void 0;
|
|
4
|
+
exports.getListAnnounceData = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = void 0;
|
|
5
5
|
var insertTable_1 = require("./publicApi/table/insertTable");
|
|
6
6
|
Object.defineProperty(exports, "insertTable", { enumerable: true, get: function () { return insertTable_1.insertTable; } });
|
|
7
7
|
var formatTable_1 = require("./publicApi/table/formatTable");
|
|
@@ -42,6 +42,8 @@ var applySegmentFormat_1 = require("./publicApi/segment/applySegmentFormat");
|
|
|
42
42
|
Object.defineProperty(exports, "applySegmentFormat", { enumerable: true, get: function () { return applySegmentFormat_1.applySegmentFormat; } });
|
|
43
43
|
var changeCapitalization_1 = require("./publicApi/segment/changeCapitalization");
|
|
44
44
|
Object.defineProperty(exports, "changeCapitalization", { enumerable: true, get: function () { return changeCapitalization_1.changeCapitalization; } });
|
|
45
|
+
var splitTextSegment_1 = require("./publicApi/segment/splitTextSegment");
|
|
46
|
+
Object.defineProperty(exports, "splitTextSegment", { enumerable: true, get: function () { return splitTextSegment_1.splitTextSegment; } });
|
|
45
47
|
var insertImage_1 = require("./publicApi/image/insertImage");
|
|
46
48
|
Object.defineProperty(exports, "insertImage", { enumerable: true, get: function () { return insertImage_1.insertImage; } });
|
|
47
49
|
var setListStyle_1 = require("./publicApi/list/setListStyle");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":";;;;AAAA,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,yEAAwE;AAA/D,sHAAA,iBAAiB,OAAA;AAC1B,yDAAwD;AAA/C,sGAAA,SAAS,OAAA;AAClB,mFAAkF;AAAzE,gIAAA,sBAAsB,OAAA;AAC/B,8DAA6D;AAApD,4GAAA,YAAY,OAAA;AACrB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AACxB,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AACrB,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,+EAA8E;AAArE,0HAAA,mBAAmB,OAAA;AAC5B,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AAC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4GAAA,YAAY,OAAA;AACrB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,wEAAuE;AAA9D,sHAAA,iBAAiB,OAAA;AAC1B,0EAAyE;AAAhE,wHAAA,kBAAkB,OAAA;AAE3B,6FAA4F;AAAnF,0IAAA,2BAA2B,OAAA;AACpC,6FAA4F;AAAnF,0IAAA,2BAA2B,OAAA;AACpC,qGAAoG;AAA3F,kJAAA,+BAA+B,OAAA;AACxC,iGAAgG;AAAvF,8IAAA,6BAA6B,OAAA;AACtC,mHAAkH;AAAzG,gKAAA,sCAAsC,OAAA;AAC/C,yGAAwG;AAA/F,sJAAA,iCAAiC,OAAA;AAE1C,2DAA0D;AAAjD,0GAAA,WAAW,OAAA;AACpB,uEAAsE;AAA7D,sHAAA,iBAAiB,OAAA;AAC1B,mFAAkF;AAAzE,kIAAA,uBAAuB,OAAA;AAChC,uFAAsF;AAA7E,sIAAA,yBAAyB,OAAA;AAClC,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAC5B,uDAAsD;AAA7C,sGAAA,SAAS,OAAA;AAClB,2EAA0E;AAAjE,0HAAA,mBAAmB,OAAA","sourcesContent":["export { insertTable } from './publicApi/table/insertTable';\nexport { formatTable } from './publicApi/table/formatTable';\nexport { setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { editTable } from './publicApi/table/editTable';\nexport { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { toggleBullet } from './publicApi/list/toggleBullet';\nexport { toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { toggleBold } from './publicApi/segment/toggleBold';\nexport { toggleItalic } from './publicApi/segment/toggleItalic';\nexport { toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { setFontName } from './publicApi/segment/setFontName';\nexport { setFontSize } from './publicApi/segment/setFontSize';\nexport { setTextColor } from './publicApi/segment/setTextColor';\nexport { changeFontSize } from './publicApi/segment/changeFontSize';\nexport { applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { insertImage } from './publicApi/image/insertImage';\nexport { setListStyle } from './publicApi/list/setListStyle';\nexport { setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { setIndentation } from './publicApi/block/setIndentation';\nexport { setAlignment } from './publicApi/block/setAlignment';\nexport { setDirection } from './publicApi/block/setDirection';\nexport { setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { setSpacing } from './publicApi/block/setSpacing';\nexport { setImageBorder } from './publicApi/image/setImageBorder';\nexport { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { changeImage } from './publicApi/image/changeImage';\nexport { getFormatState } from './publicApi/format/getFormatState';\nexport { clearFormat } from './publicApi/format/clearFormat';\nexport { insertLink } from './publicApi/link/insertLink';\nexport { removeLink } from './publicApi/link/removeLink';\nexport { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { setImageAltText } from './publicApi/image/setImageAltText';\nexport { adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { toggleCode } from './publicApi/segment/toggleCode';\nexport { insertEntity } from './publicApi/entity/insertEntity';\nexport { insertTableRow } from './modelApi/table/insertTableRow';\nexport { insertTableColumn } from './modelApi/table/insertTableColumn';\nexport { clearSelectedCells } from './modelApi/table/clearSelectedCells';\n\nexport { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';\nexport { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';\nexport { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';\nexport { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';\nexport { formatTextSegmentBeforeSelectionMarker } from './publicApi/utils/formatTextSegmentBeforeSelectionMarker';\nexport { formatInsertPointWithContentModel } from './publicApi/utils/formatInsertPointWithContentModel';\n\nexport { setListType } from './modelApi/list/setListType';\nexport { setModelListStyle } from './modelApi/list/setModelListStyle';\nexport { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';\nexport { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';\nexport { setModelIndentation } from './modelApi/block/setModelIndentation';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":";;;;AAAA,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,yEAAwE;AAA/D,sHAAA,iBAAiB,OAAA;AAC1B,yDAAwD;AAA/C,sGAAA,SAAS,OAAA;AAClB,mFAAkF;AAAzE,gIAAA,sBAAsB,OAAA;AAC/B,8DAA6D;AAApD,4GAAA,YAAY,OAAA;AACrB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AACxB,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AACrB,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,+EAA8E;AAArE,0HAAA,mBAAmB,OAAA;AAC5B,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,2EAA0E;AAAjE,sHAAA,iBAAiB,OAAA;AAC1B,6EAA4E;AAAnE,wHAAA,kBAAkB,OAAA;AAC3B,+DAA8D;AAArD,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,0GAAA,WAAW,OAAA;AACpB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AACrB,qEAAoE;AAA3D,gHAAA,cAAc,OAAA;AACvB,6EAA4E;A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,2BAA2B,OAAA;AACpC,qGAAoG;AAA3F,kJAAA,+BAA+B,OAAA;AACxC,iGAAgG;AAAvF,8IAAA,6BAA6B,OAAA;AACtC,mHAAkH;AAAzG,gKAAA,sCAAsC,OAAA;AAC/C,yGAAwG;AAA/F,sJAAA,iCAAiC,OAAA;AAE1C,2DAA0D;AAAjD,0GAAA,WAAW,OAAA;AACpB,uEAAsE;AAA7D,sHAAA,iBAAiB,OAAA;AAC1B,mFAAkF;AAAzE,kIAAA,uBAAuB,OAAA;AAChC,uFAAsF;AAA7E,sIAAA,yBAAyB,OAAA;AAClC,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAC5B,uDAAsD;AAA7C,sGAAA,SAAS,OAAA;AAClB,2EAA0E;AAAjE,0HAAA,mBAAmB,OAAA","sourcesContent":["export { insertTable } from './publicApi/table/insertTable';\nexport { formatTable } from './publicApi/table/formatTable';\nexport { setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { editTable } from './publicApi/table/editTable';\nexport { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { toggleBullet } from './publicApi/list/toggleBullet';\nexport { toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { toggleBold } from './publicApi/segment/toggleBold';\nexport { toggleItalic } from './publicApi/segment/toggleItalic';\nexport { toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { setFontName } from './publicApi/segment/setFontName';\nexport { setFontSize } from './publicApi/segment/setFontSize';\nexport { setTextColor } from './publicApi/segment/setTextColor';\nexport { changeFontSize } from './publicApi/segment/changeFontSize';\nexport { applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { splitTextSegment } from './publicApi/segment/splitTextSegment';\nexport { insertImage } from './publicApi/image/insertImage';\nexport { setListStyle } from './publicApi/list/setListStyle';\nexport { setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { setIndentation } from './publicApi/block/setIndentation';\nexport { setAlignment } from './publicApi/block/setAlignment';\nexport { setDirection } from './publicApi/block/setDirection';\nexport { setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { setSpacing } from './publicApi/block/setSpacing';\nexport { setImageBorder } from './publicApi/image/setImageBorder';\nexport { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { changeImage } from './publicApi/image/changeImage';\nexport { getFormatState } from './publicApi/format/getFormatState';\nexport { clearFormat } from './publicApi/format/clearFormat';\nexport { insertLink } from './publicApi/link/insertLink';\nexport { removeLink } from './publicApi/link/removeLink';\nexport { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { setImageAltText } from './publicApi/image/setImageAltText';\nexport { adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { toggleCode } from './publicApi/segment/toggleCode';\nexport { insertEntity } from './publicApi/entity/insertEntity';\nexport { insertTableRow } from './modelApi/table/insertTableRow';\nexport { insertTableColumn } from './modelApi/table/insertTableColumn';\nexport { clearSelectedCells } from './modelApi/table/clearSelectedCells';\n\nexport { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';\nexport { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';\nexport { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';\nexport { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';\nexport { formatTextSegmentBeforeSelectionMarker } from './publicApi/utils/formatTextSegmentBeforeSelectionMarker';\nexport { formatInsertPointWithContentModel } from './publicApi/utils/formatInsertPointWithContentModel';\n\nexport { setListType } from './modelApi/list/setListType';\nexport { setModelListStyle } from './modelApi/list/setModelListStyle';\nexport { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';\nexport { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';\nexport { setModelIndentation } from './modelApi/block/setModelIndentation';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\n"]}
|
|
@@ -91,6 +91,15 @@ function setListType(model, listType, removeMargins) {
|
|
|
91
91
|
}
|
|
92
92
|
(0, roosterjs_content_model_dom_1.mutateBlock)(parent).blocks.splice(index, 1, newListItem);
|
|
93
93
|
existingListItems.push(newListItem);
|
|
94
|
+
var levelIndex = newListItem.levels.length - 1;
|
|
95
|
+
var level = (0, roosterjs_content_model_dom_1.mutateBlock)(newListItem).levels[levelIndex];
|
|
96
|
+
if (level) {
|
|
97
|
+
(0, roosterjs_content_model_dom_1.updateListMetadata)(level, function (metadata) {
|
|
98
|
+
return Object.assign({}, metadata, {
|
|
99
|
+
applyListStyleFromLevel: true,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
94
103
|
}
|
|
95
104
|
else {
|
|
96
105
|
existingListItems.forEach(function (x) { return ((0, roosterjs_content_model_dom_1.mutateBlock)(x).levels[0].format.marginBottom = '0px'); });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;AAAA,2EAQqC;AASrC;;;;;GAKG;AACH,SAAgB,WAAW,CACvB,KAAmC,EACnC,QAAqB,EACrB,aAA8B;IAA9B,8BAAA,EAAA,qBAA8B;IAE9B,IAAM,oBAAoB,GAAG,IAAA,kDAAoB,EAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;KACpJ,CAAC;IACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;YAAP,KAAK,WAAA;QAC7D,OAAA,IAAA,gDAAkB,EAA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F,iBAAiB,GAAG,EAAE,CAAC;iBAC1B;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;IAE7B,OAAO,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3C,CAAC;AAjHD,kCAiHC;AAED,SAAS,iBAAiB,CAAC,KAAgC;IACvD,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 mutateBlock,\n normalizeContentModel,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\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: ReadonlyContentModelDocument,\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: ReadonlyContentModelListItem[] = [];\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: ShallowMutableContentModelListItem = 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 const mutableBlock = mutateBlock(block);\n\n newListItem.blocks.push(mutableBlock);\n\n if (mutableBlock.format.marginRight) {\n newListItem.format.marginRight = mutableBlock.format.marginRight;\n mutableBlock.format.marginRight = undefined;\n }\n\n if (mutableBlock.format.marginLeft) {\n newListItem.format.marginLeft = mutableBlock.format.marginLeft;\n mutableBlock.format.marginLeft = undefined;\n }\n\n if (mutableBlock.format.textAlign) {\n newListItem.format.textAlign = mutableBlock.format.textAlign;\n }\n\n mutateBlock(parent).blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n } else {\n existingListItems.forEach(\n x => (mutateBlock(x).levels[0].format.marginBottom = '0px')\n );\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ReadonlyContentModelBlock) {\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"]}
|
|
1
|
+
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;AAAA,2EASqC;AASrC;;;;;GAKG;AACH,SAAgB,WAAW,CACvB,KAAmC,EACnC,QAAqB,EACrB,aAA8B;IAA9B,8BAAA,EAAA,qBAA8B;IAE9B,IAAM,oBAAoB,GAAG,IAAA,kDAAoB,EAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;KACpJ,CAAC;IACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;YAAP,KAAK,WAAA;QAC7D,OAAA,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC;YACvD,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,QAAQ,KAAI,QAAQ;YAC7D,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;KAAA,CACjC,CAAC;IACF,IAAI,iBAAiB,GAAmC,EAAE,CAAC;IAE3D,oBAAoB,CAAC,OAAO,CAAC,UAAC,EAAiB,EAAE,SAAS;;YAA1B,KA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,KAAK,CAAC,EAAtD,CAAsD,CAC9D,CAAC;oBACF,iBAAiB,GAAG,EAAE,CAAC;iBAC1B;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;IAE7B,OAAO,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3C,CAAC;AA5HD,kCA4HC;AAED,SAAS,iBAAiB,CAAC,KAAgC;IACvD,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 mutateBlock,\n normalizeContentModel,\n setParagraphNotImplicit,\n updateListMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\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: ReadonlyContentModelDocument,\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: ReadonlyContentModelListItem[] = [];\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: ShallowMutableContentModelListItem = 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 const mutableBlock = mutateBlock(block);\n\n newListItem.blocks.push(mutableBlock);\n\n if (mutableBlock.format.marginRight) {\n newListItem.format.marginRight = mutableBlock.format.marginRight;\n mutableBlock.format.marginRight = undefined;\n }\n\n if (mutableBlock.format.marginLeft) {\n newListItem.format.marginLeft = mutableBlock.format.marginLeft;\n mutableBlock.format.marginLeft = undefined;\n }\n\n if (mutableBlock.format.textAlign) {\n newListItem.format.textAlign = mutableBlock.format.textAlign;\n }\n\n mutateBlock(parent).blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n\n const levelIndex = newListItem.levels.length - 1;\n const level = mutateBlock(newListItem).levels[levelIndex];\n\n if (level) {\n updateListMetadata(level, metadata =>\n Object.assign({}, metadata, {\n applyListStyleFromLevel: true,\n })\n );\n }\n } else {\n existingListItems.forEach(\n x => (mutateBlock(x).levels[0].format.marginBottom = '0px')\n );\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ReadonlyContentModelBlock) {\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,10 @@
|
|
|
1
|
+
import type { ContentModelText, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Split given text segments from the given range
|
|
4
|
+
* @param textSegment segment to split
|
|
5
|
+
* @param parent parent paragraph the text segment exist in
|
|
6
|
+
* @param start starting point of the split
|
|
7
|
+
* @param end ending point of the split
|
|
8
|
+
* @returns text segment from the indicated split.
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitTextSegment(textSegment: ContentModelText, parent: ShallowMutableContentModelParagraph, start: number, end: number): ContentModelText;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitTextSegment = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
+
/**
|
|
7
|
+
* Split given text segments from the given range
|
|
8
|
+
* @param textSegment segment to split
|
|
9
|
+
* @param parent parent paragraph the text segment exist in
|
|
10
|
+
* @param start starting point of the split
|
|
11
|
+
* @param end ending point of the split
|
|
12
|
+
* @returns text segment from the indicated split.
|
|
13
|
+
*/
|
|
14
|
+
function splitTextSegment(textSegment, parent, start, end) {
|
|
15
|
+
var _a;
|
|
16
|
+
var text = textSegment.text;
|
|
17
|
+
var index = parent.segments.indexOf(textSegment);
|
|
18
|
+
var middleSegment = (0, roosterjs_content_model_dom_1.createText)(text.substring(start, end), textSegment.format, textSegment.link, textSegment.code);
|
|
19
|
+
var newSegments = [middleSegment];
|
|
20
|
+
if (start > 0) {
|
|
21
|
+
newSegments.unshift((0, roosterjs_content_model_dom_1.createText)(text.substring(0, start), textSegment.format, textSegment.link, textSegment.code));
|
|
22
|
+
}
|
|
23
|
+
if (end < text.length) {
|
|
24
|
+
newSegments.push((0, roosterjs_content_model_dom_1.createText)(text.substring(end), textSegment.format, textSegment.link, textSegment.code));
|
|
25
|
+
}
|
|
26
|
+
newSegments.forEach(function (segment) { return (segment.isSelected = textSegment.isSelected); });
|
|
27
|
+
(_a = parent.segments).splice.apply(_a, (0, tslib_1.__spreadArray)([index, 1], (0, tslib_1.__read)(newSegments), false));
|
|
28
|
+
return middleSegment;
|
|
29
|
+
}
|
|
30
|
+
exports.splitTextSegment = splitTextSegment;
|
|
31
|
+
//# sourceMappingURL=splitTextSegment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/splitTextSegment.ts"],"names":[],"mappings":";;;;AAAA,2EAAyD;AAMzD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC5B,WAA6B,EAC7B,MAA2C,EAC3C,KAAa,EACb,GAAW;;IAEX,IAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,IAAM,aAAa,GAAG,IAAA,wCAAU,EAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,EAC1B,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CACnB,CAAC;IAEF,IAAM,WAAW,GAAuB,CAAC,aAAa,CAAC,CAAC;IACxD,IAAI,KAAK,GAAG,CAAC,EAAE;QACX,WAAW,CAAC,OAAO,CACf,IAAA,wCAAU,EACN,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EACxB,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CACnB,CACJ,CAAC;KACL;IACD,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE;QACnB,WAAW,CAAC,IAAI,CACZ,IAAA,wCAAU,EAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAC1F,CAAC;KACL;IAED,WAAW,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,CAAC,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,EAA7C,CAA6C,CAAC,CAAC;IAC9E,CAAA,KAAA,MAAM,CAAC,QAAQ,CAAA,CAAC,MAAM,uCAAC,KAAK,EAAE,CAAC,uBAAK,WAAW,WAAE;IAEjD,OAAO,aAAa,CAAC;AACzB,CAAC;AApCD,4CAoCC","sourcesContent":["import { createText } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Split given text segments from the given range\n * @param textSegment segment to split\n * @param parent parent paragraph the text segment exist in\n * @param start starting point of the split\n * @param end ending point of the split\n * @returns text segment from the indicated split.\n */\nexport function splitTextSegment(\n textSegment: ContentModelText,\n parent: ShallowMutableContentModelParagraph,\n start: number,\n end: number\n): ContentModelText {\n const text = textSegment.text;\n const index = parent.segments.indexOf(textSegment);\n const middleSegment = createText(\n text.substring(start, end),\n textSegment.format,\n textSegment.link,\n textSegment.code\n );\n\n const newSegments: ContentModelText[] = [middleSegment];\n if (start > 0) {\n newSegments.unshift(\n createText(\n text.substring(0, start),\n textSegment.format,\n textSegment.link,\n textSegment.code\n )\n );\n }\n if (end < text.length) {\n newSegments.push(\n createText(text.substring(end), textSegment.format, textSegment.link, textSegment.code)\n );\n }\n\n newSegments.forEach(segment => (segment.isSelected = textSegment.isSelected));\n parent.segments.splice(index, 1, ...newSegments);\n\n return middleSegment;\n}\n"]}
|
package/lib-amd/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { setTextColor } from './publicApi/segment/setTextColor';
|
|
|
18
18
|
export { changeFontSize } from './publicApi/segment/changeFontSize';
|
|
19
19
|
export { applySegmentFormat } from './publicApi/segment/applySegmentFormat';
|
|
20
20
|
export { changeCapitalization } from './publicApi/segment/changeCapitalization';
|
|
21
|
+
export { splitTextSegment } from './publicApi/segment/splitTextSegment';
|
|
21
22
|
export { insertImage } from './publicApi/image/insertImage';
|
|
22
23
|
export { setListStyle } from './publicApi/list/setListStyle';
|
|
23
24
|
export { setListStartNumber } from './publicApi/list/setListStartNumber';
|
package/lib-amd/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
define(["require", "exports", "./publicApi/table/insertTable", "./publicApi/table/formatTable", "./publicApi/table/setTableCellShade", "./publicApi/table/editTable", "./publicApi/table/applyTableBorderFormat", "./publicApi/list/toggleBullet", "./publicApi/list/toggleNumbering", "./publicApi/segment/toggleBold", "./publicApi/segment/toggleItalic", "./publicApi/segment/toggleUnderline", "./publicApi/segment/toggleStrikethrough", "./publicApi/segment/toggleSubscript", "./publicApi/segment/toggleSuperscript", "./publicApi/segment/setBackgroundColor", "./publicApi/segment/setFontName", "./publicApi/segment/setFontSize", "./publicApi/segment/setTextColor", "./publicApi/segment/changeFontSize", "./publicApi/segment/applySegmentFormat", "./publicApi/segment/changeCapitalization", "./publicApi/image/insertImage", "./publicApi/list/setListStyle", "./publicApi/list/setListStartNumber", "./publicApi/block/setIndentation", "./publicApi/block/setAlignment", "./publicApi/block/setDirection", "./publicApi/block/setHeadingLevel", "./publicApi/block/toggleBlockQuote", "./publicApi/block/setSpacing", "./publicApi/image/setImageBorder", "./publicApi/image/setImageBoxShadow", "./publicApi/image/changeImage", "./publicApi/format/getFormatState", "./publicApi/format/clearFormat", "./publicApi/link/insertLink", "./publicApi/link/removeLink", "./publicApi/link/adjustLinkSelection", "./publicApi/image/setImageAltText", "./publicApi/image/adjustImageSelection", "./publicApi/block/setParagraphMargin", "./publicApi/segment/toggleCode", "./publicApi/entity/insertEntity", "./modelApi/table/insertTableRow", "./modelApi/table/insertTableColumn", "./modelApi/table/clearSelectedCells", "./publicApi/utils/formatTableWithContentModel", "./publicApi/utils/formatImageWithContentModel", "./publicApi/utils/formatParagraphWithContentModel", "./publicApi/utils/formatSegmentWithContentModel", "./publicApi/utils/formatTextSegmentBeforeSelectionMarker", "./publicApi/utils/formatInsertPointWithContentModel", "./modelApi/list/setListType", "./modelApi/list/setModelListStyle", "./modelApi/list/setModelListStartNumber", "./modelApi/list/findListItemsInSameThread", "./modelApi/block/setModelIndentation", "./modelApi/link/matchLink", "./modelApi/list/getListAnnounceData"], function (require, exports, insertTable_1, formatTable_1, setTableCellShade_1, editTable_1, applyTableBorderFormat_1, toggleBullet_1, toggleNumbering_1, toggleBold_1, toggleItalic_1, toggleUnderline_1, toggleStrikethrough_1, toggleSubscript_1, toggleSuperscript_1, setBackgroundColor_1, setFontName_1, setFontSize_1, setTextColor_1, changeFontSize_1, applySegmentFormat_1, changeCapitalization_1, insertImage_1, setListStyle_1, setListStartNumber_1, setIndentation_1, setAlignment_1, setDirection_1, setHeadingLevel_1, toggleBlockQuote_1, setSpacing_1, setImageBorder_1, setImageBoxShadow_1, changeImage_1, getFormatState_1, clearFormat_1, insertLink_1, removeLink_1, adjustLinkSelection_1, setImageAltText_1, adjustImageSelection_1, setParagraphMargin_1, toggleCode_1, insertEntity_1, insertTableRow_1, insertTableColumn_1, clearSelectedCells_1, formatTableWithContentModel_1, formatImageWithContentModel_1, formatParagraphWithContentModel_1, formatSegmentWithContentModel_1, formatTextSegmentBeforeSelectionMarker_1, formatInsertPointWithContentModel_1, setListType_1, setModelListStyle_1, setModelListStartNumber_1, findListItemsInSameThread_1, setModelIndentation_1, matchLink_1, getListAnnounceData_1) {
|
|
1
|
+
define(["require", "exports", "./publicApi/table/insertTable", "./publicApi/table/formatTable", "./publicApi/table/setTableCellShade", "./publicApi/table/editTable", "./publicApi/table/applyTableBorderFormat", "./publicApi/list/toggleBullet", "./publicApi/list/toggleNumbering", "./publicApi/segment/toggleBold", "./publicApi/segment/toggleItalic", "./publicApi/segment/toggleUnderline", "./publicApi/segment/toggleStrikethrough", "./publicApi/segment/toggleSubscript", "./publicApi/segment/toggleSuperscript", "./publicApi/segment/setBackgroundColor", "./publicApi/segment/setFontName", "./publicApi/segment/setFontSize", "./publicApi/segment/setTextColor", "./publicApi/segment/changeFontSize", "./publicApi/segment/applySegmentFormat", "./publicApi/segment/changeCapitalization", "./publicApi/segment/splitTextSegment", "./publicApi/image/insertImage", "./publicApi/list/setListStyle", "./publicApi/list/setListStartNumber", "./publicApi/block/setIndentation", "./publicApi/block/setAlignment", "./publicApi/block/setDirection", "./publicApi/block/setHeadingLevel", "./publicApi/block/toggleBlockQuote", "./publicApi/block/setSpacing", "./publicApi/image/setImageBorder", "./publicApi/image/setImageBoxShadow", "./publicApi/image/changeImage", "./publicApi/format/getFormatState", "./publicApi/format/clearFormat", "./publicApi/link/insertLink", "./publicApi/link/removeLink", "./publicApi/link/adjustLinkSelection", "./publicApi/image/setImageAltText", "./publicApi/image/adjustImageSelection", "./publicApi/block/setParagraphMargin", "./publicApi/segment/toggleCode", "./publicApi/entity/insertEntity", "./modelApi/table/insertTableRow", "./modelApi/table/insertTableColumn", "./modelApi/table/clearSelectedCells", "./publicApi/utils/formatTableWithContentModel", "./publicApi/utils/formatImageWithContentModel", "./publicApi/utils/formatParagraphWithContentModel", "./publicApi/utils/formatSegmentWithContentModel", "./publicApi/utils/formatTextSegmentBeforeSelectionMarker", "./publicApi/utils/formatInsertPointWithContentModel", "./modelApi/list/setListType", "./modelApi/list/setModelListStyle", "./modelApi/list/setModelListStartNumber", "./modelApi/list/findListItemsInSameThread", "./modelApi/block/setModelIndentation", "./modelApi/link/matchLink", "./modelApi/list/getListAnnounceData"], function (require, exports, insertTable_1, formatTable_1, setTableCellShade_1, editTable_1, applyTableBorderFormat_1, toggleBullet_1, toggleNumbering_1, toggleBold_1, toggleItalic_1, toggleUnderline_1, toggleStrikethrough_1, toggleSubscript_1, toggleSuperscript_1, setBackgroundColor_1, setFontName_1, setFontSize_1, setTextColor_1, changeFontSize_1, applySegmentFormat_1, changeCapitalization_1, splitTextSegment_1, insertImage_1, setListStyle_1, setListStartNumber_1, setIndentation_1, setAlignment_1, setDirection_1, setHeadingLevel_1, toggleBlockQuote_1, setSpacing_1, setImageBorder_1, setImageBoxShadow_1, changeImage_1, getFormatState_1, clearFormat_1, insertLink_1, removeLink_1, adjustLinkSelection_1, setImageAltText_1, adjustImageSelection_1, setParagraphMargin_1, toggleCode_1, insertEntity_1, insertTableRow_1, insertTableColumn_1, clearSelectedCells_1, formatTableWithContentModel_1, formatImageWithContentModel_1, formatParagraphWithContentModel_1, formatSegmentWithContentModel_1, formatTextSegmentBeforeSelectionMarker_1, formatInsertPointWithContentModel_1, setListType_1, setModelListStyle_1, setModelListStartNumber_1, findListItemsInSameThread_1, setModelIndentation_1, matchLink_1, getListAnnounceData_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getListAnnounceData = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.clearSelectedCells = exports.insertTableColumn = exports.insertTableRow = exports.insertEntity = exports.toggleCode = exports.setParagraphMargin = exports.adjustImageSelection = exports.setImageAltText = exports.adjustLinkSelection = exports.removeLink = exports.insertLink = exports.clearFormat = exports.getFormatState = exports.changeImage = exports.setImageBoxShadow = exports.setImageBorder = exports.setSpacing = exports.toggleBlockQuote = exports.setHeadingLevel = exports.setDirection = exports.setAlignment = exports.setIndentation = exports.setListStartNumber = exports.setListStyle = exports.insertImage = exports.changeCapitalization = exports.applySegmentFormat = exports.changeFontSize = exports.setTextColor = exports.setFontSize = exports.setFontName = exports.setBackgroundColor = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleUnderline = exports.toggleItalic = exports.toggleBold = exports.toggleNumbering = exports.toggleBullet = exports.applyTableBorderFormat = exports.editTable = exports.setTableCellShade = exports.formatTable = exports.insertTable = void 0;
|
|
4
|
+
exports.getListAnnounceData = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.clearSelectedCells = exports.insertTableColumn = exports.insertTableRow = exports.insertEntity = exports.toggleCode = exports.setParagraphMargin = exports.adjustImageSelection = exports.setImageAltText = exports.adjustLinkSelection = exports.removeLink = exports.insertLink = exports.clearFormat = exports.getFormatState = exports.changeImage = exports.setImageBoxShadow = exports.setImageBorder = exports.setSpacing = exports.toggleBlockQuote = exports.setHeadingLevel = exports.setDirection = exports.setAlignment = exports.setIndentation = exports.setListStartNumber = exports.setListStyle = exports.insertImage = exports.splitTextSegment = exports.changeCapitalization = exports.applySegmentFormat = exports.changeFontSize = exports.setTextColor = exports.setFontSize = exports.setFontName = exports.setBackgroundColor = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleUnderline = exports.toggleItalic = exports.toggleBold = exports.toggleNumbering = exports.toggleBullet = exports.applyTableBorderFormat = exports.editTable = exports.setTableCellShade = exports.formatTable = exports.insertTable = void 0;
|
|
5
5
|
Object.defineProperty(exports, "insertTable", { enumerable: true, get: function () { return insertTable_1.insertTable; } });
|
|
6
6
|
Object.defineProperty(exports, "formatTable", { enumerable: true, get: function () { return formatTable_1.formatTable; } });
|
|
7
7
|
Object.defineProperty(exports, "setTableCellShade", { enumerable: true, get: function () { return setTableCellShade_1.setTableCellShade; } });
|
|
@@ -22,6 +22,7 @@ define(["require", "exports", "./publicApi/table/insertTable", "./publicApi/tabl
|
|
|
22
22
|
Object.defineProperty(exports, "changeFontSize", { enumerable: true, get: function () { return changeFontSize_1.changeFontSize; } });
|
|
23
23
|
Object.defineProperty(exports, "applySegmentFormat", { enumerable: true, get: function () { return applySegmentFormat_1.applySegmentFormat; } });
|
|
24
24
|
Object.defineProperty(exports, "changeCapitalization", { enumerable: true, get: function () { return changeCapitalization_1.changeCapitalization; } });
|
|
25
|
+
Object.defineProperty(exports, "splitTextSegment", { enumerable: true, get: function () { return splitTextSegment_1.splitTextSegment; } });
|
|
25
26
|
Object.defineProperty(exports, "insertImage", { enumerable: true, get: function () { return insertImage_1.insertImage; } });
|
|
26
27
|
Object.defineProperty(exports, "setListStyle", { enumerable: true, get: function () { return setListStyle_1.setListStyle; } });
|
|
27
28
|
Object.defineProperty(exports, "setListStartNumber", { enumerable: true, get: function () { return setListStartNumber_1.setListStartNumber; } });
|
package/lib-amd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-api/lib/index.ts"],"names":[],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+B,OAAA;IAC/B,8IAAA,6BAA6B,OAAA;IAC7B,gKAAA,sCAAsC,OAAA;IACtC,sJAAA,iCAAiC,OAAA;IAEjC,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,kIAAA,uBAAuB,OAAA;IACvB,sIAAA,yBAAyB,OAAA;IACzB,0HAAA,mBAAmB,OAAA;IACnB,sGAAA,SAAS,OAAA;IACT,0HAAA,mBAAmB,OAAA","sourcesContent":["export { insertTable } from './publicApi/table/insertTable';\nexport { formatTable } from './publicApi/table/formatTable';\nexport { setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { editTable } from './publicApi/table/editTable';\nexport { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { toggleBullet } from './publicApi/list/toggleBullet';\nexport { toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { toggleBold } from './publicApi/segment/toggleBold';\nexport { toggleItalic } from './publicApi/segment/toggleItalic';\nexport { toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { setFontName } from './publicApi/segment/setFontName';\nexport { setFontSize } from './publicApi/segment/setFontSize';\nexport { setTextColor } from './publicApi/segment/setTextColor';\nexport { changeFontSize } from './publicApi/segment/changeFontSize';\nexport { applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { insertImage } from './publicApi/image/insertImage';\nexport { setListStyle } from './publicApi/list/setListStyle';\nexport { setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { setIndentation } from './publicApi/block/setIndentation';\nexport { setAlignment } from './publicApi/block/setAlignment';\nexport { setDirection } from './publicApi/block/setDirection';\nexport { setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { setSpacing } from './publicApi/block/setSpacing';\nexport { setImageBorder } from './publicApi/image/setImageBorder';\nexport { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { changeImage } from './publicApi/image/changeImage';\nexport { getFormatState } from './publicApi/format/getFormatState';\nexport { clearFormat } from './publicApi/format/clearFormat';\nexport { insertLink } from './publicApi/link/insertLink';\nexport { removeLink } from './publicApi/link/removeLink';\nexport { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { setImageAltText } from './publicApi/image/setImageAltText';\nexport { adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { toggleCode } from './publicApi/segment/toggleCode';\nexport { insertEntity } from './publicApi/entity/insertEntity';\nexport { insertTableRow } from './modelApi/table/insertTableRow';\nexport { insertTableColumn } from './modelApi/table/insertTableColumn';\nexport { clearSelectedCells } from './modelApi/table/clearSelectedCells';\n\nexport { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';\nexport { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';\nexport { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';\nexport { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';\nexport { formatTextSegmentBeforeSelectionMarker } from './publicApi/utils/formatTextSegmentBeforeSelectionMarker';\nexport { formatInsertPointWithContentModel } from './publicApi/utils/formatInsertPointWithContentModel';\n\nexport { setListType } from './modelApi/list/setListType';\nexport { setModelListStyle } from './modelApi/list/setModelListStyle';\nexport { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';\nexport { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';\nexport { setModelIndentation } from './modelApi/block/setModelIndentation';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterj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OAAA;IAC3B,0IAAA,2BAA2B,OAAA;IAC3B,kJAAA,+BAA+B,OAAA;IAC/B,8IAAA,6BAA6B,OAAA;IAC7B,gKAAA,sCAAsC,OAAA;IACtC,sJAAA,iCAAiC,OAAA;IAEjC,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,kIAAA,uBAAuB,OAAA;IACvB,sIAAA,yBAAyB,OAAA;IACzB,0HAAA,mBAAmB,OAAA;IACnB,sGAAA,SAAS,OAAA;IACT,0HAAA,mBAAmB,OAAA","sourcesContent":["export { insertTable } from './publicApi/table/insertTable';\nexport { formatTable } from './publicApi/table/formatTable';\nexport { setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { editTable } from './publicApi/table/editTable';\nexport { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { toggleBullet } from './publicApi/list/toggleBullet';\nexport { toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { toggleBold } from './publicApi/segment/toggleBold';\nexport { toggleItalic } from './publicApi/segment/toggleItalic';\nexport { toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { setFontName } from './publicApi/segment/setFontName';\nexport { setFontSize } from './publicApi/segment/setFontSize';\nexport { setTextColor } from './publicApi/segment/setTextColor';\nexport { changeFontSize } from './publicApi/segment/changeFontSize';\nexport { applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { splitTextSegment } from './publicApi/segment/splitTextSegment';\nexport { insertImage } from './publicApi/image/insertImage';\nexport { setListStyle } from './publicApi/list/setListStyle';\nexport { setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { setIndentation } from './publicApi/block/setIndentation';\nexport { setAlignment } from './publicApi/block/setAlignment';\nexport { setDirection } from './publicApi/block/setDirection';\nexport { setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { setSpacing } from './publicApi/block/setSpacing';\nexport { setImageBorder } from './publicApi/image/setImageBorder';\nexport { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { changeImage } from './publicApi/image/changeImage';\nexport { getFormatState } from './publicApi/format/getFormatState';\nexport { clearFormat } from './publicApi/format/clearFormat';\nexport { insertLink } from './publicApi/link/insertLink';\nexport { removeLink } from './publicApi/link/removeLink';\nexport { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { setImageAltText } from './publicApi/image/setImageAltText';\nexport { adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { toggleCode } from './publicApi/segment/toggleCode';\nexport { insertEntity } from './publicApi/entity/insertEntity';\nexport { insertTableRow } from './modelApi/table/insertTableRow';\nexport { insertTableColumn } from './modelApi/table/insertTableColumn';\nexport { clearSelectedCells } from './modelApi/table/clearSelectedCells';\n\nexport { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';\nexport { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';\nexport { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';\nexport { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';\nexport { formatTextSegmentBeforeSelectionMarker } from './publicApi/utils/formatTextSegmentBeforeSelectionMarker';\nexport { formatInsertPointWithContentModel } from './publicApi/utils/formatInsertPointWithContentModel';\n\nexport { setListType } from './modelApi/list/setListType';\nexport { setModelListStyle } from './modelApi/list/setModelListStyle';\nexport { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';\nexport { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';\nexport { setModelIndentation } from './modelApi/block/setModelIndentation';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\n"]}
|
|
@@ -91,6 +91,15 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
|
|
|
91
91
|
}
|
|
92
92
|
(0, roosterjs_content_model_dom_1.mutateBlock)(parent).blocks.splice(index, 1, newListItem);
|
|
93
93
|
existingListItems.push(newListItem);
|
|
94
|
+
var levelIndex = newListItem.levels.length - 1;
|
|
95
|
+
var level = (0, roosterjs_content_model_dom_1.mutateBlock)(newListItem).levels[levelIndex];
|
|
96
|
+
if (level) {
|
|
97
|
+
(0, roosterjs_content_model_dom_1.updateListMetadata)(level, function (metadata) {
|
|
98
|
+
return Object.assign({}, metadata, {
|
|
99
|
+
applyListStyleFromLevel: true,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
94
103
|
}
|
|
95
104
|
else {
|
|
96
105
|
existingListItems.forEach(function (x) { return ((0, roosterjs_content_model_dom_1.mutateBlock)(x).levels[0].format.marginBottom = '0px'); });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;;IAiBA;;;;;OAKG;IACH,SAAgB,WAAW,CACvB,KAAmC,EACnC,QAAqB,EACrB,aAA8B;QAA9B,8BAAA,EAAA,qBAA8B;QAE9B,IAAM,oBAAoB,GAAG,IAAA,kDAAoB,EAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;SACpJ,CAAC;QACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;gBAAP,KAAK,WAAA;YAC7D,OAAA,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC;gBACvD,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,QAAQ,KAAI,Q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,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,CAAC;IAjHD,kCAiHC;IAED,SAAS,iBAAiB,CAAC,KAAgC;QACvD,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,OAAO;gBACR,OAAO,KAAK,CAAC;YACjB,KAAK,WAAW;gBACZ,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;YACN;gBACI,OAAO,IAAI,CAAC;SACnB;IACL,CAAC","sourcesContent":["import {\n createListItem,\n createListLevel,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n normalizeContentModel,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\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: ReadonlyContentModelDocument,\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: ReadonlyContentModelListItem[] = [];\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: ShallowMutableContentModelListItem = 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 const mutableBlock = mutateBlock(block);\n\n newListItem.blocks.push(mutableBlock);\n\n if (mutableBlock.format.marginRight) {\n newListItem.format.marginRight = mutableBlock.format.marginRight;\n mutableBlock.format.marginRight = undefined;\n }\n\n if (mutableBlock.format.marginLeft) {\n newListItem.format.marginLeft = mutableBlock.format.marginLeft;\n mutableBlock.format.marginLeft = undefined;\n }\n\n if (mutableBlock.format.textAlign) {\n newListItem.format.textAlign = mutableBlock.format.textAlign;\n }\n\n mutateBlock(parent).blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n } else {\n existingListItems.forEach(\n x => (mutateBlock(x).levels[0].format.marginBottom = '0px')\n );\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ReadonlyContentModelBlock) {\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"]}
|
|
1
|
+
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;;IAkBA;;;;;OAKG;IACH,SAAgB,WAAW,CACvB,KAAmC,EACnC,QAAqB,EACrB,aAA8B;QAA9B,8BAAA,EAAA,qBAA8B;QAE9B,IAAM,oBAAoB,GAAG,IAAA,kDAAoB,EAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;SACpJ,CAAC;QACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;gBAAP,KAAK,WAAA;YAC7D,OAAA,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC;gBACvD,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,QAAQ,KAAI,QAAQ;gBAC7D,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;SAAA,CACjC,CAAC;QACF,IAAI,iBAAiB,GAAmC,EAAE,CAAC;QAE3D,oBAAoB,CAAC,OAAO,CAAC,UAAC,EAAiB,EAAE,SAAS;;gBAA1B,KAAK,WAAA,EAAE,MAAM,YAAA;YACzC,IAAI,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;gBAC7D,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAA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,mDAAqB,EAAC,KAAK,CAAC,CAAC;QAE7B,OAAO,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,CAAC;IA5HD,kCA4HC;IAED,SAAS,iBAAiB,CAAC,KAAgC;QACvD,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,OAAO;gBACR,OAAO,KAAK,CAAC;YACjB,KAAK,WAAW;gBACZ,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;YACN;gBACI,OAAO,IAAI,CAAC;SACnB;IACL,CAAC","sourcesContent":["import {\n createListItem,\n createListLevel,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n normalizeContentModel,\n setParagraphNotImplicit,\n updateListMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\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: ReadonlyContentModelDocument,\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: ReadonlyContentModelListItem[] = [];\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: ShallowMutableContentModelListItem = 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 const mutableBlock = mutateBlock(block);\n\n newListItem.blocks.push(mutableBlock);\n\n if (mutableBlock.format.marginRight) {\n newListItem.format.marginRight = mutableBlock.format.marginRight;\n mutableBlock.format.marginRight = undefined;\n }\n\n if (mutableBlock.format.marginLeft) {\n newListItem.format.marginLeft = mutableBlock.format.marginLeft;\n mutableBlock.format.marginLeft = undefined;\n }\n\n if (mutableBlock.format.textAlign) {\n newListItem.format.textAlign = mutableBlock.format.textAlign;\n }\n\n mutateBlock(parent).blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n\n const levelIndex = newListItem.levels.length - 1;\n const level = mutateBlock(newListItem).levels[levelIndex];\n\n if (level) {\n updateListMetadata(level, metadata =>\n Object.assign({}, metadata, {\n applyListStyleFromLevel: true,\n })\n );\n }\n } else {\n existingListItems.forEach(\n x => (mutateBlock(x).levels[0].format.marginBottom = '0px')\n );\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ReadonlyContentModelBlock) {\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,10 @@
|
|
|
1
|
+
import type { ContentModelText, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Split given text segments from the given range
|
|
4
|
+
* @param textSegment segment to split
|
|
5
|
+
* @param parent parent paragraph the text segment exist in
|
|
6
|
+
* @param start starting point of the split
|
|
7
|
+
* @param end ending point of the split
|
|
8
|
+
* @returns text segment from the indicated split.
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitTextSegment(textSegment: ContentModelText, parent: ShallowMutableContentModelParagraph, start: number, end: number): ContentModelText;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.splitTextSegment = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Split given text segments from the given range
|
|
7
|
+
* @param textSegment segment to split
|
|
8
|
+
* @param parent parent paragraph the text segment exist in
|
|
9
|
+
* @param start starting point of the split
|
|
10
|
+
* @param end ending point of the split
|
|
11
|
+
* @returns text segment from the indicated split.
|
|
12
|
+
*/
|
|
13
|
+
function splitTextSegment(textSegment, parent, start, end) {
|
|
14
|
+
var _a;
|
|
15
|
+
var text = textSegment.text;
|
|
16
|
+
var index = parent.segments.indexOf(textSegment);
|
|
17
|
+
var middleSegment = (0, roosterjs_content_model_dom_1.createText)(text.substring(start, end), textSegment.format, textSegment.link, textSegment.code);
|
|
18
|
+
var newSegments = [middleSegment];
|
|
19
|
+
if (start > 0) {
|
|
20
|
+
newSegments.unshift((0, roosterjs_content_model_dom_1.createText)(text.substring(0, start), textSegment.format, textSegment.link, textSegment.code));
|
|
21
|
+
}
|
|
22
|
+
if (end < text.length) {
|
|
23
|
+
newSegments.push((0, roosterjs_content_model_dom_1.createText)(text.substring(end), textSegment.format, textSegment.link, textSegment.code));
|
|
24
|
+
}
|
|
25
|
+
newSegments.forEach(function (segment) { return (segment.isSelected = textSegment.isSelected); });
|
|
26
|
+
(_a = parent.segments).splice.apply(_a, (0, tslib_1.__spreadArray)([index, 1], (0, tslib_1.__read)(newSegments), false));
|
|
27
|
+
return middleSegment;
|
|
28
|
+
}
|
|
29
|
+
exports.splitTextSegment = splitTextSegment;
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=splitTextSegment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/splitTextSegment.ts"],"names":[],"mappings":";;;;IAMA;;;;;;;OAOG;IACH,SAAgB,gBAAgB,CAC5B,WAA6B,EAC7B,MAA2C,EAC3C,KAAa,EACb,GAAW;;QAEX,IAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QAC9B,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACnD,IAAM,aAAa,GAAG,IAAA,wCAAU,EAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,EAC1B,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CACnB,CAAC;QAEF,IAAM,WAAW,GAAuB,CAAC,aAAa,CAAC,CAAC;QACxD,IAAI,KAAK,GAAG,CAAC,EAAE;YACX,WAAW,CAAC,OAAO,CACf,IAAA,wCAAU,EACN,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EACxB,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CACnB,CACJ,CAAC;SACL;QACD,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE;YACnB,WAAW,CAAC,IAAI,CACZ,IAAA,wCAAU,EAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAC1F,CAAC;SACL;QAED,WAAW,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,CAAC,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,EAA7C,CAA6C,CAAC,CAAC;QAC9E,CAAA,KAAA,MAAM,CAAC,QAAQ,CAAA,CAAC,MAAM,uCAAC,KAAK,EAAE,CAAC,uBAAK,WAAW,WAAE;QAEjD,OAAO,aAAa,CAAC;IACzB,CAAC;IApCD,4CAoCC","sourcesContent":["import { createText } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Split given text segments from the given range\n * @param textSegment segment to split\n * @param parent parent paragraph the text segment exist in\n * @param start starting point of the split\n * @param end ending point of the split\n * @returns text segment from the indicated split.\n */\nexport function splitTextSegment(\n textSegment: ContentModelText,\n parent: ShallowMutableContentModelParagraph,\n start: number,\n end: number\n): ContentModelText {\n const text = textSegment.text;\n const index = parent.segments.indexOf(textSegment);\n const middleSegment = createText(\n text.substring(start, end),\n textSegment.format,\n textSegment.link,\n textSegment.code\n );\n\n const newSegments: ContentModelText[] = [middleSegment];\n if (start > 0) {\n newSegments.unshift(\n createText(\n text.substring(0, start),\n textSegment.format,\n textSegment.link,\n textSegment.code\n )\n );\n }\n if (end < text.length) {\n newSegments.push(\n createText(text.substring(end), textSegment.format, textSegment.link, textSegment.code)\n );\n }\n\n newSegments.forEach(segment => (segment.isSelected = textSegment.isSelected));\n parent.segments.splice(index, 1, ...newSegments);\n\n return middleSegment;\n}\n"]}
|
package/lib-mjs/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { setTextColor } from './publicApi/segment/setTextColor';
|
|
|
18
18
|
export { changeFontSize } from './publicApi/segment/changeFontSize';
|
|
19
19
|
export { applySegmentFormat } from './publicApi/segment/applySegmentFormat';
|
|
20
20
|
export { changeCapitalization } from './publicApi/segment/changeCapitalization';
|
|
21
|
+
export { splitTextSegment } from './publicApi/segment/splitTextSegment';
|
|
21
22
|
export { insertImage } from './publicApi/image/insertImage';
|
|
22
23
|
export { setListStyle } from './publicApi/list/setListStyle';
|
|
23
24
|
export { setListStartNumber } from './publicApi/list/setListStartNumber';
|
package/lib-mjs/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { setTextColor } from './publicApi/segment/setTextColor';
|
|
|
18
18
|
export { changeFontSize } from './publicApi/segment/changeFontSize';
|
|
19
19
|
export { applySegmentFormat } from './publicApi/segment/applySegmentFormat';
|
|
20
20
|
export { changeCapitalization } from './publicApi/segment/changeCapitalization';
|
|
21
|
+
export { splitTextSegment } from './publicApi/segment/splitTextSegment';
|
|
21
22
|
export { insertImage } from './publicApi/image/insertImage';
|
|
22
23
|
export { setListStyle } from './publicApi/list/setListStyle';
|
|
23
24
|
export { setListStartNumber } from './publicApi/list/setListStartNumber';
|
package/lib-mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/ro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AM,+CAA+C,CAAC;AAC5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,mDAAmD,CAAC;AACpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAChG,OAAO,EAAE,sCAAsC,EAAE,MAAM,0DAA0D,CAAC;AAClH,OAAO,EAAE,iCAAiC,EAAE,MAAM,qDAAqD,CAAC;AAExG,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC","sourcesContent":["export { insertTable } from './publicApi/table/insertTable';\nexport { formatTable } from './publicApi/table/formatTable';\nexport { setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { editTable } from './publicApi/table/editTable';\nexport { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { toggleBullet } from './publicApi/list/toggleBullet';\nexport { toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { toggleBold } from './publicApi/segment/toggleBold';\nexport { toggleItalic } from './publicApi/segment/toggleItalic';\nexport { toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { setFontName } from './publicApi/segment/setFontName';\nexport { setFontSize } from './publicApi/segment/setFontSize';\nexport { setTextColor } from './publicApi/segment/setTextColor';\nexport { changeFontSize } from './publicApi/segment/changeFontSize';\nexport { applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { insertImage } from './publicApi/image/insertImage';\nexport { setListStyle } from './publicApi/list/setListStyle';\nexport { setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { setIndentation } from './publicApi/block/setIndentation';\nexport { setAlignment } from './publicApi/block/setAlignment';\nexport { setDirection } from './publicApi/block/setDirection';\nexport { setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { setSpacing } from './publicApi/block/setSpacing';\nexport { setImageBorder } from './publicApi/image/setImageBorder';\nexport { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { changeImage } from './publicApi/image/changeImage';\nexport { getFormatState } from './publicApi/format/getFormatState';\nexport { clearFormat } from './publicApi/format/clearFormat';\nexport { insertLink } from './publicApi/link/insertLink';\nexport { removeLink } from './publicApi/link/removeLink';\nexport { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { setImageAltText } from './publicApi/image/setImageAltText';\nexport { adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { toggleCode } from './publicApi/segment/toggleCode';\nexport { insertEntity } from './publicApi/entity/insertEntity';\nexport { insertTableRow } from './modelApi/table/insertTableRow';\nexport { insertTableColumn } from './modelApi/table/insertTableColumn';\nexport { clearSelectedCells } from './modelApi/table/clearSelectedCells';\n\nexport { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';\nexport { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';\nexport { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';\nexport { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';\nexport { formatTextSegmentBeforeSelectionMarker } from './publicApi/utils/formatTextSegmentBeforeSelectionMarker';\nexport { formatInsertPointWithContentModel } from './publicApi/utils/formatInsertPointWithContentModel';\n\nexport { setListType } from './modelApi/list/setListType';\nexport { setModelListStyle } from './modelApi/list/setModelListStyle';\nexport { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';\nexport { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';\nexport { setModelIndentation } from './modelApi/block/setModelIndentation';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;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sCAAsC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,mDAAmD,CAAC;AACpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAChG,OAAO,EAAE,sCAAsC,EAAE,MAAM,0DAA0D,CAAC;AAClH,OAAO,EAAE,iCAAiC,EAAE,MAAM,qDAAqD,CAAC;AAExG,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC","sourcesContent":["export { insertTable } from './publicApi/table/insertTable';\nexport { formatTable } from './publicApi/table/formatTable';\nexport { setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { editTable } from './publicApi/table/editTable';\nexport { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { toggleBullet } from './publicApi/list/toggleBullet';\nexport { toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { toggleBold } from './publicApi/segment/toggleBold';\nexport { toggleItalic } from './publicApi/segment/toggleItalic';\nexport { toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { setFontName } from './publicApi/segment/setFontName';\nexport { setFontSize } from './publicApi/segment/setFontSize';\nexport { setTextColor } from './publicApi/segment/setTextColor';\nexport { changeFontSize } from './publicApi/segment/changeFontSize';\nexport { applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { splitTextSegment } from './publicApi/segment/splitTextSegment';\nexport { insertImage } from './publicApi/image/insertImage';\nexport { setListStyle } from './publicApi/list/setListStyle';\nexport { setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { setIndentation } from './publicApi/block/setIndentation';\nexport { setAlignment } from './publicApi/block/setAlignment';\nexport { setDirection } from './publicApi/block/setDirection';\nexport { setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { setSpacing } from './publicApi/block/setSpacing';\nexport { setImageBorder } from './publicApi/image/setImageBorder';\nexport { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { changeImage } from './publicApi/image/changeImage';\nexport { getFormatState } from './publicApi/format/getFormatState';\nexport { clearFormat } from './publicApi/format/clearFormat';\nexport { insertLink } from './publicApi/link/insertLink';\nexport { removeLink } from './publicApi/link/removeLink';\nexport { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { setImageAltText } from './publicApi/image/setImageAltText';\nexport { adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { toggleCode } from './publicApi/segment/toggleCode';\nexport { insertEntity } from './publicApi/entity/insertEntity';\nexport { insertTableRow } from './modelApi/table/insertTableRow';\nexport { insertTableColumn } from './modelApi/table/insertTableColumn';\nexport { clearSelectedCells } from './modelApi/table/clearSelectedCells';\n\nexport { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';\nexport { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';\nexport { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';\nexport { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';\nexport { formatTextSegmentBeforeSelectionMarker } from './publicApi/utils/formatTextSegmentBeforeSelectionMarker';\nexport { formatInsertPointWithContentModel } from './publicApi/utils/formatInsertPointWithContentModel';\n\nexport { setListType } from './modelApi/list/setListType';\nexport { setModelListStyle } from './modelApi/list/setModelListStyle';\nexport { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';\nexport { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';\nexport { setModelIndentation } from './modelApi/block/setModelIndentation';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createListItem, createListLevel, getOperationalBlocks, isBlockGroupOfType, mutateBlock, normalizeContentModel, setParagraphNotImplicit, } from 'roosterjs-content-model-dom';
|
|
1
|
+
import { createListItem, createListLevel, getOperationalBlocks, isBlockGroupOfType, mutateBlock, normalizeContentModel, setParagraphNotImplicit, updateListMetadata, } from 'roosterjs-content-model-dom';
|
|
2
2
|
/**
|
|
3
3
|
* Set a list type to content model
|
|
4
4
|
* @param model the model document
|
|
@@ -88,6 +88,15 @@ export function setListType(model, listType, removeMargins) {
|
|
|
88
88
|
}
|
|
89
89
|
mutateBlock(parent).blocks.splice(index, 1, newListItem);
|
|
90
90
|
existingListItems.push(newListItem);
|
|
91
|
+
var levelIndex = newListItem.levels.length - 1;
|
|
92
|
+
var level = mutateBlock(newListItem).levels[levelIndex];
|
|
93
|
+
if (level) {
|
|
94
|
+
updateListMetadata(level, function (metadata) {
|
|
95
|
+
return Object.assign({}, metadata, {
|
|
96
|
+
applyListStyleFromLevel: true,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
91
100
|
}
|
|
92
101
|
else {
|
|
93
102
|
existingListItems.forEach(function (x) { return (mutateBlock(x).levels[0].format.marginBottom = '0px'); });
|
|
@@ -1 +1 @@
|
|
|
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,WAAW,EACX,qBAAqB,EACrB,uBAAuB,GAC1B,MAAM,6BAA6B,CAAC;AASrC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACvB,KAAmC,EACnC,QAAqB,EACrB,aAA8B;IAA9B,8BAAA,EAAA,qBAA8B;IAE9B,IAAM,oBAAoB,GAAG,oBAAoB,CAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;KACpJ,CAAC;IACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;YAAP,KAAK,WAAA;QAC7D,OAAA,kBAAkB,CAAuB,KAAK,EAAE,UAAU,CAAC;YACvD,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,QAAQ,KAAI,QAAQ;YAC7D,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;KAAA,CACjC,CAAC;IACF,IAAI,iBAAiB,GAAmC,EAAE,CAAC;IAE3D,oBAAoB,CAAC,OAAO,CAAC,UAAC,EAAiB,EAAE,SAAS;;YAA1B,KAAK,WAAA,EAAE,MAAM,YAAA;QACzC,IAAI,kBAAkB,CAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;YAC7D,IA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AO,IAAI,CAAC;KACnB;AACL,CAAC","sourcesContent":["import {\n createListItem,\n createListLevel,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n normalizeContentModel,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\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: ReadonlyContentModelDocument,\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: ReadonlyContentModelListItem[] = [];\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: ShallowMutableContentModelListItem = 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 const mutableBlock = mutateBlock(block);\n\n newListItem.blocks.push(mutableBlock);\n\n if (mutableBlock.format.marginRight) {\n newListItem.format.marginRight = mutableBlock.format.marginRight;\n mutableBlock.format.marginRight = undefined;\n }\n\n if (mutableBlock.format.marginLeft) {\n newListItem.format.marginLeft = mutableBlock.format.marginLeft;\n mutableBlock.format.marginLeft = undefined;\n }\n\n if (mutableBlock.format.textAlign) {\n newListItem.format.textAlign = mutableBlock.format.textAlign;\n }\n\n mutateBlock(parent).blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n } else {\n existingListItems.forEach(\n x => (mutateBlock(x).levels[0].format.marginBottom = '0px')\n );\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ReadonlyContentModelBlock) {\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"]}
|
|
1
|
+
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model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AI,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 mutateBlock,\n normalizeContentModel,\n setParagraphNotImplicit,\n updateListMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelListItem,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\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: ReadonlyContentModelDocument,\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: ReadonlyContentModelListItem[] = [];\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: ShallowMutableContentModelListItem = 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 const mutableBlock = mutateBlock(block);\n\n newListItem.blocks.push(mutableBlock);\n\n if (mutableBlock.format.marginRight) {\n newListItem.format.marginRight = mutableBlock.format.marginRight;\n mutableBlock.format.marginRight = undefined;\n }\n\n if (mutableBlock.format.marginLeft) {\n newListItem.format.marginLeft = mutableBlock.format.marginLeft;\n mutableBlock.format.marginLeft = undefined;\n }\n\n if (mutableBlock.format.textAlign) {\n newListItem.format.textAlign = mutableBlock.format.textAlign;\n }\n\n mutateBlock(parent).blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n\n const levelIndex = newListItem.levels.length - 1;\n const level = mutateBlock(newListItem).levels[levelIndex];\n\n if (level) {\n updateListMetadata(level, metadata =>\n Object.assign({}, metadata, {\n applyListStyleFromLevel: true,\n })\n );\n }\n } else {\n existingListItems.forEach(\n x => (mutateBlock(x).levels[0].format.marginBottom = '0px')\n );\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ReadonlyContentModelBlock) {\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,10 @@
|
|
|
1
|
+
import type { ContentModelText, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Split given text segments from the given range
|
|
4
|
+
* @param textSegment segment to split
|
|
5
|
+
* @param parent parent paragraph the text segment exist in
|
|
6
|
+
* @param start starting point of the split
|
|
7
|
+
* @param end ending point of the split
|
|
8
|
+
* @returns text segment from the indicated split.
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitTextSegment(textSegment: ContentModelText, parent: ShallowMutableContentModelParagraph, start: number, end: number): ContentModelText;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { createText } from 'roosterjs-content-model-dom';
|
|
3
|
+
/**
|
|
4
|
+
* Split given text segments from the given range
|
|
5
|
+
* @param textSegment segment to split
|
|
6
|
+
* @param parent parent paragraph the text segment exist in
|
|
7
|
+
* @param start starting point of the split
|
|
8
|
+
* @param end ending point of the split
|
|
9
|
+
* @returns text segment from the indicated split.
|
|
10
|
+
*/
|
|
11
|
+
export function splitTextSegment(textSegment, parent, start, end) {
|
|
12
|
+
var _a;
|
|
13
|
+
var text = textSegment.text;
|
|
14
|
+
var index = parent.segments.indexOf(textSegment);
|
|
15
|
+
var middleSegment = createText(text.substring(start, end), textSegment.format, textSegment.link, textSegment.code);
|
|
16
|
+
var newSegments = [middleSegment];
|
|
17
|
+
if (start > 0) {
|
|
18
|
+
newSegments.unshift(createText(text.substring(0, start), textSegment.format, textSegment.link, textSegment.code));
|
|
19
|
+
}
|
|
20
|
+
if (end < text.length) {
|
|
21
|
+
newSegments.push(createText(text.substring(end), textSegment.format, textSegment.link, textSegment.code));
|
|
22
|
+
}
|
|
23
|
+
newSegments.forEach(function (segment) { return (segment.isSelected = textSegment.isSelected); });
|
|
24
|
+
(_a = parent.segments).splice.apply(_a, __spreadArray([index, 1], __read(newSegments), false));
|
|
25
|
+
return middleSegment;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=splitTextSegment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/splitTextSegment.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAMzD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC5B,WAA6B,EAC7B,MAA2C,EAC3C,KAAa,EACb,GAAW;;IAEX,IAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,IAAM,aAAa,GAAG,UAAU,CAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,EAC1B,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CACnB,CAAC;IAEF,IAAM,WAAW,GAAuB,CAAC,aAAa,CAAC,CAAC;IACxD,IAAI,KAAK,GAAG,CAAC,EAAE;QACX,WAAW,CAAC,OAAO,CACf,UAAU,CACN,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EACxB,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CACnB,CACJ,CAAC;KACL;IACD,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE;QACnB,WAAW,CAAC,IAAI,CACZ,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAC1F,CAAC;KACL;IAED,WAAW,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,CAAC,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,EAA7C,CAA6C,CAAC,CAAC;IAC9E,CAAA,KAAA,MAAM,CAAC,QAAQ,CAAA,CAAC,MAAM,0BAAC,KAAK,EAAE,CAAC,UAAK,WAAW,WAAE;IAEjD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["import { createText } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelText,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Split given text segments from the given range\n * @param textSegment segment to split\n * @param parent parent paragraph the text segment exist in\n * @param start starting point of the split\n * @param end ending point of the split\n * @returns text segment from the indicated split.\n */\nexport function splitTextSegment(\n textSegment: ContentModelText,\n parent: ShallowMutableContentModelParagraph,\n start: number,\n end: number\n): ContentModelText {\n const text = textSegment.text;\n const index = parent.segments.indexOf(textSegment);\n const middleSegment = createText(\n text.substring(start, end),\n textSegment.format,\n textSegment.link,\n textSegment.code\n );\n\n const newSegments: ContentModelText[] = [middleSegment];\n if (start > 0) {\n newSegments.unshift(\n createText(\n text.substring(0, start),\n textSegment.format,\n textSegment.link,\n textSegment.code\n )\n );\n }\n if (end < text.length) {\n newSegments.push(\n createText(text.substring(end), textSegment.format, textSegment.link, textSegment.code)\n );\n }\n\n newSegments.forEach(segment => (segment.isSelected = textSegment.isSelected));\n parent.segments.splice(index, 1, ...newSegments);\n\n return middleSegment;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"description": "Format API for roosterjs",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
|
-
"roosterjs-content-model-dom": "^9.
|
|
7
|
-
"roosterjs-content-model-types": "^9.
|
|
6
|
+
"roosterjs-content-model-dom": "^9.8.0",
|
|
7
|
+
"roosterjs-content-model-types": "^9.8.0"
|
|
8
8
|
},
|
|
9
|
-
"version": "9.
|
|
9
|
+
"version": "9.8.0",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"typings": "./lib/index.d.ts",
|
|
12
12
|
"module": "./lib-mjs/index.js",
|