roosterjs-content-model-plugins 0.26.4 → 0.28.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 (479) hide show
  1. package/lib/autoFormat/AutoFormatPlugin.d.ts +11 -2
  2. package/lib/autoFormat/AutoFormatPlugin.js +24 -4
  3. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
  4. package/lib/autoFormat/link/createLink.d.ts +5 -0
  5. package/lib/autoFormat/link/createLink.js +26 -0
  6. package/lib/autoFormat/link/createLink.js.map +1 -0
  7. package/lib/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
  8. package/lib/autoFormat/link/createLinkAfterSpace.js +39 -0
  9. package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -0
  10. package/lib/autoFormat/link/getLinkSegment.d.ts +5 -0
  11. package/lib/autoFormat/link/getLinkSegment.js +27 -0
  12. package/lib/autoFormat/link/getLinkSegment.js.map +1 -0
  13. package/lib/autoFormat/link/unlink.d.ts +5 -0
  14. package/lib/autoFormat/link/unlink.js +20 -0
  15. package/lib/autoFormat/link/unlink.js.map +1 -0
  16. package/lib/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
  17. package/lib/autoFormat/list/getIndex.js.map +1 -0
  18. package/lib/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
  19. package/lib/autoFormat/list/getListTypeStyle.js.map +1 -0
  20. package/lib/autoFormat/list/getNumberingListStyle.js.map +1 -0
  21. package/lib/autoFormat/list/keyboardListTrigger.d.ts +5 -0
  22. package/lib/autoFormat/{keyboardListTrigger.js → list/keyboardListTrigger.js} +17 -15
  23. package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -0
  24. package/lib/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
  25. package/lib/contextMenuBase/ContextMenuPluginBase.js +84 -0
  26. package/lib/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
  27. package/lib/edit/EditPlugin.d.ts +3 -3
  28. package/lib/edit/EditPlugin.js +1 -1
  29. package/lib/edit/EditPlugin.js.map +1 -1
  30. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  31. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +20 -1
  32. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  33. package/lib/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
  34. package/lib/edit/deleteSteps/deleteEmptyQuote.js +60 -0
  35. package/lib/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
  36. package/lib/edit/deleteSteps/deleteList.js +2 -1
  37. package/lib/edit/deleteSteps/deleteList.js.map +1 -1
  38. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  39. package/lib/edit/handleKeyboardEventCommon.d.ts +2 -2
  40. package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
  41. package/lib/edit/inputSteps/handleEnterOnList.js +40 -10
  42. package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
  43. package/lib/edit/keyboardDelete.d.ts +3 -3
  44. package/lib/edit/keyboardDelete.js +10 -2
  45. package/lib/edit/keyboardDelete.js.map +1 -1
  46. package/lib/edit/keyboardInput.d.ts +2 -2
  47. package/lib/edit/keyboardInput.js +2 -1
  48. package/lib/edit/keyboardInput.js.map +1 -1
  49. package/lib/edit/keyboardTab.d.ts +2 -2
  50. package/lib/edit/keyboardTab.js +19 -11
  51. package/lib/edit/keyboardTab.js.map +1 -1
  52. package/lib/edit/tabUtils/handleTabOnList.d.ts +7 -0
  53. package/lib/edit/tabUtils/handleTabOnList.js +34 -0
  54. package/lib/edit/tabUtils/handleTabOnList.js.map +1 -0
  55. package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
  56. package/lib/edit/tabUtils/handleTabOnParagraph.js +81 -0
  57. package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
  58. package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
  59. package/lib/index.d.ts +5 -0
  60. package/lib/index.js +22 -1
  61. package/lib/index.js.map +1 -1
  62. package/lib/paste/Excel/processPastedContentFromExcel.js +1 -1
  63. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  64. package/lib/paste/PastePlugin.d.ts +2 -3
  65. package/lib/paste/PastePlugin.js +6 -7
  66. package/lib/paste/PastePlugin.js.map +1 -1
  67. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  68. package/lib/paste/WacComponents/constants.js.map +1 -1
  69. package/lib/paste/WacComponents/processPastedContentWacComponents.js +6 -6
  70. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  71. package/lib/paste/WordDesktop/WordMetadata.js.map +1 -1
  72. package/lib/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
  73. package/lib/paste/WordDesktop/getStyleMetadata.js +2 -1
  74. package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  75. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -17
  76. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  77. package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
  78. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  79. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
  80. package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
  81. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  82. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  83. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  84. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  85. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  86. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  87. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  88. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  89. package/lib/paste/utils/addParser.d.ts +1 -1
  90. package/lib/paste/utils/addParser.js +2 -1
  91. package/lib/paste/utils/addParser.js.map +1 -1
  92. package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
  93. package/lib/paste/utils/getStyles.js.map +1 -1
  94. package/lib/paste/utils/linkParser.js.map +1 -1
  95. package/lib/paste/utils/setProcessor.js.map +1 -1
  96. package/lib/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
  97. package/lib/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
  98. package/lib/pluginUtils/CreateElement/createElement.d.ts +2 -2
  99. package/lib/pluginUtils/CreateElement/createElement.js +2 -1
  100. package/lib/pluginUtils/CreateElement/createElement.js.map +1 -1
  101. package/lib/pluginUtils/Disposable.d.ts +1 -1
  102. package/lib/pluginUtils/Disposable.js.map +1 -1
  103. package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
  104. package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
  105. package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
  106. package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js +2 -1
  107. package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
  108. package/lib/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
  109. package/lib/pluginUtils/Rect/getIntersectedRect.js +4 -3
  110. package/lib/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
  111. package/lib/shortcut/ShortcutCommand.d.ts +44 -0
  112. package/lib/shortcut/ShortcutCommand.js +3 -0
  113. package/lib/shortcut/ShortcutCommand.js.map +1 -0
  114. package/lib/shortcut/ShortcutPlugin.d.ts +51 -0
  115. package/lib/shortcut/ShortcutPlugin.js +120 -0
  116. package/lib/shortcut/ShortcutPlugin.js.map +1 -0
  117. package/lib/shortcut/shortcuts.d.ts +85 -0
  118. package/lib/shortcut/shortcuts.js +211 -0
  119. package/lib/shortcut/shortcuts.js.map +1 -0
  120. package/lib/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
  121. package/lib/shortcut/utils/setShortcutIndentationCommand.js +22 -0
  122. package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
  123. package/lib/tableEdit/TableEditPlugin.d.ts +47 -0
  124. package/lib/tableEdit/TableEditPlugin.js +156 -0
  125. package/lib/tableEdit/TableEditPlugin.js.map +1 -0
  126. package/lib/tableEdit/editors/TableEditor.d.ts +73 -0
  127. package/lib/tableEdit/editors/TableEditor.js +294 -0
  128. package/lib/tableEdit/editors/TableEditor.js.map +1 -0
  129. package/lib/tableEdit/editors/features/CellResizer.d.ts +6 -0
  130. package/lib/tableEdit/editors/features/CellResizer.js +169 -0
  131. package/lib/tableEdit/editors/features/CellResizer.js.map +1 -0
  132. package/lib/tableEdit/editors/features/TableEditFeature.d.ts +13 -0
  133. package/lib/tableEdit/editors/features/TableEditFeature.js +17 -0
  134. package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -0
  135. package/lib/tableEdit/editors/features/TableInserter.d.ts +6 -0
  136. package/lib/tableEdit/editors/features/TableInserter.js +113 -0
  137. package/lib/tableEdit/editors/features/TableInserter.js.map +1 -0
  138. package/lib/tableEdit/editors/features/TableMover.d.ts +8 -0
  139. package/lib/tableEdit/editors/features/TableMover.js +83 -0
  140. package/lib/tableEdit/editors/features/TableMover.js.map +1 -0
  141. package/lib/tableEdit/editors/features/TableResizer.d.ts +6 -0
  142. package/lib/tableEdit/editors/features/TableResizer.js +166 -0
  143. package/lib/tableEdit/editors/features/TableResizer.js.map +1 -0
  144. package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +11 -2
  145. package/lib-amd/autoFormat/AutoFormatPlugin.js +21 -4
  146. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
  147. package/lib-amd/autoFormat/link/createLink.d.ts +5 -0
  148. package/lib-amd/autoFormat/link/createLink.js +26 -0
  149. package/lib-amd/autoFormat/link/createLink.js.map +1 -0
  150. package/lib-amd/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
  151. package/lib-amd/autoFormat/link/createLinkAfterSpace.js +38 -0
  152. package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -0
  153. package/lib-amd/autoFormat/link/getLinkSegment.d.ts +5 -0
  154. package/lib-amd/autoFormat/link/getLinkSegment.js +27 -0
  155. package/lib-amd/autoFormat/link/getLinkSegment.js.map +1 -0
  156. package/lib-amd/autoFormat/link/unlink.d.ts +5 -0
  157. package/lib-amd/autoFormat/link/unlink.js +21 -0
  158. package/lib-amd/autoFormat/link/unlink.js.map +1 -0
  159. package/lib-amd/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
  160. package/lib-amd/autoFormat/list/getIndex.js.map +1 -0
  161. package/lib-amd/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
  162. package/lib-amd/autoFormat/list/getListTypeStyle.js.map +1 -0
  163. package/lib-amd/autoFormat/list/getNumberingListStyle.js.map +1 -0
  164. package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +5 -0
  165. package/lib-amd/autoFormat/list/keyboardListTrigger.js +46 -0
  166. package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -0
  167. package/lib-amd/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
  168. package/lib-amd/contextMenuBase/ContextMenuPluginBase.js +86 -0
  169. package/lib-amd/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
  170. package/lib-amd/edit/EditPlugin.d.ts +3 -3
  171. package/lib-amd/edit/EditPlugin.js +1 -1
  172. package/lib-amd/edit/EditPlugin.js.map +1 -1
  173. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  174. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +19 -1
  175. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  176. package/lib-amd/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
  177. package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js +60 -0
  178. package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
  179. package/lib-amd/edit/deleteSteps/deleteList.js +2 -1
  180. package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
  181. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  182. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -2
  183. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
  184. package/lib-amd/edit/inputSteps/handleEnterOnList.js +40 -10
  185. package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
  186. package/lib-amd/edit/keyboardDelete.d.ts +3 -3
  187. package/lib-amd/edit/keyboardDelete.js +10 -3
  188. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  189. package/lib-amd/edit/keyboardInput.d.ts +2 -2
  190. package/lib-amd/edit/keyboardInput.js +2 -2
  191. package/lib-amd/edit/keyboardInput.js.map +1 -1
  192. package/lib-amd/edit/keyboardTab.d.ts +2 -2
  193. package/lib-amd/edit/keyboardTab.js +18 -12
  194. package/lib-amd/edit/keyboardTab.js.map +1 -1
  195. package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +7 -0
  196. package/lib-amd/edit/tabUtils/handleTabOnList.js +34 -0
  197. package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -0
  198. package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
  199. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +81 -0
  200. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
  201. package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
  202. package/lib-amd/index.d.ts +5 -0
  203. package/lib-amd/index.js +19 -2
  204. package/lib-amd/index.js.map +1 -1
  205. package/lib-amd/paste/Excel/processPastedContentFromExcel.js +1 -1
  206. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  207. package/lib-amd/paste/PastePlugin.d.ts +2 -3
  208. package/lib-amd/paste/PastePlugin.js +6 -7
  209. package/lib-amd/paste/PastePlugin.js.map +1 -1
  210. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  211. package/lib-amd/paste/WacComponents/constants.js.map +1 -1
  212. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +6 -6
  213. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  214. package/lib-amd/paste/WordDesktop/WordMetadata.js.map +1 -1
  215. package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
  216. package/lib-amd/paste/WordDesktop/getStyleMetadata.js +2 -1
  217. package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  218. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -17
  219. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  220. package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
  221. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  222. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
  223. package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
  224. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  225. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  226. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  227. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  228. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  229. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  230. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  231. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  232. package/lib-amd/paste/utils/addParser.d.ts +1 -1
  233. package/lib-amd/paste/utils/addParser.js +2 -1
  234. package/lib-amd/paste/utils/addParser.js.map +1 -1
  235. package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
  236. package/lib-amd/paste/utils/getStyles.js.map +1 -1
  237. package/lib-amd/paste/utils/linkParser.js.map +1 -1
  238. package/lib-amd/paste/utils/setProcessor.js.map +1 -1
  239. package/lib-amd/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
  240. package/lib-amd/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
  241. package/lib-amd/pluginUtils/CreateElement/createElement.d.ts +2 -2
  242. package/lib-amd/pluginUtils/CreateElement/createElement.js +2 -1
  243. package/lib-amd/pluginUtils/CreateElement/createElement.js.map +1 -1
  244. package/lib-amd/pluginUtils/Disposable.d.ts +1 -1
  245. package/lib-amd/pluginUtils/Disposable.js.map +1 -1
  246. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
  247. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
  248. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
  249. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js +2 -1
  250. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
  251. package/lib-amd/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
  252. package/lib-amd/pluginUtils/Rect/getIntersectedRect.js +4 -3
  253. package/lib-amd/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
  254. package/lib-amd/shortcut/ShortcutCommand.d.ts +44 -0
  255. package/lib-amd/shortcut/ShortcutCommand.js +5 -0
  256. package/lib-amd/shortcut/ShortcutCommand.js.map +1 -0
  257. package/lib-amd/shortcut/ShortcutPlugin.d.ts +51 -0
  258. package/lib-amd/shortcut/ShortcutPlugin.js +120 -0
  259. package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -0
  260. package/lib-amd/shortcut/shortcuts.d.ts +85 -0
  261. package/lib-amd/shortcut/shortcuts.js +210 -0
  262. package/lib-amd/shortcut/shortcuts.js.map +1 -0
  263. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
  264. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +22 -0
  265. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
  266. package/lib-amd/tableEdit/TableEditPlugin.d.ts +47 -0
  267. package/lib-amd/tableEdit/TableEditPlugin.js +156 -0
  268. package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -0
  269. package/lib-amd/tableEdit/editors/TableEditor.d.ts +73 -0
  270. package/lib-amd/tableEdit/editors/TableEditor.js +290 -0
  271. package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -0
  272. package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +6 -0
  273. package/lib-amd/tableEdit/editors/features/CellResizer.js +166 -0
  274. package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -0
  275. package/lib-amd/tableEdit/editors/features/TableEditFeature.d.ts +13 -0
  276. package/lib-amd/tableEdit/editors/features/TableEditFeature.js +19 -0
  277. package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -0
  278. package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +6 -0
  279. package/lib-amd/tableEdit/editors/features/TableInserter.js +111 -0
  280. package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -0
  281. package/lib-amd/tableEdit/editors/features/TableMover.d.ts +8 -0
  282. package/lib-amd/tableEdit/editors/features/TableMover.js +81 -0
  283. package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -0
  284. package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +6 -0
  285. package/lib-amd/tableEdit/editors/features/TableResizer.js +164 -0
  286. package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -0
  287. package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +11 -2
  288. package/lib-mjs/autoFormat/AutoFormatPlugin.js +24 -4
  289. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
  290. package/lib-mjs/autoFormat/link/createLink.d.ts +5 -0
  291. package/lib-mjs/autoFormat/link/createLink.js +22 -0
  292. package/lib-mjs/autoFormat/link/createLink.js.map +1 -0
  293. package/lib-mjs/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
  294. package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +35 -0
  295. package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -0
  296. package/lib-mjs/autoFormat/link/getLinkSegment.d.ts +5 -0
  297. package/lib-mjs/autoFormat/link/getLinkSegment.js +23 -0
  298. package/lib-mjs/autoFormat/link/getLinkSegment.js.map +1 -0
  299. package/lib-mjs/autoFormat/link/unlink.d.ts +5 -0
  300. package/lib-mjs/autoFormat/link/unlink.js +16 -0
  301. package/lib-mjs/autoFormat/link/unlink.js.map +1 -0
  302. package/lib-mjs/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
  303. package/lib-mjs/autoFormat/list/getIndex.js.map +1 -0
  304. package/lib-mjs/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
  305. package/lib-mjs/autoFormat/list/getListTypeStyle.js.map +1 -0
  306. package/lib-mjs/autoFormat/list/getNumberingListStyle.js.map +1 -0
  307. package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +5 -0
  308. package/lib-mjs/autoFormat/{keyboardListTrigger.js → list/keyboardListTrigger.js} +17 -15
  309. package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -0
  310. package/lib-mjs/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
  311. package/lib-mjs/contextMenuBase/ContextMenuPluginBase.js +81 -0
  312. package/lib-mjs/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
  313. package/lib-mjs/edit/EditPlugin.d.ts +3 -3
  314. package/lib-mjs/edit/EditPlugin.js +1 -1
  315. package/lib-mjs/edit/EditPlugin.js.map +1 -1
  316. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  317. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +20 -1
  318. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  319. package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
  320. package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js +56 -0
  321. package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
  322. package/lib-mjs/edit/deleteSteps/deleteList.js +2 -1
  323. package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
  324. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  325. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -2
  326. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
  327. package/lib-mjs/edit/inputSteps/handleEnterOnList.js +42 -12
  328. package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
  329. package/lib-mjs/edit/keyboardDelete.d.ts +3 -3
  330. package/lib-mjs/edit/keyboardDelete.js +10 -2
  331. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  332. package/lib-mjs/edit/keyboardInput.d.ts +2 -2
  333. package/lib-mjs/edit/keyboardInput.js +2 -1
  334. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  335. package/lib-mjs/edit/keyboardTab.d.ts +2 -2
  336. package/lib-mjs/edit/keyboardTab.js +19 -11
  337. package/lib-mjs/edit/keyboardTab.js.map +1 -1
  338. package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +7 -0
  339. package/lib-mjs/edit/tabUtils/handleTabOnList.js +30 -0
  340. package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -0
  341. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
  342. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +77 -0
  343. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
  344. package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
  345. package/lib-mjs/index.d.ts +5 -0
  346. package/lib-mjs/index.js +4 -0
  347. package/lib-mjs/index.js.map +1 -1
  348. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +1 -1
  349. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  350. package/lib-mjs/paste/PastePlugin.d.ts +2 -3
  351. package/lib-mjs/paste/PastePlugin.js +1 -2
  352. package/lib-mjs/paste/PastePlugin.js.map +1 -1
  353. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  354. package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
  355. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +1 -1
  356. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  357. package/lib-mjs/paste/WordDesktop/WordMetadata.js.map +1 -1
  358. package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
  359. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +1 -1
  360. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  361. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +2 -14
  362. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  363. package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
  364. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  365. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
  366. package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
  367. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  368. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  369. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  370. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  371. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  372. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  373. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  374. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  375. package/lib-mjs/paste/utils/addParser.d.ts +1 -1
  376. package/lib-mjs/paste/utils/addParser.js +1 -1
  377. package/lib-mjs/paste/utils/addParser.js.map +1 -1
  378. package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
  379. package/lib-mjs/paste/utils/getStyles.js.map +1 -1
  380. package/lib-mjs/paste/utils/linkParser.js.map +1 -1
  381. package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
  382. package/lib-mjs/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
  383. package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
  384. package/lib-mjs/pluginUtils/CreateElement/createElement.d.ts +2 -2
  385. package/lib-mjs/pluginUtils/CreateElement/createElement.js +1 -1
  386. package/lib-mjs/pluginUtils/CreateElement/createElement.js.map +1 -1
  387. package/lib-mjs/pluginUtils/Disposable.d.ts +1 -1
  388. package/lib-mjs/pluginUtils/Disposable.js.map +1 -1
  389. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
  390. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
  391. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
  392. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js +1 -1
  393. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
  394. package/lib-mjs/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
  395. package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js +2 -2
  396. package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
  397. package/lib-mjs/shortcut/ShortcutCommand.d.ts +44 -0
  398. package/lib-mjs/shortcut/ShortcutCommand.js +2 -0
  399. package/lib-mjs/shortcut/ShortcutCommand.js.map +1 -0
  400. package/lib-mjs/shortcut/ShortcutPlugin.d.ts +51 -0
  401. package/lib-mjs/shortcut/ShortcutPlugin.js +117 -0
  402. package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -0
  403. package/lib-mjs/shortcut/shortcuts.d.ts +85 -0
  404. package/lib-mjs/shortcut/shortcuts.js +208 -0
  405. package/lib-mjs/shortcut/shortcuts.js.map +1 -0
  406. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
  407. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +18 -0
  408. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
  409. package/lib-mjs/tableEdit/TableEditPlugin.d.ts +47 -0
  410. package/lib-mjs/tableEdit/TableEditPlugin.js +153 -0
  411. package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -0
  412. package/lib-mjs/tableEdit/editors/TableEditor.d.ts +73 -0
  413. package/lib-mjs/tableEdit/editors/TableEditor.js +291 -0
  414. package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -0
  415. package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +6 -0
  416. package/lib-mjs/tableEdit/editors/features/CellResizer.js +165 -0
  417. package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -0
  418. package/lib-mjs/tableEdit/editors/features/TableEditFeature.d.ts +13 -0
  419. package/lib-mjs/tableEdit/editors/features/TableEditFeature.js +13 -0
  420. package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -0
  421. package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +6 -0
  422. package/lib-mjs/tableEdit/editors/features/TableInserter.js +109 -0
  423. package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -0
  424. package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +8 -0
  425. package/lib-mjs/tableEdit/editors/features/TableMover.js +79 -0
  426. package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -0
  427. package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +6 -0
  428. package/lib-mjs/tableEdit/editors/features/TableResizer.js +162 -0
  429. package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -0
  430. package/package.json +5 -5
  431. package/lib/autoFormat/keyboardListTrigger.d.ts +0 -5
  432. package/lib/autoFormat/keyboardListTrigger.js.map +0 -1
  433. package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
  434. package/lib/autoFormat/utils/getIndex.js.map +0 -1
  435. package/lib/autoFormat/utils/getListTypeStyle.js.map +0 -1
  436. package/lib/autoFormat/utils/getNumberingListStyle.js.map +0 -1
  437. package/lib/pluginUtils/Rect/normalizeRect.d.ts +0 -7
  438. package/lib/pluginUtils/Rect/normalizeRect.js +0 -20
  439. package/lib/pluginUtils/Rect/normalizeRect.js.map +0 -1
  440. package/lib-amd/autoFormat/keyboardListTrigger.d.ts +0 -5
  441. package/lib-amd/autoFormat/keyboardListTrigger.js +0 -44
  442. package/lib-amd/autoFormat/keyboardListTrigger.js.map +0 -1
  443. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
  444. package/lib-amd/autoFormat/utils/getIndex.js.map +0 -1
  445. package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +0 -1
  446. package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +0 -1
  447. package/lib-amd/pluginUtils/Rect/normalizeRect.d.ts +0 -7
  448. package/lib-amd/pluginUtils/Rect/normalizeRect.js +0 -22
  449. package/lib-amd/pluginUtils/Rect/normalizeRect.js.map +0 -1
  450. package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +0 -5
  451. package/lib-mjs/autoFormat/keyboardListTrigger.js.map +0 -1
  452. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
  453. package/lib-mjs/autoFormat/utils/getIndex.js.map +0 -1
  454. package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +0 -1
  455. package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +0 -1
  456. package/lib-mjs/pluginUtils/Rect/normalizeRect.d.ts +0 -7
  457. package/lib-mjs/pluginUtils/Rect/normalizeRect.js +0 -17
  458. package/lib-mjs/pluginUtils/Rect/normalizeRect.js.map +0 -1
  459. /package/lib/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
  460. /package/lib/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
  461. /package/lib/autoFormat/{utils → list}/getIndex.d.ts +0 -0
  462. /package/lib/autoFormat/{utils → list}/getIndex.js +0 -0
  463. /package/lib/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
  464. /package/lib/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
  465. /package/lib/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
  466. /package/lib-amd/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
  467. /package/lib-amd/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
  468. /package/lib-amd/autoFormat/{utils → list}/getIndex.d.ts +0 -0
  469. /package/lib-amd/autoFormat/{utils → list}/getIndex.js +0 -0
  470. /package/lib-amd/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
  471. /package/lib-amd/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
  472. /package/lib-amd/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
  473. /package/lib-mjs/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
  474. /package/lib-mjs/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
  475. /package/lib-mjs/autoFormat/{utils → list}/getIndex.d.ts +0 -0
  476. /package/lib-mjs/autoFormat/{utils → list}/getIndex.js +0 -0
  477. /package/lib-mjs/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
  478. /package/lib-mjs/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
  479. /package/lib-mjs/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
