roosterjs-content-model-api 9.57.0 → 9.59.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.
Files changed (32) hide show
  1. package/README.md +8 -0
  2. package/lib/index.d.ts +1 -0
  3. package/lib/index.js +3 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/modelApi/block/setModelDirection.d.ts +5 -0
  6. package/lib/modelApi/block/setModelDirection.js +21 -24
  7. package/lib/modelApi/block/setModelDirection.js.map +1 -1
  8. package/lib/modelApi/table/insertTableColumn.js +2 -1
  9. package/lib/modelApi/table/insertTableColumn.js.map +1 -1
  10. package/lib/modelApi/table/insertTableRow.js +2 -1
  11. package/lib/modelApi/table/insertTableRow.js.map +1 -1
  12. package/lib-amd/index.d.ts +1 -0
  13. package/lib-amd/index.js +3 -2
  14. package/lib-amd/index.js.map +1 -1
  15. package/lib-amd/modelApi/block/setModelDirection.d.ts +5 -0
  16. package/lib-amd/modelApi/block/setModelDirection.js +21 -24
  17. package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
  18. package/lib-amd/modelApi/table/insertTableColumn.js +2 -1
  19. package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
  20. package/lib-amd/modelApi/table/insertTableRow.js +2 -1
  21. package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
  22. package/lib-mjs/index.d.ts +1 -0
  23. package/lib-mjs/index.js +1 -0
  24. package/lib-mjs/index.js.map +1 -1
  25. package/lib-mjs/modelApi/block/setModelDirection.d.ts +5 -0
  26. package/lib-mjs/modelApi/block/setModelDirection.js +19 -23
  27. package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
  28. package/lib-mjs/modelApi/table/insertTableColumn.js +2 -1
  29. package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
  30. package/lib-mjs/modelApi/table/insertTableRow.js +2 -1
  31. package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
  32. package/package.json +3 -3
package/README.md CHANGED
@@ -228,6 +228,14 @@ There are two ways that tests can be run:
228
228
  ```
229
229
  yarn test
230
230
  ```
231
+ 3. Run all tests from command line in Safari on macOS
232
+
233
+ ```
234
+ safaridriver --enable
235
+ yarn test:safari
236
+ ```
237
+
238
+ Safari's **Allow Remote Automation** setting must be enabled before running the command.
231
239
 
232
240
  ## Dependencies
233
241
 
