roosterjs-content-model-plugins 0.28.2 → 9.0.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 (191) hide show
  1. package/README.md +47 -37
  2. package/lib/autoFormat/AutoFormatPlugin.d.ts +5 -2
  3. package/lib/autoFormat/AutoFormatPlugin.js +23 -11
  4. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
  5. package/lib/autoFormat/link/createLinkAfterSpace.js +28 -22
  6. package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -1
  7. package/lib/autoFormat/link/getLinkSegment.js +2 -2
  8. package/lib/autoFormat/link/getLinkSegment.js.map +1 -1
  9. package/lib/autoFormat/list/getListTypeStyle.js +14 -14
  10. package/lib/autoFormat/list/getListTypeStyle.js.map +1 -1
  11. package/lib/autoFormat/list/getNumberingListStyle.js +29 -29
  12. package/lib/autoFormat/list/getNumberingListStyle.js.map +1 -1
  13. package/lib/autoFormat/list/keyboardListTrigger.d.ts +1 -1
  14. package/lib/autoFormat/list/keyboardListTrigger.js +10 -11
  15. package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
  16. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +2 -2
  17. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  18. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +4 -5
  19. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  20. package/lib/edit/deleteSteps/deleteEmptyQuote.js +2 -3
  21. package/lib/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
  22. package/lib/edit/deleteSteps/deleteList.js +3 -5
  23. package/lib/edit/deleteSteps/deleteList.js.map +1 -1
  24. package/lib/edit/deleteSteps/deleteWordSelection.js +3 -4
  25. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  26. package/lib/edit/inputSteps/handleEnterOnList.js +2 -3
  27. package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
  28. package/lib/edit/keyboardDelete.js +4 -5
  29. package/lib/edit/keyboardDelete.js.map +1 -1
  30. package/lib/edit/keyboardInput.js +3 -4
  31. package/lib/edit/keyboardInput.js.map +1 -1
  32. package/lib/edit/keyboardTab.js +3 -3
  33. package/lib/edit/keyboardTab.js.map +1 -1
  34. package/lib/index.d.ts +3 -0
  35. package/lib/index.js +5 -1
  36. package/lib/index.js.map +1 -1
  37. package/lib/markdown/MarkdownPlugin.d.ts +55 -0
  38. package/lib/markdown/MarkdownPlugin.js +177 -0
  39. package/lib/markdown/MarkdownPlugin.js.map +1 -0
  40. package/lib/markdown/utils/setFormat.d.ts +5 -0
  41. package/lib/markdown/utils/setFormat.js +46 -0
  42. package/lib/markdown/utils/setFormat.js.map +1 -0
  43. package/lib/paste/WordDesktop/processWordLists.js +2 -3
  44. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  45. package/lib/pluginUtils/splitTextSegment.d.ts +5 -0
  46. package/lib/pluginUtils/splitTextSegment.js +26 -0
  47. package/lib/pluginUtils/splitTextSegment.js.map +1 -0
  48. package/lib/shortcut/ShortcutPlugin.js +2 -2
  49. package/lib/shortcut/ShortcutPlugin.js.map +1 -1
  50. package/lib/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  51. package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  52. package/lib/tableEdit/editors/features/CellResizer.js +5 -6
  53. package/lib/tableEdit/editors/features/CellResizer.js.map +1 -1
  54. package/lib/tableEdit/editors/features/TableResizer.js +2 -3
  55. package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
  56. package/lib/watermark/WatermarkFormat.d.ts +5 -0
  57. package/lib/watermark/WatermarkFormat.js +3 -0
  58. package/lib/watermark/WatermarkFormat.js.map +1 -0
  59. package/lib/watermark/WatermarkPlugin.d.ts +37 -0
  60. package/lib/watermark/WatermarkPlugin.js +99 -0
  61. package/lib/watermark/WatermarkPlugin.js.map +1 -0
  62. package/lib/watermark/isModelEmptyFast.d.ts +6 -0
  63. package/lib/watermark/isModelEmptyFast.js +35 -0
  64. package/lib/watermark/isModelEmptyFast.js.map +1 -0
  65. package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +5 -2
  66. package/lib-amd/autoFormat/AutoFormatPlugin.js +23 -11
  67. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
  68. package/lib-amd/autoFormat/link/createLinkAfterSpace.js +28 -22
  69. package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -1
  70. package/lib-amd/autoFormat/link/getLinkSegment.js +2 -2
  71. package/lib-amd/autoFormat/link/getLinkSegment.js.map +1 -1
  72. package/lib-amd/autoFormat/list/getListTypeStyle.js +14 -14
  73. package/lib-amd/autoFormat/list/getListTypeStyle.js.map +1 -1
  74. package/lib-amd/autoFormat/list/getNumberingListStyle.js +29 -29
  75. package/lib-amd/autoFormat/list/getNumberingListStyle.js.map +1 -1
  76. package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +1 -1
  77. package/lib-amd/autoFormat/list/keyboardListTrigger.js +11 -11
  78. package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
  79. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +2 -2
  80. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  81. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +5 -5
  82. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  83. package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js +3 -3
  84. package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
  85. package/lib-amd/edit/deleteSteps/deleteList.js +3 -5
  86. package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
  87. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +4 -4
  88. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  89. package/lib-amd/edit/inputSteps/handleEnterOnList.js +3 -3
  90. package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
  91. package/lib-amd/edit/keyboardDelete.js +4 -4
  92. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  93. package/lib-amd/edit/keyboardInput.js +3 -3
  94. package/lib-amd/edit/keyboardInput.js.map +1 -1
  95. package/lib-amd/edit/keyboardTab.js +3 -3
  96. package/lib-amd/edit/keyboardTab.js.map +1 -1
  97. package/lib-amd/index.d.ts +3 -0
  98. package/lib-amd/index.js +4 -2
  99. package/lib-amd/index.js.map +1 -1
  100. package/lib-amd/markdown/MarkdownPlugin.d.ts +55 -0
  101. package/lib-amd/markdown/MarkdownPlugin.js +178 -0
  102. package/lib-amd/markdown/MarkdownPlugin.js.map +1 -0
  103. package/lib-amd/markdown/utils/setFormat.d.ts +5 -0
  104. package/lib-amd/markdown/utils/setFormat.js +45 -0
  105. package/lib-amd/markdown/utils/setFormat.js.map +1 -0
  106. package/lib-amd/paste/WordDesktop/processWordLists.js +3 -3
  107. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  108. package/lib-amd/pluginUtils/splitTextSegment.d.ts +5 -0
  109. package/lib-amd/pluginUtils/splitTextSegment.js +26 -0
  110. package/lib-amd/pluginUtils/splitTextSegment.js.map +1 -0
  111. package/lib-amd/shortcut/ShortcutPlugin.js +2 -2
  112. package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
  113. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  114. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  115. package/lib-amd/tableEdit/editors/features/CellResizer.js +6 -6
  116. package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -1
  117. package/lib-amd/tableEdit/editors/features/TableResizer.js +3 -3
  118. package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
  119. package/lib-amd/watermark/WatermarkFormat.d.ts +5 -0
  120. package/lib-amd/watermark/WatermarkFormat.js +5 -0
  121. package/lib-amd/watermark/WatermarkFormat.js.map +1 -0
  122. package/lib-amd/watermark/WatermarkPlugin.d.ts +37 -0
  123. package/lib-amd/watermark/WatermarkPlugin.js +99 -0
  124. package/lib-amd/watermark/WatermarkPlugin.js.map +1 -0
  125. package/lib-amd/watermark/isModelEmptyFast.d.ts +6 -0
  126. package/lib-amd/watermark/isModelEmptyFast.js +37 -0
  127. package/lib-amd/watermark/isModelEmptyFast.js.map +1 -0
  128. package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +5 -2
  129. package/lib-mjs/autoFormat/AutoFormatPlugin.js +23 -11
  130. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
  131. package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +28 -22
  132. package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -1
  133. package/lib-mjs/autoFormat/link/getLinkSegment.js +1 -1
  134. package/lib-mjs/autoFormat/link/getLinkSegment.js.map +1 -1
  135. package/lib-mjs/autoFormat/list/getListTypeStyle.js +2 -2
  136. package/lib-mjs/autoFormat/list/getListTypeStyle.js.map +1 -1
  137. package/lib-mjs/autoFormat/list/getNumberingListStyle.js +1 -1
  138. package/lib-mjs/autoFormat/list/getNumberingListStyle.js.map +1 -1
  139. package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +1 -1
  140. package/lib-mjs/autoFormat/list/keyboardListTrigger.js +11 -12
  141. package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
  142. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +1 -1
  143. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  144. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +1 -2
  145. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  146. package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js +1 -2
  147. package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
  148. package/lib-mjs/edit/deleteSteps/deleteList.js +2 -4
  149. package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
  150. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +1 -2
  151. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  152. package/lib-mjs/edit/inputSteps/handleEnterOnList.js +1 -2
  153. package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
  154. package/lib-mjs/edit/keyboardDelete.js +1 -2
  155. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  156. package/lib-mjs/edit/keyboardInput.js +1 -2
  157. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  158. package/lib-mjs/edit/keyboardTab.js +1 -1
  159. package/lib-mjs/edit/keyboardTab.js.map +1 -1
  160. package/lib-mjs/index.d.ts +3 -0
  161. package/lib-mjs/index.js +2 -0
  162. package/lib-mjs/index.js.map +1 -1
  163. package/lib-mjs/markdown/MarkdownPlugin.d.ts +55 -0
  164. package/lib-mjs/markdown/MarkdownPlugin.js +174 -0
  165. package/lib-mjs/markdown/MarkdownPlugin.js.map +1 -0
  166. package/lib-mjs/markdown/utils/setFormat.d.ts +5 -0
  167. package/lib-mjs/markdown/utils/setFormat.js +42 -0
  168. package/lib-mjs/markdown/utils/setFormat.js.map +1 -0
  169. package/lib-mjs/paste/WordDesktop/processWordLists.js +1 -2
  170. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  171. package/lib-mjs/pluginUtils/splitTextSegment.d.ts +5 -0
  172. package/lib-mjs/pluginUtils/splitTextSegment.js +22 -0
  173. package/lib-mjs/pluginUtils/splitTextSegment.js.map +1 -0
  174. package/lib-mjs/shortcut/ShortcutPlugin.js +1 -1
  175. package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
  176. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +1 -1
  177. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  178. package/lib-mjs/tableEdit/editors/features/CellResizer.js +1 -2
  179. package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -1
  180. package/lib-mjs/tableEdit/editors/features/TableResizer.js +1 -2
  181. package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
  182. package/lib-mjs/watermark/WatermarkFormat.d.ts +5 -0
  183. package/lib-mjs/watermark/WatermarkFormat.js +2 -0
  184. package/lib-mjs/watermark/WatermarkFormat.js.map +1 -0
  185. package/lib-mjs/watermark/WatermarkPlugin.d.ts +37 -0
  186. package/lib-mjs/watermark/WatermarkPlugin.js +96 -0
  187. package/lib-mjs/watermark/WatermarkPlugin.js.map +1 -0
  188. package/lib-mjs/watermark/isModelEmptyFast.d.ts +6 -0
  189. package/lib-mjs/watermark/isModelEmptyFast.js +31 -0
  190. package/lib-mjs/watermark/isModelEmptyFast.js.map +1 -0
  191. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"TableResizer.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableResizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI1E,IAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAAuB,EACvB,MAAe,EACf,KAAc,EACd,OAAmB,EACnB,KAAkB,EAClB,UAA+B,EAC/B,eAA6B;IAE7B,IAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAE1D,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAkB,CAAC,EAAE;QACzD,OAAO,IAAI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;IAExB,IAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IACpD,IAAI,YAAY,CAAC,UAAU,EAAE,cAAc,CAAC,IAAI,eAAe,IAAI,IAAI,EAAE;QACrE,IAAM,aAAa,GAAG,aAAa,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAExE,OAAO,CACH,CAAC,CAAC,aAAa;YACf,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;YACnC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CACxC,CAAC;KACL;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport { getFirstSelectedTable, normalizeTable } from 'roosterjs-content-model-core';\nimport { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\n\nconst TABLE_RESIZER_LENGTH = 12;\nconst TABLE_RESIZER_ID = '_Table_Resizer';\n\n/**\n * @internal\n */\nexport function createTableResizer(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onStart: () => void,\n onEnd: () => false,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableBottomVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const document = table.ownerDocument;\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const createElementData = {\n tag: 'div',\n style: `position: fixed; cursor: ${\n isRTL ? 'ne' : 'nw'\n }-resize; user-select: none; border: 1px solid #808080`,\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_RESIZER_ID;\n div.style.width = `${TABLE_RESIZER_LENGTH}px`;\n div.style.height = `${TABLE_RESIZER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: DragAndDropContext = {\n isRTL,\n table,\n zoomScale,\n onStart,\n onEnd,\n div,\n editor,\n contentDiv,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new DragAndDropHelper<DragAndDropContext, DragAndDropInitValue>(\n div,\n context,\n hideResizer, // Resizer is hidden while dragging only\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\ninterface DragAndDropContext {\n table: HTMLTableElement;\n isRTL: boolean;\n zoomScale: number;\n onStart: () => void;\n onEnd: () => false;\n div: HTMLDivElement;\n editor: IEditor;\n contentDiv?: EventTarget | null;\n}\n\ninterface DragAndDropInitValue {\n originalRect: DOMRect;\n originalHeights: number[];\n originalWidths: number[];\n cmTable: ContentModelTable | undefined;\n}\n\nfunction onDragStart(context: DragAndDropContext, event: MouseEvent) {\n context.onStart();\n\n const { editor, table } = context;\n\n // Get current selection\n const selection = editor.getDOMSelection();\n\n // Select first cell of the table\n editor.setDOMSelection({\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n });\n\n // Get the table content model\n const cmTable = getFirstSelectedTable(editor.getContentModelCopy('disconnected'))[0];\n\n // Restore selection\n editor.setDOMSelection(selection);\n\n // Save original widths and heights\n const heights: number[] = [];\n cmTable?.rows.forEach(row => {\n heights.push(row.height);\n });\n const widths: number[] = [];\n cmTable?.widths.forEach(width => {\n widths.push(width);\n });\n\n return {\n originalRect: table.getBoundingClientRect(),\n cmTable,\n originalHeights: heights ?? [],\n originalWidths: widths ?? [],\n };\n}\n\nfunction onDragging(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue,\n deltaX: number,\n deltaY: number\n) {\n const { isRTL, zoomScale, table } = context;\n const { originalRect, originalHeights, originalWidths, cmTable } = initValue;\n\n const ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);\n const ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;\n const shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;\n const shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;\n\n // If the width of some external table is fixed, we need to make it resizable\n table.style.setProperty('width', null);\n // If the height of some external table is fixed, we need to make it resizable\n table.style.setProperty('height', null);\n\n // Assign new widths and heights to the CM table\n if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {\n // Modify the CM Table size\n for (let i = 0; i < cmTable.rows.length; i++) {\n for (let j = 0; j < cmTable.rows[i].cells.length; j++) {\n const cell = cmTable.rows[i].cells[j];\n if (cell) {\n if (shouldResizeX && i == 0) {\n cmTable.widths[j] = (originalWidths[j] ?? 0) * ratioX;\n }\n if (shouldResizeY && j == 0) {\n cmTable.rows[i].height = (originalHeights[i] ?? 0) * ratioY;\n }\n }\n }\n }\n\n // Normalize the table\n normalizeTable(cmTable);\n\n // Writeback CM Table size changes to DOM Table\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const td = tableRow.cells[col];\n td.style.width = cmTable.widths[col] + 'px';\n td.style.height = cmTable.rows[row].height + 'px';\n }\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction onDragEnd(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue | undefined\n) {\n if (context.editor.isDisposed()) {\n return false;\n }\n if (\n isTableBottomVisible(\n context.editor,\n normalizeRect(context.table.getBoundingClientRect()),\n context.contentDiv as Node\n )\n ) {\n context.div.style.visibility = 'visible';\n setDivPosition(context, context.div);\n }\n context.onEnd();\n return false;\n}\n\nfunction setDivPosition(context: DragAndDropContext, trigger: HTMLElement) {\n const { table, isRTL } = context;\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (rect) {\n trigger.style.top = `${rect.bottom}px`;\n trigger.style.left = isRTL\n ? `${rect.left - TABLE_RESIZER_LENGTH - 2}px`\n : `${rect.right}px`;\n }\n}\n\nfunction hideResizer(context: DragAndDropContext, trigger: HTMLElement) {\n trigger.style.visibility = 'hidden';\n}\n\nfunction isTableBottomVisible(\n editor: IEditor,\n rect: Rect | null,\n contentDiv?: Node | null\n): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return (\n !!containerRect &&\n containerRect.bottom >= rect.bottom &&\n visibleViewport.bottom >= rect.bottom\n );\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"TableResizer.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableResizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACvF,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,cAAc,GACjB,MAAM,6BAA6B,CAAC;AAIrC,IAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAAuB,EACvB,MAAe,EACf,KAAc,EACd,OAAmB,EACnB,KAAkB,EAClB,UAA+B,EAC/B,eAA6B;IAE7B,IAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAE1D,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAkB,CAAC,EAAE;QACzD,OAAO,IAAI,CAAC;KACf;IAED,IAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC;IACrC,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,kBAA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AAI,IAAI,EAAE;QACrE,IAAM,aAAa,GAAG,aAAa,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAExE,OAAO,CACH,CAAC,CAAC,aAAa;YACf,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;YACnC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CACxC,CAAC;KACL;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport {\n getFirstSelectedTable,\n isNodeOfType,\n normalizeRect,\n normalizeTable,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\n\nconst TABLE_RESIZER_LENGTH = 12;\nconst TABLE_RESIZER_ID = '_Table_Resizer';\n\n/**\n * @internal\n */\nexport function createTableResizer(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onStart: () => void,\n onEnd: () => false,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableBottomVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const document = table.ownerDocument;\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const createElementData = {\n tag: 'div',\n style: `position: fixed; cursor: ${\n isRTL ? 'ne' : 'nw'\n }-resize; user-select: none; border: 1px solid #808080`,\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_RESIZER_ID;\n div.style.width = `${TABLE_RESIZER_LENGTH}px`;\n div.style.height = `${TABLE_RESIZER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: DragAndDropContext = {\n isRTL,\n table,\n zoomScale,\n onStart,\n onEnd,\n div,\n editor,\n contentDiv,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new DragAndDropHelper<DragAndDropContext, DragAndDropInitValue>(\n div,\n context,\n hideResizer, // Resizer is hidden while dragging only\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\ninterface DragAndDropContext {\n table: HTMLTableElement;\n isRTL: boolean;\n zoomScale: number;\n onStart: () => void;\n onEnd: () => false;\n div: HTMLDivElement;\n editor: IEditor;\n contentDiv?: EventTarget | null;\n}\n\ninterface DragAndDropInitValue {\n originalRect: DOMRect;\n originalHeights: number[];\n originalWidths: number[];\n cmTable: ContentModelTable | undefined;\n}\n\nfunction onDragStart(context: DragAndDropContext, event: MouseEvent) {\n context.onStart();\n\n const { editor, table } = context;\n\n // Get current selection\n const selection = editor.getDOMSelection();\n\n // Select first cell of the table\n editor.setDOMSelection({\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n });\n\n // Get the table content model\n const cmTable = getFirstSelectedTable(editor.getContentModelCopy('disconnected'))[0];\n\n // Restore selection\n editor.setDOMSelection(selection);\n\n // Save original widths and heights\n const heights: number[] = [];\n cmTable?.rows.forEach(row => {\n heights.push(row.height);\n });\n const widths: number[] = [];\n cmTable?.widths.forEach(width => {\n widths.push(width);\n });\n\n return {\n originalRect: table.getBoundingClientRect(),\n cmTable,\n originalHeights: heights ?? [],\n originalWidths: widths ?? [],\n };\n}\n\nfunction onDragging(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue,\n deltaX: number,\n deltaY: number\n) {\n const { isRTL, zoomScale, table } = context;\n const { originalRect, originalHeights, originalWidths, cmTable } = initValue;\n\n const ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);\n const ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;\n const shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;\n const shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;\n\n // If the width of some external table is fixed, we need to make it resizable\n table.style.setProperty('width', null);\n // If the height of some external table is fixed, we need to make it resizable\n table.style.setProperty('height', null);\n\n // Assign new widths and heights to the CM table\n if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {\n // Modify the CM Table size\n for (let i = 0; i < cmTable.rows.length; i++) {\n for (let j = 0; j < cmTable.rows[i].cells.length; j++) {\n const cell = cmTable.rows[i].cells[j];\n if (cell) {\n if (shouldResizeX && i == 0) {\n cmTable.widths[j] = (originalWidths[j] ?? 0) * ratioX;\n }\n if (shouldResizeY && j == 0) {\n cmTable.rows[i].height = (originalHeights[i] ?? 0) * ratioY;\n }\n }\n }\n }\n\n // Normalize the table\n normalizeTable(cmTable);\n\n // Writeback CM Table size changes to DOM Table\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const td = tableRow.cells[col];\n td.style.width = cmTable.widths[col] + 'px';\n td.style.height = cmTable.rows[row].height + 'px';\n }\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction onDragEnd(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue | undefined\n) {\n if (context.editor.isDisposed()) {\n return false;\n }\n if (\n isTableBottomVisible(\n context.editor,\n normalizeRect(context.table.getBoundingClientRect()),\n context.contentDiv as Node\n )\n ) {\n context.div.style.visibility = 'visible';\n setDivPosition(context, context.div);\n }\n context.onEnd();\n return false;\n}\n\nfunction setDivPosition(context: DragAndDropContext, trigger: HTMLElement) {\n const { table, isRTL } = context;\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (rect) {\n trigger.style.top = `${rect.bottom}px`;\n trigger.style.left = isRTL\n ? `${rect.left - TABLE_RESIZER_LENGTH - 2}px`\n : `${rect.right}px`;\n }\n}\n\nfunction hideResizer(context: DragAndDropContext, trigger: HTMLElement) {\n trigger.style.visibility = 'hidden';\n}\n\nfunction isTableBottomVisible(\n editor: IEditor,\n rect: Rect | null,\n contentDiv?: Node | null\n): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return (\n !!containerRect &&\n containerRect.bottom >= rect.bottom &&\n visibleViewport.bottom >= rect.bottom\n );\n }\n\n return true;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { FontFamilyFormat, FontSizeFormat, TextColorFormat } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Format type of watermark text
4
+ */
5
+ export declare type WatermarkFormat = FontFamilyFormat & FontSizeFormat & TextColorFormat;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=WatermarkFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WatermarkFormat.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/watermark/WatermarkFormat.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n FontFamilyFormat,\n FontSizeFormat,\n TextColorFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * Format type of watermark text\n */\nexport type WatermarkFormat = FontFamilyFormat & FontSizeFormat & TextColorFormat;\n"]}
@@ -0,0 +1,37 @@
1
+ import type { WatermarkFormat } from './WatermarkFormat';
2
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
3
+ /**
4
+ * A watermark plugin to manage watermark string for roosterjs
5
+ */
6
+ export declare class WatermarkPlugin implements EditorPlugin {
7
+ private watermark;
8
+ private editor;
9
+ private format;
10
+ private isShowing;
11
+ /**
12
+ * Create an instance of Watermark plugin
13
+ * @param watermark The watermark string
14
+ */
15
+ constructor(watermark: string, format?: WatermarkFormat);
16
+ /**
17
+ * Get a friendly name of this plugin
18
+ */
19
+ getName(): string;
20
+ /**
21
+ * Initialize this plugin. This should only be called from Editor
22
+ * @param editor Editor instance
23
+ */
24
+ initialize(editor: IEditor): void;
25
+ /**
26
+ * Dispose this plugin
27
+ */
28
+ dispose(): void;
29
+ /**
30
+ * Handle events triggered from editor
31
+ * @param event PluginEvent object
32
+ */
33
+ onPluginEvent(event: PluginEvent): void;
34
+ private showHide;
35
+ protected show(editor: IEditor): void;
36
+ protected hide(editor: IEditor): void;
37
+ }
@@ -0,0 +1,96 @@
1
+ import { getObjectKeys } from 'roosterjs-content-model-dom';
2
+ import { isModelEmptyFast } from './isModelEmptyFast';
3
+ var WATERMARK_CONTENT_KEY = '_WatermarkContent';
4
+ var styleMap = {
5
+ fontFamily: 'font-family',
6
+ fontSize: 'font-size',
7
+ textColor: 'color',
8
+ };
9
+ /**
10
+ * A watermark plugin to manage watermark string for roosterjs
11
+ */
12
+ var WatermarkPlugin = /** @class */ (function () {
13
+ /**
14
+ * Create an instance of Watermark plugin
15
+ * @param watermark The watermark string
16
+ */
17
+ function WatermarkPlugin(watermark, format) {
18
+ this.watermark = watermark;
19
+ this.editor = null;
20
+ this.isShowing = false;
21
+ this.format = format || {
22
+ fontSize: '14px',
23
+ textColor: '#AAAAAA',
24
+ };
25
+ }
26
+ /**
27
+ * Get a friendly name of this plugin
28
+ */
29
+ WatermarkPlugin.prototype.getName = function () {
30
+ return 'Watermark';
31
+ };
32
+ /**
33
+ * Initialize this plugin. This should only be called from Editor
34
+ * @param editor Editor instance
35
+ */
36
+ WatermarkPlugin.prototype.initialize = function (editor) {
37
+ this.editor = editor;
38
+ };
39
+ /**
40
+ * Dispose this plugin
41
+ */
42
+ WatermarkPlugin.prototype.dispose = function () {
43
+ this.editor = null;
44
+ };
45
+ /**
46
+ * Handle events triggered from editor
47
+ * @param event PluginEvent object
48
+ */
49
+ WatermarkPlugin.prototype.onPluginEvent = function (event) {
50
+ var _this = this;
51
+ var editor = this.editor;
52
+ if (!editor) {
53
+ return;
54
+ }
55
+ if (event.eventType == 'input' && event.rawEvent.inputType == 'insertText') {
56
+ // When input text, editor must not be empty, so we can do hide watermark now without checking content model
57
+ this.showHide(editor, false /*isEmpty*/);
58
+ }
59
+ else if (event.eventType == 'editorReady' ||
60
+ event.eventType == 'contentChanged' ||
61
+ event.eventType == 'input' ||
62
+ event.eventType == 'beforeDispose') {
63
+ editor.formatContentModel(function (model) {
64
+ var isEmpty = isModelEmptyFast(model);
65
+ _this.showHide(editor, isEmpty);
66
+ return false;
67
+ });
68
+ }
69
+ };
70
+ WatermarkPlugin.prototype.showHide = function (editor, isEmpty) {
71
+ if (this.isShowing && !isEmpty) {
72
+ this.hide(editor);
73
+ }
74
+ else if (!this.isShowing && isEmpty) {
75
+ this.show(editor);
76
+ }
77
+ };
78
+ WatermarkPlugin.prototype.show = function (editor) {
79
+ var _this = this;
80
+ var rule = "position: absolute; pointer-events: none; content: \"" + this.watermark + "\";";
81
+ getObjectKeys(styleMap).forEach(function (x) {
82
+ if (_this.format[x]) {
83
+ rule += styleMap[x] + ": " + _this.format[x] + "!important;";
84
+ }
85
+ });
86
+ editor.setEditorStyle(WATERMARK_CONTENT_KEY, rule, 'before');
87
+ this.isShowing = true;
88
+ };
89
+ WatermarkPlugin.prototype.hide = function (editor) {
90
+ editor.setEditorStyle(WATERMARK_CONTENT_KEY, null);
91
+ this.isShowing = false;
92
+ };
93
+ return WatermarkPlugin;
94
+ }());
95
+ export { WatermarkPlugin };
96
+ //# sourceMappingURL=WatermarkPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WatermarkPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/watermark/WatermarkPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,IAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAClD,IAAM,QAAQ,GAA0C;IACpD,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,WAAW;IACrB,SAAS,E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,KAAK,CAAC;YACjB,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAEO,kCAAQ,GAAhB,UAAiB,MAAe,EAAE,OAAgB;QAC9C,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACrB;aAAM,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACrB;IACL,CAAC;IAES,8BAAI,GAAd,UAAe,MAAe;QAA9B,iBAYC;QAXG,IAAI,IAAI,GAAG,0DAAuD,IAAI,CAAC,SAAS,QAAI,CAAC;QAErF,aAAa,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC;YAC7B,IAAI,KAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;gBAChB,IAAI,IAAO,QAAQ,CAAC,CAAC,CAAC,UAAK,KAAI,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAa,CAAC;aAC1D;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAES,8BAAI,GAAd,UAAe,MAAe;QAC1B,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IACL,sBAAC;AAAD,CAAC,AA9FD,IA8FC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { isModelEmptyFast } from './isModelEmptyFast';\nimport type { WatermarkFormat } from './WatermarkFormat';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\nconst WATERMARK_CONTENT_KEY = '_WatermarkContent';\nconst styleMap: Record<keyof WatermarkFormat, string> = {\n fontFamily: 'font-family',\n fontSize: 'font-size',\n textColor: 'color',\n};\n\n/**\n * A watermark plugin to manage watermark string for roosterjs\n */\nexport class WatermarkPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private format: WatermarkFormat;\n private isShowing = false;\n\n /**\n * Create an instance of Watermark plugin\n * @param watermark The watermark string\n */\n constructor(private watermark: string, format?: WatermarkFormat) {\n this.format = format || {\n fontSize: '14px',\n textColor: '#AAAAAA',\n };\n }\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'Watermark';\n }\n\n /**\n * Initialize this plugin. This should only be called from Editor\n * @param editor Editor instance\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * Dispose this plugin\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(event: PluginEvent) {\n const editor = this.editor;\n\n if (!editor) {\n return;\n }\n\n if (event.eventType == 'input' && event.rawEvent.inputType == 'insertText') {\n // When input text, editor must not be empty, so we can do hide watermark now without checking content model\n this.showHide(editor, false /*isEmpty*/);\n } else if (\n event.eventType == 'editorReady' ||\n event.eventType == 'contentChanged' ||\n event.eventType == 'input' ||\n event.eventType == 'beforeDispose'\n ) {\n editor.formatContentModel(model => {\n const isEmpty = isModelEmptyFast(model);\n\n this.showHide(editor, isEmpty);\n\n return false;\n });\n }\n }\n\n private showHide(editor: IEditor, isEmpty: boolean) {\n if (this.isShowing && !isEmpty) {\n this.hide(editor);\n } else if (!this.isShowing && isEmpty) {\n this.show(editor);\n }\n }\n\n protected show(editor: IEditor) {\n let rule = `position: absolute; pointer-events: none; content: \"${this.watermark}\";`;\n\n getObjectKeys(styleMap).forEach(x => {\n if (this.format[x]) {\n rule += `${styleMap[x]}: ${this.format[x]}!important;`;\n }\n });\n\n editor.setEditorStyle(WATERMARK_CONTENT_KEY, rule, 'before');\n\n this.isShowing = true;\n }\n\n protected hide(editor: IEditor) {\n editor.setEditorStyle(WATERMARK_CONTENT_KEY, null);\n this.isShowing = false;\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ContentModelDocument } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * A fast way to check if content model is empty
5
+ */
6
+ export declare function isModelEmptyFast(model: ContentModelDocument): boolean;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @internal
3
+ * A fast way to check if content model is empty
4
+ */
5
+ export function isModelEmptyFast(model) {
6
+ var firstBlock = model.blocks[0];
7
+ if (model.blocks.length > 1) {
8
+ return false; // Multiple blocks, treat as not empty
9
+ }
10
+ else if (!firstBlock) {
11
+ return true; // No block, it is empty
12
+ }
13
+ else if (firstBlock.blockType != 'Paragraph') {
14
+ return false; // First block is not paragraph, treat as not empty
15
+ }
16
+ else if (firstBlock.segments.length == 0) {
17
+ return true; // No segment, it is empty
18
+ }
19
+ else if (firstBlock.segments.some(function (x) {
20
+ return x.segmentType == 'Entity' ||
21
+ x.segmentType == 'Image' ||
22
+ x.segmentType == 'General' ||
23
+ (x.segmentType == 'Text' && x.text);
24
+ })) {
25
+ return false; // Has meaningful segments, it is not empty
26
+ }
27
+ else {
28
+ return firstBlock.segments.filter(function (x) { return x.segmentType == 'Br'; }).length <= 1; // If there are more than one BR, it is not empty, otherwise it is empty
29
+ }
30
+ }
31
+ //# sourceMappingURL=isModelEmptyFast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isModelEmptyFast.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/watermark/isModelEmptyFast.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA2B;IACxD,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACzB,OAAO,KAAK,CAAC,CAAC,sCAAsC;KACvD;SAAM,IAAI,CAAC,UAAU,EAAE;QACpB,OAAO,IAAI,CAAC,CAAC,wBAAwB;KACxC;SAAM,IAAI,UAAU,CAAC,SAAS,IAAI,WAAW,EAAE;QAC5C,OAAO,KAAK,CAAC,CAAC,mDAAmD;KACpE;SAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;QACxC,OAAO,IAAI,CAAC,CAAC,0BAA0B;KAC1C;SAAM,IACH,UAAU,CAAC,QAAQ,CAAC,IAAI,CACpB,UAAA,CAAC;QACG,OAAA,CAAC,CAAC,WAAW,IAAI,QAAQ;YACzB,CAAC,CAAC,WAAW,IAAI,OAAO;YACxB,CAAC,CAAC,WAAW,IAAI,SAAS;YAC1B,CAAC,CAAC,CAAC,WAAW,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC;IAHnC,CAGmC,CAC1C,EACH;QACE,OAAO,KAAK,CAAC,CAAC,2CAA2C;KAC5D;SAAM;QACH,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,IAAI,EAArB,CAAqB,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,wEAAwE;KACtJ;AACL,CAAC","sourcesContent":["import type { ContentModelDocument } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * A fast way to check if content model is empty\n */\nexport function isModelEmptyFast(model: ContentModelDocument): boolean {\n const firstBlock = model.blocks[0];\n\n if (model.blocks.length > 1) {\n return false; // Multiple blocks, treat as not empty\n } else if (!firstBlock) {\n return true; // No block, it is empty\n } else if (firstBlock.blockType != 'Paragraph') {\n return false; // First block is not paragraph, treat as not empty\n } else if (firstBlock.segments.length == 0) {\n return true; // No segment, it is empty\n } else if (\n firstBlock.segments.some(\n x =>\n x.segmentType == 'Entity' ||\n x.segmentType == 'Image' ||\n x.segmentType == 'General' ||\n (x.segmentType == 'Text' && x.text)\n )\n ) {\n return false; // Has meaningful segments, it is not empty\n } else {\n return firstBlock.segments.filter(x => x.segmentType == 'Br').length <= 1; // If there are more than one BR, it is not empty, otherwise it is empty\n }\n}\n"]}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "roosterjs-content-model-plugins",
3
- "description": "Content Model for roosterjs (Under development)",
3
+ "description": "Plugins for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-core": "^0.28.1",
7
- "roosterjs-content-model-dom": "^0.28.0",
8
- "roosterjs-content-model-types": "^0.28.0",
9
- "roosterjs-content-model-api": "^0.28.0"
6
+ "roosterjs-content-model-core": "^9.0.0",
7
+ "roosterjs-content-model-dom": "^9.0.0",
8
+ "roosterjs-content-model-types": "^9.0.0",
9
+ "roosterjs-content-model-api": "^9.0.0"
10
10
  },
11
- "version": "0.28.2",
11
+ "version": "9.0.0",
12
12
  "main": "./lib/index.js",
13
13
  "typings": "./lib/index.d.ts",
14
14
  "module": "./lib-mjs/index.js",