roamjs-components 0.86.0-alpha.3 → 0.86.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 (567) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +29 -29
  3. package/components/AutocompleteInput.d.ts +29 -28
  4. package/components/AutocompleteInput.js +132 -120
  5. package/components/AutocompleteInput.js.map +1 -1
  6. package/components/BlockErrorBoundary.d.ts +15 -16
  7. package/components/BlockErrorBoundary.js +27 -27
  8. package/components/BlockErrorBoundary.js.map +1 -1
  9. package/components/BlockInput.d.ts +13 -13
  10. package/components/BlockInput.js +55 -55
  11. package/components/ComponentContainer.d.ts +10 -11
  12. package/components/ComponentContainer.js +37 -37
  13. package/components/ComponentContainer.js.map +1 -1
  14. package/components/ConfigPage.d.ts +35 -35
  15. package/components/ConfigPage.js +159 -159
  16. package/components/ConfigPanels/BlockPanel.d.ts +3 -3
  17. package/components/ConfigPanels/BlockPanel.js +42 -42
  18. package/components/ConfigPanels/BlockPanel.js.map +1 -1
  19. package/components/ConfigPanels/BlocksPanel.d.ts +3 -3
  20. package/components/ConfigPanels/BlocksPanel.js +58 -58
  21. package/components/ConfigPanels/BlocksPanel.js.map +1 -1
  22. package/components/ConfigPanels/CustomPanel.d.ts +3 -3
  23. package/components/ConfigPanels/CustomPanel.js +24 -24
  24. package/components/ConfigPanels/FlagPanel.d.ts +3 -3
  25. package/components/ConfigPanels/FlagPanel.js +31 -31
  26. package/components/ConfigPanels/MultiChildPanel.d.ts +9 -9
  27. package/components/ConfigPanels/MultiChildPanel.js +58 -58
  28. package/components/ConfigPanels/MultiTextPanel.d.ts +3 -3
  29. package/components/ConfigPanels/MultiTextPanel.js +14 -14
  30. package/components/ConfigPanels/NumberPanel.d.ts +3 -3
  31. package/components/ConfigPanels/NumberPanel.js +25 -25
  32. package/components/ConfigPanels/OauthPanel.d.ts +3 -3
  33. package/components/ConfigPanels/OauthPanel.js +81 -81
  34. package/components/ConfigPanels/OauthPanel.js.map +1 -1
  35. package/components/ConfigPanels/PagesPanel.d.ts +3 -3
  36. package/components/ConfigPanels/PagesPanel.js +11 -11
  37. package/components/ConfigPanels/SelectPanel.d.ts +3 -3
  38. package/components/ConfigPanels/SelectPanel.js +27 -27
  39. package/components/ConfigPanels/TextPanel.d.ts +3 -3
  40. package/components/ConfigPanels/TextPanel.js +28 -28
  41. package/components/ConfigPanels/TimePanel.d.ts +3 -3
  42. package/components/ConfigPanels/TimePanel.js +34 -34
  43. package/components/ConfigPanels/getBrandColors.d.ts +7 -7
  44. package/components/ConfigPanels/getBrandColors.js +28 -28
  45. package/components/ConfigPanels/types.d.ts +84 -84
  46. package/components/ConfigPanels/types.js +2 -2
  47. package/components/ConfigPanels/types.js.map +1 -1
  48. package/components/ConfigPanels/useSingleChildValue.d.ts +13 -13
  49. package/components/ConfigPanels/useSingleChildValue.js +43 -43
  50. package/components/CursorMenu.d.ts +21 -21
  51. package/components/CursorMenu.js +181 -181
  52. package/components/CursorMenu.js.map +1 -1
  53. package/components/Description.d.ts +5 -5
  54. package/components/Description.js +16 -16
  55. package/components/ExtensionApiContext.d.ts +31 -31
  56. package/components/ExtensionApiContext.js +16 -16
  57. package/components/ExternalLogin.d.ts +18 -18
  58. package/components/ExternalLogin.js +141 -141
  59. package/components/Filter.d.ts +15 -15
  60. package/components/Filter.js +142 -142
  61. package/components/FormDialog.d.ts +55 -55
  62. package/components/FormDialog.js +220 -217
  63. package/components/FormDialog.js.map +1 -1
  64. package/components/Loading.d.ts +4 -4
  65. package/components/Loading.js +35 -35
  66. package/components/MenuItemSelect.d.ts +17 -17
  67. package/components/MenuItemSelect.js +23 -23
  68. package/components/MenuItemSelect.js.map +1 -1
  69. package/components/OauthPanel.d.ts +7 -7
  70. package/components/OauthPanel.js +30 -30
  71. package/components/OauthSelect.d.ts +5 -5
  72. package/components/OauthSelect.js +25 -25
  73. package/components/PageInput.d.ts +6 -6
  74. package/components/PageInput.js +13 -13
  75. package/components/PageLink.d.ts +6 -6
  76. package/components/PageLink.js +31 -31
  77. package/components/ProgressDialog.d.ts +11 -11
  78. package/components/ProgressDialog.js +48 -48
  79. package/components/SimpleAlert.d.ts +15 -15
  80. package/components/SimpleAlert.js +47 -47
  81. package/components/Toast.d.ts +15 -15
  82. package/components/Toast.js +50 -50
  83. package/components/index.js +4 -4
  84. package/components/index.js.map +1 -1
  85. package/components.d.ts +5 -5
  86. package/components.js +172 -201
  87. package/components.js.map +1 -1
  88. package/date/constants.d.ts +3 -3
  89. package/date/constants.js +19 -19
  90. package/date/constants.js.map +1 -1
  91. package/date/index.d.ts +3 -3
  92. package/date/index.js +9 -9
  93. package/date/index.js.map +1 -1
  94. package/date/parseNlpDate.d.ts +5 -5
  95. package/date/parseNlpDate.js +226 -226
  96. package/date/parseNlpDate.js.map +1 -1
  97. package/date/parseRoamDateUid.d.ts +2 -2
  98. package/date/parseRoamDateUid.js +7 -7
  99. package/date/parseRoamDateUid.js.map +1 -1
  100. package/dom/addBlockCommand.d.ts +5 -5
  101. package/dom/addBlockCommand.js +53 -53
  102. package/dom/addBlockCommand.js.map +1 -1
  103. package/dom/addKeyboardTriggers.d.ts +11 -11
  104. package/dom/addKeyboardTriggers.js +38 -38
  105. package/dom/addKeyboardTriggers.js.map +1 -1
  106. package/dom/addOldRoamJSDependency.d.ts +2 -2
  107. package/dom/addOldRoamJSDependency.js +10 -10
  108. package/dom/addOldRoamJSDependency.js.map +1 -1
  109. package/dom/addRoamJSDependency.d.ts +2 -2
  110. package/dom/addRoamJSDependency.js +8 -8
  111. package/dom/addRoamJSDependency.js.map +1 -1
  112. package/dom/addScriptAsDependency.d.ts +6 -6
  113. package/dom/addScriptAsDependency.js +16 -16
  114. package/dom/addScriptAsDependency.js.map +1 -1
  115. package/dom/addStyle.d.ts +2 -2
  116. package/dom/addStyle.js +14 -14
  117. package/dom/addStyle.js.map +1 -1
  118. package/dom/constants.d.ts +1 -1
  119. package/dom/constants.js +4 -4
  120. package/dom/constants.js.map +1 -1
  121. package/dom/createBlockObserver.d.ts +7 -7
  122. package/dom/createBlockObserver.js +43 -43
  123. package/dom/createBlockObserver.js.map +1 -1
  124. package/dom/createButtonObserver.d.ts +6 -6
  125. package/dom/createButtonObserver.js +21 -21
  126. package/dom/createButtonObserver.js.map +1 -1
  127. package/dom/createDivObserver.d.ts +2 -2
  128. package/dom/createDivObserver.js +13 -13
  129. package/dom/createDivObserver.js.map +1 -1
  130. package/dom/createHTMLObserver.d.ts +8 -8
  131. package/dom/createHTMLObserver.js +24 -24
  132. package/dom/createHTMLObserver.js.map +1 -1
  133. package/dom/createHashtagObserver.d.ts +5 -5
  134. package/dom/createHashtagObserver.js +16 -16
  135. package/dom/createHashtagObserver.js.map +1 -1
  136. package/dom/createIconButton.d.ts +2 -2
  137. package/dom/createIconButton.js +12 -12
  138. package/dom/createIconButton.js.map +1 -1
  139. package/dom/createObserver.d.ts +2 -2
  140. package/dom/createObserver.js +9 -9
  141. package/dom/createObserver.js.map +1 -1
  142. package/dom/createOverlayObserver.d.ts +2 -2
  143. package/dom/createOverlayObserver.js +6 -6
  144. package/dom/createOverlayObserver.js.map +1 -1
  145. package/dom/createPageObserver.d.ts +2 -2
  146. package/dom/createPageObserver.js +34 -34
  147. package/dom/createPageObserver.js.map +1 -1
  148. package/dom/createPageTitleObserver.d.ts +6 -6
  149. package/dom/createPageTitleObserver.js +31 -31
  150. package/dom/createPageTitleObserver.js.map +1 -1
  151. package/dom/elToTitle.d.ts +2 -2
  152. package/dom/elToTitle.js +22 -22
  153. package/dom/elToTitle.js.map +1 -1
  154. package/dom/genericError.d.ts +3 -3
  155. package/dom/genericError.js +11 -11
  156. package/dom/genericError.js.map +1 -1
  157. package/dom/getActiveUids.d.ts +3 -3
  158. package/dom/getActiveUids.js +6 -6
  159. package/dom/getActiveUids.js.map +1 -1
  160. package/dom/getBlockUidFromTarget.d.ts +2 -2
  161. package/dom/getBlockUidFromTarget.js +33 -33
  162. package/dom/getBlockUidFromTarget.js.map +1 -1
  163. package/dom/getCurrentPageUid.d.ts +2 -2
  164. package/dom/getCurrentPageUid.js +8 -8
  165. package/dom/getCurrentPageUid.js.map +1 -1
  166. package/dom/getDomRefs.d.ts +2 -2
  167. package/dom/getDomRefs.js +12 -12
  168. package/dom/getDomRefs.js.map +1 -1
  169. package/dom/getDropUidOffset.d.ts +5 -5
  170. package/dom/getDropUidOffset.js +27 -27
  171. package/dom/getDropUidOffset.js.map +1 -1
  172. package/dom/getMutatedNodes.d.ts +7 -7
  173. package/dom/getMutatedNodes.js +11 -11
  174. package/dom/getMutatedNodes.js.map +1 -1
  175. package/dom/getPageTitleByHtmlElement.d.ts +2 -2
  176. package/dom/getPageTitleByHtmlElement.js +12 -12
  177. package/dom/getPageTitleByHtmlElement.js.map +1 -1
  178. package/dom/getPageTitleValueByHtmlElement.d.ts +2 -2
  179. package/dom/getPageTitleValueByHtmlElement.js +9 -9
  180. package/dom/getPageTitleValueByHtmlElement.js.map +1 -1
  181. package/dom/getReferenceBlockUid.d.ts +2 -2
  182. package/dom/getReferenceBlockUid.js +18 -18
  183. package/dom/getReferenceBlockUid.js.map +1 -1
  184. package/dom/getRoamUrl.d.ts +2 -2
  185. package/dom/getRoamUrl.js +4 -4
  186. package/dom/getRoamUrl.js.map +1 -1
  187. package/dom/getRoamUrlByPage.d.ts +2 -2
  188. package/dom/getRoamUrlByPage.js +10 -10
  189. package/dom/getRoamUrlByPage.js.map +1 -1
  190. package/dom/getUids.d.ts +3 -3
  191. package/dom/getUids.js +8 -8
  192. package/dom/getUids.js.map +1 -1
  193. package/dom/getUidsFromButton.d.ts +3 -3
  194. package/dom/getUidsFromButton.js +8 -8
  195. package/dom/getUidsFromButton.js.map +1 -1
  196. package/dom/getUidsFromId.d.ts +5 -5
  197. package/dom/getUidsFromId.js +15 -15
  198. package/dom/getUidsFromId.js.map +1 -1
  199. package/dom/index.d.ts +30 -30
  200. package/dom/index.js +63 -63
  201. package/dom/index.js.map +1 -1
  202. package/dom/parseRoamBlocksToHtml.d.ts +11 -11
  203. package/dom/parseRoamBlocksToHtml.js +79 -79
  204. package/dom/parseRoamBlocksToHtml.js.map +1 -1
  205. package/dom/resolveRefs.d.ts +2 -2
  206. package/dom/resolveRefs.js +24 -24
  207. package/dom/resolveRefs.js.map +1 -1
  208. package/events/index.d.ts +1 -1
  209. package/events/index.js +8 -8
  210. package/events/index.js.map +1 -1
  211. package/events/watchOnce.d.ts +3 -3
  212. package/events/watchOnce.js +12 -12
  213. package/events/watchOnce.js.map +1 -1
  214. package/hooks/index.d.ts +2 -2
  215. package/hooks/index.js +10 -10
  216. package/hooks/index.js.map +1 -1
  217. package/hooks/useArrowKeyDown.d.ts +10 -10
  218. package/hooks/useArrowKeyDown.js +54 -54
  219. package/hooks/useArrowKeyDown.js.map +1 -1
  220. package/hooks/useSubTree.d.ts +3 -3
  221. package/hooks/useSubTree.js +11 -11
  222. package/hooks/useSubTree.js.map +1 -1
  223. package/marked/index.d.ts +25 -25
  224. package/marked/index.js +567 -567
  225. package/marked/index.js.map +1 -1
  226. package/package.json +116 -125
  227. package/queries/compileDatalog.d.ts +3 -3
  228. package/queries/compileDatalog.js +63 -63
  229. package/queries/compileDatalog.js.map +1 -1
  230. package/queries/getAllBlockUids.d.ts +2 -2
  231. package/queries/getAllBlockUids.js +6 -6
  232. package/queries/getAllBlockUids.js.map +1 -1
  233. package/queries/getAllBlockUidsAndTexts.d.ts +5 -5
  234. package/queries/getAllBlockUidsAndTexts.js +6 -6
  235. package/queries/getAllBlockUidsAndTexts.js.map +1 -1
  236. package/queries/getAllPageNames.d.ts +2 -2
  237. package/queries/getAllPageNames.js +6 -6
  238. package/queries/getAllPageNames.js.map +1 -1
  239. package/queries/getAttributeValueByBlockAndName.d.ts +5 -5
  240. package/queries/getAttributeValueByBlockAndName.js +11 -11
  241. package/queries/getAttributeValueByBlockAndName.js.map +1 -1
  242. package/queries/getBasicTreeByParentUid.d.ts +3 -3
  243. package/queries/getBasicTreeByParentUid.js +13 -13
  244. package/queries/getBasicTreeByParentUid.js.map +1 -1
  245. package/queries/getBlockUidAndTextIncludingText.d.ts +5 -5
  246. package/queries/getBlockUidAndTextIncludingText.js +7 -7
  247. package/queries/getBlockUidAndTextIncludingText.js.map +1 -1
  248. package/queries/getBlockUidByTextOnPage.d.ts +5 -5
  249. package/queries/getBlockUidByTextOnPage.js +7 -7
  250. package/queries/getBlockUidByTextOnPage.js.map +1 -1
  251. package/queries/getBlockUidsAndTextsReferencingPage.d.ts +5 -5
  252. package/queries/getBlockUidsAndTextsReferencingPage.js +9 -9
  253. package/queries/getBlockUidsAndTextsReferencingPage.js.map +1 -1
  254. package/queries/getBlockUidsByPageTitle.d.ts +2 -2
  255. package/queries/getBlockUidsByPageTitle.js +8 -8
  256. package/queries/getBlockUidsByPageTitle.js.map +1 -1
  257. package/queries/getBlockUidsReferencingBlock.d.ts +2 -2
  258. package/queries/getBlockUidsReferencingBlock.js +4 -4
  259. package/queries/getBlockUidsReferencingBlock.js.map +1 -1
  260. package/queries/getBlockUidsReferencingPage.d.ts +2 -2
  261. package/queries/getBlockUidsReferencingPage.js +6 -6
  262. package/queries/getBlockUidsReferencingPage.js.map +1 -1
  263. package/queries/getBlockUidsWithParentUid.d.ts +2 -2
  264. package/queries/getBlockUidsWithParentUid.js +6 -6
  265. package/queries/getBlockUidsWithParentUid.js.map +1 -1
  266. package/queries/getChildrenLengthByPageUid.d.ts +2 -2
  267. package/queries/getChildrenLengthByPageUid.js +8 -8
  268. package/queries/getChildrenLengthByPageUid.js.map +1 -1
  269. package/queries/getChildrenLengthByParentUid.d.ts +2 -2
  270. package/queries/getChildrenLengthByParentUid.js +7 -7
  271. package/queries/getChildrenLengthByParentUid.js.map +1 -1
  272. package/queries/getCreateTimeByBlockUid.d.ts +2 -2
  273. package/queries/getCreateTimeByBlockUid.js +7 -7
  274. package/queries/getCreateTimeByBlockUid.js.map +1 -1
  275. package/queries/getCurrentUser.d.ts +2 -2
  276. package/queries/getCurrentUser.js +11 -11
  277. package/queries/getCurrentUser.js.map +1 -1
  278. package/queries/getCurrentUserDisplayName.d.ts +2 -2
  279. package/queries/getCurrentUserDisplayName.js +10 -10
  280. package/queries/getCurrentUserDisplayName.js.map +1 -1
  281. package/queries/getCurrentUserEmail.d.ts +2 -2
  282. package/queries/getCurrentUserEmail.js +13 -13
  283. package/queries/getCurrentUserEmail.js.map +1 -1
  284. package/queries/getCurrentUserUid.d.ts +2 -2
  285. package/queries/getCurrentUserUid.js +13 -13
  286. package/queries/getCurrentUserUid.js.map +1 -1
  287. package/queries/getDisplayNameByEmail.d.ts +2 -2
  288. package/queries/getDisplayNameByEmail.js +7 -7
  289. package/queries/getDisplayNameByEmail.js.map +1 -1
  290. package/queries/getDisplayNameByUid.d.ts +2 -2
  291. package/queries/getDisplayNameByUid.js +7 -7
  292. package/queries/getDisplayNameByUid.js.map +1 -1
  293. package/queries/getEditTimeByBlockUid.d.ts +2 -2
  294. package/queries/getEditTimeByBlockUid.js +7 -7
  295. package/queries/getEditTimeByBlockUid.js.map +1 -1
  296. package/queries/getEditedUserEmailByBlockUid.d.ts +2 -2
  297. package/queries/getEditedUserEmailByBlockUid.js +7 -7
  298. package/queries/getEditedUserEmailByBlockUid.js.map +1 -1
  299. package/queries/getFirstChildTextByBlockUid.d.ts +2 -2
  300. package/queries/getFirstChildTextByBlockUid.js +7 -7
  301. package/queries/getFirstChildTextByBlockUid.js.map +1 -1
  302. package/queries/getFirstChildUidByBlockUid.d.ts +2 -2
  303. package/queries/getFirstChildUidByBlockUid.js +6 -6
  304. package/queries/getFirstChildUidByBlockUid.js.map +1 -1
  305. package/queries/getFullTreeByParentUid.d.ts +3 -3
  306. package/queries/getFullTreeByParentUid.js +51 -51
  307. package/queries/getFullTreeByParentUid.js.map +1 -1
  308. package/queries/getLinkedPageTitlesUnderUid.d.ts +2 -2
  309. package/queries/getLinkedPageTitlesUnderUid.js +6 -6
  310. package/queries/getLinkedPageTitlesUnderUid.js.map +1 -1
  311. package/queries/getNthChildUidByBlockUid.d.ts +5 -5
  312. package/queries/getNthChildUidByBlockUid.js +7 -7
  313. package/queries/getNthChildUidByBlockUid.js.map +1 -1
  314. package/queries/getOrderByBlockUid.d.ts +2 -2
  315. package/queries/getOrderByBlockUid.js +7 -7
  316. package/queries/getOrderByBlockUid.js.map +1 -1
  317. package/queries/getPageTitleByBlockUid.d.ts +2 -2
  318. package/queries/getPageTitleByBlockUid.js +7 -7
  319. package/queries/getPageTitleByBlockUid.js.map +1 -1
  320. package/queries/getPageTitleByPageUid.d.ts +2 -2
  321. package/queries/getPageTitleByPageUid.js +12 -12
  322. package/queries/getPageTitleByPageUid.js.map +1 -1
  323. package/queries/getPageTitleReferencesByPageTitle.d.ts +2 -2
  324. package/queries/getPageTitleReferencesByPageTitle.js +6 -6
  325. package/queries/getPageTitleReferencesByPageTitle.js.map +1 -1
  326. package/queries/getPageTitlesAndBlockUidsReferencingPage.d.ts +5 -5
  327. package/queries/getPageTitlesAndBlockUidsReferencingPage.js +9 -9
  328. package/queries/getPageTitlesAndBlockUidsReferencingPage.js.map +1 -1
  329. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.d.ts +5 -5
  330. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js +9 -9
  331. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js.map +1 -1
  332. package/queries/getPageTitlesReferencingBlockUid.d.ts +2 -2
  333. package/queries/getPageTitlesReferencingBlockUid.js +4 -4
  334. package/queries/getPageTitlesReferencingBlockUid.js.map +1 -1
  335. package/queries/getPageTitlesStartingWithPrefix.d.ts +2 -2
  336. package/queries/getPageTitlesStartingWithPrefix.js +6 -6
  337. package/queries/getPageTitlesStartingWithPrefix.js.map +1 -1
  338. package/queries/getPageUidByBlockUid.d.ts +2 -2
  339. package/queries/getPageUidByBlockUid.js +7 -7
  340. package/queries/getPageUidByBlockUid.js.map +1 -1
  341. package/queries/getPageUidByPageTitle.d.ts +2 -2
  342. package/queries/getPageUidByPageTitle.js +9 -9
  343. package/queries/getPageUidByPageTitle.js.map +1 -1
  344. package/queries/getPageViewType.d.ts +3 -3
  345. package/queries/getPageViewType.js +9 -9
  346. package/queries/getPageViewType.js.map +1 -1
  347. package/queries/getParentTextByBlockUid.d.ts +2 -2
  348. package/queries/getParentTextByBlockUid.js +7 -7
  349. package/queries/getParentTextByBlockUid.js.map +1 -1
  350. package/queries/getParentTextByBlockUidAndTag.d.ts +5 -5
  351. package/queries/getParentTextByBlockUidAndTag.js +7 -7
  352. package/queries/getParentTextByBlockUidAndTag.js.map +1 -1
  353. package/queries/getParentUidByBlockUid.d.ts +2 -2
  354. package/queries/getParentUidByBlockUid.js +7 -7
  355. package/queries/getParentUidByBlockUid.js.map +1 -1
  356. package/queries/getParentUidsOfBlockUid.d.ts +2 -2
  357. package/queries/getParentUidsOfBlockUid.js +4 -4
  358. package/queries/getParentUidsOfBlockUid.js.map +1 -1
  359. package/queries/getSettingsByEmail.d.ts +3 -3
  360. package/queries/getSettingsByEmail.js +7 -7
  361. package/queries/getSettingsByEmail.js.map +1 -1
  362. package/queries/getShallowTreeByParentUid.d.ts +5 -5
  363. package/queries/getShallowTreeByParentUid.js +9 -9
  364. package/queries/getShallowTreeByParentUid.js.map +1 -1
  365. package/queries/getTextByBlockUid.d.ts +2 -2
  366. package/queries/getTextByBlockUid.js +9 -9
  367. package/queries/getTextByBlockUid.js.map +1 -1
  368. package/queries/index.js +4 -4
  369. package/queries/index.js.map +1 -1
  370. package/queries/isLiveBlock.d.ts +2 -2
  371. package/queries/isLiveBlock.js +4 -4
  372. package/queries/isLiveBlock.js.map +1 -1
  373. package/queries/isTagOnPage.d.ts +5 -5
  374. package/queries/isTagOnPage.js +9 -9
  375. package/queries/isTagOnPage.js.map +1 -1
  376. package/queries/normalizePageTitle.d.ts +2 -2
  377. package/queries/normalizePageTitle.js +4 -4
  378. package/queries/normalizePageTitle.js.map +1 -1
  379. package/scripts/index.d.ts +1 -1
  380. package/scripts/index.js +26 -26
  381. package/scripts/index.js.map +1 -1
  382. package/scripts/publishToRoamDepot.d.ts +7 -7
  383. package/scripts/publishToRoamDepot.js +113 -113
  384. package/scripts/publishToRoamDepot.js.map +1 -1
  385. package/testing/mockRoamEnvironment.d.ts +2 -2
  386. package/testing/mockRoamEnvironment.js +1253 -1253
  387. package/testing/mockRoamEnvironment.js.map +1 -1
  388. package/types/index.d.ts +393 -250
  389. package/types/index.js +4 -4
  390. package/types/index.js.map +1 -1
  391. package/types/native.d.ts +405 -402
  392. package/types/native.js +4 -4
  393. package/types/native.js.map +1 -1
  394. package/types/query-builder.d.ts +10 -10
  395. package/types/query-builder.js +2 -2
  396. package/types/query-builder.js.map +1 -1
  397. package/types/smartblocks.d.ts +35 -35
  398. package/types/smartblocks.js +2 -2
  399. package/types/smartblocks.js.map +1 -1
  400. package/util/addInputSetting.d.ts +7 -7
  401. package/util/addInputSetting.js +25 -25
  402. package/util/addInputSetting.js.map +1 -1
  403. package/util/apiDelete.d.ts +2 -2
  404. package/util/apiDelete.js +6 -6
  405. package/util/apiDelete.js.map +1 -1
  406. package/util/apiGet.d.ts +2 -2
  407. package/util/apiGet.js +6 -6
  408. package/util/apiGet.js.map +1 -1
  409. package/util/apiPost.d.ts +2 -2
  410. package/util/apiPost.js +6 -6
  411. package/util/apiPost.js.map +1 -1
  412. package/util/apiPut.d.ts +2 -2
  413. package/util/apiPut.js +6 -6
  414. package/util/apiPut.js.map +1 -1
  415. package/util/createOverlayRender.d.ts +4 -4
  416. package/util/createOverlayRender.js +6 -6
  417. package/util/createOverlayRender.js.map +1 -1
  418. package/util/createTagRegex.d.ts +2 -2
  419. package/util/createTagRegex.js +7 -7
  420. package/util/createTagRegex.js.map +1 -1
  421. package/util/dispatchToRegistry.d.ts +3 -3
  422. package/util/dispatchToRegistry.js +7 -7
  423. package/util/dispatchToRegistry.js.map +1 -1
  424. package/util/env.d.ts +4 -4
  425. package/util/env.js +47 -47
  426. package/util/env.js.map +1 -1
  427. package/util/extensionApiContext.d.ts +29 -29
  428. package/util/extensionApiContext.js +17 -17
  429. package/util/extensionApiContext.js.map +1 -1
  430. package/util/extensionDeprecatedWarning.d.ts +5 -5
  431. package/util/extensionDeprecatedWarning.js +39 -39
  432. package/util/extensionDeprecatedWarning.js.map +1 -1
  433. package/util/extractRef.d.ts +2 -2
  434. package/util/extractRef.js +8 -8
  435. package/util/extractRef.js.map +1 -1
  436. package/util/extractTag.d.ts +2 -2
  437. package/util/extractTag.js +15 -15
  438. package/util/extractTag.js.map +1 -1
  439. package/util/focusMainWindowBlock.d.ts +2 -2
  440. package/util/focusMainWindowBlock.js +12 -12
  441. package/util/focusMainWindowBlock.js.map +1 -1
  442. package/util/getAuthorizationHeader.d.ts +2 -2
  443. package/util/getAuthorizationHeader.js +12 -12
  444. package/util/getAuthorizationHeader.js.map +1 -1
  445. package/util/getLocalStorageKey.d.ts +2 -2
  446. package/util/getLocalStorageKey.js +4 -4
  447. package/util/getLocalStorageKey.js.map +1 -1
  448. package/util/getOauth.d.ts +2 -2
  449. package/util/getOauth.js +52 -52
  450. package/util/getOauth.js.map +1 -1
  451. package/util/getOauthAccounts.d.ts +2 -2
  452. package/util/getOauthAccounts.js +22 -22
  453. package/util/getOauthAccounts.js.map +1 -1
  454. package/util/getRenderRoot.d.ts +2 -2
  455. package/util/getRenderRoot.js +18 -18
  456. package/util/getRenderRoot.js.map +1 -1
  457. package/util/getSettingIntFromTree.d.ts +7 -7
  458. package/util/getSettingIntFromTree.js +11 -11
  459. package/util/getSettingIntFromTree.js.map +1 -1
  460. package/util/getSettingValueFromTree.d.ts +8 -8
  461. package/util/getSettingValueFromTree.js +14 -14
  462. package/util/getSettingValueFromTree.js.map +1 -1
  463. package/util/getSettingValuesFromTree.d.ts +7 -7
  464. package/util/getSettingValuesFromTree.js +12 -12
  465. package/util/getSettingValuesFromTree.js.map +1 -1
  466. package/util/getSubTree.d.ts +8 -8
  467. package/util/getSubTree.js +19 -19
  468. package/util/getSubTree.js.map +1 -1
  469. package/util/getToken.d.ts +2 -2
  470. package/util/getToken.js +10 -10
  471. package/util/getToken.js.map +1 -1
  472. package/util/getTokenFromTree.d.ts +3 -3
  473. package/util/getTokenFromTree.js +4 -4
  474. package/util/getTokenFromTree.js.map +1 -1
  475. package/util/getWorkerClient.d.ts +12 -12
  476. package/util/getWorkerClient.js +41 -41
  477. package/util/getWorkerClient.js.map +1 -1
  478. package/util/handleBodyFetch.d.ts +3 -3
  479. package/util/handleBodyFetch.js +21 -21
  480. package/util/handleBodyFetch.js.map +1 -1
  481. package/util/handleFetch.d.ts +13 -13
  482. package/util/handleFetch.js +40 -40
  483. package/util/handleFetch.js.map +1 -1
  484. package/util/handleUrlFetch.d.ts +3 -3
  485. package/util/handleUrlFetch.js +19 -19
  486. package/util/handleUrlFetch.js.map +1 -1
  487. package/util/idToTitle.d.ts +2 -2
  488. package/util/idToTitle.js +8 -8
  489. package/util/idToTitle.js.map +1 -1
  490. package/util/index.d.ts +24 -24
  491. package/util/index.js +54 -54
  492. package/util/index.js.map +1 -1
  493. package/util/isControl.d.ts +2 -2
  494. package/util/isControl.js +4 -4
  495. package/util/isControl.js.map +1 -1
  496. package/util/localStorageGet.d.ts +2 -2
  497. package/util/localStorageGet.js +8 -8
  498. package/util/localStorageGet.js.map +1 -1
  499. package/util/localStorageRemove.d.ts +2 -2
  500. package/util/localStorageRemove.js +6 -6
  501. package/util/localStorageRemove.js.map +1 -1
  502. package/util/localStorageSet.d.ts +2 -2
  503. package/util/localStorageSet.js +8 -8
  504. package/util/localStorageSet.js.map +1 -1
  505. package/util/registerExperimentalMode.d.ts +6 -6
  506. package/util/registerExperimentalMode.js +65 -65
  507. package/util/registerExperimentalMode.js.map +1 -1
  508. package/util/registerSmartBlocksCommand.d.ts +3 -3
  509. package/util/registerSmartBlocksCommand.js +23 -23
  510. package/util/registerSmartBlocksCommand.js.map +1 -1
  511. package/util/removeFromRegistry.d.ts +3 -3
  512. package/util/removeFromRegistry.js +7 -7
  513. package/util/removeFromRegistry.js.map +1 -1
  514. package/util/renderOverlay.d.ts +12 -12
  515. package/util/renderOverlay.js +48 -48
  516. package/util/renderOverlay.js.map +1 -1
  517. package/util/renderWithUnmount.d.ts +4 -4
  518. package/util/renderWithUnmount.js +44 -44
  519. package/util/renderWithUnmount.js.map +1 -1
  520. package/util/runExtension.d.ts +11 -11
  521. package/util/runExtension.js +174 -174
  522. package/util/runExtension.js.map +1 -1
  523. package/util/setInputSetting.d.ts +7 -7
  524. package/util/setInputSetting.js +37 -37
  525. package/util/setInputSetting.js.map +1 -1
  526. package/util/setInputSettings.d.ts +7 -7
  527. package/util/setInputSettings.js +28 -28
  528. package/util/setInputSettings.js.map +1 -1
  529. package/util/stripUid.d.ts +3 -3
  530. package/util/stripUid.js +10 -10
  531. package/util/stripUid.js.map +1 -1
  532. package/util/toConfigPageName.d.ts +2 -2
  533. package/util/toConfigPageName.js +4 -4
  534. package/util/toConfigPageName.js.map +1 -1
  535. package/util/toFlexRegex.d.ts +2 -2
  536. package/util/toFlexRegex.js +4 -4
  537. package/util/toFlexRegex.js.map +1 -1
  538. package/writes/clearBlockById.d.ts +2 -2
  539. package/writes/clearBlockById.js +17 -17
  540. package/writes/clearBlockById.js.map +1 -1
  541. package/writes/clearBlockByUid.d.ts +2 -2
  542. package/writes/clearBlockByUid.js +16 -16
  543. package/writes/clearBlockByUid.js.map +1 -1
  544. package/writes/createBlock.d.ts +8 -8
  545. package/writes/createBlock.js +28 -28
  546. package/writes/createBlock.js.map +1 -1
  547. package/writes/createPage.d.ts +7 -7
  548. package/writes/createPage.js +20 -20
  549. package/writes/createPage.js.map +1 -1
  550. package/writes/deleteBlock.d.ts +2 -2
  551. package/writes/deleteBlock.js +10 -10
  552. package/writes/deleteBlock.js.map +1 -1
  553. package/writes/index.d.ts +8 -8
  554. package/writes/index.js +22 -22
  555. package/writes/index.js.map +1 -1
  556. package/writes/openBlockInSidebar.d.ts +2 -2
  557. package/writes/openBlockInSidebar.js +13 -13
  558. package/writes/openBlockInSidebar.js.map +1 -1
  559. package/writes/submitActions.d.ts +8 -8
  560. package/writes/submitActions.js +36 -36
  561. package/writes/submitActions.js.map +1 -1
  562. package/writes/updateActiveBlock.d.ts +2 -2
  563. package/writes/updateActiveBlock.js +17 -17
  564. package/writes/updateActiveBlock.js.map +1 -1
  565. package/writes/updateBlock.d.ts +5 -5
  566. package/writes/updateBlock.js +23 -23
  567. package/writes/updateBlock.js.map +1 -1