package/lib/index.d.ts CHANGED
@@ -56,6 +56,7 @@ export { setModelListStyle } from './modelApi/list/setModelListStyle';
56
56
  export { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';
57
57
  export { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';
58
58
  export { setModelIndentation } from './modelApi/block/setModelIndentation';
59
+ export { getTextDirection } from './modelApi/block/setModelDirection';
59
60
  export { matchLink } from './modelApi/link/matchLink';
60
61
  export { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';
61
62
  export { getListAnnounceData } from './modelApi/list/getListAnnounceData';
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.createEditorContextForEntity = 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.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = void 0;
4
+ exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.getTextDirection = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = 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");
@@ -118,6 +118,8 @@ var findListItemsInSameThread_1 = require("./modelApi/list/findListItemsInSameTh
118
118
  Object.defineProperty(exports, "findListItemsInSameThread", { enumerable: true, get: function () { return findListItemsInSameThread_1.findListItemsInSameThread; } });
119
119
  var setModelIndentation_1 = require("./modelApi/block/setModelIndentation");
120
120
  Object.defineProperty(exports, "setModelIndentation", { enumerable: true, get: function () { return setModelIndentation_1.setModelIndentation; } });
121
+ var setModelDirection_1 = require("./modelApi/block/setModelDirection");
122
+ Object.defineProperty(exports, "getTextDirection", { enumerable: true, get: function () { return setModelDirection_1.getTextDirection; } });
121
123
  var matchLink_1 = require("./modelApi/link/matchLink");
122
124
  Object.defineProperty(exports, "matchLink", { enumerable: true, get: function () { return matchLink_1.matchLink; } });
123
125
  var promoteLink_1 = require("./modelApi/link/promoteLink");
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"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B,OAAA;AAClC,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAC5B,uDAAsD;AAA7C,sGAAA,SAAS,OAAA;AAClB,2DAA0E;AAAjE,0GAAA,WAAW,OAAA;AAAE,6GAAA,cAAc,OAAA;AACpC,2EAA0E;AAAjE,0HAAA,mBAAmB,OAAA;AAC5B,qFAAoF;AAA3E,kIAAA,uBAAuB,OAAA;AAChC,gFAA+E;AAAtE,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 { createEditorContextForEntity } from './publicApi/utils/createEditorContextForEntity';\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 { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\nexport { queryContentModelBlocks } from './modelApi/common/queryContentModelBlocks';\nexport { adjustWordSelection } from './modelApi/selection/adjustWordSelection';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":";;;;AAAA,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,yEAAwE;AAA/D,sHAAA,iBAAiB,OAAA;AAC1B,yDAAwD;AAA/C,sGAAA,SAAS,OAAA;AAClB,mFAAkF;AAAzE,gIAAA,sBAAsB,OAAA;AAC/B,8DAA6D;AAApD,4GAAA,YAAY,OAAA;AACrB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AACxB,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AACrB,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,+EAA8E;AAArE,0HAAA,mBAAmB,OAAA;AAC5B,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,2EAA0E;AAAjE,sHAAA,iBAAiB,OAAA;AAC1B,6EAA4E;AAAnE,wHAAA,kBAAkB,OAAA;AAC3B,+DAA8D;AAArD,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,0GAAA,WAAW,OAAA;AACpB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AACrB,qEAAoE;AAA3D,gHAAA,cAAc,OAAA;AACvB,6EAA4E;AAAnE,wHAAA,kBAAkB,OAAA;AAC3B,iFAAgF;AAAvE,4HAAA,oBAAoB,OAAA;AAC7B,yEAAwE;AAA/D,oHAAA,gBAAgB,OAAA;AACzB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,8DAA6D;AAApD,4GAAA,YAAY,OAAA;AACrB,0EAAyE;AAAhE,wHA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iC,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,wEAAsE;AAA7D,qHAAA,gBAAgB,OAAA;AACzB,uDAAsD;AAA7C,sGAAA,SAAS,OAAA;AAClB,2DAA0E;AAAjE,0GAAA,WAAW,OAAA;AAAE,6GAAA,cAAc,OAAA;AACpC,2EAA0E;AAAjE,0HAAA,mBAAmB,OAAA;AAC5B,qFAAoF;AAA3E,kIAAA,uBAAuB,OAAA;AAChC,gFAA+E;AAAtE,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 { createEditorContextForEntity } from './publicApi/utils/createEditorContextForEntity';\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 { getTextDirection } from './modelApi/block/setModelDirection';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\nexport { queryContentModelBlocks } from './modelApi/common/queryContentModelBlocks';\nexport { adjustWordSelection } from './modelApi/selection/adjustWordSelection';\n"]}
@@ -3,3 +3,8 @@ import type { ReadonlyContentModelDocument } from 'roosterjs-content-model-types
3
3
  * @internal
4
4
  */
5
5
  export declare function setModelDirection(model: ReadonlyContentModelDocument, direction: 'ltr' | 'rtl' | 'auto'): boolean;
6
+ /**
7
+ * Determine text direction from the first strong directional character
8
+ * @param text Text to scan
9
+ */
10
+ export declare function getTextDirection(text: string): 'ltr' | 'rtl' | undefined;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setModelDirection = void 0;
3
+ exports.getTextDirection = exports.setModelDirection = void 0;
4
4
  var findListItemsInSameThread_1 = require("../list/findListItemsInSameThread");
5
5
  var splitSelectedParagraphByBr_1 = require("./splitSelectedParagraphByBr");
6
6
  var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
- // Regexes for character direction detection
8
- // Strongly typed RTL character ranges. Referenced unicode's DerivedBidiClass.txt, excluding things in the 2 bit range.
9
- var RTL_CHAR_REGEX = /[\u0590-\u05FF\u0600-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/g;
10
- var URL_CHAR_REGEX = /http\S+|www\S+|https\S+|<a\s+(?:[^>]*?\s+)?href=(["']).*?\1.*?>.*?<\/a>/g;
11
- var WHITESPACE_REGEX = /\s/g;
7
+ var FIRST_STRONG_CHAR_REGEX = new RegExp('[\\p{L}\\u200E\\u200F]', 'u');
8
+ var RTL_CHAR_REGEX = new RegExp('[\\u0590-\\u08FF\\u200F\\uFB1D-\\uFDFF\\uFE70-\\uFEFF\\u{10840}-\\u{10FFF}\\u{1E800}-\\u{1E95F}]', 'u');
12
9
  /**
13
10
  * @internal
14
11
  */
@@ -86,29 +83,29 @@ function setProperty(format, key, value) {
86
83
  delete format[key];
87
84
  }
88
85
  }
86
+ /**
87
+ * Determine text direction from the first strong directional character
88
+ * @param text Text to scan
89
+ */
90
+ function getTextDirection(text) {
91
+ var _a;
92
+ var firstStrongChar = (_a = text.match(FIRST_STRONG_CHAR_REGEX)) === null || _a === void 0 ? void 0 : _a[0];
93
+ return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;
94
+ }
95
+ exports.getTextDirection = getTextDirection;
89
96
  // Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character
90
97
  function determineTextDirection(block) {
98
+ return getTextDirection(getTextContent(block)) || 'ltr';
99
+ }
100
+ function getTextContent(block) {
91
101
  if (block.blockType === 'Paragraph') {
92
- var findTextSegements = block.segments.filter(function (seg) { return seg.segmentType === 'Text'; });
93
- var innerText = findTextSegements.length > 0
94
- ? findTextSegements.reduce(function (prev, seg) { return prev + seg.text; }, '')
95
- : undefined;
96
- if (!!innerText) {
97
- // Remove links
98
- innerText = innerText.replace(URL_CHAR_REGEX, '');
99
- // Remove whitespace
100
- innerText = innerText.replace(WHITESPACE_REGEX, '');
101
- var rtlMatches = innerText.match(RTL_CHAR_REGEX);
102
- var rtlCount = rtlMatches ? rtlMatches.length : 0;
103
- var ltrCount = innerText.length - rtlCount;
104
- return rtlCount > ltrCount ? 'rtl' : 'ltr';
105
- }
106
- else {
107
- return 'ltr'; // Default to LTR if no text is found
108
- }
102
+ return block.segments.reduce(function (text, segment) { return text + (segment.segmentType === 'Text' ? segment.text : ''); }, '');
103
+ }
104
+ else if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(block, 'ListItem')) {
105
+ return block.blocks.reduce(function (text, childBlock) { return text + getTextContent(childBlock); }, '');
109
106
  }
110
107
  else {
111
- return 'ltr';
108
+ return '';
112
109
  }
113
110
  }
114
111
  //# sourceMappingURL=setModelDirection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;AAAA,+EAA8E;AAC9E,2EAA0E;AAC1E,2EAMqC;AAWrC,4CAA4C;AAC5C,uHAAuH;AACvH,IAAM,cAAc,GAAG,yDAAyD,CAAC;AACjF,IAAM,cAAc,GAAG,0EAA0E,CAAC;AAClG,IAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,SAAiC;IAEjC,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;IAElC,IAAM,0BAA0B,GAAG,IAAA,kDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;IAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;YAAP,KAAK,WAAA;QACvC,IAAI,aAA4B,CAAC;QACjC,IAAI,SAAS,KAAK,MAAM,EAAE;YACtB,aAAa,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;SACjD;aAAM;YACH,aAAa,GAAG,SAAS,CAAC;SAC7B;QACD,IAAI,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;YAC7D,IAAM,KAAK,GAAG,IAAA,qDAAyB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEtD,KAAK,CAAC,OAAO,CAAC,UAAA,YAAY;gBACtB,IAAM,IAAI,GAAG,IAAA,yCAAW,EAAC,YAAY,CAAC,CAAC;gBAEvC,IAAI,CAAC,MAAM,CAAC,OA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AAG,IAAsC,OAAA,GAAG,CAAC,WAAW,KAAK,MAAM,EAA1B,CAA0B,CACvE,CAAC;QACF,IAAI,SAAS,GACT,iBAAiB,CAAC,MAAM,GAAG,CAAC;YACxB,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,GAAG,IAAK,OAAA,IAAI,GAAG,GAAG,CAAC,IAAI,EAAf,CAAe,EAAE,EAAE,CAAC;YAC9D,CAAC,CAAC,SAAS,CAAC;QACpB,IAAI,CAAC,CAAC,SAAS,EAAE;YACb,eAAe;YACf,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;YAElD,oBAAoB;YACpB,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YAEpD,IAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YACnD,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAEpD,IAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,GAAG,QAAQ,CAAC;YAE7C,OAAO,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;SAC9C;aAAM;YACH,OAAO,KAAK,CAAC,CAAC,qCAAqC;SACtD;KACJ;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelText,\n} from 'roosterjs-content-model-types';\n\n// Regexes for character direction detection\n// Strongly typed RTL character ranges. Referenced unicode's DerivedBidiClass.txt, excluding things in the 2 bit range.\nconst RTL_CHAR_REGEX = /[\\u0590-\\u05FF\\u0600-\\u08FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFF]/g;\nconst URL_CHAR_REGEX = /http\\S+|www\\S+|https\\S+|<a\\s+(?:[^>]*?\\s+)?href=([\"']).*?\\1.*?>.*?<\\/a>/g;\nconst WHITESPACE_REGEX = /\\s/g;\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\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(mutateBlock(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\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n if (block.blockType === 'Paragraph') {\n const findTextSegements: ReadonlyContentModelText[] = block.segments.filter(\n (seg): seg is ReadonlyContentModelText => seg.segmentType === 'Text'\n );\n let innerText =\n findTextSegements.length > 0\n ? findTextSegements.reduce((prev, seg) => prev + seg.text, '')\n : undefined;\n if (!!innerText) {\n // Remove links\n innerText = innerText.replace(URL_CHAR_REGEX, '');\n\n // Remove whitespace\n innerText = innerText.replace(WHITESPACE_REGEX, '');\n\n const rtlMatches = innerText.match(RTL_CHAR_REGEX);\n const rtlCount = rtlMatches ? rtlMatches.length : 0;\n\n const ltrCount = innerText.length - rtlCount;\n\n return rtlCount > ltrCount ? 'rtl' : 'ltr';\n } else {\n return 'ltr'; // Default to LTR if no text is found\n }\n } else {\n return 'ltr';\n }\n}\n"]}
1
+ {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api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I,KAAK,CAAC;AAC5D,CAAC;AAED,SAAS,cAAc,CAAC,KAAgC;IACpD,IAAI,KAAK,CAAC,SAAS,KAAK,WAAW,EAAE;QACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CACxB,UAAC,IAAI,EAAE,OAAO,IAAK,OAAA,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAA3D,CAA2D,EAC9E,EAAE,CACL,CAAC;KACL;SAAM,IAAI,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;QACpE,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,UAAU,IAAK,OAAA,IAAI,GAAG,cAAc,CAAC,UAAU,CAAC,EAAjC,CAAiC,EAAE,EAAE,CAAC,CAAC;KAC3F;SAAM;QACH,OAAO,EAAE,CAAC;KACb;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst FIRST_STRONG_CHAR_REGEX = new RegExp('[\\\\p{L}\\\\u200E\\\\u200F]', 'u');\nconst RTL_CHAR_REGEX = new RegExp(\n '[\\\\u0590-\\\\u08FF\\\\u200F\\\\uFB1D-\\\\uFDFF\\\\uFE70-\\\\uFEFF\\\\u{10840}-\\\\u{10FFF}\\\\u{1E800}-\\\\u{1E95F}]',\n 'u'\n);\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\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(mutateBlock(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\n/**\n * Determine text direction from the first strong directional character\n * @param text Text to scan\n */\nexport function getTextDirection(text: string): 'ltr' | 'rtl' | undefined {\n const firstStrongChar = text.match(FIRST_STRONG_CHAR_REGEX)?.[0];\n\n return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;\n}\n\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n return getTextDirection(getTextContent(block)) || 'ltr';\n}\n\nfunction getTextContent(block: ReadonlyContentModelBlock): string {\n if (block.blockType === 'Paragraph') {\n return block.segments.reduce(\n (text, segment) => text + (segment.segmentType === 'Text' ? segment.text : ''),\n ''\n );\n } else if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n return block.blocks.reduce((text, childBlock) => text + getTextContent(childBlock), '');\n } else {\n return '';\n }\n}\n"]}
@@ -17,7 +17,8 @@ function insertTableColumn(table, operation) {
17
17
  for (var i = sel === null || sel === void 0 ? void 0 : sel.firstColumn; i <= sel.lastColumn; i++) {
18
18
  table.rows.forEach(function (row) {
19
19
  var cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];
20
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
20
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(false, //spanLeft
21
+ cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
21
22
  (0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
22
23
  newCell.isSelected = true;
23
24
  row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,iFAAgF;AAChF,2EAAgF;AAMhF;;;;GAIG;AACH,SAAgB,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;IAEzC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;IACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;IAE7C,IAAI,GAAG,EAAE;QACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;YACrD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAEtE,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;gBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;gBAE1B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YACpF,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,CAAC,MAAM,CACf,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EACjD,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;SACL;KACJ;AACL,CAAC;AAhCD,8CAgCC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"m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C,EACjD,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;SACL;KACJ;AACL,CAAC;AAhCD,8CAgCC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n false, //spanLeft\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
@@ -20,7 +20,8 @@ function insertTableRow(table, operation) {
20
20
  table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {
21
21
  format: (0, tslib_1.__assign)({}, sourceRow.format),
22
22
  cells: sourceRow.cells.map(function (cell) {
23
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
23
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, false, //spanAbove
24
+ cell.isHeader, cell.format, cell.dataset);
24
25
  (0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
25
26
  newCell.isSelected = true;
26
27
  return newCell;
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;AAAA,2DAA0D;AAC1D,iFAAgF;AAChF,2EAAgF;AAMhF;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,KAAsC,EACtC,SAAuC;IAEvC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;IACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;IAE/C,IAAI,GAAG,EAAE;QACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;gBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;gBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;oBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAC1B,OAAO,OAAO,CAAC;gBACnB,CAAC,CAAC;gBACF,MAAM,EAAE,SAAS,CAAC,MAAM;aAC3B,CAAC,CAAC;SACN;KACJ;AACL,CAAC;AA/BD,wCA+BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;AAAA,2DAA0D;AAC1D,iFAAgF;AAChF,2EAAgF;AAMhF;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,KAAsC,EACtC,SAAuC;IAEvC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;IACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;IAE/C,IAAI,GAAG,EAAE;QACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;gBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;gBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;oBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,KAAK,EAAE,WAAW;oBAClB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAC1B,OAAO,OAAO,CAAC;gBACnB,CAAC,CAAC;gBACF,MAAM,EAAE,SAAS,CAAC,MAAM;aAC3B,CAAC,CAAC;SACN;KACJ;AACL,CAAC;AA/BD,wCA+BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n false, //spanAbove\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
@@ -56,6 +56,7 @@ export { setModelListStyle } from './modelApi/list/setModelListStyle';
56
56
  export { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';
57
57
  export { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';
58
58
  export { setModelIndentation } from './modelApi/block/setModelIndentation';
59
+ export { getTextDirection } from './modelApi/block/setModelDirection';
59
60
  export { matchLink } from './modelApi/link/matchLink';
60
61
  export { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';
61
62
  export { getListAnnounceData } from './modelApi/list/getListAnnounceData';
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/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/createEditorContextForEntity", "./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/link/promoteLink", "./modelApi/list/getListAnnounceData", "./modelApi/common/queryContentModelBlocks", "./modelApi/selection/adjustWordSelection"], 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, createEditorContextForEntity_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, promoteLink_1, getListAnnounceData_1, queryContentModelBlocks_1, adjustWordSelection_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/createEditorContextForEntity", "./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/block/setModelDirection", "./modelApi/link/matchLink", "./modelApi/link/promoteLink", "./modelApi/list/getListAnnounceData", "./modelApi/common/queryContentModelBlocks", "./modelApi/selection/adjustWordSelection"], 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, createEditorContextForEntity_1, formatTableWithContentModel_1, formatImageWithContentModel_1, formatParagraphWithContentModel_1, formatSegmentWithContentModel_1, formatTextSegmentBeforeSelectionMarker_1, formatInsertPointWithContentModel_1, setListType_1, setModelListStyle_1, setModelListStartNumber_1, findListItemsInSameThread_1, setModelIndentation_1, setModelDirection_1, matchLink_1, promoteLink_1, getListAnnounceData_1, queryContentModelBlocks_1, adjustWordSelection_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = 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.createEditorContextForEntity = 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.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.getTextDirection = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.createEditorContextForEntity = 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; } });
@@ -60,6 +60,7 @@ define(["require", "exports", "./publicApi/table/insertTable", "./publicApi/tabl
60
60
  Object.defineProperty(exports, "setModelListStartNumber", { enumerable: true, get: function () { return setModelListStartNumber_1.setModelListStartNumber; } });
61
61
  Object.defineProperty(exports, "findListItemsInSameThread", { enumerable: true, get: function () { return findListItemsInSameThread_1.findListItemsInSameThread; } });
62
62
  Object.defineProperty(exports, "setModelIndentation", { enumerable: true, get: function () { return setModelIndentation_1.setModelIndentation; } });
63
+ Object.defineProperty(exports, "getTextDirection", { enumerable: true, get: function () { return setModelDirection_1.getTextDirection; } });
63
64
  Object.defineProperty(exports, "matchLink", { enumerable: true, get: function () { return matchLink_1.matchLink; } });
64
65
  Object.defineProperty(exports, "promoteLink", { enumerable: true, get: function () { return promoteLink_1.promoteLink; } });
65
66
  Object.defineProperty(exports, "getPromoteLink", { enumerable: true, get: function () { return promoteLink_1.getPromoteLink; } });
@@ -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,kHAAA,eAAe,OAAA;IACf,0HAAA,mBAAmB,OAAA;IACnB,kHAAA,eAAe,OAAA;IACf,sHAAA,iBAAiB,OAAA;IACjB,wHAAA,kBAAkB,OAAA;IAClB,0GAAA,WAAW,OAAA;IACX,0GAAA,WAAW,OAAA;IACX,4GAAA,YAAY,OAAA;IACZ,gHAAA,cAAc,OAAA;IACd,wHAAA,kBAAkB,OAAA;IAClB,4HAAA,oBAAoB,OAAA;IACpB,oHAAA,gBAAgB,OAAA;IAChB,0GAAA,WAAW,OAAA;IACX,4GAAA,YAAY,OAAA;IACZ,wHAAA,kBAAkB,OAAA;IAClB,gHAAA,cAAc,OAAA;IACd,4GAAA,YAAY,OAAA;IACZ,4GAAA,YAAY,OAAA;IACZ,kHAAA,eAAe,OAAA;IACf,oHAAA,gBAAgB,OAAA;IAChB,wGAAA,UAAU,OAAA;IACV,gHAAA,cAAc,OAAA;IACd,sHAAA,iBAAiB,OAAA;IACjB,0GAAA,WAAW,OAAA;IACX,gHAAA,cAAc,OAAA;IACd,0GAAA,WAAW,OAAA;IACX,wGAAA,UAAU,OAAA;IACV,wGAAA,UAAU,OAAA;IACV,0HAAA,mBAAmB,OAAA;IACnB,kHAAA,eAAe,OAAA;IACf,4HAAA,oBAAoB,OAAA;IACpB,wHAAA,kBAAkB,OAAA;IAClB,wGAAA,UAAU,OAAA;IACV,4GAAA,YAAY,OAAA;IACZ,gHAAA,cAAc,OAAA;IACd,sHAAA,iBAAiB,OAAA;IACjB,wHAAA,kBAAkB,OAAA;IAElB,4IAAA,4BAA4B,OAAA;IAC5B,0IAAA,2BAA2B,OAAA;IAC3B,0IAAA,2BAA2B,OAAA;IAC3B,kJAAA,+BAA+B,OAAA;IAC/B,8IAAA,6BAA6B,OAAA;IAC7B,gKAAA,sCAAsC,OAAA;IACtC,sJAAA,iCAAiC,OAAA;IAEjC,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,kIAAA,uBAAuB,OAAA;IACvB,sIAAA,yBAAyB,OAAA;IACzB,0HAAA,mBAAmB,OAAA;IACnB,sGAAA,SAAS,OAAA;IACT,0GAAA,WAAW,OAAA;IAAE,6GAAA,cAAc,OAAA;IAC3B,0HAAA,mBAAmB,OAAA;IACnB,kIAAA,uBAAuB,OAAA;IACvB,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 { createEditorContextForEntity } from './publicApi/utils/createEditorContextForEntity';\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 { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\nexport { queryContentModelBlocks } from './modelApi/common/queryContentModelBlocks';\nexport { adjustWordSelection } from './modelApi/selection/adjustWordSelection';\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;IACV,4GAAA,YAAY,OAAA;IACZ,kHAAA,eAAe,OAAA;IACf,0HAAA,mBAAmB,OAAA;IACnB,kHAAA,eAAe,OAAA;IACf,sHAAA,iBAAiB,OAAA;IACjB,wHAAA,kBA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,OAAA;IAAE,6GAAA,cAAc,OAAA;IAC3B,0HAAA,mBAAmB,OAAA;IACnB,kIAAA,uBAAuB,OAAA;IACvB,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 { createEditorContextForEntity } from './publicApi/utils/createEditorContextForEntity';\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 { getTextDirection } from './modelApi/block/setModelDirection';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\nexport { queryContentModelBlocks } from './modelApi/common/queryContentModelBlocks';\nexport { adjustWordSelection } from './modelApi/selection/adjustWordSelection';\n"]}
@@ -3,3 +3,8 @@ import type { ReadonlyContentModelDocument } from 'roosterjs-content-model-types
3
3
  * @internal
4
4
  */
5
5
  export declare function setModelDirection(model: ReadonlyContentModelDocument, direction: 'ltr' | 'rtl' | 'auto'): boolean;
6
+ /**
7
+ * Determine text direction from the first strong directional character
8
+ * @param text Text to scan
9
+ */
10
+ export declare function getTextDirection(text: string): 'ltr' | 'rtl' | undefined;
@@ -1,12 +1,9 @@
1
1
  define(["require", "exports", "../list/findListItemsInSameThread", "./splitSelectedParagraphByBr", "roosterjs-content-model-dom"], function (require, exports, findListItemsInSameThread_1, splitSelectedParagraphByBr_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.setModelDirection = void 0;
5
- // Regexes for character direction detection
6
- // Strongly typed RTL character ranges. Referenced unicode's DerivedBidiClass.txt, excluding things in the 2 bit range.
7
- var RTL_CHAR_REGEX = /[\u0590-\u05FF\u0600-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/g;
8
- var URL_CHAR_REGEX = /http\S+|www\S+|https\S+|<a\s+(?:[^>]*?\s+)?href=(["']).*?\1.*?>.*?<\/a>/g;
9
- var WHITESPACE_REGEX = /\s/g;
4
+ exports.getTextDirection = exports.setModelDirection = void 0;
5
+ var FIRST_STRONG_CHAR_REGEX = new RegExp('[\\p{L}\\u200E\\u200F]', 'u');
6
+ var RTL_CHAR_REGEX = new RegExp('[\\u0590-\\u08FF\\u200F\\uFB1D-\\uFDFF\\uFE70-\\uFEFF\\u{10840}-\\u{10FFF}\\u{1E800}-\\u{1E95F}]', 'u');
10
7
  /**
11
8
  * @internal
12
9
  */
@@ -84,29 +81,29 @@ define(["require", "exports", "../list/findListItemsInSameThread", "./splitSelec
84
81
  delete format[key];
85
82
  }
86
83
  }
84
+ /**
85
+ * Determine text direction from the first strong directional character
86
+ * @param text Text to scan
87
+ */
88
+ function getTextDirection(text) {
89
+ var _a;
90
+ var firstStrongChar = (_a = text.match(FIRST_STRONG_CHAR_REGEX)) === null || _a === void 0 ? void 0 : _a[0];
91
+ return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;
92
+ }
93
+ exports.getTextDirection = getTextDirection;
87
94
  // Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character
88
95
  function determineTextDirection(block) {
96
+ return getTextDirection(getTextContent(block)) || 'ltr';
97
+ }
98
+ function getTextContent(block) {
89
99
  if (block.blockType === 'Paragraph') {
90
- var findTextSegements = block.segments.filter(function (seg) { return seg.segmentType === 'Text'; });
91
- var innerText = findTextSegements.length > 0
92
- ? findTextSegements.reduce(function (prev, seg) { return prev + seg.text; }, '')
93
- : undefined;
94
- if (!!innerText) {
95
- // Remove links
96
- innerText = innerText.replace(URL_CHAR_REGEX, '');
97
- // Remove whitespace
98
- innerText = innerText.replace(WHITESPACE_REGEX, '');
99
- var rtlMatches = innerText.match(RTL_CHAR_REGEX);
100
- var rtlCount = rtlMatches ? rtlMatches.length : 0;
101
- var ltrCount = innerText.length - rtlCount;
102
- return rtlCount > ltrCount ? 'rtl' : 'ltr';
103
- }
104
- else {
105
- return 'ltr'; // Default to LTR if no text is found
106
- }
100
+ return block.segments.reduce(function (text, segment) { return text + (segment.segmentType === 'Text' ? segment.text : ''); }, '');
101
+ }
102
+ else if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(block, 'ListItem')) {
103
+ return block.blocks.reduce(function (text, childBlock) { return text + getTextContent(childBlock); }, '');
107
104
  }
108
105
  else {
109
- return 'ltr';
106
+ return '';
110
107
  }
111
108
  }
112
109
  });
@@ -1 +1 @@
1
- {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;;IAmBA,4CAA4C;IAC5C,uHAAuH;IACvH,IAAM,cAAc,GAAG,yDAAyD,CAAC;IACjF,IAA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ElD,oBAAoB;gBACpB,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;gBAEpD,IAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;gBACnD,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEpD,IAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,GAAG,QAAQ,CAAC;gBAE7C,OAAO,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;aAC9C;iBAAM;gBACH,OAAO,KAAK,CAAC,CAAC,qCAAqC;aACtD;SACJ;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelText,\n} from 'roosterjs-content-model-types';\n\n// Regexes for character direction detection\n// Strongly typed RTL character ranges. Referenced unicode's DerivedBidiClass.txt, excluding things in the 2 bit range.\nconst RTL_CHAR_REGEX = /[\\u0590-\\u05FF\\u0600-\\u08FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFF]/g;\nconst URL_CHAR_REGEX = /http\\S+|www\\S+|https\\S+|<a\\s+(?:[^>]*?\\s+)?href=([\"']).*?\\1.*?>.*?<\\/a>/g;\nconst WHITESPACE_REGEX = /\\s/g;\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\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(mutateBlock(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\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n if (block.blockType === 'Paragraph') {\n const findTextSegements: ReadonlyContentModelText[] = block.segments.filter(\n (seg): seg is ReadonlyContentModelText => seg.segmentType === 'Text'\n );\n let innerText =\n findTextSegements.length > 0\n ? findTextSegements.reduce((prev, seg) => prev + seg.text, '')\n : undefined;\n if (!!innerText) {\n // Remove links\n innerText = innerText.replace(URL_CHAR_REGEX, '');\n\n // Remove whitespace\n innerText = innerText.replace(WHITESPACE_REGEX, '');\n\n const rtlMatches = innerText.match(RTL_CHAR_REGEX);\n const rtlCount = rtlMatches ? rtlMatches.length : 0;\n\n const ltrCount = innerText.length - rtlCount;\n\n return rtlCount > ltrCount ? 'rtl' : 'ltr';\n } else {\n return 'ltr'; // Default to LTR if no text is found\n }\n } else {\n return 'ltr';\n }\n}\n"]}
1
+ {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;;IAkBA,IAAM,uBAAuB,GAAG,IAAI,MAAM,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;IAC1E,IAAM,cAAc,GAAG,IAAI,MAAM,CAC7B,kGAAkG,EAClG,GAAG,CACN,CAAC;IAEF;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,SAAiC;QAEjC,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;QAElC,IAAM,0BAA0B,GAAG,IAAA,kDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CA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,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,UAAU,IAAK,OAAA,IAAI,GAAG,cAAc,CAAC,UAAU,CAAC,EAAjC,CAAiC,EAAE,EAAE,CAAC,CAAC;SAC3F;aAAM;YACH,OAAO,EAAE,CAAC;SACb;IACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst FIRST_STRONG_CHAR_REGEX = new RegExp('[\\\\p{L}\\\\u200E\\\\u200F]', 'u');\nconst RTL_CHAR_REGEX = new RegExp(\n '[\\\\u0590-\\\\u08FF\\\\u200F\\\\uFB1D-\\\\uFDFF\\\\uFE70-\\\\uFEFF\\\\u{10840}-\\\\u{10FFF}\\\\u{1E800}-\\\\u{1E95F}]',\n 'u'\n);\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\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(mutateBlock(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\n/**\n * Determine text direction from the first strong directional character\n * @param text Text to scan\n */\nexport function getTextDirection(text: string): 'ltr' | 'rtl' | undefined {\n const firstStrongChar = text.match(FIRST_STRONG_CHAR_REGEX)?.[0];\n\n return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;\n}\n\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n return getTextDirection(getTextContent(block)) || 'ltr';\n}\n\nfunction getTextContent(block: ReadonlyContentModelBlock): string {\n if (block.blockType === 'Paragraph') {\n return block.segments.reduce(\n (text, segment) => text + (segment.segmentType === 'Text' ? segment.text : ''),\n ''\n );\n } else if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n return block.blocks.reduce((text, childBlock) => text + getTextContent(childBlock), '');\n } else {\n return '';\n }\n}\n"]}
@@ -15,7 +15,8 @@ define(["require", "exports", "./clearSelectedCells", "./copyPreviousCellSegment
15
15
  for (var i = sel === null || sel === void 0 ? void 0 : sel.firstColumn; i <= sel.lastColumn; i++) {
16
16
  table.rows.forEach(function (row) {
17
17
  var cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];
18
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
18
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(false, //spanLeft
19
+ cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
19
20
  (0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
20
21
  newCell.isSelected = true;
21
22
  row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;QAEzC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACrD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAEtE,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAE1B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,MAAM,CAAC,MAAM,CACf,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EACjD,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;aACL;SACJ;IACL,CAAC;IAhCD,8CAgCC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;QAEzC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACrD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAEtE,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,KAAK,EAAE,UAAU;oBACjB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAE1B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,MAAM,CAAC,MAAM,CACf,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EACjD,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;aACL;SACJ;IACL,CAAC;IAhCD,8CAgCC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n false, //spanLeft\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
@@ -17,7 +17,8 @@ define(["require", "exports", "tslib", "./clearSelectedCells", "./copyPreviousCe
17
17
  table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {
18
18
  format: (0, tslib_1.__assign)({}, sourceRow.format),
19
19
  cells: sourceRow.cells.map(function (cell) {
20
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
20
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, false, //spanAbove
21
+ cell.isHeader, cell.format, cell.dataset);
21
22
  (0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
22
23
  newCell.isSelected = true;
23
24
  return newCell;
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,KAAsC,EACtC,SAAuC;QAEvC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;QAE/C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;oBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;oBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;wBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;wBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;wBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;wBAC1B,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;oBACF,MAAM,EAAE,SAAS,CAAC,MAAM;iBAC3B,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IA/BD,wCA+BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,KAAsC,EACtC,SAAuC;QAEvC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;QAE/C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;oBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;oBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;wBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,KAAK,EAAE,WAAW;wBAClB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;wBACF,IAAA,6DAA6B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;wBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;wBAC1B,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;oBACF,MAAM,EAAE,SAAS,CAAC,MAAM;iBAC3B,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IA/BD,wCA+BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n false, //spanAbove\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
@@ -56,6 +56,7 @@ export { setModelListStyle } from './modelApi/list/setModelListStyle';
56
56
  export { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';
57
57
  export { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';
58
58
  export { setModelIndentation } from './modelApi/block/setModelIndentation';
59
+ export { getTextDirection } from './modelApi/block/setModelDirection';
59
60
  export { matchLink } from './modelApi/link/matchLink';
60
61
  export { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';
61
62
  export { getListAnnounceData } from './modelApi/list/getListAnnounceData';
package/lib-mjs/index.js CHANGED
@@ -56,6 +56,7 @@ export { setModelListStyle } from './modelApi/list/setModelListStyle';
56
56
  export { setModelListStartNumber } from './modelApi/list/setModelListStartNumber';
57
57
  export { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';
58
58
  export { setModelIndentation } from './modelApi/block/setModelIndentation';
59
+ export { getTextDirection } from './modelApi/block/setModelDirection';
59
60
  export { matchLink } from './modelApi/link/matchLink';
60
61
  export { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';
61
62
  export { getListAnnounceData } from './modelApi/list/getListAnnounceData';
@@ -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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AO,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,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,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 { createEditorContextForEntity } from './publicApi/utils/createEditorContextForEntity';\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 { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\nexport { queryContentModelBlocks } from './modelApi/common/queryContentModelBlocks';\nexport { adjustWordSelection } from './modelApi/selection/adjustWordSelection';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-api/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,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,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,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 { createEditorContextForEntity } from './publicApi/utils/createEditorContextForEntity';\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 { getTextDirection } from './modelApi/block/setModelDirection';\nexport { matchLink } from './modelApi/link/matchLink';\nexport { promoteLink, getPromoteLink } from './modelApi/link/promoteLink';\nexport { getListAnnounceData } from './modelApi/list/getListAnnounceData';\nexport { queryContentModelBlocks } from './modelApi/common/queryContentModelBlocks';\nexport { adjustWordSelection } from './modelApi/selection/adjustWordSelection';\n"]}
@@ -3,3 +3,8 @@ import type { ReadonlyContentModelDocument } from 'roosterjs-content-model-types
3
3
  * @internal
4
4
  */
5
5
  export declare function setModelDirection(model: ReadonlyContentModelDocument, direction: 'ltr' | 'rtl' | 'auto'): boolean;
6
+ /**
7
+ * Determine text direction from the first strong directional character
8
+ * @param text Text to scan
9
+ */
10
+ export declare function getTextDirection(text: string): 'ltr' | 'rtl' | undefined;
@@ -1,11 +1,8 @@
1
1
  import { findListItemsInSameThread } from '../list/findListItemsInSameThread';
2
2
  import { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';
3
3
  import { applyTableFormat, getOperationalBlocks, isBlockGroupOfType, mutateBlock, updateTableCellMetadata, } from 'roosterjs-content-model-dom';
4
- // Regexes for character direction detection
5
- // Strongly typed RTL character ranges. Referenced unicode's DerivedBidiClass.txt, excluding things in the 2 bit range.
6
- var RTL_CHAR_REGEX = /[\u0590-\u05FF\u0600-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/g;
7
- var URL_CHAR_REGEX = /http\S+|www\S+|https\S+|<a\s+(?:[^>]*?\s+)?href=(["']).*?\1.*?>.*?<\/a>/g;
8
- var WHITESPACE_REGEX = /\s/g;
4
+ var FIRST_STRONG_CHAR_REGEX = new RegExp('[\\p{L}\\u200E\\u200F]', 'u');
5
+ var RTL_CHAR_REGEX = new RegExp('[\\u0590-\\u08FF\\u200F\\uFB1D-\\uFDFF\\uFE70-\\uFEFF\\u{10840}-\\u{10FFF}\\u{1E800}-\\u{1E95F}]', 'u');
9
6
  /**
10
7
  * @internal
11
8
  */
@@ -82,29 +79,28 @@ function setProperty(format, key, value) {
82
79
  delete format[key];
83
80
  }
84
81
  }
82
+ /**
83
+ * Determine text direction from the first strong directional character
84
+ * @param text Text to scan
85
+ */
86
+ export function getTextDirection(text) {
87
+ var _a;
88
+ var firstStrongChar = (_a = text.match(FIRST_STRONG_CHAR_REGEX)) === null || _a === void 0 ? void 0 : _a[0];
89
+ return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;
90
+ }
85
91
  // Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character
86
92
  function determineTextDirection(block) {
93
+ return getTextDirection(getTextContent(block)) || 'ltr';
94
+ }
95
+ function getTextContent(block) {
87
96
  if (block.blockType === 'Paragraph') {
88
- var findTextSegements = block.segments.filter(function (seg) { return seg.segmentType === 'Text'; });
89
- var innerText = findTextSegements.length > 0
90
- ? findTextSegements.reduce(function (prev, seg) { return prev + seg.text; }, '')
91
- : undefined;
92
- if (!!innerText) {
93
- // Remove links
94
- innerText = innerText.replace(URL_CHAR_REGEX, '');
95
- // Remove whitespace
96
- innerText = innerText.replace(WHITESPACE_REGEX, '');
97
- var rtlMatches = innerText.match(RTL_CHAR_REGEX);
98
- var rtlCount = rtlMatches ? rtlMatches.length : 0;
99
- var ltrCount = innerText.length - rtlCount;
100
- return rtlCount > ltrCount ? 'rtl' : 'ltr';
101
- }
102
- else {
103
- return 'ltr'; // Default to LTR if no text is found
104
- }
97
+ return block.segments.reduce(function (text, segment) { return text + (segment.segmentType === 'Text' ? segment.text : ''); }, '');
98
+ }
99
+ else if (isBlockGroupOfType(block, 'ListItem')) {
100
+ return block.blocks.reduce(function (text, childBlock) { return text + getTextContent(childBlock); }, '');
105
101
  }
106
102
  else {
107
- return 'ltr';
103
+ return '';
108
104
  }
109
105
  }
110
106
  //# sourceMappingURL=setModelDirection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,uBAAuB,GAC1B,MAAM,6BAA6B,CAAC;AAWrC,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SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YAEpD,IAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YACnD,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAEpD,IAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,GAAG,QAAQ,CAAC;YAE7C,OAAO,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;SAC9C;aAAM;YACH,OAAO,KAAK,CAAC,CAAC,qCAAqC;SACtD;KACJ;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n ReadonlyContentModelText,\n} from 'roosterjs-content-model-types';\n\n// Regexes for character direction detection\n// Strongly typed RTL character ranges. Referenced unicode's DerivedBidiClass.txt, excluding things in the 2 bit range.\nconst RTL_CHAR_REGEX = /[\\u0590-\\u05FF\\u0600-\\u08FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFF]/g;\nconst URL_CHAR_REGEX = /http\\S+|www\\S+|https\\S+|<a\\s+(?:[^>]*?\\s+)?href=([\"']).*?\\1.*?>.*?<\\/a>/g;\nconst WHITESPACE_REGEX = /\\s/g;\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\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(mutateBlock(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\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n if (block.blockType === 'Paragraph') {\n const findTextSegements: ReadonlyContentModelText[] = block.segments.filter(\n (seg): seg is ReadonlyContentModelText => seg.segmentType === 'Text'\n );\n let innerText =\n findTextSegements.length > 0\n ? findTextSegements.reduce((prev, seg) => prev + seg.text, '')\n : undefined;\n if (!!innerText) {\n // Remove links\n innerText = innerText.replace(URL_CHAR_REGEX, '');\n\n // Remove whitespace\n innerText = innerText.replace(WHITESPACE_REGEX, '');\n\n const rtlMatches = innerText.match(RTL_CHAR_REGEX);\n const rtlCount = rtlMatches ? rtlMatches.length : 0;\n\n const ltrCount = innerText.length - rtlCount;\n\n return rtlCount > ltrCount ? 'rtl' : 'ltr';\n } else {\n return 'ltr'; // Default to LTR if no text is found\n }\n } else {\n return 'ltr';\n }\n}\n"]}
1
+ {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,uBAAuB,GAC1B,MAAM,6BAA6B,CAAC;AAUrC,IAAM,uBAAuB,GAAG,IAAI,MAAM,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;AAC1E,IAAM,cAAc,GAAG,IAAI,MAAM,CAC7B,kGAAkG,EAClG,GAAG,CACN,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,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SAAM,IAAI,kBAAkB,CAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;QACpE,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,UAAU,IAAK,OAAA,IAAI,GAAG,cAAc,CAAC,UAAU,CAAC,EAAjC,CAAiC,EAAE,EAAE,CAAC,CAAC;KAC3F;SAAM;QACH,OAAO,EAAE,CAAC;KACb;AACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst FIRST_STRONG_CHAR_REGEX = new RegExp('[\\\\p{L}\\\\u200E\\\\u200F]', 'u');\nconst RTL_CHAR_REGEX = new RegExp(\n '[\\\\u0590-\\\\u08FF\\\\u200F\\\\uFB1D-\\\\uFDFF\\\\uFE70-\\\\uFEFF\\\\u{10840}-\\\\u{10FFF}\\\\u{1E800}-\\\\u{1E95F}]',\n 'u'\n);\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\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(mutateBlock(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\n/**\n * Determine text direction from the first strong directional character\n * @param text Text to scan\n */\nexport function getTextDirection(text: string): 'ltr' | 'rtl' | undefined {\n const firstStrongChar = text.match(FIRST_STRONG_CHAR_REGEX)?.[0];\n\n return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;\n}\n\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n return getTextDirection(getTextContent(block)) || 'ltr';\n}\n\nfunction getTextContent(block: ReadonlyContentModelBlock): string {\n if (block.blockType === 'Paragraph') {\n return block.segments.reduce(\n (text, segment) => text + (segment.segmentType === 'Text' ? segment.text : ''),\n ''\n );\n } else if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n return block.blocks.reduce((text, childBlock) => text + getTextContent(childBlock), '');\n } else {\n return '';\n }\n}\n"]}
@@ -14,7 +14,8 @@ export function insertTableColumn(table, operation) {
14
14
  for (var i = sel === null || sel === void 0 ? void 0 : sel.firstColumn; i <= sel.lastColumn; i++) {
15
15
  table.rows.forEach(function (row) {
16
16
  var cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];
17
- var newCell = createTableCell(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
17
+ var newCell = createTableCell(false, //spanLeft
18
+ cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
18
19
  copyPreviousCellSegmentFormat(cell, newCell);
19
20
  newCell.isSelected = true;
20
21
  row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMhF;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;IAEzC,IAAM,GAAG,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sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMhF;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;IAEzC,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpC,IAAM,UAAU,GAAG,SAAS,IA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ousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n false, //spanLeft\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
@@ -17,7 +17,8 @@ export function insertTableRow(table, operation) {
17
17
  table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {
18
18
  format: __assign({}, sourceRow.format),
19
19
  cells: sourceRow.cells.map(function (cell) {
20
- var newCell = createTableCell(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
20
+ var newCell = createTableCell(cell.spanLeft, false, //spanAbove
21
+ cell.isHeader, cell.format, cell.dataset);
21
22
  copyPreviousCellSegmentFormat(cell, newCell);
22
23
  newCell.isSelected = true;
23
24
  return newCell;
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sB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AM;aAC3B,CAAC,CAAC;SACN;KACJ;AACL,CAAC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMhF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC1B,KAAsC,EACtC,SAAuC;IAEvC,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;IAE/C,IAAI,GAAG,EAAE;QACL,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;gBAC/D,MAAM,eAAO,SAAS,CAAC,MAAM,CAAE;gBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;oBAC3B,IAAM,OAAO,GAAG,eAAe,CAC3B,IAAI,CAAC,QAAQ,EACb,KAAK,EAAE,WAAW;oBAClB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,6BAA6B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAC7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAC1B,OAAO,OAAO,CAAC;gBACnB,CAAC,CAAC;gBACF,MAAM,EAAE,SAAS,CAAC,MAAM;aAC3B,CAAC,CAAC;SACN;KACJ;AACL,CAAC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n false, //spanAbove\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\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.57.0",
7
- "roosterjs-content-model-types": "^9.57.0"
6
+ "roosterjs-content-model-dom": "^9.59.0",
7
+ "roosterjs-content-model-types": "^9.59.0"
8
8
  },
9
- "version": "9.57.0",
9
+ "version": "9.59.0",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",