roosterjs-content-model-plugins 9.0.1 → 9.2.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 (331) hide show
  1. package/lib/autoFormat/AutoFormatPlugin.d.ts +19 -4
  2. package/lib/autoFormat/AutoFormatPlugin.js +61 -6
  3. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
  4. package/lib/autoFormat/hyphen/transformHyphen.d.ts +5 -0
  5. package/lib/autoFormat/hyphen/transformHyphen.js +35 -0
  6. package/lib/autoFormat/hyphen/transformHyphen.js.map +1 -0
  7. package/lib/autoFormat/link/createLink.js +8 -6
  8. package/lib/autoFormat/link/createLink.js.map +1 -1
  9. package/lib/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
  10. package/lib/autoFormat/link/createLinkAfterSpace.js +17 -34
  11. package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -1
  12. package/lib/autoFormat/link/unlink.js +4 -5
  13. package/lib/autoFormat/link/unlink.js.map +1 -1
  14. package/lib/autoFormat/list/keyboardListTrigger.d.ts +2 -2
  15. package/lib/autoFormat/list/keyboardListTrigger.js +9 -19
  16. package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
  17. package/lib/autoFormat/numbers/transformFraction.d.ts +5 -0
  18. package/lib/autoFormat/numbers/transformFraction.js +27 -0
  19. package/lib/autoFormat/numbers/transformFraction.js.map +1 -0
  20. package/lib/autoFormat/numbers/transformOrdinals.d.ts +5 -0
  21. package/lib/autoFormat/numbers/transformOrdinals.js +32 -0
  22. package/lib/autoFormat/numbers/transformOrdinals.js.map +1 -0
  23. package/lib/customReplace/CustomReplacePlugin.d.ts +61 -0
  24. package/lib/customReplace/CustomReplacePlugin.js +87 -0
  25. package/lib/customReplace/CustomReplacePlugin.js.map +1 -0
  26. package/lib/edit/EditPlugin.js +19 -1
  27. package/lib/edit/EditPlugin.js.map +1 -1
  28. package/lib/edit/deleteSteps/deleteList.js +13 -7
  29. package/lib/edit/deleteSteps/deleteList.js.map +1 -1
  30. package/lib/edit/inputSteps/handleEnterOnList.js +9 -2
  31. package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
  32. package/lib/edit/keyboardDelete.js +2 -2
  33. package/lib/edit/keyboardDelete.js.map +1 -1
  34. package/lib/edit/keyboardTab.js +28 -12
  35. package/lib/edit/keyboardTab.js.map +1 -1
  36. package/lib/edit/tabUtils/handleTabOnList.d.ts +2 -2
  37. package/lib/edit/tabUtils/handleTabOnList.js +3 -3
  38. package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
  39. package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
  40. package/lib/edit/tabUtils/handleTabOnParagraph.js +2 -2
  41. package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
  42. package/lib/edit/tabUtils/handleTabOnTable.d.ts +6 -0
  43. package/lib/edit/tabUtils/handleTabOnTable.js +25 -0
  44. package/lib/edit/tabUtils/handleTabOnTable.js.map +1 -0
  45. package/lib/edit/tabUtils/handleTabOnTableCell.d.ts +6 -0
  46. package/lib/edit/tabUtils/handleTabOnTableCell.js +40 -0
  47. package/lib/edit/tabUtils/handleTabOnTableCell.js.map +1 -0
  48. package/lib/hyperlink/HyperlinkPlugin.d.ts +48 -0
  49. package/lib/hyperlink/HyperlinkPlugin.js +141 -0
  50. package/lib/hyperlink/HyperlinkPlugin.js.map +1 -0
  51. package/lib/hyperlink/HyperlinkToolTip.d.ts +7 -0
  52. package/lib/hyperlink/HyperlinkToolTip.js +3 -0
  53. package/lib/hyperlink/HyperlinkToolTip.js.map +1 -0
  54. package/lib/index.d.ts +9 -1
  55. package/lib/index.js +10 -1
  56. package/lib/index.js.map +1 -1
  57. package/lib/markdown/MarkdownPlugin.d.ts +13 -4
  58. package/lib/markdown/MarkdownPlugin.js +31 -12
  59. package/lib/markdown/MarkdownPlugin.js.map +1 -1
  60. package/lib/markdown/utils/setFormat.d.ts +2 -2
  61. package/lib/markdown/utils/setFormat.js +21 -29
  62. package/lib/markdown/utils/setFormat.js.map +1 -1
  63. package/lib/picker/PickerHandler.d.ts +112 -0
  64. package/lib/picker/PickerHandler.js +3 -0
  65. package/lib/picker/PickerHandler.js.map +1 -0
  66. package/lib/picker/PickerHelper.d.ts +22 -0
  67. package/lib/picker/PickerHelper.js +3 -0
  68. package/lib/picker/PickerHelper.js.map +1 -0
  69. package/lib/picker/PickerHelperImpl.d.ts +25 -0
  70. package/lib/picker/PickerHelperImpl.js +54 -0
  71. package/lib/picker/PickerHelperImpl.js.map +1 -0
  72. package/lib/picker/PickerPlugin.d.ts +54 -0
  73. package/lib/picker/PickerPlugin.js +217 -0
  74. package/lib/picker/PickerPlugin.js.map +1 -0
  75. package/lib/picker/getQueryString.d.ts +5 -0
  76. package/lib/picker/getQueryString.js +36 -0
  77. package/lib/picker/getQueryString.js.map +1 -0
  78. package/lib/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
  79. package/lib/pluginUtils/Rect/getDOMInsertPointRect.js +57 -0
  80. package/lib/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
  81. package/lib/shortcut/ShortcutPlugin.js +1 -0
  82. package/lib/shortcut/ShortcutPlugin.js.map +1 -1
  83. package/lib/shortcut/shortcuts.d.ts +10 -3
  84. package/lib/shortcut/shortcuts.js +21 -4
  85. package/lib/shortcut/shortcuts.js.map +1 -1
  86. package/lib/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  87. package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  88. package/lib/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
  89. package/lib/tableEdit/OnTableEditorCreatedCallback.js +3 -0
  90. package/lib/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
  91. package/lib/tableEdit/TableEditPlugin.d.ts +4 -1
  92. package/lib/tableEdit/TableEditPlugin.js +5 -2
  93. package/lib/tableEdit/TableEditPlugin.js.map +1 -1
  94. package/lib/tableEdit/editors/TableEditor.d.ts +4 -1
  95. package/lib/tableEdit/editors/TableEditor.js +23 -7
  96. package/lib/tableEdit/editors/TableEditor.js.map +1 -1
  97. package/lib/tableEdit/editors/features/TableEditFeature.js +3 -3
  98. package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -1
  99. package/lib/tableEdit/editors/features/TableInserter.d.ts +2 -1
  100. package/lib/tableEdit/editors/features/TableInserter.js +7 -9
  101. package/lib/tableEdit/editors/features/TableInserter.js.map +1 -1
  102. package/lib/tableEdit/editors/features/TableMover.d.ts +2 -1
  103. package/lib/tableEdit/editors/features/TableMover.js +8 -11
  104. package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
  105. package/lib/tableEdit/editors/features/TableResizer.d.ts +2 -1
  106. package/lib/tableEdit/editors/features/TableResizer.js +19 -3
  107. package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
  108. package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +19 -4
  109. package/lib-amd/autoFormat/AutoFormatPlugin.js +57 -7
  110. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
  111. package/lib-amd/autoFormat/hyphen/transformHyphen.d.ts +5 -0
  112. package/lib-amd/autoFormat/hyphen/transformHyphen.js +36 -0
  113. package/lib-amd/autoFormat/hyphen/transformHyphen.js.map +1 -0
  114. package/lib-amd/autoFormat/link/createLink.js +8 -6
  115. package/lib-amd/autoFormat/link/createLink.js.map +1 -1
  116. package/lib-amd/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
  117. package/lib-amd/autoFormat/link/createLinkAfterSpace.js +18 -34
  118. package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -1
  119. package/lib-amd/autoFormat/link/unlink.js +4 -5
  120. package/lib-amd/autoFormat/link/unlink.js.map +1 -1
  121. package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +2 -2
  122. package/lib-amd/autoFormat/list/keyboardListTrigger.js +10 -19
  123. package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
  124. package/lib-amd/autoFormat/numbers/transformFraction.d.ts +5 -0
  125. package/lib-amd/autoFormat/numbers/transformFraction.js +28 -0
  126. package/lib-amd/autoFormat/numbers/transformFraction.js.map +1 -0
  127. package/lib-amd/autoFormat/numbers/transformOrdinals.d.ts +5 -0
  128. package/lib-amd/autoFormat/numbers/transformOrdinals.js +33 -0
  129. package/lib-amd/autoFormat/numbers/transformOrdinals.js.map +1 -0
  130. package/lib-amd/customReplace/CustomReplacePlugin.d.ts +61 -0
  131. package/lib-amd/customReplace/CustomReplacePlugin.js +88 -0
  132. package/lib-amd/customReplace/CustomReplacePlugin.js.map +1 -0
  133. package/lib-amd/edit/EditPlugin.js +19 -1
  134. package/lib-amd/edit/EditPlugin.js.map +1 -1
  135. package/lib-amd/edit/deleteSteps/deleteList.js +13 -7
  136. package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
  137. package/lib-amd/edit/inputSteps/handleEnterOnList.js +9 -3
  138. package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
  139. package/lib-amd/edit/keyboardDelete.js +2 -2
  140. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  141. package/lib-amd/edit/keyboardTab.js +27 -13
  142. package/lib-amd/edit/keyboardTab.js.map +1 -1
  143. package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +2 -2
  144. package/lib-amd/edit/tabUtils/handleTabOnList.js +3 -3
  145. package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
  146. package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
  147. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +2 -2
  148. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
  149. package/lib-amd/edit/tabUtils/handleTabOnTable.d.ts +6 -0
  150. package/lib-amd/edit/tabUtils/handleTabOnTable.js +25 -0
  151. package/lib-amd/edit/tabUtils/handleTabOnTable.js.map +1 -0
  152. package/lib-amd/edit/tabUtils/handleTabOnTableCell.d.ts +6 -0
  153. package/lib-amd/edit/tabUtils/handleTabOnTableCell.js +40 -0
  154. package/lib-amd/edit/tabUtils/handleTabOnTableCell.js.map +1 -0
  155. package/lib-amd/hyperlink/HyperlinkPlugin.d.ts +48 -0
  156. package/lib-amd/hyperlink/HyperlinkPlugin.js +142 -0
  157. package/lib-amd/hyperlink/HyperlinkPlugin.js.map +1 -0
  158. package/lib-amd/hyperlink/HyperlinkToolTip.d.ts +7 -0
  159. package/lib-amd/hyperlink/HyperlinkToolTip.js +5 -0
  160. package/lib-amd/hyperlink/HyperlinkToolTip.js.map +1 -0
  161. package/lib-amd/index.d.ts +9 -1
  162. package/lib-amd/index.js +7 -2
  163. package/lib-amd/index.js.map +1 -1
  164. package/lib-amd/markdown/MarkdownPlugin.d.ts +13 -4
  165. package/lib-amd/markdown/MarkdownPlugin.js +31 -12
  166. package/lib-amd/markdown/MarkdownPlugin.js.map +1 -1
  167. package/lib-amd/markdown/utils/setFormat.d.ts +2 -2
  168. package/lib-amd/markdown/utils/setFormat.js +21 -29
  169. package/lib-amd/markdown/utils/setFormat.js.map +1 -1
  170. package/lib-amd/picker/PickerHandler.d.ts +112 -0
  171. package/lib-amd/picker/PickerHandler.js +5 -0
  172. package/lib-amd/picker/PickerHandler.js.map +1 -0
  173. package/lib-amd/picker/PickerHelper.d.ts +22 -0
  174. package/lib-amd/picker/PickerHelper.js +5 -0
  175. package/lib-amd/picker/PickerHelper.js.map +1 -0
  176. package/lib-amd/picker/PickerHelperImpl.d.ts +25 -0
  177. package/lib-amd/picker/PickerHelperImpl.js +53 -0
  178. package/lib-amd/picker/PickerHelperImpl.js.map +1 -0
  179. package/lib-amd/picker/PickerPlugin.d.ts +54 -0
  180. package/lib-amd/picker/PickerPlugin.js +215 -0
  181. package/lib-amd/picker/PickerPlugin.js.map +1 -0
  182. package/lib-amd/picker/getQueryString.d.ts +5 -0
  183. package/lib-amd/picker/getQueryString.js +37 -0
  184. package/lib-amd/picker/getQueryString.js.map +1 -0
  185. package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
  186. package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js +58 -0
  187. package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
  188. package/lib-amd/shortcut/ShortcutPlugin.js +1 -0
  189. package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
  190. package/lib-amd/shortcut/shortcuts.d.ts +10 -3
  191. package/lib-amd/shortcut/shortcuts.js +21 -4
  192. package/lib-amd/shortcut/shortcuts.js.map +1 -1
  193. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  194. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  195. package/lib-amd/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
  196. package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js +5 -0
  197. package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
  198. package/lib-amd/tableEdit/TableEditPlugin.d.ts +4 -1
  199. package/lib-amd/tableEdit/TableEditPlugin.js +5 -2
  200. package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -1
  201. package/lib-amd/tableEdit/editors/TableEditor.d.ts +4 -1
  202. package/lib-amd/tableEdit/editors/TableEditor.js +23 -7
  203. package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
  204. package/lib-amd/tableEdit/editors/features/TableEditFeature.js +3 -3
  205. package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -1
  206. package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +2 -1
  207. package/lib-amd/tableEdit/editors/features/TableInserter.js +7 -9
  208. package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -1
  209. package/lib-amd/tableEdit/editors/features/TableMover.d.ts +2 -1
  210. package/lib-amd/tableEdit/editors/features/TableMover.js +8 -11
  211. package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
  212. package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +2 -1
  213. package/lib-amd/tableEdit/editors/features/TableResizer.js +19 -4
  214. package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
  215. package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +19 -4
  216. package/lib-mjs/autoFormat/AutoFormatPlugin.js +61 -6
  217. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
  218. package/lib-mjs/autoFormat/hyphen/transformHyphen.d.ts +5 -0
  219. package/lib-mjs/autoFormat/hyphen/transformHyphen.js +31 -0
  220. package/lib-mjs/autoFormat/hyphen/transformHyphen.js.map +1 -0
  221. package/lib-mjs/autoFormat/link/createLink.js +9 -7
  222. package/lib-mjs/autoFormat/link/createLink.js.map +1 -1
  223. package/lib-mjs/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
  224. package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +17 -34
  225. package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -1
  226. package/lib-mjs/autoFormat/link/unlink.js +4 -5
  227. package/lib-mjs/autoFormat/link/unlink.js.map +1 -1
  228. package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +2 -2
  229. package/lib-mjs/autoFormat/list/keyboardListTrigger.js +9 -19
  230. package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
  231. package/lib-mjs/autoFormat/numbers/transformFraction.d.ts +5 -0
  232. package/lib-mjs/autoFormat/numbers/transformFraction.js +23 -0
  233. package/lib-mjs/autoFormat/numbers/transformFraction.js.map +1 -0
  234. package/lib-mjs/autoFormat/numbers/transformOrdinals.d.ts +5 -0
  235. package/lib-mjs/autoFormat/numbers/transformOrdinals.js +28 -0
  236. package/lib-mjs/autoFormat/numbers/transformOrdinals.js.map +1 -0
  237. package/lib-mjs/customReplace/CustomReplacePlugin.d.ts +61 -0
  238. package/lib-mjs/customReplace/CustomReplacePlugin.js +84 -0
  239. package/lib-mjs/customReplace/CustomReplacePlugin.js.map +1 -0
  240. package/lib-mjs/edit/EditPlugin.js +19 -1
  241. package/lib-mjs/edit/EditPlugin.js.map +1 -1
  242. package/lib-mjs/edit/deleteSteps/deleteList.js +13 -7
  243. package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
  244. package/lib-mjs/edit/inputSteps/handleEnterOnList.js +9 -2
  245. package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
  246. package/lib-mjs/edit/keyboardDelete.js +2 -2
  247. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  248. package/lib-mjs/edit/keyboardTab.js +28 -12
  249. package/lib-mjs/edit/keyboardTab.js.map +1 -1
  250. package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +2 -2
  251. package/lib-mjs/edit/tabUtils/handleTabOnList.js +3 -3
  252. package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
  253. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
  254. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +2 -2
  255. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
  256. package/lib-mjs/edit/tabUtils/handleTabOnTable.d.ts +6 -0
  257. package/lib-mjs/edit/tabUtils/handleTabOnTable.js +21 -0
  258. package/lib-mjs/edit/tabUtils/handleTabOnTable.js.map +1 -0
  259. package/lib-mjs/edit/tabUtils/handleTabOnTableCell.d.ts +6 -0
  260. package/lib-mjs/edit/tabUtils/handleTabOnTableCell.js +36 -0
  261. package/lib-mjs/edit/tabUtils/handleTabOnTableCell.js.map +1 -0
  262. package/lib-mjs/hyperlink/HyperlinkPlugin.d.ts +48 -0
  263. package/lib-mjs/hyperlink/HyperlinkPlugin.js +138 -0
  264. package/lib-mjs/hyperlink/HyperlinkPlugin.js.map +1 -0
  265. package/lib-mjs/hyperlink/HyperlinkToolTip.d.ts +7 -0
  266. package/lib-mjs/hyperlink/HyperlinkToolTip.js +2 -0
  267. package/lib-mjs/hyperlink/HyperlinkToolTip.js.map +1 -0
  268. package/lib-mjs/index.d.ts +9 -1
  269. package/lib-mjs/index.js +5 -1
  270. package/lib-mjs/index.js.map +1 -1
  271. package/lib-mjs/markdown/MarkdownPlugin.d.ts +13 -4
  272. package/lib-mjs/markdown/MarkdownPlugin.js +31 -12
  273. package/lib-mjs/markdown/MarkdownPlugin.js.map +1 -1
  274. package/lib-mjs/markdown/utils/setFormat.d.ts +2 -2
  275. package/lib-mjs/markdown/utils/setFormat.js +21 -29
  276. package/lib-mjs/markdown/utils/setFormat.js.map +1 -1
  277. package/lib-mjs/picker/PickerHandler.d.ts +112 -0
  278. package/lib-mjs/picker/PickerHandler.js +2 -0
  279. package/lib-mjs/picker/PickerHandler.js.map +1 -0
  280. package/lib-mjs/picker/PickerHelper.d.ts +22 -0
  281. package/lib-mjs/picker/PickerHelper.js +2 -0
  282. package/lib-mjs/picker/PickerHelper.js.map +1 -0
  283. package/lib-mjs/picker/PickerHelperImpl.d.ts +25 -0
  284. package/lib-mjs/picker/PickerHelperImpl.js +51 -0
  285. package/lib-mjs/picker/PickerHelperImpl.js.map +1 -0
  286. package/lib-mjs/picker/PickerPlugin.d.ts +54 -0
  287. package/lib-mjs/picker/PickerPlugin.js +214 -0
  288. package/lib-mjs/picker/PickerPlugin.js.map +1 -0
  289. package/lib-mjs/picker/getQueryString.d.ts +5 -0
  290. package/lib-mjs/picker/getQueryString.js +32 -0
  291. package/lib-mjs/picker/getQueryString.js.map +1 -0
  292. package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
  293. package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js +53 -0
  294. package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
  295. package/lib-mjs/shortcut/ShortcutPlugin.js +2 -1
  296. package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
  297. package/lib-mjs/shortcut/shortcuts.d.ts +10 -3
  298. package/lib-mjs/shortcut/shortcuts.js +20 -3
  299. package/lib-mjs/shortcut/shortcuts.js.map +1 -1
  300. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  301. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  302. package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
  303. package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js +2 -0
  304. package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
  305. package/lib-mjs/tableEdit/TableEditPlugin.d.ts +4 -1
  306. package/lib-mjs/tableEdit/TableEditPlugin.js +5 -2
  307. package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -1
  308. package/lib-mjs/tableEdit/editors/TableEditor.d.ts +4 -1
  309. package/lib-mjs/tableEdit/editors/TableEditor.js +24 -8
  310. package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
  311. package/lib-mjs/tableEdit/editors/features/TableEditFeature.js +3 -3
  312. package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -1
  313. package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +2 -1
  314. package/lib-mjs/tableEdit/editors/features/TableInserter.js +7 -9
  315. package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -1
  316. package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +2 -1
  317. package/lib-mjs/tableEdit/editors/features/TableMover.js +8 -11
  318. package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
  319. package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +2 -1
  320. package/lib-mjs/tableEdit/editors/features/TableResizer.js +19 -3
  321. package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
  322. package/package.json +5 -5
  323. package/lib/autoFormat/link/getLinkSegment.d.ts +0 -5
  324. package/lib/autoFormat/link/getLinkSegment.js +0 -27
  325. package/lib/autoFormat/link/getLinkSegment.js.map +0 -1
  326. package/lib-amd/autoFormat/link/getLinkSegment.d.ts +0 -5
  327. package/lib-amd/autoFormat/link/getLinkSegment.js +0 -27
  328. package/lib-amd/autoFormat/link/getLinkSegment.js.map +0 -1
  329. package/lib-mjs/autoFormat/link/getLinkSegment.d.ts +0 -5
  330. package/lib-mjs/autoFormat/link/getLinkSegment.js +0 -23
  331. package/lib-mjs/autoFormat/link/getLinkSegment.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"handleTabOnParagraph.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnParagraph.ts"],"names":[],"mappings":";;;AAAA,2EAAgF;AAChF,2EAAkE;AAGlE,IAAM,SAAS,GAAG,MAAM,CAAC;AACzB,IAAM,KAAK,GAAG,GAAG,CAAC;AAElB;;;;;;;;;;;;;;GAcG;AACH,SAAgB,oBAAoB,CAChC,KAA2B,EAC3B,SAAgC,EAChC,QAAuB;IAEvB,IAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;IAClF,IAAM,WAAW,GACb,gBAAgB,CAAC,MAAM,KAAK,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,iBAAiB,CAAC;IAC3F,IAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;IAC9E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,iBAAiB,IAAI,WAAW,CAAC,IAAI,aAAa,EAAE;QACrF,IAAA,KAAyC,SAAS,CAAC,MAAM,EAAvD,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,SAAS,eAAqB,CAAC;QAChE,IAAM,KAAK,GAAG,SAAS,KAAK,KAAK,CAAC;QAClC,IACI,QAAQ,CAAC,QAAQ;YACjB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,IAAI,UAAU,IAAI,KAAK,CAAC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AC,WAAW,KAAK,iBAAiB,EAAzC,CAAyC,CACvD,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;gBACpB,IAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;gBAC5D,IAAM,OAAO,GAAG,IAAA,wCAAU,EAAC,SAAS,EAAE,YAAY,CAAC,CAAC;gBACpD,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;aACtD;iBAAM;gBACH,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBACpD,IAAM,eAAe,GAAG,SAAS,CAAC,MAAM,CAAC;gBACzC,IAAI,OAAO,CAAC,WAAW,IAAI,MAAM,EAAE;oBAC/B,IAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC;oBACjE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;wBAC5B,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;qBACjD;yBAAM,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,SAAS,EAAE;wBACjE,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;qBAChE;yBAAM;wBACH,OAAO,KAAK,CAAC;qBAChB;iBACJ;aACJ;SACJ;KACJ;IACD,QAAQ,CAAC,cAAc,EAAE,CAAC;IAC1B,OAAO,IAAI,CAAC;AAChB,CAAC;AA3ED,oDA2EC","sourcesContent":["import { createSelectionMarker, createText } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { ContentModelDocument, ContentModelParagraph } from 'roosterjs-content-model-types';\n\nconst tabSpaces = '    ';\nconst space = ' ';\n\n/**\n * @internal\n The handleTabOnParagraph function will handle the tab key in following scenarios:\n * 1. When the selection is collapsed and the cursor is at the end of a paragraph, add 4 spaces.\n * 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to indent the whole paragraph\n * 3. When the selection is collapsed and the cursor is at the middle of a paragraph, add 4 spaces.\n * 4. When the selection is not collapsed, replace the selected range with a single space.\n * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to indent the whole paragraph\n The handleTabOnParagraph function will handle the shift + tab key in a indented paragraph in following scenarios:\n * 1. When the selection is collapsed and the cursor is at the end of a paragraph, remove 4 spaces.\n * 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to outdent the whole paragraph\n * 3. When the selection is collapsed and the cursor is at the middle of a paragraph, remove 4 spaces.\n * 4. When the selection is not collapsed, replace the selected range with a 4 space.\n * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to outdent the whole paragraph\n */\nexport function handleTabOnParagraph(\n model: ContentModelDocument,\n paragraph: ContentModelParagraph,\n rawEvent: KeyboardEvent\n) {\n const selectedSegments = paragraph.segments.filter(segment => segment.isSelected);\n const isCollapsed =\n selectedSegments.length === 1 && selectedSegments[0].segmentType === 'SelectionMarker';\n const isAllSelected = paragraph.segments.every(segment => segment.isSelected);\n if ((paragraph.segments[0].segmentType === 'SelectionMarker' && isCollapsed) || isAllSelected) {\n const { marginLeft, marginRight, direction } = paragraph.format;\n const isRtl = direction === 'rtl';\n if (\n rawEvent.shiftKey &&\n ((!isRtl && (!marginLeft || marginLeft == '0px')) ||\n (isRtl && (!marginRight || marginRight == '0px')))\n ) {\n return false;\n }\n setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');\n } else {\n if (!isCollapsed) {\n let firstSelectedSegmentIndex: number | undefined = undefined;\n let lastSelectedSegmentIndex: number | undefined = undefined;\n\n paragraph.segments.forEach((segment, index) => {\n if (segment.isSelected) {\n if (!firstSelectedSegmentIndex) {\n firstSelectedSegmentIndex = index;\n }\n lastSelectedSegmentIndex = index;\n }\n });\n if (firstSelectedSegmentIndex && lastSelectedSegmentIndex) {\n const firstSelectedSegment = paragraph.segments[firstSelectedSegmentIndex];\n const spaceText = createText(\n rawEvent.shiftKey ? tabSpaces : space,\n firstSelectedSegment.format\n );\n const marker = createSelectionMarker(firstSelectedSegment.format);\n paragraph.segments.splice(\n firstSelectedSegmentIndex,\n lastSelectedSegmentIndex - firstSelectedSegmentIndex + 1,\n spaceText,\n marker\n );\n } else {\n return false;\n }\n } else {\n const markerIndex = paragraph.segments.findIndex(\n segment => segment.segmentType === 'SelectionMarker'\n );\n if (!rawEvent.shiftKey) {\n const markerFormat = paragraph.segments[markerIndex].format;\n const tabText = createText(tabSpaces, markerFormat);\n paragraph.segments.splice(markerIndex, 0, tabText);\n } else {\n const tabText = paragraph.segments[markerIndex - 1];\n const tabSpacesLength = tabSpaces.length;\n if (tabText.segmentType == 'Text') {\n const tabSpaceTextLength = tabText.text.length - tabSpacesLength;\n if (tabText.text === tabSpaces) {\n paragraph.segments.splice(markerIndex - 1, 1);\n } else if (tabText.text.substring(tabSpaceTextLength) === tabSpaces) {\n tabText.text = tabText.text.substring(0, tabSpaceTextLength);\n } else {\n return false;\n }\n }\n }\n }\n }\n rawEvent.preventDefault();\n return true;\n}\n"]}
