@dooc-dev/dooc 0.0.4 → 0.0.6

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 (231) hide show
  1. package/dist/cli.js +157 -58
  2. package/dist/code-worker.global.js +152 -0
  3. package/dist/code.global.js +101 -101
  4. package/dist/compiler/asset-references.d.ts +4 -0
  5. package/dist/compiler/asset-references.js +117 -0
  6. package/dist/compiler/bundle-urls.d.ts +1 -1
  7. package/dist/compiler/bundle-urls.js +17 -5
  8. package/dist/compiler/check.js +10 -5
  9. package/dist/compiler/code-languages.js +7 -2
  10. package/dist/compiler/compile.d.ts +5 -0
  11. package/dist/compiler/compile.js +117 -12
  12. package/dist/compiler/config.js +2 -1
  13. package/dist/compiler/dxf.d.ts +1 -0
  14. package/dist/compiler/dxf.js +81 -0
  15. package/dist/compiler/export.d.ts +4 -0
  16. package/dist/compiler/export.js +147 -0
  17. package/dist/compiler/figures.js +43 -10
  18. package/dist/compiler/files.js +82 -41
  19. package/dist/compiler/fonts.js +4 -1
  20. package/dist/compiler/icons.d.ts +1 -1
  21. package/dist/compiler/icons.js +11 -2
  22. package/dist/compiler/ignored-files.d.ts +5 -0
  23. package/dist/compiler/ignored-files.js +98 -0
  24. package/dist/compiler/locales.js +13 -8
  25. package/dist/compiler/ops.d.ts +6 -0
  26. package/dist/compiler/ops.js +99 -8
  27. package/dist/compiler/subformat-schema.d.ts +14 -0
  28. package/dist/compiler/subformat-schema.js +92 -0
  29. package/dist/compiler/subformats.d.ts +22 -0
  30. package/dist/compiler/subformats.js +339 -0
  31. package/dist/compiler/textfile.js +3 -0
  32. package/dist/compiler/theme-variants.js +5 -2
  33. package/dist/core/code-file.js +7 -5
  34. package/dist/core/code-grammars.d.ts +5 -0
  35. package/dist/core/code-grammars.js +34 -0
  36. package/dist/core/content-metadata.d.ts +16 -6
  37. package/dist/core/content-metadata.js +283 -17
  38. package/dist/core/content-types.d.ts +4 -2
  39. package/dist/core/escape-html.d.ts +1 -0
  40. package/dist/core/escape-html.js +1 -0
  41. package/dist/core/figure-frame.js +20 -2
  42. package/dist/core/file-embed.js +7 -3
  43. package/dist/core/files.d.ts +2 -1
  44. package/dist/core/files.js +6 -8
  45. package/dist/core/flow-base-css.generated.js +1 -1
  46. package/dist/core/html.d.ts +4 -1
  47. package/dist/core/html.js +11 -10
  48. package/dist/core/icons.d.ts +3 -0
  49. package/dist/core/icons.js +3 -0
  50. package/dist/core/json-tools.d.ts +1 -0
  51. package/dist/core/json-tools.js +12 -0
  52. package/dist/core/language.js +5 -2
  53. package/dist/core/markdown.js +3 -1
  54. package/dist/core/previewers.d.ts +8 -0
  55. package/dist/core/previewers.js +2 -0
  56. package/dist/core/routing.d.ts +5 -2
  57. package/dist/core/routing.js +17 -5
  58. package/dist/core/schema-fields.d.ts +13 -0
  59. package/dist/core/schema-fields.js +175 -0
  60. package/dist/core/schema-graph-mount.js +26 -3
  61. package/dist/core/schema-refs.d.ts +8 -0
  62. package/dist/core/schema-refs.js +82 -0
  63. package/dist/core/subformat-record.d.ts +3 -0
  64. package/dist/core/subformat-record.js +131 -0
  65. package/dist/core/subformats.d.ts +43 -0
  66. package/dist/core/subformats.js +81 -0
  67. package/dist/core/toc-ui.js +26 -24
  68. package/dist/edit.global.js +326 -118
  69. package/dist/flow.global.js +3 -3
  70. package/dist/graph/abnfDiagram-S7VZAUFO-ASBULSKE.js +1 -0
  71. package/dist/graph/architecture-WOLXFQ4H-V57EDXXY.js +1 -0
  72. package/dist/graph/architectureDiagram-YGSQEFNW-GIMP347N.js +36 -0
  73. package/dist/graph/blockDiagram-APKKGZFW-RDL2T4JW.js +140 -0
  74. package/dist/graph/bpmnIcons-APHXDYXF-TWOSQNUQ.js +1 -0
  75. package/dist/graph/c4Diagram-KJ2TOQU5-75LIUC4F.js +38 -0
  76. package/dist/graph/chunk-26TUJSYJ.js +1 -0
  77. package/dist/graph/chunk-3LU66YMI.js +1 -0
  78. package/dist/graph/chunk-3RNHDNP5.js +1 -0
  79. package/dist/graph/chunk-3Y2PDVDE.js +1 -0
  80. package/dist/graph/chunk-3YJHMOOA.js +3 -0
  81. package/dist/graph/chunk-4KILFWYV.js +339 -0
  82. package/dist/graph/chunk-4QDE4SUK.js +1 -0
  83. package/dist/graph/chunk-5OO6DATX.js +1 -0
  84. package/dist/graph/chunk-5UUEAHTN.js +1 -0
  85. package/dist/graph/chunk-6T55RVVR.js +1 -0
  86. package/dist/graph/chunk-ARAJTKOH.js +2 -0
  87. package/dist/graph/chunk-BBD5CEDC.js +72 -0
  88. package/dist/graph/chunk-BVXT562I.js +1 -0
  89. package/dist/graph/chunk-BZAMCJ6B.js +32 -0
  90. package/dist/graph/chunk-C6J4A356.js +15 -0
  91. package/dist/graph/chunk-EG5UVNOC.js +213 -0
  92. package/dist/graph/chunk-GF4TOPUK.js +1 -0
  93. package/dist/graph/chunk-GYT4IYBZ.js +1 -0
  94. package/dist/graph/chunk-HJG2HUYJ.js +88 -0
  95. package/dist/graph/chunk-HOPPTA6H.js +62 -0
  96. package/dist/graph/chunk-I3DMZIHV.js +1 -0
  97. package/dist/graph/chunk-IC23EEF6.js +1 -0
  98. package/dist/graph/chunk-ISO77HML.js +1 -0
  99. package/dist/graph/chunk-JD7ZBJD2.js +1 -0
  100. package/dist/graph/chunk-JRSH5GNS.js +1 -0
  101. package/dist/graph/chunk-JSHWCPFJ.js +1 -0
  102. package/dist/graph/chunk-K2KLZU7M.js +10 -0
  103. package/dist/graph/chunk-K4I76XBX.js +14 -0
  104. package/dist/graph/chunk-KT4VPQD5.js +135 -0
  105. package/dist/graph/chunk-KU6GTEMS.js +1 -0
  106. package/dist/graph/chunk-LT6LXKCR.js +136 -0
  107. package/dist/graph/chunk-MPR575IN.js +1 -0
  108. package/dist/graph/chunk-N3OHKGRZ.js +1 -0
  109. package/dist/graph/chunk-O656ZI37.js +1 -0
  110. package/dist/graph/chunk-OFZLK5G4.js +1 -0
  111. package/dist/graph/chunk-PDH25ALM.js +2 -0
  112. package/dist/graph/chunk-PW2RGZ3O.js +1 -0
  113. package/dist/graph/chunk-QCJUF4YA.js +1 -0
  114. package/dist/graph/chunk-QEEA3KYY.js +2 -0
  115. package/dist/graph/chunk-QYAXYFNI.js +1 -0
  116. package/dist/graph/chunk-QYTM6GY3.js +1 -0
  117. package/dist/graph/chunk-R63JUMUK.js +1 -0
  118. package/dist/graph/chunk-SCEY3ZPT.js +1 -0
  119. package/dist/graph/chunk-VM2H7G2R.js +1 -0
  120. package/dist/graph/chunk-XQS73SBQ.js +1 -0
  121. package/dist/graph/chunk-YCRLJT2S.js +1 -0
  122. package/dist/graph/chunk-Z4FIZ7CR.js +1 -0
  123. package/dist/graph/chunk-ZMCB7VP2.js +1 -0
  124. package/dist/graph/chunk-ZSZXN4BT.js +2 -0
  125. package/dist/graph/classDiagram-v2-L25IHNXF-JL7LVDZH.js +217 -0
  126. package/dist/graph/cose-bilkent-JH36ORCC-PNM3EYPB.js +1 -0
  127. package/dist/graph/cynefin-EF2NZ3EQ-PSXP3DXL.js +1 -0
  128. package/dist/graph/cynefinDiagram-L36ESFBY-QVY54CXO.js +62 -0
  129. package/dist/graph/dagre-SPEB5RXH-HPGQXBZJ.js +4 -0
  130. package/dist/graph/diagram-3B7GL73J-DWH5WS2P.js +200 -0
  131. package/dist/graph/diagram-DNEMPZML-TEGH2U5I.js +24 -0
  132. package/dist/graph/diagram-L3MUGCDN-X4MREUWR.js +41 -0
  133. package/dist/graph/diagram-LA4NIPWU-NXT746HG.js +24 -0
  134. package/dist/graph/diagram-MHCOC4E2-JGHXSAGS.js +3 -0
  135. package/dist/graph/diagram-XPFHEONP-ZHZPBLT4.js +30 -0
  136. package/dist/graph/ebnfDiagram-UZSYDL2S-SMF6KJ43.js +1 -0
  137. package/dist/graph/elk-XV6XMXQE-AZ4HLCWI.js +27 -0
  138. package/dist/graph/erDiagram-EYBAPDEH-B3JNJ357.js +99 -0
  139. package/dist/graph/eventmodeling-K75KTNOO-WG6DDYMC.js +1 -0
  140. package/dist/graph/flowDiagram-MALGAFMO-2R7EYAQI.js +1 -0
  141. package/dist/graph/ganttDiagram-23REXITY-YXBYWFOJ.js +292 -0
  142. package/dist/graph/gitGraph-VSP46ZUC-VBFWJBBT.js +1 -0
  143. package/dist/graph/gitGraphDiagram-STJD7YCW-4FZDCFGV.js +106 -0
  144. package/dist/graph/info-OHQRW6UA-ALVDUVYV.js +1 -0
  145. package/dist/graph/infoDiagram-KBXO4MBG-7EHX2GQG.js +2 -0
  146. package/dist/graph/ishikawaDiagram-M35NCXHK-FRZD2PWQ.js +70 -0
  147. package/dist/graph/journeyDiagram-OPLOXDXO-7Z66JCPR.js +139 -0
  148. package/dist/graph/kanban-definition-BZKZHSQY-NN5AIKTE.js +89 -0
  149. package/dist/graph/katex-DXDNVO6V.js +257 -0
  150. package/dist/graph/mindmap-definition-I2QAS2VK-HDPCABN2.js +98 -0
  151. package/dist/graph/packet-JDAUHWVQ-5MQIBWAH.js +1 -0
  152. package/dist/graph/pegDiagram-FD4XPPHP-H2BFNCKT.js +1 -0
  153. package/dist/graph/pie-XZMESJXO-T5VRKHVT.js +1 -0
  154. package/dist/graph/pieDiagram-J4AKIIQI-O3NJSVD3.js +39 -0
  155. package/dist/graph/quadrantDiagram-XTYBLID2-TMTZJI3P.js +7 -0
  156. package/dist/graph/radar-ABXABTNO-C6FXIBYW.js +1 -0
  157. package/dist/graph/railroad-I3PHUGI6-ZSO5JXB3.js +1 -0
  158. package/dist/graph/railroad-abnf-LNEFI6M7-CI4GQRHB.js +1 -0
  159. package/dist/graph/railroad-ebnf-DWYD2UWJ-MUENNCGK.js +1 -0
  160. package/dist/graph/railroad-peg-JR7BVNR7-N3X5GGIX.js +1 -0
  161. package/dist/graph/railroadDiagram-MRQ6NCDL-JHWS23UO.js +1 -0
  162. package/dist/graph/requirementDiagram-Y7LWUY3S-7DVLPO4B.js +84 -0
  163. package/dist/graph/sankeyDiagram-WGJFYUXA-Z5L4R5TR.js +40 -0
  164. package/dist/graph/schema-graph-global.js +639 -0
  165. package/dist/graph/sequenceDiagram-5NDRBG5M-RCTU25NT.js +169 -0
  166. package/dist/graph/sizeCapture-INFHLROL-RROY32P5.js +1 -0
  167. package/dist/graph/stateDiagram-v2-FJ4FJNEA-BXUSPWDK.js +291 -0
  168. package/dist/graph/swimlanes-UMQ2AFYF-LDD74Q2S.js +1 -0
  169. package/dist/graph/swimlanesDiagram-OMPLPG4O-ZYULLJSU.js +8 -0
  170. package/dist/graph/timeline-definition-SEUHKTQE-ZQSMIVAS.js +120 -0
  171. package/dist/graph/treeView-D4JQ5SDB-42S7U73N.js +1 -0
  172. package/dist/graph/treemap-SAJKECNS-RUBYQ7XF.js +1 -0
  173. package/dist/graph/usecaseDiagram-AFA6YXN4-57RDRYXF.js +370 -0
  174. package/dist/graph/vennDiagram-NNMJR3RB-5C3LVAV6.js +34 -0
  175. package/dist/graph/wardley-7MLQ67FV-NV5HXTTC.js +1 -0
  176. package/dist/graph/wardleyDiagram-S7YFUSEH-6D5BKXHM.js +78 -0
  177. package/dist/graph/xychartDiagram-GGNKY7IX-6ET3ZM67.js +7 -0
  178. package/dist/mcp.js +54 -12
  179. package/dist/plugins/index.d.ts +1 -0
  180. package/dist/plugins/transport.d.ts +22 -0
  181. package/dist/plugins/transport.js +1 -0
  182. package/dist/plugins.global.js +95 -0
  183. package/dist/subformats.global.js +21 -0
  184. package/dist/ui.global.js +80 -60
  185. package/dist/viewer/build-plugins.d.ts +7 -0
  186. package/dist/viewer/build-plugins.js +70 -0
  187. package/dist/viewer/build.d.ts +11 -0
  188. package/dist/viewer/build.js +52 -11
  189. package/dist/viewer/code-file.js +7 -2
  190. package/dist/viewer/editor-tools.d.ts +7 -7
  191. package/dist/viewer/editor-tools.js +36 -5
  192. package/dist/viewer/figure-preview.d.ts +4 -0
  193. package/dist/viewer/figure-preview.js +54 -0
  194. package/dist/viewer/font-picker.js +5 -1
  195. package/dist/viewer/git-diff.d.ts +3 -0
  196. package/dist/viewer/git-diff.js +47 -0
  197. package/dist/viewer/hmr.js +8 -4
  198. package/dist/viewer/i18n.js +7 -5
  199. package/dist/viewer/language-picker.d.ts +2 -2
  200. package/dist/viewer/language-picker.js +26 -9
  201. package/dist/viewer/lazy-preview.d.ts +2 -0
  202. package/dist/viewer/lazy-preview.js +43 -0
  203. package/dist/viewer/locales/eng.json +95 -10
  204. package/dist/viewer/locales/jpn.json +96 -11
  205. package/dist/viewer/locales/zho.json +96 -11
  206. package/dist/viewer/nav-focus.js +8 -1
  207. package/dist/viewer/nav-update.d.ts +2 -0
  208. package/dist/viewer/nav-update.js +117 -0
  209. package/dist/viewer/plugin-blocks.js +1 -1
  210. package/dist/viewer/plugin-style.d.ts +1 -0
  211. package/dist/viewer/plugin-style.js +82 -0
  212. package/dist/viewer/plugins.js +1 -1
  213. package/dist/viewer/resize.d.ts +0 -2
  214. package/dist/viewer/resize.js +2 -98
  215. package/dist/viewer/resource-library.d.ts +11 -9
  216. package/dist/viewer/resource-library.js +181 -31
  217. package/dist/viewer/search.d.ts +4 -2
  218. package/dist/viewer/search.js +252 -53
  219. package/dist/viewer/serve.d.ts +11 -5
  220. package/dist/viewer/serve.js +913 -295
  221. package/dist/viewer/site-icon.js +13 -6
  222. package/dist/viewer/site-title.js +15 -2
  223. package/dist/viewer/textfile.d.ts +5 -0
  224. package/dist/viewer/textfile.js +34 -2
  225. package/dist/viewer/theme-picker.d.ts +2 -0
  226. package/dist/viewer/theme-picker.js +24 -8
  227. package/dist/viewer/workspace.d.ts +2 -0
  228. package/dist/viewer/workspace.js +46 -1
  229. package/package.json +27 -10
  230. package/dist/compiler/bundle.d.ts +0 -2
  231. package/dist/compiler/bundle.js +0 -100
