roosterjs-content-model-api 0.22.0 → 0.24.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 (67) hide show
  1. package/lib/modelApi/block/setModelAlignment.d.ts +1 -1
  2. package/lib/modelApi/block/setModelAlignment.js +13 -3
  3. package/lib/modelApi/block/setModelAlignment.js.map +1 -1
  4. package/lib/modelApi/block/setModelDirection.js +20 -3
  5. package/lib/modelApi/block/setModelDirection.js.map +1 -1
  6. package/lib/modelApi/common/retrieveModelFormatState.js +5 -3
  7. package/lib/modelApi/common/retrieveModelFormatState.js.map +1 -1
  8. package/lib/modelApi/selection/adjustTrailingSpaceSelection.d.ts +6 -0
  9. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js +56 -0
  10. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -0
  11. package/lib/publicApi/block/setAlignment.d.ts +1 -1
  12. package/lib/publicApi/block/setAlignment.js.map +1 -1
  13. package/lib/publicApi/image/changeImage.js +1 -1
  14. package/lib/publicApi/image/changeImage.js.map +1 -1
  15. package/lib/publicApi/link/insertLink.js +2 -0
  16. package/lib/publicApi/link/insertLink.js.map +1 -1
  17. package/lib/publicApi/segment/toggleUnderline.js +2 -1
  18. package/lib/publicApi/segment/toggleUnderline.js.map +1 -1
  19. package/lib/publicApi/table/applyTableBorderFormat.js +18 -16
  20. package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
  21. package/lib/publicApi/utils/formatSegmentWithContentModel.js +2 -7
  22. package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  23. package/lib-amd/modelApi/block/setModelAlignment.d.ts +1 -1
  24. package/lib-amd/modelApi/block/setModelAlignment.js +13 -3
  25. package/lib-amd/modelApi/block/setModelAlignment.js.map +1 -1
  26. package/lib-amd/modelApi/block/setModelDirection.js +20 -3
  27. package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
  28. package/lib-amd/modelApi/common/retrieveModelFormatState.js +5 -4
  29. package/lib-amd/modelApi/common/retrieveModelFormatState.js.map +1 -1
  30. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.d.ts +6 -0
  31. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js +55 -0
  32. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -0
  33. package/lib-amd/publicApi/block/setAlignment.d.ts +1 -1
  34. package/lib-amd/publicApi/block/setAlignment.js.map +1 -1
  35. package/lib-amd/publicApi/image/changeImage.js +1 -1
  36. package/lib-amd/publicApi/image/changeImage.js.map +1 -1
  37. package/lib-amd/publicApi/link/insertLink.js +2 -1
  38. package/lib-amd/publicApi/link/insertLink.js.map +1 -1
  39. package/lib-amd/publicApi/segment/toggleUnderline.js +2 -2
  40. package/lib-amd/publicApi/segment/toggleUnderline.js.map +1 -1
  41. package/lib-amd/publicApi/table/applyTableBorderFormat.js +18 -16
  42. package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
  43. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +2 -7
  44. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  45. package/lib-mjs/modelApi/block/setModelAlignment.d.ts +1 -1
  46. package/lib-mjs/modelApi/block/setModelAlignment.js +13 -3
  47. package/lib-mjs/modelApi/block/setModelAlignment.js.map +1 -1
  48. package/lib-mjs/modelApi/block/setModelDirection.js +21 -4
  49. package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
  50. package/lib-mjs/modelApi/common/retrieveModelFormatState.js +5 -3
  51. package/lib-mjs/modelApi/common/retrieveModelFormatState.js.map +1 -1
  52. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.d.ts +6 -0
  53. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js +52 -0
  54. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -0
  55. package/lib-mjs/publicApi/block/setAlignment.d.ts +1 -1
  56. package/lib-mjs/publicApi/block/setAlignment.js.map +1 -1
  57. package/lib-mjs/publicApi/image/changeImage.js +1 -1
  58. package/lib-mjs/publicApi/image/changeImage.js.map +1 -1
  59. package/lib-mjs/publicApi/link/insertLink.js +2 -0
  60. package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
  61. package/lib-mjs/publicApi/segment/toggleUnderline.js +2 -1
  62. package/lib-mjs/publicApi/segment/toggleUnderline.js.map +1 -1
  63. package/lib-mjs/publicApi/table/applyTableBorderFormat.js +18 -16
  64. package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
  65. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +2 -7
  66. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  67. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;AAAA,2EAAiE;AACjE,6EAKsC;AA4BtC;;;;;GAKG;AACH,SAAwB,sBAAsB,CAC1C,MAAyB,EACzB,MAAc,EACd,SAA2B;IAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAAe,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;QAElD,IAAI,UAAU,EAAE;YACZ,IAAM,GAAG,GAAG,IAAA,+CAAgB,EAAC,UAAU,CAAC,CAAC;YACzC,IAAM,SAAS,GAAc;gBACzB,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;aACf,CAAC;YAEF,mDAAmD;YACnD,IAAI,YAAY,GAAG,EAAE,CAAC;YACtB,IAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;YACzB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,KAAK,GAAY,MAAM,MAAlB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C,OAAO,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;YAClE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;SAC1D;KACJ;IACD,qBAAqB;IACrB,IAAI,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;QACzE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YACjE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;SACzD;KACJ;AACL,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getFirstSelectedTable,\n getSelectedCells,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n IStandaloneEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport default function applyTableBorderFormat(\n editor: IStandaloneEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n perimeter.Left = true;\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n perimeter.Right = true;\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.lastColumn],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.lastColumn],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.lastColumn],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, ['borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, ['borderLeft']);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;AAAA,2EAAiE;AACjE,6EAKsC;AA4BtC;;;;;GAKG;AACH,SAAwB,sBAAsB,CAC1C,MAAyB,EACzB,MAAc,EACd,SAA2B;IAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAAe,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;QAElD,IAAI,UAAU,EAAE;YACZ,IAAM,GAAG,GAAG,IAAA,+CAAgB,EAAC,UAAU,CAAC,CAAC;YACzC,IAAM,SAAS,GAAc;gBACzB,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;aACf,CAAC;YAEF,mDAAmD;YACnD,IAAI,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C,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;SACjF;KACJ;IACD,qBAAqB;IACrB,IAAI,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;QACzE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YACjE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;SACjF;KACJ;AACL,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getFirstSelectedTable,\n getSelectedCells,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n IStandaloneEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport default function applyTableBorderFormat(\n editor: IStandaloneEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
@@ -10,7 +10,6 @@ var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
10
10
  function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, segmentHasStyleCallback, includingFormatHolder, afterFormatCallback) {
11
11
  editor.formatContentModel(function (model, context) {
12
12
  var segmentAndParagraphs = (0, roosterjs_content_model_core_1.getSelectedSegmentsAndParagraphs)(model, !!includingFormatHolder);
13
- var pendingFormat = editor.getPendingFormat();
14
13
  var isCollapsedSelection = segmentAndParagraphs.length == 1 &&
15
14
  segmentAndParagraphs[0][0].segmentType == 'SelectionMarker';
16
15
  if (isCollapsedSelection) {
@@ -20,9 +19,7 @@ function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, seg
20
19
  isCollapsedSelection = false;
21
20
  }
22
21
  }
23
- var formatsAndSegments = pendingFormat
24
- ? [[pendingFormat, null, null]]
25
- : segmentAndParagraphs.map(function (item) { return [item[0].format, item[0], item[1]]; });
22
+ var formatsAndSegments = segmentAndParagraphs.map(function (item) { return [item[0].format, item[0], item[1]]; });
26
23
  var isTurningOff = segmentHasStyleCallback
27
24
  ? formatsAndSegments.every(function (_a) {
28
25
  var _b = (0, tslib_1.__read)(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
@@ -34,10 +31,8 @@ function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, seg
34
31
  return toggleStyleCallback(format, !isTurningOff, segment, paragraph);
35
32
  });
36
33
  afterFormatCallback === null || afterFormatCallback === void 0 ? void 0 : afterFormatCallback(model);
37
- if (!pendingFormat && isCollapsedSelection) {
38
- context.newPendingFormat = segmentAndParagraphs[0][0].format;
39
- }
40
34
  if (isCollapsedSelection) {
35
+ context.newPendingFormat = segmentAndParagraphs[0][0].format;
41
36
  editor.focus();
42
37
  return false;
43
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,oFAAmF;AACnF,6EAAgF;AAQhF;;GAEG;AACH,SAAgB,6BAA6B,CACzC,MAAyB,EACzB,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAA2D;IAE3D,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,IAAA,+DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,CAC1B,CAAC;QACF,IAAM,aAAa,GAAG,MAAM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A3B,MAAM,QAAA,EAAE,OAAO,QAAA,EAAE,SAAS,QAAA;YACnD,OAAA,mBAAmB,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC;QAA9D,CAA8D,CACjE,CAAC;QAEF,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,aAAa,IAAI,oBAAoB,EAAE;YACxC,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;SAChE;QAED,IAAI,oBAAoB,EAAE;YACtB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;SACxC;IACL,CAAC,EACD;QACI,OAAO,SAAA;KACV,CACJ,CAAC;AACN,CAAC;AA5ED,sEA4EC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-core';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelSegmentFormat,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n/**\n * @internal\n */\nexport function formatSegmentWithContentModel(\n editor: IStandaloneEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder\n );\n const pendingFormat = editor.getPendingFormat();\n let isCollapsedSelection =\n segmentAndParagraphs.length == 1 &&\n segmentAndParagraphs[0][0].segmentType == 'SelectionMarker';\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ContentModelSegment | null,\n ContentModelParagraph | null\n ][] = pendingFormat\n ? [[pendingFormat, null, null]]\n : segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (!pendingFormat && isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n }\n\n if (isCollapsedSelection) {\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,oFAAmF;AACnF,6EAAgF;AAQhF;;GAEG;AACH,SAAgB,6BAA6B,CACzC,MAAyB,EACzB,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAA2D;IAE3D,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,IAAA,+DAAgC,EACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,CAC1B,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YA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AmB,uBAAnB,mBAAmB,CAAG,KAAK,CAAC,CAAC;QAE7B,IAAI,oBAAoB,EAAE;YACtB,OAAO,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;SACxC;IACL,CAAC,EACD;QACI,OAAO,SAAA;KACV,CACJ,CAAC;AACN,CAAC;AAtED,sEAsEC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-core';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelSegmentFormat,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n/**\n * @internal\n */\nexport function formatSegmentWithContentModel(\n editor: IStandaloneEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ContentModelSegment | null,\n paragraph: ContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (model: ContentModelDocument) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length == 1 &&\n segmentAndParagraphs[0][0].segmentType == 'SelectionMarker';\n\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ContentModelSegment | null,\n ContentModelParagraph | null\n ][] = segmentAndParagraphs.map(item => [item[0].format, item[0], item[1]]);\n\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n formatsAndSegments.forEach(([format, segment, paragraph]) =>\n toggleStyleCallback(format, !isTurningOff, segment, paragraph)\n );\n\n afterFormatCallback?.(model);\n\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\n}\n"]}
@@ -2,4 +2,4 @@ import type { ContentModelDocument } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function setModelAlignment(model: ContentModelDocument, alignment: 'left' | 'center' | 'right'): boolean;
5
+ export declare function setModelAlignment(model: ContentModelDocument, alignment: 'left' | 'center' | 'right' | 'justify'): boolean;
@@ -15,6 +15,10 @@ define(["require", "exports", "../table/alignTable", "roosterjs-content-model-co
15
15
  ltr: 'end',
16
16
  rtl: 'start',
17
17
  },
18
+ justify: {
19
+ ltr: 'justify',
20
+ rtl: 'justify',
21
+ },
18
22
  };
19
23
  var TableAlignMap = {
20
24
  left: {
@@ -37,13 +41,19 @@ define(["require", "exports", "../table/alignTable", "roosterjs-content-model-co
37
41
  var paragraphOrListItemOrTable = (0, roosterjs_content_model_core_1.getOperationalBlocks)(model, ['ListItem'], ['TableCell']);
38
42
  paragraphOrListItemOrTable.forEach(function (_a) {
39
43
  var block = _a.block;
40
- var newAligment = ResultMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr'];
41
- if (block.blockType === 'Table') {
44
+ var newAlignment = ResultMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr'];
45
+ if (block.blockType === 'Table' && alignment !== 'justify') {
42
46
  (0, alignTable_1.alignTable)(block, TableAlignMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr']);
43
47
  }
44
48
  else if (block) {
49
+ if (block.blockType === 'BlockGroup' && block.blockGroupType === 'ListItem') {
50
+ block.blocks.forEach(function (b) {
51
+ var format = b.format;
52
+ format.textAlign = newAlignment;
53
+ });
54
+ }
45
55
  var format = block.format;
46
- format.textAlign = newAligment;
56
+ format.textAlign = newAlignment;
47
57
  }
48
58
  });
49
59
  return paragraphOrListItemOrTable.length > 0;
@@ -1 +1 @@
1
- {"version":3,"file":"setModelAlignment.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/setModelAlignment.ts"],"names":[],"mappings":";;;;IAQA,IAAM,SAAS,GAGX;QACA,IAAI,EAAE;YACF,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,KAAK;SACb;QACD,MAAM,EAAE;YACJ,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,QAAQ;SAChB;QACD,KAAK,EAAE;YACH,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,OAAO;SACf;KACJ,CAAC;IAEF,IAAM,aAAa,GAGf;QACA,IAAI,EAAE;YACF,GAAG,EAAE,WAAW;YAChB,GAAG,EAAE,YAAY;SACpB;QACD,MAAM,EAAE;YACJ,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,aAAa;SACrB;QACD,KAAK,EAAE;YACH,GAAG,EAAE,YAAY;YACjB,GAAG,EAAE,WAAW;SACnB;KACJ,CAAC;IAEF;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,KAA2B,EAC3B,SAAsC;QAEtC,IAAM,0BAA0B,GAAG,IAAA,mDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;QAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;gBAAP,KAAK,WAAA;YACvC,IAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC1F,IAAI,KAAK,CAAC,SAAS,KAAK,OAAO,EAAE;gBAC7B,IAAA,uBAAU,EACN,KAAK,EACL,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAC5E,CAAC;aACL;iBAAM,IAAI,KAAK,EAAE;gBACN,IAAA,MAAM,GAAK,KAAK,OAAV,CAAW;gBACzB,MAAM,CAAC,SAAS,GAAG,WAAW,CAAC;aAClC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAC;IACjD,CAAC;IAxBD,8CAwBC","sourcesContent":["import { alignTable } from '../table/alignTable';\nimport { getOperationalBlocks } from 'roosterjs-content-model-core';\nimport type {\n ContentModelDocument,\n ContentModelListItem,\n TableAlignOperation,\n} from 'roosterjs-content-model-types';\n\nconst ResultMap: Record<\n 'left' | 'center' | 'right',\n Record<'ltr' | 'rtl', 'start' | 'center' | 'end'>\n> = {\n left: {\n ltr: 'start',\n rtl: 'end',\n },\n center: {\n ltr: 'center',\n rtl: 'center',\n },\n right: {\n ltr: 'end',\n rtl: 'start',\n },\n};\n\nconst TableAlignMap: Record<\n 'left' | 'center' | 'right',\n Record<'ltr' | 'rtl', TableAlignOperation>\n> = {\n left: {\n ltr: 'alignLeft',\n rtl: 'alignRight',\n },\n center: {\n ltr: 'alignCenter',\n rtl: 'alignCenter',\n },\n right: {\n ltr: 'alignRight',\n rtl: 'alignLeft',\n },\n};\n\n/**\n * @internal\n */\nexport function setModelAlignment(\n model: ContentModelDocument,\n alignment: 'left' | 'center' | 'right'\n) {\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n const newAligment = ResultMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr'];\n if (block.blockType === 'Table') {\n alignTable(\n block,\n TableAlignMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr']\n );\n } else if (block) {\n const { format } = block;\n format.textAlign = newAligment;\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n"]}
1
+ {"version":3,"file":"setModelAlignment.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/setModelAlignment.ts"],"names":[],"mappings":";;;;IAQA,IAAM,SAAS,GAGX;QACA,IAAI,EAAE;YACF,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,KAAK;SACb;QACD,MAAM,EAAE;YACJ,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,QAAQ;SAChB;QACD,KAAK,EAAE;YACH,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,OAAO;SACf;QACD,OAAO,EAAE;YACL,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;SACjB;KACJ,CAAC;IAEF,IAAM,aAAa,GAGf;QACA,IAAI,EAAE;YACF,GAAG,EAAE,WAAW;YAChB,GAAG,EAAE,YAAY;SACpB;QACD,MAAM,EAAE;YACJ,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,aAAa;SACrB;QACD,KAAK,EAAE;YACH,GAAG,EAAE,YAAY;YACjB,GAAG,EAAE,WAAW;SACnB;KACJ,CAAC;IAEF;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,KAA2B,EAC3B,SAAkD;QAElD,IAAM,0BAA0B,GAAG,IAAA,mDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;QAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;gBAAP,KAAK,WAAA;YACvC,IAAM,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC3F,IAAI,KAAK,CAAC,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,SAAS,EAAE;gBACxD,IAAA,uBAAU,EACN,KAAK,EACL,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAC5E,CAAC;aACL;iBAAM,IAAI,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,SAAS,KAAK,YAAY,IAAI,KAAK,CAAC,cAAc,KAAK,UAAU,EAAE;oBACzE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC;wBACV,IAAA,MAAM,GAAK,CAAC,OAAN,CAAO;wBACrB,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC;oBACpC,CAAC,CAAC,CAAC;iBACN;gBACO,IAAA,MAAM,GAAK,KAAK,OAAV,CAAW;gBACzB,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC;aACnC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAC;IACjD,CAAC;IA9BD,8CA8BC","sourcesContent":["import { alignTable } from '../table/alignTable';\nimport { getOperationalBlocks } from 'roosterjs-content-model-core';\nimport type {\n ContentModelDocument,\n ContentModelListItem,\n TableAlignOperation,\n} from 'roosterjs-content-model-types';\n\nconst ResultMap: Record<\n 'left' | 'center' | 'right' | 'justify',\n Record<'ltr' | 'rtl', 'start' | 'center' | 'end' | 'justify'>\n> = {\n left: {\n ltr: 'start',\n rtl: 'end',\n },\n center: {\n ltr: 'center',\n rtl: 'center',\n },\n right: {\n ltr: 'end',\n rtl: 'start',\n },\n justify: {\n ltr: 'justify',\n rtl: 'justify',\n },\n};\n\nconst TableAlignMap: Record<\n 'left' | 'center' | 'right',\n Record<'ltr' | 'rtl', TableAlignOperation>\n> = {\n left: {\n ltr: 'alignLeft',\n rtl: 'alignRight',\n },\n center: {\n ltr: 'alignCenter',\n rtl: 'alignCenter',\n },\n right: {\n ltr: 'alignRight',\n rtl: 'alignLeft',\n },\n};\n\n/**\n * @internal\n */\nexport function setModelAlignment(\n model: ContentModelDocument,\n alignment: 'left' | 'center' | 'right' | 'justify'\n) {\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n const newAlignment = ResultMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr'];\n if (block.blockType === 'Table' && alignment !== 'justify') {\n alignTable(\n block,\n TableAlignMap[alignment][block.format.direction == 'rtl' ? 'rtl' : 'ltr']\n );\n } else if (block) {\n if (block.blockType === 'BlockGroup' && block.blockGroupType === 'ListItem') {\n block.blocks.forEach(b => {\n const { format } = b;\n format.textAlign = newAlignment;\n });\n }\n const { format } = block;\n format.textAlign = newAlignment;\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n"]}
@@ -19,26 +19,43 @@ define(["require", "exports", "../list/findListItemsInSameThread", "roosterjs-co
19
19
  });
20
20
  }
21
21
  else if (block) {
22
- internalSetDirection(block.format, direction);
22
+ internalSetDirection(block.format, direction, block);
23
23
  }
24
24
  });
25
25
  return paragraphOrListItemOrTable.length > 0;
26
26
  }
27
27
  exports.setModelDirection = setModelDirection;
28
- function internalSetDirection(format, direction) {
28
+ function internalSetDirection(format, direction, block) {
29
29
  var wasRtl = format.direction == 'rtl';
30
30
  var isRtl = direction == 'rtl';
31
31
  if (wasRtl != isRtl) {
32
32
  format.direction = direction;
33
33
  // Adjust margin when change direction
34
34
  // TODO: make margin and padding direction-aware, like what we did for textAlign. So no need to adjust them here
35
- // TODO: Do we also need to handle border here?
36
35
  var marginLeft = format.marginLeft;
37
36
  var paddingLeft = format.paddingLeft;
38
37
  setProperty(format, 'marginLeft', format.marginRight);
39
38
  setProperty(format, 'marginRight', marginLeft);
40
39
  setProperty(format, 'paddingLeft', format.paddingRight);
41
40
  setProperty(format, 'paddingRight', paddingLeft);
41
+ // If whole Table direction changed, flip cell side borders
42
+ if (block && block.blockType == 'Table') {
43
+ block.rows.forEach(function (row) {
44
+ row.cells.forEach(function (cell) {
45
+ // Optimise by skipping cells with unchanged borders
46
+ (0, roosterjs_content_model_core_1.updateTableCellMetadata)(cell, function (metadata) {
47
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.borderOverride) {
48
+ var storeBorderLeft = cell.format.borderLeft;
49
+ setProperty(cell.format, 'borderLeft', cell.format.borderRight);
50
+ setProperty(cell.format, 'borderRight', storeBorderLeft);
51
+ }
52
+ return metadata;
53
+ });
54
+ });
55
+ });
56
+ // Apply changed borders
57
+ (0, roosterjs_content_model_core_1.applyTableFormat)(block, undefined /* newFormat */, true /* keepCellShade*/);
58
+ }
42
59
  }
43
60
  }
44
61
  function setProperty(format, key, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;;IAUA;;OAEG;IACH,SAAgB,iBAAiB,CAAC,KAA2B,EAAE,SAAwB;QACnF,IAAM,0BAA0B,GAAG,IAAA,mDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;QAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;gBAAP,KAAK,WAAA;YACvC,IAAI,IAAA,iDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;gBAC7D,IAAM,KAAK,GAAG,IAAA,qDAAyB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAEtD,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;oBACd,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;wBACrB,KAA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;aAAM;YACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;IACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';\nimport type {\n ContentModelBlockFormat,\n ContentModelDocument,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setModelDirection(model: ContentModelDocument, direction: 'ltr' | 'rtl') {\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(item => {\n item.levels.forEach(level => {\n level.format.direction = direction;\n });\n\n item.blocks.forEach(block => internalSetDirection(block.format, direction));\n });\n } else if (block) {\n internalSetDirection(block.format, direction);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(format: ContentModelBlockFormat, direction: 'ltr' | 'rtl') {\n const wasRtl = format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n format.direction = direction;\n\n // Adjust margin when change direction\n // TODO: make margin and padding direction-aware, like what we did for textAlign. So no need to adjust them here\n // TODO: Do we also need to handle border here?\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}\n\nfunction setProperty(\n format: MarginFormat & PaddingFormat,\n key: keyof (MarginFormat & PaddingFormat),\n value: string | undefined\n) {\n if (value) {\n format[key] = value;\n } else {\n delete format[key];\n }\n}\n"]}
1
+ {"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages-content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MAAmD,EACnD,GAAwD,EACxD,KAAyB;QAEzB,IAAI,KAAK,EAAE;YACP,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACvB;aAAM;YACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;IACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n BorderFormat,\n ContentModelBlock,\n ContentModelBlockFormat,\n ContentModelDocument,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setModelDirection(model: ContentModelDocument, direction: 'ltr' | 'rtl') {\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(item => {\n item.levels.forEach(level => {\n level.format.direction = direction;\n });\n\n item.blocks.forEach(block => internalSetDirection(block.format, direction));\n });\n } else if (block) {\n internalSetDirection(block.format, direction, block);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(\n format: ContentModelBlockFormat,\n direction: 'ltr' | 'rtl',\n block?: ContentModelBlock\n) {\n const wasRtl = format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n format.direction = direction;\n\n // Adjust margin when change direction\n // TODO: make margin and padding direction-aware, like what we did for textAlign. So no need to adjust them here\n const marginLeft = format.marginLeft;\n const paddingLeft = format.paddingLeft;\n\n setProperty(format, 'marginLeft', format.marginRight);\n setProperty(format, 'marginRight', marginLeft);\n setProperty(format, 'paddingLeft', format.paddingRight);\n setProperty(format, 'paddingRight', paddingLeft);\n\n // If whole Table direction changed, flip cell side borders\n if (block && block.blockType == 'Table') {\n block.rows.forEach(row => {\n row.cells.forEach(cell => {\n // Optimise by skipping cells with unchanged borders\n updateTableCellMetadata(cell, metadata => {\n if (metadata?.borderOverride) {\n const storeBorderLeft = cell.format.borderLeft;\n setProperty(cell.format, 'borderLeft', cell.format.borderRight);\n setProperty(cell.format, 'borderRight', storeBorderLeft);\n }\n return metadata;\n });\n });\n });\n\n // Apply changed borders\n applyTableFormat(block, undefined /* newFormat */, true /* keepCellShade*/);\n }\n }\n}\n\nfunction setProperty(\n format: MarginFormat & PaddingFormat & BorderFormat,\n key: keyof (MarginFormat & PaddingFormat & BorderFormat),\n value: string | undefined\n) {\n if (value) {\n format[key] = value;\n } else {\n delete format[key];\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.retrieveModelFormatState = void 0;
@@ -95,7 +95,7 @@ define(["require", "exports", "roosterjs-content-model-core"], function (require
95
95
  mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);
96
96
  mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);
97
97
  mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);
98
- mergeValue(result, 'fontSize', mergedFormat.fontSize, isFirst);
98
+ mergeValue(result, 'fontSize', mergedFormat.fontSize, isFirst, function (val) { return (0, roosterjs_content_model_dom_1.parseValueWithUnit)(val, undefined, 'pt') + 'pt'; });
99
99
  mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);
100
100
  mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);
101
101
  mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);
@@ -150,13 +150,14 @@ define(["require", "exports", "roosterjs-content-model-core"], function (require
150
150
  borderRadius: format.borderRadius,
151
151
  };
152
152
  }
153
- function mergeValue(format, key, newValue, isFirst) {
153
+ function mergeValue(format, key, newValue, isFirst, parseFn) {
154
+ if (parseFn === void 0) { parseFn = function (val) { return val; }; }
154
155
  if (isFirst) {
155
156
  if (newValue !== undefined) {
156
157
  format[key] = newValue;
157
158
  }
158
159
  }
159
- else if (newValue !== format[key]) {
160
+ else if (parseFn(newValue) !== parseFn(format[key])) {
160
161
  delete format[key];
161
162
  }
162
163
  }
@@ -1 +1 @@
1
- {"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/retrieveModelFormatState.ts"],"names":[],"mappings":";;;;IAoBA;;OAEG;IACH,SAAgB,wBAAwB,CACpC,KAA2B,EAC3B,aAA+C,EAC/C,WAAoC;QAEpC,IAAI,iBAAoD,CAAC;QACzD,IAAI,UAAyC,CAAC;QAC9C,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,YAAY,GAAG,IAAI,CAAC;QACxB,IAAI,cAAc,GAAG,IAAI,CAAC;QAE1B,IAAA,gDAAiB,EACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ;YAChC,oBAAoB;YACpB,uBAAuB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YAEpD,uBAAuB;YACvB,IAAI,KAAK,EAAE;gBACP,IAAI,UAAU,EAAE;oBACZ,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC;iBAC3C;qBAAM;oBACH,UAAU,GAAG,KAAK,CAAC;iBACtB;aACJ;YAED,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,WAAW,EAAE;gBACjC,oBAAoB;gBACpB,uBAAuB,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;gBAErD,kBAAkB;gBAClB,Q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W,aAAA;YACX,WAAW,aAAA;YACX,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;SACpC,CAAC;IACN,CAAC;IAED,SAAS,UAAU,CACf,MAA+B,EAC/B,GAAM,EACN,QAAgD,EAChD,OAAgB;QAEhB,IAAI,OAAO,EAAE;YACT,IAAI,QAAQ,KAAK,SAAS,EAAE;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;aAC1B;SACJ;aAAM,IAAI,QAAQ,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE;YACjC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;IACL,CAAC;IAED,SAAS,KAAK,CAAC,EAAU;QACrB,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YACzC,uHAAuH;YACvH,wBAAwB;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;SAC9D;QACD,OAAO,EAAE,CAAC;IACd,CAAC","sourcesContent":["import {\n extractBorderValues,\n getClosestAncestorBlockGroupIndex,\n isBold,\n iterateSelections,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelFormatState,\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelImage,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function retrieveModelFormatState(\n model: ContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState\n) {\n let firstTableContext: TableSelectionContext | undefined;\n let firstBlock: ContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n const modelFormat = Object.assign({}, model.format);\n delete modelFormat?.italic;\n delete modelFormat?.underline;\n delete modelFormat?.fontWeight;\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n Object.assign(\n {},\n modelFormat,\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n )\n );\n\n mergeValue(formatState, 'isCodeInline', !!segment?.code, isFirst);\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n\n // TODO: Support Code block in format state for Content Model\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);\n mergeValue(result, 'fontSize', mergedFormat.fontSize, isFirst);\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);\n\n //TODO: handle block owning segments with different line-heights\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ContentModelParagraph,\n isFirst: boolean\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ContentModelBlockGroup[],\n isFirst: boolean\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst\n );\n}\n\nfunction retrieveTableFormat(tableContext: TableSelectionContext, result: ContentModelFormatState) {\n const tableFormat = updateTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (newValue !== format[key]) {\n delete format[key];\n }\n}\n\nfunction px2Pt(px: string) {\n if (px && px.indexOf('px') == px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value is a little less than actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n return px;\n}\n"]}
1
+ {"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/common/retrieveModelFormatState.ts"],"names":[],"mappings":";;;;IAqBA;;OAEG;IACH,SAAgB,wBAAwB,CACpC,KAA2B,EAC3B,aAA+C,EAC/C,WAAoC;QAEpC,IAAI,iBAAoD,CAAC;QACzD,IAAI,UAAyC,CAAC;QAC9C,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,YAAY,GAAG,IAAI,CAAC;QACxB,IAAI,cAAc,GAAG,IAAI,CAAC;QAE1B,IAAA,gDAAiB,EACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ;YAChC,oBAAoB;YACpB,uBAAuB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YAEpD,uBAAuB;YACvB,IAAI,KAAK,EAAE;gBACP,IAAI,UAAU,EAAE;oBACZ,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC;iBAC3C;qBAAM;oBACH,UAAU,GAAG,KAAK,CAAC;iBACtB;aACJ;YAED,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,WAAW,EAAE;gBACjC,oBAAoB;gBACpB,uBAAuB,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;gBAErD,kBAAkB;gBAClB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,UAAA,OAAO;;oBACrB,IAAI,cAAc,IAAI,OAAO,CAAC,WAAW,IAAI,iBAAiB,EAAE;wBAC5D,IAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;wBAC7C,WAAW,aAAX,WAAW,4BAAX,WAAW,CAAE,MAAM,CAAC;wBACpB,WAAW,aAAX,WAAW,4BAAX,WAAW,CAAE,SAAS,CAAC;wBACvB,WAAW,aAAX,WAAW,4BAAX,WAAW,CAAE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AI,OAAO,EAAE;YACT,IAAI,QAAQ,KAAK,SAAS,EAAE;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;aAC1B;SACJ;aAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;YACnD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;IACL,CAAC;IAED,SAAS,KAAK,CAAC,EAAU;QACrB,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YACzC,uHAAuH;YACvH,wBAAwB;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;SAC9D;QACD,OAAO,EAAE,CAAC;IACd,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getClosestAncestorBlockGroupIndex,\n isBold,\n iterateSelections,\n updateTableMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelFormatState,\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelFormatContainer,\n ContentModelImage,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function retrieveModelFormatState(\n model: ContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState\n) {\n let firstTableContext: TableSelectionContext | undefined;\n let firstBlock: ContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n const modelFormat = Object.assign({}, model.format);\n delete modelFormat?.italic;\n delete modelFormat?.underline;\n delete modelFormat?.fontWeight;\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n Object.assign(\n {},\n modelFormat,\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n )\n );\n\n mergeValue(formatState, 'isCodeInline', !!segment?.code, isFirst);\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n\n // TODO: Support Code block in format state for Content Model\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst);\n\n //TODO: handle block owning segments with different line-heights\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ContentModelParagraph,\n isFirst: boolean\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ContentModelBlockGroup[],\n isFirst: boolean\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst\n );\n}\n\nfunction retrieveTableFormat(tableContext: TableSelectionContext, result: ContentModelFormatState) {\n const tableFormat = updateTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n delete format[key];\n }\n}\n\nfunction px2Pt(px: string) {\n if (px && px.indexOf('px') == px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value is a little less than actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n return px;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ContentModelDocument } from 'roosterjs-content-model-types';
2
+ /**
3
+ * If a format cannot be applied to be applied to a trailing space, split the trailing space into a separate segment
4
+ * @internal
5
+ */
6
+ export declare function adjustTrailingSpaceSelection(model: ContentModelDocument): void;
@@ -0,0 +1,55 @@
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, tslib_1, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.adjustTrailingSpaceSelection = void 0;
5
+ /**
6
+ * If a format cannot be applied to be applied to a trailing space, split the trailing space into a separate segment
7
+ * @internal
8
+ */
9
+ function adjustTrailingSpaceSelection(model) {
10
+ (0, roosterjs_content_model_core_1.iterateSelections)(model, function (_, __, block, segments) {
11
+ if ((block === null || block === void 0 ? void 0 : block.blockType) === 'Paragraph' && segments && segments.length > 0) {
12
+ if (segments.length === 1 &&
13
+ segments[0].segmentType === 'Text' &&
14
+ shouldSplitTrailingSpace(segments[0])) {
15
+ splitTextSegment(block, segments[0]);
16
+ }
17
+ else {
18
+ var lastTextSegment = segments[segments.length - 1].segmentType === 'SelectionMarker'
19
+ ? segments[segments.length - 2]
20
+ : segments[segments.length - 1];
21
+ if (lastTextSegment &&
22
+ lastTextSegment.segmentType === 'Text' &&
23
+ shouldSplitTrailingSpace(lastTextSegment)) {
24
+ splitTextSegment(block, lastTextSegment);
25
+ }
26
+ }
27
+ }
28
+ return false;
29
+ });
30
+ }
31
+ exports.adjustTrailingSpaceSelection = adjustTrailingSpaceSelection;
32
+ function shouldSplitTrailingSpace(segment) {
33
+ return segment.isSelected && hasTrailingSpace(segment.text) && !isTrailingSpace(segment.text);
34
+ }
35
+ function hasTrailingSpace(text) {
36
+ return text.trimRight() !== text;
37
+ }
38
+ function isTrailingSpace(text) {
39
+ return text.trimRight().length == 0;
40
+ }
41
+ function splitTextSegment(block, textSegment) {
42
+ var _a;
43
+ var text = textSegment.text.trimRight();
44
+ var trailingSpace = textSegment.text.substring(text.length);
45
+ var newText = (0, roosterjs_content_model_dom_1.createText)(text, textSegment.format, textSegment.link, textSegment.code);
46
+ newText.isSelected = true;
47
+ var trailingSpaceLink = textSegment.link
48
+ ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, textSegment.link), { format: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (_a = textSegment.link) === null || _a === void 0 ? void 0 : _a.format), { underline: false }) }) : undefined;
49
+ var trailingSpaceSegment = (0, roosterjs_content_model_dom_1.createText)(trailingSpace, undefined, trailingSpaceLink, textSegment.code);
50
+ trailingSpaceSegment.isSelected = true;
51
+ var index = block.segments.indexOf(textSegment);
52
+ block.segments.splice(index, 1, newText, trailingSpaceSegment);
53
+ }
54
+ });
55
+ //# sourceMappingURL=adjustTrailingSpaceSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adjustTrailingSpaceSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/selection/adjustTrailingSpaceSelection.ts"],"names":[],"mappings":";;;;IAQA;;;OAGG;IACH,SAAgB,4BAA4B,CAAC,KAA2B;QACpE,IAAA,gDAAiB,EAAC,KAAK,EAAE,UAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ;YAC5C,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,WAAW,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrE,IACI,QAAQ,CAAC,MAAM,KAAK,CAAC;oBACrB,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,MAAM;oBAClC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EACvC;oBACE,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxC;qBAAM;oBACH,IAAM,eAAe,GACjB,QAAQ,CAAC,QAAQ,CAAC,MAAM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C,IAAI;YACtC,CAAC,iDACQ,WAAW,CAAC,IAAI,KACnB,MAAM,kDACC,MAAA,WAAW,CAAC,IAAI,0CAAE,MAAM,KAC3B,SAAS,EAAE,KAAK,OAG1B,CAAC,CAAC,SAAS,CAAC;QAChB,IAAM,oBAAoB,GAAG,IAAA,wCAAU,EACnC,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,CAAC,IAAI,CACnB,CAAC;QACF,oBAAoB,CAAC,UAAU,GAAG,IAAI,CAAC;QACvC,IAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACnE,CAAC","sourcesContent":["import { createText } from 'roosterjs-content-model-dom';\nimport { iterateSelections } from 'roosterjs-content-model-core';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelText,\n} from 'roosterjs-content-model-types';\n\n/**\n * If a format cannot be applied to be applied to a trailing space, split the trailing space into a separate segment\n * @internal\n */\nexport function adjustTrailingSpaceSelection(model: ContentModelDocument) {\n iterateSelections(model, (_, __, block, segments) => {\n if (block?.blockType === 'Paragraph' && segments && segments.length > 0) {\n if (\n segments.length === 1 &&\n segments[0].segmentType === 'Text' &&\n shouldSplitTrailingSpace(segments[0])\n ) {\n splitTextSegment(block, segments[0]);\n } else {\n const lastTextSegment =\n segments[segments.length - 1].segmentType === 'SelectionMarker'\n ? segments[segments.length - 2]\n : segments[segments.length - 1];\n if (\n lastTextSegment &&\n lastTextSegment.segmentType === 'Text' &&\n shouldSplitTrailingSpace(lastTextSegment)\n ) {\n splitTextSegment(block, lastTextSegment);\n }\n }\n }\n\n return false;\n });\n}\n\nfunction shouldSplitTrailingSpace(segment: ContentModelText) {\n return segment.isSelected && hasTrailingSpace(segment.text) && !isTrailingSpace(segment.text);\n}\n\nfunction hasTrailingSpace(text: string) {\n return text.trimRight() !== text;\n}\n\nfunction isTrailingSpace(text: string) {\n return text.trimRight().length == 0;\n}\n\nfunction splitTextSegment(block: ContentModelParagraph, textSegment: Readonly<ContentModelText>) {\n const text = textSegment.text.trimRight();\n const trailingSpace = textSegment.text.substring(text.length);\n const newText = createText(text, textSegment.format, textSegment.link, textSegment.code);\n newText.isSelected = true;\n const trailingSpaceLink = textSegment.link\n ? {\n ...textSegment.link,\n format: {\n ...textSegment.link?.format,\n underline: false, // Remove underline for trailing space link\n },\n }\n : undefined;\n const trailingSpaceSegment = createText(\n trailingSpace,\n undefined,\n trailingSpaceLink,\n textSegment.code\n );\n trailingSpaceSegment.isSelected = true;\n const index = block.segments.indexOf(textSegment);\n block.segments.splice(index, 1, newText, trailingSpaceSegment);\n}\n"]}
@@ -4,4 +4,4 @@ import type { IStandaloneEditor } from 'roosterjs-content-model-types';
4
4
  * @param editor The editor to set alignment
