roosterjs-content-model-api 9.5.1 → 9.7.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/entity/insertEntityModel.js +18 -1
- package/lib/modelApi/entity/insertEntityModel.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/publicApi/utils/formatSegmentWithContentModel.js +2 -2
- package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- 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/entity/insertEntityModel.js +18 -1
- package/lib-amd/modelApi/entity/insertEntityModel.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-amd/publicApi/utils/formatSegmentWithContentModel.js +2 -2
- package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- 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/entity/insertEntityModel.js +18 -1
- package/lib-mjs/modelApi/entity/insertEntityModel.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/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +2 -2
- package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
- 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,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D;AAAhD,wGAAA,UAAU,OAAA;AACnB,0DAAyD;AAAhD,wGAAA,UAAU,OAAA;AACnB,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAC5B,qEAAoE;AAA3D,kHAAA,eAAe,OAAA;AACxB,+EAA8E;AAArE,4HAAA,oBAAoB,OAAA;AAC7B,2EAA0E;AAAjE,wHAAA,kBAAkB,OAAA;AAC3B,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,gEAA+D;AAAtD,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;AA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wHAAA,kBAAkB,OAAA;AAC3B,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,gEAA+D;AAAtD,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 { 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"]}
|
|
@@ -75,7 +75,24 @@ function insertEntityModel(model, entityModel, position, isBlock, focusAfterEnti
|
|
|
75
75
|
exports.insertEntityModel = insertEntityModel;
|
|
76
76
|
function getInsertPoint(model, insertPointOverride, context) {
|
|
77
77
|
if (insertPointOverride) {
|
|
78
|
-
|
|
78
|
+
var paragraph = insertPointOverride.paragraph, marker = insertPointOverride.marker, tableContext = insertPointOverride.tableContext, path = insertPointOverride.path;
|
|
79
|
+
var index = paragraph.segments.indexOf(marker);
|
|
80
|
+
var previousSegment = index > 0 ? paragraph.segments[index - 1] : null;
|
|
81
|
+
// It is possible that the real selection is right before the override selection marker.
|
|
82
|
+
// This happens when:
|
|
83
|
+
// [Override marker][Entity node to wrap][Real marker]
|
|
84
|
+
// Then we will move the entity node into entity wrapper, causes the override marker and real marker are at the same place
|
|
85
|
+
// And recreating content model causes real marker to appear before override marker.
|
|
86
|
+
// Once that happens, we need to use the real marker instead so that after insert entity, real marker can be placed
|
|
87
|
+
// after new entity (if insertPointOverride==true)
|
|
88
|
+
return (previousSegment === null || previousSegment === void 0 ? void 0 : previousSegment.segmentType) == 'SelectionMarker' && previousSegment.isSelected
|
|
89
|
+
? {
|
|
90
|
+
marker: previousSegment,
|
|
91
|
+
paragraph: paragraph,
|
|
92
|
+
tableContext: tableContext,
|
|
93
|
+
path: path,
|
|
94
|
+
}
|
|
95
|
+
: insertPointOverride;
|
|
79
96
|
}
|
|
80
97
|
else {
|
|
81
98
|
var deleteResult = (0, roosterjs_content_model_dom_1.deleteSelection)(model, [], context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";;;;AAAA,2EASqC;AAarC;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,WAA+B,EAC/B,QAA8B,EAC9B,OAAgB,EAChB,gBAA0B,EAC1B,OAAmC,EACnC,mBAAiC;;;IAEjC,IAAI,WAAuD,CAAC;IAC5D,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,IAAI,WAA+B,CAAC;IAEpC,IAAI,QAAQ,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK,EAAE;QAC1C,WAAW,GAAG,KAAK,CAAC;QACpB,UAAU,GAAG,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QAE3D,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;SACnD;KACJ;SAAM,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC,EAAE;QACpE,IAAA,MAAM,GAAsB,WAAW,OAAjC,EAAE,SAAS,GAAW,WAAW,UAAtB,EAAE,IAAI,GAAK,WAAW,KAAhB,CAAiB;QAEhD,IAAI,CAAC,OAAO,EAAE;YACV,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM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,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3D,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SACvC;KACJ;AACL,CAAC;AAvFD,8CAuFC;AAED,SAAS,cAAc,CACnB,KAAmC,EACnC,mBAAiC,EACjC,OAAmC;IAEnC,IAAI,mBAAmB,EAAE;QACrB,OAAO,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";;;;AAAA,2EASqC;AAarC;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,WAA+B,EAC/B,QAA8B,EAC9B,OAAgB,EAChB,gBAA0B,EAC1B,OAAmC,EACnC,mBAAiC;;;IAEjC,IAAI,WAAuD,CAAC;IAC5D,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,IAAI,WAA+B,CAAC;IAEpC,IAAI,QAAQ,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK,EAAE;QAC1C,WAAW,GAAG,KAAK,CAAC;QACpB,UAAU,GAAG,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QAE3D,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;SACnD;KACJ;SAAM,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC,EAAE;QACpE,IAAA,MAAM,GAAsB,WAAW,OAAjC,EAAE,SAAS,GAAW,WAAW,UAAtB,EAAE,IAAI,GAAK,WAAW,KAAhB,CAAiB;QAEhD,IAAI,CAA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Y,CAAC,YAAY,IAAI,OAAO,EAAE;YACtC,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;SAChC;QAED,OAAO,WAAW,CAAC;KACtB;AACL,CAAC","sourcesContent":["import {\n createBr,\n createParagraph,\n createSelectionMarker,\n normalizeContentModel,\n deleteSelection,\n getClosestAncestorBlockGroupIndex,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelEntity,\n FormatContentModelContext,\n InsertEntityPosition,\n InsertPoint,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelBlock,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function insertEntityModel(\n model: ReadonlyContentModelDocument,\n entityModel: ContentModelEntity,\n position: InsertEntityPosition,\n isBlock: boolean,\n focusAfterEntity?: boolean,\n context?: FormatContentModelContext,\n insertPointOverride?: InsertPoint\n) {\n let blockParent: ReadonlyContentModelBlockGroup | undefined;\n let blockIndex = -1;\n let insertPoint: InsertPoint | null;\n\n if (position == 'begin' || position == 'end') {\n blockParent = model;\n blockIndex = position == 'begin' ? 0 : model.blocks.length;\n\n if (!isBlock) {\n Object.assign(entityModel.format, model.format);\n }\n } else if ((insertPoint = getInsertPoint(model, insertPointOverride, context))) {\n const { marker, paragraph, path } = insertPoint;\n\n if (!isBlock) {\n const index = paragraph.segments.indexOf(marker);\n\n Object.assign(entityModel.format, marker.format);\n\n if (index >= 0) {\n paragraph.segments.splice(focusAfterEntity ? index : index + 1, 0, entityModel);\n }\n } else {\n const pathIndex =\n position == 'root'\n ? getClosestAncestorBlockGroupIndex(path, ['TableCell', 'Document'])\n : 0;\n blockParent = mutateBlock(path[pathIndex]);\n\n const child = path[pathIndex - 1];\n const directChild: ReadonlyContentModelBlock =\n child?.blockGroupType == 'FormatContainer' ||\n child?.blockGroupType == 'General' ||\n child?.blockGroupType == 'ListItem'\n ? child\n : paragraph;\n const childIndex = blockParent.blocks.indexOf(directChild);\n blockIndex = childIndex >= 0 ? childIndex + 1 : -1;\n }\n }\n\n if (blockIndex >= 0 && blockParent) {\n const blocksToInsert: ShallowMutableContentModelBlock[] = [];\n let nextParagraph: ShallowMutableContentModelParagraph | undefined;\n\n if (isBlock) {\n const nextBlock = blockParent.blocks[blockIndex];\n\n blocksToInsert.push(entityModel);\n\n if (nextBlock?.blockType == 'Paragraph') {\n nextParagraph = mutateBlock(nextBlock);\n } else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {\n nextParagraph = createParagraph(false /*isImplicit*/, {}, model.format);\n nextParagraph.segments.push(createBr(model.format));\n blocksToInsert.push(nextParagraph);\n }\n } else {\n nextParagraph = createParagraph(\n false /*isImplicit*/,\n undefined /*format*/,\n model.format\n );\n\n nextParagraph.segments.push(entityModel);\n blocksToInsert.push(nextParagraph);\n }\n\n mutateBlock(blockParent).blocks.splice(blockIndex, 0, ...blocksToInsert);\n\n if (focusAfterEntity && nextParagraph) {\n const marker = createSelectionMarker(nextParagraph.segments[0]?.format || model.format);\n const segments = nextParagraph.segments;\n\n isBlock ? segments.unshift(marker) : segments.push(marker);\n setSelection(model, marker, marker);\n }\n }\n}\n\nfunction getInsertPoint(\n model: ReadonlyContentModelDocument,\n insertPointOverride?: InsertPoint,\n context?: FormatContentModelContext\n): InsertPoint | null {\n if (insertPointOverride) {\n const { paragraph, marker, tableContext, path } = insertPointOverride;\n const index = paragraph.segments.indexOf(marker);\n const previousSegment = index > 0 ? paragraph.segments[index - 1] : null;\n\n // It is possible that the real selection is right before the override selection marker.\n // This happens when:\n // [Override marker][Entity node to wrap][Real marker]\n // Then we will move the entity node into entity wrapper, causes the override marker and real marker are at the same place\n // And recreating content model causes real marker to appear before override marker.\n // Once that happens, we need to use the real marker instead so that after insert entity, real marker can be placed\n // after new entity (if insertPointOverride==true)\n return previousSegment?.segmentType == 'SelectionMarker' && previousSegment.isSelected\n ? {\n marker: previousSegment,\n paragraph,\n tableContext,\n path,\n }\n : insertPointOverride;\n } else {\n const deleteResult = deleteSelection(model, [], context);\n const insertPoint = deleteResult.insertPoint;\n\n if (deleteResult.deleteResult == 'range') {\n normalizeContentModel(model);\n }\n\n return insertPoint;\n }\n}\n"]}
|
|
@@ -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"]}
|
|
@@ -16,8 +16,8 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
|
16
16
|
function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, segmentHasStyleCallback, includingFormatHolder, afterFormatCallback) {
|
|
17
17
|
editor.formatContentModel(function (model, context) {
|
|
18
18
|
var segmentAndParagraphs = (0, roosterjs_content_model_dom_1.getSelectedSegmentsAndParagraphs)(model, !!includingFormatHolder, false /*includingEntity*/, true /*mutate*/);
|
|
19
|
-
var isCollapsedSelection = segmentAndParagraphs.length
|
|
20
|
-
segmentAndParagraphs[0]
|
|
19
|
+
var isCollapsedSelection = segmentAndParagraphs.length >= 1 &&
|
|
20
|
+
segmentAndParagraphs.every(function (x) { return x[0].segmentType == 'SelectionMarker'; });
|
|
21
21
|
if (isCollapsedSelection) {
|
|
22
22
|
var para_1 = segmentAndParagraphs[0][1];
|
|
23
23
|
var path_1 = segmentAndParagraphs[0][2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,oFAAmF;AACnF,2EAA+E;AAS/E;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,IAAA,8DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,oFAAmF;AACnF,2EAA+E;AAS/E;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,IAAA,8DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAArC,CAAqC,CAAC,CAAC;QAE3E,IAAI,oBAAoB,EAAE;YACtB,IAAM,MAAI,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,IAAM,MAAI,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExC,oBAAoB,GAAG,IAAA,yCAAmB,EACtC,KAAK,EACL,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC7B,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,MAAI,EAAE,MAAI,CAAC,EAAf,CAAe,CAAC,CAAC;YAE5B,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjC,oBAAoB,GAAG,KAAK,CAAC;aAChC;SACJ;QAED,IAAM,kBAAkB,GAIlB,oBAAoB,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC;QAE3E,IAAM,YAAY,GAAG,uBAAuB;YACxC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,UAAC,EAA4B;oBAA5B,KAAA,0BAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;gBACjD,OAAA,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC;YAAnD,CAAmD,CACtD;YACH,CAAC,CAAC,KAAK,CAAC;QAEZ,kBAAkB,CAAC,OAAO,CAAC,UAAC,EAA4B;gBAA5B,KAAA,0BAA4B,EAA3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;YACnD,OAAA,mBAAmB,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC;QAA9D,CAA8D,CACjE,CAAC;QAEF,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;QAE7B,IAAI,oBAAoB,EAAE;YACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;SACxC;IACL,CAAC,EACD;QACI,OAAO,SAAA;KACV,CACJ,CAAC;AACN,CAAC;AAzED,sEAyEC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected segment using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\n */\nexport function formatSegmentWithContentModel(\n editor: IEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[0].segmentType == 'SelectionMarker');\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n const path = segmentAndParagraphs[0][2];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para, path]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | null\n ][] = segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\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":[],"mappings":";;;;IAAS,0GAAA,WAAW,OAAA;IACX,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,sGAAA,SAAS,OAAA;IACT,gIAAA,sBAAsB,OAAA;IACtB,4GAAA,YAAY,OAAA;IACZ,kHAAA,eAAe,OAAA;IACf,wGAAA,UAAU,OAAA;IACV,4GAAA,YAAY,OAAA;IACZ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AA,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/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":";;;;IAAS,0GAAA,WAAW,OAAA;IACX,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,sGAAA,SAAS,OAAA;IACT,gIAAA,sBAAsB,OAAA;IACtB,4GAAA,YAAY,OAAA;IACZ,kHAAA,eAAe,OAAA;IACf,wGAAA,UAAU,OAAA;I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A,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"]}
|
|
@@ -74,7 +74,24 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
74
74
|
exports.insertEntityModel = insertEntityModel;
|
|
75
75
|
function getInsertPoint(model, insertPointOverride, context) {
|
|
76
76
|
if (insertPointOverride) {
|
|
77
|
-
|
|
77
|
+
var paragraph = insertPointOverride.paragraph, marker = insertPointOverride.marker, tableContext = insertPointOverride.tableContext, path = insertPointOverride.path;
|
|
78
|
+
var index = paragraph.segments.indexOf(marker);
|
|
79
|
+
var previousSegment = index > 0 ? paragraph.segments[index - 1] : null;
|
|
80
|
+
// It is possible that the real selection is right before the override selection marker.
|
|
81
|
+
// This happens when:
|
|
82
|
+
// [Override marker][Entity node to wrap][Real marker]
|
|
83
|
+
// Then we will move the entity node into entity wrapper, causes the override marker and real marker are at the same place
|
|
84
|
+
// And recreating content model causes real marker to appear before override marker.
|
|
85
|
+
// Once that happens, we need to use the real marker instead so that after insert entity, real marker can be placed
|
|
86
|
+
// after new entity (if insertPointOverride==true)
|
|
87
|
+
return (previousSegment === null || previousSegment === void 0 ? void 0 : previousSegment.segmentType) == 'SelectionMarker' && previousSegment.isSelected
|
|
88
|
+
? {
|
|
89
|
+
marker: previousSegment,
|
|
90
|
+
paragraph: paragraph,
|
|
91
|
+
tableContext: tableContext,
|
|
92
|
+
path: path,
|
|
93
|
+
}
|
|
94
|
+
: insertPointOverride;
|
|
78
95
|
}
|
|
79
96
|
else {
|
|
80
97
|
var deleteResult = (0, roosterjs_content_model_dom_1.deleteSelection)(model, [], context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";;;;IAsBA;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,WAA+B,EAC/B,QAA8B,EAC9B,OAAgB,EAChB,gBAA0B,EAC1B,OAAmC,EACnC,mBAAiC;;;QAEjC,IAAI,WAAuD,CAAC;QAC5D,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;QACpB,IAAI,WAA+B,CAAC;QAEpC,IAAI,QAAQ,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK,EAAE;YAC1C,WAAW,GAAG,KAAK,CAAC;YACpB,UAAU,GAAG,QAA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pB,KAAK,CAAC,MAAM,CACf,CAAC;gBAEF,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACzC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aACtC;YAED,CAAA,KAAA,IAAA,yCAAW,EAAC,WAAW,CAAC,CAAC,MAAM,CAAA,CAAC,MAAM,uCAAC,UAAU,EAAE,CAAC,uBAAK,cAAc,WAAE;YAEzE,IAAI,gBAAgB,IAAI,aAAa,EAAE;gBACnC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,CAAA,MAAA,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAE,MAAM,KAAI,KAAK,CAAC,MAAM,CAAC,CAAC;gBACxF,IAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;gBAExC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC3D,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;aACvC;SACJ;IACL,CAAC;IAvFD,8CAuFC;IAED,SAAS,cAAc,CACnB,KAAmC,EACnC,mBAAiC,EACjC,OAAmC;QAEnC,IAAI,mBAAmB,EAAE;YACrB,OAAO,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";;;;IAsBA;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,WAA+B,EAC/B,QAA8B,EAC9B,OAAgB,EAChB,gBAA0B,EAC1B,OAAmC,EACnC,mBAAiC;;;QAEjC,IAAI,WAAuD,CAAC;QAC5D,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;QACpB,IAAI,WAA+B,CAAC;QAEpC,IAAI,QAAQ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AQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAEzE,wFAAwF;YACxF,qBAAqB;YACrB,sDAAsD;YACtD,0HAA0H;YAC1H,oFAAoF;YACpF,mHAAmH;YACnH,kDAAkD;YAClD,OAAO,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,WAAW,KAAI,iBAAiB,IAAI,eAAe,CAAC,UAAU;gBAClF,CAAC,CAAC;oBACI,MAAM,EAAE,eAAe;oBACvB,SAAS,WAAA;oBACT,YAAY,cAAA;oBACZ,IAAI,MAAA;iBACP;gBACH,CAAC,CAAC,mBAAmB,CAAC;SAC7B;aAAM;YACH,IAAM,YAAY,GAAG,IAAA,6CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YACzD,IAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;YAE7C,IAAI,YAAY,CAAC,YAAY,IAAI,OAAO,EAAE;gBACtC,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;aAChC;YAED,OAAO,WAAW,CAAC;SACtB;IACL,CAAC","sourcesContent":["import {\n createBr,\n createParagraph,\n createSelectionMarker,\n normalizeContentModel,\n deleteSelection,\n getClosestAncestorBlockGroupIndex,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelEntity,\n FormatContentModelContext,\n InsertEntityPosition,\n InsertPoint,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelBlock,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function insertEntityModel(\n model: ReadonlyContentModelDocument,\n entityModel: ContentModelEntity,\n position: InsertEntityPosition,\n isBlock: boolean,\n focusAfterEntity?: boolean,\n context?: FormatContentModelContext,\n insertPointOverride?: InsertPoint\n) {\n let blockParent: ReadonlyContentModelBlockGroup | undefined;\n let blockIndex = -1;\n let insertPoint: InsertPoint | null;\n\n if (position == 'begin' || position == 'end') {\n blockParent = model;\n blockIndex = position == 'begin' ? 0 : model.blocks.length;\n\n if (!isBlock) {\n Object.assign(entityModel.format, model.format);\n }\n } else if ((insertPoint = getInsertPoint(model, insertPointOverride, context))) {\n const { marker, paragraph, path } = insertPoint;\n\n if (!isBlock) {\n const index = paragraph.segments.indexOf(marker);\n\n Object.assign(entityModel.format, marker.format);\n\n if (index >= 0) {\n paragraph.segments.splice(focusAfterEntity ? index : index + 1, 0, entityModel);\n }\n } else {\n const pathIndex =\n position == 'root'\n ? getClosestAncestorBlockGroupIndex(path, ['TableCell', 'Document'])\n : 0;\n blockParent = mutateBlock(path[pathIndex]);\n\n const child = path[pathIndex - 1];\n const directChild: ReadonlyContentModelBlock =\n child?.blockGroupType == 'FormatContainer' ||\n child?.blockGroupType == 'General' ||\n child?.blockGroupType == 'ListItem'\n ? child\n : paragraph;\n const childIndex = blockParent.blocks.indexOf(directChild);\n blockIndex = childIndex >= 0 ? childIndex + 1 : -1;\n }\n }\n\n if (blockIndex >= 0 && blockParent) {\n const blocksToInsert: ShallowMutableContentModelBlock[] = [];\n let nextParagraph: ShallowMutableContentModelParagraph | undefined;\n\n if (isBlock) {\n const nextBlock = blockParent.blocks[blockIndex];\n\n blocksToInsert.push(entityModel);\n\n if (nextBlock?.blockType == 'Paragraph') {\n nextParagraph = mutateBlock(nextBlock);\n } else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {\n nextParagraph = createParagraph(false /*isImplicit*/, {}, model.format);\n nextParagraph.segments.push(createBr(model.format));\n blocksToInsert.push(nextParagraph);\n }\n } else {\n nextParagraph = createParagraph(\n false /*isImplicit*/,\n undefined /*format*/,\n model.format\n );\n\n nextParagraph.segments.push(entityModel);\n blocksToInsert.push(nextParagraph);\n }\n\n mutateBlock(blockParent).blocks.splice(blockIndex, 0, ...blocksToInsert);\n\n if (focusAfterEntity && nextParagraph) {\n const marker = createSelectionMarker(nextParagraph.segments[0]?.format || model.format);\n const segments = nextParagraph.segments;\n\n isBlock ? segments.unshift(marker) : segments.push(marker);\n setSelection(model, marker, marker);\n }\n }\n}\n\nfunction getInsertPoint(\n model: ReadonlyContentModelDocument,\n insertPointOverride?: InsertPoint,\n context?: FormatContentModelContext\n): InsertPoint | null {\n if (insertPointOverride) {\n const { paragraph, marker, tableContext, path } = insertPointOverride;\n const index = paragraph.segments.indexOf(marker);\n const previousSegment = index > 0 ? paragraph.segments[index - 1] : null;\n\n // It is possible that the real selection is right before the override selection marker.\n // This happens when:\n // [Override marker][Entity node to wrap][Real marker]\n // Then we will move the entity node into entity wrapper, causes the override marker and real marker are at the same place\n // And recreating content model causes real marker to appear before override marker.\n // Once that happens, we need to use the real marker instead so that after insert entity, real marker can be placed\n // after new entity (if insertPointOverride==true)\n return previousSegment?.segmentType == 'SelectionMarker' && previousSegment.isSelected\n ? {\n marker: previousSegment,\n paragraph,\n tableContext,\n path,\n }\n : insertPointOverride;\n } else {\n const deleteResult = deleteSelection(model, [], context);\n const insertPoint = deleteResult.insertPoint;\n\n if (deleteResult.deleteResult == 'range') {\n normalizeContentModel(model);\n }\n\n return insertPoint;\n }\n}\n"]}
|
|
@@ -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"]}
|
|
@@ -14,8 +14,8 @@ define(["require", "exports", "tslib", "../../modelApi/selection/adjustWordSelec
|
|
|
14
14
|
function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, segmentHasStyleCallback, includingFormatHolder, afterFormatCallback) {
|
|
15
15
|
editor.formatContentModel(function (model, context) {
|
|
16
16
|
var segmentAndParagraphs = (0, roosterjs_content_model_dom_1.getSelectedSegmentsAndParagraphs)(model, !!includingFormatHolder, false /*includingEntity*/, true /*mutate*/);
|
|
17
|
-
var isCollapsedSelection = segmentAndParagraphs.length
|
|
18
|
-
segmentAndParagraphs[0]
|
|
17
|
+
var isCollapsedSelection = segmentAndParagraphs.length >= 1 &&
|
|
18
|
+
segmentAndParagraphs.every(function (x) { return x[0].segmentType == 'SelectionMarker'; });
|
|
19
19
|
if (isCollapsedSelection) {
|
|
20
20
|
var para_1 = segmentAndParagraphs[0][1];
|
|
21
21
|
var path_1 = segmentAndParagraphs[0][2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;IAUA;;;;;;;;OAQG;IACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;QAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAI,oBAAoB,GAAG,IAAA,8DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;YACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;gBAChC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;IAUA;;;;;;;;OAQG;IACH,SAAgB,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;QAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAI,oBAAoB,GAAG,IAAA,8DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;YACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;gBAChC,oBAAoB,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAArC,CAAqC,CAAC,CAAC;YAE3E,IAAI,oBAAoB,EAAE;gBACtB,IAAM,MAAI,GAAG,oBAAo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AC;YAE7B,IAAI,oBAAoB,EAAE;gBACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;aAChB;iBAAM;gBACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;aACxC;QACL,CAAC,EACD;YACI,OAAO,SAAA;SACV,CACJ,CAAC;IACN,CAAC;IAzED,sEAyEC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected segment using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\n */\nexport function formatSegmentWithContentModel(\n editor: IEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[0].segmentType == 'SelectionMarker');\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n const path = segmentAndParagraphs[0][2];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para, path]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | null\n ][] = segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\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/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;AA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C,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,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 { 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;AACh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,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"]}
|
|
@@ -71,7 +71,24 @@ export function insertEntityModel(model, entityModel, position, isBlock, focusAf
|
|
|
71
71
|
}
|
|
72
72
|
function getInsertPoint(model, insertPointOverride, context) {
|
|
73
73
|
if (insertPointOverride) {
|
|
74
|
-
|
|
74
|
+
var paragraph = insertPointOverride.paragraph, marker = insertPointOverride.marker, tableContext = insertPointOverride.tableContext, path = insertPointOverride.path;
|
|
75
|
+
var index = paragraph.segments.indexOf(marker);
|
|
76
|
+
var previousSegment = index > 0 ? paragraph.segments[index - 1] : null;
|
|
77
|
+
// It is possible that the real selection is right before the override selection marker.
|
|
78
|
+
// This happens when:
|
|
79
|
+
// [Override marker][Entity node to wrap][Real marker]
|
|
80
|
+
// Then we will move the entity node into entity wrapper, causes the override marker and real marker are at the same place
|
|
81
|
+
// And recreating content model causes real marker to appear before override marker.
|
|
82
|
+
// Once that happens, we need to use the real marker instead so that after insert entity, real marker can be placed
|
|
83
|
+
// after new entity (if insertPointOverride==true)
|
|
84
|
+
return (previousSegment === null || previousSegment === void 0 ? void 0 : previousSegment.segmentType) == 'SelectionMarker' && previousSegment.isSelected
|
|
85
|
+
? {
|
|
86
|
+
marker: previousSegment,
|
|
87
|
+
paragraph: paragraph,
|
|
88
|
+
tableContext: tableContext,
|
|
89
|
+
path: path,
|
|
90
|
+
}
|
|
91
|
+
: insertPointOverride;
|
|
75
92
|
}
|
|
76
93
|
else {
|
|
77
94
|
var deleteResult = deleteSelection(model, [], context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,iCAAiC,EACjC,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAarC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC7B,KAAmC,EACnC,WAA+B,EAC/B,QAA8B,EAC9B,OAAgB,EAChB,gBAA0B,EAC1B,OAAmC,EACnC,mBAAiC;;;IAEjC,IAAI,WAAuD,CAAC;IAC5D,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;I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;YACH,aAAa,GAAG,eAAe,CAC3B,KAAK,CAAC,cAAc,EACpB,SAAS,CAAC,UAAU,EACpB,KAAK,CAAC,MAAM,CACf,CAAC;YAEF,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SACtC;QAED,CAAA,KAAA,WAAW,CAAC,WAAW,CAAC,CAAC,MAAM,CAAA,CAAC,MAAM,0BAAC,UAAU,EAAE,CAAC,UAAK,cAAc,WAAE;QAEzE,IAAI,gBAAgB,IAAI,aAAa,EAAE;YACnC,IAAM,MAAM,GAAG,qBAAqB,CAAC,CAAA,MAAA,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAE,MAAM,KAAI,KAAK,CAAC,MAAM,CAAC,CAAC;YACxF,IAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;YAExC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3D,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SACvC;KACJ;AACL,CAAC;AAED,SAAS,cAAc,CACnB,KAAmC,EACnC,mBAAiC,EACjC,OAAmC;IAEnC,IAAI,mBAAmB,EAAE;QACrB,OAAO,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"insertEntityModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,iCAAiC,EACjC,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAarC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC7B,KAAmC,EACnC,WAA+B,EAC/B,QAA8B,EAC9B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e,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAEzE,wFAAwF;QACxF,qBAAqB;QACrB,sDAAsD;QACtD,0HAA0H;QAC1H,oFAAoF;QACpF,mHAAmH;QACnH,kDAAkD;QAClD,OAAO,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,WAAW,KAAI,iBAAiB,IAAI,eAAe,CAAC,UAAU;YAClF,CAAC,CAAC;gBACI,MAAM,EAAE,eAAe;gBACvB,SAAS,WAAA;gBACT,YAAY,cAAA;gBACZ,IAAI,MAAA;aACP;YACH,CAAC,CAAC,mBAAmB,CAAC;KAC7B;SAAM;QACH,IAAM,YAAY,GAAG,eAAe,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACzD,IAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;QAE7C,IAAI,YAAY,CAAC,YAAY,IAAI,OAAO,EAAE;YACtC,qBAAqB,CAAC,KAAK,CAAC,CAAC;SAChC;QAED,OAAO,WAAW,CAAC;KACtB;AACL,CAAC","sourcesContent":["import {\n createBr,\n createParagraph,\n createSelectionMarker,\n normalizeContentModel,\n deleteSelection,\n getClosestAncestorBlockGroupIndex,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelEntity,\n FormatContentModelContext,\n InsertEntityPosition,\n InsertPoint,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelBlock,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function insertEntityModel(\n model: ReadonlyContentModelDocument,\n entityModel: ContentModelEntity,\n position: InsertEntityPosition,\n isBlock: boolean,\n focusAfterEntity?: boolean,\n context?: FormatContentModelContext,\n insertPointOverride?: InsertPoint\n) {\n let blockParent: ReadonlyContentModelBlockGroup | undefined;\n let blockIndex = -1;\n let insertPoint: InsertPoint | null;\n\n if (position == 'begin' || position == 'end') {\n blockParent = model;\n blockIndex = position == 'begin' ? 0 : model.blocks.length;\n\n if (!isBlock) {\n Object.assign(entityModel.format, model.format);\n }\n } else if ((insertPoint = getInsertPoint(model, insertPointOverride, context))) {\n const { marker, paragraph, path } = insertPoint;\n\n if (!isBlock) {\n const index = paragraph.segments.indexOf(marker);\n\n Object.assign(entityModel.format, marker.format);\n\n if (index >= 0) {\n paragraph.segments.splice(focusAfterEntity ? index : index + 1, 0, entityModel);\n }\n } else {\n const pathIndex =\n position == 'root'\n ? getClosestAncestorBlockGroupIndex(path, ['TableCell', 'Document'])\n : 0;\n blockParent = mutateBlock(path[pathIndex]);\n\n const child = path[pathIndex - 1];\n const directChild: ReadonlyContentModelBlock =\n child?.blockGroupType == 'FormatContainer' ||\n child?.blockGroupType == 'General' ||\n child?.blockGroupType == 'ListItem'\n ? child\n : paragraph;\n const childIndex = blockParent.blocks.indexOf(directChild);\n blockIndex = childIndex >= 0 ? childIndex + 1 : -1;\n }\n }\n\n if (blockIndex >= 0 && blockParent) {\n const blocksToInsert: ShallowMutableContentModelBlock[] = [];\n let nextParagraph: ShallowMutableContentModelParagraph | undefined;\n\n if (isBlock) {\n const nextBlock = blockParent.blocks[blockIndex];\n\n blocksToInsert.push(entityModel);\n\n if (nextBlock?.blockType == 'Paragraph') {\n nextParagraph = mutateBlock(nextBlock);\n } else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {\n nextParagraph = createParagraph(false /*isImplicit*/, {}, model.format);\n nextParagraph.segments.push(createBr(model.format));\n blocksToInsert.push(nextParagraph);\n }\n } else {\n nextParagraph = createParagraph(\n false /*isImplicit*/,\n undefined /*format*/,\n model.format\n );\n\n nextParagraph.segments.push(entityModel);\n blocksToInsert.push(nextParagraph);\n }\n\n mutateBlock(blockParent).blocks.splice(blockIndex, 0, ...blocksToInsert);\n\n if (focusAfterEntity && nextParagraph) {\n const marker = createSelectionMarker(nextParagraph.segments[0]?.format || model.format);\n const segments = nextParagraph.segments;\n\n isBlock ? segments.unshift(marker) : segments.push(marker);\n setSelection(model, marker, marker);\n }\n }\n}\n\nfunction getInsertPoint(\n model: ReadonlyContentModelDocument,\n insertPointOverride?: InsertPoint,\n context?: FormatContentModelContext\n): InsertPoint | null {\n if (insertPointOverride) {\n const { paragraph, marker, tableContext, path } = insertPointOverride;\n const index = paragraph.segments.indexOf(marker);\n const previousSegment = index > 0 ? paragraph.segments[index - 1] : null;\n\n // It is possible that the real selection is right before the override selection marker.\n // This happens when:\n // [Override marker][Entity node to wrap][Real marker]\n // Then we will move the entity node into entity wrapper, causes the override marker and real marker are at the same place\n // And recreating content model causes real marker to appear before override marker.\n // Once that happens, we need to use the real marker instead so that after insert entity, real marker can be placed\n // after new entity (if insertPointOverride==true)\n return previousSegment?.segmentType == 'SelectionMarker' && previousSegment.isSelected\n ? {\n marker: previousSegment,\n paragraph,\n tableContext,\n path,\n }\n : insertPointOverride;\n } else {\n const deleteResult = deleteSelection(model, [], context);\n const insertPoint = deleteResult.insertPoint;\n\n if (deleteResult.deleteResult == 'range') {\n normalizeContentModel(model);\n }\n\n return insertPoint;\n }\n}\n"]}
|
|
@@ -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"]}
|
|
@@ -13,8 +13,8 @@ import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';
|
|
|
13
13
|
export function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, segmentHasStyleCallback, includingFormatHolder, afterFormatCallback) {
|
|
14
14
|
editor.formatContentModel(function (model, context) {
|
|
15
15
|
var segmentAndParagraphs = getSelectedSegmentsAndParagraphs(model, !!includingFormatHolder, false /*includingEntity*/, true /*mutate*/);
|
|
16
|
-
var isCollapsedSelection = segmentAndParagraphs.length
|
|
17
|
-
segmentAndParagraphs[0]
|
|
16
|
+
var isCollapsedSelection = segmentAndParagraphs.length >= 1 &&
|
|
17
|
+
segmentAndParagraphs.every(function (x) { return x[0].segmentType == 'SelectionMarker'; });
|
|
18
18
|
if (isCollapsedSelection) {
|
|
19
19
|
var para_1 = segmentAndParagraphs[0][1];
|
|
20
20
|
var path_1 = segmentAndParagraphs[0][2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAS/E;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAS/E;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAAmE;IAEnE,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,KAAK,CAAC,mBAAmB,EACzB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAArC,CAAqC,CAAC,CAAC;QAE3E,IAAI,oBAAoB,EAAE;YACtB,IAAM,MAAI,GAAG,oBAAoB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AAoB,EAAE;YACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;SACxC;IACL,CAAC,EACD;QACI,OAAO,SAAA;KACV,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n IEditor,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected segment using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\n */\nexport function formatSegmentWithContentModel(\n editor: IEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ReadonlyContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n false /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[0].segmentType == 'SelectionMarker');\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n const path = segmentAndParagraphs[0][2];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para, path]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | null\n ][] = segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\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.7.0",
|
|
7
|
+
"roosterjs-content-model-types": "^9.7.0"
|
|
8
8
|
},
|
|
9
|
-
"version": "9.
|
|
9
|
+
"version": "9.7.0",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"typings": "./lib/index.d.ts",
|
|
12
12
|
"module": "./lib-mjs/index.js",
|