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
@@ -16,9 +16,10 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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 @@ define(["require", "exports", "./utils/setFormat"], function (require, exports,
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;
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/markdown/MarkdownPlugin.ts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,CAAC,oBAAoB,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,KAAK,WAAW,EAAE;gBACnE,IAAI,IAAI,CAAC,YAAY,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;oBAC9C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;iBAC3B;qBAAM,IAAI,IAAI,CAAC,YAAY,KAAK,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE;oBAC9D,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;iBACpC;qBAAM,IAAI,IAAI,CAAC,YAAY,KAAK,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE;oBACvD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;iBAC7B;gBACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;aAC5B;QACL,CAAC;QAEO,kDAAyB,GAAjC,UAAkC,KAA0B;YACxD,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ,EAAE;gBAC1B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBACxB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;gBAC1B,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;aACpC;QACL,CAAC;QACL,qBAAC;IAAD,CAAC,AAhKD,IAgKC;IAhKY,wCAAc","sourcesContent":["import { setFormat } from './utils/setFormat';\nimport type {\n ContentChangedEvent,\n EditorInputEvent,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Options for Markdown plugin\n */\nexport interface MarkdownOptions {\n strikethrough?: boolean;\n bold?: boolean;\n italic?: boolean;\n}\n\n/**\n * @internal\n */\nconst DefaultOptions: Required<MarkdownOptions> = {\n strikethrough: false,\n bold: false,\n italic: false,\n};\n\n/**\n * Markdown plugin handles markdown formatting, such as transforming * characters into bold text.\n */\nexport class MarkdownPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private shouldBold = false;\n private shouldItalic = false;\n private shouldStrikethrough = false;\n private lastKeyTyped: string | null = null;\n\n /**\n * @param options An optional parameter that takes in an object of type MarkdownOptions, which includes the following properties:\n * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to true.\n * - bold: If true text between * will receive bold format. Defaults to true.\n * - italic: If true text between _ will receive italic format. Defaults to true.\n */\n constructor(private options: MarkdownOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Markdown';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n this.shouldBold = false;\n this.shouldItalic = false;\n this.shouldStrikethrough = false;\n this.lastKeyTyped = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case 'input':\n this.handleEditorInputEvent(this.editor, event);\n break;\n case 'keyDown':\n this.handleBackspaceEvent(event);\n this.handleKeyDownEvent(event);\n break;\n case 'contentChanged':\n this.handleContentChangedEvent(event);\n break;\n }\n }\n }\n\n private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {\n const rawEvent = event.rawEvent;\n const selection = editor.getDOMSelection();\n if (\n selection &&\n selection.type == 'range' &&\n selection.range.collapsed &&\n rawEvent.inputType == 'insertText'\n ) {\n switch (rawEvent.data) {\n case '*':\n if (this.options.bold) {\n if (this.shouldBold) {\n setFormat(editor, '*', { fontWeight: 'bold' });\n this.shouldBold = false;\n } else {\n this.shouldBold = true;\n }\n }\n\n break;\n case '~':\n if (this.options.strikethrough) {\n if (this.shouldStrikethrough) {\n setFormat(editor, '~', { strikethrough: true });\n this.shouldStrikethrough = false;\n } else {\n this.shouldStrikethrough = true;\n }\n }\n break;\n case '_':\n if (this.options.italic) {\n if (this.shouldItalic) {\n setFormat(editor, '_', { italic: true });\n this.shouldItalic = false;\n } else {\n this.shouldItalic = true;\n }\n }\n break;\n }\n }\n }\n\n private handleKeyDownEvent(event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!event.handledByEditFeature && !rawEvent.defaultPrevented) {\n switch (rawEvent.key) {\n case 'Enter':\n this.shouldBold = false;\n this.shouldItalic = false;\n this.shouldStrikethrough = false;\n this.lastKeyTyped = null;\n break;\n case ' ':\n if (this.lastKeyTyped === '*' && this.shouldBold) {\n this.shouldBold = false;\n } else if (this.lastKeyTyped === '~' && this.shouldStrikethrough) {\n this.shouldStrikethrough = false;\n } else if (this.lastKeyTyped === '_' && this.shouldItalic) {\n this.shouldItalic = false;\n }\n this.lastKeyTyped = null;\n break;\n default:\n this.lastKeyTyped = rawEvent.key;\n break;\n }\n }\n }\n\n private handleBackspaceEvent(event: KeyDownEvent) {\n if (!event.handledByEditFeature && event.rawEvent.key === 'Backspace') {\n if (this.lastKeyTyped === '*' && this.shouldBold) {\n this.shouldBold = false;\n } else if (this.lastKeyTyped === '~' && this.shouldStrikethrough) {\n this.shouldStrikethrough = false;\n } else if (this.lastKeyTyped === '_' && this.shouldItalic) {\n this.shouldItalic = false;\n }\n this.lastKeyTyped = null;\n }\n }\n\n private handleContentChangedEvent(event: ContentChangedEvent) {\n if (event.source == 'Format') {\n this.shouldBold = false;\n this.shouldItalic = false;\n this.shouldStrikethrough = false;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MarkdownPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/markdown/MarkdownPlugin.ts"],"names":[],"mappings":";;;;IA0BA;;OAEG;IACH,IAAM,cAAc,GAA6B;QAC7C,aAAa,EAAE,KAAK;QACpB,IAAI,EAAE,KAAK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LD,IAiLC;IAjLY,wCAAc","sourcesContent":["import { setFormat } from './utils/setFormat';\nimport type {\n ContentChangedEvent,\n ContentModelCodeFormat,\n EditorInputEvent,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n *\n * Options for Markdown plugin\n * - strikethrough: If true text between ~ will receive strikethrough format.\n * - bold: If true text between * will receive bold format.\n * - italic: If true text between _ will receive italic format.\n * - codeFormat: If provided, text between ` will receive code format. If equal to {}, it will set the default code format.\n */\nexport interface MarkdownOptions {\n strikethrough?: boolean;\n bold?: boolean;\n italic?: boolean;\n codeFormat?: ContentModelCodeFormat;\n}\n\n/**\n * @internal\n */\nconst DefaultOptions: Partial<MarkdownOptions> = {\n strikethrough: false,\n bold: false,\n italic: false,\n};\n\n/**\n * Markdown plugin handles markdown formatting, such as transforming * characters into bold text.\n */\nexport class MarkdownPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private shouldBold = false;\n private shouldItalic = false;\n private shouldStrikethrough = false;\n private shouldCode = false;\n private lastKeyTyped: string | null = null;\n\n /**\n * @param options An optional parameter that takes in an object of type MarkdownOptions, which includes the following properties:\n * - strikethrough: If true text between ~ will receive strikethrough format. Defaults to false.\n * - bold: If true text between * will receive bold format. Defaults to false.\n * - italic: If true text between _ will receive italic format. Defaults to false.\n * - codeFormat: If provided, text between ` will receive code format. Defaults to undefined.\n */\n constructor(private options: MarkdownOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Markdown';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n this.disableAllFeatures();\n this.lastKeyTyped = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case 'input':\n this.handleEditorInputEvent(this.editor, event);\n break;\n case 'keyDown':\n this.handleBackspaceEvent(event);\n this.handleKeyDownEvent(event);\n break;\n case 'contentChanged':\n this.handleContentChangedEvent(event);\n break;\n }\n }\n }\n\n private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {\n const rawEvent = event.rawEvent;\n const selection = editor.getDOMSelection();\n if (\n selection &&\n selection.type == 'range' &&\n selection.range.collapsed &&\n rawEvent.inputType == 'insertText'\n ) {\n switch (rawEvent.data) {\n case '*':\n if (this.options.bold) {\n if (this.shouldBold) {\n setFormat(editor, '*', { fontWeight: 'bold' });\n this.shouldBold = false;\n } else {\n this.shouldBold = true;\n }\n }\n\n break;\n case '~':\n if (this.options.strikethrough) {\n if (this.shouldStrikethrough) {\n setFormat(editor, '~', { strikethrough: true });\n this.shouldStrikethrough = false;\n } else {\n this.shouldStrikethrough = true;\n }\n }\n break;\n case '_':\n if (this.options.italic) {\n if (this.shouldItalic) {\n setFormat(editor, '_', { italic: true });\n this.shouldItalic = false;\n } else {\n this.shouldItalic = true;\n }\n }\n break;\n case '`':\n if (this.options.codeFormat) {\n if (this.shouldCode) {\n setFormat(editor, '`', {} /* format */, this.options.codeFormat);\n this.shouldCode = false;\n } else {\n this.shouldCode = true;\n }\n }\n break;\n }\n }\n }\n\n private handleKeyDownEvent(event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!event.handledByEditFeature && !rawEvent.defaultPrevented) {\n switch (rawEvent.key) {\n case 'Enter':\n this.disableAllFeatures();\n this.lastKeyTyped = null;\n break;\n case ' ':\n if (this.lastKeyTyped === '*' && this.shouldBold) {\n this.shouldBold = false;\n } else if (this.lastKeyTyped === '~' && this.shouldStrikethrough) {\n this.shouldStrikethrough = false;\n } else if (this.lastKeyTyped === '_' && this.shouldItalic) {\n this.shouldItalic = false;\n } else if (this.lastKeyTyped === '`' && this.shouldCode) {\n this.shouldCode = false;\n }\n this.lastKeyTyped = null;\n break;\n default:\n this.lastKeyTyped = rawEvent.key;\n break;\n }\n }\n }\n\n private handleBackspaceEvent(event: KeyDownEvent) {\n if (!event.handledByEditFeature && event.rawEvent.key === 'Backspace') {\n if (this.lastKeyTyped === '*' && this.shouldBold) {\n this.shouldBold = false;\n } else if (this.lastKeyTyped === '~' && this.shouldStrikethrough) {\n this.shouldStrikethrough = false;\n } else if (this.lastKeyTyped === '_' && this.shouldItalic) {\n this.shouldItalic = false;\n } else if (this.lastKeyTyped === '`' && this.shouldCode) {\n this.shouldCode = false;\n }\n this.lastKeyTyped = null;\n }\n }\n\n private handleContentChangedEvent(event: ContentChangedEvent) {\n if (event.source == 'Format') {\n this.disableAllFeatures();\n }\n }\n\n private disableAllFeatures() {\n this.shouldBold = false;\n this.shouldItalic = false;\n this.shouldStrikethrough = false;\n this.shouldCode = false;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelSegmentFormat, IEditor } from 'roosterjs-content-model-types';
1
+ import type { ContentModelCodeFormat, ContentModelSegmentFormat, IEditor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function setFormat(editor: IEditor, character: string, format: ContentModelSegmentFormat): void;
5
+ export declare function setFormat(editor: IEditor, character: string, format: ContentModelSegmentFormat, codeFormat?: ContentModelCodeFormat): void;
@@ -1,39 +1,31 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-dom", "../../pluginUtils/splitTextSegment"], function (require, exports, tslib_1, roosterjs_content_model_dom_1, splitTextSegment_1) {
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-api", "../../pluginUtils/splitTextSegment"], function (require, exports, tslib_1, roosterjs_content_model_api_1, splitTextSegment_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setFormat = void 0;
5
5
  /**
6
6
  * @internal
7
7
  */
8
- function setFormat(editor, character, format) {
9
- editor.formatContentModel(function (model, context) {
10
- var _a;
11
- var selectedSegmentsAndParagraphs = (0, roosterjs_content_model_dom_1.getSelectedSegmentsAndParagraphs)(model, false /*includeFormatHolder*/);
12
- if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {
13
- var marker = selectedSegmentsAndParagraphs[0][0];
14
- context.newPendingFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, marker.format), { strikethrough: !!marker.format.strikethrough, italic: !!marker.format.italic, fontWeight: ((_a = marker.format) === null || _a === void 0 ? void 0 : _a.fontWeight) ? 'bold' : undefined });
15
- var paragraph = selectedSegmentsAndParagraphs[0][1];
16
- if (marker.segmentType == 'SelectionMarker') {
17
- var markerIndex = paragraph.segments.indexOf(marker);
18
- if (markerIndex > 0 && paragraph.segments[markerIndex - 1]) {
19
- var segmentBeforeMarker = paragraph.segments[markerIndex - 1];
20
- if (segmentBeforeMarker.segmentType == 'Text' &&
21
- segmentBeforeMarker.text[segmentBeforeMarker.text.length - 1] == character) {
22
- var textBeforeMarker = segmentBeforeMarker.text.slice(0, -1);
23
- if (textBeforeMarker.indexOf(character) > -1) {
24
- var lastCharIndex = segmentBeforeMarker.text.length;
25
- var firstCharIndex = segmentBeforeMarker.text
26
- .substring(0, lastCharIndex - 1)
27
- .lastIndexOf(character);
28
- var formattedText = (0, splitTextSegment_1.splitTextSegment)(segmentBeforeMarker, paragraph, firstCharIndex, lastCharIndex);
29
- formattedText.text = formattedText.text
30
- .replace(character, '')
31
- .slice(0, -1);
32
- formattedText.format = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, formattedText.format), format);
33
- context.canUndoByBackspace = true;
34
- return true;
35
- }
8
+ function setFormat(editor, character, format, codeFormat) {
9
+ (0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (_model, previousSegment, paragraph, markerFormat, context) {
10
+ if (previousSegment.text[previousSegment.text.length - 1] == character) {
11
+ var textBeforeMarker = previousSegment.text.slice(0, -1);
12
+ context.newPendingFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, markerFormat), { strikethrough: !!markerFormat.strikethrough, italic: !!markerFormat.italic, fontWeight: (markerFormat === null || markerFormat === void 0 ? void 0 : markerFormat.fontWeight) ? 'bold' : undefined });
13
+ if (textBeforeMarker.indexOf(character) > -1) {
14
+ var lastCharIndex = previousSegment.text.length;
15
+ var firstCharIndex = previousSegment.text
16
+ .substring(0, lastCharIndex - 1)
17
+ .lastIndexOf(character);
18
+ if (lastCharIndex - firstCharIndex > 2) {
19
+ var formattedText = (0, splitTextSegment_1.splitTextSegment)(previousSegment, paragraph, firstCharIndex, lastCharIndex);
20
+ formattedText.text = formattedText.text.replace(character, '').slice(0, -1);
21
+ formattedText.format = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, formattedText.format), format);
22
+ if (codeFormat) {
23
+ formattedText.code = {
24
+ format: codeFormat,
25
+ };
36
26
  }
27
+ context.canUndoByBackspace = true;
28
+ return true;
37
29
  }
38
30
  }
39
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,SAAS,CAAC,MAAe,EAAE,SAAiB,EAAE,MAAiC;QAC3F,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;;YACrC,IAAM,6BAA6B,GAAG,IAAA,8DAAgC,EAClE,KAAK,EACL,KAAK,CAAC,uBAAuB,CAChC,CAAC;YAEF,IAAI,6BAA6B,CAAC,MAAM,GAAG,CAAC,IAAI,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;gBACjF,IAAM,MAAM,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAA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AC;gCAE5B,IAAM,aAAa,GAAG,IAAA,mCAAgB,EAClC,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,aAAa,CAChB,CAAC;gCAEF,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI;qCAClC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;qCACtB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gCAClB,aAAa,CAAC,MAAM,mDACb,aAAa,CAAC,MAAM,GACpB,MAAM,CACZ,CAAC;gCAEF,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;gCAClC,OAAO,IAAI,CAAC;6BACf;yBACJ;qBACJ;iBACJ;aACJ;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAzDD,8BAyDC","sourcesContent":["import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-dom';\nimport { splitTextSegment } from '../../pluginUtils/splitTextSegment';\n\nimport type { ContentModelSegmentFormat, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setFormat(editor: IEditor, character: string, format: ContentModelSegmentFormat) {\n editor.formatContentModel((model, context) => {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n false /*includeFormatHolder*/\n );\n\n if (selectedSegmentsAndParagraphs.length > 0 && selectedSegmentsAndParagraphs[0][1]) {\n const marker = selectedSegmentsAndParagraphs[0][0];\n context.newPendingFormat = {\n ...marker.format,\n strikethrough: !!marker.format.strikethrough,\n italic: !!marker.format.italic,\n fontWeight: marker.format?.fontWeight ? 'bold' : undefined,\n };\n\n const paragraph = selectedSegmentsAndParagraphs[0][1];\n if (marker.segmentType == 'SelectionMarker') {\n const markerIndex = paragraph.segments.indexOf(marker);\n if (markerIndex > 0 && paragraph.segments[markerIndex - 1]) {\n const segmentBeforeMarker = paragraph.segments[markerIndex - 1];\n\n if (\n segmentBeforeMarker.segmentType == 'Text' &&\n segmentBeforeMarker.text[segmentBeforeMarker.text.length - 1] == character\n ) {\n const textBeforeMarker = segmentBeforeMarker.text.slice(0, -1);\n if (textBeforeMarker.indexOf(character) > -1) {\n const lastCharIndex = segmentBeforeMarker.text.length;\n const firstCharIndex = segmentBeforeMarker.text\n .substring(0, lastCharIndex - 1)\n .lastIndexOf(character);\n\n const formattedText = splitTextSegment(\n segmentBeforeMarker,\n paragraph,\n firstCharIndex,\n lastCharIndex\n );\n\n formattedText.text = formattedText.text\n .replace(character, '')\n .slice(0, -1);\n formattedText.format = {\n ...formattedText.format,\n ...format,\n };\n\n context.canUndoByBackspace = true;\n return true;\n }\n }\n }\n }\n }\n return false;\n });\n}\n"]}
1
+ {"version":3,"file":"setFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts"],"names":[],"mappings":";;;;IASA;;OAEG;IACH,SAAgB,SAAS,CACrB,MAAe,EACf,SAAiB,EACjB,MAAiC,EACjC,UAAmC;QAEnC,IAAA,oEAAsC,EAClC,MAAM,EACN,UAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO;YACtD,IAAI,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE;gBACpE,IAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3D,OAAO,CAAC,gBAAgB,mDACjB,YAAY,KACf,aAAa,EAAE,CAAC,CAAC,YAAY,CAAC,aAAa,EAC3C,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM,EAC7B,UAAU,EAAE,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,UAAU,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GAC5D,CAAC;gBACF,IAAI,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC1C,IAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;oBAClD,IAAM,cAAc,GAAG,eAAe,CAAC,IAAI;yBACtC,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,CAAC;yBAC/B,WAAW,CAAC,SAAS,CAAC,CAAC;oBAC5B,IAAI,aAAa,GAAG,cAAc,GAAG,CAAC,EAAE;wBACpC,IAAM,aAAa,GAAG,IAAA,mCAAgB,EAClC,eAAe,EACf,SAAS,EACT,cAAc,EACd,aAAa,CAChB,CAAC;wBAEF,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;wBAC5E,aAAa,CAAC,MAAM,mDACb,aAAa,CAAC,MAAM,GACpB,MAAM,CACZ,CAAC;wBACF,IAAI,UAAU,EAAE;4BACZ,aAAa,CAAC,IAAI,GAAG;gCACjB,MAAM,EAAE,UAAU;6BACrB,CAAC;yBACL;wBAED,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;wBAClC,OAAO,IAAI,CAAC;qBACf;iBACJ;aACJ;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CACJ,CAAC;IACN,CAAC;IAjDD,8BAiDC","sourcesContent":["import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\nimport { splitTextSegment } from '../../pluginUtils/splitTextSegment';\n\nimport type {\n ContentModelCodeFormat,\n ContentModelSegmentFormat,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setFormat(\n editor: IEditor,\n character: string,\n format: ContentModelSegmentFormat,\n codeFormat?: ContentModelCodeFormat\n) {\n formatTextSegmentBeforeSelectionMarker(\n editor,\n (_model, previousSegment, paragraph, markerFormat, context) => {\n if (previousSegment.text[previousSegment.text.length - 1] == character) {\n const textBeforeMarker = previousSegment.text.slice(0, -1);\n context.newPendingFormat = {\n ...markerFormat,\n strikethrough: !!markerFormat.strikethrough,\n italic: !!markerFormat.italic,\n fontWeight: markerFormat?.fontWeight ? 'bold' : undefined,\n };\n if (textBeforeMarker.indexOf(character) > -1) {\n const lastCharIndex = previousSegment.text.length;\n const firstCharIndex = previousSegment.text\n .substring(0, lastCharIndex - 1)\n .lastIndexOf(character);\n if (lastCharIndex - firstCharIndex > 2) {\n const formattedText = splitTextSegment(\n previousSegment,\n paragraph,\n firstCharIndex,\n lastCharIndex\n );\n\n formattedText.text = formattedText.text.replace(character, '').slice(0, -1);\n formattedText.format = {\n ...formattedText.format,\n ...format,\n };\n if (codeFormat) {\n formattedText.code = {\n format: codeFormat,\n };\n }\n\n context.canUndoByBackspace = true;\n return true;\n }\n }\n }\n return false;\n }\n );\n}\n"]}
@@ -0,0 +1,112 @@
1
+ import type { PickerHelper } from './PickerHelper';
2
+ import type { DOMInsertPoint } from 'roosterjs-content-model-types';
3
+ /**
4
+ * Direction option for picker
5
+ */
6
+ export declare type PickerDirection =
7
+ /**
8
+ * Show options horizontally
9
+ */
10
+ 'horizontal'
11
+ /**
12
+ * Show options vertically
13
+ */
14
+ | 'vertical'
15
+ /**
16
+ * Show options in both direction (2-D picker)
17
+ */
18
+ | 'both';
19
+ /**
20
+ * Change mode that PickerPlugin will pass to child class
21
+ */
22
+ export declare type PickerSelectionChangMode =
23
+ /**
24
+ * When user press Right ("horizontal" mode or "both" mode) (Left in RTL) or Down ("vertical" mode),
25
+ * select the next option
26
+ */
27
+ 'next'
28
+ /**
29
+ * When user press Left ("horizontal" mode or "both" mode) (Right in RTL) or Up ("vertical" mode),
30
+ * select the previous option
31
+ */
32
+ | 'previous'
33
+ /**
34
+ * When user press Down ("both" mode),
35
+ * select the next row
36
+ */
37
+ | 'nextRow'
38
+ /**
39
+ * When user press Up ("both" mode),
40
+ * select the previous row
41
+ */
42
+ | 'previousRow'
43
+ /**
44
+ * When user press PageDown,
45
+ * switch to next page
46
+ */
47
+ | 'nextPage'
48
+ /**
49
+ * When user press PageUp,
50
+ * switch to previous page
51
+ */
52
+ | 'previousPage'
53
+ /**
54
+ * When user press Home,
55
+ * Select the first item in current row
56
+ */
57
+ | 'firstInRow'
58
+ /**
59
+ * When user press End,
60
+ * Select the last item in current row
61
+ */
62
+ | 'lastInRow'
63
+ /**
64
+ * When user press CTRL (or META on Mac) + Home,
65
+ * Select the very first item
66
+ */
67
+ | 'first'
68
+ /**
69
+ * When user press CTRL (or META on Mac) + End,
70
+ * Select the very last item
71
+ */
72
+ | 'last';
73
+ /**
74
+ * Represents the interface a handler for picker plugin. Developer need to implement this interface to create a new type of picker
75
+ */
76
+ export interface PickerHandler {
77
+ /**
78
+ * Initialize the picker handler, pass in editor and PickerPlugin instance so that the handler can save them
79
+ * @param editor The editor instance
80
+ * @param pickerPlugin The PickerPlugin instance
81
+ */
82
+ onInitialize: (helper: PickerHelper) => void;
83
+ /**
84
+ * Dispose the picker handler
85
+ */
86
+ onDispose: () => void;
87
+ /**
88
+ * Notify the picker handler that user has typed trigger character so handler should show picker now
89
+ * @param queryString Current query string
90
+ * @param insertPoint Insert point where user is typing, can be used for calculating picker position
91
+ * @returns A picker direction to let picker plugin know what kind of picker is opened. Picker plugin will use this value
92
+ * to decide how to handle keyboard event to change selection. Return null means picker is not actually opened
93
+ */
94
+ onTrigger: (queryString: string, insertPoint: DOMInsertPoint) => PickerDirection | null;
95
+ /**
96
+ * Notify the picker handler that picker should be closed now
97
+ */
98
+ onClosePicker?(): void;
99
+ /**
100
+ * Notify the picker handler that user has changed current typed query string
101
+ */
102
+ onQueryStringChanged?(queryString: string): void;
103
+ /**
104
+ * Notify the picker handler that user has decide to select the current option in picker
105
+ */
106
+ onSelect?(): void;
107
+ /**
108
+ * Notify the picker handler that user is using keyboard to change current selection
109
+ * @param mode The moving mode. Handler code can use this value to decide which item need to be selected
110
+ */
111
+ onSelectionChanged?(mode: PickerSelectionChangMode): void;
112
+ }
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=PickerHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerHandler.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/picker/PickerHandler.ts"],"names":[],"mappings":"","sourcesContent":["import type { PickerHelper } from './PickerHelper';\nimport type { DOMInsertPoint } from 'roosterjs-content-model-types';\n\n/**\n * Direction option for picker\n */\nexport type PickerDirection =\n /**\n * Show options horizontally\n */\n | 'horizontal'\n /**\n * Show options vertically\n */\n | 'vertical'\n\n /**\n * Show options in both direction (2-D picker)\n */\n | 'both';\n\n/**\n * Change mode that PickerPlugin will pass to child class\n */\nexport type PickerSelectionChangMode =\n /**\n * When user press Right (\"horizontal\" mode or \"both\" mode) (Left in RTL) or Down (\"vertical\" mode),\n * select the next option\n */\n | 'next'\n\n /**\n * When user press Left (\"horizontal\" mode or \"both\" mode) (Right in RTL) or Up (\"vertical\" mode),\n * select the previous option\n */\n | 'previous'\n\n /**\n * When user press Down (\"both\" mode),\n * select the next row\n */\n | 'nextRow'\n\n /**\n * When user press Up (\"both\" mode),\n * select the previous row\n */\n | 'previousRow'\n\n /**\n * When user press PageDown,\n * switch to next page\n */\n | 'nextPage'\n\n /**\n * When user press PageUp,\n * switch to previous page\n */\n | 'previousPage'\n\n /**\n * When user press Home,\n * Select the first item in current row\n */\n | 'firstInRow'\n\n /**\n * When user press End,\n * Select the last item in current row\n */\n | 'lastInRow'\n\n /**\n * When user press CTRL (or META on Mac) + Home,\n * Select the very first item\n */\n | 'first'\n\n /**\n * When user press CTRL (or META on Mac) + End,\n * Select the very last item\n */\n | 'last';\n\n/**\n * Represents the interface a handler for picker plugin. Developer need to implement this interface to create a new type of picker\n */\nexport interface PickerHandler {\n /**\n * Initialize the picker handler, pass in editor and PickerPlugin instance so that the handler can save them\n * @param editor The editor instance\n * @param pickerPlugin The PickerPlugin instance\n */\n onInitialize: (helper: PickerHelper) => void;\n\n /**\n * Dispose the picker handler\n */\n onDispose: () => void;\n\n /**\n * Notify the picker handler that user has typed trigger character so handler should show picker now\n * @param queryString Current query string\n * @param insertPoint Insert point where user is typing, can be used for calculating picker position\n * @returns A picker direction to let picker plugin know what kind of picker is opened. Picker plugin will use this value\n * to decide how to handle keyboard event to change selection. Return null means picker is not actually opened\n */\n onTrigger: (queryString: string, insertPoint: DOMInsertPoint) => PickerDirection | null;\n\n /**\n * Notify the picker handler that picker should be closed now\n */\n onClosePicker?(): void;\n\n /**\n * Notify the picker handler that user has changed current typed query string\n */\n onQueryStringChanged?(queryString: string): void;\n\n /**\n * Notify the picker handler that user has decide to select the current option in picker\n */\n onSelect?(): void;\n\n /**\n * Notify the picker handler that user is using keyboard to change current selection\n * @param mode The moving mode. Handler code can use this value to decide which item need to be selected\n */\n onSelectionChanged?(mode: PickerSelectionChangMode): void;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { ContentModelDocument, FormatContentModelOptions, IEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Represents the interface of picker plugin, provides necessary utility functions for pickers
4
+ */
5
+ export interface PickerHelper {
6
+ /**
7
+ * The editor instance
8
+ */
9
+ readonly editor: IEditor;
10
+ /**
11
+ * Replace the query string with a given Content Model.
12
+ * This is used for commit a change from picker and insert the committed content into editor.
13
+ * @param model The Content Model to insert
14
+ * @param options Options for formatting content model
15
+ * @param canUndoByBackspace Whether this change can be undone using Backspace key
16
+ */
17
+ replaceQueryString: (model: ContentModelDocument, options?: FormatContentModelOptions, canUndoByBackspace?: boolean) => void;
18
+ /**
19
+ * Notify Picker Plugin that picker is closed from the handler code, so picker plugin can quit the suggesting state
20
+ */
21
+ closePicker: () => void;
22
+ }
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=PickerHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/picker/PickerHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ContentModelDocument,\n FormatContentModelOptions,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Represents the interface of picker plugin, provides necessary utility functions for pickers\n */\nexport interface PickerHelper {\n /**\n * The editor instance\n */\n readonly editor: IEditor;\n\n /**\n * Replace the query string with a given Content Model.\n * This is used for commit a change from picker and insert the committed content into editor.\n * @param model The Content Model to insert\n * @param options Options for formatting content model\n * @param canUndoByBackspace Whether this change can be undone using Backspace key\n */\n replaceQueryString: (\n model: ContentModelDocument,\n options?: FormatContentModelOptions,\n canUndoByBackspace?: boolean\n ) => void;\n\n /**\n * Notify Picker Plugin that picker is closed from the handler code, so picker plugin can quit the suggesting state\n */\n closePicker: () => void;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { ContentModelDocument, FormatContentModelOptions, IEditor } from 'roosterjs-content-model-types';
2
+ import type { PickerDirection, PickerHandler } from './PickerHandler';
3
+ import type { PickerHelper } from './PickerHelper';
4
+ /**
5
+ * @internal
6
+ */
7
+ export declare class PickerHelperImpl implements PickerHelper {
8
+ readonly editor: IEditor;
9
+ readonly handler: PickerHandler;
10
+ private triggerCharacter;
11
+ direction: PickerDirection | null;
12
+ constructor(editor: IEditor, handler: PickerHandler, triggerCharacter: string);
13
+ /**
14
+ * Replace the query string with a given Content Model.
15
+ * This is used for commit a change from picker and insert the committed content into editor.
16
+ * @param model The Content Model to insert
17
+ * @param options Options for formatting content model
18
+ * @param canUndoByBackspace Whether this change can be undone using Backspace key
19
+ */
20
+ replaceQueryString(model: ContentModelDocument, options?: FormatContentModelOptions, canUndoByBackspace?: boolean): void;
21
+ /**
22
+ * Notify Picker Plugin that picker is closed from the handler code, so picker plugin can quit the suggesting state
23
+ */
24
+ closePicker(): void;
25
+ }
@@ -0,0 +1,53 @@
1
+ define(["require", "exports", "roosterjs-content-model-api", "./getQueryString", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_api_1, getQueryString_1, roosterjs_content_model_dom_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PickerHelperImpl = void 0;
5
+ /**
6
+ * @internal
7
+ */
8
+ var PickerHelperImpl = /** @class */ (function () {
9
+ function PickerHelperImpl(editor, handler, triggerCharacter) {
10
+ this.editor = editor;
11
+ this.handler = handler;
12
+ this.triggerCharacter = triggerCharacter;
13
+ this.direction = null;
14
+ }
15
+ /**
16
+ * Replace the query string with a given Content Model.
17
+ * This is used for commit a change from picker and insert the committed content into editor.
18
+ * @param model The Content Model to insert
19
+ * @param options Options for formatting content model
20
+ * @param canUndoByBackspace Whether this change can be undone using Backspace key
21
+ */
22
+ PickerHelperImpl.prototype.replaceQueryString = function (model, options, canUndoByBackspace) {
23
+ var _this = this;
24
+ this.editor.focus();
25
+ (0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(this.editor, function (target, previousSegment, paragraph, _, context) {
26
+ var potentialSegments = [];
27
+ var queryString = (0, getQueryString_1.getQueryString)(_this.triggerCharacter, paragraph, previousSegment, potentialSegments);
28
+ if (queryString) {
29
+ potentialSegments.forEach(function (x) { return (x.isSelected = true); });
30
+ (0, roosterjs_content_model_dom_1.mergeModel)(target, model, context);
31
+ context.canUndoByBackspace = canUndoByBackspace;
32
+ return true;
33
+ }
34
+ else {
35
+ return false;
36
+ }
37
+ }, options);
38
+ };
39
+ /**
40
+ * Notify Picker Plugin that picker is closed from the handler code, so picker plugin can quit the suggesting state
41
+ */
42
+ PickerHelperImpl.prototype.closePicker = function () {
43
+ var _a, _b;
44
+ if (this.direction) {
45
+ this.direction = null;
46
+ (_b = (_a = this.handler).onClosePicker) === null || _b === void 0 ? void 0 : _b.call(_a);
47
+ }
48
+ };
49
+ return PickerHelperImpl;
50
+ }());
51
+ exports.PickerHelperImpl = PickerHelperImpl;
52
+ });
53
+ //# sourceMappingURL=PickerHelperImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerHelperImpl.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/picker/PickerHelperImpl.ts"],"names":[],"mappings":";;;;IAYA;;OAEG;IACH;QAGI,0BACoB,MAAe,EACf,OAAsB,EAC9B,gBAAwB;YAFhB,WAAM,GAAN,MAAM,CAAS;YACf,YAAO,GAAP,OAAO,CAAe;YAC9B,qBAAgB,GAAhB,gBAAgB,CAAQ;YAL7B,cAAS,GAA2B,IAAI,CAAC;QAM7C,CAAC;QAEJ;;;;;;WAMG;QACH,6CAAkB,GAAlB,UACI,KAA2B,EAC3B,OAAmC,EACnC,kBAA4B;YAHhC,iBA6BC;YAxBG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAEpB,IAAA,oEAAsC,EAClC,IAAI,CAAC,MAAM,EACX,UAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO;gBAC3C,IAAM,iBAAiB,GAAuB,EAAE,CAAC;gBACjD,IAAM,WAAW,GAAG,IAAA,+BAAc,EAC9B,KAAI,CAAC,gBAAgB,EACrB,SAAS,EACT,eAAe,EACf,iBAAiB,CACpB,CAAC;gBAEF,IAAI,WAAW,EAAE;oBACb,iBAAiB,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,EAArB,CAAqB,CAAC,CAAC;oBACtD,IAAA,wCAAU,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;oBACnC,OAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;oBAChD,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD,OAAO,CACV,CAAC;QACN,CAAC;QAED;;WAEG;QACH,sCAAW,GAAX;;YACI,IAAI,IAAI,CAAC,SAAS,EAAE;gBAChB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,aAAa,kDAAI,CAAC;aAClC;QACL,CAAC;QACL,uBAAC;IAAD,CAAC,AAxDD,IAwDC;IAxDY,4CAAgB","sourcesContent":["import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\nimport { getQueryString } from './getQueryString';\nimport { mergeModel } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelText,\n FormatContentModelOptions,\n IEditor,\n} from 'roosterjs-content-model-types';\nimport type { PickerDirection, PickerHandler } from './PickerHandler';\nimport type { PickerHelper } from './PickerHelper';\n\n/**\n * @internal\n */\nexport class PickerHelperImpl implements PickerHelper {\n public direction: PickerDirection | null = null;\n\n constructor(\n public readonly editor: IEditor,\n public readonly handler: PickerHandler,\n private triggerCharacter: string\n ) {}\n\n /**\n * Replace the query string with a given Content Model.\n * This is used for commit a change from picker and insert the committed content into editor.\n * @param model The Content Model to insert\n * @param options Options for formatting content model\n * @param canUndoByBackspace Whether this change can be undone using Backspace key\n */\n replaceQueryString(\n model: ContentModelDocument,\n options?: FormatContentModelOptions,\n canUndoByBackspace?: boolean\n ): void {\n this.editor.focus();\n\n formatTextSegmentBeforeSelectionMarker(\n this.editor,\n (target, previousSegment, paragraph, _, context) => {\n const potentialSegments: ContentModelText[] = [];\n const queryString = getQueryString(\n this.triggerCharacter,\n paragraph,\n previousSegment,\n potentialSegments\n );\n\n if (queryString) {\n potentialSegments.forEach(x => (x.isSelected = true));\n mergeModel(target, model, context);\n context.canUndoByBackspace = canUndoByBackspace;\n return true;\n } else {\n return false;\n }\n },\n options\n );\n }\n\n /**\n * Notify Picker Plugin that picker is closed from the handler code, so picker plugin can quit the suggesting state\n */\n closePicker() {\n if (this.direction) {\n this.direction = null;\n this.handler.onClosePicker?.();\n }\n }\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { PickerHandler } from './PickerHandler';
2
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
3
+ /**
4
+ * PickerPlugin represents a plugin of editor which can handle picker related behaviors, including
5
+ * - Show picker when special trigger key is pressed
6
+ * - Hide picker
7
+ * - Change selection in picker by Up/Down/Left/Right
8
+ * - Apply selected item in picker
9
+ *
10
+ * PickerPlugin doesn't provide any UI, it just wraps related DOM events and invoke callback functions.
11
+ */
12
+ export declare class PickerPlugin implements EditorPlugin {
13
+ private triggerCharacter;
14
+ private readonly handler;
15
+ private isMac;
16
+ private lastQueryString;
17
+ private helper;
18
+ /**
19
+ * Construct a new instance of PickerPlugin class
20
+ * @param triggerCharacter The character to trigger a picker to be shown
21
+ * @param handler Picker handler for receiving picker state change events
22
+ */
23
+ constructor(triggerCharacter: string, handler: PickerHandler);
24
+ /**
25
+ * Get a friendly name
26
+ */
27
+ getName(): string;
28
+ /**
29
+ * Initialize this plugin. This should only be called from Editor
30
+ * @param editor Editor instance
31
+ */
32
+ initialize(editor: IEditor): void;
33
+ /**
34
+ * Dispose this plugin
35
+ */
36
+ dispose(): void;
37
+ /**
38
+ * Check if the plugin should handle the given event exclusively.
39
+ * Handle an event exclusively means other plugin will not receive this event in
40
+ * onPluginEvent method.
41
+ * If two plugins will return true in willHandleEventExclusively() for the same event,
42
+ * the final result depends on the order of the plugins are added into editor
43
+ * @param event The event to check
44
+ */
45
+ willHandleEventExclusively(event: PluginEvent): boolean;
46
+ /**
47
+ * Handle events triggered from editor
48
+ * @param event PluginEvent object
49
+ */
50
+ onPluginEvent(event: PluginEvent): void;
51
+ private onSuggestingKeyDown;
52
+ private onSuggestingInput;
53
+ private onInput;
54
+ }