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,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTableInserter = void 0;
4
+ var createElement_1 = require("../../../pluginUtils/CreateElement/createElement");
5
+ var getIntersectedRect_1 = require("../../../pluginUtils/Rect/getIntersectedRect");
6
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
+ var roosterjs_content_model_api_1 = require("roosterjs-content-model-api");
8
+ var INSERTER_COLOR = '#4A4A4A';
9
+ var INSERTER_COLOR_DARK_MODE = 'white';
10
+ var INSERTER_SIDE_LENGTH = 12;
11
+ var INSERTER_BORDER_SIZE = 1;
12
+ /**
13
+ * @internal
14
+ */
15
+ function createTableInserter(editor, td, table, isRTL, isHorizontal, onInsert, getOnMouseOut, anchorContainer) {
16
+ var tdRect = (0, roosterjs_content_model_dom_1.normalizeRect)(td.getBoundingClientRect());
17
+ var viewPort = editor.getVisibleViewport();
18
+ var tableRect = table && viewPort ? (0, getIntersectedRect_1.getIntersectedRect)([table], [viewPort]) : null;
19
+ // set inserter position
20
+ if (tdRect && tableRect) {
21
+ var document_1 = td.ownerDocument;
22
+ var createElementData = getInsertElementData(isHorizontal, editor.isDarkMode(), isRTL, editor.getDOMHelper().getDomStyle('backgroundColor') || 'white');
23
+ var div = (0, createElement_1.createElement)(createElementData, document_1);
24
+ if (isHorizontal) {
25
+ // tableRect.left/right is used because the Inserter is always intended to be on the side
26
+ div.id = 'horizontalInserter';
27
+ div.style.left = (isRTL
28
+ ? tableRect.right
29
+ : tableRect.left - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE)) + "px";
30
+ div.style.top = tdRect.bottom - 8 + "px";
31
+ div.firstChild.style.width = tableRect.right - tableRect.left + "px";
32
+ }
33
+ else {
34
+ div.id = 'verticalInserter';
35
+ div.style.left = (isRTL ? tdRect.left - 8 : tdRect.right - 8) + "px";
36
+ // tableRect.top is used because the Inserter is always intended to be on top
37
+ div.style.top = tableRect.top - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE) + "px";
38
+ div.firstChild.style.height = tableRect.bottom - tableRect.top + "px";
39
+ }
40
+ (anchorContainer || document_1.body).appendChild(div);
41
+ var handler = new TableInsertHandler(div, td, table, isHorizontal, editor, onInsert, getOnMouseOut);
42
+ return { div: div, featureHandler: handler, node: td };
43
+ }
44
+ return null;
45
+ }
46
+ exports.createTableInserter = createTableInserter;
47
+ var TableInsertHandler = /** @class */ (function () {
48
+ function TableInsertHandler(div, td, table, isHorizontal, editor, onInsert, getOnMouseOut) {
49
+ var _this = this;
50
+ this.div = div;
51
+ this.td = td;
52
+ this.table = table;
53
+ this.isHorizontal = isHorizontal;
54
+ this.editor = editor;
55
+ this.onInsert = onInsert;
56
+ this.insertTd = function () {
57
+ // Get cell coordinates
58
+ var columnIndex = _this.td.cellIndex;
59
+ var row = _this.td.parentElement && (0, roosterjs_content_model_dom_1.isElementOfType)(_this.td.parentElement, 'tr')
60
+ ? _this.td.parentElement
61
+ : undefined;
62
+ var rowIndex = row && row.rowIndex;
63
+ if ((row === null || row === void 0 ? void 0 : row.cells) == undefined || rowIndex == undefined) {
64
+ return;
65
+ }
66
+ // Insert row or column
67
+ (0, roosterjs_content_model_api_1.formatTableWithContentModel)(_this.editor, 'editTablePlugin', function (tableModel) {
68
+ _this.isHorizontal
69
+ ? (0, roosterjs_content_model_api_1.insertTableRow)(tableModel, 'insertBelow')
70
+ : (0, roosterjs_content_model_api_1.insertTableColumn)(tableModel, 'insertRight');
71
+ }, // Select cell to make insertion
72
+ {
73
+ type: 'table',
74
+ firstColumn: columnIndex,
75
+ firstRow: rowIndex,
76
+ lastColumn: columnIndex,
77
+ lastRow: rowIndex,
78
+ table: _this.table,
79
+ });
80
+ _this.onInsert();
81
+ };
82
+ this.div.addEventListener('click', this.insertTd);
83
+ this.onMouseOutEvent = getOnMouseOut(div);
84
+ this.div.addEventListener('mouseout', this.onMouseOutEvent);
85
+ }
86
+ TableInsertHandler.prototype.dispose = function () {
87
+ this.div.removeEventListener('click', this.insertTd);
88
+ if (this.onMouseOutEvent) {
89
+ this.div.removeEventListener('mouseout', this.onMouseOutEvent);
90
+ }
91
+ this.onMouseOutEvent = null;
92
+ };
93
+ return TableInsertHandler;
94
+ }());
95
+ function getInsertElementData(isHorizontal, isDark, isRTL, backgroundColor) {
96
+ var inserterColor = isDark ? INSERTER_COLOR_DARK_MODE : INSERTER_COLOR;
97
+ var outerDivStyle = "position: fixed; width: " + INSERTER_SIDE_LENGTH + "px; height: " + INSERTER_SIDE_LENGTH + "px; font-size: 16px; color: black; line-height: 8px; vertical-align: middle; text-align: center; cursor: pointer; border: solid " + INSERTER_BORDER_SIZE + "px " + inserterColor + "; border-radius: 50%; background-color: " + backgroundColor;
98
+ var leftOrRight = isRTL ? 'right' : 'left';
99
+ var childBaseStyles = "position: absolute; box-sizing: border-box; background-color: " + backgroundColor + ";";
100
+ var childInfo = {
101
+ tag: 'div',
102
+ style: childBaseStyles +
103
+ (isHorizontal
104
+ ? leftOrRight + ": 12px; top: 5px; height: 3px; border-top: 1px solid " + inserterColor + "; border-bottom: 1px solid " + inserterColor + "; border-right: 1px solid " + inserterColor + "; border-left: 0px;"
105
+ : "left: 5px; top: 12px; width: 3px; border-left: 1px solid " + inserterColor + "; border-right: 1px solid " + inserterColor + "; border-bottom: 1px solid " + inserterColor + "; border-top: 0px;"),
106
+ };
107
+ return {
108
+ tag: 'div',
109
+ style: outerDivStyle,
110
+ children: [childInfo, '+'],
111
+ };
112
+ }
113
+ //# sourceMappingURL=TableInserter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableInserter.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableInserter.ts"],"names":[],"mappings":";;;AAAA,kFAAiF;AACjF,mFAAkF;AAClF,2EAA6E;AAC7E,2EAIqC;AAMrC,IAAM,cAAc,GAAG,SAAS,CAAC;AACjC,IAAM,wBAAwB,GAAG,OAAO,CAAC;AACzC,IAAM,oBAAoB,GAA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I,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;IAED,oCAAO,GAAP;QACI,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAErD,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;SAClE;QAED,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAChC,CAAC;IAoCL,yBAAC;AAAD,CAAC,AA5DD,IA4DC;AAED,SAAS,oBAAoB,CACzB,YAAqB,EACrB,MAAe,EACf,KAAc,EACd,eAAuB;IAEvB,IAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,cAAc,CAAC;IACzE,IAAM,aAAa,GAAG,6BAA2B,oBAAoB,oBAAe,oBAAoB,wIAAmI,oBAAoB,WAAM,aAAa,gDAA2C,eAAiB,CAAC;IAC/U,IAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAM,eAAe,GAAG,mEAAiE,eAAe,MAAG,CAAC;IAC5G,IAAM,SAAS,GAAsB;QACjC,GAAG,EAAE,KAAK;QACV,KAAK,EACD,eAAe;YACf,CAAC,YAAY;gBACT,CAAC,CAAI,WAAW,6DAAwD,aAAa,mCAA8B,aAAa,kCAA6B,aAAa,wBAAqB;gBAC/L,CAAC,CAAC,8DAA4D,aAAa,kCAA6B,aAAa,mCAA8B,aAAa,uBAAoB,CAAC;KAChM,CAAC;IAEF,OAAO;QACH,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC;KAC7B,CAAC;AACN,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { getIntersectedRect } from '../../../pluginUtils/Rect/getIntersectedRect';\nimport { isElementOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport {\n formatTableWithContentModel,\n insertTableColumn,\n insertTableRow,\n} from 'roosterjs-content-model-api';\nimport type { CreateElementData } from '../../../pluginUtils/CreateElement/CreateElementData';\nimport type { Disposable } from '../../../pluginUtils/Disposable';\nimport type { TableEditFeature } from './TableEditFeature';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\nconst INSERTER_COLOR = '#4A4A4A';\nconst INSERTER_COLOR_DARK_MODE = 'white';\nconst INSERTER_SIDE_LENGTH = 12;\nconst INSERTER_BORDER_SIZE = 1;\n\n/**\n * @internal\n */\nexport function createTableInserter(\n editor: IEditor,\n td: HTMLTableCellElement,\n table: HTMLTableElement,\n isRTL: boolean,\n isHorizontal: boolean,\n onInsert: () => void,\n getOnMouseOut: (feature: HTMLElement) => (ev: MouseEvent) => void,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const tdRect = normalizeRect(td.getBoundingClientRect());\n const viewPort = editor.getVisibleViewport();\n const tableRect = table && viewPort ? getIntersectedRect([table], [viewPort]) : null;\n\n // set inserter position\n if (tdRect && tableRect) {\n const document = td.ownerDocument;\n const createElementData = getInsertElementData(\n isHorizontal,\n editor.isDarkMode(),\n isRTL,\n editor.getDOMHelper().getDomStyle('backgroundColor') || 'white'\n );\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n if (isHorizontal) {\n // tableRect.left/right is used because the Inserter is always intended to be on the side\n div.id = 'horizontalInserter';\n div.style.left = `${\n isRTL\n ? tableRect.right\n : tableRect.left - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE)\n }px`;\n div.style.top = `${tdRect.bottom - 8}px`;\n (div.firstChild as HTMLElement).style.width = `${tableRect.right - tableRect.left}px`;\n } else {\n div.id = 'verticalInserter';\n div.style.left = `${isRTL ? tdRect.left - 8 : tdRect.right - 8}px`;\n // tableRect.top is used because the Inserter is always intended to be on top\n div.style.top = `${\n tableRect.top - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE)\n }px`;\n (div.firstChild as HTMLElement).style.height = `${tableRect.bottom - tableRect.top}px`;\n }\n\n (anchorContainer || document.body).appendChild(div);\n\n const handler = new TableInsertHandler(\n div,\n td,\n table,\n isHorizontal,\n editor,\n onInsert,\n getOnMouseOut\n );\n\n return { div, featureHandler: handler, node: td };\n }\n\n return null;\n}\n\nclass TableInsertHandler implements Disposable {\n private onMouseOutEvent: null | ((ev: MouseEvent) => void);\n constructor(\n private div: HTMLDivElement,\n private td: HTMLTableCellElement,\n private table: HTMLTableElement,\n private isHorizontal: boolean,\n private editor: IEditor,\n private onInsert: () => void,\n getOnMouseOut: (feature: HTMLElement) => (ev: MouseEvent) => void\n ) {\n this.div.addEventListener('click', this.insertTd);\n this.onMouseOutEvent = getOnMouseOut(div);\n this.div.addEventListener('mouseout', this.onMouseOutEvent);\n }\n\n dispose() {\n this.div.removeEventListener('click', this.insertTd);\n\n if (this.onMouseOutEvent) {\n this.div.removeEventListener('mouseout', this.onMouseOutEvent);\n }\n\n this.onMouseOutEvent = null;\n }\n\n private insertTd = () => {\n // Get cell coordinates\n const columnIndex = this.td.cellIndex;\n const row =\n this.td.parentElement && isElementOfType(this.td.parentElement, 'tr')\n ? this.td.parentElement\n : undefined;\n const rowIndex = row && row.rowIndex;\n\n if (row?.cells == undefined || rowIndex == undefined) {\n return;\n }\n\n // Insert row or column\n formatTableWithContentModel(\n this.editor,\n 'editTablePlugin',\n tableModel => {\n this.isHorizontal\n ? insertTableRow(tableModel, 'insertBelow')\n : insertTableColumn(tableModel, 'insertRight');\n }, // Select cell to make insertion\n {\n type: 'table',\n firstColumn: columnIndex,\n firstRow: rowIndex,\n lastColumn: columnIndex,\n lastRow: rowIndex,\n table: this.table,\n }\n );\n\n this.onInsert();\n };\n}\n\nfunction getInsertElementData(\n isHorizontal: boolean,\n isDark: boolean,\n isRTL: boolean,\n backgroundColor: string\n): CreateElementData {\n const inserterColor = isDark ? INSERTER_COLOR_DARK_MODE : INSERTER_COLOR;\n const outerDivStyle = `position: fixed; width: ${INSERTER_SIDE_LENGTH}px; height: ${INSERTER_SIDE_LENGTH}px; font-size: 16px; color: black; line-height: 8px; vertical-align: middle; text-align: center; cursor: pointer; border: solid ${INSERTER_BORDER_SIZE}px ${inserterColor}; border-radius: 50%; background-color: ${backgroundColor}`;\n const leftOrRight = isRTL ? 'right' : 'left';\n const childBaseStyles = `position: absolute; box-sizing: border-box; background-color: ${backgroundColor};`;\n const childInfo: CreateElementData = {\n tag: 'div',\n style:\n childBaseStyles +\n (isHorizontal\n ? `${leftOrRight}: 12px; top: 5px; height: 3px; border-top: 1px solid ${inserterColor}; border-bottom: 1px solid ${inserterColor}; border-right: 1px solid ${inserterColor}; border-left: 0px;`\n : `left: 5px; top: 12px; width: 3px; border-left: 1px solid ${inserterColor}; border-right: 1px solid ${inserterColor}; border-bottom: 1px solid ${inserterColor}; border-top: 0px;`),\n };\n\n return {\n tag: 'div',\n style: outerDivStyle,\n children: [childInfo, '+'],\n };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { IEditor } from 'roosterjs-content-model-types';
2
+ import type { TableEditFeature } from './TableEditFeature';
3
+ /**
4
+ * @internal
5
+ * Contains the function to select whole table
6
+ * Moving behavior not implemented yet
7
+ */
8
+ export declare function createTableMover(table: HTMLTableElement, editor: IEditor, isRTL: boolean, onFinishDragging: (table: HTMLTableElement) => void, getOnMouseOut: (feature: HTMLElement) => (ev: MouseEvent) => void, contentDiv?: EventTarget | null, anchorContainer?: HTMLElement): TableEditFeature | null;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTableMover = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var createElement_1 = require("../../../pluginUtils/CreateElement/createElement");
6
+ var DragAndDropHelper_1 = require("../../../pluginUtils/DragAndDrop/DragAndDropHelper");
7
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
8
+ var TABLE_MOVER_LENGTH = 12;
9
+ var TABLE_MOVER_ID = '_Table_Mover';
10
+ /**
11
+ * @internal
12
+ * Contains the function to select whole table
13
+ * Moving behavior not implemented yet
14
+ */
15
+ function createTableMover(table, editor, isRTL, onFinishDragging, getOnMouseOut, contentDiv, anchorContainer) {
16
+ var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(table.getBoundingClientRect());
17
+ if (!isTableTopVisible(editor, rect, contentDiv)) {
18
+ return null;
19
+ }
20
+ var zoomScale = editor.getDOMHelper().calculateZoomScale();
21
+ var document = table.ownerDocument;
22
+ var createElementData = {
23
+ tag: 'div',
24
+ style: 'position: fixed; cursor: all-scroll; user-select: none; border: 1px solid #808080',
25
+ };
26
+ var div = (0, createElement_1.createElement)(createElementData, document);
27
+ div.id = TABLE_MOVER_ID;
28
+ div.style.width = TABLE_MOVER_LENGTH + "px";
29
+ div.style.height = TABLE_MOVER_LENGTH + "px";
30
+ (anchorContainer || document.body).appendChild(div);
31
+ var context = {
32
+ table: table,
33
+ zoomScale: zoomScale,
34
+ rect: rect,
35
+ isRTL: isRTL,
36
+ };
37
+ setDivPosition(context, div);
38
+ var onDragEnd = function (context, event) {
39
+ if (event.target == div) {
40
+ onFinishDragging(context.table);
41
+ }
42
+ return false;
43
+ };
44
+ var featureHandler = new TableMoverFeature(div, context, setDivPosition, {
45
+ onDragEnd: onDragEnd,
46
+ }, context.zoomScale, getOnMouseOut);
47
+ return { div: div, featureHandler: featureHandler, node: table };
48
+ }
49
+ exports.createTableMover = createTableMover;
50
+ var TableMoverFeature = /** @class */ (function (_super) {
51
+ (0, tslib_1.__extends)(TableMoverFeature, _super);
52
+ function TableMoverFeature(div, context, onSubmit, handler, zoomScale, getOnMouseOut, forceMobile, container) {
53
+ var _this = _super.call(this, div, context, onSubmit, handler, zoomScale, forceMobile) || this;
54
+ _this.div = div;
55
+ _this.onMouseOut = getOnMouseOut(div);
56
+ div.addEventListener('mouseout', _this.onMouseOut);
57
+ return _this;
58
+ }
59
+ TableMoverFeature.prototype.dispose = function () {
60
+ _super.prototype.dispose.call(this);
61
+ if (this.onMouseOut) {
62
+ this.div.removeEventListener('mouseout', this.onMouseOut);
63
+ }
64
+ this.onMouseOut = null;
65
+ };
66
+ return TableMoverFeature;
67
+ }(DragAndDropHelper_1.DragAndDropHelper));
68
+ function setDivPosition(context, trigger) {
69
+ var rect = context.rect;
70
+ if (rect) {
71
+ trigger.style.top = rect.top - TABLE_MOVER_LENGTH + "px";
72
+ trigger.style.left = rect.left - TABLE_MOVER_LENGTH - 2 + "px";
73
+ }
74
+ }
75
+ function isTableTopVisible(editor, rect, contentDiv) {
76
+ var visibleViewport = editor.getVisibleViewport();
77
+ if ((0, roosterjs_content_model_dom_1.isNodeOfType)(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {
78
+ var containerRect = (0, roosterjs_content_model_dom_1.normalizeRect)(contentDiv.getBoundingClientRect());
79
+ return !!containerRect && containerRect.top <= rect.top && visibleViewport.top <= rect.top;
80
+ }
81
+ return true;
82
+ }
83
+ //# sourceMappingURL=TableMover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableMover.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableMover.ts"],"names":[],"mappings":";;;;AAAA,kFAAiF;AACjF,wFAAuF;AACvF,2EAA0E;AAK1E,IAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,IAAM,cAAc,GAAG,cAAc,CAAC;AAEtC;;;;GAIG;AACH,SAAgB,gBAAgB,CAC5B,KAAuB,EACvB,MAAe,EACf,KAAc,EACd,gBAAmD,EACnD,aAAiE,EACjE,UAA+B,EAC/B,eAA6B;IAE7B,IAAM,IAAI,GAAG,IAAA,2CAAa,EAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAE1D,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAkB,CAAC,EAAE;QACtD,OAAO,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,CAAC,CAAC;QAExE,OAAO,CAAC,CAAC,aAAa,IAAI,aAAa,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;KAC9F;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport type { DragAndDropHandler } from '../../../pluginUtils/DragAndDrop/DragAndDropHandler';\nimport type { IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\n\nconst TABLE_MOVER_LENGTH = 12;\nconst TABLE_MOVER_ID = '_Table_Mover';\n\n/**\n * @internal\n * Contains the function to select whole table\n * Moving behavior not implemented yet\n */\nexport function createTableMover(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onFinishDragging: (table: HTMLTableElement) => void,\n getOnMouseOut: (feature: HTMLElement) => (ev: MouseEvent) => void,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableTopVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const document = table.ownerDocument;\n const createElementData = {\n tag: 'div',\n style: 'position: fixed; cursor: all-scroll; user-select: none; border: 1px solid #808080',\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_MOVER_ID;\n div.style.width = `${TABLE_MOVER_LENGTH}px`;\n div.style.height = `${TABLE_MOVER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: TableMoverContext = {\n table,\n zoomScale,\n rect,\n isRTL,\n };\n\n setDivPosition(context, div);\n\n const onDragEnd = (context: TableMoverContext, event: MouseEvent): false => {\n if (event.target == div) {\n onFinishDragging(context.table);\n }\n return false;\n };\n\n const featureHandler = new TableMoverFeature(\n div,\n context,\n setDivPosition,\n {\n onDragEnd,\n },\n context.zoomScale,\n getOnMouseOut\n );\n\n return { div, featureHandler, node: table };\n}\n\ninterface TableMoverContext {\n table: HTMLTableElement;\n zoomScale: number;\n rect: Rect | null;\n isRTL: boolean;\n}\n\ninterface TableMoverInitValue {\n event: MouseEvent;\n}\n\nclass TableMoverFeature extends DragAndDropHelper<TableMoverContext, TableMoverInitValue> {\n private onMouseOut: ((ev: MouseEvent) => void) | null;\n\n constructor(\n private div: HTMLElement,\n context: TableMoverContext,\n onSubmit: (\n context: TableMoverContext,\n trigger: HTMLElement,\n container?: HTMLElement\n ) => void,\n handler: DragAndDropHandler<TableMoverContext, TableMoverInitValue>,\n zoomScale: number,\n getOnMouseOut: (feature: HTMLElement) => (ev: MouseEvent) => void,\n forceMobile?: boolean | undefined,\n container?: HTMLElement\n ) {\n super(div, context, onSubmit, handler, zoomScale, forceMobile);\n this.onMouseOut = getOnMouseOut(div);\n div.addEventListener('mouseout', this.onMouseOut);\n }\n\n dispose(): void {\n super.dispose();\n if (this.onMouseOut) {\n this.div.removeEventListener('mouseout', this.onMouseOut);\n }\n this.onMouseOut = null;\n }\n}\n\nfunction setDivPosition(context: TableMoverContext, trigger: HTMLElement) {\n const { rect } = context;\n if (rect) {\n trigger.style.top = `${rect.top - TABLE_MOVER_LENGTH}px`;\n trigger.style.left = `${rect.left - TABLE_MOVER_LENGTH - 2}px`;\n }\n}\n\nfunction isTableTopVisible(editor: IEditor, rect: Rect | null, contentDiv?: Node | null): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return !!containerRect && containerRect.top <= rect.top && visibleViewport.top <= rect.top;\n }\n\n return true;\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 createTableResizer(table: HTMLTableElement, editor: IEditor, isRTL: boolean, onStart: () => void, onEnd: () => false, contentDiv?: EventTarget | null, anchorContainer?: HTMLElement): TableEditFeature | null;
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTableResizer = void 0;
4
+ var createElement_1 = require("../../../pluginUtils/CreateElement/createElement");
5
+ var DragAndDropHelper_1 = require("../../../pluginUtils/DragAndDrop/DragAndDropHelper");
6
+ var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
7
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
8
+ var TABLE_RESIZER_LENGTH = 12;
9
+ var TABLE_RESIZER_ID = '_Table_Resizer';
10
+ /**
11
+ * @internal
12
+ */
13
+ function createTableResizer(table, editor, isRTL, onStart, onEnd, contentDiv, anchorContainer) {
14
+ var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(table.getBoundingClientRect());
15
+ if (!isTableBottomVisible(editor, rect, contentDiv)) {
16
+ return null;
17
+ }
18
+ var document = table.ownerDocument;
19
+ var zoomScale = editor.getDOMHelper().calculateZoomScale();
20
+ var createElementData = {
21
+ tag: 'div',
22
+ style: "position: fixed; cursor: " + (isRTL ? 'ne' : 'nw') + "-resize; user-select: none; border: 1px solid #808080",
23
+ };
24
+ var div = (0, createElement_1.createElement)(createElementData, document);
25
+ div.id = TABLE_RESIZER_ID;
26
+ div.style.width = TABLE_RESIZER_LENGTH + "px";
27
+ div.style.height = TABLE_RESIZER_LENGTH + "px";
28
+ (anchorContainer || document.body).appendChild(div);
29
+ var context = {
30
+ isRTL: isRTL,
31
+ table: table,
32
+ zoomScale: zoomScale,
33
+ onStart: onStart,
34
+ onEnd: onEnd,
35
+ div: div,
36
+ editor: editor,
37
+ contentDiv: contentDiv,
38
+ };
39
+ setDivPosition(context, div);
40
+ var featureHandler = new DragAndDropHelper_1.DragAndDropHelper(div, context, hideResizer, // Resizer is hidden while dragging only
41
+ {
42
+ onDragStart: onDragStart,
43
+ onDragging: onDragging,
44
+ onDragEnd: onDragEnd,
45
+ }, zoomScale, editor.getEnvironment().isMobileOrTablet);
46
+ return { node: table, div: div, featureHandler: featureHandler };
47
+ }
48
+ exports.createTableResizer = createTableResizer;
49
+ function onDragStart(context, event) {
50
+ context.onStart();
51
+ var editor = context.editor, table = context.table;
52
+ // Get current selection
53
+ var selection = editor.getDOMSelection();
54
+ // Select first cell of the table
55
+ editor.setDOMSelection({
56
+ type: 'table',
57
+ firstColumn: 0,
58
+ firstRow: 0,
59
+ lastColumn: 0,
60
+ lastRow: 0,
61
+ table: table,
62
+ });
63
+ // Get the table content model
64
+ var cmTable = (0, roosterjs_content_model_core_1.getFirstSelectedTable)(editor.getContentModelCopy('disconnected'))[0];
65
+ // Restore selection
66
+ editor.setDOMSelection(selection);
67
+ // Save original widths and heights
68
+ var heights = [];
69
+ cmTable === null || cmTable === void 0 ? void 0 : cmTable.rows.forEach(function (row) {
70
+ heights.push(row.height);
71
+ });
72
+ var widths = [];
73
+ cmTable === null || cmTable === void 0 ? void 0 : cmTable.widths.forEach(function (width) {
74
+ widths.push(width);
75
+ });
76
+ return {
77
+ originalRect: table.getBoundingClientRect(),
78
+ cmTable: cmTable,
79
+ originalHeights: heights !== null && heights !== void 0 ? heights : [],
80
+ originalWidths: widths !== null && widths !== void 0 ? widths : [],
81
+ };
82
+ }
83
+ function onDragging(context, event, initValue, deltaX, deltaY) {
84
+ var _a, _b;
85
+ var isRTL = context.isRTL, zoomScale = context.zoomScale, table = context.table;
86
+ var originalRect = initValue.originalRect, originalHeights = initValue.originalHeights, originalWidths = initValue.originalWidths, cmTable = initValue.cmTable;
87
+ var ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);
88
+ var ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;
89
+ var shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;
90
+ var shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;
91
+ // If the width of some external table is fixed, we need to make it resizable
92
+ table.style.setProperty('width', null);
93
+ // If the height of some external table is fixed, we need to make it resizable
94
+ table.style.setProperty('height', null);
95
+ // Assign new widths and heights to the CM table
96
+ if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {
97
+ // Modify the CM Table size
98
+ for (var i = 0; i < cmTable.rows.length; i++) {
99
+ for (var j = 0; j < cmTable.rows[i].cells.length; j++) {
100
+ var cell = cmTable.rows[i].cells[j];
101
+ if (cell) {
102
+ if (shouldResizeX && i == 0) {
103
+ cmTable.widths[j] = ((_a = originalWidths[j]) !== null && _a !== void 0 ? _a : 0) * ratioX;
104
+ }
105
+ if (shouldResizeY && j == 0) {
106
+ cmTable.rows[i].height = ((_b = originalHeights[i]) !== null && _b !== void 0 ? _b : 0) * ratioY;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ // Normalize the table
112
+ (0, roosterjs_content_model_core_1.normalizeTable)(cmTable);
113
+ // Writeback CM Table size changes to DOM Table
114
+ for (var row = 0; row < table.rows.length; row++) {
115
+ var tableRow = table.rows[row];
116
+ if (tableRow.cells.length == 0) {
117
+ // Skip empty row
118
+ continue;
119
+ }
120
+ for (var col = 0; col < tableRow.cells.length; col++) {
121
+ var td = tableRow.cells[col];
122
+ td.style.width = cmTable.widths[col] + 'px';
123
+ td.style.height = cmTable.rows[row].height + 'px';
124
+ }
125
+ }
126
+ return true;
127
+ }
128
+ else {
129
+ return false;
130
+ }
131
+ }
132
+ function onDragEnd(context, event, initValue) {
133
+ if (context.editor.isDisposed()) {
134
+ return false;
135
+ }
136
+ if (isTableBottomVisible(context.editor, (0, roosterjs_content_model_dom_1.normalizeRect)(context.table.getBoundingClientRect()), context.contentDiv)) {
137
+ context.div.style.visibility = 'visible';
138
+ setDivPosition(context, context.div);
139
+ }
140
+ context.onEnd();
141
+ return false;
142
+ }
143
+ function setDivPosition(context, trigger) {
144
+ var table = context.table, isRTL = context.isRTL;
145
+ var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(table.getBoundingClientRect());
146
+ if (rect) {
147
+ trigger.style.top = rect.bottom + "px";
148
+ trigger.style.left = isRTL
149
+ ? rect.left - TABLE_RESIZER_LENGTH - 2 + "px"
150
+ : rect.right + "px";
151
+ }
152
+ }
153
+ function hideResizer(context, trigger) {
154
+ trigger.style.visibility = 'hidden';
155
+ }
156
+ function isTableBottomVisible(editor, rect, contentDiv) {
157
+ var visibleViewport = editor.getVisibleViewport();
158
+ if ((0, roosterjs_content_model_dom_1.isNodeOfType)(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {
159
+ var containerRect = (0, roosterjs_content_model_dom_1.normalizeRect)(contentDiv.getBoundingClientRect());
160
+ return (!!containerRect &&
161
+ containerRect.bottom >= rect.bottom &&
162
+ visibleViewport.bottom >= rect.bottom);
163
+ }
164
+ return true;
165
+ }
166
+ //# sourceMappingURL=TableResizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableResizer.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableResizer.ts"],"names":[],"mappings":";;;AAAA,kFAAiF;AACjF,wFAAuF;AACvF,6EAAqF;AACrF,2EAA0E;AAI1E,IAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C;;GAEG;AACH,SAAgB,kBAAkB,CAC9B,KAAuB,EACvB,MAAe,EACf,KAAc,EACd,OAAmB,EACnB,KAAkB,EAClB,UAA+B,EAC/B,eAA6B;IAE7B,IAAM,IAAI,GAAG,IAAA,2CAAa,EAAC,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,GAA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AiB,EACjB,UAAwB;IAExB,IAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IACpD,IAAI,IAAA,0CAAY,EAAC,UAAU,EAAE,cAAc,CAAC,IAAI,eAAe,IAAI,IAAI,EAAE;QACrE,IAAM,aAAa,GAAG,IAAA,2CAAa,EAAC,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,4 +1,4 @@
1
- import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
1
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Options to customize the Content Model Auto Format Plugin
4
4
  */
@@ -11,6 +11,14 @@ export declare type AutoFormatOptions = {
11
11
  * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true
12
12
  */
13
13
  autoNumbering: boolean;
14
+ /**
15
+ * When press backspace before a link, remove the hyperlink
16
+ */
17
+ autoUnlink: boolean;
18
+ /**
19
+ * When paste content, create hyperlink for the pasted link
20
+ */
21
+ autoLink: boolean;
14
22
  };
15
23
  /**
16
24
  * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
@@ -35,7 +43,7 @@ export declare class AutoFormatPlugin implements EditorPlugin {
35
43
  * editor reference so that it can call to any editor method or format API later.
36
44
  * @param editor The editor object
37
45
  */
38
- initialize(editor: IStandaloneEditor): void;
46
+ initialize(editor: IEditor): void;
39
47
  /**
40
48
  * The last method that editor will call to a plugin before it is disposed.
41
49
  * Plugin can take this chance to clear the reference to editor. After this method is
@@ -50,4 +58,5 @@ export declare class AutoFormatPlugin implements EditorPlugin {
50
58
  */
51
59
  onPluginEvent(event: PluginEvent): void;
52
60
  private handleKeyDownEvent;
61
+ private handleContentChangedEvent;
53
62
  }
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "./keyboardListTrigger"], function (require, exports, keyboardListTrigger_1) {
1
+ define(["require", "exports", "./link/createLink", "./link/createLinkAfterSpace", "./list/keyboardListTrigger", "./link/unlink"], function (require, exports, createLink_1, createLinkAfterSpace_1, keyboardListTrigger_1, unlink_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AutoFormatPlugin = void 0;
@@ -8,6 +8,8 @@ define(["require", "exports", "./keyboardListTrigger"], function (require, expor
8
8
  var DefaultOptions = {
9
9
  autoBullet: true,
10
10
  autoNumbering: true,
11
+ autoUnlink: false,
12
+ autoLink: true,
11
13
  };
12
14
  /**
13
15
  * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
@@ -59,22 +61,37 @@ define(["require", "exports", "./keyboardListTrigger"], function (require, expor
59
61
  case 'keyDown':
60
62
  this.handleKeyDownEvent(this.editor, event);
61
63
  break;
64
+ case 'contentChanged':
65
+ this.handleContentChangedEvent(this.editor, event);
66
+ break;
62
67
  }
63
68
  }
64
69
  };
65
70
  AutoFormatPlugin.prototype.handleKeyDownEvent = function (editor, event) {
66
71
  var rawEvent = event.rawEvent;
67
72
  if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
73
+ var _a = this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering, autoUnlink = _a.autoUnlink, autoLink = _a.autoLink;
68
74
  switch (rawEvent.key) {
69
75
  case ' ':
70
- var _a = this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering;
71
- if (autoBullet || autoNumbering) {
72
- (0, keyboardListTrigger_1.keyboardListTrigger)(editor, rawEvent, autoBullet, autoNumbering);
76
+ (0, keyboardListTrigger_1.keyboardListTrigger)(editor, rawEvent, autoBullet, autoNumbering);
77
+ if (autoLink) {
78
+ (0, createLinkAfterSpace_1.createLinkAfterSpace)(editor);
79
+ }
80
+ break;
81
+ case 'Backspace':
82
+ if (autoUnlink) {
83
+ (0, unlink_1.unlink)(editor, rawEvent);
73
84
  }
74
85
  break;
75
86
  }
76
87
  }
77
88
  };
89
+ AutoFormatPlugin.prototype.handleContentChangedEvent = function (editor, event) {
90
+ var autoLink = this.options.autoLink;
91
+ if (event.source == 'Paste' && autoLink) {
92
+ (0, createLink_1.createLink)(editor);
93
+ }
94
+ };
78
95
  return AutoFormatPlugin;
79
96
  }());
80
97
  exports.AutoFormatPlugin = AutoFormatPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":";;;;IAuBA;;OAEG;IACH,IAAM,cAAc,GAAgC;QAChD,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;KACtB,CAAC;IAEF;;;OAGG;IACH;QAGI;;;;WAIG;QACH,0BAAoB,OAA2C;YAA3C,wBAAA,EAAA,wBAA2C;YAA3C,YAAO,GAAP,OAAO,CAAoC;YAPvD,WAAM,GAA6B,IAAI,CAAC;QAOkB,CAAC;QAEnE;;WAEG;QACH,kCAAO,GAAP;YACI,OAAO,YAAY,CAAC;QACxB,CAAC;QAED;;;;;WAKG;QACH,qCAAU,GAAV,UAAW,MAAyB;YAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,kCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QAED;;;;;WAKG;QACH,wCAAa,GAAb,UAAc,KAAkB;YAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,QAAQ,KAAK,CAAC,SAAS,EAAE;oBACrB,KAAK,SAAS;wBACV,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;wBAC5C,MAAM;iBACb;aACJ;QACL,CAAC;QAEO,6CAAkB,GAA1B,UAA2B,MAAyB,EAAE,KAAmB;YACrE,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAC3D,QAAQ,QAAQ,CAAC,GAAG,EAAE;oBAClB,KAAK,GAAG;wBACE,IAAA,KAAgC,IAAI,CAAC,OAAO,EAA1C,UAAU,gBAAA,EAAE,aAAa,mBAAiB,CAAC;wBACnD,IAAI,UAAU,IAAI,aAAa,EAAE;4BAC7B,IAAA,yCAAmB,EAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;yBACpE;wBACD,MAAM;iBACb;aACJ;QACL,CAAC;QACL,uBAAC;IAAD,CAAC,AAjED,IAiEC;IAjEY,4CAAgB","sourcesContent":["import { keyboardListTrigger } from './keyboardListTrigger';\nimport type {\n EditorPlugin,\n IStandaloneEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Options to customize the Content Model Auto Format Plugin\n */\nexport type AutoFormatOptions = {\n /**\n * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true\n */\n autoBullet: boolean;\n\n /**\n * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true\n */\n autoNumbering: boolean;\n};\n\n/**\n * @internal\n */\nconst DefaultOptions: Required<AutoFormatOptions> = {\n autoBullet: true,\n autoNumbering: true,\n};\n\n/**\n * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.\n * It can be customized with options to enable or disable auto list features.\n */\nexport class AutoFormatPlugin implements EditorPlugin {\n private editor: IStandaloneEditor | null = null;\n\n /**\n * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:\n * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to true.\n * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to true.\n */\n constructor(private options: AutoFormatOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'AutoFormat';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IStandaloneEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IStandaloneEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case ' ':\n const { autoBullet, autoNumbering } = this.options;\n if (autoBullet || autoNumbering) {\n keyboardListTrigger(editor, rawEvent, autoBullet, autoNumbering);\n }\n break;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":";;;;IAqCA;;OAEG;IACH,IAAM,cAAc,GAAgC;QAChD,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;KACjB,CAAC;IAEF;;;OAGG;IACH;QAGI;;;;WAIG;QACH,0BAAoB,OAA2C;YAA3C,wBAAA,EAAA,wBAA2C;YAA3C,YAAO,GAA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Z,IAAI,UAAU,EAAE;4BACZ,IAAA,eAAM,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;yBAC5B;wBACD,MAAM;iBACb;aACJ;QACL,CAAC;QAEO,oDAAyB,GAAjC,UAAkC,MAAe,EAAE,KAA0B;YACjE,IAAA,QAAQ,GAAK,IAAI,CAAC,OAAO,SAAjB,CAAkB;YAClC,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,IAAI,QAAQ,EAAE;gBACrC,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;aACtB;QACL,CAAC;QACL,uBAAC;IAAD,CAAC,AAjFD,IAiFC;IAjFY,4CAAgB","sourcesContent":["import { createLink } from './link/createLink';\nimport { createLinkAfterSpace } from './link/createLinkAfterSpace';\nimport { keyboardListTrigger } from './list/keyboardListTrigger';\nimport { unlink } from './link/unlink';\nimport type {\n ContentChangedEvent,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Options to customize the Content Model Auto Format Plugin\n */\nexport type AutoFormatOptions = {\n /**\n * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true\n */\n autoBullet: boolean;\n\n /**\n * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true\n */\n autoNumbering: boolean;\n\n /**\n * When press backspace before a link, remove the hyperlink\n */\n autoUnlink: boolean;\n\n /**\n * When paste content, create hyperlink for the pasted link\n */\n autoLink: boolean;\n};\n\n/**\n * @internal\n */\nconst DefaultOptions: Required<AutoFormatOptions> = {\n autoBullet: true,\n autoNumbering: true,\n autoUnlink: false,\n autoLink: true,\n};\n\n/**\n * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.\n * It can be customized with options to enable or disable auto list features.\n */\nexport class AutoFormatPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n\n /**\n * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:\n * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to true.\n * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to true.\n */\n constructor(private options: AutoFormatOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'AutoFormat';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n case 'contentChanged':\n this.handleContentChangedEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n const { autoBullet, autoNumbering, autoUnlink, autoLink } = this.options;\n switch (rawEvent.key) {\n case ' ':\n keyboardListTrigger(editor, rawEvent, autoBullet, autoNumbering);\n if (autoLink) {\n createLinkAfterSpace(editor);\n }\n break;\n case 'Backspace':\n if (autoUnlink) {\n unlink(editor, rawEvent);\n }\n break;\n }\n }\n }\n\n private handleContentChangedEvent(editor: IEditor, event: ContentChangedEvent) {\n const { autoLink } = this.options;\n if (event.source == 'Paste' && autoLink) {\n createLink(editor);\n }\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function createLink(editor: IEditor): void;
@@ -0,0 +1,26 @@
1
+ define(["require", "exports", "roosterjs-content-model-dom", "./getLinkSegment"], function (require, exports, roosterjs_content_model_dom_1, getLinkSegment_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createLink = void 0;
5
+ /**
6
+ * @internal
7
+ */
8
+ function createLink(editor) {
9
+ editor.formatContentModel(function (model) {
10
+ var link = (0, getLinkSegment_1.getLinkSegment)(model);
11
+ if (link && !link.link) {
12
+ (0, roosterjs_content_model_dom_1.addLink)(link, {
13
+ format: {
14
+ href: link.text,
15
+ underline: true,
16
+ },
17
+ dataset: {},
18
+ });
19
+ return true;
20
+ }
21
+ return false;
22
+ });
23
+ }
24
+ exports.createLink = createLink;
25
+ });
26
+ //# sourceMappingURL=createLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLink.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,MAAM,CAAC,kBAAkB,CAAC,UAAA,KAAK;YAC3B,IAAM,IAAI,GAAG,IAAA,+BAAc,EAAC,KAAK,CAAC,CAAC;YACnC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACpB,IAAA,qCAAO,EAAC,IAAI,EAAE;oBACV,MAAM,EAAE;wBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,SAAS,EAAE,IAAI;qBAClB;oBACD,OAAO,EAAE,EAAE;iBACd,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;aACf;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAfD,gCAeC","sourcesContent":["import { addLink } from 'roosterjs-content-model-dom';\nimport { getLinkSegment } from './getLinkSegment';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function createLink(editor: IEditor) {\n editor.formatContentModel(model => {\n const link = getLinkSegment(model);\n if (link && !link.link) {\n addLink(link, {\n format: {\n href: link.text,\n underline: true,\n },\n dataset: {},\n });\n return true;\n }\n return false;\n });\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function createLinkAfterSpace(editor: IEditor): void;