@@ -0,0 +1 @@
1
+ export declare const PLUGIN_BLOCK_CSS = "\n.plugin-content :is(th, td) { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--doc-border, #dde3eb); }\n.plugin-content th { background: var(--doc-bg-2, #f6f8fb); color: var(--doc-fg-2, #2a3140); font-size: 12px; font-weight: 600; }\n.plugin-content tr:last-child td { border-bottom: 0; }\n.plugin-blocks { font: inherit; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }\n.plugin-blocks > :first-child, .plugin-block-columns > div > :first-child { margin-top: 0; }\n.plugin-blocks .plugin-block-heading { margin: 0 0 8px; padding: 0; border: 0; font: inherit; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--doc-fg, #000000); }\n.plugin-block-text { margin: 8px 0; white-space: pre-wrap; }\n.plugin-block-text:has(p, pre, ul, ol) { white-space: normal; }\n.plugin-blocks p { margin: 4px 0; white-space: pre-wrap; }\n.plugin-blocks :is(ul, ol) { margin: 6px 0; padding-left: 22px; }\n.plugin-blocks > :last-child { margin-bottom: 0; }\n.plugin-blocks strong { font-weight: 600; }\n.plugin-blocks a { color: var(--doc-accent, #1b4994); text-underline-offset: 3px; }\n.plugin-blocks code { font-family: var(--doc-mono, ui-monospace, monospace); }\n.plugin-block-context { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0; color: var(--doc-fg-3, #5b6271); font-size: 11px; }\n.plugin-block-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 16px; margin: 8px 0; }\n.plugin-block-fields > div { min-width: 0; }\n.plugin-block-fields dt { color: var(--doc-fg-3, #5b6271); font-size: 10px; margin-bottom: 1px; }\n.plugin-block-fields dd { margin: 0; min-height: 20px; font-size: 12px; }\n.plugin-block-columns { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }\n.plugin-block-columns > div, .plugin-block-columns aside { min-width: 0; }\n.plugin-block-columns aside { border-left: 1px solid var(--doc-border, #dde3eb); padding-left: 12px; }\n.plugin-block-columns aside .plugin-block-fields { grid-template-columns: 1fr; margin-top: 0; }\n.plugin-block-section { border-top: 1px solid var(--doc-border, #dde3eb); padding-top: 6px; margin: 10px 0 0; min-width: 0; }\n.plugin-block-section > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--doc-fg-2, #2a3140); padding: 4px 0; }\n.plugin-block-note { color: var(--doc-warn, #b97600); font-size: 11px; border-left: 2px solid currentColor; padding-left: 10px; }\n.plugin-block-table { overflow: auto; width: 100%; margin: 8px 0; }\n.plugin-block-table table { width: 100%; border-collapse: collapse; font-size: 12px; }\n.plugin-block-table :is(th, td) { padding: 5px 8px; min-width: 72px; max-width: 320px; vertical-align: top; }\n.plugin-blocks .plugin-block-code { font: 12px/1.65 var(--doc-mono, ui-monospace, monospace); padding: 12px; margin: 10px 0; border: 1px solid var(--doc-border, #dde3eb); border-radius: 6px; max-height: 400px; overflow: auto; white-space: pre-wrap; }\n.plugin-block-diff code > span { display: inline-block; min-width: 100%; }\n.plugin-block-diff [data-tone=\"success\"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 8%, transparent); }\n.plugin-block-diff [data-tone=\"danger\"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 8%, transparent); }\n.plugin-block-message { padding: 8px 0; border-bottom: 1px solid var(--doc-border, #dde3eb); }\n.plugin-block-message:last-child { border-bottom: 0; }\n.plugin-message-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n.plugin-message-byline > span:not(.plugin-avatar, .plugin-message-actions) { color: var(--doc-fg-3, #5b6271); font-size: 10px; }\n.plugin-avatar { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 12%, var(--doc-bg, #ffffff)); font-size: 10px; }\n.plugin-task { display: flex; align-items: baseline; gap: 8px; list-style: none; }\n.plugin-message-actions svg { display: block; width: 14px; height: 14px; }\n.plugin-message-actions .plugin-block-button { padding: 4px; border: 0; color: var(--doc-fg-3, #5b6271); }\n.plugin-message-actions { margin-left: auto; display: flex; gap: 4px; }\n.plugin-message-body, .plugin-reactions { margin: 4px 0 0 32px; }\n.plugin-reactions { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; }\n.plugin-reactions button { font: inherit; padding: 2px 8px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 12px; background: transparent; color: var(--doc-fg-2, #2a3140); cursor: pointer; }\n.plugin-reactions [aria-pressed=\"true\"] { border-color: var(--doc-accent, #1b4994); color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 8%, transparent); }\n.plugin-badge { display: inline-flex; padding: 1px 7px; border-radius: 5px; font-size: 11px; color: var(--doc-fg-2, #2a3140); background: var(--doc-bg-2, #f6f8fb); }\n.plugin-badge[data-tone=\"accent\"] { color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 10%, var(--doc-bg, #ffffff)); }\n.plugin-badge[data-tone=\"success\"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 10%, var(--doc-bg, #ffffff)); }\n.plugin-badge[data-tone=\"warning\"] { color: var(--doc-warn, #b97600); background: color-mix(in srgb, var(--doc-warn, #b97600) 10%, var(--doc-bg, #ffffff)); }\n.plugin-badge[data-tone=\"danger\"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 10%, var(--doc-bg, #ffffff)); }\n.plugin-copy-value { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; }\n.plugin-copy { width: 22px; height: 22px; padding: 3px; border: 0; background: transparent; color: var(--doc-fg-3, #5b6271); cursor: pointer; flex: none; }\n.plugin-copy svg { width: 14px; height: 14px; }\n.plugin-block-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--doc-fg-3, #5b6271); margin: 12px 0; }\n.plugin-block-progress progress { flex: 1; width: 0; height: 6px; accent-color: var(--doc-accent, #1b4994); }\n.plugin-block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }\n.plugin-block-actions:has([data-block-composer]) { display: block; }\n.plugin-block-button { font: inherit; font-size: 12px; padding: 5px 10px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 5px; color: var(--doc-fg, #000000); background: transparent; cursor: pointer; }\n.plugin-block-button:hover { background: var(--doc-bg-2, #f6f8fb); }\n.plugin-block-button:disabled { opacity: .5; cursor: wait; }\n.plugin-action[aria-pressed=\"true\"] { color: var(--doc-accent, #1b4994); background: var(--doc-bg-2, #f6f8fb); }\n.plugin-danger { color: var(--doc-danger, #b53030); }\n.plugin [data-plugin-edit-trigger]:focus-visible, .plugin :is(button, summary, input, select, textarea):focus-visible, .plugin-block-table:focus-visible { outline: 2px solid var(--doc-accent, #1b4994); outline-offset: 2px; }\n.plugin-editor { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font: inherit; font-size: 12px; line-height: 1.5; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); min-width: 0; }\n.plugin-editor label { display: grid; gap: 0; font-size: 0; }\n.plugin-editor :is(input, textarea, select) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; padding: 3px 6px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 4px; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); font: inherit; font-size: 12px; line-height: 1.5; }\n.plugin-editor textarea { resize: vertical; min-height: 54px; max-height: 40vh; }\n.plugin-editor .plugin-submit { background: var(--doc-accent, #1b4994); color: var(--doc-accent-fg, #ffffff); border-color: transparent; }\n.plugin-editor-notice { color: var(--doc-danger, #b53030); font-size: 11px; }\n.plugin-editor-notice:empty { display: none; }\n.plugin [hidden] { display: none !important; }\n@container (max-width: 600px) {\n .plugin-block-columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }\n .plugin-block-columns aside { border-left: 0; border-top: 1px solid var(--doc-border, #dde3eb); padding: 14px 0 0; }\n .plugin-block-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n .plugin-heading-context { display: none; }\n .plugin-blocks .plugin-block-heading { font-size: 16px; }\n .plugin-message-body, .plugin-reactions { margin-left: 0; }\n}\n";
@@ -0,0 +1,82 @@
1
+ export const PLUGIN_BLOCK_CSS = `
2
+ .plugin-content :is(th, td) { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--doc-border, #dde3eb); }
3
+ .plugin-content th { background: var(--doc-bg-2, #f6f8fb); color: var(--doc-fg-2, #2a3140); font-size: 12px; font-weight: 600; }
4
+ .plugin-content tr:last-child td { border-bottom: 0; }
5
+ .plugin-blocks { font: inherit; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
6
+ .plugin-blocks > :first-child, .plugin-block-columns > div > :first-child { margin-top: 0; }
7
+ .plugin-blocks .plugin-block-heading { margin: 0 0 8px; padding: 0; border: 0; font: inherit; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--doc-fg, #000000); }
8
+ .plugin-block-text { margin: 8px 0; white-space: pre-wrap; }
9
+ .plugin-block-text:has(p, pre, ul, ol) { white-space: normal; }
10
+ .plugin-blocks p { margin: 4px 0; white-space: pre-wrap; }
11
+ .plugin-blocks :is(ul, ol) { margin: 6px 0; padding-left: 22px; }
12
+ .plugin-blocks > :last-child { margin-bottom: 0; }
13
+ .plugin-blocks strong { font-weight: 600; }
14
+ .plugin-blocks a { color: var(--doc-accent, #1b4994); text-underline-offset: 3px; }
15
+ .plugin-blocks code { font-family: var(--doc-mono, ui-monospace, monospace); }
16
+ .plugin-block-context { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0; color: var(--doc-fg-3, #5b6271); font-size: 11px; }
17
+ .plugin-block-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 16px; margin: 8px 0; }
18
+ .plugin-block-fields > div { min-width: 0; }
19
+ .plugin-block-fields dt { color: var(--doc-fg-3, #5b6271); font-size: 10px; margin-bottom: 1px; }
20
+ .plugin-block-fields dd { margin: 0; min-height: 20px; font-size: 12px; }
21
+ .plugin-block-columns { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }
22
+ .plugin-block-columns > div, .plugin-block-columns aside { min-width: 0; }
23
+ .plugin-block-columns aside { border-left: 1px solid var(--doc-border, #dde3eb); padding-left: 12px; }
24
+ .plugin-block-columns aside .plugin-block-fields { grid-template-columns: 1fr; margin-top: 0; }
25
+ .plugin-block-section { border-top: 1px solid var(--doc-border, #dde3eb); padding-top: 6px; margin: 10px 0 0; min-width: 0; }
26
+ .plugin-block-section > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--doc-fg-2, #2a3140); padding: 4px 0; }
27
+ .plugin-block-note { color: var(--doc-warn, #b97600); font-size: 11px; border-left: 2px solid currentColor; padding-left: 10px; }
28
+ .plugin-block-table { overflow: auto; width: 100%; margin: 8px 0; }
29
+ .plugin-block-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
30
+ .plugin-block-table :is(th, td) { padding: 5px 8px; min-width: 72px; max-width: 320px; vertical-align: top; }
31
+ .plugin-blocks .plugin-block-code { font: 12px/1.65 var(--doc-mono, ui-monospace, monospace); padding: 12px; margin: 10px 0; border: 1px solid var(--doc-border, #dde3eb); border-radius: 6px; max-height: 400px; overflow: auto; white-space: pre-wrap; }
32
+ .plugin-block-diff code > span { display: inline-block; min-width: 100%; }
33
+ .plugin-block-diff [data-tone="success"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 8%, transparent); }
34
+ .plugin-block-diff [data-tone="danger"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 8%, transparent); }
35
+ .plugin-block-message { padding: 8px 0; border-bottom: 1px solid var(--doc-border, #dde3eb); }
36
+ .plugin-block-message:last-child { border-bottom: 0; }
37
+ .plugin-message-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
38
+ .plugin-message-byline > span:not(.plugin-avatar, .plugin-message-actions) { color: var(--doc-fg-3, #5b6271); font-size: 10px; }
39
+ .plugin-avatar { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 12%, var(--doc-bg, #ffffff)); font-size: 10px; }
40
+ .plugin-task { display: flex; align-items: baseline; gap: 8px; list-style: none; }
41
+ .plugin-message-actions svg { display: block; width: 14px; height: 14px; }
42
+ .plugin-message-actions .plugin-block-button { padding: 4px; border: 0; color: var(--doc-fg-3, #5b6271); }
43
+ .plugin-message-actions { margin-left: auto; display: flex; gap: 4px; }
44
+ .plugin-message-body, .plugin-reactions { margin: 4px 0 0 32px; }
45
+ .plugin-reactions { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; }
46
+ .plugin-reactions button { font: inherit; padding: 2px 8px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 12px; background: transparent; color: var(--doc-fg-2, #2a3140); cursor: pointer; }
47
+ .plugin-reactions [aria-pressed="true"] { border-color: var(--doc-accent, #1b4994); color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 8%, transparent); }
48
+ .plugin-badge { display: inline-flex; padding: 1px 7px; border-radius: 5px; font-size: 11px; color: var(--doc-fg-2, #2a3140); background: var(--doc-bg-2, #f6f8fb); }
49
+ .plugin-badge[data-tone="accent"] { color: var(--doc-accent, #1b4994); background: color-mix(in srgb, var(--doc-accent, #1b4994) 10%, var(--doc-bg, #ffffff)); }
50
+ .plugin-badge[data-tone="success"] { color: var(--doc-ok, #1f7a32); background: color-mix(in srgb, var(--doc-ok, #1f7a32) 10%, var(--doc-bg, #ffffff)); }
51
+ .plugin-badge[data-tone="warning"] { color: var(--doc-warn, #b97600); background: color-mix(in srgb, var(--doc-warn, #b97600) 10%, var(--doc-bg, #ffffff)); }
52
+ .plugin-badge[data-tone="danger"] { color: var(--doc-danger, #b53030); background: color-mix(in srgb, var(--doc-danger, #b53030) 10%, var(--doc-bg, #ffffff)); }
53
+ .plugin-copy-value { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; }
54
+ .plugin-copy { width: 22px; height: 22px; padding: 3px; border: 0; background: transparent; color: var(--doc-fg-3, #5b6271); cursor: pointer; flex: none; }
55
+ .plugin-copy svg { width: 14px; height: 14px; }
56
+ .plugin-block-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--doc-fg-3, #5b6271); margin: 12px 0; }
57
+ .plugin-block-progress progress { flex: 1; width: 0; height: 6px; accent-color: var(--doc-accent, #1b4994); }
58
+ .plugin-block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
59
+ .plugin-block-actions:has([data-block-composer]) { display: block; }
60
+ .plugin-block-button { font: inherit; font-size: 12px; padding: 5px 10px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 5px; color: var(--doc-fg, #000000); background: transparent; cursor: pointer; }
61
+ .plugin-block-button:hover { background: var(--doc-bg-2, #f6f8fb); }
62
+ .plugin-block-button:disabled { opacity: .5; cursor: wait; }
63
+ .plugin-action[aria-pressed="true"] { color: var(--doc-accent, #1b4994); background: var(--doc-bg-2, #f6f8fb); }
64
+ .plugin-danger { color: var(--doc-danger, #b53030); }
65
+ .plugin [data-plugin-edit-trigger]:focus-visible, .plugin :is(button, summary, input, select, textarea):focus-visible, .plugin-block-table:focus-visible { outline: 2px solid var(--doc-accent, #1b4994); outline-offset: 2px; }
66
+ .plugin-editor { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font: inherit; font-size: 12px; line-height: 1.5; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); min-width: 0; }
67
+ .plugin-editor label { display: grid; gap: 0; font-size: 0; }
68
+ .plugin-editor :is(input, textarea, select) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; padding: 3px 6px; border: 1px solid var(--doc-border, #dde3eb); border-radius: 4px; color: var(--doc-fg, #000000); background: var(--doc-bg, #ffffff); font: inherit; font-size: 12px; line-height: 1.5; }
69
+ .plugin-editor textarea { resize: vertical; min-height: 54px; max-height: 40vh; }
70
+ .plugin-editor .plugin-submit { background: var(--doc-accent, #1b4994); color: var(--doc-accent-fg, #ffffff); border-color: transparent; }
71
+ .plugin-editor-notice { color: var(--doc-danger, #b53030); font-size: 11px; }
72
+ .plugin-editor-notice:empty { display: none; }
73
+ .plugin [hidden] { display: none !important; }
74
+ @container (max-width: 600px) {
75
+ .plugin-block-columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }
76
+ .plugin-block-columns aside { border-left: 0; border-top: 1px solid var(--doc-border, #dde3eb); padding: 14px 0 0; }
77
+ .plugin-block-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
78
+ .plugin-heading-context { display: none; }
79
+ .plugin-blocks .plugin-block-heading { font-size: 16px; }
80
+ .plugin-message-body, .plugin-reactions { margin-left: 0; }
81
+ }
82
+ `;
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- import { escapeHtml } from "../core/html.js";
2
+ import { escapeHtml } from "../core/escape-html.js";
3
3
  import { isPluginError, PluginError } from "../plugins/oauth.js";
