roosterjs-content-model-api 9.45.1 → 9.46.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 (85) hide show
  1. package/lib/modelApi/common/clearModelFormat.js +12 -5
  2. package/lib/modelApi/common/clearModelFormat.js.map +1 -1
  3. package/lib/modelApi/list/setListType.js +6 -2
  4. package/lib/modelApi/list/setListType.js.map +1 -1
  5. package/lib/modelApi/table/alignTableCell.js +22 -7
  6. package/lib/modelApi/table/alignTableCell.js.map +1 -1
  7. package/lib/modelApi/table/copyPreviousCellSegmentFormat.d.ts +5 -0
  8. package/lib/modelApi/table/copyPreviousCellSegmentFormat.js +24 -0
  9. package/lib/modelApi/table/copyPreviousCellSegmentFormat.js.map +1 -0
  10. package/lib/modelApi/table/insertTableColumn.js +2 -0
  11. package/lib/modelApi/table/insertTableColumn.js.map +1 -1
  12. package/lib/modelApi/table/insertTableRow.js +2 -0
  13. package/lib/modelApi/table/insertTableRow.js.map +1 -1
  14. package/lib/modelApi/table/shiftCells.d.ts +5 -0
  15. package/lib/modelApi/table/shiftCells.js +50 -0
  16. package/lib/modelApi/table/shiftCells.js.map +1 -0
  17. package/lib/modelApi/table/tableContent.d.ts +9 -0
  18. package/lib/modelApi/table/tableContent.js +118 -0
  19. package/lib/modelApi/table/tableContent.js.map +1 -0
  20. package/lib/publicApi/link/insertLink.js +2 -4
  21. package/lib/publicApi/link/insertLink.js.map +1 -1
  22. package/lib/publicApi/table/editTable.js +5 -0
  23. package/lib/publicApi/table/editTable.js.map +1 -1
  24. package/lib/publicApi/table/insertTable.js +5 -1
  25. package/lib/publicApi/table/insertTable.js.map +1 -1
  26. package/lib/publicApi/utils/checkXss.d.ts +8 -0
  27. package/lib/publicApi/utils/checkXss.js +15 -0
  28. package/lib/publicApi/utils/checkXss.js.map +1 -0
  29. package/lib-amd/modelApi/common/clearModelFormat.js +12 -5
  30. package/lib-amd/modelApi/common/clearModelFormat.js.map +1 -1
  31. package/lib-amd/modelApi/list/setListType.js +6 -2
  32. package/lib-amd/modelApi/list/setListType.js.map +1 -1
  33. package/lib-amd/modelApi/table/alignTableCell.js +22 -8
  34. package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
  35. package/lib-amd/modelApi/table/copyPreviousCellSegmentFormat.d.ts +5 -0
  36. package/lib-amd/modelApi/table/copyPreviousCellSegmentFormat.js +25 -0
  37. package/lib-amd/modelApi/table/copyPreviousCellSegmentFormat.js.map +1 -0
  38. package/lib-amd/modelApi/table/insertTableColumn.js +2 -1
  39. package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
  40. package/lib-amd/modelApi/table/insertTableRow.js +2 -1
  41. package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
  42. package/lib-amd/modelApi/table/shiftCells.d.ts +5 -0
  43. package/lib-amd/modelApi/table/shiftCells.js +50 -0
  44. package/lib-amd/modelApi/table/shiftCells.js.map +1 -0
  45. package/lib-amd/modelApi/table/tableContent.d.ts +9 -0
  46. package/lib-amd/modelApi/table/tableContent.js +118 -0
  47. package/lib-amd/modelApi/table/tableContent.js.map +1 -0
  48. package/lib-amd/publicApi/link/insertLink.js +2 -5
  49. package/lib-amd/publicApi/link/insertLink.js.map +1 -1
  50. package/lib-amd/publicApi/table/editTable.js +5 -1
  51. package/lib-amd/publicApi/table/editTable.js.map +1 -1
  52. package/lib-amd/publicApi/table/insertTable.js +5 -2
  53. package/lib-amd/publicApi/table/insertTable.js.map +1 -1
  54. package/lib-amd/publicApi/utils/checkXss.d.ts +8 -0
  55. package/lib-amd/publicApi/utils/checkXss.js +17 -0
  56. package/lib-amd/publicApi/utils/checkXss.js.map +1 -0
  57. package/lib-mjs/modelApi/common/clearModelFormat.js +13 -6
  58. package/lib-mjs/modelApi/common/clearModelFormat.js.map +1 -1
  59. package/lib-mjs/modelApi/list/setListType.js +6 -2
  60. package/lib-mjs/modelApi/list/setListType.js.map +1 -1
  61. package/lib-mjs/modelApi/table/alignTableCell.js +22 -7
  62. package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
  63. package/lib-mjs/modelApi/table/copyPreviousCellSegmentFormat.d.ts +5 -0
  64. package/lib-mjs/modelApi/table/copyPreviousCellSegmentFormat.js +20 -0
  65. package/lib-mjs/modelApi/table/copyPreviousCellSegmentFormat.js.map +1 -0
  66. package/lib-mjs/modelApi/table/insertTableColumn.js +2 -0
  67. package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
  68. package/lib-mjs/modelApi/table/insertTableRow.js +2 -0
  69. package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
  70. package/lib-mjs/modelApi/table/shiftCells.d.ts +5 -0
  71. package/lib-mjs/modelApi/table/shiftCells.js +46 -0
  72. package/lib-mjs/modelApi/table/shiftCells.js.map +1 -0
  73. package/lib-mjs/modelApi/table/tableContent.d.ts +9 -0
  74. package/lib-mjs/modelApi/table/tableContent.js +113 -0
  75. package/lib-mjs/modelApi/table/tableContent.js.map +1 -0
  76. package/lib-mjs/publicApi/link/insertLink.js +1 -3
  77. package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
  78. package/lib-mjs/publicApi/table/editTable.js +5 -0
  79. package/lib-mjs/publicApi/table/editTable.js.map +1 -1
  80. package/lib-mjs/publicApi/table/insertTable.js +5 -1
  81. package/lib-mjs/publicApi/table/insertTable.js.map +1 -1
  82. package/lib-mjs/publicApi/utils/checkXss.d.ts +8 -0
  83. package/lib-mjs/publicApi/utils/checkXss.js +11 -0
  84. package/lib-mjs/publicApi/utils/checkXss.js.map +1 -0
  85. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"insertTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACH,0BAA0B,EAC1B,qBAAq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AO,EAAE,CAAC;KACb;AACL,CAAC","sourcesContent":["import { adjustTableIndentation } from '../../modelApi/common/adjustIndentation';\nimport { createTableStructure } from '../../modelApi/table/createTableStructure';\nimport {\n createContentModelDocument,\n createSelectionMarker,\n applyTableFormat,\n deleteSelection,\n mergeModel,\n normalizeTable,\n setSelection,\n MIN_ALLOWED_TABLE_CELL_WIDTH,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTable,\n ContentModelTableFormat,\n IEditor,\n TableMetadataFormat,\n ContentModelTableCellFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert table into editor at current selection\n * @param editor The editor instance\n * @param columns Number of columns in table, it also controls the default table cell width:\n * if columns &lt;= 4, width = 120px; if columns &lt;= 6, width = 100px; else width = 70px\n * @param rows Number of rows in table\n * @param tableMetadataFormat (Optional) The table format that are stored as metadata. If not passed, the default format will be applied: background color: #FFF; border color: #ABABAB\n * @param format (Optional) The table format used for style attributes\n * @param cellFormat (Optional) custom format for table cells, except for borders styles, for borders use tableMetadataFormat\n */\nexport function insertTable(\n editor: IEditor,\n columns: number,\n rows: number,\n tableMetadataFormat?: Partial<TableMetadataFormat>,\n format?: ContentModelTableFormat,\n customCellFormat?: ContentModelTableCellFormat\n) {\n editor.focus();\n\n editor.formatContentModel(\n (model, context) => {\n const insertPosition = deleteSelection(model, [], context).insertPoint;\n\n if (insertPosition) {\n const doc = createContentModelDocument();\n const table = createTableStructure(doc, columns, rows, customCellFormat);\n if (format) {\n table.format = { ...format };\n }\n\n normalizeTable(table, editor.getPendingFormat() || insertPosition.marker.format);\n initCellWidth(table);\n\n adjustTableIndentation(insertPosition, table);\n\n // Assign default vertical align\n tableMetadataFormat = tableMetadataFormat || { verticalAlign: 'top' };\n applyTableFormat(table, tableMetadataFormat);\n mergeModel(model, doc, context, {\n insertPosition,\n mergeFormat: 'mergeAll',\n });\n\n const firstBlock = table.rows[0]?.cells[0]?.blocks[0];\n\n if (firstBlock?.blockType == 'Paragraph') {\n const marker = createSelectionMarker(firstBlock.segments[0]?.format);\n firstBlock.segments.unshift(marker);\n setSelection(model, marker);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'insertTable',\n }\n );\n}\n\nfunction initCellWidth(table: ContentModelTable) {\n const columns = Math.max(...table.rows.map(row => row.cells.length));\n\n for (let i = 0; i < columns; i++) {\n if (table.widths[i] === undefined) {\n table.widths[i] = getTableCellWidth(columns);\n } else if (table.widths[i] < MIN_ALLOWED_TABLE_CELL_WIDTH) {\n table.widths[i] = MIN_ALLOWED_TABLE_CELL_WIDTH;\n }\n }\n}\n\nfunction getTableCellWidth(columns: number): number {\n if (columns <= 4) {\n return 120;\n } else if (columns <= 6) {\n return 100;\n } else {\n return 70;\n }\n}\n"]}
