roamjs-components 0.85.1 → 0.85.3

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 (557) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +29 -29
  3. package/components/AutocompleteInput.d.ts +28 -28
  4. package/components/AutocompleteInput.js +120 -120
  5. package/components/BlockErrorBoundary.d.ts +15 -15
  6. package/components/BlockErrorBoundary.js +27 -27
  7. package/components/BlockInput.d.ts +13 -13
  8. package/components/BlockInput.js +55 -55
  9. package/components/ComponentContainer.d.ts +10 -10
  10. package/components/ComponentContainer.js +37 -37
  11. package/components/ConfigPage.d.ts +35 -35
  12. package/components/ConfigPage.js +159 -159
  13. package/components/ConfigPanels/BlockPanel.d.ts +3 -3
  14. package/components/ConfigPanels/BlockPanel.js +42 -42
  15. package/components/ConfigPanels/BlocksPanel.d.ts +3 -3
  16. package/components/ConfigPanels/BlocksPanel.js +58 -58
  17. package/components/ConfigPanels/CustomPanel.d.ts +3 -3
  18. package/components/ConfigPanels/CustomPanel.js +24 -24
  19. package/components/ConfigPanels/FlagPanel.d.ts +3 -3
  20. package/components/ConfigPanels/FlagPanel.js +31 -31
  21. package/components/ConfigPanels/MultiChildPanel.d.ts +9 -9
  22. package/components/ConfigPanels/MultiChildPanel.js +58 -58
  23. package/components/ConfigPanels/MultiTextPanel.d.ts +3 -3
  24. package/components/ConfigPanels/MultiTextPanel.js +14 -14
  25. package/components/ConfigPanels/NumberPanel.d.ts +3 -3
  26. package/components/ConfigPanels/NumberPanel.js +25 -25
  27. package/components/ConfigPanels/OauthPanel.d.ts +3 -3
  28. package/components/ConfigPanels/OauthPanel.js +81 -81
  29. package/components/ConfigPanels/PagesPanel.d.ts +3 -3
  30. package/components/ConfigPanels/PagesPanel.js +11 -11
  31. package/components/ConfigPanels/SelectPanel.d.ts +3 -3
  32. package/components/ConfigPanels/SelectPanel.js +27 -27
  33. package/components/ConfigPanels/TextPanel.d.ts +3 -3
  34. package/components/ConfigPanels/TextPanel.js +28 -28
  35. package/components/ConfigPanels/TimePanel.d.ts +3 -3
  36. package/components/ConfigPanels/TimePanel.js +34 -34
  37. package/components/ConfigPanels/getBrandColors.d.ts +7 -7
  38. package/components/ConfigPanels/getBrandColors.js +28 -28
  39. package/components/ConfigPanels/types.d.ts +84 -84
  40. package/components/ConfigPanels/types.js +2 -2
  41. package/components/ConfigPanels/types.js.map +1 -1
  42. package/components/ConfigPanels/useSingleChildValue.d.ts +13 -13
  43. package/components/ConfigPanels/useSingleChildValue.js +43 -43
  44. package/components/CursorMenu.d.ts +21 -21
  45. package/components/CursorMenu.js +181 -181
  46. package/components/Description.d.ts +5 -5
  47. package/components/Description.js +16 -16
  48. package/components/ExtensionApiContext.d.ts +31 -31
  49. package/components/ExtensionApiContext.js +16 -16
  50. package/components/ExternalLogin.d.ts +18 -18
  51. package/components/ExternalLogin.js +141 -141
  52. package/components/Filter.d.ts +15 -15
  53. package/components/Filter.js +142 -142
  54. package/components/FormDialog.d.ts +55 -55
  55. package/components/FormDialog.js +217 -217
  56. package/components/Loading.d.ts +4 -4
  57. package/components/Loading.js +35 -35
  58. package/components/MenuItemSelect.d.ts +17 -17
  59. package/components/MenuItemSelect.js +23 -23
  60. package/components/OauthPanel.d.ts +7 -7
  61. package/components/OauthPanel.js +30 -30
  62. package/components/OauthSelect.d.ts +5 -5
  63. package/components/OauthSelect.js +25 -25
  64. package/components/PageInput.d.ts +6 -6
  65. package/components/PageInput.js +13 -13
  66. package/components/PageLink.d.ts +6 -6
  67. package/components/PageLink.js +31 -31
  68. package/components/ProgressDialog.d.ts +11 -11
  69. package/components/ProgressDialog.js +48 -48
  70. package/components/SimpleAlert.d.ts +15 -15
  71. package/components/SimpleAlert.js +47 -47
  72. package/components/Toast.d.ts +15 -15
  73. package/components/Toast.js +50 -50
  74. package/components/index.js +4 -4
  75. package/components/index.js.map +1 -1
  76. package/components.d.ts +5 -5
  77. package/components.js +170 -170
  78. package/date/constants.d.ts +3 -3
  79. package/date/constants.js +19 -19
  80. package/date/constants.js.map +1 -1
  81. package/date/index.d.ts +3 -3
  82. package/date/index.js +9 -9
  83. package/date/index.js.map +1 -1
  84. package/date/parseNlpDate.d.ts +5 -5
  85. package/date/parseNlpDate.js +226 -226
  86. package/date/parseNlpDate.js.map +1 -1
  87. package/date/parseRoamDateUid.d.ts +2 -2
  88. package/date/parseRoamDateUid.js +7 -7
  89. package/date/parseRoamDateUid.js.map +1 -1
  90. package/dom/addBlockCommand.d.ts +5 -5
  91. package/dom/addBlockCommand.js +53 -53
  92. package/dom/addBlockCommand.js.map +1 -1
  93. package/dom/addKeyboardTriggers.d.ts +11 -11
  94. package/dom/addKeyboardTriggers.js +38 -38
  95. package/dom/addKeyboardTriggers.js.map +1 -1
  96. package/dom/addOldRoamJSDependency.d.ts +2 -2
  97. package/dom/addOldRoamJSDependency.js +10 -10
  98. package/dom/addOldRoamJSDependency.js.map +1 -1
  99. package/dom/addRoamJSDependency.d.ts +2 -2
  100. package/dom/addRoamJSDependency.js +8 -8
  101. package/dom/addRoamJSDependency.js.map +1 -1
  102. package/dom/addScriptAsDependency.d.ts +6 -6
  103. package/dom/addScriptAsDependency.js +16 -16
  104. package/dom/addScriptAsDependency.js.map +1 -1
  105. package/dom/addStyle.d.ts +2 -2
  106. package/dom/addStyle.js +14 -14
  107. package/dom/addStyle.js.map +1 -1
  108. package/dom/constants.d.ts +1 -1
  109. package/dom/constants.js +4 -4
  110. package/dom/constants.js.map +1 -1
  111. package/dom/createBlockObserver.d.ts +7 -7
  112. package/dom/createBlockObserver.js +43 -43
  113. package/dom/createBlockObserver.js.map +1 -1
  114. package/dom/createButtonObserver.d.ts +6 -6
  115. package/dom/createButtonObserver.js +21 -21
  116. package/dom/createButtonObserver.js.map +1 -1
  117. package/dom/createDivObserver.d.ts +2 -2
  118. package/dom/createDivObserver.js +13 -13
  119. package/dom/createDivObserver.js.map +1 -1
  120. package/dom/createHTMLObserver.d.ts +8 -8
  121. package/dom/createHTMLObserver.js +24 -24
  122. package/dom/createHTMLObserver.js.map +1 -1
  123. package/dom/createHashtagObserver.d.ts +5 -5
  124. package/dom/createHashtagObserver.js +16 -16
  125. package/dom/createHashtagObserver.js.map +1 -1
  126. package/dom/createIconButton.d.ts +2 -2
  127. package/dom/createIconButton.js +12 -12
  128. package/dom/createIconButton.js.map +1 -1
  129. package/dom/createObserver.d.ts +2 -2
  130. package/dom/createObserver.js +9 -9
  131. package/dom/createObserver.js.map +1 -1
  132. package/dom/createOverlayObserver.d.ts +2 -2
  133. package/dom/createOverlayObserver.js +6 -6
  134. package/dom/createOverlayObserver.js.map +1 -1
  135. package/dom/createPageObserver.d.ts +2 -2
  136. package/dom/createPageObserver.js +34 -34
  137. package/dom/createPageObserver.js.map +1 -1
  138. package/dom/createPageTitleObserver.d.ts +6 -6
  139. package/dom/createPageTitleObserver.js +31 -31
  140. package/dom/createPageTitleObserver.js.map +1 -1
  141. package/dom/elToTitle.d.ts +2 -2
  142. package/dom/elToTitle.js +22 -22
  143. package/dom/elToTitle.js.map +1 -1
  144. package/dom/genericError.d.ts +3 -3
  145. package/dom/genericError.js +11 -11
  146. package/dom/genericError.js.map +1 -1
  147. package/dom/getActiveUids.d.ts +3 -3
  148. package/dom/getActiveUids.js +6 -6
  149. package/dom/getActiveUids.js.map +1 -1
  150. package/dom/getBlockUidFromTarget.d.ts +2 -2
  151. package/dom/getBlockUidFromTarget.js +33 -33
  152. package/dom/getBlockUidFromTarget.js.map +1 -1
  153. package/dom/getCurrentPageUid.d.ts +2 -2
  154. package/dom/getCurrentPageUid.js +8 -8
  155. package/dom/getCurrentPageUid.js.map +1 -1
  156. package/dom/getDomRefs.d.ts +2 -2
  157. package/dom/getDomRefs.js +12 -12
  158. package/dom/getDomRefs.js.map +1 -1
  159. package/dom/getDropUidOffset.d.ts +5 -5
  160. package/dom/getDropUidOffset.js +27 -27
  161. package/dom/getDropUidOffset.js.map +1 -1
  162. package/dom/getMutatedNodes.d.ts +7 -7
  163. package/dom/getMutatedNodes.js +11 -11
  164. package/dom/getMutatedNodes.js.map +1 -1
  165. package/dom/getPageTitleByHtmlElement.d.ts +2 -2
  166. package/dom/getPageTitleByHtmlElement.js +12 -12
  167. package/dom/getPageTitleByHtmlElement.js.map +1 -1
  168. package/dom/getPageTitleValueByHtmlElement.d.ts +2 -2
  169. package/dom/getPageTitleValueByHtmlElement.js +9 -9
  170. package/dom/getPageTitleValueByHtmlElement.js.map +1 -1
  171. package/dom/getReferenceBlockUid.d.ts +2 -2
  172. package/dom/getReferenceBlockUid.js +18 -18
  173. package/dom/getReferenceBlockUid.js.map +1 -1
  174. package/dom/getRoamUrl.d.ts +2 -2
  175. package/dom/getRoamUrl.js +4 -4
  176. package/dom/getRoamUrl.js.map +1 -1
  177. package/dom/getRoamUrlByPage.d.ts +2 -2
  178. package/dom/getRoamUrlByPage.js +10 -10
  179. package/dom/getRoamUrlByPage.js.map +1 -1
  180. package/dom/getUids.d.ts +3 -3
  181. package/dom/getUids.js +8 -8
  182. package/dom/getUids.js.map +1 -1
  183. package/dom/getUidsFromButton.d.ts +3 -3
  184. package/dom/getUidsFromButton.js +8 -8
  185. package/dom/getUidsFromButton.js.map +1 -1
  186. package/dom/getUidsFromId.d.ts +5 -5
  187. package/dom/getUidsFromId.js +15 -15
  188. package/dom/getUidsFromId.js.map +1 -1
  189. package/dom/index.d.ts +30 -30
  190. package/dom/index.js +63 -63
  191. package/dom/index.js.map +1 -1
  192. package/dom/parseRoamBlocksToHtml.d.ts +11 -11
  193. package/dom/parseRoamBlocksToHtml.js +79 -79
  194. package/dom/parseRoamBlocksToHtml.js.map +1 -1
  195. package/dom/resolveRefs.d.ts +2 -2
  196. package/dom/resolveRefs.js +24 -24
  197. package/dom/resolveRefs.js.map +1 -1
  198. package/events/index.d.ts +1 -1
  199. package/events/index.js +8 -8
  200. package/events/index.js.map +1 -1
  201. package/events/watchOnce.d.ts +3 -3
  202. package/events/watchOnce.js +12 -12
  203. package/events/watchOnce.js.map +1 -1
  204. package/hooks/index.d.ts +2 -2
  205. package/hooks/index.js +10 -10
  206. package/hooks/index.js.map +1 -1
  207. package/hooks/useArrowKeyDown.d.ts +10 -10
  208. package/hooks/useArrowKeyDown.js +54 -54
  209. package/hooks/useArrowKeyDown.js.map +1 -1
  210. package/hooks/useSubTree.d.ts +3 -3
  211. package/hooks/useSubTree.js +11 -11
  212. package/hooks/useSubTree.js.map +1 -1
  213. package/marked/index.d.ts +25 -25
  214. package/marked/index.js +567 -567
  215. package/marked/index.js.map +1 -1
  216. package/package.json +116 -117
  217. package/queries/compileDatalog.d.ts +3 -3
  218. package/queries/compileDatalog.js +63 -63
  219. package/queries/compileDatalog.js.map +1 -1
  220. package/queries/getAllBlockUids.d.ts +2 -2
  221. package/queries/getAllBlockUids.js +6 -6
  222. package/queries/getAllBlockUids.js.map +1 -1
  223. package/queries/getAllBlockUidsAndTexts.d.ts +5 -5
  224. package/queries/getAllBlockUidsAndTexts.js +6 -6
  225. package/queries/getAllBlockUidsAndTexts.js.map +1 -1
  226. package/queries/getAllPageNames.d.ts +2 -2
  227. package/queries/getAllPageNames.js +6 -6
  228. package/queries/getAllPageNames.js.map +1 -1
  229. package/queries/getAttributeValueByBlockAndName.d.ts +5 -5
  230. package/queries/getAttributeValueByBlockAndName.js +11 -11
  231. package/queries/getAttributeValueByBlockAndName.js.map +1 -1
  232. package/queries/getBasicTreeByParentUid.d.ts +3 -3
  233. package/queries/getBasicTreeByParentUid.js +13 -13
  234. package/queries/getBasicTreeByParentUid.js.map +1 -1
  235. package/queries/getBlockUidAndTextIncludingText.d.ts +5 -5
  236. package/queries/getBlockUidAndTextIncludingText.js +7 -7
  237. package/queries/getBlockUidAndTextIncludingText.js.map +1 -1
  238. package/queries/getBlockUidByTextOnPage.d.ts +5 -5
  239. package/queries/getBlockUidByTextOnPage.js +7 -7
  240. package/queries/getBlockUidByTextOnPage.js.map +1 -1
  241. package/queries/getBlockUidsAndTextsReferencingPage.d.ts +5 -5
  242. package/queries/getBlockUidsAndTextsReferencingPage.js +9 -9
  243. package/queries/getBlockUidsAndTextsReferencingPage.js.map +1 -1
  244. package/queries/getBlockUidsByPageTitle.d.ts +2 -2
  245. package/queries/getBlockUidsByPageTitle.js +8 -8
  246. package/queries/getBlockUidsByPageTitle.js.map +1 -1
  247. package/queries/getBlockUidsReferencingBlock.d.ts +2 -2
  248. package/queries/getBlockUidsReferencingBlock.js +4 -4
  249. package/queries/getBlockUidsReferencingBlock.js.map +1 -1
  250. package/queries/getBlockUidsReferencingPage.d.ts +2 -2
  251. package/queries/getBlockUidsReferencingPage.js +6 -6
  252. package/queries/getBlockUidsReferencingPage.js.map +1 -1
  253. package/queries/getBlockUidsWithParentUid.d.ts +2 -2
  254. package/queries/getBlockUidsWithParentUid.js +6 -6
  255. package/queries/getBlockUidsWithParentUid.js.map +1 -1
  256. package/queries/getChildrenLengthByPageUid.d.ts +2 -2
  257. package/queries/getChildrenLengthByPageUid.js +8 -8
  258. package/queries/getChildrenLengthByPageUid.js.map +1 -1
  259. package/queries/getChildrenLengthByParentUid.d.ts +2 -2
  260. package/queries/getChildrenLengthByParentUid.js +7 -7
  261. package/queries/getChildrenLengthByParentUid.js.map +1 -1
  262. package/queries/getCreateTimeByBlockUid.d.ts +2 -2
  263. package/queries/getCreateTimeByBlockUid.js +7 -7
  264. package/queries/getCreateTimeByBlockUid.js.map +1 -1
  265. package/queries/getCurrentUser.d.ts +2 -2
  266. package/queries/getCurrentUser.js +11 -11
  267. package/queries/getCurrentUser.js.map +1 -1
  268. package/queries/getCurrentUserDisplayName.d.ts +2 -2
  269. package/queries/getCurrentUserDisplayName.js +10 -10
  270. package/queries/getCurrentUserDisplayName.js.map +1 -1
  271. package/queries/getCurrentUserEmail.d.ts +2 -2
  272. package/queries/getCurrentUserEmail.js +13 -13
  273. package/queries/getCurrentUserEmail.js.map +1 -1
  274. package/queries/getCurrentUserUid.d.ts +2 -2
  275. package/queries/getCurrentUserUid.js +13 -13
  276. package/queries/getCurrentUserUid.js.map +1 -1
  277. package/queries/getDisplayNameByEmail.d.ts +2 -2
  278. package/queries/getDisplayNameByEmail.js +7 -7
  279. package/queries/getDisplayNameByEmail.js.map +1 -1
  280. package/queries/getDisplayNameByUid.d.ts +2 -2
  281. package/queries/getDisplayNameByUid.js +7 -7
  282. package/queries/getDisplayNameByUid.js.map +1 -1
  283. package/queries/getEditTimeByBlockUid.d.ts +2 -2
  284. package/queries/getEditTimeByBlockUid.js +7 -7
  285. package/queries/getEditTimeByBlockUid.js.map +1 -1
  286. package/queries/getEditedUserEmailByBlockUid.d.ts +2 -2
  287. package/queries/getEditedUserEmailByBlockUid.js +7 -7
  288. package/queries/getEditedUserEmailByBlockUid.js.map +1 -1
  289. package/queries/getFirstChildTextByBlockUid.d.ts +2 -2
  290. package/queries/getFirstChildTextByBlockUid.js +7 -7
  291. package/queries/getFirstChildTextByBlockUid.js.map +1 -1
  292. package/queries/getFirstChildUidByBlockUid.d.ts +2 -2
  293. package/queries/getFirstChildUidByBlockUid.js +6 -6
  294. package/queries/getFirstChildUidByBlockUid.js.map +1 -1
  295. package/queries/getFullTreeByParentUid.d.ts +3 -3
  296. package/queries/getFullTreeByParentUid.js +51 -51
  297. package/queries/getFullTreeByParentUid.js.map +1 -1
  298. package/queries/getLinkedPageTitlesUnderUid.d.ts +2 -2
  299. package/queries/getLinkedPageTitlesUnderUid.js +6 -6
  300. package/queries/getLinkedPageTitlesUnderUid.js.map +1 -1
  301. package/queries/getNthChildUidByBlockUid.d.ts +5 -5
  302. package/queries/getNthChildUidByBlockUid.js +7 -7
  303. package/queries/getNthChildUidByBlockUid.js.map +1 -1
  304. package/queries/getOrderByBlockUid.d.ts +2 -2
  305. package/queries/getOrderByBlockUid.js +7 -7
  306. package/queries/getOrderByBlockUid.js.map +1 -1
  307. package/queries/getPageTitleByBlockUid.d.ts +2 -2
  308. package/queries/getPageTitleByBlockUid.js +7 -7
  309. package/queries/getPageTitleByBlockUid.js.map +1 -1
  310. package/queries/getPageTitleByPageUid.d.ts +2 -2
  311. package/queries/getPageTitleByPageUid.js +12 -12
  312. package/queries/getPageTitleByPageUid.js.map +1 -1
  313. package/queries/getPageTitleReferencesByPageTitle.d.ts +2 -2
  314. package/queries/getPageTitleReferencesByPageTitle.js +6 -6
  315. package/queries/getPageTitleReferencesByPageTitle.js.map +1 -1
  316. package/queries/getPageTitlesAndBlockUidsReferencingPage.d.ts +5 -5
  317. package/queries/getPageTitlesAndBlockUidsReferencingPage.js +9 -9
  318. package/queries/getPageTitlesAndBlockUidsReferencingPage.js.map +1 -1
  319. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.d.ts +5 -5
  320. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js +9 -9
  321. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js.map +1 -1
  322. package/queries/getPageTitlesReferencingBlockUid.d.ts +2 -2
  323. package/queries/getPageTitlesReferencingBlockUid.js +4 -4
  324. package/queries/getPageTitlesReferencingBlockUid.js.map +1 -1
  325. package/queries/getPageTitlesStartingWithPrefix.d.ts +2 -2
  326. package/queries/getPageTitlesStartingWithPrefix.js +6 -6
  327. package/queries/getPageTitlesStartingWithPrefix.js.map +1 -1
  328. package/queries/getPageUidByBlockUid.d.ts +2 -2
  329. package/queries/getPageUidByBlockUid.js +7 -7
  330. package/queries/getPageUidByBlockUid.js.map +1 -1
  331. package/queries/getPageUidByPageTitle.d.ts +2 -2
  332. package/queries/getPageUidByPageTitle.js +9 -9
  333. package/queries/getPageUidByPageTitle.js.map +1 -1
  334. package/queries/getPageViewType.d.ts +3 -3
  335. package/queries/getPageViewType.js +9 -9
  336. package/queries/getPageViewType.js.map +1 -1
  337. package/queries/getParentTextByBlockUid.d.ts +2 -2
  338. package/queries/getParentTextByBlockUid.js +7 -7
  339. package/queries/getParentTextByBlockUid.js.map +1 -1
  340. package/queries/getParentTextByBlockUidAndTag.d.ts +5 -5
  341. package/queries/getParentTextByBlockUidAndTag.js +7 -7
  342. package/queries/getParentTextByBlockUidAndTag.js.map +1 -1
  343. package/queries/getParentUidByBlockUid.d.ts +2 -2
  344. package/queries/getParentUidByBlockUid.js +7 -7
  345. package/queries/getParentUidByBlockUid.js.map +1 -1
  346. package/queries/getParentUidsOfBlockUid.d.ts +2 -2
  347. package/queries/getParentUidsOfBlockUid.js +4 -4
  348. package/queries/getParentUidsOfBlockUid.js.map +1 -1
  349. package/queries/getSettingsByEmail.d.ts +3 -3
  350. package/queries/getSettingsByEmail.js +7 -7
  351. package/queries/getSettingsByEmail.js.map +1 -1
  352. package/queries/getShallowTreeByParentUid.d.ts +5 -5
  353. package/queries/getShallowTreeByParentUid.js +9 -9
  354. package/queries/getShallowTreeByParentUid.js.map +1 -1
  355. package/queries/getTextByBlockUid.d.ts +2 -2
  356. package/queries/getTextByBlockUid.js +9 -9
  357. package/queries/getTextByBlockUid.js.map +1 -1
  358. package/queries/index.js +4 -4
  359. package/queries/index.js.map +1 -1
  360. package/queries/isLiveBlock.d.ts +2 -2
  361. package/queries/isLiveBlock.js +4 -4
  362. package/queries/isLiveBlock.js.map +1 -1
  363. package/queries/isTagOnPage.d.ts +5 -5
  364. package/queries/isTagOnPage.js +9 -9
  365. package/queries/isTagOnPage.js.map +1 -1
  366. package/queries/normalizePageTitle.d.ts +2 -2
  367. package/queries/normalizePageTitle.js +4 -4
  368. package/queries/normalizePageTitle.js.map +1 -1
  369. package/scripts/index.d.ts +1 -1
  370. package/scripts/index.js +26 -26
  371. package/scripts/index.js.map +1 -1
  372. package/scripts/publishToRoamDepot.d.ts +7 -7
  373. package/scripts/publishToRoamDepot.js +113 -113
  374. package/scripts/publishToRoamDepot.js.map +1 -1
  375. package/testing/mockRoamEnvironment.d.ts +2 -2
  376. package/testing/mockRoamEnvironment.js +1253 -1253
  377. package/testing/mockRoamEnvironment.js.map +1 -1
  378. package/types/index.d.ts +250 -250
  379. package/types/index.js +4 -4
  380. package/types/index.js.map +1 -1
  381. package/types/native.d.ts +402 -402
  382. package/types/native.js +4 -4
  383. package/types/native.js.map +1 -1
  384. package/types/query-builder.d.ts +10 -10
  385. package/types/query-builder.js +2 -2
  386. package/types/query-builder.js.map +1 -1
  387. package/types/smartblocks.d.ts +35 -35
  388. package/types/smartblocks.js +2 -2
  389. package/types/smartblocks.js.map +1 -1
  390. package/util/addInputSetting.d.ts +7 -7
  391. package/util/addInputSetting.js +25 -25
  392. package/util/addInputSetting.js.map +1 -1
  393. package/util/apiDelete.d.ts +2 -2
  394. package/util/apiDelete.js +6 -6
  395. package/util/apiDelete.js.map +1 -1
  396. package/util/apiGet.d.ts +2 -2
  397. package/util/apiGet.js +6 -6
  398. package/util/apiGet.js.map +1 -1
  399. package/util/apiPost.d.ts +2 -2
  400. package/util/apiPost.js +6 -6
  401. package/util/apiPost.js.map +1 -1
  402. package/util/apiPut.d.ts +2 -2
  403. package/util/apiPut.js +6 -6
  404. package/util/apiPut.js.map +1 -1
  405. package/util/createOverlayRender.d.ts +4 -4
  406. package/util/createOverlayRender.js +6 -6
  407. package/util/createOverlayRender.js.map +1 -1
  408. package/util/createTagRegex.d.ts +2 -2
  409. package/util/createTagRegex.js +7 -7
  410. package/util/createTagRegex.js.map +1 -1
  411. package/util/dispatchToRegistry.d.ts +3 -3
  412. package/util/dispatchToRegistry.js +7 -7
  413. package/util/dispatchToRegistry.js.map +1 -1
  414. package/util/env.d.ts +4 -4
  415. package/util/env.js +47 -47
  416. package/util/env.js.map +1 -1
  417. package/util/extensionApiContext.d.ts +29 -29
  418. package/util/extensionApiContext.js +17 -17
  419. package/util/extensionApiContext.js.map +1 -1
  420. package/util/extensionDeprecatedWarning.d.ts +5 -5
  421. package/util/extensionDeprecatedWarning.js +39 -39
  422. package/util/extensionDeprecatedWarning.js.map +1 -1
  423. package/util/extractRef.d.ts +2 -2
  424. package/util/extractRef.js +8 -8
  425. package/util/extractRef.js.map +1 -1
  426. package/util/extractTag.d.ts +2 -2
  427. package/util/extractTag.js +15 -15
  428. package/util/extractTag.js.map +1 -1
  429. package/util/focusMainWindowBlock.d.ts +2 -2
  430. package/util/focusMainWindowBlock.js +12 -12
  431. package/util/focusMainWindowBlock.js.map +1 -1
  432. package/util/getAuthorizationHeader.d.ts +2 -2
  433. package/util/getAuthorizationHeader.js +12 -12
  434. package/util/getAuthorizationHeader.js.map +1 -1
  435. package/util/getLocalStorageKey.d.ts +2 -2
  436. package/util/getLocalStorageKey.js +4 -4
  437. package/util/getLocalStorageKey.js.map +1 -1
  438. package/util/getOauth.d.ts +2 -2
  439. package/util/getOauth.js +52 -52
  440. package/util/getOauth.js.map +1 -1
  441. package/util/getOauthAccounts.d.ts +2 -2
  442. package/util/getOauthAccounts.js +22 -22
  443. package/util/getOauthAccounts.js.map +1 -1
  444. package/util/getRenderRoot.d.ts +2 -2
  445. package/util/getRenderRoot.js +18 -18
  446. package/util/getRenderRoot.js.map +1 -1
  447. package/util/getSettingIntFromTree.d.ts +7 -7
  448. package/util/getSettingIntFromTree.js +11 -11
  449. package/util/getSettingIntFromTree.js.map +1 -1
  450. package/util/getSettingValueFromTree.d.ts +8 -8
  451. package/util/getSettingValueFromTree.js +14 -14
  452. package/util/getSettingValueFromTree.js.map +1 -1
  453. package/util/getSettingValuesFromTree.d.ts +7 -7
  454. package/util/getSettingValuesFromTree.js +12 -12
  455. package/util/getSettingValuesFromTree.js.map +1 -1
  456. package/util/getSubTree.d.ts +8 -8
  457. package/util/getSubTree.js +19 -19
  458. package/util/getSubTree.js.map +1 -1
  459. package/util/getToken.d.ts +2 -2
  460. package/util/getToken.js +10 -10
  461. package/util/getToken.js.map +1 -1
  462. package/util/getTokenFromTree.d.ts +3 -3
  463. package/util/getTokenFromTree.js +4 -4
  464. package/util/getTokenFromTree.js.map +1 -1
  465. package/util/getWorkerClient.d.ts +12 -12
  466. package/util/getWorkerClient.js +41 -41
  467. package/util/getWorkerClient.js.map +1 -1
  468. package/util/handleBodyFetch.d.ts +3 -3
  469. package/util/handleBodyFetch.js +21 -21
  470. package/util/handleBodyFetch.js.map +1 -1
  471. package/util/handleFetch.d.ts +13 -13
  472. package/util/handleFetch.js +40 -40
  473. package/util/handleFetch.js.map +1 -1
  474. package/util/handleUrlFetch.d.ts +3 -3
  475. package/util/handleUrlFetch.js +19 -19
  476. package/util/handleUrlFetch.js.map +1 -1
  477. package/util/idToTitle.d.ts +2 -2
  478. package/util/idToTitle.js +8 -8
  479. package/util/idToTitle.js.map +1 -1
  480. package/util/index.d.ts +24 -24
  481. package/util/index.js +54 -54
  482. package/util/index.js.map +1 -1
  483. package/util/isControl.d.ts +2 -2
  484. package/util/isControl.js +4 -4
  485. package/util/isControl.js.map +1 -1
  486. package/util/localStorageGet.d.ts +2 -2
  487. package/util/localStorageGet.js +8 -8
  488. package/util/localStorageGet.js.map +1 -1
  489. package/util/localStorageRemove.d.ts +2 -2
  490. package/util/localStorageRemove.js +6 -6
  491. package/util/localStorageRemove.js.map +1 -1
  492. package/util/localStorageSet.d.ts +2 -2
  493. package/util/localStorageSet.js +8 -8
  494. package/util/localStorageSet.js.map +1 -1
  495. package/util/registerExperimentalMode.d.ts +6 -6
  496. package/util/registerExperimentalMode.js +65 -65
  497. package/util/registerExperimentalMode.js.map +1 -1
  498. package/util/registerSmartBlocksCommand.d.ts +3 -3
  499. package/util/registerSmartBlocksCommand.js +23 -23
  500. package/util/registerSmartBlocksCommand.js.map +1 -1
  501. package/util/removeFromRegistry.d.ts +3 -3
  502. package/util/removeFromRegistry.js +7 -7
  503. package/util/removeFromRegistry.js.map +1 -1
  504. package/util/renderOverlay.d.ts +12 -12
  505. package/util/renderOverlay.js +48 -48
  506. package/util/renderOverlay.js.map +1 -1
  507. package/util/renderWithUnmount.d.ts +4 -4
  508. package/util/renderWithUnmount.js +44 -44
  509. package/util/renderWithUnmount.js.map +1 -1
  510. package/util/runExtension.d.ts +11 -11
  511. package/util/runExtension.js +174 -174
  512. package/util/runExtension.js.map +1 -1
  513. package/util/setInputSetting.d.ts +7 -7
  514. package/util/setInputSetting.js +37 -37
  515. package/util/setInputSetting.js.map +1 -1
  516. package/util/setInputSettings.d.ts +7 -7
  517. package/util/setInputSettings.js +28 -28
  518. package/util/setInputSettings.js.map +1 -1
  519. package/util/stripUid.d.ts +3 -3
  520. package/util/stripUid.js +10 -10
  521. package/util/stripUid.js.map +1 -1
  522. package/util/toConfigPageName.d.ts +2 -2
  523. package/util/toConfigPageName.js +4 -4
  524. package/util/toConfigPageName.js.map +1 -1
  525. package/util/toFlexRegex.d.ts +2 -2
  526. package/util/toFlexRegex.js +4 -4
  527. package/util/toFlexRegex.js.map +1 -1
  528. package/writes/clearBlockById.d.ts +2 -2
  529. package/writes/clearBlockById.js +17 -17
  530. package/writes/clearBlockById.js.map +1 -1
  531. package/writes/clearBlockByUid.d.ts +2 -2
  532. package/writes/clearBlockByUid.js +16 -16
  533. package/writes/clearBlockByUid.js.map +1 -1
  534. package/writes/createBlock.d.ts +8 -8
  535. package/writes/createBlock.js +28 -28
  536. package/writes/createBlock.js.map +1 -1
  537. package/writes/createPage.d.ts +7 -7
  538. package/writes/createPage.js +20 -20
  539. package/writes/createPage.js.map +1 -1
  540. package/writes/deleteBlock.d.ts +2 -2
  541. package/writes/deleteBlock.js +10 -10
  542. package/writes/deleteBlock.js.map +1 -1
  543. package/writes/index.d.ts +8 -8
  544. package/writes/index.js +22 -22
  545. package/writes/index.js.map +1 -1
  546. package/writes/openBlockInSidebar.d.ts +2 -2
  547. package/writes/openBlockInSidebar.js +13 -13
  548. package/writes/openBlockInSidebar.js.map +1 -1
  549. package/writes/submitActions.d.ts +8 -8
  550. package/writes/submitActions.js +36 -36
  551. package/writes/submitActions.js.map +1 -1
  552. package/writes/updateActiveBlock.d.ts +2 -2
  553. package/writes/updateActiveBlock.js +17 -17
  554. package/writes/updateActiveBlock.js.map +1 -1
  555. package/writes/updateBlock.d.ts +5 -5
  556. package/writes/updateBlock.js +23 -23
  557. 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