roosterjs-content-model-api 0.24.0 → 0.25.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 +3 -1
- package/lib/index.js.map +1 -1
- package/lib/modelApi/block/setModelDirection.js +0 -1
- package/lib/modelApi/block/setModelDirection.js.map +1 -1
- package/lib/modelApi/block/toggleModelBlockQuote.d.ts +1 -1
- package/lib/modelApi/block/toggleModelBlockQuote.js +6 -4
- package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib/modelApi/common/retrieveModelFormatState.js +0 -2
- package/lib/modelApi/common/retrieveModelFormatState.js.map +1 -1
- package/lib/modelApi/common/wrapBlock.d.ts +2 -2
- package/lib/modelApi/common/wrapBlock.js +8 -4
- package/lib/modelApi/common/wrapBlock.js.map +1 -1
- package/lib/modelApi/link/matchLink.d.ts +29 -0
- package/lib/modelApi/link/matchLink.js +95 -0
- package/lib/modelApi/link/matchLink.js.map +1 -0
- package/lib/modelApi/list/setListType.d.ts +3 -1
- package/lib/modelApi/list/setListType.js +6 -9
- package/lib/modelApi/list/setListType.js.map +1 -1
- package/lib/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib/publicApi/block/toggleBlockQuote.js +10 -6
- package/lib/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib/publicApi/entity/insertEntity.js +6 -10
- package/lib/publicApi/entity/insertEntity.js.map +1 -1
- package/lib/publicApi/format/getFormatState.d.ts +1 -21
- package/lib/publicApi/format/getFormatState.js +1 -69
- package/lib/publicApi/format/getFormatState.js.map +1 -1
- package/lib/publicApi/link/insertLink.js +3 -12
- package/lib/publicApi/link/insertLink.js.map +1 -1
- package/lib/publicApi/segment/changeCapitalization.js +0 -1
- package/lib/publicApi/segment/changeCapitalization.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/block/setModelDirection.js +0 -1
- package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.d.ts +1 -1
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js +6 -4
- package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-amd/modelApi/common/retrieveModelFormatState.js +0 -2
- package/lib-amd/modelApi/common/retrieveModelFormatState.js.map +1 -1
- package/lib-amd/modelApi/common/wrapBlock.d.ts +2 -2
- package/lib-amd/modelApi/common/wrapBlock.js +8 -4
- package/lib-amd/modelApi/common/wrapBlock.js.map +1 -1
- package/lib-amd/modelApi/link/matchLink.d.ts +29 -0
- package/lib-amd/modelApi/link/matchLink.js +95 -0
- package/lib-amd/modelApi/link/matchLink.js.map +1 -0
- package/lib-amd/modelApi/list/setListType.d.ts +3 -1
- package/lib-amd/modelApi/list/setListType.js +6 -9
- package/lib-amd/modelApi/list/setListType.js.map +1 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib-amd/publicApi/block/toggleBlockQuote.js +10 -6
- package/lib-amd/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib-amd/publicApi/entity/insertEntity.js +6 -10
- package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-amd/publicApi/format/getFormatState.d.ts +1 -21
- package/lib-amd/publicApi/format/getFormatState.js +2 -67
- package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
- package/lib-amd/publicApi/link/insertLink.js +3 -12
- package/lib-amd/publicApi/link/insertLink.js.map +1 -1
- package/lib-amd/publicApi/segment/changeCapitalization.js +0 -1
- package/lib-amd/publicApi/segment/changeCapitalization.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/block/setModelDirection.js +0 -1
- package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.d.ts +1 -1
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js +6 -4
- package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
- package/lib-mjs/modelApi/common/retrieveModelFormatState.js +0 -2
- package/lib-mjs/modelApi/common/retrieveModelFormatState.js.map +1 -1
- package/lib-mjs/modelApi/common/wrapBlock.d.ts +2 -2
- package/lib-mjs/modelApi/common/wrapBlock.js +8 -4
- package/lib-mjs/modelApi/common/wrapBlock.js.map +1 -1
- package/lib-mjs/modelApi/link/matchLink.d.ts +29 -0
- package/lib-mjs/modelApi/link/matchLink.js +91 -0
- package/lib-mjs/modelApi/link/matchLink.js.map +1 -0
- package/lib-mjs/modelApi/list/setListType.d.ts +3 -1
- package/lib-mjs/modelApi/list/setListType.js +6 -9
- package/lib-mjs/modelApi/list/setListType.js.map +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.d.ts +1 -1
- package/lib-mjs/publicApi/block/toggleBlockQuote.js +10 -6
- package/lib-mjs/publicApi/block/toggleBlockQuote.js.map +1 -1
- package/lib-mjs/publicApi/entity/insertEntity.js +6 -10
- package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
- package/lib-mjs/publicApi/format/getFormatState.d.ts +1 -21
- package/lib-mjs/publicApi/format/getFormatState.js +1 -67
- package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
- package/lib-mjs/publicApi/link/insertLink.js +2 -11
- package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.js +0 -1
- package/lib-mjs/publicApi/segment/changeCapitalization.js.map +1 -1
- package/package.json +4 -6
package/lib/index.d.ts
CHANGED
|
@@ -40,3 +40,4 @@ export { default as adjustImageSelection } from './publicApi/image/adjustImageSe
|
|
|
40
40
|
export { default as setParagraphMargin } from './publicApi/block/setParagraphMargin';
|
|
41
41
|
export { default as toggleCode } from './publicApi/segment/toggleCode';
|
|
42
42
|
export { default as insertEntity } from './publicApi/entity/insertEntity';
|
|
43
|
+
export { setListType } from './modelApi/list/setListType';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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;
|
|
3
|
+
exports.setListType = 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
4
|
var insertTable_1 = require("./publicApi/table/insertTable");
|
|
5
5
|
Object.defineProperty(exports, "insertTable", { enumerable: true, get: function () { return insertTable_1.default; } });
|
|
6
6
|
var formatTable_1 = require("./publicApi/table/formatTable");
|
|
@@ -85,4 +85,6 @@ var toggleCode_1 = require("./publicApi/segment/toggleCode");
|
|
|
85
85
|
Object.defineProperty(exports, "toggleCode", { enumerable: true, get: function () { return toggleCode_1.default; } });
|
|
86
86
|
var insertEntity_1 = require("./publicApi/entity/insertEntity");
|
|
87
87
|
Object.defineProperty(exports, "insertEntity", { enumerable: true, get: function () { return insertEntity_1.default; } });
|
|
88
|
+
var setListType_1 = require("./modelApi/list/setListType");
|
|
89
|
+
Object.defineProperty(exports, "setListType", { enumerable: true, get: function () { return setListType_1.setListType; } });
|
|
88
90
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages-content-model/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":";;;AAAA,6DAAuE;AAA9D,0GAAA,OAAO,OAAe;AAC/B,6DAAuE;AAA9D,0GAAA,OAAO,OAAe;AAC/B,yEAAmF;AAA1E,sHAAA,OAAO,OAAqB;AACrC,yDAAmE;AAA1D,sGAAA,OAAO,OAAa;AAC7B,mFAA6F;AAApF,gIAAA,OAAO,OAA0B;AAC1C,8DAAwE;AAA/D,4GAAA,OAAO,OAAgB;AAChC,oEAA8E;AAArE,kHAAA,OAAO,OAAmB;AACnC,6DAAuE;AAA9D,wGAAA,OAAO,OAAc;AAC9B,iEAA2E;AAAlE,4GAAA,OAAO,OAAgB;AAChC,uEAAiF;AAAxE,kHAAA,OAAO,OAAmB;AACnC,+EAAyF;AAAhF,0HAAA,OAAO,OAAuB;AACvC,uEAAiF;AAAxE,kHAAA,OAAO,OAAmB;AACnC,2EAAqF;AAA5E,sHAAA,OAAO,OAAqB;AACrC,6EAAuF;AAA9E,wHAA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port { default as formatTable } from './publicApi/table/formatTable';\nexport { default as setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { default as editTable } from './publicApi/table/editTable';\nexport { default as applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { default as toggleBullet } from './publicApi/list/toggleBullet';\nexport { default as toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { default as toggleBold } from './publicApi/segment/toggleBold';\nexport { default as toggleItalic } from './publicApi/segment/toggleItalic';\nexport { default as toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { default as toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { default as toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { default as toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { default as setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { default as setFontName } from './publicApi/segment/setFontName';\nexport { default as setFontSize } from './publicApi/segment/setFontSize';\nexport { default as setTextColor } from './publicApi/segment/setTextColor';\nexport { default as changeFontSize } from './publicApi/segment/changeFontSize';\nexport { default as applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { default as changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { default as insertImage } from './publicApi/image/insertImage';\nexport { default as setListStyle } from './publicApi/list/setListStyle';\nexport { default as setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { default as setIndentation } from './publicApi/block/setIndentation';\nexport { default as setAlignment } from './publicApi/block/setAlignment';\nexport { default as setDirection } from './publicApi/block/setDirection';\nexport { default as setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { default as toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { default as setSpacing } from './publicApi/block/setSpacing';\nexport { default as setImageBorder } from './publicApi/image/setImageBorder';\nexport { default as setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { default as changeImage } from './publicApi/image/changeImage';\nexport { default as getFormatState } from './publicApi/format/getFormatState';\nexport { default as clearFormat } from './publicApi/format/clearFormat';\nexport { default as insertLink } from './publicApi/link/insertLink';\nexport { default as removeLink } from './publicApi/link/removeLink';\nexport { default as adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { default as setImageAltText } from './publicApi/image/setImageAltText';\nexport { default as adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { default as setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { default as toggleCode } from './publicApi/segment/toggleCode';\nexport { default as insertEntity } from './publicApi/entity/insertEntity';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages-content-model/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":";;;AAAA,6DAAuE;AAA9D,0GAAA,OAAO,OAAe;AAC/B,6DAAuE;AAA9D,0GAAA,OAAO,OAAe;AAC/B,yEAAmF;AAA1E,sHAAA,OAAO,OAAqB;AACrC,yDAAmE;AAA1D,sGAAA,OAAO,OAAa;AAC7B,mFAA6F;AAApF,gIAAA,OAAO,OAA0B;AAC1C,8DAAwE;AAA/D,4GAAA,OAAO,OAAgB;AAChC,oEAA8E;AAArE,kHAAA,OAAO,OAAmB;AACnC,6DAAuE;AAA9D,wGAAA,OAAO,OAAc;AAC9B,iEAA2E;AAAlE,4GAAA,OAAO,OAAgB;AAChC,uEAAiF;AAAxE,kHAAA,OAAO,OAAmB;AACnC,+EAAyF;AAAhF,0HAAA,OAAO,OAAuB;AACvC,uEAAiF;AAAxE,kHAAA,OAAO,OAAmB;AACnC,2EAAqF;AAA5E,sHAAA,OAAO,OAAqB;AACrC,6EAAuF;AAA9E,wHAAA,OAAO,OAAsB;AACtC,+DAAyE;AAAhE,0GAAA,OAAO,OAAe;AAC/B,+DAAyE;AAAhE,0GAAA,OAAO,OAAe;AAC/B,iEAA2E;AAAlE,4GAAA,OAAO,OAAgB;AAChC,qEAA+E;AAAtE,gHAAA,OAAO,OAAkB;AAClC,6EAAuF;AAA9E,wHAAA,OAAO,OAAsB;AACtC,iFAA2F;AAAlF,4HAAA,OAAO,OAAwB;AACxC,6DAAuE;AAA9D,0GAAA,OAAO,OAAe;AAC/B,8DAAwE;AAA/D,4GAAA,OAAO,OAAgB;AAChC,0EAAoF;AAA3E,wHAAA,OAAO,OAAsB;AACtC,mEAA6E;AAApE,gHAAA,OAAO,OAAkB;AAClC,+DAAyE;AAAhE,4GAAA,OAAO,OAAgB;AAChC,+DAAyE;AAAhE,4GAAA,OAAO,OAAgB;AAChC,qEAA+E;AAAtE,kHAAA,OAAO,OAAmB;AACnC,uEAAiF;AAAxE,oHAAA,OAAO,OAAoB;AACpC,2DAAqE;AAA5D,wGAAA,OAAO,OAAc;AAC9B,mEAA6E;AAApE,gHAAA,OAAO,OAAkB;AAClC,yEAAmF;AAA1E,sHAAA,OAAO,OAAqB;AACrC,6DAAuE;AAA9D,0GAAA,OAAO,OAAe;AAC/B,oEAA8E;AAArE,gHAAA,OAAO,OAAkB;AAClC,8DAAwE;AAA/D,0GAAA,OAAO,OAAe;AAC/B,0DAAoE;AAA3D,wGAAA,OAAO,OAAc;AAC9B,0DAAoE;AAA3D,wGAAA,OAAO,OAAc;AAC9B,4EAAsF;AAA7E,0HAAA,OAAO,OAAuB;AACvC,qEAA+E;AAAtE,kHAAA,OAAO,OAAmB;AACnC,+EAAyF;AAAhF,4HAAA,OAAO,OAAwB;AACxC,2EAAqF;AAA5E,wHAAA,OAAO,OAAsB;AACtC,6DAAuE;AAA9D,wGAAA,OAAO,OAAc;AAC9B,gEAA0E;AAAjE,4GAAA,OAAO,OAAgB;AAChC,2DAA0D;AAAjD,0GAAA,WAAW,OAAA","sourcesContent":["export { default as insertTable } from './publicApi/table/insertTable';\nexport { default as formatTable } from './publicApi/table/formatTable';\nexport { default as setTableCellShade } from './publicApi/table/setTableCellShade';\nexport { default as editTable } from './publicApi/table/editTable';\nexport { default as applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';\nexport { default as toggleBullet } from './publicApi/list/toggleBullet';\nexport { default as toggleNumbering } from './publicApi/list/toggleNumbering';\nexport { default as toggleBold } from './publicApi/segment/toggleBold';\nexport { default as toggleItalic } from './publicApi/segment/toggleItalic';\nexport { default as toggleUnderline } from './publicApi/segment/toggleUnderline';\nexport { default as toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';\nexport { default as toggleSubscript } from './publicApi/segment/toggleSubscript';\nexport { default as toggleSuperscript } from './publicApi/segment/toggleSuperscript';\nexport { default as setBackgroundColor } from './publicApi/segment/setBackgroundColor';\nexport { default as setFontName } from './publicApi/segment/setFontName';\nexport { default as setFontSize } from './publicApi/segment/setFontSize';\nexport { default as setTextColor } from './publicApi/segment/setTextColor';\nexport { default as changeFontSize } from './publicApi/segment/changeFontSize';\nexport { default as applySegmentFormat } from './publicApi/segment/applySegmentFormat';\nexport { default as changeCapitalization } from './publicApi/segment/changeCapitalization';\nexport { default as insertImage } from './publicApi/image/insertImage';\nexport { default as setListStyle } from './publicApi/list/setListStyle';\nexport { default as setListStartNumber } from './publicApi/list/setListStartNumber';\nexport { default as setIndentation } from './publicApi/block/setIndentation';\nexport { default as setAlignment } from './publicApi/block/setAlignment';\nexport { default as setDirection } from './publicApi/block/setDirection';\nexport { default as setHeadingLevel } from './publicApi/block/setHeadingLevel';\nexport { default as toggleBlockQuote } from './publicApi/block/toggleBlockQuote';\nexport { default as setSpacing } from './publicApi/block/setSpacing';\nexport { default as setImageBorder } from './publicApi/image/setImageBorder';\nexport { default as setImageBoxShadow } from './publicApi/image/setImageBoxShadow';\nexport { default as changeImage } from './publicApi/image/changeImage';\nexport { default as getFormatState } from './publicApi/format/getFormatState';\nexport { default as clearFormat } from './publicApi/format/clearFormat';\nexport { default as insertLink } from './publicApi/link/insertLink';\nexport { default as removeLink } from './publicApi/link/removeLink';\nexport { default as adjustLinkSelection } from './publicApi/link/adjustLinkSelection';\nexport { default as setImageAltText } from './publicApi/image/setImageAltText';\nexport { default as adjustImageSelection } from './publicApi/image/adjustImageSelection';\nexport { default as setParagraphMargin } from './publicApi/block/setParagraphMargin';\nexport { default as toggleCode } from './publicApi/segment/toggleCode';\nexport { default as insertEntity } from './publicApi/entity/insertEntity';\nexport { setListType } from './modelApi/list/setListType';\n"]}
|
|
@@ -32,7 +32,6 @@ function internalSetDirection(format, direction, block) {
|
|
|
32
32
|
if (wasRtl != isRtl) {
|
|
33
33
|
format.direction = direction;
|
|
34
34
|
// Adjust margin when change direction
|
|
35
|
-
// TODO: make margin and padding direction-aware, like what we did for textAlign. So no need to adjust them here
|
|
36
35
|
var marginLeft = format.marginLeft;
|
|
37
36
|
var paddingLeft = format.paddingLeft;
|
|
38
37
|
setProperty(format, 'marginLeft', format.marginRight);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;AAAA,+EAA8E;AAC9E,6EAKsC;AAWtC;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA2B,EAAE,SAAwB;IACnF,IAAM,0BAA0B,GAAG,IAAA,mDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;IAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;YAAP,KAAK,WAAA;QACvC,IAAI,IAAA,iDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;YAC7D,IAAM,KAAK,GAAG,IAAA,qDAAyB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEtD,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;gBACd,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;oBACrB,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;gBACvC,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,EAA7C,CAA6C,CAAC,CAAC;YAChF,CAAC,CAAC,CAAC;SACN;aAAM,IAAI,KAAK,EAAE;YACd,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;SACxD;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC;AAxBD,8CAwBC;AAED,SAAS,oBAAoB,CACzB,MAA+B,EAC/B,SAAwB,EACxB,KAAyB;IAEzB,IAAM,MAAM,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC;IACzC,IAAM,KAAK,GAAG,SAAS,IAAI,KAAK,CAAC;IAEjC,IAAI,MAAM,IAAI,KAAK,EAAE;QACjB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAE7B,sCAAsC;QACtC,
|
|
1
|
+
{"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;AAAA,+EAA8E;AAC9E,6EAKsC;AAWtC;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA2B,EAAE,SAAwB;IACnF,IAAM,0BAA0B,GAAG,IAAA,mDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;IAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;YAAP,KAAK,WAAA;QACvC,IAAI,IAAA,iDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;YAC7D,IAAM,KAAK,GAAG,IAAA,qDAAyB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEtD,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;gBACd,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;oBACrB,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;gBACvC,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,MAA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AAQ;wBAClC,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,cAAc,EAAE;4BAC1B,IAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;4BAC/C,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;4BAChE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;yBAC5D;wBACD,OAAO,QAAQ,CAAC;oBACpB,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;YAEH,wBAAwB;YACxB,IAAA,+CAAgB,EAAC,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;SAC/E;KACJ;AACL,CAAC;AAED,SAAS,WAAW,CAChB,MAAmD,EACnD,GAAwD,EACxD,KAAyB;IAEzB,IAAI,KAAK,EAAE;QACP,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KACvB;SAAM;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;KACtB;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n BorderFormat,\n ContentModelBlock,\n ContentModelBlockFormat,\n ContentModelDocument,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setModelDirection(model: ContentModelDocument, direction: 'ltr' | 'rtl') {\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(item => {\n item.levels.forEach(level => {\n level.format.direction = direction;\n });\n\n item.blocks.forEach(block => internalSetDirection(block.format, direction));\n });\n } else if (block) {\n internalSetDirection(block.format, direction, block);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(\n format: ContentModelBlockFormat,\n direction: 'ltr' | 'rtl',\n block?: ContentModelBlock\n) {\n const wasRtl = format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n format.direction = direction;\n\n // Adjust margin when change direction\n const marginLeft = format.marginLeft;\n const paddingLeft = format.paddingLeft;\n\n setProperty(format, 'marginLeft', format.marginRight);\n setProperty(format, 'marginRight', marginLeft);\n setProperty(format, 'paddingLeft', format.paddingRight);\n setProperty(format, 'paddingRight', paddingLeft);\n\n // If whole Table direction changed, flip cell side borders\n if (block && block.blockType == 'Table') {\n block.rows.forEach(row => {\n row.cells.forEach(cell => {\n // Optimise by skipping cells with unchanged borders\n updateTableCellMetadata(cell, metadata => {\n if (metadata?.borderOverride) {\n const storeBorderLeft = cell.format.borderLeft;\n setProperty(cell.format, 'borderLeft', cell.format.borderRight);\n setProperty(cell.format, 'borderRight', storeBorderLeft);\n }\n return metadata;\n });\n });\n });\n\n // Apply changed borders\n applyTableFormat(block, undefined /* newFormat */, true /* keepCellShade*/);\n }\n }\n}\n\nfunction setProperty(\n format: MarginFormat & PaddingFormat & BorderFormat,\n key: keyof (MarginFormat & PaddingFormat & BorderFormat),\n value: string | undefined\n) {\n if (value) {\n format[key] = value;\n } else {\n delete format[key];\n }\n}\n"]}
|
|
@@ -2,4 +2,4 @@ import type { ContentModelDocument, ContentModelFormatContainerFormat } from 'ro
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function toggleModelBlockQuote(model: ContentModelDocument,
|
|
5
|
+
export declare function toggleModelBlockQuote(model: ContentModelDocument, formatLtr: ContentModelFormatContainerFormat, formatRtl: ContentModelFormatContainerFormat): boolean;
|
|
@@ -7,7 +7,7 @@ var wrapBlock_1 = require("../common/wrapBlock");
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
function toggleModelBlockQuote(model,
|
|
10
|
+
function toggleModelBlockQuote(model, formatLtr, formatRtl) {
|
|
11
11
|
var paragraphOfQuote = (0, roosterjs_content_model_core_1.getOperationalBlocks)(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/);
|
|
12
12
|
if (areAllBlockQuotes(paragraphOfQuote)) {
|
|
13
13
|
// All selections are already in quote, we need to unquote them
|
|
@@ -18,9 +18,11 @@ function toggleModelBlockQuote(model, format) {
|
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
var step1Results_1 = [];
|
|
21
|
-
var creator_1 = function () {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var creator_1 = function (isRtl) {
|
|
22
|
+
return (0, roosterjs_content_model_dom_1.createFormatContainer)('blockquote', isRtl ? formatRtl : formatLtr);
|
|
23
|
+
};
|
|
24
|
+
var canMerge_1 = function (isRtl, target, current) {
|
|
25
|
+
return canMergeQuote(target, (current === null || current === void 0 ? void 0 : current.format) || (isRtl ? formatRtl : formatLtr));
|
|
24
26
|
};
|
|
25
27
|
paragraphOfQuote.forEach(function (_a) {
|
|
26
28
|
var block = _a.block, parent = _a.parent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.ts"],"names":[],"mappings":";;;AAAA,2EAAiG;AACjG,6EAAwF;AACxF,iDAAqE;AAYrE;;GAEG;AACH,SAAgB,qBAAqB,CACjC,KAA2B,EAC3B,
|
|
1
|
+
{"version":3,"file":"toggleModelBlockQuote.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/toggleModelBlockQuote.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;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,0BAAc,EAAC,cAAY,EAAE,UAAQ,CAAC,CAAC;KAC1C;IAED,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;AACvC,CAAC;AArCD,sDAqCC;AAED,SAAS,aAAa,CAClB,MAAyB,EACzB,MAAyC;IAEzC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,IAAA,4CAAc,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,OAAO,CAAC,KAAwB;IACrC,OAAO,CACH,IAAA,iDAAkB,EAA8B,KAAK,EAAE,iBAAiB,CAAC;QACzE,KAAK,CAAC,OAAO,IAAI,YAAY,CAChC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CACtB,eAAwF;IAExF,OAAO,eAAe,CAAC,KAAK,CAAC,UAAA,cAAc,IAAI,OAAA,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import { areSameFormats, createFormatContainer, unwrapBlock } from 'roosterjs-content-model-dom';\nimport { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';\nimport { wrapBlockStep1, wrapBlockStep2 } from '../common/wrapBlock';\nimport type { OperationalBlocks } from 'roosterjs-content-model-core';\nimport type { WrapBlockStep1Result } from '../common/wrapBlock';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelFormatContainerFormat,\n ContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function toggleModelBlockQuote(\n model: ContentModelDocument,\n formatLtr: ContentModelFormatContainerFormat,\n formatRtl: ContentModelFormatContainerFormat\n): boolean {\n const paragraphOfQuote = getOperationalBlocks<\n ContentModelFormatContainer | ContentModelListItem\n >(model, ['FormatContainer', 'ListItem'], ['TableCell'], true /*deepFirst*/);\n\n if (areAllBlockQuotes(paragraphOfQuote)) {\n // All selections are already in quote, we need to unquote them\n paragraphOfQuote.forEach(({ block, parent }) => {\n unwrapBlock(parent, block);\n });\n } else {\n const step1Results: WrapBlockStep1Result<ContentModelFormatContainer>[] = [];\n const creator = (isRtl: boolean) =>\n createFormatContainer('blockquote', isRtl ? formatRtl : formatLtr);\n const canMerge = (\n isRtl: boolean,\n target: ContentModelBlock,\n current?: ContentModelFormatContainer\n ): target is ContentModelFormatContainer =>\n canMergeQuote(target, current?.format || (isRtl ? formatRtl : formatLtr));\n\n paragraphOfQuote.forEach(({ block, parent }) => {\n if (isQuote(block)) {\n // Already in quote, no op\n } else {\n wrapBlockStep1(step1Results, parent, block, creator, canMerge);\n }\n });\n\n wrapBlockStep2(step1Results, canMerge);\n }\n\n return paragraphOfQuote.length > 0;\n}\n\nfunction canMergeQuote(\n target: ContentModelBlock,\n format: ContentModelFormatContainerFormat\n): target is ContentModelFormatContainer {\n return isQuote(target) && areSameFormats(format, target.format);\n}\n\nfunction isQuote(block: ContentModelBlock): block is ContentModelFormatContainer {\n return (\n isBlockGroupOfType<ContentModelFormatContainer>(block, 'FormatContainer') &&\n block.tagName == 'blockquote'\n );\n}\n\nfunction areAllBlockQuotes(\n blockAndParents: OperationalBlocks<ContentModelFormatContainer | ContentModelListItem>[]\n): blockAndParents is { block: ContentModelFormatContainer; parent: ContentModelBlockGroup }[] {\n return blockAndParents.every(blockAndParent => isQuote(blockAndParent.block));\n}\n"]}
|
|
@@ -76,7 +76,6 @@ function retrieveModelFormatState(model, pendingFormat, formatState) {
|
|
|
76
76
|
firstTableContext = tableContext;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
// TODO: Support Code block in format state for Content Model
|
|
80
79
|
}, {
|
|
81
80
|
includeListFormatHolder: 'never',
|
|
82
81
|
});
|
|
@@ -100,7 +99,6 @@ function retrieveSegmentFormat(result, isFirst, mergedFormat) {
|
|
|
100
99
|
mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);
|
|
101
100
|
mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);
|
|
102
101
|
mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);
|
|
103
|
-
//TODO: handle block owning segments with different line-heights
|
|
104
102
|
mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);
|
|
105
103
|
}
|
|
106
104
|
function retrieveParagraphFormat(result, paragraph, isFirst) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/retrieveModelFormatState.ts"],"names":[],"mappings":";;;AAAA,2EAAiE;AACjE,6EAMsC;AActC;;GAEG;AACH,SAAgB,wBAAwB,CACpC,KAA2B,EAC3B,aAA+C,EAC/C,WAAoC;IAEpC,IAAI,iBAAoD,CAAC;IACzD,IAAI,UAAyC,CAAC;IAC9C,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,YAAY,GAAG,IAAI,CAAC;IACxB,IAAI,cAAc,GAAG,IAAI,CAAC;IAE1B,IAAA,gDAAiB,EACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ;QAChC,oBAAoB;QACpB,uBAAuB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAEpD,uBAAuB;QACvB,IAAI,KAAK,EAAE;YACP,IAAI,UAAU,EAAE;gBACZ,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC;aAC3C;iBAAM;gBACH,UAAU,GAAG,KAAK,CAAC;aACtB;SACJ;QAED,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,WAAW,EAAE;YACjC,oBAAoB;YACpB,uBAAuB,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAErD,kBAAkB;YAClB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,UA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,CAAC,WAAW,GAAG;QACjB,WAAW,aAAA;QACX,WAAW,aAAA;QACX,WAAW,aAAA;QACX,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;KACpC,CAAC;AACN,CAAC;AAED,SAAS,UAAU,CACf,MAA+B,EAC/B,GAAM,EACN,QAAgD,EAChD,OAAgB,EAChB,OAAqF;IAArF,wBAAA,EAAA,oBAA2E,GAAG,IAAI,OAAA,GAAG,EAAH,CAAG;IAErF,IAAI,OAAO,EAAE;QACT,IAAI,QAAQ,KAAK,SAAS,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;SAC1B;KACJ;SAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;QACnD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;KACtB;AACL,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACrB,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;QACzC,uHAAuH;QACvH,wBAAwB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;KAC9D;IACD,OAAO,EAAE,CAAC;AACd,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getClosestAncestorBlockGroupIndex,\n isBold,\n iterateSelections,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelFormatState,\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelImage,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function retrieveModelFormatState(\n model: ContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState\n) {\n let firstTableContext: TableSelectionContext | undefined;\n let firstBlock: ContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n const modelFormat = Object.assign({}, model.format);\n delete modelFormat?.italic;\n delete modelFormat?.underline;\n delete modelFormat?.fontWeight;\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n Object.assign(\n {},\n modelFormat,\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n )\n );\n\n mergeValue(formatState, 'isCodeInline', !!segment?.code, isFirst);\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n\n // TODO: Support Code block in format state for Content Model\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);\n\n //TODO: handle block owning segments with different line-heights\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ContentModelParagraph,\n isFirst: boolean\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ContentModelBlockGroup[],\n isFirst: boolean\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst\n );\n}\n\nfunction retrieveTableFormat(tableContext: TableSelectionContext, result: ContentModelFormatState) {\n const tableFormat = updateTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n delete format[key];\n }\n}\n\nfunction px2Pt(px: string) {\n if (px && px.indexOf('px') == px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value is a little less than actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n return px;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/retrieveModelFormatState.ts"],"names":[],"mappings":";;;AAAA,2EAAiE;AACjE,6EAMsC;AActC;;GAEG;AACH,SAAgB,wBAAwB,CACpC,KAA2B,EAC3B,aAA+C,EAC/C,WAAoC;IAEpC,IAAI,iBAAoD,CAAC;IACzD,IAAI,UAAyC,CAAC;IAC9C,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,YAAY,GAAG,IAAI,CAAC;IACxB,IAAI,cAAc,GAAG,IAAI,CAAC;IAE1B,IAAA,gDAAiB,EACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ;QAChC,oBAAoB;QACpB,uBAAuB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAEpD,uBAAuB;QACvB,IAAI,KAAK,EAAE;YACP,IAAI,UAAU,EAAE;gBACZ,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC;aAC3C;iBAAM;gBACH,UAAU,GAAG,KAAK,CAAC;aACtB;SACJ;QAED,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,WAAW,EAAE;YACjC,oBAAoB;YACpB,uBAAuB,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAErD,kBAAkB;YAClB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CA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,WAAW,aAAA;QACX,WAAW,aAAA;QACX,WAAW,aAAA;QACX,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;KACpC,CAAC;AACN,CAAC;AAED,SAAS,UAAU,CACf,MAA+B,EAC/B,GAAM,EACN,QAAgD,EAChD,OAAgB,EAChB,OAAqF;IAArF,wBAAA,EAAA,oBAA2E,GAAG,IAAI,OAAA,GAAG,EAAH,CAAG;IAErF,IAAI,OAAO,EAAE;QACT,IAAI,QAAQ,KAAK,SAAS,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;SAC1B;KACJ;SAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;QACnD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;KACtB;AACL,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACrB,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;QACzC,uHAAuH;QACvH,wBAAwB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;KAC9D;IACD,OAAO,EAAE,CAAC;AACd,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getClosestAncestorBlockGroupIndex,\n isBold,\n iterateSelections,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelFormatState,\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelImage,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function retrieveModelFormatState(\n model: ContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState\n) {\n let firstTableContext: TableSelectionContext | undefined;\n let firstBlock: ContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n const modelFormat = Object.assign({}, model.format);\n delete modelFormat?.italic;\n delete modelFormat?.underline;\n delete modelFormat?.fontWeight;\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n Object.assign(\n {},\n modelFormat,\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n )\n );\n\n mergeValue(formatState, 'isCodeInline', !!segment?.code, isFirst);\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ContentModelParagraph,\n isFirst: boolean\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ContentModelBlockGroup[],\n isFirst: boolean\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst\n );\n}\n\nfunction retrieveTableFormat(tableContext: TableSelectionContext, result: ContentModelFormatState) {\n const tableFormat = updateTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n delete format[key];\n }\n}\n\nfunction px2Pt(px: string) {\n if (px && px.indexOf('px') == px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value is a little less than actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n return px;\n}\n"]}
|
|
@@ -9,8 +9,8 @@ export interface WrapBlockStep1Result<T extends ContentModelBlockGroup & Content
|
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export declare function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], parent: ContentModelBlockGroup | null, blockToWrap: ContentModelBlock, creator: () => T, canMerge: (target: ContentModelBlock) => target is T): void;
|
|
12
|
+
export declare function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], parent: ContentModelBlockGroup | null, blockToWrap: ContentModelBlock, creator: (isRtl: boolean) => T, canMerge: (isRtl: boolean, target: ContentModelBlock) => target is T): void;
|
|
13
13
|
/**
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export declare function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], canMerge: (target: ContentModelBlock, current: T) => target is T): void;
|
|
16
|
+
export declare function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(step1Result: WrapBlockStep1Result<T>[], canMerge: (isRtl: boolean, target: ContentModelBlock, current: T) => target is T): void;
|
|
@@ -12,7 +12,10 @@ function wrapBlockStep1(step1Result, parent, blockToWrap, creator, canMerge) {
|
|
|
12
12
|
if (parent && index >= 0) {
|
|
13
13
|
parent.blocks.splice(index, 1);
|
|
14
14
|
var prevBlock = parent.blocks[index - 1];
|
|
15
|
-
var
|
|
15
|
+
var isRtl = blockToWrap.format.direction == 'rtl';
|
|
16
|
+
var wrapper = canMerge(isRtl, prevBlock)
|
|
17
|
+
? prevBlock
|
|
18
|
+
: createAndAdd(parent, index, creator, isRtl);
|
|
16
19
|
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(blockToWrap);
|
|
17
20
|
(0, roosterjs_content_model_dom_1.addBlock)(wrapper, blockToWrap);
|
|
18
21
|
// Use reverse order, so that we can merge from last to first to avoid modifying unmerged quotes
|
|
@@ -29,7 +32,8 @@ function wrapBlockStep2(step1Result, canMerge) {
|
|
|
29
32
|
var parent = _a.parent, wrapper = _a.wrapper;
|
|
30
33
|
var index = parent.blocks.indexOf(wrapper);
|
|
31
34
|
var nextBlock = parent.blocks[index + 1];
|
|
32
|
-
|
|
35
|
+
var isRtl = wrapper.format.direction == 'rtl';
|
|
36
|
+
if (index >= 0 && canMerge(isRtl, nextBlock, wrapper)) {
|
|
33
37
|
wrapper.blocks.forEach(roosterjs_content_model_dom_1.setParagraphNotImplicit);
|
|
34
38
|
(_b = wrapper.blocks).push.apply(_b, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(nextBlock.blocks), false));
|
|
35
39
|
parent.blocks.splice(index + 1, 1);
|
|
@@ -37,8 +41,8 @@ function wrapBlockStep2(step1Result, canMerge) {
|
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
exports.wrapBlockStep2 = wrapBlockStep2;
|
|
40
|
-
function createAndAdd(parent, index, creator) {
|
|
41
|
-
var block = creator();
|
|
44
|
+
function createAndAdd(parent, index, creator, isRtl) {
|
|
45
|
+
var block = creator(isRtl);
|
|
42
46
|
parent.blocks.splice(index, 0, block);
|
|
43
47
|
return block;
|
|
44
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/wrapBlock.ts"],"names":[],"mappings":";;;;AAAA,2EAAgF;AAWhF;;GAEG;AACH,SAAgB,cAAc,CAC1B,WAAsC,EACtC,MAAqC,EACrC,WAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"wrapBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/wrapBlock.ts"],"names":[],"mappings":";;;;AAAA,2EAAgF;AAWhF;;GAEG;AACH,SAAgB,cAAc,CAC1B,WAAsC,EACtC,MAAqC,EACrC,WAA8B,EAC9B,OAA8B,EAC9B,QAAoE;;IAEpE,IAAM,KAAK,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,mCAAI,CAAC,CAAC,CAAC;IAExD,IAAI,MAAM,IAAI,KAAK,IAAI,CAAC,EAAE;QACtB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE/B,IAAM,SAAS,GAAsB,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC;QACpD,IAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;YACtC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAElD,IAAA,qDAAuB,EAAC,WAAW,CAAC,CAAC;QACrC,IAAA,sCAAQ,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAE/B,gGAAgG;QAChG,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;KAC5C;AACL,CAAC;AAxBD,wCAwBC;AAED;;GAEG;AACH,SAAgB,cAAc,CAC1B,WAAsC,EACtC,QAAgF;IAEhF,WAAW,CAAC,OAAO,CAAC,UAAC,EAAmB;;YAAjB,MAAM,YAAA,EAAE,OAAO,aAAA;QAClC,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC3C,IAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC;QAEhD,IAAI,KAAK,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE;YACnD,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,qDAAuB,CAAC,CAAC;YAChD,CAAA,KAAA,OAAO,CAAC,MAAM,CAAA,CAAC,IAAI,8DAAI,SAAS,CAAC,MAAM,WAAE;YACzC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;SACtC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAfD,wCAeC;AAED,SAAS,YAAY,CACjB,MAA8B,EAC9B,KAAa,EACb,OAA8B,EAC9B,KAAc;IAEd,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import { addBlock, setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { ContentModelBlock, ContentModelBlockGroup } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport interface WrapBlockStep1Result<T extends ContentModelBlockGroup & ContentModelBlock> {\n parent: ContentModelBlockGroup;\n wrapper: T;\n}\n\n/**\n * @internal\n */\nexport function wrapBlockStep1<T extends ContentModelBlockGroup & ContentModelBlock>(\n step1Result: WrapBlockStep1Result<T>[],\n parent: ContentModelBlockGroup | null,\n blockToWrap: ContentModelBlock,\n creator: (isRtl: boolean) => T,\n canMerge: (isRtl: boolean, target: ContentModelBlock) => target is T\n) {\n const index = parent?.blocks.indexOf(blockToWrap) ?? -1;\n\n if (parent && index >= 0) {\n parent.blocks.splice(index, 1);\n\n const prevBlock: ContentModelBlock = parent.blocks[index - 1];\n const isRtl = blockToWrap.format.direction == 'rtl';\n const wrapper = canMerge(isRtl, prevBlock)\n ? prevBlock\n : createAndAdd(parent, index, creator, isRtl);\n\n setParagraphNotImplicit(blockToWrap);\n addBlock(wrapper, blockToWrap);\n\n // Use reverse order, so that we can merge from last to first to avoid modifying unmerged quotes\n step1Result.unshift({ parent, wrapper });\n }\n}\n\n/**\n * @internal\n */\nexport function wrapBlockStep2<T extends ContentModelBlockGroup & ContentModelBlock>(\n step1Result: WrapBlockStep1Result<T>[],\n canMerge: (isRtl: boolean, target: ContentModelBlock, current: T) => target is T\n) {\n step1Result.forEach(({ parent, wrapper }) => {\n const index = parent.blocks.indexOf(wrapper);\n const nextBlock = parent.blocks[index + 1];\n const isRtl = wrapper.format.direction == 'rtl';\n\n if (index >= 0 && canMerge(isRtl, nextBlock, wrapper)) {\n wrapper.blocks.forEach(setParagraphNotImplicit);\n wrapper.blocks.push(...nextBlock.blocks);\n parent.blocks.splice(index + 1, 1);\n }\n });\n}\n\nfunction createAndAdd<T extends ContentModelBlockGroup & ContentModelBlock>(\n parent: ContentModelBlockGroup,\n index: number,\n creator: (isRtl: boolean) => T,\n isRtl: boolean\n): T {\n const block = creator(isRtl);\n\n parent.blocks.splice(index, 0, block);\n return block;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export interface LinkData {
|
|
5
|
+
/**
|
|
6
|
+
* Schema of a hyperlink
|
|
7
|
+
*/
|
|
8
|
+
scheme: string;
|
|
9
|
+
/**
|
|
10
|
+
* Original url of a hyperlink
|
|
11
|
+
*/
|
|
12
|
+
originalUrl: string;
|
|
13
|
+
/**
|
|
14
|
+
* Normalized url of a hyperlink
|
|
15
|
+
*/
|
|
16
|
+
normalizedUrl: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* Try to match a given string with link match rules, return matched link
|
|
21
|
+
* @param url Input url to match
|
|
22
|
+
* @param option Link match option, exact or partial. If it is exact match, we need
|
|
23
|
+
* to check the length of matched link and url
|
|
24
|
+
* @param rules Optional link match rules, if not passed, only the default link match
|
|
25
|
+
* rules will be applied
|
|
26
|
+
* @returns The matched link data, or null if no match found.
|
|
27
|
+
* The link data includes an original url and a normalized url
|
|
28
|
+
*/
|
|
29
|
+
export declare function matchLink(url: string): LinkData | null;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchLink = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
+
// http exclude matching regex
|
|
7
|
+
// invalid URL example (in particular on IE and Edge):
|
|
8
|
+
// - http://www.bing.com%00, %00 before ? (question mark) is considered invalid. IE/Edge throws invalid argument exception
|
|
9
|
+
// - http://www.bing.com%1, %1 is invalid
|
|
10
|
+
// - http://www.bing.com%g, %g is invalid (IE and Edge expects a two hex value after a %)
|
|
11
|
+
// - http://www.bing.com%, % as ending is invalid (IE and Edge expects a two hex value after a %)
|
|
12
|
+
// All above % cases if they're after ? (question mark) is then considered valid again
|
|
13
|
+
// Similar for @, it needs to be after / (forward slash), or ? (question mark). Otherwise IE/Edge will throw security exception
|
|
14
|
+
// - http://www.bing.com@name, @name before ? (question mark) is considered invalid
|
|
15
|
+
// - http://www.bing.com/@name, is valid sine it is after / (forward slash)
|
|
16
|
+
// - http://www.bing.com?@name, is also valid since it is after ? (question mark)
|
|
17
|
+
// The regex below is essentially a break down of:
|
|
18
|
+
// ^[^?]+%[^0-9a-f]+ => to exclude URL like www.bing.com%%
|
|
19
|
+
// ^[^?]+%[0-9a-f][^0-9a-f]+ => to exclude URL like www.bing.com%1
|
|
20
|
+
// ^[^?]+%00 => to exclude URL like www.bing.com%00
|
|
21
|
+
// ^[^?]+%$ => to exclude URL like www.bing.com%
|
|
22
|
+
// ^https?:\/\/[^?\/]+@ => to exclude URL like http://www.bing.com@name
|
|
23
|
+
// ^www\.[^?\/]+@ => to exclude URL like www.bing.com@name
|
|
24
|
+
// , => to exclude url like www.bing,,com
|
|
25
|
+
var httpExcludeRegEx = /^[^?]+%[^0-9a-f]+|^[^?]+%[0-9a-f][^0-9a-f]+|^[^?]+%00|^[^?]+%$|^https?:\/\/[^?\/]+@|^www\.[^?\/]+@/i;
|
|
26
|
+
// via https://tools.ietf.org/html/rfc1035 Page 7
|
|
27
|
+
var labelRegEx = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'; // We're using case insensitive regexps below so don't bother including A-Z
|
|
28
|
+
var domainNameRegEx = "(?:" + labelRegEx + "\\.)*" + labelRegEx;
|
|
29
|
+
var domainPortRegEx = domainNameRegEx + "(?:\\:[0-9]+)?";
|
|
30
|
+
var domainPortWithUrlRegEx = domainPortRegEx + "(?:[\\/\\?]\\S*)?";
|
|
31
|
+
var linkMatchRules = {
|
|
32
|
+
http: {
|
|
33
|
+
match: new RegExp("^(?:microsoft-edge:)?http:\\/\\/" + domainPortWithUrlRegEx + "|www\\." + domainPortWithUrlRegEx, 'i'),
|
|
34
|
+
except: httpExcludeRegEx,
|
|
35
|
+
normalizeUrl: function (url) {
|
|
36
|
+
return new RegExp('^(?:microsoft-edge:)?http:\\/\\/', 'i').test(url) ? url : 'http://' + url;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
https: {
|
|
40
|
+
match: new RegExp("^(?:microsoft-edge:)?https:\\/\\/" + domainPortWithUrlRegEx, 'i'),
|
|
41
|
+
except: httpExcludeRegEx,
|
|
42
|
+
},
|
|
43
|
+
mailto: { match: new RegExp('^mailto:\\S+@\\S+\\.\\S+', 'i') },
|
|
44
|
+
notes: { match: new RegExp('^notes:\\/\\/\\S+', 'i') },
|
|
45
|
+
file: { match: new RegExp('^file:\\/\\/\\/?\\S+', 'i') },
|
|
46
|
+
unc: { match: new RegExp('^\\\\\\\\\\S+', 'i') },
|
|
47
|
+
ftp: {
|
|
48
|
+
match: new RegExp("^ftp:\\/\\/" + domainPortWithUrlRegEx + "|ftp\\." + domainPortWithUrlRegEx, 'i'),
|
|
49
|
+
normalizeUrl: function (url) { return (new RegExp('^ftp:\\/\\/', 'i').test(url) ? url : 'ftp://' + url); },
|
|
50
|
+
},
|
|
51
|
+
news: { match: new RegExp("^news:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
52
|
+
telnet: { match: new RegExp("^telnet:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
53
|
+
gopher: { match: new RegExp("^gopher:\\/\\/" + domainPortWithUrlRegEx, 'i') },
|
|
54
|
+
wais: { match: new RegExp("^wais:(\\/\\/)?" + domainPortWithUrlRegEx, 'i') },
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
* Try to match a given string with link match rules, return matched link
|
|
59
|
+
* @param url Input url to match
|
|
60
|
+
* @param option Link match option, exact or partial. If it is exact match, we need
|
|
61
|
+
* to check the length of matched link and url
|
|
62
|
+
* @param rules Optional link match rules, if not passed, only the default link match
|
|
63
|
+
* rules will be applied
|
|
64
|
+
* @returns The matched link data, or null if no match found.
|
|
65
|
+
* The link data includes an original url and a normalized url
|
|
66
|
+
*/
|
|
67
|
+
function matchLink(url) {
|
|
68
|
+
var e_1, _a;
|
|
69
|
+
if (url) {
|
|
70
|
+
try {
|
|
71
|
+
for (var _b = (0, tslib_1.__values)((0, roosterjs_content_model_dom_1.getObjectKeys)(linkMatchRules)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
72
|
+
var schema = _c.value;
|
|
73
|
+
var rule = linkMatchRules[schema];
|
|
74
|
+
var matches = url.match(rule.match);
|
|
75
|
+
if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {
|
|
76
|
+
return {
|
|
77
|
+
scheme: schema,
|
|
78
|
+
originalUrl: url,
|
|
79
|
+
normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
85
|
+
finally {
|
|
86
|
+
try {
|
|
87
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
88
|
+
}
|
|
89
|
+
finally { if (e_1) throw e_1.error; }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
exports.matchLink = matchLink;
|
|
95
|
+
//# sourceMappingURL=matchLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchLink.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts"],"names":[],"mappings":";;;;AAAA,2EAA4D;AA4B5D,8BAA8B;AAC9B,sDAAsD;AACtD,0HAA0H;AAC1H,yCAAyC;AACzC,yFAAyF;AACzF,iGAAiG;AACjG,sFAAsF;AACtF,+HAA+H;AAC/H,mFAAmF;AACnF,2EAA2E;AAC3E,iFAAiF;AACjF,kDAAkD;AAClD,0DAA0D;AAC1D,kEAAkE;AAClE,mDAAmD;AACnD,gDAAgD;AAChD,uEAAuE;AACvE,0DAA0D;AAC1D,yCAAyC;AACzC,IAAM,gBAAgB,GAAG,qGAAqG,CAAC;AAE/H,iDAAiD;AACjD,IAAM,UAAU,GAAG,iCAAiC,CAAC,CAAC,2EAA2E;AACjI,IAAM,eAAe,GAAG,QAAM,UAAU,aAAQ,UAAY,CAAC;AAC7D,IAAM,eAAe,GAAM,eAAe,mBAAgB,CAAC;AAC3D,IAAM,sBAAsB,GAAM,eAAe,sBAAmB,CAAC;AAErE,IAAM,cAAc,GAAkC;IAClD,IAAI,EAAE;QACF,KAAK,EAA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GAAG,CAAC,EAAE;IAChF,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,mBAAiB,sBAAwB,EAAE,GAAG,CAAC,EAAE;IAC7E,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,oBAAkB,sBAAwB,EAAE,GAAG,CAAC,EAAE;CAC/E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,SAAgB,SAAS,CAAC,GAAW;;IACjC,IAAI,GAAG,EAAE;;YACL,KAAqB,IAAA,KAAA,sBAAA,IAAA,2CAAa,EAAC,cAAc,CAAC,CAAA,gBAAA,4BAAE;gBAA/C,IAAM,MAAM,WAAA;gBACb,IAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;gBACpC,IAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtC,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC1E,OAAO;wBACH,MAAM,EAAE,MAAM;wBACd,WAAW,EAAE,GAAG;wBAChB,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;qBAClE,CAAC;iBACL;aACJ;;;;;;;;;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAhBD,8BAgBC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\n\n/**\n * @internal\n */\nexport interface LinkData {\n /**\n * Schema of a hyperlink\n */\n scheme: string;\n\n /**\n * Original url of a hyperlink\n */\n originalUrl: string;\n\n /**\n * Normalized url of a hyperlink\n */\n normalizedUrl: string;\n}\n\ninterface LinkMatchRule {\n match: RegExp;\n except?: RegExp;\n normalizeUrl?: (url: string) => string;\n}\n\n// http exclude matching regex\n// invalid URL example (in particular on IE and Edge):\n// - http://www.bing.com%00, %00 before ? (question mark) is considered invalid. IE/Edge throws invalid argument exception\n// - http://www.bing.com%1, %1 is invalid\n// - http://www.bing.com%g, %g is invalid (IE and Edge expects a two hex value after a %)\n// - http://www.bing.com%, % as ending is invalid (IE and Edge expects a two hex value after a %)\n// All above % cases if they're after ? (question mark) is then considered valid again\n// Similar for @, it needs to be after / (forward slash), or ? (question mark). Otherwise IE/Edge will throw security exception\n// - http://www.bing.com@name, @name before ? (question mark) is considered invalid\n// - http://www.bing.com/@name, is valid sine it is after / (forward slash)\n// - http://www.bing.com?@name, is also valid since it is after ? (question mark)\n// The regex below is essentially a break down of:\n// ^[^?]+%[^0-9a-f]+ => to exclude URL like www.bing.com%%\n// ^[^?]+%[0-9a-f][^0-9a-f]+ => to exclude URL like www.bing.com%1\n// ^[^?]+%00 => to exclude URL like www.bing.com%00\n// ^[^?]+%$ => to exclude URL like www.bing.com%\n// ^https?:\\/\\/[^?\\/]+@ => to exclude URL like http://www.bing.com@name\n// ^www\\.[^?\\/]+@ => to exclude URL like www.bing.com@name\n// , => to exclude url like www.bing,,com\nconst httpExcludeRegEx = /^[^?]+%[^0-9a-f]+|^[^?]+%[0-9a-f][^0-9a-f]+|^[^?]+%00|^[^?]+%$|^https?:\\/\\/[^?\\/]+@|^www\\.[^?\\/]+@/i;\n\n// via https://tools.ietf.org/html/rfc1035 Page 7\nconst labelRegEx = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'; // We're using case insensitive regexps below so don't bother including A-Z\nconst domainNameRegEx = `(?:${labelRegEx}\\\\.)*${labelRegEx}`;\nconst domainPortRegEx = `${domainNameRegEx}(?:\\\\:[0-9]+)?`;\nconst domainPortWithUrlRegEx = `${domainPortRegEx}(?:[\\\\/\\\\?]\\\\S*)?`;\n\nconst linkMatchRules: Record<string, LinkMatchRule> = {\n http: {\n match: new RegExp(\n `^(?:microsoft-edge:)?http:\\\\/\\\\/${domainPortWithUrlRegEx}|www\\\\.${domainPortWithUrlRegEx}`,\n 'i'\n ),\n except: httpExcludeRegEx,\n normalizeUrl: url =>\n new RegExp('^(?:microsoft-edge:)?http:\\\\/\\\\/', 'i').test(url) ? url : 'http://' + url,\n },\n https: {\n match: new RegExp(`^(?:microsoft-edge:)?https:\\\\/\\\\/${domainPortWithUrlRegEx}`, 'i'),\n except: httpExcludeRegEx,\n },\n mailto: { match: new RegExp('^mailto:\\\\S+@\\\\S+\\\\.\\\\S+', 'i') },\n notes: { match: new RegExp('^notes:\\\\/\\\\/\\\\S+', 'i') },\n file: { match: new RegExp('^file:\\\\/\\\\/\\\\/?\\\\S+', 'i') },\n unc: { match: new RegExp('^\\\\\\\\\\\\\\\\\\\\S+', 'i') },\n ftp: {\n match: new RegExp(\n `^ftp:\\\\/\\\\/${domainPortWithUrlRegEx}|ftp\\\\.${domainPortWithUrlRegEx}`,\n 'i'\n ),\n normalizeUrl: url => (new RegExp('^ftp:\\\\/\\\\/', 'i').test(url) ? url : 'ftp://' + url),\n },\n news: { match: new RegExp(`^news:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n telnet: { match: new RegExp(`^telnet:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n gopher: { match: new RegExp(`^gopher:\\\\/\\\\/${domainPortWithUrlRegEx}`, 'i') },\n wais: { match: new RegExp(`^wais:(\\\\/\\\\/)?${domainPortWithUrlRegEx}`, 'i') },\n};\n\n/**\n * @internal\n * Try to match a given string with link match rules, return matched link\n * @param url Input url to match\n * @param option Link match option, exact or partial. If it is exact match, we need\n * to check the length of matched link and url\n * @param rules Optional link match rules, if not passed, only the default link match\n * rules will be applied\n * @returns The matched link data, or null if no match found.\n * The link data includes an original url and a normalized url\n */\nexport function matchLink(url: string): LinkData | null {\n if (url) {\n for (const schema of getObjectKeys(linkMatchRules)) {\n const rule = linkMatchRules[schema];\n const matches = url.match(rule.match);\n if (matches && matches[0] == url && (!rule.except || !rule.except.test(url))) {\n return {\n scheme: schema,\n originalUrl: url,\n normalizedUrl: rule.normalizeUrl ? rule.normalizeUrl(url) : url,\n };\n }\n }\n }\n\n return null;\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ContentModelDocument } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Set a list type to content model
|
|
4
|
+
* @param model the model document
|
|
5
|
+
* @param listType the list type OL | UL
|
|
4
6
|
*/
|
|
5
7
|
export declare function setListType(model: ContentModelDocument, listType: 'OL' | 'UL'): boolean;
|
|
@@ -4,7 +4,9 @@ exports.setListType = void 0;
|
|
|
4
4
|
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
5
|
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Set a list type to content model
|
|
8
|
+
* @param model the model document
|
|
9
|
+
* @param listType the list type OL | UL
|
|
8
10
|
*/
|
|
9
11
|
function setListType(model, listType) {
|
|
10
12
|
var paragraphOrListItems = (0, roosterjs_content_model_core_1.getOperationalBlocks)(model, ['ListItem'], [] // Set stop types to be empty so we can find list items even cross the boundary of table, then we can always operation on the list item if any
|
|
@@ -17,7 +19,6 @@ function setListType(model, listType) {
|
|
|
17
19
|
: shouldIgnoreBlock(block);
|
|
18
20
|
});
|
|
19
21
|
var existingListItems = [];
|
|
20
|
-
var hasIgnoredParagraphBefore = false;
|
|
21
22
|
paragraphOrListItems.forEach(function (_a, itemIndex) {
|
|
22
23
|
var _b, _c;
|
|
23
24
|
var block = _a.block, parent = _a.parent;
|
|
@@ -61,9 +62,8 @@ function setListType(model, listType) {
|
|
|
61
62
|
: 1,
|
|
62
63
|
direction: block.format.direction,
|
|
63
64
|
textAlign: block.format.textAlign,
|
|
64
|
-
marginTop:
|
|
65
|
-
|
|
66
|
-
marginBlockStart: '0px',
|
|
65
|
+
marginTop: '0px',
|
|
66
|
+
marginBottom: '0px',
|
|
67
67
|
}),
|
|
68
68
|
],
|
|
69
69
|
// For list bullet, we only want to carry over these formats from segments:
|
|
@@ -72,8 +72,6 @@ function setListType(model, listType) {
|
|
|
72
72
|
fontSize: segmentFormat.fontSize,
|
|
73
73
|
textColor: segmentFormat.textColor,
|
|
74
74
|
});
|
|
75
|
-
// Since there is only one paragraph under the list item, no need to keep its paragraph element (DIV).
|
|
76
|
-
// TODO: Do we need to keep the CSS styles applied to original DIV?
|
|
77
75
|
if (block.blockType == 'Paragraph') {
|
|
78
76
|
block.isImplicit = true;
|
|
79
77
|
}
|
|
@@ -93,8 +91,7 @@ function setListType(model, listType) {
|
|
|
93
91
|
existingListItems.push(newListItem);
|
|
94
92
|
}
|
|
95
93
|
else {
|
|
96
|
-
|
|
97
|
-
existingListItems.forEach(function (x) { return (x.levels[0].format.marginBottom = '0'); });
|
|
94
|
+
existingListItems.forEach(function (x) { return (x.levels[0].format.marginBottom = '0px'); });
|
|
98
95
|
existingListItems = [];
|
|
99
96
|
}
|
|
100
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;AAAA,6EAAwF;AACxF,2EAKqC;AAOrC
|
|
1
|
+
{"version":3,"file":"setListType.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/list/setListType.ts"],"names":[],"mappings":";;;AAAA,6EAAwF;AACxF,2EAKqC;AAOrC;;;;GAIG;AACH,SAAgB,WAAW,CAAC,KAA2B,EAAE,QAAqB;IAC1E,IAAM,oBAAoB,GAAG,IAAA,mDAAoB,EAC7C,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,EAAE,CAAC,8IAA8I;KACpJ,CAAC;IACF,IAAM,qBAAqB,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAC,EAAS;;YAAP,KAAK,W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AAC;AAxGD,kCAwGC;AAED,SAAS,iBAAiB,CAAC,KAAwB;IAC/C,QAAQ,KAAK,CAAC,SAAS,EAAE;QACrB,KAAK,OAAO;YACR,OAAO,KAAK,CAAC;QACjB,KAAK,WAAW;YACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CACvB,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAA3D,CAA2D,CACnE,CAAC;QACN;YACI,OAAO,IAAI,CAAC;KACnB;AACL,CAAC","sourcesContent":["import { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';\nimport {\n createListItem,\n createListLevel,\n normalizeContentModel,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelDocument,\n ContentModelListItem,\n} from 'roosterjs-content-model-types';\n\n/**\n * Set a list type to content model\n * @param model the model document\n * @param listType the list type OL | UL\n */\nexport function setListType(model: ContentModelDocument, listType: 'OL' | 'UL') {\n const paragraphOrListItems = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n [] // Set stop types to be empty so we can find list items even cross the boundary of table, then we can always operation on the list item if any\n );\n const alreadyInExpectedType = paragraphOrListItems.every(({ block }) =>\n isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')\n ? block.levels[block.levels.length - 1]?.listType == listType\n : shouldIgnoreBlock(block)\n );\n let existingListItems: ContentModelListItem[] = [];\n\n paragraphOrListItems.forEach(({ block, parent }, itemIndex) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const level = block.levels.pop();\n\n if (!alreadyInExpectedType && level) {\n level.listType = listType;\n block.levels.push(level);\n } else if (block.blocks.length == 1) {\n setParagraphNotImplicit(block.blocks[0]);\n }\n\n if (alreadyInExpectedType) {\n //if the list item has margins or textAlign, we need to apply them to the block to preserve the indention and alignment\n block.blocks.forEach(x => {\n if (block.format.marginLeft) {\n x.format.marginLeft = block.format.marginLeft;\n }\n\n if (block.format.marginRight) {\n x.format.marginRight = block.format.marginRight;\n }\n\n if (block.format.textAlign) {\n x.format.textAlign = block.format.textAlign;\n }\n });\n }\n } else {\n const index = parent.blocks.indexOf(block);\n\n if (index >= 0) {\n if (paragraphOrListItems.length == 1 || !shouldIgnoreBlock(block)) {\n const prevBlock = parent.blocks[index - 1];\n const segmentFormat =\n (block.blockType == 'Paragraph' && block.segments[0]?.format) || {};\n const newListItem = createListItem(\n [\n createListLevel(listType, {\n startNumberOverride:\n itemIndex > 0 ||\n (prevBlock?.blockType == 'BlockGroup' &&\n prevBlock.blockGroupType == 'ListItem' &&\n prevBlock.levels[0]?.listType == 'OL')\n ? undefined\n : 1,\n direction: block.format.direction,\n textAlign: block.format.textAlign,\n marginTop: '0px',\n marginBottom: '0px',\n }),\n ],\n // For list bullet, we only want to carry over these formats from segments:\n {\n fontFamily: segmentFormat.fontFamily,\n fontSize: segmentFormat.fontSize,\n textColor: segmentFormat.textColor,\n }\n );\n\n if (block.blockType == 'Paragraph') {\n block.isImplicit = true;\n }\n\n newListItem.blocks.push(block);\n\n if (block.format.marginRight) {\n newListItem.format.marginRight = block.format.marginRight;\n block.format.marginRight = undefined;\n }\n if (block.format.marginLeft) {\n newListItem.format.marginLeft = block.format.marginLeft;\n block.format.marginLeft = undefined;\n }\n\n if (block.format.textAlign) {\n newListItem.format.textAlign = block.format.textAlign;\n }\n\n parent.blocks.splice(index, 1, newListItem);\n existingListItems.push(newListItem);\n } else {\n existingListItems.forEach(x => (x.levels[0].format.marginBottom = '0px'));\n existingListItems = [];\n }\n }\n }\n });\n\n normalizeContentModel(model);\n\n return paragraphOrListItems.length > 0;\n}\n\nfunction shouldIgnoreBlock(block: ContentModelBlock) {\n switch (block.blockType) {\n case 'Table':\n return false;\n case 'Paragraph':\n return block.segments.every(\n x => x.segmentType == 'Br' || x.segmentType == 'SelectionMarker'\n );\n default:\n return true;\n }\n}\n"]}
|
|
@@ -6,4 +6,4 @@ import type { ContentModelFormatContainerFormat, IStandaloneEditor } from 'roost
|
|
|
6
6
|
* @param editor The editor object to toggle BLOCKQUOTE onto
|
|
7
7
|
* @param quoteFormat @optional Block format for the new quote object
|
|
8
8
|
*/
|
|
9
|
-
export default function toggleBlockQuote(editor: IStandaloneEditor, quoteFormat?: ContentModelFormatContainerFormat): void;
|
|
9
|
+
export default function toggleBlockQuote(editor: IStandaloneEditor, quoteFormat?: ContentModelFormatContainerFormat, quoteFormatRtl?: ContentModelFormatContainerFormat): void;
|