@@ -0,0 +1,156 @@
1
+ define(["require", "exports", "roosterjs-content-model-dom", "./editors/TableEditor"], function (require, exports, roosterjs_content_model_dom_1, TableEditor_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TableEditPlugin = void 0;
5
+ var TABLE_RESIZER_LENGTH = 12;
6
+ /**
7
+ * TableEdit plugin, provides the ability to resize a table by drag-and-drop
8
+ */
9
+ var TableEditPlugin = /** @class */ (function () {
10
+ /**
11
+ * Construct a new instance of TableResize plugin
12
+ * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
13
+ * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
14
+ * If not specified, the plugin will be inserted in document.body
15
+ */
16
+ function TableEditPlugin(anchorContainerSelector) {
17
+ var _this = this;
18
+ this.anchorContainerSelector = anchorContainerSelector;
19
+ this.editor = null;
20
+ this.onMouseMoveDisposer = null;
21
+ this.tableRectMap = null;
22
+ this.tableEditor = null;
23
+ this.onMouseOut = function (_a) {
24
+ var relatedTarget = _a.relatedTarget, currentTarget = _a.currentTarget;
25
+ var relatedTargetNode = relatedTarget;
26
+ var currentTargetNode = currentTarget;
27
+ if ((0, roosterjs_content_model_dom_1.isNodeOfType)(relatedTargetNode, 'ELEMENT_NODE') &&
28
+ (0, roosterjs_content_model_dom_1.isNodeOfType)(currentTargetNode, 'ELEMENT_NODE') &&
29
+ _this.tableEditor &&
30
+ !_this.tableEditor.isOwnedElement(relatedTargetNode) &&
31
+ !currentTargetNode.contains(relatedTargetNode)) {
32
+ _this.setTableEditor(null);
33
+ }
34
+ };
35
+ this.onMouseMove = function (event) {
36
+ var _a;
37
+ var e = event;
38
+ if (e.buttons > 0 || !_this.editor) {
39
+ return;
40
+ }
41
+ _this.ensureTableRects();
42
+ var editorWindow = _this.editor.getDocument().defaultView || window;
43
+ var x = e.pageX - editorWindow.scrollX;
44
+ var y = e.pageY - editorWindow.scrollY;
45
+ var currentTable = null;
46
+ //Find table in range of mouse
47
+ if (_this.tableRectMap) {
48
+ for (var i = _this.tableRectMap.length - 1; i >= 0; i--) {
49
+ var _b = _this.tableRectMap[i], table = _b.table, rect = _b.rect;
50
+ if (x >= rect.left - TABLE_RESIZER_LENGTH &&
51
+ x <= rect.right + TABLE_RESIZER_LENGTH &&
52
+ y >= rect.top - TABLE_RESIZER_LENGTH &&
53
+ y <= rect.bottom + TABLE_RESIZER_LENGTH) {
54
+ currentTable = table;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ _this.setTableEditor(currentTable, e);
60
+ (_a = _this.tableEditor) === null || _a === void 0 ? void 0 : _a.onMouseMove(x, y);
61
+ };
62
+ this.invalidateTableRects = function () {
63
+ _this.tableRectMap = null;
64
+ };
65
+ }
66
+ /**
67
+ * Get a friendly name of this plugin
68
+ */
69
+ TableEditPlugin.prototype.getName = function () {
70
+ return 'TableEdit';
71
+ };
72
+ /**
73
+ * Initialize this plugin. This should only be called from Editor
74
+ * @param editor Editor instance
75
+ */
76
+ TableEditPlugin.prototype.initialize = function (editor) {
77
+ this.editor = editor;
78
+ this.onMouseMoveDisposer = this.editor.attachDomEvent({
79
+ mousemove: { beforeDispatch: this.onMouseMove },
80
+ });
81
+ var scrollContainer = this.editor.getScrollContainer();
82
+ scrollContainer.addEventListener('mouseout', this.onMouseOut);
83
+ };
84
+ /**
85
+ * Dispose this plugin
86
+ */
87
+ TableEditPlugin.prototype.dispose = function () {
88
+ var _a, _b;
89
+ var scrollContainer = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getScrollContainer();
90
+ scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('mouseout', this.onMouseOut);
91
+ (_b = this.onMouseMoveDisposer) === null || _b === void 0 ? void 0 : _b.call(this);
92
+ this.invalidateTableRects();
93
+ this.disposeTableEditor();
94
+ this.editor = null;
95
+ this.onMouseMoveDisposer = null;
96
+ };
97
+ /**
98
+ * Handle events triggered from editor
99
+ * @param event PluginEvent object
100
+ */
101
+ TableEditPlugin.prototype.onPluginEvent = function (e) {
102
+ switch (e.eventType) {
103
+ case 'input':
104
+ case 'contentChanged':
105
+ case 'scroll':
106
+ case 'zoomChanged':
107
+ this.setTableEditor(null);
108
+ this.invalidateTableRects();
109
+ break;
110
+ }
111
+ };
112
+ /**
113
+ * @internal Public only for unit test
114
+ * @param table Table to use when setting the Editors
115
+ * @param event (Optional) Mouse event
116
+ */
117
+ TableEditPlugin.prototype.setTableEditor = function (table, event) {
118
+ if (this.tableEditor && !this.tableEditor.isEditing() && table != this.tableEditor.table) {
119
+ this.disposeTableEditor();
120
+ }
121
+ if (!this.tableEditor && table && this.editor && table.rows.length > 0) {
122
+ // anchorContainerSelector is used to specify the container to host the plugin, which can be outside of the editor's div
123
+ var container = this.anchorContainerSelector
124
+ ? this.editor.getDocument().querySelector(this.anchorContainerSelector)
125
+ : undefined;
126
+ this.tableEditor = new TableEditor_1.TableEditor(this.editor, table, this.invalidateTableRects, (0, roosterjs_content_model_dom_1.isNodeOfType)(container, 'ELEMENT_NODE') ? container : undefined, event === null || event === void 0 ? void 0 : event.currentTarget);
127
+ }
128
+ };
129
+ TableEditPlugin.prototype.disposeTableEditor = function () {
130
+ var _a;
131
+ (_a = this.tableEditor) === null || _a === void 0 ? void 0 : _a.dispose();
132
+ this.tableEditor = null;
133
+ };
134
+ TableEditPlugin.prototype.ensureTableRects = function () {
135
+ var _this = this;
136
+ if (!this.tableRectMap && this.editor) {
137
+ this.tableRectMap = [];
138
+ var tables = this.editor.getDOMHelper().queryElements('table');
139
+ tables.forEach(function (table) {
140
+ if (table.isContentEditable) {
141
+ var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(table.getBoundingClientRect());
142
+ if (rect && _this.tableRectMap) {
143
+ _this.tableRectMap.push({
144
+ table: table,
145
+ rect: rect,
146
+ });
147
+ }
148
+ }
149
+ });
150
+ }
151
+ };
152
+ return TableEditPlugin;
153
+ }());
154
+ exports.TableEditPlugin = TableEditPlugin;
155
+ });
156
+ //# sourceMappingURL=TableEditPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableEditPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/TableEditPlugin.ts"],"names":[],"mappings":";;;;IAIA,IAAM,oBAAoB,GAAG,EAAE,CAAC;IAEhC;;OAEG;IACH;QAMI;;;;;WAKG;QACH,yBAAoB,uBAAgC;YAApD,iBAAwD;YAApC,4BAAuB,GAAvB,uBAAuB,CAAS;YAX5C,WAAM,GAAmB,IAAI,CAAC;YAC9B,wBAAmB,GAAwB,IAAI,CAAC;YAChD,iBAAY,GAAqD,IAAI,CAAC;YACtE,gBAAW,GAAuB,IAAI,CAAC;YA8BvC,eAAU,GAAG,UAAC,EAA4C;oBAA1C,aAAa,mBAAA,EAAE,aAAa,mBAAA;gBAChD,IAAM,iBAAiB,GAAG,aAAqB,CAAC;gBAChD,IAAM,iBAAiB,GAAG,aAAqB,CAAC;gBAChD,IACI,IAAA,0CAAY,EAAC,iBAAiB,EAAE,cAAc,CAAC;oBAC/C,IAAA,0CAAY,EAAC,iBAAiB,EAAE,cAAc,CAAC;oBAC/C,KAAI,CAAC,WAAW;oBAChB,CAAC,KAAI,CAAC,WAAW,CAAC,cAAc,CAAC,iBAAiB,CAAC;oBACnD,CAAC,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAChD;oBACE,KAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;iBAC7B;YACL,CAAC,CAAC;YA+BM,gBAAW,GAAG,UAAC,KAAY;;gBAC/B,IAAM,CAAC,GAAG,KAAmB,CAAC;gBAE9B,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAI,CAAC,MAAM,EAAE;oBAC/B,OAAO;iBACV;gBAED,KAAI,CAAC,gBAAgB,EAAE,CAAC;gBAExB,IAAM,YAAY,GAAG,KAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,WAAW,IAAI,MAAM,CAAC;gBACrE,IAAM,CAAC,GAAG,CAAC,CAAC,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C,CAAC;yBACN;qBACJ;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC;QACL,sBAAC;IAAD,CAAC,AArKD,IAqKC;IArKY,0CAAe","sourcesContent":["import { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport { TableEditor } from './editors/TableEditor';\nimport type { EditorPlugin, IEditor, PluginEvent, Rect } from 'roosterjs-content-model-types';\n\nconst TABLE_RESIZER_LENGTH = 12;\n\n/**\n * TableEdit plugin, provides the ability to resize a table by drag-and-drop\n */\nexport class TableEditPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private onMouseMoveDisposer: (() => void) | null = null;\n private tableRectMap: { table: HTMLTableElement; rect: Rect }[] | null = null;\n private tableEditor: TableEditor | null = null;\n\n /**\n * Construct a new instance of TableResize plugin\n * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.\n * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.\n * If not specified, the plugin will be inserted in document.body\n */\n constructor(private anchorContainerSelector?: string) {}\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'TableEdit';\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 this.onMouseMoveDisposer = this.editor.attachDomEvent({\n mousemove: { beforeDispatch: this.onMouseMove },\n });\n const scrollContainer = this.editor.getScrollContainer();\n scrollContainer.addEventListener('mouseout', this.onMouseOut);\n }\n\n private onMouseOut = ({ relatedTarget, currentTarget }: MouseEvent) => {\n const relatedTargetNode = relatedTarget as Node;\n const currentTargetNode = currentTarget as Node;\n if (\n isNodeOfType(relatedTargetNode, 'ELEMENT_NODE') &&\n isNodeOfType(currentTargetNode, 'ELEMENT_NODE') &&\n this.tableEditor &&\n !this.tableEditor.isOwnedElement(relatedTargetNode) &&\n !currentTargetNode.contains(relatedTargetNode)\n ) {\n this.setTableEditor(null);\n }\n };\n\n /**\n * Dispose this plugin\n */\n dispose() {\n const scrollContainer = this.editor?.getScrollContainer();\n scrollContainer?.removeEventListener('mouseout', this.onMouseOut);\n this.onMouseMoveDisposer?.();\n this.invalidateTableRects();\n this.disposeTableEditor();\n this.editor = null;\n this.onMouseMoveDisposer = null;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(e: PluginEvent) {\n switch (e.eventType) {\n case 'input':\n case 'contentChanged':\n case 'scroll':\n case 'zoomChanged':\n this.setTableEditor(null);\n this.invalidateTableRects();\n break;\n }\n }\n\n private onMouseMove = (event: Event) => {\n const e = event as MouseEvent;\n\n if (e.buttons > 0 || !this.editor) {\n return;\n }\n\n this.ensureTableRects();\n\n const editorWindow = this.editor.getDocument().defaultView || window;\n const x = e.pageX - editorWindow.scrollX;\n const y = e.pageY - editorWindow.scrollY;\n let currentTable: HTMLTableElement | null = null;\n\n //Find table in range of mouse\n if (this.tableRectMap) {\n for (let i = this.tableRectMap.length - 1; i >= 0; i--) {\n const { table, rect } = this.tableRectMap[i];\n\n if (\n x >= rect.left - TABLE_RESIZER_LENGTH &&\n x <= rect.right + TABLE_RESIZER_LENGTH &&\n y >= rect.top - TABLE_RESIZER_LENGTH &&\n y <= rect.bottom + TABLE_RESIZER_LENGTH\n ) {\n currentTable = table;\n break;\n }\n }\n }\n\n this.setTableEditor(currentTable, e);\n this.tableEditor?.onMouseMove(x, y);\n };\n\n /**\n * @internal Public only for unit test\n * @param table Table to use when setting the Editors\n * @param event (Optional) Mouse event\n */\n public setTableEditor(table: HTMLTableElement | null, event?: MouseEvent) {\n if (this.tableEditor && !this.tableEditor.isEditing() && table != this.tableEditor.table) {\n this.disposeTableEditor();\n }\n\n if (!this.tableEditor && table && this.editor && table.rows.length > 0) {\n // anchorContainerSelector is used to specify the container to host the plugin, which can be outside of the editor's div\n const container = this.anchorContainerSelector\n ? this.editor.getDocument().querySelector(this.anchorContainerSelector)\n : undefined;\n\n this.tableEditor = new TableEditor(\n this.editor,\n table,\n this.invalidateTableRects,\n isNodeOfType(container, 'ELEMENT_NODE') ? container : undefined,\n event?.currentTarget\n );\n }\n }\n\n private invalidateTableRects = () => {\n this.tableRectMap = null;\n };\n\n private disposeTableEditor() {\n this.tableEditor?.dispose();\n this.tableEditor = null;\n }\n\n private ensureTableRects() {\n if (!this.tableRectMap && this.editor) {\n this.tableRectMap = [];\n\n const tables = this.editor.getDOMHelper().queryElements('table');\n tables.forEach(table => {\n if (table.isContentEditable) {\n const rect = normalizeRect(table.getBoundingClientRect());\n if (rect && this.tableRectMap) {\n this.tableRectMap.push({\n table,\n rect,\n });\n }\n }\n });\n }\n }\n}\n"]}
@@ -0,0 +1,73 @@
1
+ import type { IEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ *
5
+ * A table has 6 hot areas to be resized/edited (take LTR example):
6
+ *
7
+ * [6] [ ]
8
+ * +[ 1 ]+--------------------+
9
+ * |[ ]| |
10
+ * [ ] [ ] |
11
+ * [ ] [ ] |
12
+ * [2] [3] |
13
+ * [ ] [ ] |
14
+ * [ ][ 4 ]| |
15
+ * +------------------+--------------------+
16
+ * | | |
17
+ * | | |
18
+ * | | |
19
+ * +------------------+--------------------+
20
+ * [5]
21
+ *
22
+ * 1 - Hover area to show insert column button
23
+ * 2 - Hover area to show insert row button
24
+ * 3 - Hover area to show vertical resizing bar
25
+ * 4 - Hover area to show horizontal resizing bar
26
+ * 5 - Hover area to show whole table resize handle
27
+ * 6 - Hover area to show whole table mover handle
28
+ *
29
+ * When set a different current table or change current TD, we need to update these areas
30
+ */
31
+ export declare class TableEditor {
32
+ private editor;
33
+ readonly table: HTMLTableElement;
34
+ private onChanged;
35
+ private anchorContainer?;
36
+ private contentDiv?;
37
+ private horizontalInserter;
38
+ private verticalInserter;
39
+ private horizontalResizer;
40
+ private verticalResizer;
41
+ private tableResizer;
42
+ private tableMover;
43
+ private isRTL;
44
+ private range;
45
+ private isCurrentlyEditing;
46
+ constructor(editor: IEditor, table: HTMLTableElement, onChanged: () => void, anchorContainer?: HTMLElement | undefined, contentDiv?: EventTarget | null | undefined);
47
+ dispose(): void;
48
+ isEditing(): boolean;
49
+ isOwnedElement(node: Node): boolean;
50
+ onMouseMove(x: number, y: number): void;
51
+ private setEditorFeatures;
52
+ private setResizingTd;
53
+ /**
54
+ * create or remove TableInserter
55
+ * @param td td to attach to, set this to null to remove inserters (both horizontal and vertical)
56
+ */
57
+ private setInserterTd;
58
+ private disposeTableResizer;
59
+ private disposeTableInserter;
60
+ private disposeCellResizers;
61
+ private disposeTableMover;
62
+ private onFinishEditing;
63
+ private onStartTableResize;
64
+ private onStartCellResize;
65
+ private onStartResize;
66
+ private onInserted;
67
+ /**
68
+ * Public only for testing purposes
69
+ * @param table the table to select
70
+ */
71
+ onSelect: (table: HTMLTableElement) => void;
72
+ private getOnMouseOut;
73
+ }
@@ -0,0 +1,290 @@
1
+ define(["require", "exports", "./features/CellResizer", "./features/TableInserter", "./features/TableMover", "./features/TableResizer", "./features/TableEditFeature", "roosterjs-content-model-dom"], function (require, exports, CellResizer_1, TableInserter_1, TableMover_1, TableResizer_1, TableEditFeature_1, roosterjs_content_model_dom_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TableEditor = void 0;
5
+ var INSERTER_HOVER_OFFSET = 6;
6
+ var TOP_OR_SIDE;
7
+ (function (TOP_OR_SIDE) {
8
+ TOP_OR_SIDE[TOP_OR_SIDE["top"] = 0] = "top";
9
+ TOP_OR_SIDE[TOP_OR_SIDE["side"] = 1] = "side";
10
+ })(TOP_OR_SIDE || (TOP_OR_SIDE = {}));
11
+ /**
12
+ * @internal
13
+ *
14
+ * A table has 6 hot areas to be resized/edited (take LTR example):
15
+ *
16
+ * [6] [ ]
17
+ * +[ 1 ]+--------------------+
18
+ * |[ ]| |
19
+ * [ ] [ ] |
20
+ * [ ] [ ] |
21
+ * [2] [3] |
22
+ * [ ] [ ] |
23
+ * [ ][ 4 ]| |
24
+ * +------------------+--------------------+
25
+ * | | |
26
+ * | | |
27
+ * | | |
28
+ * +------------------+--------------------+
29
+ * [5]
30
+ *
31
+ * 1 - Hover area to show insert column button
32
+ * 2 - Hover area to show insert row button
33
+ * 3 - Hover area to show vertical resizing bar
34
+ * 4 - Hover area to show horizontal resizing bar
35
+ * 5 - Hover area to show whole table resize handle
36
+ * 6 - Hover area to show whole table mover handle
37
+ *
38
+ * When set a different current table or change current TD, we need to update these areas
39
+ */
40
+ var TableEditor = /** @class */ (function () {
41
+ function TableEditor(editor, table, onChanged, anchorContainer, contentDiv) {
42
+ var _this = this;
43
+ var _a;
44
+ this.editor = editor;
45
+ this.table = table;
46
+ this.onChanged = onChanged;
47
+ this.anchorContainer = anchorContainer;
48
+ this.contentDiv = contentDiv;
49
+ // 1, 2 - Insert a column or a row
50
+ this.horizontalInserter = null;
51
+ this.verticalInserter = null;
52
+ // 3, 4 - Resize a column or a row from a cell
53
+ this.horizontalResizer = null;
54
+ this.verticalResizer = null;
55
+ // 5 - Resize whole table
56
+ this.tableResizer = null;
57
+ // 6 - Move as well as select whole table
58
+ this.tableMover = null;
59
+ this.range = null;
60
+ this.onFinishEditing = function () {
61
+ _this.editor.focus();
62
+ if (_this.range) {
63
+ _this.editor.setDOMSelection({ type: 'range', range: _this.range, isReverted: false });
64
+ }
65
+ _this.editor.takeSnapshot(); // Pass in an empty callback to make sure ContentChangedEvent is triggered
66
+ _this.onChanged();
67
+ _this.isCurrentlyEditing = false;
68
+ return false;
69
+ };
70
+ this.onStartTableResize = function () {
71
+ _this.isCurrentlyEditing = true;
72
+ _this.onStartResize();
73
+ };
74
+ this.onStartCellResize = function () {
75
+ _this.isCurrentlyEditing = true;
76
+ _this.disposeTableResizer();
77
+ _this.onStartResize();
78
+ };
79
+ this.onInserted = function () {
80
+ _this.disposeTableResizer();
81
+ _this.onFinishEditing();
82
+ };
83
+ /**
84
+ * Public only for testing purposes
85
+ * @param table the table to select
86
+ */
87
+ this.onSelect = function (table) {
88
+ _this.editor.focus();
89
+ if (table) {
90
+ var selection = {
91
+ table: table,
92
+ firstRow: 0,
93
+ firstColumn: 0,
94
+ lastRow: table.rows.length - 1,
95
+ lastColumn: table.rows[table.rows.length - 1].cells.length - 1,
96
+ type: 'table',
97
+ };
98
+ _this.editor.setDOMSelection(selection);
99
+ }
100
+ };
101
+ this.getOnMouseOut = function (feature) {
102
+ return function (ev) {
103
+ if (feature &&
104
+ ev.relatedTarget != feature &&
105
+ (0, roosterjs_content_model_dom_1.isNodeOfType)(_this.contentDiv, 'ELEMENT_NODE') &&
106
+ (0, roosterjs_content_model_dom_1.isNodeOfType)(ev.relatedTarget, 'ELEMENT_NODE') &&
107
+ !(_this.contentDiv == ev.relatedTarget)) {
108
+ _this.dispose();
109
+ }
110
+ };
111
+ };
112
+ this.isRTL = ((_a = editor.getDocument().defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(table).direction) == 'rtl';
113
+ this.setEditorFeatures();
114
+ this.isCurrentlyEditing = false;
115
+ }
116
+ TableEditor.prototype.dispose = function () {
117
+ this.disposeTableResizer();
118
+ this.disposeCellResizers();
119
+ this.disposeTableInserter();
120
+ this.disposeTableMover();
121
+ };
122
+ TableEditor.prototype.isEditing = function () {
123
+ return this.isCurrentlyEditing;
124
+ };
125
+ TableEditor.prototype.isOwnedElement = function (node) {
126
+ return [
127
+ this.tableResizer,
128
+ this.tableMover,
129
+ this.horizontalInserter,
130
+ this.verticalInserter,
131
+ this.horizontalResizer,
132
+ this.verticalResizer,
133
+ ]
134
+ .filter(function (feature) { return !!(feature === null || feature === void 0 ? void 0 : feature.div); })
135
+ .some(function (feature) { return (feature === null || feature === void 0 ? void 0 : feature.div) == node; });
136
+ };
137
+ TableEditor.prototype.onMouseMove = function (x, y) {
138
+ var _a;
139
+ // Get whole table rect
140
+ var tableRect = (0, roosterjs_content_model_dom_1.normalizeRect)(this.table.getBoundingClientRect());
141
+ //console.log('>>>tableRect', tableRect);
142
+ if (!tableRect) {
143
+ return;
144
+ }
145
+ // Determine if cursor is on top or side
146
+ var topOrSide = y <= tableRect.top + INSERTER_HOVER_OFFSET
147
+ ? 0 /* top */
148
+ : this.isRTL
149
+ ? x >= tableRect.right - INSERTER_HOVER_OFFSET
150
+ ? 1 /* side */
151
+ : undefined
152
+ : x <= tableRect.left + INSERTER_HOVER_OFFSET
153
+ ? 1 /* side */
154
+ : undefined;
155
+ var topOrSideBinary = topOrSide ? 1 : 0;
156
+ // i is row index, j is column index
157
+ for (var i = 0; i < this.table.rows.length; i++) {
158
+ var tr = this.table.rows[i];
159
+ var j = 0;
160
+ for (; j < tr.cells.length; j++) {
161
+ var td = tr.cells[j];
162
+ var tdRect = (0, roosterjs_content_model_dom_1.normalizeRect)(td.getBoundingClientRect());
163
+ if (!tdRect || !tableRect) {
164
+ continue;
165
+ }
166
+ // Determine the cell the cursor is in range of
167
+ // Offset is only used for first row and column
168
+ var lessThanBottom = y <= tdRect.bottom;
169
+ var lessThanRight = this.isRTL
170
+ ? x <= tdRect.right + INSERTER_HOVER_OFFSET * topOrSideBinary
171
+ : x <= tdRect.right;
172
+ var moreThanLeft = this.isRTL
173
+ ? x >= tdRect.left
174
+ : x >= tdRect.left - INSERTER_HOVER_OFFSET * topOrSideBinary;
175
+ if (lessThanBottom && lessThanRight && moreThanLeft) {
176
+ if (i === 0 && topOrSide == 0 /* top */) {
177
+ var center = (tdRect.left + tdRect.right) / 2;
178
+ var isOnRightHalf = this.isRTL ? x < center : x > center;
179
+ this.setInserterTd(isOnRightHalf ? td : tr.cells[j - 1], false /*isHorizontal*/);
180
+ }
181
+ else if (j === 0 && topOrSide == 1 /* side */) {
182
+ var tdAbove = (_a = this.table.rows[i - 1]) === null || _a === void 0 ? void 0 : _a.cells[0];
183
+ var tdAboveRect = tdAbove
184
+ ? (0, roosterjs_content_model_dom_1.normalizeRect)(tdAbove.getBoundingClientRect())
185
+ : null;
186
+ var isTdNotAboveMerged = !tdAboveRect
187
+ ? null
188
+ : this.isRTL
189
+ ? tdAboveRect.right === tdRect.right
190
+ : tdAboveRect.left === tdRect.left;
191
+ this.setInserterTd(y < (tdRect.top + tdRect.bottom) / 2 && isTdNotAboveMerged
192
+ ? tdAbove
193
+ : td, true /*isHorizontal*/);
194
+ }
195
+ else {
196
+ this.setInserterTd(null);
197
+ }
198
+ this.setResizingTd(td);
199
+ //Cell found
200
+ break;
201
+ }
202
+ }
203
+ if (j < tr.cells.length) {
204
+ break;
205
+ }
206
+ }
207
+ // Create Mover and Resizer
208
+ this.setEditorFeatures();
209
+ };
210
+ TableEditor.prototype.setEditorFeatures = function () {
211
+ if (!this.tableMover) {
212
+ this.tableMover = (0, TableMover_1.createTableMover)(this.table, this.editor, this.isRTL, this.onSelect, this.getOnMouseOut, this.contentDiv, this.anchorContainer);
213
+ }
214
+ if (!this.tableResizer) {
215
+ this.tableResizer = (0, TableResizer_1.createTableResizer)(this.table, this.editor, this.isRTL, this.onStartTableResize, this.onFinishEditing, this.contentDiv, this.anchorContainer);
216
+ }
217
+ };
218
+ TableEditor.prototype.setResizingTd = function (td) {
219
+ if (this.horizontalResizer && this.horizontalResizer.node != td) {
220
+ this.disposeCellResizers();
221
+ }
222
+ if (!this.horizontalResizer && td) {
223
+ this.horizontalResizer = (0, CellResizer_1.createCellResizer)(this.editor, td, this.table, this.isRTL, true /*isHorizontal*/, this.onStartCellResize, this.onFinishEditing, this.anchorContainer);
224
+ this.verticalResizer = (0, CellResizer_1.createCellResizer)(this.editor, td, this.table, this.isRTL, false /*isHorizontal*/, this.onStartCellResize, this.onFinishEditing, this.anchorContainer);
225
+ }
226
+ };
227
+ /**
228
+ * create or remove TableInserter
229
+ * @param td td to attach to, set this to null to remove inserters (both horizontal and vertical)
230
+ */
231
+ TableEditor.prototype.setInserterTd = function (td, isHorizontal) {
232
+ var inserter = isHorizontal ? this.horizontalInserter : this.verticalInserter;
233
+ if (td === null || (inserter && inserter.node != td)) {
234
+ this.disposeTableInserter();
235
+ }
236
+ if (!this.horizontalInserter && !this.verticalInserter && td) {
237
+ var newInserter = (0, TableInserter_1.createTableInserter)(this.editor, td, this.table, this.isRTL, !!isHorizontal, this.onInserted, this.getOnMouseOut, this.anchorContainer);
238
+ if (isHorizontal) {
239
+ this.horizontalInserter = newInserter;
240
+ }
241
+ else {
242
+ this.verticalInserter = newInserter;
243
+ }
244
+ }
245
+ };
246
+ TableEditor.prototype.disposeTableResizer = function () {
247
+ if (this.tableResizer) {
248
+ (0, TableEditFeature_1.disposeTableEditFeature)(this.tableResizer);
249
+ this.tableResizer = null;
250
+ }
251
+ };
252
+ TableEditor.prototype.disposeTableInserter = function () {
253
+ if (this.horizontalInserter) {
254
+ (0, TableEditFeature_1.disposeTableEditFeature)(this.horizontalInserter);
255
+ this.horizontalInserter = null;
256
+ }
257
+ if (this.verticalInserter) {
258
+ (0, TableEditFeature_1.disposeTableEditFeature)(this.verticalInserter);
259
+ this.verticalInserter = null;
260
+ }
261
+ };
262
+ TableEditor.prototype.disposeCellResizers = function () {
263
+ if (this.horizontalResizer) {
264
+ (0, TableEditFeature_1.disposeTableEditFeature)(this.horizontalResizer);
265
+ this.horizontalResizer = null;
266
+ }
267
+ if (this.verticalResizer) {
268
+ (0, TableEditFeature_1.disposeTableEditFeature)(this.verticalResizer);
269
+ this.verticalResizer = null;
270
+ }
271
+ };
272
+ TableEditor.prototype.disposeTableMover = function () {
273
+ if (this.tableMover) {
274
+ (0, TableEditFeature_1.disposeTableEditFeature)(this.tableMover);
275
+ this.tableMover = null;
276
+ }
277
+ };
278
+ TableEditor.prototype.onStartResize = function () {
279
+ this.isCurrentlyEditing = true;
280
+ var range = this.editor.getDOMSelection();
281
+ if (range && range.type == 'range') {
282
+ this.range = range.range;
283
+ }
284
+ this.editor.takeSnapshot();
285
+ };
286
+ return TableEditor;
287
+ }());
288
+ exports.TableEditor = TableEditor;
289
+ });
290
+ //# sourceMappingURL=TableEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableEditor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/TableEditor.ts"],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,IAAI,CAAC;YAC/B,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;YAE5C,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE;gBAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;aAC5B;YAED,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAC/B,CAAC;QAyCL,kBAAC;IAAD,CAAC,AApVD,IAoVC;IApVY,kCAAW","sourcesContent":["import { createCellResizer } from './features/CellResizer';\nimport { createTableInserter } from './features/TableInserter';\nimport { createTableMover } from './features/TableMover';\nimport { createTableResizer } from './features/TableResizer';\nimport { disposeTableEditFeature } from './features/TableEditFeature';\nimport { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport type { TableEditFeature } from './features/TableEditFeature';\nimport type { IEditor, TableSelection } from 'roosterjs-content-model-types';\n\nconst INSERTER_HOVER_OFFSET = 6;\nconst enum TOP_OR_SIDE {\n top = 0,\n side = 1,\n}\n/**\n * @internal\n *\n * A table has 6 hot areas to be resized/edited (take LTR example):\n *\n * [6] [ ]\n * +[ 1 ]+--------------------+\n * |[ ]| |\n * [ ] [ ] |\n * [ ] [ ] |\n * [2] [3] |\n * [ ] [ ] |\n * [ ][ 4 ]| |\n * +------------------+--------------------+\n * | | |\n * | | |\n * | | |\n * +------------------+--------------------+\n * [5]\n *\n * 1 - Hover area to show insert column button\n * 2 - Hover area to show insert row button\n * 3 - Hover area to show vertical resizing bar\n * 4 - Hover area to show horizontal resizing bar\n * 5 - Hover area to show whole table resize handle\n * 6 - Hover area to show whole table mover handle\n *\n * When set a different current table or change current TD, we need to update these areas\n */\nexport class TableEditor {\n // 1, 2 - Insert a column or a row\n private horizontalInserter: TableEditFeature | null = null;\n private verticalInserter: TableEditFeature | null = null;\n\n // 3, 4 - Resize a column or a row from a cell\n private horizontalResizer: TableEditFeature | null = null;\n private verticalResizer: TableEditFeature | null = null;\n\n // 5 - Resize whole table\n private tableResizer: TableEditFeature | null = null;\n\n // 6 - Move as well as select whole table\n private tableMover: TableEditFeature | null = null;\n\n private isRTL: boolean;\n private range: Range | null = null;\n private isCurrentlyEditing: boolean;\n\n constructor(\n private editor: IEditor,\n public readonly table: HTMLTableElement,\n private onChanged: () => void,\n private anchorContainer?: HTMLElement,\n private contentDiv?: EventTarget | null\n ) {\n this.isRTL = editor.getDocument().defaultView?.getComputedStyle(table).direction == 'rtl';\n this.setEditorFeatures();\n this.isCurrentlyEditing = false;\n }\n\n dispose() {\n this.disposeTableResizer();\n this.disposeCellResizers();\n this.disposeTableInserter();\n this.disposeTableMover();\n }\n\n isEditing(): boolean {\n return this.isCurrentlyEditing;\n }\n\n isOwnedElement(node: Node) {\n return [\n this.tableResizer,\n this.tableMover,\n this.horizontalInserter,\n this.verticalInserter,\n this.horizontalResizer,\n this.verticalResizer,\n ]\n .filter(feature => !!feature?.div)\n .some(feature => feature?.div == node);\n }\n\n onMouseMove(x: number, y: number) {\n // Get whole table rect\n const tableRect = normalizeRect(this.table.getBoundingClientRect());\n\n //console.log('>>>tableRect', tableRect);\n if (!tableRect) {\n return;\n }\n\n // Determine if cursor is on top or side\n const topOrSide =\n y <= tableRect.top + INSERTER_HOVER_OFFSET\n ? TOP_OR_SIDE.top\n : this.isRTL\n ? x >= tableRect.right - INSERTER_HOVER_OFFSET\n ? TOP_OR_SIDE.side\n : undefined\n : x <= tableRect.left + INSERTER_HOVER_OFFSET\n ? TOP_OR_SIDE.side\n : undefined;\n const topOrSideBinary = topOrSide ? 1 : 0;\n\n // i is row index, j is column index\n for (let i = 0; i < this.table.rows.length; i++) {\n const tr = this.table.rows[i];\n let j = 0;\n for (; j < tr.cells.length; j++) {\n const td = tr.cells[j];\n const tdRect = normalizeRect(td.getBoundingClientRect());\n\n if (!tdRect || !tableRect) {\n continue;\n }\n\n // Determine the cell the cursor is in range of\n // Offset is only used for first row and column\n const lessThanBottom = y <= tdRect.bottom;\n const lessThanRight = this.isRTL\n ? x <= tdRect.right + INSERTER_HOVER_OFFSET * topOrSideBinary\n : x <= tdRect.right;\n const moreThanLeft = this.isRTL\n ? x >= tdRect.left\n : x >= tdRect.left - INSERTER_HOVER_OFFSET * topOrSideBinary;\n\n if (lessThanBottom && lessThanRight && moreThanLeft) {\n if (i === 0 && topOrSide == TOP_OR_SIDE.top) {\n const center = (tdRect.left + tdRect.right) / 2;\n const isOnRightHalf = this.isRTL ? x < center : x > center;\n this.setInserterTd(\n isOnRightHalf ? td : tr.cells[j - 1],\n false /*isHorizontal*/\n );\n } else if (j === 0 && topOrSide == TOP_OR_SIDE.side) {\n const tdAbove = this.table.rows[i - 1]?.cells[0];\n const tdAboveRect = tdAbove\n ? normalizeRect(tdAbove.getBoundingClientRect())\n : null;\n\n const isTdNotAboveMerged = !tdAboveRect\n ? null\n : this.isRTL\n ? tdAboveRect.right === tdRect.right\n : tdAboveRect.left === tdRect.left;\n\n this.setInserterTd(\n y < (tdRect.top + tdRect.bottom) / 2 && isTdNotAboveMerged\n ? tdAbove\n : td,\n true /*isHorizontal*/\n );\n } else {\n this.setInserterTd(null);\n }\n\n this.setResizingTd(td);\n\n //Cell found\n break;\n }\n }\n\n if (j < tr.cells.length) {\n break;\n }\n }\n\n // Create Mover and Resizer\n this.setEditorFeatures();\n }\n\n private setEditorFeatures() {\n if (!this.tableMover) {\n this.tableMover = createTableMover(\n this.table,\n this.editor,\n this.isRTL,\n this.onSelect,\n this.getOnMouseOut,\n this.contentDiv,\n this.anchorContainer\n );\n }\n\n if (!this.tableResizer) {\n this.tableResizer = createTableResizer(\n this.table,\n this.editor,\n this.isRTL,\n this.onStartTableResize,\n this.onFinishEditing,\n this.contentDiv,\n this.anchorContainer\n );\n }\n }\n\n private setResizingTd(td: HTMLTableCellElement) {\n if (this.horizontalResizer && this.horizontalResizer.node != td) {\n this.disposeCellResizers();\n }\n\n if (!this.horizontalResizer && td) {\n this.horizontalResizer = createCellResizer(\n this.editor,\n td,\n this.table,\n this.isRTL,\n true /*isHorizontal*/,\n this.onStartCellResize,\n this.onFinishEditing,\n this.anchorContainer\n );\n this.verticalResizer = createCellResizer(\n this.editor,\n td,\n this.table,\n this.isRTL,\n false /*isHorizontal*/,\n this.onStartCellResize,\n this.onFinishEditing,\n this.anchorContainer\n );\n }\n }\n\n /**\n * create or remove TableInserter\n * @param td td to attach to, set this to null to remove inserters (both horizontal and vertical)\n */\n private setInserterTd(td: HTMLTableCellElement | null, isHorizontal?: boolean) {\n const inserter = isHorizontal ? this.horizontalInserter : this.verticalInserter;\n if (td === null || (inserter && inserter.node != td)) {\n this.disposeTableInserter();\n }\n\n if (!this.horizontalInserter && !this.verticalInserter && td) {\n const newInserter = createTableInserter(\n this.editor,\n td,\n this.table,\n this.isRTL,\n !!isHorizontal,\n this.onInserted,\n this.getOnMouseOut,\n this.anchorContainer\n );\n if (isHorizontal) {\n this.horizontalInserter = newInserter;\n } else {\n this.verticalInserter = newInserter;\n }\n }\n }\n\n private disposeTableResizer() {\n if (this.tableResizer) {\n disposeTableEditFeature(this.tableResizer);\n this.tableResizer = null;\n }\n }\n\n private disposeTableInserter() {\n if (this.horizontalInserter) {\n disposeTableEditFeature(this.horizontalInserter);\n this.horizontalInserter = null;\n }\n if (this.verticalInserter) {\n disposeTableEditFeature(this.verticalInserter);\n this.verticalInserter = null;\n }\n }\n\n private disposeCellResizers() {\n if (this.horizontalResizer) {\n disposeTableEditFeature(this.horizontalResizer);\n this.horizontalResizer = null;\n }\n if (this.verticalResizer) {\n disposeTableEditFeature(this.verticalResizer);\n this.verticalResizer = null;\n }\n }\n\n private disposeTableMover() {\n if (this.tableMover) {\n disposeTableEditFeature(this.tableMover);\n this.tableMover = null;\n }\n }\n\n private onFinishEditing = (): false => {\n this.editor.focus();\n\n if (this.range) {\n this.editor.setDOMSelection({ type: 'range', range: this.range, isReverted: false });\n }\n\n this.editor.takeSnapshot(); // Pass in an empty callback to make sure ContentChangedEvent is triggered\n this.onChanged();\n this.isCurrentlyEditing = false;\n\n return false;\n };\n\n private onStartTableResize = () => {\n this.isCurrentlyEditing = true;\n this.onStartResize();\n };\n\n private onStartCellResize = () => {\n this.isCurrentlyEditing = true;\n this.disposeTableResizer();\n this.onStartResize();\n };\n\n private onStartResize() {\n this.isCurrentlyEditing = true;\n const range = this.editor.getDOMSelection();\n\n if (range && range.type == 'range') {\n this.range = range.range;\n }\n\n this.editor.takeSnapshot();\n }\n\n private onInserted = () => {\n this.disposeTableResizer();\n this.onFinishEditing();\n };\n\n /**\n * Public only for testing purposes\n * @param table the table to select\n */\n public onSelect = (table: HTMLTableElement) => {\n this.editor.focus();\n\n if (table) {\n const selection: TableSelection = {\n table: table,\n firstRow: 0,\n firstColumn: 0,\n lastRow: table.rows.length - 1,\n lastColumn: table.rows[table.rows.length - 1].cells.length - 1,\n type: 'table',\n };\n\n this.editor.setDOMSelection(selection);\n }\n };\n\n private getOnMouseOut = (feature: HTMLElement) => {\n return (ev: MouseEvent) => {\n if (\n feature &&\n ev.relatedTarget != feature &&\n isNodeOfType(this.contentDiv as Node, 'ELEMENT_NODE') &&\n isNodeOfType(ev.relatedTarget as Node, 'ELEMENT_NODE') &&\n !(this.contentDiv == ev.relatedTarget)\n ) {\n this.dispose();\n }\n };\n };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { IEditor } from 'roosterjs-content-model-types';
2
+ import type { TableEditFeature } from './TableEditFeature';
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare function createCellResizer(editor: IEditor, td: HTMLTableCellElement, table: HTMLTableElement, isRTL: boolean, isHorizontal: boolean, onStart: () => void, onEnd: () => false, anchorContainer?: HTMLElement): TableEditFeature | null;