1
+ {"version":3,"file":"insertTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EACH,0BAA0B,EAC1B,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,cAAc,EACd,YAAY,EACZ,4BAA4B,GAC/B,MAAM,6BAA6B,CAAC;AASrC;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACvB,MAAe,EACf,OAAe,EACf,IAAY,EACZ,mBAAkD,EAClD,MAAgC,EAChC,gBAA8C;IAE9C,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,IAAM,MAAM,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAElD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;QACX,IAAM,qBAAqB,GAAG,eAAe,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;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CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;aAC/B;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,EAAE,aAAa;KACzB,CACJ,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,KAAwB;IAC3C,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,OAAR,IAAI,2BAAQ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,MAAM,EAAhB,CAAgB,CAAC,UAAC,CAAC;IAErE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE;QAC9B,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;SAChD;aAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,4BAA4B,EAAE;YACvD,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC;SAClD;KACJ;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe;IACtC,IAAI,OAAO,IAAI,CAAC,EAAE;QACd,OAAO,GAAG,CAAC;KACd;SAAM,IAAI,OAAO,IAAI,CAAC,EAAE;QACrB,OAAO,GAAG,CAAC;KACd;SAAM;QACH,OAAO,EAAE,CAAC;KACb;AACL,CAAC","sourcesContent":["import { adjustTableIndentation } from '../../modelApi/common/adjustIndentation';\nimport { createTableStructure } from '../../modelApi/table/createTableStructure';\nimport { getSelectedContentForTable, insertTableContent } from '../../modelApi/table/tableContent';\nimport {\n createContentModelDocument,\n createSelectionMarker,\n applyTableFormat,\n deleteSelection,\n mergeModel,\n normalizeTable,\n setSelection,\n MIN_ALLOWED_TABLE_CELL_WIDTH,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTable,\n ContentModelTableFormat,\n IEditor,\n TableMetadataFormat,\n ContentModelTableCellFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert table into editor at current selection\n * @param editor The editor instance\n * @param columns Number of columns in table, it also controls the default table cell width:\n * if columns &lt;= 4, width = 120px; if columns &lt;= 6, width = 100px; else width = 70px\n * @param rows Number of rows in table\n * @param tableMetadataFormat (Optional) The table format that are stored as metadata. If not passed, the default format will be applied: background color: #FFF; border color: #ABABAB\n * @param format (Optional) The table format used for style attributes\n * @param cellFormat (Optional) custom format for table cells, except for borders styles, for borders use tableMetadataFormat\n */\nexport function insertTable(\n editor: IEditor,\n columns: number,\n rows: number,\n tableMetadataFormat?: Partial<TableMetadataFormat>,\n format?: ContentModelTableFormat,\n customCellFormat?: ContentModelTableCellFormat\n) {\n editor.focus();\n\n const blocks = getSelectedContentForTable(editor);\n\n editor.formatContentModel(\n (model, context) => {\n const deleteSelectionResult = deleteSelection(model, [], context);\n const insertPosition = deleteSelectionResult.insertPoint;\n\n if (insertPosition) {\n const doc = createContentModelDocument();\n\n const table = createTableStructure(doc, columns, rows, customCellFormat);\n\n if (format) {\n table.format = { ...format };\n }\n\n normalizeTable(table, editor.getPendingFormat() || insertPosition.marker.format);\n initCellWidth(table);\n\n insertTableContent(table, blocks, columns, customCellFormat);\n\n adjustTableIndentation(insertPosition, table);\n\n // Assign default vertical align\n tableMetadataFormat = tableMetadataFormat || { verticalAlign: 'top' };\n applyTableFormat(table, tableMetadataFormat);\n\n mergeModel(model, doc, context, {\n insertPosition,\n mergeFormat: 'mergeAll',\n });\n\n const firstBlock = table.rows[0]?.cells[0]?.blocks[0];\n\n if (firstBlock?.blockType == 'Paragraph') {\n const marker = createSelectionMarker(firstBlock.segments[0]?.format);\n firstBlock.segments.unshift(marker);\n setSelection(model, marker);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'insertTable',\n }\n );\n}\n\nfunction initCellWidth(table: ContentModelTable) {\n const columns = Math.max(...table.rows.map(row => row.cells.length));\n\n for (let i = 0; i < columns; i++) {\n if (table.widths[i] === undefined) {\n table.widths[i] = getTableCellWidth(columns);\n } else if (table.widths[i] < MIN_ALLOWED_TABLE_CELL_WIDTH) {\n table.widths[i] = MIN_ALLOWED_TABLE_CELL_WIDTH;\n }\n }\n}\n\nfunction getTableCellWidth(columns: number): number {\n if (columns <= 4) {\n return 120;\n } else if (columns <= 6) {\n return 100;\n } else {\n return 70;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @internal Check if there is XSS attack in the link
3
+ * @param link The link to be checked
4
+ * @returns The safe link, or empty string if there is XSS attack
5
+ * @remarks This function checks for patterns like s\nc\nr\ni\np\nt: to prevent XSS attacks. This may block some valid links,
6
+ * but it is necessary for security reasons. We treat the word "script" as safe if there are "/" before it.
7
+ */
8
+ export declare function checkXss(link: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @internal Check if there is XSS attack in the link
3
+ * @param link The link to be checked
4
+ * @returns The safe link, or empty string if there is XSS attack
5
+ * @remarks This function checks for patterns like s\nc\nr\ni\np\nt: to prevent XSS attacks. This may block some valid links,
6
+ * but it is necessary for security reasons. We treat the word "script" as safe if there are "/" before it.
7
+ */
8
+ export function checkXss(link) {
9
+ return link.match(/^[^\/]*s\n*c\n*r\n*i\n*p\n*t\n*:/i) ? '' : link;
10
+ }
11
+ //# sourceMappingURL=checkXss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkXss.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvE,CAAC","sourcesContent":["/**\n * @internal Check if there is XSS attack in the link\n * @param link The link to be checked\n * @returns The safe link, or empty string if there is XSS attack\n * @remarks This function checks for patterns like s\\nc\\nr\\ni\\np\\nt: to prevent XSS attacks. This may block some valid links,\n * but it is necessary for security reasons. We treat the word \"script\" as safe if there are \"/\" before it.\n */\nexport function checkXss(link: string): string {\n return link.match(/^[^\\/]*s\\n*c\\n*r\\n*i\\n*p\\n*t\\n*:/i) ? '' : link;\n}\n"]}
package/package.json CHANGED
@@ -3,16 +3,16 @@
3
3
  "description": "Format API for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-dom": "^9.45.1",
7
- "roosterjs-content-model-types": "^9.45.1"
6
+ "roosterjs-content-model-dom": "^9.46.0",
7
+ "roosterjs-content-model-types": "^9.46.0"
8
8
  },
9
- "version": "9.45.1",
9
+ "version": "9.46.0",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",
13
13
  "license": "MIT",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://github.com/Microsoft/roosterjs.git"
16
+ "url": "https://github.com/Microsoft/roosterjs"
17
17
  }
18
18
  }