5
5
  * @param alignment Alignment value: left, center or right
6
6
  */
7
- export default function setAlignment(editor: IStandaloneEditor, alignment: 'left' | 'center' | 'right'): void;
7
+ export default function setAlignment(editor: IStandaloneEditor, alignment: 'left' | 'center' | 'right' | 'justify'): void;
@@ -1 +1 @@
1
- {"version":3,"file":"setAlignment.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/block/setAlignment.ts"],"names":[],"mappings":";;;IAGA;;;;OAIG;IACH,SAAwB,YAAY,CAChC,MAAyB,EACzB,SAAsC;QAEtC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CAAC,UAAA,KAAK,IAAI,OAAA,IAAA,qCAAiB,EAAC,KAAK,EAAE,SAAS,CAAC,EAAnC,CAAmC,EAAE;YACpE,OAAO,EAAE,cAAc;SAC1B,CAAC,CAAC;IACP,CAAC;IATD,+BASC","sourcesContent":["import { setModelAlignment } from '../../modelApi/block/setModelAlignment';\nimport type { IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set text alignment of selected paragraphs\n * @param editor The editor to set alignment\n * @param alignment Alignment value: left, center or right\n */\nexport default function setAlignment(\n editor: IStandaloneEditor,\n alignment: 'left' | 'center' | 'right'\n) {\n editor.focus();\n\n editor.formatContentModel(model => setModelAlignment(model, alignment), {\n apiName: 'setAlignment',\n });\n}\n"]}
1
+ {"version":3,"file":"setAlignment.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/block/setAlignment.ts"],"names":[],"mappings":";;;IAGA;;;;OAIG;IACH,SAAwB,YAAY,CAChC,MAAyB,EACzB,SAAkD;QAElD,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CAAC,UAAA,KAAK,IAAI,OAAA,IAAA,qCAAiB,EAAC,KAAK,EAAE,SAAS,CAAC,EAAnC,CAAmC,EAAE;YACpE,OAAO,EAAE,cAAc;SAC1B,CAAC,CAAC;IACP,CAAC;IATD,+BASC","sourcesContent":["import { setModelAlignment } from '../../modelApi/block/setModelAlignment';\nimport type { IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set text alignment of selected paragraphs\n * @param editor The editor to set alignment\n * @param alignment Alignment value: left, center or right\n */\nexport default function setAlignment(\n editor: IStandaloneEditor,\n alignment: 'left' | 'center' | 'right' | 'justify'\n) {\n editor.focus();\n\n editor.formatContentModel(model => setModelAlignment(model, alignment), {\n apiName: 'setAlignment',\n });\n}\n"]}
@@ -20,7 +20,7 @@ define(["require", "exports", "../utils/formatImageWithContentModel", "roosterjs
20
20
  image.format.width = '';
21
21
  image.format.height = '';
22
22
  image.alt = '';
23
- editor.triggerPluginEvent(19 /* EditImage */, {
23
+ editor.triggerEvent('editImage', {
24
24
  image: selection.image,
25
25
  previousSrc: previousSrc,
26
26
  newSrc: dataUrl,
@@ -1 +1 @@
1
- {"version":3,"file":"changeImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts"],"names":[],"mappings":";;;IAKA;;;;OAIG;IACH,SAAwB,WAAW,CAAC,MAAyB,EAAE,IAAU;QACrE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3C,IAAA,uCAAQ,EAAC,IAAI,EAAE,UAAA,OAAO;YAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,OAAO,EAAE;gBAChE,IAAA,qCAA2B,EAAC,MAAM,EAAE,aAAa,EAAE,UAAC,KAAwB;;oBACxE,IAAM,WAAW,GAAG,MAAA,MAAA,IAAA,kDAAmB,EAAC,KAAK,CAAC,0CAAE,GAAG,mCAAI,EAAE,CAAC;oBAC1D,IAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;oBAE9B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;oBACpB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;oBACnB,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;oBACxB,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;oBACzB,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;oBAEf,MAAM,CAAC,kBAAkB,qBAA4B;wBACjD,KAAK,EAAE,SAAS,CAAC,KAAK;wBACtB,WAAW,aAAA;wBACX,MAAM,EAAE,OAAO;wBACf,WAAW,aAAA;qBACd,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAzBD,8BAyBC","sourcesContent":["import formatImageWithContentModel from '../utils/formatImageWithContentModel';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport { readFile, updateImageMetadata } from 'roosterjs-content-model-core';\nimport type { ContentModelImage, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Change the selected image src\n * @param editor The editor instance\n * @param file The image file\n */\nexport default function changeImage(editor: IStandaloneEditor, file: File) {\n editor.focus();\n\n const selection = editor.getDOMSelection();\n readFile(file, dataUrl => {\n if (dataUrl && !editor.isDisposed() && selection?.type === 'image') {\n formatImageWithContentModel(editor, 'changeImage', (image: ContentModelImage) => {\n const originalSrc = updateImageMetadata(image)?.src ?? '';\n const previousSrc = image.src;\n\n image.src = dataUrl;\n image.dataset = {};\n image.format.width = '';\n image.format.height = '';\n image.alt = '';\n\n editor.triggerPluginEvent(PluginEventType.EditImage, {\n image: selection.image,\n previousSrc,\n newSrc: dataUrl,\n originalSrc,\n });\n });\n }\n });\n}\n"]}
1
+ {"version":3,"file":"changeImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts"],"names":[],"mappings":";;;IAIA;;;;OAIG;IACH,SAAwB,WAAW,CAAC,MAAyB,EAAE,IAAU;QACrE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3C,IAAA,uCAAQ,EAAC,IAAI,EAAE,UAAA,OAAO;YAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,OAAO,EAAE;gBAChE,IAAA,qCAA2B,EAAC,MAAM,EAAE,aAAa,EAAE,UAAC,KAAwB;;oBACxE,IAAM,WAAW,GAAG,MAAA,MAAA,IAAA,kDAAmB,EAAC,KAAK,CAAC,0CAAE,GAAG,mCAAI,EAAE,CAAC;oBAC1D,IAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;oBAE9B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;oBACpB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;oBACnB,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;oBACxB,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;oBACzB,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;oBAEf,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;wBAC7B,KAAK,EAAE,SAAS,CAAC,KAAK;wBACtB,WAAW,aAAA;wBACX,MAAM,EAAE,OAAO;wBACf,WAAW,aAAA;qBACd,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAzBD,8BAyBC","sourcesContent":["import formatImageWithContentModel from '../utils/formatImageWithContentModel';\nimport { readFile, updateImageMetadata } from 'roosterjs-content-model-core';\nimport type { ContentModelImage, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Change the selected image src\n * @param editor The editor instance\n * @param file The image file\n */\nexport default function changeImage(editor: IStandaloneEditor, file: File) {\n editor.focus();\n\n const selection = editor.getDOMSelection();\n readFile(file, dataUrl => {\n if (dataUrl && !editor.isDisposed() && selection?.type === 'image') {\n formatImageWithContentModel(editor, 'changeImage', (image: ContentModelImage) => {\n const originalSrc = updateImageMetadata(image)?.src ?? '';\n const previousSrc = image.src;\n\n image.src = dataUrl;\n image.dataset = {};\n image.format.width = '';\n image.format.height = '';\n image.alt = '';\n\n editor.triggerEvent('editImage', {\n image: selection.image,\n previousSrc,\n newSrc: dataUrl,\n originalSrc,\n });\n });\n }\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-core", "roosterjs-editor-dom", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_core_1, roosterjs_editor_dom_1, roosterjs_content_model_dom_1) {
1
+ define(["require", "exports", "tslib", "../../modelApi/selection/adjustTrailingSpaceSelection", "roosterjs-content-model-core", "roosterjs-editor-dom", "roosterjs-content-model-dom"], function (require, exports, tslib_1, adjustTrailingSpaceSelection_1, roosterjs_content_model_core_1, roosterjs_editor_dom_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  // Regex matching Uri scheme
@@ -59,6 +59,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core", "roosterj
59
59
  mergeFormat: 'mergeAll',
60
60
  });
61
61
  }
62
+ (0, adjustTrailingSpaceSelection_1.adjustTrailingSpaceSelection)(model);
62
63
  return segments.length > 0;
63
64
  }, {
64
65
  changeSource: roosterjs_content_model_core_1.ChangeSource.CreateLink,