4
4
  import { createPluginRuntime } from "../plugins/runtime.js";
5
5
  import { isLocalToolRequest } from "./editor-tools.js";
@@ -1,4 +1,2 @@
1
1
  /** Shared by editor, preview, and published pages; keep this function self-contained. */
2
2
  export declare const mountPanelResize: () => void;
3
- /** The navigation is replaced on refresh; keep listeners and height on its stable sidebar. */
4
- export declare const mountToolsResize: () => (() => void);
@@ -37,6 +37,8 @@ export const mountPanelResize = () => {
37
37
  }
38
38
  const property = options.direction === 1 ? "--sidebar-width" : "--panel-width";
39
39
  const requested = () => preferred ?? (options.direction === 1 ? 260 : Math.min(760, window.innerWidth * 0.52));
40
+ if (options.direction === 1 && closed())
41
+ element.style.setProperty(property, `${requested()}px`);
40
42
  const apply = (width) => {
41
43
  const other = options.direction === 1 ? editor : sidebar;
42
44
  const max = Math.max(0, Math.min(options.max, window.innerWidth -
@@ -138,101 +140,3 @@ export const mountPanelResize = () => {
138
140
  });
139
141
  layout();
140
142
  };
141
- /** The navigation is replaced on refresh; keep listeners and height on its stable sidebar. */
142
- export const mountToolsResize = () => {
143
- const sidebar = document.getElementById("sidebar");
144
- if (!sidebar || !document.getElementById("nav-tools"))
145
- return () => { };
146
- const key = "docs:tools-height";
147
- let preferred;
148
- try {
149
- const saved = Number(localStorage.getItem(key));
150
- if (Number.isFinite(saved) && saved > 0)
151
- preferred = saved;
152
- }
153
- catch {
154
- /* Persistence is optional. */
155
- }
156
- const apply = (height = preferred ?? Math.min(220, innerHeight * 0.4)) => {
157
- const handle = document.getElementById("tools-resize");
158
- if (!handle)
159
- return;
160
- const max = Math.max(80, sidebar.clientHeight - 100);
161
- const min = Math.min(144, max);
162
- const value = Math.round(Math.max(min, Math.min(height, max)));
163
- sidebar.style.setProperty("--tools-height", `${value}px`);
164
- handle.setAttribute("aria-valuemin", String(min));
165
- handle.setAttribute("aria-valuemax", String(max));
166
- handle.setAttribute("aria-valuenow", String(value));
167
- };
168
- const persist = () => {
169
- preferred = Number.parseFloat(sidebar.style.getPropertyValue("--tools-height"));
170
- try {
171
- localStorage.setItem(key, String(preferred));
172
- }
173
- catch {
174
- /* Optional. */
175
- }
176
- };
177
- const isHandle = (event) => event.target instanceof Element && !!event.target.closest("#tools-resize");
178
- const height = () => document.getElementById("nav-tools")?.getBoundingClientRect().height ?? 0;
179
- let drag;
180
- sidebar.addEventListener("pointerdown", (event) => {
181
- if (!isHandle(event) || event.button !== 0 || drag)
182
- return;
183
- const handle = document.getElementById("tools-resize");
184
- if (!handle)
185
- return;
186
- event.preventDefault();
187
- handle.focus({ preventScroll: true });
188
- drag = { id: event.pointerId, y: event.clientY, height: height(), handle };
189
- handle.setPointerCapture(event.pointerId);
190
- document.body.classList.add("resizing-tools");
191
- });
192
- sidebar.addEventListener("pointermove", (event) => {
193
- if (drag?.id === event.pointerId)
194
- apply(drag.height + drag.y - event.clientY);
195
- });
196
- const stop = () => {
197
- if (!drag)
198
- return;
199
- drag = undefined;
200
- document.body.classList.remove("resizing-tools");
201
- persist();
202
- };
203
- for (const type of ["pointerup", "pointercancel", "lostpointercapture"])
204
- sidebar.addEventListener(type, (event) => {
205
- if (drag?.id === event.pointerId)
206
- stop();
207
- });
208
- sidebar.addEventListener("keydown", (event) => {
209
- if (!isHandle(event) || (event.key !== "ArrowUp" && event.key !== "ArrowDown"))
210
- return;
211
- event.preventDefault();
212
- apply(height() + (event.key === "ArrowUp" ? 20 : -20));
213
- persist();
214
- });
215
- sidebar.addEventListener("dblclick", (event) => {
216
- if (!isHandle(event))
217
- return;
218
- preferred = undefined;
219
- try {
220
- localStorage.removeItem(key);
221
- }
222
- catch {
223
- /* Optional. */
224
- }
225
- apply();
226
- });
227
- window.addEventListener("resize", () => apply());
228
- const restore = () => {
229
- if (drag && !drag.handle.isConnected)
230
- stop();
231
- apply();
232
- };
233
- const nav = document.getElementById("nav-groups");
234
- if (nav)
235
- new MutationObserver(restore).observe(nav, { childList: true });
236
- restore();
237
- return restore;
238
- };
@@ -1,29 +1,31 @@
1
- import type { TermEntry } from "../core/content-types.js";
1
+ import { type SubformatCollection } from "../core/subformats.js";
2
2
  interface SourceLocation {
3
3
  file: string;
4
4
  line: number;
5
5
  }
6
6
  export interface ResourceIndex {
7
- terms: {
8
- entry: TermEntry;
9
- source: SourceLocation;
10
- }[];
11
- code: {
7
+ codeblocks: {
12
8
  language: string;
9
+ format: string;
13
10
  caption: string;
14
11
  content: string;
15
12
  source: SourceLocation;
13
+ reference?: SourceLocation & {
14
+ range?: string;
15
+ };
16
16
  }[];
17
17
  urls: {
18
18
  url: string;
19
19
  host: string;
20
20
  sources: SourceLocation[];
21
21
  }[];
22
+ urlPreviews: ResourceIndex["urls"];
23
+ subformats: SubformatCollection[];
22
24
  errors: string[];
23
25
  }
24
26
  /** Index authored content, including files not referenced by any document. */
25
- export declare const resourceIndex: (root: string, files: readonly string[]) => ResourceIndex;
26
- export type ResourceView = "files" | "dictionary" | "code" | "urls";
27
+ export declare const resourceIndex: (root: string, files: readonly string[], domains?: readonly string[]) => ResourceIndex;
28
+ export type ResourceView = "files" | "codeblocks" | "urls" | "url-previews";
27
29
  export declare const resourceTabs: (view: ResourceView) => string;
28
- export declare const resourceLibraryHtml: (index: ResourceIndex, view: Exclude<ResourceView, "files">) => string;
30
+ export declare const resourceLibraryHtml: (index: ResourceIndex, view: Exclude<ResourceView, "files"> | "subformats", pageTitle?: string) => string;
29
31
  export {};
@@ -1,15 +1,56 @@
1
+ import { basename, extname } from "node:path";
2
+ import { bundledLanguagesInfo } from "shiki/langs";
1
3
  import { visit } from "unist-util-visit";
4
+ import { readManifest } from "../compiler/manifest.js";
5
+ import { loadSubformat, parseSubformatRecord, validateSubformatRecord, } from "../compiler/subformats.js";
2
6
  import { parseTermSource } from "../compiler/terms.js";
3
- import { readTextfile } from "../compiler/textfile.js";
7
+ import { readTextfile, selectTextfileRange } from "../compiler/textfile.js";
8
+ import { parseFileEmbed } from "../core/file-embed.js";
9
+ import { fileExtension, localFile } from "../core/files.js";
4
10
  import { blocksHtml, escapeHtml } from "../core/html.js";
11
+ import { SEARCH_ICON_PATH } from "../core/icons.js";
5
12
  import { parseMdast } from "../core/markdown.js";
13
+ import { subformatChange } from "../core/subformats.js";
14
+ import { parseFileReference, parseTextfileRange } from "../core/textfile.js";
15
+ const codeFormat = (language) => /^(text|txt|plain|plaintext)$/.test(language)
16
+ ? "text"
17
+ : (bundledLanguagesInfo.find((entry) => entry.id === language || entry.aliases?.includes(language))?.id ?? language);
6
18
  /** Index authored content, including files not referenced by any document. */
7
- export const resourceIndex = (root, files) => {
8
- const result = { terms: [], code: [], urls: [], errors: [] };
19
+ export const resourceIndex = (root, files, domains = []) => {
20
+ const result = {
21
+ codeblocks: [],
22
+ urls: [],
23
+ urlPreviews: [],
24
+ subformats: [],
25
+ errors: [],
26
+ };
27
+ const paths = new Set(files);
28
+ const manifest = readManifest(root);
29
+ result.errors.push(...manifest.errors);
30
+ const formats = new Map();
31
+ for (const config of manifest.subformats ?? []) {
32
+ try {
33
+ if (!paths.has(config.schema))
34
+ throw new Error("Schema is not available in the workspace");
35
+ const loaded = loadSubformat(root, config, domains);
36
+ formats.set(config.ext, loaded);
37
+ result.subformats.push({
38
+ ...config,
39
+ fields: loaded.fields,
40
+ template: loaded.template,
41
+ defaultFolder: manifest.defaultSubformatFolder,
42
+ records: [],
43
+ });
44
+ }
45
+ catch (error) {
46
+ result.errors.push(`${config.schema}: ${error instanceof Error ? error.message : String(error)}`);
47
+ }
48
+ }
9
49
  const urls = new Map();
10
- const terms = (raw, source) => {
50
+ const urlPreviews = new Map();
51
+ const references = new Map();
52
+ const validateTerms = (raw, source) => {
11
53
  const parsed = parseTermSource(`${source.file}#L${source.line}`, raw);
12
- result.terms.push(...parsed.entries.map((entry) => ({ entry, source })));
13
54
  result.errors.push(...parsed.errors.map((error) => `${source.file}:L${source.line + error.line}: ${error.message}`));
14
55
  };
15
56
  const scan = (tree, file, offset = 0) => {
@@ -21,14 +62,16 @@ export const resourceIndex = (root, files) => {
21
62
  const source = { file, line: offset + (node.position?.start.line ?? 1) };
22
63
  if (node.type === "code") {
23
64
  const language = node.lang?.toLowerCase() || "text";
24
- result.code.push({
25
- language,
65
+ const format = formats.get(language.replace(/^\./, ""));
66
+ result.codeblocks.push({
67
+ language: format?.format ?? language,
68
+ format: format?.ext ?? codeFormat(language),
26
69
  caption: node.meta ?? "",
27
70
  content: node.value,
28
71
  source,
29
72
  });
30
73
  if (language === "termth")
31
- terms(node.value, { ...source, line: source.line + 1 });
74
+ validateTerms(node.value, { ...source, line: source.line + 1 });
32
75
  if (language === "callouth")
33
76
  scan(parseMdast(node.value), file, source.line);
34
77
  return;
@@ -40,31 +83,104 @@ export const resourceIndex = (root, files) => {
40
83
  : undefined;
41
84
  if (!target)
42
85
  return;
86
+ if (!/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(target)) {
87
+ try {
88
+ const file = parseFileReference(target).file.replace(/^(\.\/)+/, "");
89
+ if (localFile(file) && formats.has(fileExtension(file))) {
90
+ const sources = references.get(file) ?? [];
91
+ sources.push(source);
92
+ references.set(file, sources);
93
+ }
94
+ }
95
+ catch {
96
+ // Invalid references are reported by the compiler.
97
+ }
98
+ }
99
+ const preview = node.type === "image" || node.type === "imageReference";
100
+ if (preview && !/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(target)) {
101
+ try {
102
+ const ref = parseFileEmbed(target);
103
+ if (ref.kind !== "textfile")
104
+ return;
105
+ const referencedFile = ref.file.replace(/^(\.\/)+/, "");
106
+ if (!paths.has(referencedFile))
107
+ throw new Error("File is not available in the workspace");
108
+ const language = (extname(referencedFile).slice(1) || basename(referencedFile)).toLowerCase();
109
+ result.codeblocks.push({
110
+ language: formats.get(language)?.format ?? language,
111
+ format: formats.has(language) ? language : codeFormat(language),
112
+ caption: node.alt ?? "",
113
+ content: selectTextfileRange(readTextfile(root, referencedFile), ref.range),
114
+ source,
115
+ reference: {
116
+ file: referencedFile,
117
+ line: ref.range ? parseTextfileRange(ref.range)[0] : 1,
118
+ ...(ref.range ? { range: ref.range } : {}),
119
+ },
120
+ });
121
+ }
122
+ catch (error) {
123
+ result.errors.push(`${file}:L${source.line}: ${target}: ${error instanceof Error ? error.message : String(error)}`);
124
+ }
125
+ return;
126
+ }
43
127
  try {
44
128
  const url = new URL(target);
45
129
  if (!["http:", "https:", "mailto:"].includes(url.protocol))
46
130
  return;
131
+ const entries = preview ? urlPreviews : urls;
47
132
  const key = url.href;
48
- const entry = urls.get(key) ?? {
133
+ const entry = entries.get(key) ?? {
49
134
  url: key,
50
135
  host: url.host || url.protocol,
51
136
  sources: [],
52
137
  };
53
138
  entry.sources.push(source);
54
- urls.set(key, entry);
139
+ entries.set(key, entry);
55
140
  }
56
141
  catch {
57
142
  // Local paths and anchors are not external URL resources.
58
143
  }
59
144
  });
60
145
  };
61
- for (const file of new Set(files)) {
146
+ for (const file of paths) {
147
+ const format = formats.get(fileExtension(file));
148
+ if (format && !(manifest.subformats ?? []).some((item) => item.schema === file)) {
149
+ try {
150
+ const content = readTextfile(root, file);
151
+ result.codeblocks.push({
152
+ language: format.format,
153
+ format: format.ext,
154
+ caption: file,
155
+ content,
156
+ source: { file, line: 1 },
157
+ });
158
+ const data = parseSubformatRecord(content, format.format);
159
+ validateSubformatRecord(format, data);
160
+ result.subformats
161
+ .find((item) => item.ext === format.ext)
162
+ ?.records.push({ file, content, data });
163
+ }
164
+ catch (error) {
165
+ result.errors.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
166
+ }
167
+ continue;
168
+ }
62
169
  if (!/\.(?:md|termth)$/i.test(file))
63
170
  continue;
64
171
  try {
65
172
  const raw = readTextfile(root, file);
66
- if (/\.termth$/i.test(file))
67
- terms(raw, { file, line: 1 });
173
+ if (/\.termth$/i.test(file)) {
174
+ const source = { file, line: 1 };
175
+ result.codeblocks.push({
176
+ language: "termth",
177
+ format: "termth",
178
+ caption: "",
179
+ content: raw,
180
+ source,
181
+ });
182
+ validateTerms(raw, source);
183
+ }
68
184
  else
69
185
  scan(parseMdast(raw), file);
70
186
  }
@@ -72,33 +188,67 @@ export const resourceIndex = (root, files) => {
72
188
  result.errors.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
73
189
  }
74
190
  }
75
- result.terms.sort((a, b) => a.entry.name.localeCompare(b.entry.name, undefined, { numeric: true }));
76
191
  result.urls = [...urls.values()].sort((a, b) => a.url.localeCompare(b.url));
192
+ result.urlPreviews = [...urlPreviews.values()].sort((a, b) => a.url.localeCompare(b.url));
193
+ for (const collection of result.subformats)
194
+ for (const record of collection.records)
195
+ record.references = references.get(record.file) ?? [];
77
196
  return result;
78
197
  };
79
198
  export const resourceTabs = (view) => view === "files"
80
199
  ? ""
81
200
  : `<nav class="resource-tabs" aria-label="Resource views" data-i18n-aria-label="Resource views">${[
82
- ["dictionary", "Dictionary"],
83
- ["code", "Code blocks"],
201
+ ["codeblocks", "Codeblocks"],
84
202
  ["urls", "URLs"],
203
+ ["url-previews", "URL previews"],
85
204
  ]
86
- .map(([key, label]) => `<a href="/_statics${key === "dictionary" ? "" : `/${key}`}"${view === key ? ' aria-current="page"' : ""} data-i18n="${label}">${label}</a>`)
205
+ .map(([key, label]) => `<a href="/_statics/${key}"${view === key ? ' aria-current="page"' : ""} data-i18n="${label}">${label}</a>`)
87
206
  .join("")}</nav>`;
88
207
  const sourceLink = ({ file, line }) => `<a class="resource-source" href="/_files/file/${encodeURIComponent(file)}#L${line}" data-resource-source="${escapeHtml(file)}" data-resource-line="${line}" title="${escapeHtml(file)}:L${line}"><span class="resource-source-file">${escapeHtml(file)}</span><span>L${line}</span></a>`;
89
- export const resourceLibraryHtml = (index, view) => {
90
- const groupLabel = view === "code" ? "Code language" : "Domain";
91
- const groups = view === "dictionary"
208
+ export const resourceLibraryHtml = (index, view, pageTitle) => {
209
+ const subformatsOnly = view === "subformats";
210
+ const groupLabel = subformatsOnly ? "Subformats" : view === "codeblocks" ? "Format" : "Domain";
211
+ const urls = view === "url-previews" ? index.urlPreviews : index.urls;
212
+ const groups = [
213
+ ...new Set(subformatsOnly
214
+ ? index.subformats.map((item) => item.ext)
215
+ : view === "codeblocks"
216
+ ? [
217
+ ...index.codeblocks.map((item) => item.format),
218
+ ...index.subformats.map((item) => item.ext),
219
+ ]
220
+ : urls.map((item) => item.host)),
221
+ ].sort();
222
+ const items = subformatsOnly
92
223
  ? []
93
- : [
94
- ...new Set(view === "code"
95
- ? index.code.map((item) => item.language)
96
- : index.urls.map((item) => item.host)),
97
- ].sort();
98
- const items = view === "dictionary"
99
- ? index.terms.map(({ entry, source }) => `<details class="resource-item resource-term" data-resource-item><summary><span class="resource-name" title="${escapeHtml(entry.name)}">${escapeHtml(entry.name)}</span>${sourceLink(source)}</summary><div class="resource-body"><p class="term-definition">${escapeHtml(entry.definition)}</p>${entry.description ? `<p class="resource-description">${escapeHtml(entry.description)}</p>` : ""}</div></details>`)
100
- : view === "code"
101
- ? index.code.map(({ language, caption, content, source }) => `<details class="resource-item resource-code" data-resource-item data-resource-group="${escapeHtml(language)}"><summary><span class="resource-badge">${escapeHtml(language)}</span>${caption ? `<span class="resource-name" title="${escapeHtml(caption)}">${escapeHtml(caption)}</span>` : ""}${sourceLink(source)}</summary><div class="resource-body">${blocksHtml([{ type: "code", lang: language === "mermaid" ? "text" : language, lines: content.split("\n") }])}</div></details>`)
102
- : index.urls.map(({ url, host, sources }) => `<details class="resource-item resource-url" data-resource-item data-resource-group="${escapeHtml(host)}"><summary><a class="resource-name" href="${escapeHtml(url)}" title="${escapeHtml(url)}" target="_blank" rel="noopener noreferrer">${escapeHtml(url)}</a><span class="resource-usage" title="references" data-i18n-title="references">${sources.length}</span></summary><div class="resource-body resource-sources">${sources.map(sourceLink).join("")}</div></details>`);
103
- return `<section class="resource-results" data-resource-results><div class="resource-toolbar"><span data-i18n="Name">Name</span><label class="resource-search"><svg width="13" height="13" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M14 14l4 4M15 9a6 6 0 1 1-12 0 6 6 0 0 1 12 0"/></svg><input type="search" data-resource-search placeholder="Search resources" aria-label="Search resources" data-i18n-placeholder="Search resources" data-i18n-aria-label="Search resources"></label>${groups.length ? `<select data-resource-filter aria-label="${groupLabel}" data-i18n-aria-label="${groupLabel}"><option value="" data-i18n="All">All</option>${groups.map((group) => `<option value="${escapeHtml(group)}">${escapeHtml(group)}</option>`).join("")}</select>` : ""}<span class="resource-count" data-resource-count role="status" aria-live="polite">${items.length}</span></div>${index.errors.length ? `<details class="resource-errors"><summary><span data-i18n="Files with errors">Files with errors</span> (${index.errors.length})</summary><ul>${index.errors.map((error) => `<li>${escapeHtml(error)}</li>`).join("")}</ul></details>` : ""}<div class="resource-items resource-${view}">${items.join("")}</div><p class="resource-empty" data-resource-empty${items.length ? " hidden" : ""} data-i18n="No matching resources">No matching resources</p></section>`;
224
+ : view === "codeblocks"
225
+ ? index.codeblocks.map(({ language, format, caption, content, source, reference }) => {
226
+ const name = caption || (reference ? reference.file + (reference.range ?? "") : "");
227
+ return `<details class="resource-item resource-code" data-resource-item data-resource-group="${escapeHtml(format)}"><summary><span class="resource-badge">${escapeHtml(format)}</span>${name ? `<span class="resource-name" title="${escapeHtml(name)}">${escapeHtml(name)}</span>` : ""}${sourceLink(source)}</summary><div class="resource-body">${reference ? `<div class="resource-sources">${sourceLink(reference)}</div>` : ""}${blocksHtml([{ type: "code", lang: language === "mermaid" ? "text" : language, lines: content.split("\n") }])}</div></details>`;
228
+ })
229
+ : urls.map(({ url, host, sources }) => `<details class="resource-item resource-url" data-resource-item data-resource-group="${escapeHtml(host)}"><summary><a class="resource-name" href="${escapeHtml(url)}" title="${escapeHtml(url)}" target="_blank" rel="noopener noreferrer">${escapeHtml(url)}</a><span class="resource-usage" title="references" data-i18n-title="references">${sources.length}</span></summary><div class="resource-body resource-sources">${sources.map(sourceLink).join("")}</div></details>`);
230
+ const filterGroups = subformatsOnly ? index.subformats.map((item) => item.ext) : groups;
231
+ const selector = filterGroups.length || subformatsOnly
232
+ ? `<select data-resource-filter${subformatsOnly ? " data-subformat-filter hidden" : ""} aria-label="${groupLabel}" data-i18n-aria-label="${groupLabel}">${subformatsOnly ? (filterGroups.length ? "" : '<option value="" data-i18n="Subformats">Subformats</option>') : '<option value="" data-i18n="All">All</option>'}${filterGroups
233
+ .map((group) => {
234
+ const collection = index.subformats.find((item) => item.ext === group);
235
+ const change = collection && subformatChange(collection);
236
+ return `<option value="${escapeHtml(group)}"${change ? ` data-subformat-change="${change}"` : ""}>${escapeHtml(group)}</option>`;
237
+ })
238
+ .join("")}</select>`
239
+ : "";
240
+ const selectedChange = index.subformats[0] && subformatChange(index.subformats[0]);
241
+ const filter = pageTitle !== undefined
242
+ ? `<h1 class="subformat-page-title">${escapeHtml(pageTitle)}</h1>`
243
+ : subformatsOnly
244
+ ? `<div class="subformat-picker">${selector}<button type="button" data-subformat-trigger aria-haspopup="menu" aria-expanded="false"${selectedChange ? ` data-subformat-change="${selectedChange}"` : ""}>${escapeHtml(filterGroups[0] ?? "Subformats")}</button><div class="subformat-picker-menu" data-subformat-options popover="auto" role="menu" aria-label="Subformats" data-i18n-aria-label="Subformats"></div></div>`
245
+ : selector;
246
+ const search = `<label class="resource-search"><svg width="13" height="13" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="${SEARCH_ICON_PATH}"/></svg><input type="search" data-resource-search placeholder="Search resources" aria-label="Search resources" data-i18n-placeholder="Search resources" data-i18n-aria-label="Search resources"></label>`;
247
+ const subformats = subformatsOnly || (view === "codeblocks" && index.subformats.length)
248
+ ? `<template data-subformats>${escapeHtml(JSON.stringify(index.subformats))}</template><div data-subformat-board role="region" hidden></div>`
249
+ : "";
250
+ const emptyMessage = subformatsOnly && !index.subformats.length
251
+ ? "No subformats configured. Add subformats to dooc.yaml."
252
+ : "No matching resources";
253
+ return `<section class="resource-results" data-resource-results${pageTitle !== undefined ? ` data-subformat-page="${escapeHtml(index.subformats[0]?.ext ?? "")}"` : ""}><div class="resource-toolbar">${subformatsOnly ? `<div class="resource-query">${filter}</div>` : `<span data-i18n="Name">Name</span>${search}${filter}`}${subformatsOnly ? "" : `<span class="resource-count" data-resource-count role="status" aria-live="polite">${items.length}</span>`}</div>${subformats}${index.errors.length ? `<details class="resource-errors"><summary><span data-i18n="Files with errors">Files with errors</span> (${index.errors.length})</summary><ul>${index.errors.map((error) => `<li>${escapeHtml(error)}</li>`).join("")}</ul></details>` : ""}<div class="resource-items resource-${view}">${items.join("")}</div><p class="resource-empty" data-resource-empty${items.length ? " hidden" : ""} data-i18n="${emptyMessage}">${emptyMessage}</p></section>`;
104
254
  };
@@ -1,14 +1,16 @@
1
1
  import type { Site } from "./serve.js";
2
2
  export interface SearchSection {
3
+ /** text: rendered document text; file: a file name; folder: a folder document's path. */
4
+ kind: "text" | "file" | "folder";
3
5
  path: string;
4
6
  file: string;
5
- folder: boolean;
6
7
  title: string;
7
8
  heading: string;
8
9
  anchor: string;
9
10
  text: string;
10
11
  }
11
- export declare const searchIndex: (site: Site) => SearchSection[];
12
+ /** `files` are workspace files that open at /_files/file/<path> (edit mode only). */
13
+ export declare const searchIndex: (site: Site, files?: readonly string[]) => SearchSection[];
12
14
  export declare const searchSections: (index: SearchSection[], query: string, currentPath?: string) => (SearchSection & {
13
15
  snippet: string;
14
16
  })[];