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
@@ -5,15 +5,15 @@ import { setModelIndentation } from 'roosterjs-content-model-api';
5
5
  * 2. Otherwise call handleTabOnParagraph.
6
6
  * @internal
7
7
  */
8
- export function handleTabOnList(model, listItem, rawEvent) {
8
+ export function handleTabOnList(model, listItem, rawEvent, context) {
9
9
  var selectedParagraph = findSelectedParagraph(listItem);
10
10
  if (!isMarkerAtStartOfBlock(listItem) &&
11
11
  selectedParagraph.length == 1 &&
12
12
  selectedParagraph[0].blockType === 'Paragraph') {
13
- return handleTabOnParagraph(model, selectedParagraph[0], rawEvent);
13
+ return handleTabOnParagraph(model, selectedParagraph[0], rawEvent, context);
14
14
  }
15
15
  else {
16
- setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');
16
+ setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent', undefined /*length*/, context);
17
17
  rawEvent.preventDefault();
18
18
  return true;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handleTabOnList.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC3B,KAA2B,EAC3B,QAA8B,EAC9B,QAAuB;IAEvB,IAAM,iBAAiB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC1D,IACI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;QACjC,iBAAiB,CAAC,MAAM,IAAI,CAAC;QAC7B,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW,EAChD;QACE,OAAO,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;KACtE;SAAM;QACH,mBAAmB,CAAC,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;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,QAA8B;IAC1D,OAAO,CACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,WAAW;QAC3C,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAClE,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAC,QAA8B;IACzD,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CACzB,UAAA,KAAK;QACD,OAAA,KAAK,CAAC,SAAS,IAAI,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC;IAApF,CAAoF,CAC3F,CAAC;AACN,CAAC","sourcesContent":["import { handleTabOnParagraph } from './handleTabOnParagraph';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { ContentModelDocument, ContentModelListItem } from 'roosterjs-content-model-types';\n\n/**\n * 1. When the selection is collapsed and the cursor is at start of a list item, call setModelIndentation.\n * 2. Otherwise call handleTabOnParagraph.\n * @internal\n */\nexport function handleTabOnList(\n model: ContentModelDocument,\n listItem: ContentModelListItem,\n rawEvent: KeyboardEvent\n) {\n const selectedParagraph = findSelectedParagraph(listItem);\n if (\n !isMarkerAtStartOfBlock(listItem) &&\n selectedParagraph.length == 1 &&\n selectedParagraph[0].blockType === 'Paragraph'\n ) {\n return handleTabOnParagraph(model, selectedParagraph[0], rawEvent);\n } else {\n setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');\n rawEvent.preventDefault();\n return true;\n }\n}\n\nfunction isMarkerAtStartOfBlock(listItem: ContentModelListItem) {\n return (\n listItem.blocks[0].blockType == 'Paragraph' &&\n listItem.blocks[0].segments[0].segmentType == 'SelectionMarker'\n );\n}\n\nfunction findSelectedParagraph(listItem: ContentModelListItem) {\n return listItem.blocks.filter(\n block =>\n block.blockType == 'Paragraph' && block.segments.some(segment => segment.isSelected)\n );\n}\n"]}
1
+ {"version":3,"file":"handleTabOnList.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAOlE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC3B,KAA2B,EAC3B,QAA8B,EAC9B,QAAuB,EACvB,OAAmC;IAEnC,IAAM,iBAAiB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC1D,IACI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;QACjC,iBAAiB,CAAC,MAAM,IAAI,CAAC;QAC7B,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW,EAChD;QACE,OAAO,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC/E;SAAM;QACH,mBAAmB,CACf,KAAK,EACL,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACxC,SAAS,CAAC,UAAU,EACpB,OAAO,CACV,CAAC;QACF,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,QAA8B;IAC1D,OAAO,CACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,WAAW;QAC3C,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAClE,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAC,QAA8B;IACzD,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CACzB,UAAA,KAAK;QACD,OAAA,KAAK,CAAC,SAAS,IAAI,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC;IAApF,CAAoF,CAC3F,CAAC;AACN,CAAC","sourcesContent":["import { handleTabOnParagraph } from './handleTabOnParagraph';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type {\n ContentModelDocument,\n ContentModelListItem,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * 1. When the selection is collapsed and the cursor is at start of a list item, call setModelIndentation.\n * 2. Otherwise call handleTabOnParagraph.\n * @internal\n */\nexport function handleTabOnList(\n model: ContentModelDocument,\n listItem: ContentModelListItem,\n rawEvent: KeyboardEvent,\n context?: FormatContentModelContext\n) {\n const selectedParagraph = findSelectedParagraph(listItem);\n if (\n !isMarkerAtStartOfBlock(listItem) &&\n selectedParagraph.length == 1 &&\n selectedParagraph[0].blockType === 'Paragraph'\n ) {\n return handleTabOnParagraph(model, selectedParagraph[0], rawEvent, context);\n } else {\n setModelIndentation(\n model,\n rawEvent.shiftKey ? 'outdent' : 'indent',\n undefined /*length*/,\n context\n );\n rawEvent.preventDefault();\n return true;\n }\n}\n\nfunction isMarkerAtStartOfBlock(listItem: ContentModelListItem) {\n return (\n listItem.blocks[0].blockType == 'Paragraph' &&\n listItem.blocks[0].segments[0].segmentType == 'SelectionMarker'\n );\n}\n\nfunction findSelectedParagraph(listItem: ContentModelListItem) {\n return listItem.blocks.filter(\n block =>\n block.blockType == 'Paragraph' && block.segments.some(segment => segment.isSelected)\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ContentModelDocument, ContentModelParagraph } from 'roosterjs-content-model-types';
1
+ import type { ContentModelDocument, ContentModelParagraph, FormatContentModelContext } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  The handleTabOnParagraph function will handle the tab key in following scenarios:
@@ -14,4 +14,4 @@ import type { ContentModelDocument, ContentModelParagraph } from 'roosterjs-cont
14
14
  * 4. When the selection is not collapsed, replace the selected range with a 4 space.
15
15
  * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to outdent the whole paragraph
16
16
  */
17
- export declare function handleTabOnParagraph(model: ContentModelDocument, paragraph: ContentModelParagraph, rawEvent: KeyboardEvent): boolean;
17
+ export declare function handleTabOnParagraph(model: ContentModelDocument, paragraph: ContentModelParagraph, rawEvent: KeyboardEvent, context?: FormatContentModelContext): boolean;
@@ -17,7 +17,7 @@ var space = ' ';
17
17
  * 4. When the selection is not collapsed, replace the selected range with a 4 space.
18
18
  * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to outdent the whole paragraph
19
19
  */
20
- export function handleTabOnParagraph(model, paragraph, rawEvent) {
20
+ export function handleTabOnParagraph(model, paragraph, rawEvent, context) {
21
21
  var selectedSegments = paragraph.segments.filter(function (segment) { return segment.isSelected; });
22
22
  var isCollapsed = selectedSegments.length === 1 && selectedSegments[0].segmentType === 'SelectionMarker';
23
23
  var isAllSelected = paragraph.segments.every(function (segment) { return segment.isSelected; });
@@ -29,7 +29,7 @@ export function handleTabOnParagraph(model, paragraph, rawEvent) {
29
29
  (isRtl && (!marginRight || marginRight == '0px')))) {
30
30
  return false;
31
31
  }
32
- setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');
32
+ setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent', undefined /*length*/, context);
33
33
  }
34
34
  else {
35
35
  if (!isCollapsed) {
@@ -1 +1 @@
1
- {"version":3,"file":"handleTabOnParagraph.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnParagraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,IAAM,SAAS,GAAG,MAAM,CAAC;AACzB,IAAM,KAAK,GAAG,GAAG,CAAC;AAElB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,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,CAAC;gBAC7C,CAAC,KAAK,IAAI,CAAC,CAAC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AC,QAAQ,CAAC,QAAQ,EAAE;gBACpB,IAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;gBAC5D,IAAM,OAAO,GAAG,UAAU,CAAC,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","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,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAOlE,IAAM,SAAS,GAAG,MAAM,CAAC;AACzB,IAAM,KAAK,GAAG,GAAG,CAAC;AAElB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,oBAAoB,CAChC,KAA2B,EAC3B,SAAgC,EAChC,QAAuB,EACvB,OAAmC;IAEnC,IAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,OAAO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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","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,21 @@
1
+ import { getFirstSelectedTable } from 'roosterjs-content-model-dom';
2
+ import { setModelIndentation } from 'roosterjs-content-model-api';
3
+ /**
4
+ * When the whole table is selected, indent or outdent the whole table with setModelIndentation.
5
+ * @internal
6
+ */
7
+ export function handleTabOnTable(model, rawEvent) {
8
+ var tableModel = getFirstSelectedTable(model)[0];
9
+ if (tableModel && isWholeTableSelected(tableModel)) {
10
+ setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');
11
+ rawEvent.preventDefault();
12
+ return true;
13
+ }
14
+ return false;
15
+ }
16
+ function isWholeTableSelected(tableModel) {
17
+ var _a, _b, _c, _d;
18
+ return (((_b = (_a = tableModel.rows[0]) === null || _a === void 0 ? void 0 : _a.cells[0]) === null || _b === void 0 ? void 0 : _b.isSelected) &&
19
+ ((_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));
20
+ }
21
+ //# 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,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA2B,EAAE,QAAuB;IACjF,IAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,UAAU,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE;QAChD,mBAAmB,CAAC,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;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,36 @@
1
+ import { clearSelectedCells, insertTableRow } from 'roosterjs-content-model-api';
2
+ import { createSelectionMarker, getFirstSelectedTable, normalizeTable, setParagraphNotImplicit, setSelection, } from 'roosterjs-content-model-dom';
3
+ /**
4
+ * When the cursor is on the last cell of a table, add new row and focus first new cell.
5
+ * @internal
6
+ */
7
+ export function handleTabOnTableCell(model, cell, rawEvent) {
8
+ var _a, _b, _c;
9
+ var tableModel = getFirstSelectedTable(model)[0];
10
+ // Check if cursor is on last cell of the table
11
+ if (!rawEvent.shiftKey &&
12
+ tableModel &&
13
+ ((_a = tableModel.rows[tableModel.rows.length - 1]) === null || _a === void 0 ? void 0 : _a.cells[tableModel.widths.length - 1]) === cell) {
14
+ insertTableRow(tableModel, 'insertBelow');
15
+ // Clear Table selection
16
+ clearSelectedCells(tableModel, {
17
+ firstRow: tableModel.rows.length - 1,
18
+ firstColumn: 0,
19
+ lastRow: tableModel.rows.length - 1,
20
+ lastColumn: tableModel.widths.length - 1,
21
+ });
22
+ normalizeTable(tableModel, model.format);
23
+ // Add selection marker to the first cell of the new row
24
+ 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];
25
+ if (markerParagraph.blockType == 'Paragraph') {
26
+ var marker = createSelectionMarker(model.format);
27
+ markerParagraph.segments.unshift(marker);
28
+ setParagraphNotImplicit(markerParagraph);
29
+ setSelection(tableModel.rows[tableModel.rows.length - 1].cells[0], marker);
30
+ }
31
+ rawEvent.preventDefault();
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ //# 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,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,uBAAuB,EACvB,YAAY,GACf,MAAM,6BAA6B,CAAC;AAGrC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAChC,KAA2B,EAC3B,IAA2B,EAC3B,QAAuB;;IAEvB,IAAM,UAAU,GAAG,qBAAqB,CAAC,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,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAE1C,wBAAwB;QACxB,kBAAkB,CAAC,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,cAAc,CAAC,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,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEnD,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACzC,uBAAuB,CAAC,eAAe,CAAC,CAAC;YACzC,YAAY,CAAC,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","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,138 @@
1
+ import { matchLink } from 'roosterjs-content-model-api';
2
+ var defaultToolTipCallback = function (url) { return url; };
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
+ var HyperlinkPlugin = /** @class */ (function () {
10
+ /**
11
+ * Create a new instance of HyperLink class
12
+ * @param tooltip Tooltip to show when mouse hover over a link
13
+ * Default value is to return the href itself. If null, there will be no tooltip text.
14
+ * @param target (Optional) Target window name for hyperlink. If null, will use "_blank"
15
+ * @param onLinkClick (Optional) Open link callback (return false to use default behavior)
16
+ */
17
+ function HyperlinkPlugin(tooltip, target, onLinkClick) {
18
+ var _this = this;
19
+ if (tooltip === void 0) { tooltip = defaultToolTipCallback; }
20
+ this.tooltip = tooltip;
21
+ this.target = target;
22
+ this.onLinkClick = onLinkClick;
23
+ this.editor = null;
24
+ this.domHelper = null;
25
+ this.isMac = false;
26
+ this.disposer = null;
27
+ this.currentNode = null;
28
+ this.currentLink = null;
29
+ this.onMouse = function (e) {
30
+ _this.runWithHyperlink(e.target, function (href, a) {
31
+ var _a;
32
+ var tooltip = e.type == 'mouseover'
33
+ ? typeof _this.tooltip == 'function'
34
+ ? _this.tooltip(href, a)
35
+ : _this.tooltip
36
+ : null;
37
+ (_a = _this.domHelper) === null || _a === void 0 ? void 0 : _a.setDomAttribute('title', tooltip);
38
+ });
39
+ };
40
+ }
41
+ /**
42
+ * Get a friendly name of this plugin
43
+ */
44
+ HyperlinkPlugin.prototype.getName = function () {
45
+ return 'Hyperlink';
46
+ };
47
+ /**
48
+ * Initialize this plugin
49
+ * @param editor The editor instance
50
+ */
51
+ HyperlinkPlugin.prototype.initialize = function (editor) {
52
+ this.editor = editor;
53
+ this.domHelper = editor.getDOMHelper();
54
+ this.isMac = !!editor.getEnvironment().isMac;
55
+ this.disposer = editor.attachDomEvent({
56
+ mouseover: { beforeDispatch: this.onMouse },
57
+ mouseout: { beforeDispatch: this.onMouse },
58
+ });
59
+ };
60
+ /**
61
+ * Dispose this plugin
62
+ */
63
+ HyperlinkPlugin.prototype.dispose = function () {
64
+ if (this.disposer) {
65
+ this.disposer();
66
+ this.disposer = null;
67
+ }
68
+ this.currentNode = null;
69
+ this.currentLink = null;
70
+ this.editor = null;
71
+ };
72
+ /**
73
+ * Handle events triggered from editor
74
+ * @param event PluginEvent object
75
+ */
76
+ HyperlinkPlugin.prototype.onPluginEvent = function (event) {
77
+ var _this = this;
78
+ var _a, _b;
79
+ var matchedLink;
80
+ if (event.eventType == 'keyDown') {
81
+ var selection = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getDOMSelection();
82
+ var node_1 = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' ? selection.range.commonAncestorContainer : null;
83
+ if (node_1 && node_1 != this.currentNode) {
84
+ this.currentNode = node_1;
85
+ this.currentLink = null;
86
+ this.runWithHyperlink(node_1, function (href, a) {
87
+ if (node_1.textContent &&
88
+ (matchedLink = matchLink(node_1.textContent)) &&
89
+ matchedLink.normalizedUrl == href) {
90
+ _this.currentLink = a;
91
+ }
92
+ });
93
+ }
94
+ }
95
+ else if (event.eventType == 'keyUp') {
96
+ var selection = (_b = this.editor) === null || _b === void 0 ? void 0 : _b.getDOMSelection();
97
+ var node = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' ? selection.range.commonAncestorContainer : null;
98
+ if (node &&
99
+ node == this.currentNode &&
100
+ this.currentLink &&
101
+ this.currentLink.contains(node) &&
102
+ node.textContent &&
103
+ (matchedLink = matchLink(node.textContent))) {
104
+ this.currentLink.setAttribute('href', matchedLink.normalizedUrl);
105
+ }
106
+ }
107
+ else if (event.eventType == 'mouseUp' && event.isClicking) {
108
+ this.runWithHyperlink(event.rawEvent.target, function (href, anchor) {
109
+ var _a, _b;
110
+ if (!((_a = _this.onLinkClick) === null || _a === void 0 ? void 0 : _a.call(_this, anchor, event.rawEvent)) &&
111
+ _this.isCtrlOrMetaPressed(event.rawEvent) &&
112
+ event.rawEvent.button === 0) {
113
+ event.rawEvent.preventDefault();
114
+ var target = _this.target || '_blank';
115
+ var window_1 = (_b = _this.editor) === null || _b === void 0 ? void 0 : _b.getDocument().defaultView;
116
+ try {
117
+ window_1 === null || window_1 === void 0 ? void 0 : window_1.open(href, target);
118
+ }
119
+ catch (_c) { }
120
+ }
121
+ });
122
+ }
123
+ };
124
+ HyperlinkPlugin.prototype.runWithHyperlink = function (node, callback) {
125
+ var _a;
126
+ var a = (_a = this.domHelper) === null || _a === void 0 ? void 0 : _a.findClosestElementAncestor(node, 'a[href]');
127
+ var href = a === null || a === void 0 ? void 0 : a.getAttribute('href');
128
+ if (href && a) {
129
+ callback(href, a);
130
+ }
131
+ };
132
+ HyperlinkPlugin.prototype.isCtrlOrMetaPressed = function (event) {
133
+ return this.isMac ? event.metaKey : event.ctrlKey;
134
+ };
135
+ return HyperlinkPlugin;
136
+ }());
137
+ export { HyperlinkPlugin };
138
+ //# 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,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAUxD,IAAM,sBAAsB,GAAqB,UAAC,GAAW,IAAK,OAAA,GAAG,EAAH,CAAG,CAAC;AAEt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AC,MAAM,0CAAE,WAAW,GAAG,WAAW,CAAC;oBAEtD,IAAI;wBACA,QAAM,aAAN,QAAM,uBAAN,QAAM,CAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;qBAC9B;oBAAC,WAAM,GAAE;iBACb;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAcO,0CAAgB,GAAxB,UAAyB,IAAU,EAAE,QAAsD;;QACvF,IAAM,CAAC,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,0BAA0B,CAChD,IAAI,EACJ,SAAS,CACgB,CAAC;QAC9B,IAAM,IAAI,GAAG,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QAErC,IAAI,IAAI,IAAI,CAAC,EAAE;YACX,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SACrB;IACL,CAAC;IAEO,6CAAmB,GAA3B,UAA4B,KAAiC;QACzD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IACtD,CAAC;IACL,sBAAC;AAAD,CAAC,AAjJD,IAiJC","sourcesContent":["import { matchLink } from 'roosterjs-content-model-api';\nimport type { HyperlinkToolTip } from './HyperlinkToolTip';\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,2 @@
1
+ export {};
2
+ //# 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"]}
@@ -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-mjs/index.js CHANGED
@@ -2,9 +2,13 @@ export { TableEditPlugin } from './tableEdit/TableEditPlugin';
2
2
  export { PastePlugin } from './paste/PastePlugin';
3
3
  export { EditPlugin } from './edit/EditPlugin';
4
4
  export { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';
5
- export { ShortcutBold, ShortcutItalic, ShortcutUnderline, ShortcutClearFormat, ShortcutUndo, ShortcutUndo2, ShortcutRedo, ShortcutRedoMacOS, ShortcutBullet, ShortcutNumbering, ShortcutIncreaseFont, ShortcutDecreaseFont, ShortcutIndentList, ShortcutOutdentList, } from './shortcut/shortcuts';
5
+ export { ShortcutBold, ShortcutItalic, ShortcutUnderline, ShortcutClearFormat, ShortcutUndo, ShortcutUndo2, ShortcutRedo, ShortcutRedoAlt, ShortcutRedoMacOS, ShortcutBullet, ShortcutNumbering, ShortcutIncreaseFont, ShortcutDecreaseFont, ShortcutIndentList, ShortcutOutdentList, } from './shortcut/shortcuts';
6
6
  export { ShortcutPlugin } from './shortcut/ShortcutPlugin';
7
7
  export { ContextMenuPluginBase } from './contextMenuBase/ContextMenuPluginBase';
8
8
  export { WatermarkPlugin } from './watermark/WatermarkPlugin';
9
9
  export { MarkdownPlugin } from './markdown/MarkdownPlugin';
10
+ export { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';
11
+ export { PickerPlugin } from './picker/PickerPlugin';
12
+ export { CustomReplacePlugin } from './customReplace/CustomReplacePlugin';
13
+ export { getDOMInsertPointRect } from './pluginUtils/Rect/getDOMInsertPointRect';
10
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAqB,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EACH,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAsB,MAAM,yCAAyC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAmB,MAAM,2BAA2B,CAAC","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,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAqB,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EACH,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAsB,MAAM,yCAAyC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAmB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAiB,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC","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
  }
@@ -13,9 +13,10 @@ var DefaultOptions = {
13
13
  var MarkdownPlugin = /** @class */ (function () {
14
14
  /**
15
15
  * @param options An optional parameter that takes in an object of type MarkdownOptions, which includes the following properties:
16
- * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to true.
17
- * - bold: If true text between * will receive bold format. Defaults to true.
18
- * - italic: If true text between _ will receive italic format. Defaults to true.
16
+ * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to false.
17
+ * - bold: If true text between * will receive bold format. Defaults to false.
18
+ * - italic: If true text between _ will receive italic format. Defaults to false.
19
+ * - codeFormat: If provided, text between ` will receive code format. Defaults to undefined.
19
20
  */
20
21
  function MarkdownPlugin(options) {
21
22
  if (options === void 0) { options = DefaultOptions; }
@@ -24,6 +25,7 @@ var MarkdownPlugin = /** @class */ (function () {
24
25
  this.shouldBold = false;
25
26
  this.shouldItalic = false;
26
27
  this.shouldStrikethrough = false;
28
+ this.shouldCode = false;
27
29
  this.lastKeyTyped = null;
28
30
  }
29
31
  /**
@@ -48,9 +50,7 @@ var MarkdownPlugin = /** @class */ (function () {
48
50
  */
49
51
  MarkdownPlugin.prototype.dispose = function () {
50
52
  this.editor = null;
51
- this.shouldBold = false;
52
- this.shouldItalic = false;
53
- this.shouldStrikethrough = false;
53
+ this.disableAllFeatures();
54
54
  this.lastKeyTyped = null;
55
55
  };
56
56
  /**
@@ -116,6 +116,17 @@ var MarkdownPlugin = /** @class */ (function () {
116
116
  }
117
117
  }
118
118
  break;
119
+ case '`':
120
+ if (this.options.codeFormat) {
121
+ if (this.shouldCode) {
122
+ setFormat(editor, '`', {} /* format */, this.options.codeFormat);
123
+ this.shouldCode = false;
124
+ }
125
+ else {
126
+ this.shouldCode = true;
127
+ }
128
+ }
129
+ break;
119
130
  }
120
131
  }
121
132
  };
@@ -124,9 +135,7 @@ var MarkdownPlugin = /** @class */ (function () {
124
135
  if (!event.handledByEditFeature && !rawEvent.defaultPrevented) {
125
136
  switch (rawEvent.key) {
126
137
  case 'Enter':
127
- this.shouldBold = false;
128
- this.shouldItalic = false;
129
- this.shouldStrikethrough = false;
138
+ this.disableAllFeatures();
130
139
  this.lastKeyTyped = null;
131
140
  break;
132
141
  case ' ':
@@ -139,6 +148,9 @@ var MarkdownPlugin = /** @class */ (function () {
139
148
  else if (this.lastKeyTyped === '_' && this.shouldItalic) {
140
149
  this.shouldItalic = false;
141
150
  }
151
+ else if (this.lastKeyTyped === '`' && this.shouldCode) {
152
+ this.shouldCode = false;
153
+ }
142
154
  this.lastKeyTyped = null;
143
155
  break;
144
156
  default:
@@ -158,16 +170,23 @@ var MarkdownPlugin = /** @class */ (function () {
158
170
  else if (this.lastKeyTyped === '_' && this.shouldItalic) {
159
171
  this.shouldItalic = false;
160
172
  }
173
+ else if (this.lastKeyTyped === '`' && this.shouldCode) {
174
+ this.shouldCode = false;
175
+ }
161
176
  this.lastKeyTyped = null;
162
177
  }
163
178
  };
164
179
  MarkdownPlugin.prototype.handleContentChangedEvent = function (event) {
165
180
  if (event.source == 'Format') {
166
- this.shouldBold = false;
167
- this.shouldItalic = false;
168
- this.shouldStrikethrough = false;
181
+ this.disableAllFeatures();
169
182
  }
170
183
  };
184
+ MarkdownPlugin.prototype.disableAllFeatures = function () {
185
+ this.shouldBold = false;
186
+ this.shouldItalic = false;
187
+ this.shouldStrikethrough = false;
188
+ this.shouldCode = false;
189
+ };
171
190
  return MarkdownPlugin;
172
191
  }());
173
192
  export { MarkdownPlugin };