roamjs-components 0.53.2 → 0.53.5

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