package/marked/index.js CHANGED
@@ -1,568 +1,568 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parse = exports.parseInline = exports.lexer = exports.inlineLexer = exports.getParse = exports.getParseInline = exports.getLexer = exports.getInlineLexer = void 0;
4
- const tslib_1 = require("tslib");
5
- const xregexp_1 = tslib_1.__importDefault(require("xregexp"));
6
- const refractor_1 = tslib_1.__importDefault(require("refractor"));
7
- const markdown_1 = tslib_1.__importDefault(require("refractor/lang/markdown"));
8
- const yaml_1 = tslib_1.__importDefault(require("refractor/lang/yaml"));
9
- const css_1 = tslib_1.__importDefault(require("refractor/lang/css"));
10
- const bash_1 = tslib_1.__importDefault(require("refractor/lang/bash"));
11
- const java_1 = tslib_1.__importDefault(require("refractor/lang/java"));
12
- const rust_1 = tslib_1.__importDefault(require("refractor/lang/rust"));
13
- const python_1 = tslib_1.__importDefault(require("refractor/lang/python"));
14
- const csharp_1 = tslib_1.__importDefault(require("refractor/lang/csharp"));
15
- const clojure_1 = tslib_1.__importDefault(require("refractor/lang/clojure"));
16
- const hcl_1 = tslib_1.__importDefault(require("refractor/lang/hcl"));
17
- const hast_util_to_html_1 = tslib_1.__importDefault(require("hast-util-to-html"));
18
- refractor_1.default.register(markdown_1.default);
19
- refractor_1.default.register(yaml_1.default);
20
- refractor_1.default.register(css_1.default);
21
- refractor_1.default.register(bash_1.default);
22
- refractor_1.default.register(java_1.default);
23
- refractor_1.default.register(rust_1.default);
24
- refractor_1.default.register(python_1.default);
25
- refractor_1.default.register(csharp_1.default);
26
- refractor_1.default.register(clojure_1.default);
27
- refractor_1.default.register(hcl_1.default);
28
- const RENDERED_TODO = '<span><label class="check-container"><input type="checkbox" disabled=""><span class="checkmark"></span></label></span>';
29
- const RENDERED_DONE = '<span><label class="check-container"><input type="checkbox" checked="" disabled=""><span class="checkmark"></span></label></span>';
30
- const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=$]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=$,]*)/;
31
- const TODO_REGEX = /^{{(?:\[\[)?TODO(?:\]\])?}}/;
32
- const DONE_REGEX = /^{{(?:\[\[)?DONE(?:\]\])?}}/;
33
- const IFRAME_REGEX = new RegExp(`^{{(?:\\[\\[)?iframe(?:\\]\\])?:\\s*(${URL_REGEX.source})}}`);
34
- const BUTTON_REGEX = /^{{(?:\[\[)?((?:(?!}}[^}])[\w\s-/])*)(?:\]\])?(?::(.*))?}}/;
35
- const TAG_REGEX = /^#?\[\[(.*?)\]\]/;
36
- const BLOCK_REF_REGEX = /^\(\((.*?)\)\)/;
37
- const toAlias = (r) => new RegExp(`^\\[([^\\]]*?)\\]\\(${r.source.substring(1)}\\)`);
38
- const ALIAS_REGEX = toAlias(TAG_REGEX);
39
- const ALIAS_REF_REGEX = toAlias(BLOCK_REF_REGEX);
40
- const HASHTAG_REGEX = /^#([^\s]*)/;
41
- const ATTRIBUTE_REGEX = /^(.*?)::/;
42
- const BOLD_REGEX = /^\*\*(.*?)\*\*/;
43
- const ITALICS_REGEX = /^__(.*?)__/;
44
- const HIGHLIGHT_REGEX = /^\^\^([^^]*)\^\^/;
45
- const INLINE_STOP_REGEX = /({{|\*\*([^*]+?)\*\*|__([^_]+?)__|~~([^_]+?)~~|\^\^([^^]+?)\^\^|#?\[\[(.*?)\]\]|#[^\s]|\(\(.*?\)\)|\[(.*?)\]\((.*?)\))/;
46
- const HR_REGEX = /^---$/;
47
- const BQ_REGEX = /^(?:>|\[\[>\]\]) (.*)$/s;
48
- const TWEET_STATUS_REGEX = /\/status\/(.*?)(?:\?s=\d*)?$/;
49
- const HTML_REGEXES = [BUTTON_REGEX, BLOCK_REF_REGEX, HR_REGEX];
50
- const HTML_WITH_CHILD_REGEXES = [
51
- { rgx: BQ_REGEX, title: "blockquote" },
52
- { rgx: HIGHLIGHT_REGEX, title: "highlight" },
53
- ];
54
- const CODESPAN_REGEX = new RegExp("^```([\\w]*)\n(.*)```$", "s");
55
- const defaultComponents = (component, afterColon) => {
56
- var _a;
57
- const opts = ((_a = afterColon === null || afterColon === void 0 ? void 0 : afterColon.trim) === null || _a === void 0 ? void 0 : _a.call(afterColon)) || "";
58
- switch (component) {
59
- case "youtube":
60
- case "video":
61
- return `<div class="rm-iframe-container"><iframe src="${opts
62
- .replace("youtu.be", "www.youtube.com/embed")
63
- .replace("watch?v=", "embed/")
64
- .replace("vimeo.com", "player.vimeo.com/video")}" class="rm-iframe rm-video-player"></iframe></div>`;
65
- case "pdf":
66
- return `<div class="rm-iframe-container"><iframe src="${opts}" class="rm-iframe"></iframe></div>`;
67
- default:
68
- return "";
69
- }
70
- };
71
- // https://github.com/markedjs/marked/blob/d2347e9b9ae517d02138fa6a9844bd8d586acfeb/src/Tokenizer.js#L33-L59
72
- function indentCodeCompensation(raw, text) {
73
- const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
74
- if (matchIndentToCode === null) {
75
- return text;
76
- }
77
- const indentToCode = matchIndentToCode[1];
78
- return text
79
- .split("\n")
80
- .map((node) => {
81
- const matchIndentInNode = node.match(/^\s+/);
82
- if (matchIndentInNode === null) {
83
- return node;
84
- }
85
- const [indentInNode] = matchIndentInNode;
86
- if (indentInNode.length >= indentToCode.length) {
87
- return node.slice(indentToCode.length);
88
- }
89
- return node;
90
- })
91
- .join("\n");
92
- }
93
- const context = {
94
- marked: {
95
- parseInline: (s) => s,
96
- lastSrc: "",
97
- used: false,
98
- lexInline: () => [],
99
- },
100
- };
101
- const opts = {
102
- tokenizer: {
103
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
104
- // @ts-ignore should accept boolean return value
105
- tag(src) {
106
- for (const r of HTML_REGEXES) {
107
- const match = r.exec(src);
108
- if (match) {
109
- return {
110
- type: "html",
111
- raw: match[0],
112
- text: match[0],
113
- };
114
- }
115
- }
116
- return false;
117
- },
118
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
119
- // @ts-ignore should accept boolean return value
120
- del(src) {
121
- const match = /^~[^~]/.exec(src);
122
- if (match) {
123
- return {
124
- type: "text",
125
- raw: "~",
126
- text: "~",
127
- };
128
- }
129
- return false;
130
- },
131
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
132
- // @ts-ignore should accept boolean return value
133
- emStrong(src) {
134
- var _a, _b;
135
- const match = BOLD_REGEX.exec(src);
136
- if (match && ((_a = match[1]) === null || _a === void 0 ? void 0 : _a.length)) {
137
- return {
138
- type: "strong",
139
- raw: match[0],
140
- text: match[1],
141
- tokens: context.marked.lexInline(match[1]),
142
- };
143
- }
144
- const emMatch = ITALICS_REGEX.exec(src);
145
- if (emMatch && ((_b = emMatch[1]) === null || _b === void 0 ? void 0 : _b.length)) {
146
- return {
147
- type: "em",
148
- raw: emMatch[0],
149
- text: emMatch[1],
150
- tokens: context.marked.lexInline(emMatch[1]),
151
- };
152
- }
153
- return false;
154
- },
155
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
156
- // @ts-ignore should accept boolean return value
157
- fences(src) {
158
- const newSrc = src.replace(/```$/, "\n```");
159
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
160
- // @ts-ignore should accept boolean return value
161
- const rules = this.rules;
162
- const cap = rules.block.fences.exec(newSrc);
163
- if (cap) {
164
- const raw = cap[0];
165
- const text = indentCodeCompensation(raw, cap[3] || "");
166
- return {
167
- type: "code",
168
- raw,
169
- lang: cap[2] ? cap[2].trim() : cap[2],
170
- text,
171
- };
172
- }
173
- return false;
174
- },
175
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
176
- // @ts-ignore should accept boolean return value
177
- inlineText(src) {
178
- var _a, _b;
179
- if (src === context.marked.lastSrc) {
180
- throw new Error(`Infinite loop on string ${src}`);
181
- }
182
- context.marked.lastSrc = src;
183
- const attribute = ATTRIBUTE_REGEX.exec(src);
184
- if (attribute) {
185
- const raw = attribute[0];
186
- const numberOfTicks = (raw.match(/([^`]`|`[^`])/g) || []).length;
187
- if (numberOfTicks % 2 === 0) {
188
- const page = attribute[1];
189
- const href = (_a = context.pagesToHrefs) === null || _a === void 0 ? void 0 : _a.call(context, page);
190
- const text = `${page}:`;
191
- if (href) {
192
- return {
193
- type: "strong",
194
- raw,
195
- text,
196
- tokens: [
197
- {
198
- type: "link",
199
- raw: text,
200
- text,
201
- href,
202
- tokens: [
203
- {
204
- type: "text",
205
- raw: text,
206
- text,
207
- },
208
- ],
209
- },
210
- ],
211
- };
212
- }
213
- else {
214
- return {
215
- type: "strong",
216
- raw,
217
- text,
218
- tokens: [
219
- {
220
- type: "text",
221
- raw: text,
222
- text,
223
- },
224
- ],
225
- };
226
- }
227
- }
228
- }
229
- const match = INLINE_STOP_REGEX.exec(src);
230
- if (match) {
231
- const raw = src.substring(0, match.index);
232
- const tickMatch = raw.match(/([^`]`|`[^`])/g);
233
- const numberOfTicks = (tickMatch || []).length;
234
- if (numberOfTicks % 2 === 0) {
235
- const index = numberOfTicks > 0 ? (_b = /`/.exec(raw)) === null || _b === void 0 ? void 0 : _b.index : match.index;
236
- return {
237
- type: "text",
238
- raw: src.substring(0, index),
239
- text: src.substring(0, index),
240
- };
241
- }
242
- }
243
- return false;
244
- },
245
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
246
- // @ts-ignore should accept boolean return value
247
- codespan(src) {
248
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
249
- // @ts-ignore should accept boolean return value
250
- const cap = this.rules.inline.code.exec(src);
251
- if (cap) {
252
- if (cap[0].startsWith("```")) {
253
- return {
254
- type: "codespan",
255
- raw: cap[0],
256
- text: cap[0],
257
- };
258
- }
259
- }
260
- return false;
261
- },
262
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
263
- // @ts-ignore should accept boolean return value
264
- link(src) {
265
- var _a, _b, _c;
266
- // hijacking link for html elements with tokens
267
- for (const { rgx, title } of HTML_WITH_CHILD_REGEXES) {
268
- const match = rgx.exec(src);
269
- if (match) {
270
- return {
271
- type: "link",
272
- raw: match[0],
273
- text: match[1],
274
- title,
275
- tokens: context.marked.lexInline(match[1]),
276
- };
277
- }
278
- }
279
- if (TAG_REGEX.test(src)) {
280
- const match = xregexp_1.default.matchRecursive(src, "#?\\[\\[", "\\]\\]", "i", {
281
- valueNames: ["between", "left", "match", "right"],
282
- });
283
- const raw = match.map((m) => m.value).join("");
284
- if (context.pagesToHrefs) {
285
- const text = match[1].value;
286
- const href = context.pagesToHrefs(text);
287
- if (href) {
288
- return {
289
- type: "link",
290
- raw,
291
- href,
292
- text,
293
- title: `tag:${text}`,
294
- tokens: context.marked.lexInline(text),
295
- };
296
- }
297
- else {
298
- return {
299
- type: "text",
300
- raw,
301
- text,
302
- };
303
- }
304
- }
305
- else {
306
- return {
307
- type: "text",
308
- raw,
309
- text: raw,
310
- };
311
- }
312
- }
313
- const hashMatch = HASHTAG_REGEX.exec(src);
314
- if (hashMatch) {
315
- const raw = hashMatch[0];
316
- if (context.pagesToHrefs) {
317
- const text = hashMatch[1];
318
- const href = context.pagesToHrefs(text);
319
- if (href) {
320
- return {
321
- type: "link",
322
- raw,
323
- href,
324
- text,
325
- title: `tag:${text}`,
326
- tokens: context.marked.lexInline(text),
327
- };
328
- }
329
- else {
330
- return {
331
- type: "text",
332
- raw,
333
- text,
334
- };
335
- }
336
- }
337
- else {
338
- return {
339
- type: "text",
340
- raw,
341
- text: raw,
342
- };
343
- }
344
- }
345
- const aliasMatch = ALIAS_REGEX.exec(src);
346
- if (aliasMatch) {
347
- const raw = aliasMatch[0];
348
- if (context.pagesToHrefs) {
349
- const text = aliasMatch[1];
350
- const href = context.pagesToHrefs(aliasMatch[2]);
351
- if (href) {
352
- return {
353
- type: "link",
354
- raw,
355
- href,
356
- text,
357
- title: "alias",
358
- tokens: context.marked.lexInline(text),
359
- };
360
- }
361
- else {
362
- return {
363
- type: "text",
364
- raw,
365
- text,
366
- };
367
- }
368
- }
369
- else {
370
- return {
371
- type: "text",
372
- raw,
373
- text: raw,
374
- };
375
- }
376
- }
377
- const aliasRefMatch = ALIAS_REF_REGEX.exec(src);
378
- if (aliasRefMatch) {
379
- const raw = aliasRefMatch[0];
380
- const text = aliasRefMatch[1];
381
- const ref = aliasRefMatch[2];
382
- const href = (_a = context.pagesToHrefs) === null || _a === void 0 ? void 0 : _a.call(context, ((_c = (_b = context.blockReferences) === null || _b === void 0 ? void 0 : _b.call(context, ref)) === null || _c === void 0 ? void 0 : _c.page) || "", ref);
383
- if (href) {
384
- return {
385
- type: "link",
386
- raw,
387
- href,
388
- text,
389
- title: "alias",
390
- tokens: context.marked.lexInline(text),
391
- };
392
- }
393
- else {
394
- return {
395
- type: "text",
396
- raw,
397
- text,
398
- };
399
- }
400
- }
401
- return false;
402
- },
403
- },
404
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
405
- // @ts-ignore should be optional
406
- renderer: {
407
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
408
- // @ts-ignore should allow false
409
- link(href, title, text) {
410
- var _a;
411
- if (title === "alias") {
412
- const html = this.link(href, null, text || "");
413
- if (html) {
414
- return html.replace("href=", 'class="rm-alias" href=');
415
- }
416
- }
417
- else if (title === null || title === void 0 ? void 0 : title.startsWith("tag:")) {
418
- const html = this.link(href, null, text || "");
419
- if (html) {
420
- return html.replace("href=", `class="rm-page-ref" data-tag="${title.substring(4)}" href=`);
421
- }
422
- }
423
- else if (title === "highlight") {
424
- return `<span class="rm-highlight">${text}</span>`;
425
- }
426
- else if (title === "blockquote") {
427
- return `<blockquote class="rm-bq">${text}</blockquote>`;
428
- }
429
- else if (href.startsWith("https://twitter.com") && text === href) {
430
- const tweetId = (_a = TWEET_STATUS_REGEX.exec(href)) === null || _a === void 0 ? void 0 : _a[1];
431
- const options = {
432
- dnt: false,
433
- frame: false,
434
- hideCard: false,
435
- hideThread: true,
436
- id: tweetId,
437
- lang: "en",
438
- theme: "light",
439
- width: "550px",
440
- };
441
- if (tweetId) {
442
- return `<div>
443
- <iframe scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="" style="position: static; visibility: visible; width: ${options.width}; height: ${options.width}; display: block; flex-grow: 1; pointer-events: auto;" title="Twitter Tweet" src="https://platform.twitter.com/embed/Tweet.html?${new URLSearchParams(Object.fromEntries(Object.entries(options).map(([k, v]) => [k, `${v}`])))
444
- .toString()
445
- .replace(/&/g, "&amp;")}" data-tweet-id="${tweetId}"></iframe>
446
- <script>const cs = document.currentScript;
447
- const iframe = cs.previousElementSibling;
448
- const tweetId = iframe.getAttribute('data-tweet-id');
449
- const renderTweet = () => {
450
- const container = cs.parentElement;
451
- container.style.height = '${options.width}';
452
- window['twttr'].ready().then(({widgets}) =>
453
- widgets.createTweetEmbed(tweetId, cs.parentElement, ${JSON.stringify(options)})).then(() => {
454
- iframe.remove();
455
- cs.remove();
456
- container.style.height = 'unset';
457
- });
458
- }
459
- const twttr = window['twttr']
460
- if (!(twttr && twttr.ready)) {
461
- var s = document.createElement('script');
462
- s.setAttribute('src', "https://platform.twitter.com/widgets.js");
463
- s.onload = renderTweet;
464
- document.body.appendChild(s);
465
- } else {
466
- renderTweet()
467
- }
468
- </script>
469
- </div>`;
470
- }
471
- }
472
- return false;
473
- },
474
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
475
- // @ts-ignore should allow false
476
- codespan(code) {
477
- const match = CODESPAN_REGEX.exec(code);
478
- if (match) {
479
- const nodes = refractor_1.default.highlight(match[2], match[1]);
480
- return `<pre><code class="language-${match[1]}">${(0, hast_util_to_html_1.default)(
481
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
482
- //@ts-ignore
483
- nodes)}</code></pre>`;
484
- }
485
- return false;
486
- },
487
- strong: (text) => `<span class="rm-bold">${text}</span>`,
488
- em: (text) => `<em class="rm-italics">${text}</em>`,
489
- html(text) {
490
- var _a, _b, _c, _d, _e, _f;
491
- if (TODO_REGEX.test(text)) {
492
- return RENDERED_TODO;
493
- }
494
- else if (DONE_REGEX.test(text)) {
495
- return RENDERED_DONE;
496
- }
497
- else if (HR_REGEX.test(text)) {
498
- return "<hr>";
499
- }
500
- else if (IFRAME_REGEX.test(text)) {
501
- const match = IFRAME_REGEX.exec(text);
502
- return `<div class="rm-iframe-container"><iframe src="${match === null || match === void 0 ? void 0 : match[1]}" frameborder="0" class="rm-iframe"></iframe></div>`;
503
- }
504
- else if (HIGHLIGHT_REGEX.test(text)) {
505
- const match = HIGHLIGHT_REGEX.exec(text);
506
- return `<span class="rm-highlight">${match === null || match === void 0 ? void 0 : match[1]}</span>`;
507
- }
508
- else if (BUTTON_REGEX.test(text)) {
509
- const match = ((_a = BUTTON_REGEX.exec(text)) === null || _a === void 0 ? void 0 : _a[1]) || "";
510
- const afterColon = (_b = BUTTON_REGEX.exec(text)) === null || _b === void 0 ? void 0 : _b[2];
511
- return (((_c = context.components) === null || _c === void 0 ? void 0 : _c.call(context, match, afterColon)) ||
512
- defaultComponents(match, afterColon) ||
513
- `<button class="bp3-button">${match}</button>`);
514
- }
515
- else if (BLOCK_REF_REGEX.test(text)) {
516
- const match = ((_d = BLOCK_REF_REGEX.exec(text)) === null || _d === void 0 ? void 0 : _d[1]) || "";
517
- const blockRefInfo = (_e = context.blockReferences) === null || _e === void 0 ? void 0 : _e.call(context, match);
518
- if (!blockRefInfo) {
519
- return text;
520
- }
521
- const page = blockRefInfo.page || "";
522
- const blockText = context.marked.parseInline(blockRefInfo.text || "") || "";
523
- if (!page)
524
- return blockText;
525
- const href = (_f = context.pagesToHrefs) === null || _f === void 0 ? void 0 : _f.call(context, page, match);
526
- return `<a class="rm-block-ref" href="${href}">${blockText}</a>`;
527
- }
528
- else if (BQ_REGEX.test(text)) {
529
- const match = BQ_REGEX.exec(text);
530
- return `<blockquote class="rm-bq">${match === null || match === void 0 ? void 0 : match[1]}</blockquote>`;
531
- }
532
- else {
533
- return text;
534
- }
535
- },
536
- },
537
- };
538
- const contextualize = (m) => (getMethod) => (text, ctxt) => {
539
- context.blockReferences = ctxt === null || ctxt === void 0 ? void 0 : ctxt.blockReferences;
540
- context.pagesToHrefs = ctxt === null || ctxt === void 0 ? void 0 : ctxt.pagesToHrefs;
541
- context.components = ctxt === null || ctxt === void 0 ? void 0 : ctxt.components;
542
- context.marked.parseInline = m.marked.parseInline;
543
- context.marked.lexInline = m.marked.Lexer.lexInline;
544
- context.marked.lastSrc = "";
545
- if (!context.marked.used) {
546
- m.marked.use(opts);
547
- context.marked.used = true;
548
- }
549
- return getMethod(m)(text);
550
- };
551
- const wrapOnce = (getMethod) => () => {
552
- return (typeof window !== "undefined" && window.RoamLazy
553
- ? window.RoamLazy.Marked()
554
- : Promise.resolve().then(() => tslib_1.__importStar(require("marked")))).then((m) => contextualize(m)(getMethod));
555
- };
556
- exports.getInlineLexer = wrapOnce((m) => m.marked.Lexer.lexInline);
557
- exports.getLexer = wrapOnce((m) => m.marked.lexer);
558
- exports.getParseInline = wrapOnce((m) => m.marked.parseInline);
559
- exports.getParse = wrapOnce((m) => m.marked.parse);
560
- const wrapEach = (getMethod) => (text, ctxt) => {
561
- return (window.RoamLazy ? window.RoamLazy.Marked() : Promise.resolve().then(() => tslib_1.__importStar(require("marked")))).then((m) => contextualize(m)(getMethod)(text, ctxt));
562
- };
563
- exports.inlineLexer = wrapEach((m) => m.marked.Lexer.lexInline);
564
- exports.lexer = wrapEach((m) => m.marked.lexer);
565
- exports.parseInline = wrapEach((m) => m.marked.parseInline);
566
- exports.parse = wrapEach((m) => m.marked.parse);
567
- exports.default = wrapEach((m) => m.marked.parse);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.parseInline = exports.lexer = exports.inlineLexer = exports.getParse = exports.getParseInline = exports.getLexer = exports.getInlineLexer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const xregexp_1 = tslib_1.__importDefault(require("xregexp"));
6
+ const refractor_1 = tslib_1.__importDefault(require("refractor"));
7
+ const markdown_1 = tslib_1.__importDefault(require("refractor/lang/markdown"));
8
+ const yaml_1 = tslib_1.__importDefault(require("refractor/lang/yaml"));
9
+ const css_1 = tslib_1.__importDefault(require("refractor/lang/css"));
10
+ const bash_1 = tslib_1.__importDefault(require("refractor/lang/bash"));
11
+ const java_1 = tslib_1.__importDefault(require("refractor/lang/java"));
12
+ const rust_1 = tslib_1.__importDefault(require("refractor/lang/rust"));
13
+ const python_1 = tslib_1.__importDefault(require("refractor/lang/python"));
14
+ const csharp_1 = tslib_1.__importDefault(require("refractor/lang/csharp"));
15
+ const clojure_1 = tslib_1.__importDefault(require("refractor/lang/clojure"));
16
+ const hcl_1 = tslib_1.__importDefault(require("refractor/lang/hcl"));
17
+ const hast_util_to_html_1 = tslib_1.__importDefault(require("hast-util-to-html"));
18
+ refractor_1.default.register(markdown_1.default);
19
+ refractor_1.default.register(yaml_1.default);
20
+ refractor_1.default.register(css_1.default);
21
+ refractor_1.default.register(bash_1.default);
22
+ refractor_1.default.register(java_1.default);
23
+ refractor_1.default.register(rust_1.default);
24
+ refractor_1.default.register(python_1.default);
25
+ refractor_1.default.register(csharp_1.default);
26
+ refractor_1.default.register(clojure_1.default);
27
+ refractor_1.default.register(hcl_1.default);
28
+ const RENDERED_TODO = '<span><label class="check-container"><input type="checkbox" disabled=""><span class="checkmark"></span></label></span>';
29
+ const RENDERED_DONE = '<span><label class="check-container"><input type="checkbox" checked="" disabled=""><span class="checkmark"></span></label></span>';
30
+ const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=$]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=$,]*)/;
31
+ const TODO_REGEX = /^{{(?:\[\[)?TODO(?:\]\])?}}/;
32
+ const DONE_REGEX = /^{{(?:\[\[)?DONE(?:\]\])?}}/;
33
+ const IFRAME_REGEX = new RegExp(`^{{(?:\\[\\[)?iframe(?:\\]\\])?:\\s*(${URL_REGEX.source})}}`);
34
+ const BUTTON_REGEX = /^{{(?:\[\[)?((?:(?!}}[^}])[\w\s-/])*)(?:\]\])?(?::(.*))?}}/;
35
+ const TAG_REGEX = /^#?\[\[(.*?)\]\]/;
36
+ const BLOCK_REF_REGEX = /^\(\((.*?)\)\)/;
37
+ const toAlias = (r) => new RegExp(`^\\[([^\\]]*?)\\]\\(${r.source.substring(1)}\\)`);
38
+ const ALIAS_REGEX = toAlias(TAG_REGEX);
39
+ const ALIAS_REF_REGEX = toAlias(BLOCK_REF_REGEX);
40
+ const HASHTAG_REGEX = /^#([^\s]*)/;
41
+ const ATTRIBUTE_REGEX = /^(.*?)::/;
42
+ const BOLD_REGEX = /^\*\*(.*?)\*\*/;
43
+ const ITALICS_REGEX = /^__(.*?)__/;
44
+ const HIGHLIGHT_REGEX = /^\^\^([^^]*)\^\^/;
45
+ const INLINE_STOP_REGEX = /({{|\*\*([^*]+?)\*\*|__([^_]+?)__|~~([^_]+?)~~|\^\^([^^]+?)\^\^|#?\[\[(.*?)\]\]|#[^\s]|\(\(.*?\)\)|\[(.*?)\]\((.*?)\))/;
46
+ const HR_REGEX = /^---$/;
47
+ const BQ_REGEX = /^(?:>|\[\[>\]\]) (.*)$/s;
48
+ const TWEET_STATUS_REGEX = /\/status\/(.*?)(?:\?s=\d*)?$/;
49
+ const HTML_REGEXES = [BUTTON_REGEX, BLOCK_REF_REGEX, HR_REGEX];
50
+ const HTML_WITH_CHILD_REGEXES = [
51
+ { rgx: BQ_REGEX, title: "blockquote" },
52
+ { rgx: HIGHLIGHT_REGEX, title: "highlight" },
53
+ ];
54
+ const CODESPAN_REGEX = new RegExp("^```([\\w]*)\n(.*)```$", "s");
55
+ const defaultComponents = (component, afterColon) => {
56
+ var _a;
57
+ const opts = ((_a = afterColon === null || afterColon === void 0 ? void 0 : afterColon.trim) === null || _a === void 0 ? void 0 : _a.call(afterColon)) || "";
58
+ switch (component) {
59
+ case "youtube":
60
+ case "video":
61
+ return `<div class="rm-iframe-container"><iframe src="${opts
62
+ .replace("youtu.be", "www.youtube.com/embed")
63
+ .replace("watch?v=", "embed/")
64
+ .replace("vimeo.com", "player.vimeo.com/video")}" class="rm-iframe rm-video-player"></iframe></div>`;
65
+ case "pdf":
66
+ return `<div class="rm-iframe-container"><iframe src="${opts}" class="rm-iframe"></iframe></div>`;
67
+ default:
68
+ return "";
69
+ }
70
+ };
71
+ // https://github.com/markedjs/marked/blob/d2347e9b9ae517d02138fa6a9844bd8d586acfeb/src/Tokenizer.js#L33-L59
72
+ function indentCodeCompensation(raw, text) {
73
+ const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
74
+ if (matchIndentToCode === null) {
75
+ return text;
76
+ }
77
+ const indentToCode = matchIndentToCode[1];
78
+ return text
79
+ .split("\n")
80
+ .map((node) => {
81
+ const matchIndentInNode = node.match(/^\s+/);
82
+ if (matchIndentInNode === null) {
83
+ return node;
84
+ }
85
+ const [indentInNode] = matchIndentInNode;
86
+ if (indentInNode.length >= indentToCode.length) {
87
+ return node.slice(indentToCode.length);
88
+ }
89
+ return node;
90
+ })
91
+ .join("\n");
92
+ }
93
+ const context = {
94
+ marked: {
95
+ parseInline: (s) => s,
96
+ lastSrc: "",
97
+ used: false,
98
+ lexInline: () => [],
99
+ },
100
+ };
101
+ const opts = {
102
+ tokenizer: {
103
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
104
+ // @ts-ignore should accept boolean return value
105
+ tag(src) {
106
+ for (const r of HTML_REGEXES) {
107
+ const match = r.exec(src);
108
+ if (match) {
109
+ return {
110
+ type: "html",
111
+ raw: match[0],
112
+ text: match[0],
113
+ };
114
+ }
115
+ }
116
+ return false;
117
+ },
118
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
119
+ // @ts-ignore should accept boolean return value
120
+ del(src) {
121
+ const match = /^~[^~]/.exec(src);
122
+ if (match) {
123
+ return {
124
+ type: "text",
125
+ raw: "~",
126
+ text: "~",
127
+ };
128
+ }
129
+ return false;
130
+ },
131
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
132
+ // @ts-ignore should accept boolean return value
133
+ emStrong(src) {
134
+ var _a, _b;
135
+ const match = BOLD_REGEX.exec(src);
136
+ if (match && ((_a = match[1]) === null || _a === void 0 ? void 0 : _a.length)) {
137
+ return {
138
+ type: "strong",
139
+ raw: match[0],
140
+ text: match[1],
141
+ tokens: context.marked.lexInline(match[1]),
142
+ };
143
+ }
144
+ const emMatch = ITALICS_REGEX.exec(src);
145
+ if (emMatch && ((_b = emMatch[1]) === null || _b === void 0 ? void 0 : _b.length)) {
146
+ return {
147
+ type: "em",
148
+ raw: emMatch[0],
149
+ text: emMatch[1],
150
+ tokens: context.marked.lexInline(emMatch[1]),
151
+ };
152
+ }
153
+ return false;
154
+ },
155
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
156
+ // @ts-ignore should accept boolean return value
157
+ fences(src) {
158
+ const newSrc = src.replace(/```$/, "\n```");
159
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
160
+ // @ts-ignore should accept boolean return value
161
+ const rules = this.rules;
162
+ const cap = rules.block.fences.exec(newSrc);
163
+ if (cap) {
164
+ const raw = cap[0];
165
+ const text = indentCodeCompensation(raw, cap[3] || "");
166
+ return {
167
+ type: "code",
168
+ raw,
169
+ lang: cap[2] ? cap[2].trim() : cap[2],
170
+ text,
171
+ };
172
+ }
173
+ return false;
174
+ },
175
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
176
+ // @ts-ignore should accept boolean return value
177
+ inlineText(src) {
178
+ var _a, _b;
179
+ if (src === context.marked.lastSrc) {
180
+ throw new Error(`Infinite loop on string ${src}`);
181
+ }
182
+ context.marked.lastSrc = src;
183
+ const attribute = ATTRIBUTE_REGEX.exec(src);
184
+ if (attribute) {
185
+ const raw = attribute[0];
186
+ const numberOfTicks = (raw.match(/([^`]`|`[^`])/g) || []).length;
187
+ if (numberOfTicks % 2 === 0) {
188
+ const page = attribute[1];
189
+ const href = (_a = context.pagesToHrefs) === null || _a === void 0 ? void 0 : _a.call(context, page);
190
+ const text = `${page}:`;
191
+ if (href) {
192
+ return {
193
+ type: "strong",
194
+ raw,
195
+ text,
196
+ tokens: [
197
+ {
198
+ type: "link",
199
+ raw: text,
200
+ text,
201
+ href,
202
+ tokens: [
203
+ {
204
+ type: "text",
205
+ raw: text,
206
+ text,
207
+ },
208
+ ],
209
+ },
210
+ ],
211
+ };
212
+ }
213
+ else {
214
+ return {
215
+ type: "strong",
216
+ raw,
217
+ text,
218
+ tokens: [
219
+ {
220
+ type: "text",
221
+ raw: text,
222
+ text,
223
+ },
224
+ ],
225
+ };
226
+ }
227
+ }
228
+ }
229
+ const match = INLINE_STOP_REGEX.exec(src);
230
+ if (match) {
231
+ const raw = src.substring(0, match.index);
232
+ const tickMatch = raw.match(/([^`]`|`[^`])/g);
233
+ const numberOfTicks = (tickMatch || []).length;
234
+ if (numberOfTicks % 2 === 0) {
235
+ const index = numberOfTicks > 0 ? (_b = /`/.exec(raw)) === null || _b === void 0 ? void 0 : _b.index : match.index;
236
+ return {
237
+ type: "text",
238
+ raw: src.substring(0, index),
239
+ text: src.substring(0, index),
240
+ };
241
+ }
242
+ }
243
+ return false;
244
+ },
245
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
246
+ // @ts-ignore should accept boolean return value
247
+ codespan(src) {
248
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
249
+ // @ts-ignore should accept boolean return value
250
+ const cap = this.rules.inline.code.exec(src);
251
+ if (cap) {
252
+ if (cap[0].startsWith("```")) {
253
+ return {
254
+ type: "codespan",
255
+ raw: cap[0],
256
+ text: cap[0],
257
+ };
258
+ }
259
+ }
260
+ return false;
261
+ },
262
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
263
+ // @ts-ignore should accept boolean return value
264
+ link(src) {
265
+ var _a, _b, _c;
266
+ // hijacking link for html elements with tokens
267
+ for (const { rgx, title } of HTML_WITH_CHILD_REGEXES) {
268
+ const match = rgx.exec(src);
269
+ if (match) {
270
+ return {
271
+ type: "link",
272
+ raw: match[0],
273
+ text: match[1],
274
+ title,
275
+ tokens: context.marked.lexInline(match[1]),
276
+ };
277
+ }
278
+ }
279
+ if (TAG_REGEX.test(src)) {
280
+ const match = xregexp_1.default.matchRecursive(src, "#?\\[\\[", "\\]\\]", "i", {
281
+ valueNames: ["between", "left", "match", "right"],
282
+ });
283
+ const raw = match.map((m) => m.value).join("");
284
+ if (context.pagesToHrefs) {
285
+ const text = match[1].value;
286
+ const href = context.pagesToHrefs(text);
287
+ if (href) {
288
+ return {
289
+ type: "link",
290
+ raw,
291
+ href,
292
+ text,
293
+ title: `tag:${text}`,
294
+ tokens: context.marked.lexInline(text),
295
+ };
296
+ }
297
+ else {
298
+ return {
299
+ type: "text",
300
+ raw,
301
+ text,
302
+ };
303
+ }
304
+ }
305
+ else {
306
+ return {
307
+ type: "text",
308
+ raw,
309
+ text: raw,
310
+ };
311
+ }
312
+ }
313
+ const hashMatch = HASHTAG_REGEX.exec(src);
314
+ if (hashMatch) {
315
+ const raw = hashMatch[0];
316
+ if (context.pagesToHrefs) {
317
+ const text = hashMatch[1];
318
+ const href = context.pagesToHrefs(text);
319
+ if (href) {
320
+ return {
321
+ type: "link",
322
+ raw,
323
+ href,
324
+ text,
325
+ title: `tag:${text}`,
326
+ tokens: context.marked.lexInline(text),
327
+ };
328
+ }
329
+ else {
330
+ return {
331
+ type: "text",
332
+ raw,
333
+ text,
334
+ };
335
+ }
336
+ }
337
+ else {
338
+ return {
339
+ type: "text",
340
+ raw,
341
+ text: raw,
342
+ };
343
+ }
344
+ }
345
+ const aliasMatch = ALIAS_REGEX.exec(src);
346
+ if (aliasMatch) {
347
+ const raw = aliasMatch[0];
348
+ if (context.pagesToHrefs) {
349
+ const text = aliasMatch[1];
350
+ const href = context.pagesToHrefs(aliasMatch[2]);
351
+ if (href) {
352
+ return {
353
+ type: "link",
354
+ raw,
355
+ href,
356
+ text,
357
+ title: "alias",
358
+ tokens: context.marked.lexInline(text),
359
+ };
360
+ }
361
+ else {
362
+ return {
363
+ type: "text",
364
+ raw,
365
+ text,
366
+ };
367
+ }
368
+ }
369
+ else {
370
+ return {
371
+ type: "text",
372
+ raw,
373
+ text: raw,
374
+ };
375
+ }
376
+ }
377
+ const aliasRefMatch = ALIAS_REF_REGEX.exec(src);
378
+ if (aliasRefMatch) {
379
+ const raw = aliasRefMatch[0];
380
+ const text = aliasRefMatch[1];
381
+ const ref = aliasRefMatch[2];
382
+ const href = (_a = context.pagesToHrefs) === null || _a === void 0 ? void 0 : _a.call(context, ((_c = (_b = context.blockReferences) === null || _b === void 0 ? void 0 : _b.call(context, ref)) === null || _c === void 0 ? void 0 : _c.page) || "", ref);
383
+ if (href) {
384
+ return {
385
+ type: "link",
386
+ raw,
387
+ href,
388
+ text,
389
+ title: "alias",
390
+ tokens: context.marked.lexInline(text),
391
+ };
392
+ }
393
+ else {
394
+ return {
395
+ type: "text",
396
+ raw,
397
+ text,
398
+ };
399
+ }
400
+ }
401
+ return false;
402
+ },
403
+ },
404
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
405
+ // @ts-ignore should be optional
406
+ renderer: {
407
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
408
+ // @ts-ignore should allow false
409
+ link(href, title, text) {
410
+ var _a;
411
+ if (title === "alias") {
412
+ const html = this.link(href, null, text || "");
413
+ if (html) {
414
+ return html.replace("href=", 'class="rm-alias" href=');
415
+ }
416
+ }
417
+ else if (title === null || title === void 0 ? void 0 : title.startsWith("tag:")) {
418
+ const html = this.link(href, null, text || "");
419
+ if (html) {
420
+ return html.replace("href=", `class="rm-page-ref" data-tag="${title.substring(4)}" href=`);
421
+ }
422
+ }
423
+ else if (title === "highlight") {
424
+ return `<span class="rm-highlight">${text}</span>`;
425
+ }
426
+ else if (title === "blockquote") {
427
+ return `<blockquote class="rm-bq">${text}</blockquote>`;
428
+ }
429
+ else if (href.startsWith("https://twitter.com") && text === href) {
430
+ const tweetId = (_a = TWEET_STATUS_REGEX.exec(href)) === null || _a === void 0 ? void 0 : _a[1];
431
+ const options = {
432
+ dnt: false,
433
+ frame: false,
434
+ hideCard: false,
435
+ hideThread: true,
436
+ id: tweetId,
437
+ lang: "en",
438
+ theme: "light",
439
+ width: "550px",
440
+ };
441
+ if (tweetId) {
442
+ return `<div>
443
+ <iframe scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="" style="position: static; visibility: visible; width: ${options.width}; height: ${options.width}; display: block; flex-grow: 1; pointer-events: auto;" title="Twitter Tweet" src="https://platform.twitter.com/embed/Tweet.html?${new URLSearchParams(Object.fromEntries(Object.entries(options).map(([k, v]) => [k, `${v}`])))
444
+ .toString()
445
+ .replace(/&/g, "&amp;")}" data-tweet-id="${tweetId}"></iframe>
446
+ <script>const cs = document.currentScript;
447
+ const iframe = cs.previousElementSibling;
448
+ const tweetId = iframe.getAttribute('data-tweet-id');
449
+ const renderTweet = () => {
450
+ const container = cs.parentElement;
451
+ container.style.height = '${options.width}';
452
+ window['twttr'].ready().then(({widgets}) =>
453
+ widgets.createTweetEmbed(tweetId, cs.parentElement, ${JSON.stringify(options)})).then(() => {
454
+ iframe.remove();
455
+ cs.remove();
456
+ container.style.height = 'unset';
457
+ });
458
+ }
459
+ const twttr = window['twttr']
460
+ if (!(twttr && twttr.ready)) {
461
+ var s = document.createElement('script');
462
+ s.setAttribute('src', "https://platform.twitter.com/widgets.js");
463
+ s.onload = renderTweet;
464
+ document.body.appendChild(s);
465
+ } else {
466
+ renderTweet()
467
+ }
468
+ </script>
469
+ </div>`;
470
+ }
471
+ }
472
+ return false;
473
+ },
474
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
475
+ // @ts-ignore should allow false
476
+ codespan(code) {
477
+ const match = CODESPAN_REGEX.exec(code);
478
+ if (match) {
479
+ const nodes = refractor_1.default.highlight(match[2], match[1]);
480
+ return `<pre><code class="language-${match[1]}">${(0, hast_util_to_html_1.default)(
481
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
482
+ //@ts-ignore
483
+ nodes)}</code></pre>`;
484
+ }
485
+ return false;
486
+ },
487
+ strong: (text) => `<span class="rm-bold">${text}</span>`,
488
+ em: (text) => `<em class="rm-italics">${text}</em>`,
489
+ html(text) {
490
+ var _a, _b, _c, _d, _e, _f;
491
+ if (TODO_REGEX.test(text)) {
492
+ return RENDERED_TODO;
493
+ }
494
+ else if (DONE_REGEX.test(text)) {
495
+ return RENDERED_DONE;
496
+ }
497
+ else if (HR_REGEX.test(text)) {
498
+ return "<hr>";
499
+ }
500
+ else if (IFRAME_REGEX.test(text)) {
501
+ const match = IFRAME_REGEX.exec(text);
502
+ return `<div class="rm-iframe-container"><iframe src="${match === null || match === void 0 ? void 0 : match[1]}" frameborder="0" class="rm-iframe"></iframe></div>`;
503
+ }
504
+ else if (HIGHLIGHT_REGEX.test(text)) {
505
+ const match = HIGHLIGHT_REGEX.exec(text);
506
+ return `<span class="rm-highlight">${match === null || match === void 0 ? void 0 : match[1]}</span>`;
507
+ }
508
+ else if (BUTTON_REGEX.test(text)) {
509
+ const match = ((_a = BUTTON_REGEX.exec(text)) === null || _a === void 0 ? void 0 : _a[1]) || "";
510
+ const afterColon = (_b = BUTTON_REGEX.exec(text)) === null || _b === void 0 ? void 0 : _b[2];
511
+ return (((_c = context.components) === null || _c === void 0 ? void 0 : _c.call(context, match, afterColon)) ||
512
+ defaultComponents(match, afterColon) ||
513
+ `<button class="bp3-button">${match}</button>`);
514
+ }
515
+ else if (BLOCK_REF_REGEX.test(text)) {
516
+ const match = ((_d = BLOCK_REF_REGEX.exec(text)) === null || _d === void 0 ? void 0 : _d[1]) || "";
517
+ const blockRefInfo = (_e = context.blockReferences) === null || _e === void 0 ? void 0 : _e.call(context, match);
518
+ if (!blockRefInfo) {
519
+ return text;
520
+ }
521
+ const page = blockRefInfo.page || "";
522
+ const blockText = context.marked.parseInline(blockRefInfo.text || "") || "";
523
+ if (!page)
524
+ return blockText;
525
+ const href = (_f = context.pagesToHrefs) === null || _f === void 0 ? void 0 : _f.call(context, page, match);
526
+ return `<a class="rm-block-ref" href="${href}">${blockText}</a>`;
527
+ }
528
+ else if (BQ_REGEX.test(text)) {
529
+ const match = BQ_REGEX.exec(text);
530
+ return `<blockquote class="rm-bq">${match === null || match === void 0 ? void 0 : match[1]}</blockquote>`;
531
+ }
532
+ else {
533
+ return text;
534
+ }
535
+ },
536
+ },
537
+ };
538
+ const contextualize = (m) => (getMethod) => (text, ctxt) => {
539
+ context.blockReferences = ctxt === null || ctxt === void 0 ? void 0 : ctxt.blockReferences;
540
+ context.pagesToHrefs = ctxt === null || ctxt === void 0 ? void 0 : ctxt.pagesToHrefs;
541
+ context.components = ctxt === null || ctxt === void 0 ? void 0 : ctxt.components;
542
+ context.marked.parseInline = m.marked.parseInline;
543
+ context.marked.lexInline = m.marked.Lexer.lexInline;
544
+ context.marked.lastSrc = "";
545
+ if (!context.marked.used) {
546
+ m.marked.use(opts);
547
+ context.marked.used = true;
548
+ }
549
+ return getMethod(m)(text);
550
+ };
551
+ const wrapOnce = (getMethod) => () => {
552
+ return (typeof window !== "undefined" && window.RoamLazy
553
+ ? window.RoamLazy.Marked()
554
+ : Promise.resolve().then(() => tslib_1.__importStar(require("marked")))).then((m) => contextualize(m)(getMethod));
555
+ };
556
+ exports.getInlineLexer = wrapOnce((m) => m.marked.Lexer.lexInline);
557
+ exports.getLexer = wrapOnce((m) => m.marked.lexer);
558
+ exports.getParseInline = wrapOnce((m) => m.marked.parseInline);
559
+ exports.getParse = wrapOnce((m) => m.marked.parse);
560
+ const wrapEach = (getMethod) => (text, ctxt) => {
561
+ return (window.RoamLazy ? window.RoamLazy.Marked() : Promise.resolve().then(() => tslib_1.__importStar(require("marked")))).then((m) => contextualize(m)(getMethod)(text, ctxt));
562
+ };
563
+ exports.inlineLexer = wrapEach((m) => m.marked.Lexer.lexInline);
564
+ exports.lexer = wrapEach((m) => m.marked.lexer);
565
+ exports.parseInline = wrapEach((m) => m.marked.parseInline);
566
+ exports.parse = wrapEach((m) => m.marked.parse);
567
+ exports.default = wrapEach((m) => m.marked.parse);
568
568
  //# sourceMappingURL=index.js.map