1
+ {"version":3,"file":"handleTabOnParagraph.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnParagraph.ts"],"names":[],"mappings":";;;AAAA,2EAAgF;AAChF,2EAAkE;AAOlE,IAAM,SAAS,GAAG,MAAM,CAAC;AACzB,IAAM,KAAK,GAAG,GAAG,CAAC;AAElB;;;;;;;;;;;;;;GAcG;AACH,SAAgB,oBAAoB,CAChC,KAA2B,EAC3B,SAAgC,EAChC,QAAuB,EACvB,OAAmC;IAEnC,IAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,OAAO,IAA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AI,MAAM,EAAE;oBAC/B,IAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC;oBACjE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;wBAC5B,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;qBACjD;yBAAM,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,SAAS,EAAE;wBACjE,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;qBAChE;yBAAM;wBACH,OAAO,KAAK,CAAC;qBAChB;iBACJ;aACJ;SACJ;KACJ;IACD,QAAQ,CAAC,cAAc,EAAE,CAAC;IAC1B,OAAO,IAAI,CAAC;AAChB,CAAC;AAjFD,oDAiFC","sourcesContent":["import { createSelectionMarker, createText } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type {\n ContentModelDocument,\n ContentModelParagraph,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\nconst tabSpaces = '    ';\nconst space = ' ';\n\n/**\n * @internal\n The handleTabOnParagraph function will handle the tab key in following scenarios:\n * 1. When the selection is collapsed and the cursor is at the end of a paragraph, add 4 spaces.\n * 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to indent the whole paragraph\n * 3. When the selection is collapsed and the cursor is at the middle of a paragraph, add 4 spaces.\n * 4. When the selection is not collapsed, replace the selected range with a single space.\n * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to indent the whole paragraph\n The handleTabOnParagraph function will handle the shift + tab key in a indented paragraph in following scenarios:\n * 1. When the selection is collapsed and the cursor is at the end of a paragraph, remove 4 spaces.\n * 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to outdent the whole paragraph\n * 3. When the selection is collapsed and the cursor is at the middle of a paragraph, remove 4 spaces.\n * 4. When the selection is not collapsed, replace the selected range with a 4 space.\n * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to outdent the whole paragraph\n */\nexport function handleTabOnParagraph(\n model: ContentModelDocument,\n paragraph: ContentModelParagraph,\n rawEvent: KeyboardEvent,\n context?: FormatContentModelContext\n) {\n const selectedSegments = paragraph.segments.filter(segment => segment.isSelected);\n const isCollapsed =\n selectedSegments.length === 1 && selectedSegments[0].segmentType === 'SelectionMarker';\n const isAllSelected = paragraph.segments.every(segment => segment.isSelected);\n if ((paragraph.segments[0].segmentType === 'SelectionMarker' && isCollapsed) || isAllSelected) {\n const { marginLeft, marginRight, direction } = paragraph.format;\n const isRtl = direction === 'rtl';\n if (\n rawEvent.shiftKey &&\n ((!isRtl && (!marginLeft || marginLeft == '0px')) ||\n (isRtl && (!marginRight || marginRight == '0px')))\n ) {\n return false;\n }\n setModelIndentation(\n model,\n rawEvent.shiftKey ? 'outdent' : 'indent',\n undefined /*length*/,\n context\n );\n } else {\n if (!isCollapsed) {\n let firstSelectedSegmentIndex: number | undefined = undefined;\n let lastSelectedSegmentIndex: number | undefined = undefined;\n\n paragraph.segments.forEach((segment, index) => {\n if (segment.isSelected) {\n if (!firstSelectedSegmentIndex) {\n firstSelectedSegmentIndex = index;\n }\n lastSelectedSegmentIndex = index;\n }\n });\n if (firstSelectedSegmentIndex && lastSelectedSegmentIndex) {\n const firstSelectedSegment = paragraph.segments[firstSelectedSegmentIndex];\n const spaceText = createText(\n rawEvent.shiftKey ? tabSpaces : space,\n firstSelectedSegment.format\n );\n const marker = createSelectionMarker(firstSelectedSegment.format);\n paragraph.segments.splice(\n firstSelectedSegmentIndex,\n lastSelectedSegmentIndex - firstSelectedSegmentIndex + 1,\n spaceText,\n marker\n );\n } else {\n return false;\n }\n } else {\n const markerIndex = paragraph.segments.findIndex(\n segment => segment.segmentType === 'SelectionMarker'\n );\n if (!rawEvent.shiftKey) {\n const markerFormat = paragraph.segments[markerIndex].format;\n const tabText = createText(tabSpaces, markerFormat);\n paragraph.segments.splice(markerIndex, 0, tabText);\n } else {\n const tabText = paragraph.segments[markerIndex - 1];\n const tabSpacesLength = tabSpaces.length;\n if (tabText.segmentType == 'Text') {\n const tabSpaceTextLength = tabText.text.length - tabSpacesLength;\n if (tabText.text === tabSpaces) {\n paragraph.segments.splice(markerIndex - 1, 1);\n } else if (tabText.text.substring(tabSpaceTextLength) === tabSpaces) {\n tabText.text = tabText.text.substring(0, tabSpaceTextLength);\n } else {\n return false;\n }\n }\n }\n }\n }\n rawEvent.preventDefault();\n return true;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ContentModelDocument } from 'roosterjs-content-model-types';
2
+ /**
3
+ * When the whole table is selected, indent or outdent the whole table with setModelIndentation.
4
+ * @internal
5
+ */
6
+ export declare function handleTabOnTable(model: ContentModelDocument, rawEvent: KeyboardEvent): boolean;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleTabOnTable = void 0;
4
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
+ var roosterjs_content_model_api_1 = require("roosterjs-content-model-api");
6
+ /**
7
+ * When the whole table is selected, indent or outdent the whole table with setModelIndentation.
8
+ * @internal
9
+ */
10
+ function handleTabOnTable(model, rawEvent) {
11
+ var tableModel = (0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model)[0];
12
+ if (tableModel && isWholeTableSelected(tableModel)) {
13
+ (0, roosterjs_content_model_api_1.setModelIndentation)(model, rawEvent.shiftKey ? 'outdent' : 'indent');
14
+ rawEvent.preventDefault();
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ exports.handleTabOnTable = handleTabOnTable;
20
+ function isWholeTableSelected(tableModel) {
21
+ var _a, _b, _c, _d;
22
+ return (((_b = (_a = tableModel.rows[0]) === null || _a === void 0 ? void 0 : _a.cells[0]) === null || _b === void 0 ? void 0 : _b.isSelected) &&
23
+ ((_d = (_c = tableModel.rows[tableModel.rows.length - 1]) === null || _c === void 0 ? void 0 : _c.cells[tableModel.widths.length - 1]) === null || _d === void 0 ? void 0 : _d.isSelected));
24
+ }
25
+ //# sourceMappingURL=handleTabOnTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleTabOnTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnTable.ts"],"names":[],"mappings":";;;AAAA,2EAAoE;AACpE,2EAAkE;AAGlE;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAA2B,EAAE,QAAuB;IACjF,IAAM,UAAU,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,UAAU,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE;QAChD,IAAA,iDAAmB,EAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACrE,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AARD,4CAQC;AAED,SAAS,oBAAoB,CAAC,UAA6B;;IACvD,OAAO,CACH,CAAA,MAAA,MAAA,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,0CAAE,UAAU;SACxC,MAAA,MAAA,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,UAAU,CAAA,CAC/F,CAAC;AACN,CAAC","sourcesContent":["import { getFirstSelectedTable } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { ContentModelDocument, ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * When the whole table is selected, indent or outdent the whole table with setModelIndentation.\n * @internal\n */\nexport function handleTabOnTable(model: ContentModelDocument, rawEvent: KeyboardEvent) {\n const tableModel = getFirstSelectedTable(model)[0];\n if (tableModel && isWholeTableSelected(tableModel)) {\n setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');\n rawEvent.preventDefault();\n return true;\n }\n return false;\n}\n\nfunction isWholeTableSelected(tableModel: ContentModelTable) {\n return (\n tableModel.rows[0]?.cells[0]?.isSelected &&\n tableModel.rows[tableModel.rows.length - 1]?.cells[tableModel.widths.length - 1]?.isSelected\n );\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ContentModelDocument, ContentModelTableCell } from 'roosterjs-content-model-types';
2
+ /**
3
+ * When the cursor is on the last cell of a table, add new row and focus first new cell.
4
+ * @internal
5
+ */
6
+ export declare function handleTabOnTableCell(model: ContentModelDocument, cell: ContentModelTableCell, rawEvent: KeyboardEvent): boolean;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleTabOnTableCell = void 0;
4
+ var roosterjs_content_model_api_1 = require("roosterjs-content-model-api");
5
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
6
+ /**
7
+ * When the cursor is on the last cell of a table, add new row and focus first new cell.
8
+ * @internal
9
+ */
10
+ function handleTabOnTableCell(model, cell, rawEvent) {
11
+ var _a, _b, _c;
12
+ var tableModel = (0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model)[0];
13
+ // Check if cursor is on last cell of the table
14
+ if (!rawEvent.shiftKey &&
15
+ tableModel &&
16
+ ((_a = tableModel.rows[tableModel.rows.length - 1]) === null || _a === void 0 ? void 0 : _a.cells[tableModel.widths.length - 1]) === cell) {
17
+ (0, roosterjs_content_model_api_1.insertTableRow)(tableModel, 'insertBelow');
18
+ // Clear Table selection
19
+ (0, roosterjs_content_model_api_1.clearSelectedCells)(tableModel, {
20
+ firstRow: tableModel.rows.length - 1,
21
+ firstColumn: 0,
22
+ lastRow: tableModel.rows.length - 1,
23
+ lastColumn: tableModel.widths.length - 1,
24
+ });
25
+ (0, roosterjs_content_model_dom_1.normalizeTable)(tableModel, model.format);
26
+ // Add selection marker to the first cell of the new row
27
+ var markerParagraph = (_c = (_b = tableModel.rows[tableModel.rows.length - 1]) === null || _b === void 0 ? void 0 : _b.cells[0]) === null || _c === void 0 ? void 0 : _c.blocks[0];
28
+ if (markerParagraph.blockType == 'Paragraph') {
29
+ var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(model.format);
30
+ markerParagraph.segments.unshift(marker);
31
+ (0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(markerParagraph);
32
+ (0, roosterjs_content_model_dom_1.setSelection)(tableModel.rows[tableModel.rows.length - 1].cells[0], marker);
33
+ }
34
+ rawEvent.preventDefault();
35
+ return true;
36
+ }
37
+ return false;
38
+ }
39
+ exports.handleTabOnTableCell = handleTabOnTableCell;
40
+ //# sourceMappingURL=handleTabOnTableCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleTabOnTableCell.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnTableCell.ts"],"names":[],"mappings":";;;AAAA,2EAAiF;AACjF,2EAMqC;AAGrC;;;GAGG;AACH,SAAgB,oBAAoB,CAChC,KAA2B,EAC3B,IAA2B,EAC3B,QAAuB;;IAEvB,IAAM,UAAU,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,+CAA+C;IAC/C,IACI,CAAC,QAAQ,CAAC,QAAQ;QAClB,UAAU;QACV,CAAA,MAAA,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,MAAK,IAAI,EAC3F;QACE,IAAA,4CAAc,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAE1C,wBAAwB;QACxB,IAAA,gDAAkB,EAAC,UAAU,EAAE;YAC3B,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YACpC,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YACnC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;SAC3C,CAAC,CAAC;QACH,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAEzC,wDAAwD;QACxD,IAAM,eAAe,GAAG,MAAA,MAAA,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACzF,IAAI,eAAe,CAAC,SAAS,IAAI,WAAW,EAAE;YAC1C,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEnD,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACzC,IAAA,qDAAuB,EAAC,eAAe,CAAC,CAAC;YACzC,IAAA,0CAAY,EAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;SAC9E;QAED,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAtCD,oDAsCC","sourcesContent":["import { clearSelectedCells, insertTableRow } from 'roosterjs-content-model-api';\nimport {\n createSelectionMarker,\n getFirstSelectedTable,\n normalizeTable,\n setParagraphNotImplicit,\n setSelection,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelDocument, ContentModelTableCell } from 'roosterjs-content-model-types';\n\n/**\n * When the cursor is on the last cell of a table, add new row and focus first new cell.\n * @internal\n */\nexport function handleTabOnTableCell(\n model: ContentModelDocument,\n cell: ContentModelTableCell,\n rawEvent: KeyboardEvent\n) {\n const tableModel = getFirstSelectedTable(model)[0];\n // Check if cursor is on last cell of the table\n if (\n !rawEvent.shiftKey &&\n tableModel &&\n tableModel.rows[tableModel.rows.length - 1]?.cells[tableModel.widths.length - 1] === cell\n ) {\n insertTableRow(tableModel, 'insertBelow');\n\n // Clear Table selection\n clearSelectedCells(tableModel, {\n firstRow: tableModel.rows.length - 1,\n firstColumn: 0,\n lastRow: tableModel.rows.length - 1,\n lastColumn: tableModel.widths.length - 1,\n });\n normalizeTable(tableModel, model.format);\n\n // Add selection marker to the first cell of the new row\n const markerParagraph = tableModel.rows[tableModel.rows.length - 1]?.cells[0]?.blocks[0];\n if (markerParagraph.blockType == 'Paragraph') {\n const marker = createSelectionMarker(model.format);\n\n markerParagraph.segments.unshift(marker);\n setParagraphNotImplicit(markerParagraph);\n setSelection(tableModel.rows[tableModel.rows.length - 1].cells[0], marker);\n }\n\n rawEvent.preventDefault();\n return true;\n }\n\n return false;\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import type { HyperlinkToolTip } from './HyperlinkToolTip';
2
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
3
+ /**
4
+ * Hyperlink plugin does the following jobs for a hyperlink in editor:
5
+ * 1. When hover on a link, show a tool tip
6
+ * 2. When Ctrl+Click on a link, open a new window with the link
7
+ * 3. When type directly on a link whose text matches its link url, update the link url with the link text
8
+ */
9
+ export declare class HyperlinkPlugin implements EditorPlugin {
10
+ private tooltip;
11
+ private target?;
12
+ private onLinkClick?;
13
+ private editor;
14
+ private domHelper;
15
+ private isMac;
16
+ private disposer;
17
+ private currentNode;
18
+ private currentLink;
19
+ /**
20
+ * Create a new instance of HyperLink class
21
+ * @param tooltip Tooltip to show when mouse hover over a link
22
+ * Default value is to return the href itself. If null, there will be no tooltip text.
23
+ * @param target (Optional) Target window name for hyperlink. If null, will use "_blank"
24
+ * @param onLinkClick (Optional) Open link callback (return false to use default behavior)
25
+ */
26
+ constructor(tooltip?: HyperlinkToolTip, target?: string | undefined, onLinkClick?: ((anchor: HTMLAnchorElement, mouseEvent: MouseEvent) => boolean | void) | undefined);
27
+ /**
28
+ * Get a friendly name of this plugin
29
+ */
30
+ getName(): string;
31
+ /**
32
+ * Initialize this plugin
33
+ * @param editor The editor instance
34
+ */
35
+ initialize(editor: IEditor): void;
36
+ /**
37
+ * Dispose this plugin
38
+ */
39
+ dispose(): void;
40
+ /**
41
+ * Handle events triggered from editor
42
+ * @param event PluginEvent object
43
+ */
44
+ onPluginEvent(event: PluginEvent): void;
45
+ protected onMouse: (e: Event) => void;
46
+ private runWithHyperlink;
47
+ private isCtrlOrMetaPressed;
48
+ }
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HyperlinkPlugin = void 0;
4
+ var roosterjs_content_model_api_1 = require("roosterjs-content-model-api");
5
+ var defaultToolTipCallback = function (url) { return url; };
6
+ /**
7
+ * Hyperlink plugin does the following jobs for a hyperlink in editor:
8
+ * 1. When hover on a link, show a tool tip
9
+ * 2. When Ctrl+Click on a link, open a new window with the link
10
+ * 3. When type directly on a link whose text matches its link url, update the link url with the link text
11
+ */
12
+ var HyperlinkPlugin = /** @class */ (function () {
13
+ /**
14
+ * Create a new instance of HyperLink class
15
+ * @param tooltip Tooltip to show when mouse hover over a link
16
+ * Default value is to return the href itself. If null, there will be no tooltip text.
17
+ * @param target (Optional) Target window name for hyperlink. If null, will use "_blank"
18
+ * @param onLinkClick (Optional) Open link callback (return false to use default behavior)
19
+ */
20
+ function HyperlinkPlugin(tooltip, target, onLinkClick) {
21
+ var _this = this;
22
+ if (tooltip === void 0) { tooltip = defaultToolTipCallback; }
23
+ this.tooltip = tooltip;
24
+ this.target = target;
25
+ this.onLinkClick = onLinkClick;
26
+ this.editor = null;
27
+ this.domHelper = null;
28
+ this.isMac = false;
29
+ this.disposer = null;
30
+ this.currentNode = null;
31
+ this.currentLink = null;
32
+ this.onMouse = function (e) {
33
+ _this.runWithHyperlink(e.target, function (href, a) {
34
+ var _a;
35
+ var tooltip = e.type == 'mouseover'
36
+ ? typeof _this.tooltip == 'function'
37
+ ? _this.tooltip(href, a)
38
+ : _this.tooltip
39
+ : null;
40
+ (_a = _this.domHelper) === null || _a === void 0 ? void 0 : _a.setDomAttribute('title', tooltip);
41
+ });
42
+ };
43
+ }
44
+ /**
45
+ * Get a friendly name of this plugin
46
+ */
47
+ HyperlinkPlugin.prototype.getName = function () {
48
+ return 'Hyperlink';
49
+ };
50
+ /**
51
+ * Initialize this plugin
52
+ * @param editor The editor instance
53
+ */
54
+ HyperlinkPlugin.prototype.initialize = function (editor) {
55
+ this.editor = editor;
56
+ this.domHelper = editor.getDOMHelper();
57
+ this.isMac = !!editor.getEnvironment().isMac;
58
+ this.disposer = editor.attachDomEvent({
59
+ mouseover: { beforeDispatch: this.onMouse },
60
+ mouseout: { beforeDispatch: this.onMouse },
61
+ });
62
+ };
63
+ /**
64
+ * Dispose this plugin
65
+ */
66
+ HyperlinkPlugin.prototype.dispose = function () {
67
+ if (this.disposer) {
68
+ this.disposer();
69
+ this.disposer = null;
70
+ }
71
+ this.currentNode = null;
72
+ this.currentLink = null;
73
+ this.editor = null;
74
+ };
75
+ /**
76
+ * Handle events triggered from editor
77
+ * @param event PluginEvent object
78
+ */
79
+ HyperlinkPlugin.prototype.onPluginEvent = function (event) {
80
+ var _this = this;
81
+ var _a, _b;
82
+ var matchedLink;
83
+ if (event.eventType == 'keyDown') {
84
+ var selection = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getDOMSelection();
85
+ var node_1 = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' ? selection.range.commonAncestorContainer : null;
86
+ if (node_1 && node_1 != this.currentNode) {
87
+ this.currentNode = node_1;
88
+ this.currentLink = null;
89
+ this.runWithHyperlink(node_1, function (href, a) {
90
+ if (node_1.textContent &&
91
+ (matchedLink = (0, roosterjs_content_model_api_1.matchLink)(node_1.textContent)) &&
92
+ matchedLink.normalizedUrl == href) {
93
+ _this.currentLink = a;
94
+ }
95
+ });
96
+ }
97
+ }
98
+ else if (event.eventType == 'keyUp') {
99
+ var selection = (_b = this.editor) === null || _b === void 0 ? void 0 : _b.getDOMSelection();
100
+ var node = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' ? selection.range.commonAncestorContainer : null;
101
+ if (node &&
102
+ node == this.currentNode &&
103
+ this.currentLink &&
104
+ this.currentLink.contains(node) &&
105
+ node.textContent &&
106
+ (matchedLink = (0, roosterjs_content_model_api_1.matchLink)(node.textContent))) {
107
+ this.currentLink.setAttribute('href', matchedLink.normalizedUrl);
108
+ }
109
+ }
110
+ else if (event.eventType == 'mouseUp' && event.isClicking) {
111
+ this.runWithHyperlink(event.rawEvent.target, function (href, anchor) {
112
+ var _a, _b;
113
+ if (!((_a = _this.onLinkClick) === null || _a === void 0 ? void 0 : _a.call(_this, anchor, event.rawEvent)) &&
114
+ _this.isCtrlOrMetaPressed(event.rawEvent) &&
115
+ event.rawEvent.button === 0) {
116
+ event.rawEvent.preventDefault();
117
+ var target = _this.target || '_blank';
118
+ var window_1 = (_b = _this.editor) === null || _b === void 0 ? void 0 : _b.getDocument().defaultView;
119
+ try {
120
+ window_1 === null || window_1 === void 0 ? void 0 : window_1.open(href, target);
121
+ }
122
+ catch (_c) { }
123
+ }
124
+ });
125
+ }
126
+ };
127
+ HyperlinkPlugin.prototype.runWithHyperlink = function (node, callback) {
128
+ var _a;
129
+ var a = (_a = this.domHelper) === null || _a === void 0 ? void 0 : _a.findClosestElementAncestor(node, 'a[href]');
130
+ var href = a === null || a === void 0 ? void 0 : a.getAttribute('href');
131
+ if (href && a) {
132
+ callback(href, a);
133
+ }
134
+ };
135
+ HyperlinkPlugin.prototype.isCtrlOrMetaPressed = function (event) {
136
+ return this.isMac ? event.metaKey : event.ctrlKey;
137
+ };
138
+ return HyperlinkPlugin;
139
+ }());
140
+ exports.HyperlinkPlugin = HyperlinkPlugin;
141
+ //# sourceMappingURL=HyperlinkPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HyperlinkPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/hyperlink/HyperlinkPlugin.ts"],"names":[],"mappings":";;;AAAA,2EAAwD;AAUxD,IAAM,sBAAsB,GAAqB,UAAC,GAAW,IAAK,OAAA,GAAG,EAAH,CAAG,CAAC;AAEtE;;;;;GAKG;AACH;IASI;;;;;;OAMG;IACH,yBACY,OAAkD,EAClD,MAAe,EACf,WAAmF;QAH/F,iBAII;QAHQ,wBAAA,EAAA,gCAAkD;QAAlD,YAAO,GAAP,OAAO,CAA2C;QAClD,WAAM,GAAN,MAAM,CAAS;QACf,gBAAW,GAAX,WAAW,CAAwE;QAlBvF,WAAM,GAAmB,IAAI,CAAC;QAC9B,cAAS,GAAqB,IAAI,CAAC;QACnC,UAAK,GAAY,KAAK,CAAC;QACvB,aAAQ,GAAwB,IAAI,CAAC;QAErC,gBAAW,GAAgB,IAAI,CAAC;QAChC,gBAAW,GAA6B,IAAI,CAAC;QA+G3C,YAAO,GAAG,UAAC,CAAQ;YACzB,KAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAc,EAAE,UAAC,IAAI,EAAE,CAAC;;gBAC5C,IAAM,OAAO,GACT,CAAC,CAAC,IAAI,IAAI,WAAW;oBACjB,CAAC,CAAC,OAAO,KAAI,CAAC,OAAO,IAAI,UAAU;wBAC/B,CAAC,CAAC,KAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;wBACvB,CAAC,CAAC,KAAI,CAAC,OAAO;oBAClB,CAAC,CAAC,IAAI,CAAC;gBACf,MAAA,KAAI,CAAC,SAAS,0CAAE,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC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linkToolTip';\nimport type {\n DOMHelper,\n EditorPlugin,\n IEditor,\n PluginEvent,\n LinkData,\n} from 'roosterjs-content-model-types';\n\nconst defaultToolTipCallback: HyperlinkToolTip = (url: string) => url;\n\n/**\n * Hyperlink plugin does the following jobs for a hyperlink in editor:\n * 1. When hover on a link, show a tool tip\n * 2. When Ctrl+Click on a link, open a new window with the link\n * 3. When type directly on a link whose text matches its link url, update the link url with the link text\n */\nexport class HyperlinkPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private domHelper: DOMHelper | null = null;\n private isMac: boolean = false;\n private disposer: (() => void) | null = null;\n\n private currentNode: Node | null = null;\n private currentLink: HTMLAnchorElement | null = null;\n\n /**\n * Create a new instance of HyperLink class\n * @param tooltip Tooltip to show when mouse hover over a link\n * Default value is to return the href itself. If null, there will be no tooltip text.\n * @param target (Optional) Target window name for hyperlink. If null, will use \"_blank\"\n * @param onLinkClick (Optional) Open link callback (return false to use default behavior)\n */\n constructor(\n private tooltip: HyperlinkToolTip = defaultToolTipCallback,\n private target?: string,\n private onLinkClick?: (anchor: HTMLAnchorElement, mouseEvent: MouseEvent) => boolean | void\n ) {}\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'Hyperlink';\n }\n\n /**\n * Initialize this plugin\n * @param editor The editor instance\n */\n public initialize(editor: IEditor): void {\n this.editor = editor;\n this.domHelper = editor.getDOMHelper();\n this.isMac = !!editor.getEnvironment().isMac;\n this.disposer = editor.attachDomEvent({\n mouseover: { beforeDispatch: this.onMouse },\n mouseout: { beforeDispatch: this.onMouse },\n });\n }\n\n /**\n * Dispose this plugin\n */\n public dispose(): void {\n if (this.disposer) {\n this.disposer();\n this.disposer = null;\n }\n\n this.currentNode = null;\n this.currentLink = null;\n this.editor = null;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n public onPluginEvent(event: PluginEvent): void {\n let matchedLink: LinkData | null;\n\n if (event.eventType == 'keyDown') {\n const selection = this.editor?.getDOMSelection();\n const node =\n selection?.type == 'range' ? selection.range.commonAncestorContainer : null;\n\n if (node && node != this.currentNode) {\n this.currentNode = node;\n this.currentLink = null;\n\n this.runWithHyperlink(node, (href, a) => {\n if (\n node.textContent &&\n (matchedLink = matchLink(node.textContent)) &&\n matchedLink.normalizedUrl == href\n ) {\n this.currentLink = a;\n }\n });\n }\n } else if (event.eventType == 'keyUp') {\n const selection = this.editor?.getDOMSelection();\n const node =\n selection?.type == 'range' ? selection.range.commonAncestorContainer : null;\n\n if (\n node &&\n node == this.currentNode &&\n this.currentLink &&\n this.currentLink.contains(node) &&\n node.textContent &&\n (matchedLink = matchLink(node.textContent))\n ) {\n this.currentLink.setAttribute('href', matchedLink.normalizedUrl);\n }\n } else if (event.eventType == 'mouseUp' && event.isClicking) {\n this.runWithHyperlink(event.rawEvent.target as Node, (href, anchor) => {\n if (\n !this.onLinkClick?.(anchor, event.rawEvent) &&\n this.isCtrlOrMetaPressed(event.rawEvent) &&\n event.rawEvent.button === 0\n ) {\n event.rawEvent.preventDefault();\n\n const target = this.target || '_blank';\n const window = this.editor?.getDocument().defaultView;\n\n try {\n window?.open(href, target);\n } catch {}\n }\n });\n }\n }\n\n protected onMouse = (e: Event) => {\n this.runWithHyperlink(e.target as Node, (href, a) => {\n const tooltip =\n e.type == 'mouseover'\n ? typeof this.tooltip == 'function'\n ? this.tooltip(href, a)\n : this.tooltip\n : null;\n this.domHelper?.setDomAttribute('title', tooltip);\n });\n };\n\n private runWithHyperlink(node: Node, callback: (href: string, a: HTMLAnchorElement) => void) {\n const a = this.domHelper?.findClosestElementAncestor(\n node,\n 'a[href]'\n ) as HTMLAnchorElement | null;\n const href = a?.getAttribute('href');\n\n if (href && a) {\n callback(href, a);\n }\n }\n\n private isCtrlOrMetaPressed(event: KeyboardEvent | MouseEvent): boolean {\n return this.isMac ? event.metaKey : event.ctrlKey;\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A type to specify how to get a tool tip of hyperlink in editor
3
+ * string: Use this string as tooltip
4
+ * null: No tooltip
5
+ * function: Call this function to get a tooltip
6
+ */
7
+ export declare type HyperlinkToolTip = string | null | ((url: string, anchor: HTMLAnchorElement) => string);
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=HyperlinkToolTip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HyperlinkToolTip.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/hyperlink/HyperlinkToolTip.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A type to specify how to get a tool tip of hyperlink in editor\n * string: Use this string as tooltip\n * null: No tooltip\n * function: Call this function to get a tooltip\n */\nexport type HyperlinkToolTip = string | null | ((url: string, anchor: HTMLAnchorElement) => string);\n"]}
package/lib/index.d.ts CHANGED
@@ -1,11 +1,19 @@
1
1
  export { TableEditPlugin } from './tableEdit/TableEditPlugin';
2
+ export { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';
2
3
  export { PastePlugin } from './paste/PastePlugin';
3
4
  export { EditPlugin } from './edit/EditPlugin';
4
5
  export { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';
5
- export { ShortcutBold, ShortcutItalic, ShortcutUnderline, ShortcutClearFormat, ShortcutUndo, ShortcutUndo2, ShortcutRedo, ShortcutRedoMacOS, ShortcutBullet, ShortcutNumbering, ShortcutIncreaseFont, ShortcutDecreaseFont, ShortcutIndentList, ShortcutOutdentList, } from './shortcut/shortcuts';
6
+ export { ShortcutBold, ShortcutItalic, ShortcutUnderline, ShortcutClearFormat, ShortcutUndo, ShortcutUndo2, ShortcutRedo, ShortcutRedoAlt, ShortcutRedoMacOS, ShortcutBullet, ShortcutNumbering, ShortcutIncreaseFont, ShortcutDecreaseFont, ShortcutIndentList, ShortcutOutdentList, } from './shortcut/shortcuts';
6
7
  export { ShortcutPlugin } from './shortcut/ShortcutPlugin';
7
8
  export { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';
8
9
  export { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';
9
10
  export { WatermarkPlugin } from './watermark/WatermarkPlugin';
10
11
  export { WatermarkFormat } from './watermark/WatermarkFormat';
11
12
  export { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';
13
+ export { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';
14
+ export { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';
15
+ export { PickerPlugin } from './picker/PickerPlugin';
16
+ export { PickerHelper } from './picker/PickerHelper';
17
+ export { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';
18
+ export { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';
19
+ export { getDOMInsertPointRect } from './pluginUtils/Rect/getDOMInsertPointRect';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MarkdownPlugin = exports.WatermarkPlugin = exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.PastePlugin = exports.TableEditPlugin = void 0;
3
+ exports.getDOMInsertPointRect = exports.CustomReplacePlugin = exports.PickerPlugin = exports.HyperlinkPlugin = exports.MarkdownPlugin = exports.WatermarkPlugin = exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedoAlt = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.PastePlugin = exports.TableEditPlugin = void 0;
4
4
  var TableEditPlugin_1 = require("./tableEdit/TableEditPlugin");
5
5
  Object.defineProperty(exports, "TableEditPlugin", { enumerable: true, get: function () { return TableEditPlugin_1.TableEditPlugin; } });
6
6
  var PastePlugin_1 = require("./paste/PastePlugin");
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "ShortcutClearFormat", { enumerable: true, get: f
17
17
  Object.defineProperty(exports, "ShortcutUndo", { enumerable: true, get: function () { return shortcuts_1.ShortcutUndo; } });
18
18
  Object.defineProperty(exports, "ShortcutUndo2", { enumerable: true, get: function () { return shortcuts_1.ShortcutUndo2; } });
19
19
  Object.defineProperty(exports, "ShortcutRedo", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedo; } });
20
+ Object.defineProperty(exports, "ShortcutRedoAlt", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedoAlt; } });
20
21
  Object.defineProperty(exports, "ShortcutRedoMacOS", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedoMacOS; } });
21
22
  Object.defineProperty(exports, "ShortcutBullet", { enumerable: true, get: function () { return shortcuts_1.ShortcutBullet; } });
22
23
  Object.defineProperty(exports, "ShortcutNumbering", { enumerable: true, get: function () { return shortcuts_1.ShortcutNumbering; } });
@@ -32,4 +33,12 @@ var WatermarkPlugin_1 = require("./watermark/WatermarkPlugin");
32
33
  Object.defineProperty(exports, "WatermarkPlugin", { enumerable: true, get: function () { return WatermarkPlugin_1.WatermarkPlugin; } });
33
34
  var MarkdownPlugin_1 = require("./markdown/MarkdownPlugin");
34
35
  Object.defineProperty(exports, "MarkdownPlugin", { enumerable: true, get: function () { return MarkdownPlugin_1.MarkdownPlugin; } });
36
+ var HyperlinkPlugin_1 = require("./hyperlink/HyperlinkPlugin");
37
+ Object.defineProperty(exports, "HyperlinkPlugin", { enumerable: true, get: function () { return HyperlinkPlugin_1.HyperlinkPlugin; } });
38
+ var PickerPlugin_1 = require("./picker/PickerPlugin");
39
+ Object.defineProperty(exports, "PickerPlugin", { enumerable: true, get: function () { return PickerPlugin_1.PickerPlugin; } });
40
+ var CustomReplacePlugin_1 = require("./customReplace/CustomReplacePlugin");
41
+ Object.defineProperty(exports, "CustomReplacePlugin", { enumerable: true, get: function () { return CustomReplacePlugin_1.CustomReplacePlugin; } });
42
+ var getDOMInsertPointRect_1 = require("./pluginUtils/Rect/getDOMInsertPointRect");
43
+ Object.defineProperty(exports, "getDOMInsertPointRect", { enumerable: true, get: function () { return getDOMInsertPointRect_1.getDOMInsertPointRect; } });
35
44
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,kEAAoF;AAA3E,oHAAA,gBAAgB,OAAA;AAEzB,kDAe8B;AAd1B,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,gHAAA,mBAAmB,OAAA;AACnB,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,iHAAA,oBAAoB,OAAA;AACpB,iHAAA,oBAAoB,OAAA;AACpB,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AAEvB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AAEvB,iFAAoG;AAA3F,8HAAA,qBAAqB,OAAA;AAC9B,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,4DAA4E;AAAnE,gHAAA,cAAc,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';\n\nexport {\n ShortcutBold,\n ShortcutItalic,\n ShortcutUnderline,\n ShortcutClearFormat,\n ShortcutUndo,\n ShortcutUndo2,\n ShortcutRedo,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n ShortcutIndentList,\n ShortcutOutdentList,\n} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,kEAAoF;AAA3E,oHAAA,gBAAgB,OAAA;AAEzB,kDAgB8B;AAf1B,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,gHAAA,mBAAmB,OAAA;AACnB,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,iHAAA,oBAAoB,OAAA;AACpB,iHAAA,oBAAoB,OAAA;AACpB,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AAEvB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AAEvB,iFAAoG;AAA3F,8HAAA,qBAAqB,OAAA;AAC9B,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,4DAA4E;AAAnE,gHAAA,cAAc,OAAA;AACvB,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AAGrB,2EAAyF;AAAhF,0HAAA,mBAAmB,OAAA;AAE5B,kFAAiF;AAAxE,8HAAA,qBAAqB,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';\n\nexport {\n ShortcutBold,\n ShortcutItalic,\n ShortcutUnderline,\n ShortcutClearFormat,\n ShortcutUndo,\n ShortcutUndo2,\n ShortcutRedo,\n ShortcutRedoAlt,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n ShortcutIndentList,\n ShortcutOutdentList,\n} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\n\nexport { getDOMInsertPointRect } from './pluginUtils/Rect/getDOMInsertPointRect';\n"]}
@@ -1,11 +1,17 @@
1
- import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
1
+ import type { ContentModelCodeFormat, EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
2
2
  /**
3
+ *
3
4
  * Options for Markdown plugin
5
+ * - strikethrough: If true text between ~ will receive strikethrough format.
6
+ * - bold: If true text between * will receive bold format.
7
+ * - italic: If true text between _ will receive italic format.
8
+ * - codeFormat: If provided, text between ` will receive code format. If equal to {}, it will set the default code format.
4
9
  */
5
10
  export interface MarkdownOptions {
6
11
  strikethrough?: boolean;
7
12
  bold?: boolean;
8
13
  italic?: boolean;
14
+ codeFormat?: ContentModelCodeFormat;
9
15
  }
10
16
  /**
11
17
  * Markdown plugin handles markdown formatting, such as transforming * characters into bold text.
@@ -16,12 +22,14 @@ export declare class MarkdownPlugin implements EditorPlugin {
16
22
  private shouldBold;
17
23
  private shouldItalic;
18
24
  private shouldStrikethrough;
25
+ private shouldCode;
19
26
  private lastKeyTyped;
20
27
  /**
21
28
  * @param options An optional parameter that takes in an object of type MarkdownOptions, which includes the following properties:
22
- * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to true.
23
- * - bold: If true text between * will receive bold format. Defaults to true.
24
- * - italic: If true text between _ will receive italic format. Defaults to true.
29
+ * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to false.
30
+ * - bold: If true text between * will receive bold format. Defaults to false.
31
+ * - italic: If true text between _ will receive italic format. Defaults to false.
32
+ * - codeFormat: If provided, text between ` will receive code format. Defaults to undefined.
25
33
  */
26
34
  constructor(options?: MarkdownOptions);
27
35
  /**
@@ -52,4 +60,5 @@ export declare class MarkdownPlugin implements EditorPlugin {
52
60
  private handleKeyDownEvent;
53
61
  private handleBackspaceEvent;
54
62
  private handleContentChangedEvent;
63
+ private disableAllFeatures;
55
64
  }
@@ -16,9 +16,10 @@ var DefaultOptions = {
16
16
  var MarkdownPlugin = /** @class */ (function () {
17
17
  /**
18
18
  * @param options An optional parameter that takes in an object of type MarkdownOptions, which includes the following properties:
19
- * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to true.
20
- * - bold: If true text between * will receive bold format. Defaults to true.
21
- * - italic: If true text between _ will receive italic format. Defaults to true.
19
+ * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to false.
20
+ * - bold: If true text between * will receive bold format. Defaults to false.
21
+ * - italic: If true text between _ will receive italic format. Defaults to false.
22
+ * - codeFormat: If provided, text between ` will receive code format. Defaults to undefined.
22
23
  */
23
24
  function MarkdownPlugin(options) {
24
25
  if (options === void 0) { options = DefaultOptions; }
@@ -27,6 +28,7 @@ var MarkdownPlugin = /** @class */ (function () {
27
28
  this.shouldBold = false;
28
29
  this.shouldItalic = false;
29
30
  this.shouldStrikethrough = false;
31
+ this.shouldCode = false;
30
32
  this.lastKeyTyped = null;
31
33
  }
32
34
  /**
@@ -51,9 +53,7 @@ var MarkdownPlugin = /** @class */ (function () {
51
53
  */
52
54
  MarkdownPlugin.prototype.dispose = function () {
53
55
  this.editor = null;
54
- this.shouldBold = false;
55
- this.shouldItalic = false;
56
- this.shouldStrikethrough = false;
56
+ this.disableAllFeatures();
57
57
  this.lastKeyTyped = null;
58
58
  };
59
59
  /**
@@ -119,6 +119,17 @@ var MarkdownPlugin = /** @class */ (function () {
119
119
  }
120
120
  }
121
121
  break;
122
+ case '`':
123
+ if (this.options.codeFormat) {
124
+ if (this.shouldCode) {
125
+ (0, setFormat_1.setFormat)(editor, '`', {} /* format */, this.options.codeFormat);
126
+ this.shouldCode = false;
127
+ }
128
+ else {
129
+ this.shouldCode = true;
130
+ }
131
+ }
132
+ break;
122
133
  }
123
134
  }
124
135
  };
@@ -127,9 +138,7 @@ var MarkdownPlugin = /** @class */ (function () {
127
138
  if (!event.handledByEditFeature && !rawEvent.defaultPrevented) {
128
139
  switch (rawEvent.key) {
129
140
  case 'Enter':
130
- this.shouldBold = false;
131
- this.shouldItalic = false;
132
- this.shouldStrikethrough = false;
141
+ this.disableAllFeatures();
133
142
  this.lastKeyTyped = null;
134
143
  break;
135
144
  case ' ':
@@ -142,6 +151,9 @@ var MarkdownPlugin = /** @class */ (function () {
142
151
  else if (this.lastKeyTyped === '_' && this.shouldItalic) {
143
152
  this.shouldItalic = false;
144
153
  }
154
+ else if (this.lastKeyTyped === '`' && this.shouldCode) {
155
+ this.shouldCode = false;
156
+ }
145
157
  this.lastKeyTyped = null;
146
158
  break;
147
159
  default:
@@ -161,16 +173,23 @@ var MarkdownPlugin = /** @class */ (function () {
161
173
  else if (this.lastKeyTyped === '_' && this.shouldItalic) {
162
174
  this.shouldItalic = false;
163
175
  }
176
+ else if (this.lastKeyTyped === '`' && this.shouldCode) {
177
+ this.shouldCode = false;
178
+ }
164
179
  this.lastKeyTyped = null;
165
180
  }
166
181
  };
167
182
  MarkdownPlugin.prototype.handleContentChangedEvent = function (event) {
168
183
  if (event.source == 'Format') {
169
- this.shouldBold = false;
170
- this.shouldItalic = false;
171
- this.shouldStrikethrough = false;
184
+ this.disableAllFeatures();
172
185
  }
173
186
  };
187
+ MarkdownPlugin.prototype.disableAllFeatures = function () {
188
+ this.shouldBold = false;
189
+ this.shouldItalic = false;
190
+ this.shouldStrikethrough = false;
191
+ this.shouldCode = false;
192
+ };
174
193
  return MarkdownPlugin;
175
194
  }());
176
195
  exports.MarkdownPlugin = MarkdownPlugin;