@lostgradient/cinder 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (556) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/README.md +33 -11
  3. package/components.json +53 -102
  4. package/dist/_internal/chart/chart-utilities.d.ts +1 -0
  5. package/dist/cli/index.js +63 -10
  6. package/dist/cli/mcp-dependencies.d.ts +4 -0
  7. package/dist/components/approval-card/approval-card.css +1 -6
  8. package/dist/components/approval-card/index.js +94 -55
  9. package/dist/components/area-chart/index.js +40 -6
  10. package/dist/components/bar-chart/index.js +132 -83
  11. package/dist/components/code-block/index.js +58 -9
  12. package/dist/components/command-menu/command-menu.css +9 -0
  13. package/dist/components/command-menu/index.js +7 -2
  14. package/dist/components/diff-statistics/diff-statistics.svelte.d.ts +3 -3
  15. package/dist/components/file-upload/file-upload.schema.js +5 -1
  16. package/dist/components/file-upload/file-upload.types.d.ts +2 -0
  17. package/dist/components/file-upload/index.js +37 -27
  18. package/dist/components/invocation-rule-builder/index.d.ts +1 -1
  19. package/dist/components/invocation-rule-builder/index.js +244 -199
  20. package/dist/components/invocation-rule-builder/invocation-rule-builder.css +8 -0
  21. package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.d.ts +2 -2
  22. package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.js +309 -193
  23. package/dist/components/invocation-rule-builder/invocation-rule-builder.svelte.d.ts +3 -2
  24. package/dist/components/invocation-rule-builder/invocation-rule-builder.types.d.ts +98 -31
  25. package/dist/components/json-editor/index.d.ts +5 -0
  26. package/dist/components/json-editor/index.js +261 -0
  27. package/dist/components/json-editor/json-editor.css +49 -0
  28. package/dist/components/{diff-viewer/diff-viewer.schema.js → json-editor/json-editor.schema.js} +37 -49
  29. package/dist/components/json-editor/json-editor.svelte.d.ts +21 -0
  30. package/dist/components/json-editor/json-editor.types.d.ts +25 -0
  31. package/dist/components/{diff-viewer/diff-viewer.variables.js → json-editor/json-editor.variables.js} +4 -4
  32. package/dist/components/json-schema-editor/index.js +2041 -4165
  33. package/dist/components/json-schema-editor/json-schema-editor-state.svelte.d.ts +17 -1
  34. package/dist/components/json-schema-editor/json-schema-editor-types.d.ts +8 -1
  35. package/dist/components/json-schema-editor/json-schema-editor.css +35 -0
  36. package/dist/components/json-schema-editor/json-schema-editor.svelte.d.ts +0 -1
  37. package/dist/components/json-schema-editor/json-schema-validator.d.ts +9 -4
  38. package/dist/components/line-chart/index.js +40 -6
  39. package/dist/components/matrix-chart/index.js +40 -6
  40. package/dist/components/payload-inspector/index.js +10 -2
  41. package/dist/components/payload-inspector/payload-inspector.schema.js +11 -1
  42. package/dist/components/payload-inspector/payload-inspector.types.d.ts +20 -0
  43. package/dist/components/run-step-timeline/index.js +158 -110
  44. package/dist/components/run-step-timeline/run-step-timeline.css +46 -0
  45. package/dist/components/run-step-timeline/run-step-timeline.schema.js +26 -1
  46. package/dist/components/run-step-timeline/run-step-timeline.types.d.ts +22 -2
  47. package/dist/components/schedule-builder/index.js +165 -93
  48. package/dist/components/schedule-builder/schedule-builder.schema.js +8 -1
  49. package/dist/components/schedule-builder/schedule-builder.svelte.d.ts +1 -1
  50. package/dist/components/schedule-builder/schedule-builder.types.d.ts +12 -0
  51. package/dist/components/schema-form/index.d.ts +1 -1
  52. package/dist/components/schema-form/index.js +107 -25
  53. package/dist/components/schema-form/schema-form.schema.js +9 -1
  54. package/dist/components/schema-form/schema-form.svelte.d.ts +1 -1
  55. package/dist/components/schema-form/schema-form.types.d.ts +8 -0
  56. package/dist/components/sidebar/index.js +93 -42
  57. package/dist/components/sidebar/sidebar.css +7 -16
  58. package/dist/components/sidebar/sidebar.schema.js +8 -9
  59. package/dist/components/sidebar/sidebar.types.d.ts +14 -12
  60. package/dist/components/source-diff-viewer/source-diff-viewer.svelte.d.ts +2 -2
  61. package/dist/components/spectrogram/index.js +40 -6
  62. package/dist/components/spectrum-chart/index.js +40 -6
  63. package/dist/components/tabs/tabs.css +2 -0
  64. package/dist/components/textarea/textarea.svelte.d.ts +1 -1
  65. package/dist/components/toast-region/index.js +2 -2
  66. package/dist/components/toast-region/toast-region.css +1 -1
  67. package/dist/components/waveform/index.js +40 -6
  68. package/dist/highlighters/shiki/index.d.ts +47 -5
  69. package/dist/highlighters/shiki/index.js +58 -9
  70. package/dist/index.d.ts +4 -4
  71. package/dist/index.js +15347 -16138
  72. package/dist/server/components/access-gate/index.js +2 -5
  73. package/dist/server/components/approval-card/index.js +2 -2
  74. package/dist/server/components/area-chart/index.js +3 -3
  75. package/dist/server/components/bar-chart/index.js +3 -3
  76. package/dist/server/components/command-menu/index.js +1 -1
  77. package/dist/server/components/context-menu/index.js +5 -5
  78. package/dist/server/components/data-table/index.js +2 -2
  79. package/dist/server/components/diff-statistics/index.js +3 -5
  80. package/dist/server/components/dropdown/index.js +6 -7
  81. package/dist/server/components/file-upload/index.js +2 -3
  82. package/dist/server/components/icons/index.js +17 -26
  83. package/dist/server/components/inline-loading/index.js +1 -1
  84. package/dist/server/components/invocation-rule-builder/index.js +1 -1
  85. package/dist/server/components/json-editor/index.js +13 -0
  86. package/dist/server/components/json-schema-editor/index.js +4 -16
  87. package/dist/server/components/line-chart/index.js +3 -3
  88. package/dist/server/components/matrix-chart/index.js +2 -2
  89. package/dist/server/components/menu-bar/index.js +4 -4
  90. package/dist/server/components/payload-inspector/index.js +2 -2
  91. package/dist/server/components/run-step-timeline/index.js +1 -1
  92. package/dist/server/components/schedule-builder/index.js +3 -3
  93. package/dist/server/components/schema-form/index.js +1 -1
  94. package/dist/server/components/selection-popover/index.js +3 -5
  95. package/dist/server/components/sidebar/index.js +1 -1
  96. package/dist/server/components/spectrogram/index.js +2 -2
  97. package/dist/server/components/spectrum-chart/index.js +2 -2
  98. package/dist/server/components/surface/index.js +3 -5
  99. package/dist/server/components/table/index.js +2 -2
  100. package/dist/server/components/tabs/index.js +5 -5
  101. package/dist/server/components/toast-region/index.js +1 -1
  102. package/dist/server/components/toolbar/index.js +2 -3
  103. package/dist/server/components/waveform/index.js +2 -2
  104. package/dist/server/highlighters/shiki/index.js +61 -25
  105. package/dist/server/index.js +105 -115
  106. package/dist/server/{index.server-7yfz2t73.js → index.server-003t81xk.js} +1 -1
  107. package/dist/server/{index.server-gwgm8gqg.js → index.server-032p855q.js} +4 -4
  108. package/dist/server/{index.server-tf2n3ccm.js → index.server-1vfhzhkj.js} +1 -1
  109. package/dist/server/{index.server-jz5yxwde.js → index.server-4cbqjf14.js} +16 -7
  110. package/dist/server/{index.server-aqethy0w.js → index.server-66nm5gd5.js} +102 -26
  111. package/dist/server/{index.server-m0ezemav.js → index.server-6mnbznbt.js} +4 -2
  112. package/dist/server/{index.server-1nq8h5yb.js → index.server-6vbpz6dd.js} +40 -6
  113. package/dist/server/{index.server-796hb0r8.js → index.server-7qak74fg.js} +1 -1
  114. package/dist/server/{index.server-5exh7rmw.js → index.server-7ygdwxre.js} +57 -5
  115. package/dist/server/{index.server-q1d48s9t.js → index.server-8c6cck0y.js} +6 -4
  116. package/dist/server/index.server-93vt8ktj.js +95 -0
  117. package/dist/server/{index.server-ep81fn23.js → index.server-9eccb2fc.js} +2 -2
  118. package/dist/server/{index.server-zncgb7mw.js → index.server-9nac5z11.js} +92 -49
  119. package/dist/server/{index.server-bf7d81b4.js → index.server-9vqfmhez.js} +16 -18
  120. package/dist/server/{index.server-nt304e00.js → index.server-dx58qant.js} +1 -1
  121. package/dist/server/{index.server-zh3r8vfd.js → index.server-fhrqsg97.js} +1 -1
  122. package/dist/server/{index.server-dq0k0qf6.js → index.server-geq56xaz.js} +10 -10
  123. package/dist/server/{index.server-51sxnete.js → index.server-hxveaqg1.js} +10 -10
  124. package/dist/server/{index.server-c5qv3p61.js → index.server-j87v28yy.js} +59 -30
  125. package/dist/server/{index.server-s5g7reqp.js → index.server-mewms9dg.js} +2 -2
  126. package/dist/server/index.server-mm728d0w.js +20 -0
  127. package/dist/server/{index.server-5mc2vsy0.js → index.server-n0rbn5yf.js} +4 -2
  128. package/dist/server/{index.server-qv0kkre4.js → index.server-ng8y854r.js} +188 -107
  129. package/dist/server/{index.server-wasj5rbh.js → index.server-q5gvb174.js} +4 -4
  130. package/dist/server/{index.server-g5jgq3jp.js → index.server-qxneqxf8.js} +40 -6
  131. package/dist/server/{index.server-x1dha7bk.js → index.server-rnddtcb3.js} +4 -2
  132. package/dist/server/{index.server-7zpzspk6.js → index.server-s4wm4g2a.js} +30 -2
  133. package/dist/server/index.server-szgghcdh.js +887 -0
  134. package/dist/server/{index.server-thcda9ny.js → index.server-vd302sxz.js} +11 -4
  135. package/dist/server/{index.server-3sq9d73w.js → index.server-vz9hqkdq.js} +2 -2
  136. package/dist/server/{index.server-mvjzcna5.js → index.server-wg6ddzpa.js} +42 -20
  137. package/dist/server/{index.server-67q8dmbp.js → index.server-y2ncgt7p.js} +1 -1
  138. package/dist/server/{index.server-4x91gzy1.js → index.server-yqhww50r.js} +4 -4
  139. package/dist/server/{index.server-7798gc22.js → index.server-zfx4magq.js} +4 -2
  140. package/package.json +45 -288
  141. package/src/_internal/chart/chart-utilities.ts +74 -5
  142. package/src/components/approval-card/approval-card-actions.svelte +12 -28
  143. package/src/components/approval-card/approval-card.css +1 -6
  144. package/src/components/bar-chart/bar-chart.examples.json +1 -1
  145. package/src/components/bar-chart/bar-chart.svelte +3 -1
  146. package/src/components/command-menu/command-menu.css +9 -0
  147. package/src/components/command-menu/command-menu.svelte +9 -2
  148. package/src/components/file-upload/file-upload.schema.json +4 -0
  149. package/src/components/file-upload/file-upload.schema.ts +4 -0
  150. package/src/components/file-upload/file-upload.svelte +3 -3
  151. package/src/components/file-upload/file-upload.types.ts +2 -0
  152. package/src/components/invocation-rule-builder/index.ts +1 -0
  153. package/src/components/invocation-rule-builder/invocation-rule-builder.css +8 -0
  154. package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +6 -0
  155. package/src/components/invocation-rule-builder/invocation-rule-builder.schema.json +70 -7
  156. package/src/components/invocation-rule-builder/invocation-rule-builder.schema.ts +5 -250
  157. package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +106 -83
  158. package/src/components/invocation-rule-builder/invocation-rule-builder.types.ts +145 -62
  159. package/src/components/json-editor/index.ts +6 -0
  160. package/src/components/json-editor/json-editor.css +49 -0
  161. package/src/components/json-editor/json-editor.examples.json +13 -0
  162. package/src/components/json-editor/json-editor.schema.json +57 -0
  163. package/src/components/json-editor/json-editor.schema.ts +62 -0
  164. package/src/components/json-editor/json-editor.svelte +104 -0
  165. package/src/components/json-editor/json-editor.types.ts +29 -0
  166. package/src/components/json-schema-editor/diff-view.svelte +26 -8
  167. package/src/components/json-schema-editor/form-view.svelte +1 -1
  168. package/src/components/json-schema-editor/json-schema-editor-state.svelte.ts +163 -56
  169. package/src/components/json-schema-editor/json-schema-editor-types.ts +8 -1
  170. package/src/components/json-schema-editor/json-schema-editor.css +35 -0
  171. package/src/components/json-schema-editor/json-schema-validator.ts +59 -25
  172. package/src/components/json-schema-editor/json-view.svelte +52 -18
  173. package/src/components/payload-inspector/payload-inspector.schema.json +8 -0
  174. package/src/components/payload-inspector/payload-inspector.schema.ts +10 -0
  175. package/src/components/payload-inspector/payload-inspector.svelte +2 -2
  176. package/src/components/payload-inspector/payload-inspector.types.ts +20 -0
  177. package/src/components/run-step-timeline/run-step-timeline.css +46 -0
  178. package/src/components/run-step-timeline/run-step-timeline.examples.json +3 -3
  179. package/src/components/run-step-timeline/run-step-timeline.schema.json +24 -0
  180. package/src/components/run-step-timeline/run-step-timeline.schema.ts +26 -0
  181. package/src/components/run-step-timeline/run-step-timeline.svelte +41 -4
  182. package/src/components/run-step-timeline/run-step-timeline.types.ts +22 -1
  183. package/src/components/run-step-timeline/run-step-timeline.utilities.ts +9 -1
  184. package/src/components/schedule-builder/schedule-builder.schema.json +7 -0
  185. package/src/components/schedule-builder/schedule-builder.schema.ts +8 -0
  186. package/src/components/schedule-builder/schedule-builder.svelte +94 -22
  187. package/src/components/schedule-builder/schedule-builder.types.ts +12 -0
  188. package/src/components/schema-form/index.ts +1 -0
  189. package/src/components/schema-form/schema-form-body.svelte +94 -17
  190. package/src/components/schema-form/schema-form.examples.json +1 -1
  191. package/src/components/schema-form/schema-form.schema.json +5 -0
  192. package/src/components/schema-form/schema-form.schema.ts +6 -0
  193. package/src/components/schema-form/schema-form.svelte +4 -0
  194. package/src/components/schema-form/schema-form.types.ts +9 -0
  195. package/src/components/side-navigation/side-navigation.examples.json +1 -1
  196. package/src/components/sidebar/sidebar.css +7 -16
  197. package/src/components/sidebar/sidebar.examples.json +3 -3
  198. package/src/components/sidebar/sidebar.schema.json +7 -8
  199. package/src/components/sidebar/sidebar.schema.ts +8 -8
  200. package/src/components/sidebar/sidebar.svelte +65 -27
  201. package/src/components/sidebar/sidebar.types.ts +14 -12
  202. package/src/components/tabs/tabs.css +2 -0
  203. package/src/components/toast-region/toast-region.css +1 -1
  204. package/src/components/toast-region/toast-region.examples.json +1 -1
  205. package/src/components/toast-region/toast-region.svelte +2 -2
  206. package/src/highlighters/shiki/index.ts +157 -17
  207. package/src/index.ts +5 -7
  208. package/src/styles/components.css +1 -1
  209. package/src/utilities/change-tracker.svelte.ts +1 -1
  210. package/dist/commentary/anchor-decorations.d.ts +0 -86
  211. package/dist/commentary/anchor-decorations.js +0 -490
  212. package/dist/commentary/anchoring.d.ts +0 -93
  213. package/dist/commentary/anchoring.js +0 -157
  214. package/dist/commentary/comments/index.d.ts +0 -12
  215. package/dist/commentary/comments/index.js +0 -14
  216. package/dist/commentary/comments/mentions.d.ts +0 -43
  217. package/dist/commentary/comments/mentions.js +0 -65
  218. package/dist/commentary/comments/reanchor.d.ts +0 -86
  219. package/dist/commentary/comments/reanchor.js +0 -220
  220. package/dist/commentary/comments/types.d.ts +0 -260
  221. package/dist/commentary/comments/types.js +0 -83
  222. package/dist/commentary/comments/updates.d.ts +0 -102
  223. package/dist/commentary/comments/updates.js +0 -226
  224. package/dist/commentary/export/comments-export.d.ts +0 -42
  225. package/dist/commentary/export/comments-export.js +0 -258
  226. package/dist/commentary/export/index.d.ts +0 -12
  227. package/dist/commentary/export/index.js +0 -12
  228. package/dist/commentary/export/markdown-summary.d.ts +0 -31
  229. package/dist/commentary/export/markdown-summary.js +0 -218
  230. package/dist/commentary/export/types.d.ts +0 -162
  231. package/dist/commentary/export/types.js +0 -7
  232. package/dist/commentary/export/unified-diff.d.ts +0 -28
  233. package/dist/commentary/export/unified-diff.js +0 -250
  234. package/dist/commentary/index.d.ts +0 -6
  235. package/dist/commentary/index.js +0 -6
  236. package/dist/commentary/session/index.d.ts +0 -12
  237. package/dist/commentary/session/index.js +0 -14
  238. package/dist/commentary/session/persistence.d.ts +0 -92
  239. package/dist/commentary/session/persistence.js +0 -253
  240. package/dist/commentary/session/types.d.ts +0 -208
  241. package/dist/commentary/session/types.js +0 -26
  242. package/dist/commentary/session/updates.d.ts +0 -155
  243. package/dist/commentary/session/updates.js +0 -362
  244. package/dist/commentary/shared/anchor-types.d.ts +0 -116
  245. package/dist/commentary/shared/anchor-types.js +0 -9
  246. package/dist/components/diff-viewer/diff-controller.svelte.d.ts +0 -75
  247. package/dist/components/diff-viewer/diff-front-matter.svelte.d.ts +0 -28
  248. package/dist/components/diff-viewer/diff-line.svelte.d.ts +0 -22
  249. package/dist/components/diff-viewer/diff-summary-bar.svelte.d.ts +0 -13
  250. package/dist/components/diff-viewer/diff-toolbar.svelte.d.ts +0 -36
  251. package/dist/components/diff-viewer/diff-viewer.svelte.d.ts +0 -22
  252. package/dist/components/diff-viewer/diff-viewer.types.d.ts +0 -53
  253. package/dist/components/diff-viewer/front-matter-header.svelte.d.ts +0 -26
  254. package/dist/components/diff-viewer/index.d.ts +0 -4
  255. package/dist/components/diff-viewer/index.js +0 -2848
  256. package/dist/components/markdown-editor/editor-skeleton.svelte.d.ts +0 -10
  257. package/dist/components/markdown-editor/editor-toolbar/editor-toolbar.svelte.d.ts +0 -37
  258. package/dist/components/markdown-editor/editor-toolbar/index.d.ts +0 -11
  259. package/dist/components/markdown-editor/editor-toolbar/link-popover.svelte.d.ts +0 -30
  260. package/dist/components/markdown-editor/editor-toolbar/toolbar-button.svelte.d.ts +0 -19
  261. package/dist/components/markdown-editor/editor-toolbar/toolbar-dropdown.svelte.d.ts +0 -24
  262. package/dist/components/markdown-editor/editor-toolbar/toolbar-separator.svelte.d.ts +0 -7
  263. package/dist/components/markdown-editor/editor-toolbar/types.d.ts +0 -13
  264. package/dist/components/markdown-editor/index.css +0 -61
  265. package/dist/components/markdown-editor/index.d.ts +0 -4
  266. package/dist/components/markdown-editor/index.js +0 -7494
  267. package/dist/components/markdown-editor/markdown-editor.schema.d.ts +0 -3
  268. package/dist/components/markdown-editor/markdown-editor.schema.js +0 -177
  269. package/dist/components/markdown-editor/markdown-editor.svelte.d.ts +0 -29
  270. package/dist/components/markdown-editor/markdown-editor.types.d.ts +0 -100
  271. package/dist/components/markdown-editor/markdown-editor.variables.d.ts +0 -2
  272. package/dist/components/markdown-editor/markdown-editor.variables.js +0 -61
  273. package/dist/components/review-editor/comment-composer.svelte.d.ts +0 -37
  274. package/dist/components/review-editor/comment-list.svelte.d.ts +0 -19
  275. package/dist/components/review-editor/comment-sidebar.svelte.d.ts +0 -22
  276. package/dist/components/review-editor/export-actions.svelte.d.ts +0 -18
  277. package/dist/components/review-editor/focus-navigation.d.ts +0 -105
  278. package/dist/components/review-editor/front-matter-fields.svelte.d.ts +0 -10
  279. package/dist/components/review-editor/index.d.ts +0 -20
  280. package/dist/components/review-editor/index.js +0 -14731
  281. package/dist/components/review-editor/live-region.svelte.d.ts +0 -23
  282. package/dist/components/review-editor/review-editor-anchors.svelte.d.ts +0 -96
  283. package/dist/components/review-editor/review-editor-controls.svelte.d.ts +0 -41
  284. package/dist/components/review-editor/review-editor-exports.d.ts +0 -80
  285. package/dist/components/review-editor/review-editor-front-matter.d.ts +0 -28
  286. package/dist/components/review-editor/review-editor-impl.svelte.d.ts +0 -31
  287. package/dist/components/review-editor/review-editor-selection-geometry.d.ts +0 -10
  288. package/dist/components/review-editor/review-editor-selection-types.d.ts +0 -62
  289. package/dist/components/review-editor/review-editor-selection.svelte.d.ts +0 -50
  290. package/dist/components/review-editor/review-editor-state.svelte.d.ts +0 -77
  291. package/dist/components/review-editor/review-editor-threads.svelte.d.ts +0 -137
  292. package/dist/components/review-editor/review-editor.css +0 -273
  293. package/dist/components/review-editor/review-editor.schema.d.ts +0 -3
  294. package/dist/components/review-editor/review-editor.schema.js +0 -143
  295. package/dist/components/review-editor/review-editor.svelte.d.ts +0 -19
  296. package/dist/components/review-editor/review-editor.types.d.ts +0 -77
  297. package/dist/components/review-editor/review-editor.variables.d.ts +0 -2
  298. package/dist/components/review-editor/review-editor.variables.js +0 -61
  299. package/dist/components/review-editor/thread-popover.svelte.d.ts +0 -32
  300. package/dist/diff/index.d.ts +0 -2
  301. package/dist/diff/index.js +0 -1
  302. package/dist/diff/line-diff.d.ts +0 -84
  303. package/dist/diff/line-diff.js +0 -372
  304. package/dist/diff/types.d.ts +0 -1
  305. package/dist/diff/types.js +0 -1
  306. package/dist/editor/attach.d.ts +0 -30
  307. package/dist/editor/attach.js +0 -86
  308. package/dist/editor/bridge.d.ts +0 -110
  309. package/dist/editor/bridge.js +0 -260
  310. package/dist/editor/clipboard.d.ts +0 -19
  311. package/dist/editor/clipboard.js +0 -189
  312. package/dist/editor/commands.d.ts +0 -167
  313. package/dist/editor/commands.js +0 -728
  314. package/dist/editor/component-runtime.d.ts +0 -21
  315. package/dist/editor/component-runtime.js +0 -20
  316. package/dist/editor/editor.d.ts +0 -23
  317. package/dist/editor/editor.js +0 -256
  318. package/dist/editor/index.d.ts +0 -30
  319. package/dist/editor/index.js +0 -42
  320. package/dist/editor/keymap-plugin.d.ts +0 -56
  321. package/dist/editor/keymap-plugin.js +0 -157
  322. package/dist/editor/link-input-rule.d.ts +0 -4
  323. package/dist/editor/link-input-rule.js +0 -26
  324. package/dist/editor/milkdown-plugin-runtime.d.ts +0 -20
  325. package/dist/editor/milkdown-plugin-runtime.js +0 -43
  326. package/dist/editor/placeholder-security.d.ts +0 -22
  327. package/dist/editor/placeholder-security.js +0 -36
  328. package/dist/editor/placeholder.d.ts +0 -14
  329. package/dist/editor/placeholder.js +0 -56
  330. package/dist/editor/sanitize-html.d.ts +0 -32
  331. package/dist/editor/sanitize-html.js +0 -111
  332. package/dist/editor/template-completion-plugin.d.ts +0 -159
  333. package/dist/editor/template-completion-plugin.js +0 -615
  334. package/dist/editor/template-invalid-decoration-plugin.d.ts +0 -73
  335. package/dist/editor/template-invalid-decoration-plugin.js +0 -155
  336. package/dist/editor/template-placeholders.d.ts +0 -96
  337. package/dist/editor/template-placeholders.js +0 -355
  338. package/dist/editor/template-position-utilities.d.ts +0 -34
  339. package/dist/editor/template-position-utilities.js +0 -63
  340. package/dist/editor/template-render.d.ts +0 -37
  341. package/dist/editor/template-render.js +0 -45
  342. package/dist/editor/test-utilities.d.ts +0 -49
  343. package/dist/editor/test-utilities.js +0 -93
  344. package/dist/editor/types.d.ts +0 -234
  345. package/dist/editor/types.js +0 -8
  346. package/dist/markdown/diff/compute.d.ts +0 -28
  347. package/dist/markdown/diff/compute.js +0 -250
  348. package/dist/markdown/diff/frontmatter.d.ts +0 -66
  349. package/dist/markdown/diff/frontmatter.js +0 -135
  350. package/dist/markdown/diff/index.d.ts +0 -27
  351. package/dist/markdown/diff/index.js +0 -28
  352. package/dist/markdown/diff/line-diff.d.ts +0 -2
  353. package/dist/markdown/diff/line-diff.js +0 -1
  354. package/dist/markdown/diff/positions.d.ts +0 -66
  355. package/dist/markdown/diff/positions.js +0 -147
  356. package/dist/markdown/diff/types.d.ts +0 -78
  357. package/dist/markdown/diff/types.js +0 -7
  358. package/dist/markdown/index.d.ts +0 -2
  359. package/dist/markdown/index.js +0 -8
  360. package/dist/markdown/pipeline/ast.d.ts +0 -302
  361. package/dist/markdown/pipeline/ast.js +0 -417
  362. package/dist/markdown/pipeline/errors.d.ts +0 -37
  363. package/dist/markdown/pipeline/errors.js +0 -49
  364. package/dist/markdown/pipeline/frontmatter.d.ts +0 -127
  365. package/dist/markdown/pipeline/frontmatter.js +0 -438
  366. package/dist/markdown/pipeline/index.d.ts +0 -37
  367. package/dist/markdown/pipeline/index.js +0 -40
  368. package/dist/markdown/pipeline/parser.d.ts +0 -65
  369. package/dist/markdown/pipeline/parser.js +0 -106
  370. package/dist/markdown/pipeline/serializer.d.ts +0 -67
  371. package/dist/markdown/pipeline/serializer.js +0 -78
  372. package/dist/markdown/pipeline/strip-positions.d.ts +0 -20
  373. package/dist/markdown/pipeline/strip-positions.js +0 -28
  374. package/dist/markdown/pipeline/types.d.ts +0 -116
  375. package/dist/markdown/pipeline/types.js +0 -8
  376. package/dist/markdown/rendering/extract-code-blocks.d.ts +0 -16
  377. package/dist/markdown/rendering/extract-code-blocks.js +0 -27
  378. package/dist/markdown/rendering/highlighter.d.ts +0 -109
  379. package/dist/markdown/rendering/highlighter.js +0 -251
  380. package/dist/markdown/rendering/index.d.ts +0 -41
  381. package/dist/markdown/rendering/index.js +0 -46
  382. package/dist/markdown/rendering/mermaid-cache.d.ts +0 -55
  383. package/dist/markdown/rendering/mermaid-cache.js +0 -123
  384. package/dist/markdown/rendering/rehype-shiki-sync.d.ts +0 -57
  385. package/dist/markdown/rendering/rehype-shiki-sync.js +0 -354
  386. package/dist/markdown/rendering/render-async.d.ts +0 -43
  387. package/dist/markdown/rendering/render-async.js +0 -114
  388. package/dist/markdown/rendering/render-streaming.d.ts +0 -33
  389. package/dist/markdown/rendering/render-streaming.js +0 -123
  390. package/dist/markdown/rendering/render-worker.d.ts +0 -19
  391. package/dist/markdown/rendering/render-worker.js +0 -35
  392. package/dist/markdown/rendering/render.d.ts +0 -123
  393. package/dist/markdown/rendering/render.js +0 -477
  394. package/dist/markdown/rendering/sanitize-schema.d.ts +0 -24
  395. package/dist/markdown/rendering/sanitize-schema.js +0 -105
  396. package/dist/markdown/rendering/transform-urls.d.ts +0 -37
  397. package/dist/markdown/rendering/transform-urls.js +0 -51
  398. package/dist/markdown/rendering/types.d.ts +0 -51
  399. package/dist/markdown/rendering/types.js +0 -8
  400. package/dist/markdown/rendering/worker-dom-shim.d.ts +0 -87
  401. package/dist/markdown/rendering/worker-dom-shim.js +0 -50
  402. package/dist/markdown/utilities/safe-url.d.ts +0 -100
  403. package/dist/markdown/utilities/safe-url.js +0 -236
  404. package/dist/markdown/utilities/sort-keys.d.ts +0 -19
  405. package/dist/markdown/utilities/sort-keys.js +0 -33
  406. package/dist/server/commentary/anchor-decorations.js +0 -490
  407. package/dist/server/commentary/anchoring.js +0 -157
  408. package/dist/server/commentary/comments/index.js +0 -14
  409. package/dist/server/commentary/comments/mentions.js +0 -65
  410. package/dist/server/commentary/comments/reanchor.js +0 -220
  411. package/dist/server/commentary/comments/types.js +0 -83
  412. package/dist/server/commentary/comments/updates.js +0 -226
  413. package/dist/server/commentary/export/comments-export.js +0 -258
  414. package/dist/server/commentary/export/index.js +0 -12
  415. package/dist/server/commentary/export/markdown-summary.js +0 -218
  416. package/dist/server/commentary/export/types.js +0 -7
  417. package/dist/server/commentary/export/unified-diff.js +0 -250
  418. package/dist/server/commentary/index.js +0 -6
  419. package/dist/server/commentary/session/index.js +0 -14
  420. package/dist/server/commentary/session/persistence.js +0 -253
  421. package/dist/server/commentary/session/types.js +0 -26
  422. package/dist/server/commentary/session/updates.js +0 -362
  423. package/dist/server/commentary/shared/anchor-types.js +0 -9
  424. package/dist/server/components/diff-viewer/index.js +0 -33
  425. package/dist/server/components/markdown-editor/index.js +0 -52
  426. package/dist/server/components/review-editor/index.js +0 -3493
  427. package/dist/server/diff/index.js +0 -1
  428. package/dist/server/diff/line-diff.js +0 -372
  429. package/dist/server/diff/types.js +0 -1
  430. package/dist/server/editor/attach.js +0 -86
  431. package/dist/server/editor/bridge.js +0 -260
  432. package/dist/server/editor/clipboard.js +0 -189
  433. package/dist/server/editor/commands.js +0 -728
  434. package/dist/server/editor/component-runtime.js +0 -20
  435. package/dist/server/editor/editor.js +0 -256
  436. package/dist/server/editor/index.js +0 -42
  437. package/dist/server/editor/keymap-plugin.js +0 -157
  438. package/dist/server/editor/link-input-rule.js +0 -26
  439. package/dist/server/editor/milkdown-plugin-runtime.js +0 -43
  440. package/dist/server/editor/placeholder-security.js +0 -36
  441. package/dist/server/editor/placeholder.js +0 -56
  442. package/dist/server/editor/sanitize-html.js +0 -111
  443. package/dist/server/editor/template-completion-plugin.js +0 -615
  444. package/dist/server/editor/template-invalid-decoration-plugin.js +0 -155
  445. package/dist/server/editor/template-placeholders.js +0 -355
  446. package/dist/server/editor/template-position-utilities.js +0 -63
  447. package/dist/server/editor/template-render.js +0 -45
  448. package/dist/server/editor/test-utilities.js +0 -93
  449. package/dist/server/editor/types.js +0 -8
  450. package/dist/server/index.server-25wmev4e.js +0 -2
  451. package/dist/server/index.server-2c56kqws.js +0 -187
  452. package/dist/server/index.server-45n4s30n.js +0 -35
  453. package/dist/server/index.server-4jkqgp17.js +0 -1026
  454. package/dist/server/index.server-8nm871y8.js +0 -176
  455. package/dist/server/index.server-d04aj37r.js +0 -62
  456. package/dist/server/index.server-dg19y3m7.js +0 -9
  457. package/dist/server/index.server-g3726bja.js +0 -9
  458. package/dist/server/index.server-gyzmkrnz.js +0 -2
  459. package/dist/server/index.server-jp19145t.js +0 -9
  460. package/dist/server/index.server-n4jxy52q.js +0 -2
  461. package/dist/server/index.server-sghkqw5x.js +0 -421
  462. package/dist/server/index.server-w6am2dxc.js +0 -12
  463. package/dist/server/index.server-x66zvjfc.js +0 -1163
  464. package/dist/server/index.server-zdhv33ph.js +0 -124
  465. package/dist/server/index.server-zke5zt13.js +0 -9
  466. package/dist/server/markdown/diff/compute.js +0 -250
  467. package/dist/server/markdown/diff/frontmatter.js +0 -135
  468. package/dist/server/markdown/diff/index.js +0 -28
  469. package/dist/server/markdown/diff/line-diff.js +0 -1
  470. package/dist/server/markdown/diff/positions.js +0 -147
  471. package/dist/server/markdown/diff/types.js +0 -7
  472. package/dist/server/markdown/index.js +0 -8
  473. package/dist/server/markdown/pipeline/ast.js +0 -417
  474. package/dist/server/markdown/pipeline/errors.js +0 -49
  475. package/dist/server/markdown/pipeline/frontmatter.js +0 -438
  476. package/dist/server/markdown/pipeline/index.js +0 -40
  477. package/dist/server/markdown/pipeline/parser.js +0 -106
  478. package/dist/server/markdown/pipeline/serializer.js +0 -78
  479. package/dist/server/markdown/pipeline/strip-positions.js +0 -28
  480. package/dist/server/markdown/pipeline/types.js +0 -8
  481. package/dist/server/markdown/rendering/extract-code-blocks.js +0 -27
  482. package/dist/server/markdown/rendering/highlighter.js +0 -251
  483. package/dist/server/markdown/rendering/index.js +0 -46
  484. package/dist/server/markdown/rendering/mermaid-cache.js +0 -123
  485. package/dist/server/markdown/rendering/rehype-shiki-sync.js +0 -354
  486. package/dist/server/markdown/rendering/render-async.js +0 -114
  487. package/dist/server/markdown/rendering/render-streaming.js +0 -123
  488. package/dist/server/markdown/rendering/render-worker.js +0 -35
  489. package/dist/server/markdown/rendering/render.js +0 -477
  490. package/dist/server/markdown/rendering/sanitize-schema.js +0 -105
  491. package/dist/server/markdown/rendering/transform-urls.js +0 -51
  492. package/dist/server/markdown/rendering/types.js +0 -8
  493. package/dist/server/markdown/rendering/worker-dom-shim.js +0 -50
  494. package/dist/server/markdown/utilities/safe-url.js +0 -236
  495. package/dist/server/markdown/utilities/sort-keys.js +0 -33
  496. package/src/components/diff-viewer/diff-controller.svelte.ts +0 -250
  497. package/src/components/diff-viewer/diff-front-matter.svelte +0 -52
  498. package/src/components/diff-viewer/diff-line.svelte +0 -340
  499. package/src/components/diff-viewer/diff-summary-bar.svelte +0 -106
  500. package/src/components/diff-viewer/diff-toolbar.svelte +0 -182
  501. package/src/components/diff-viewer/diff-viewer.examples.json +0 -25
  502. package/src/components/diff-viewer/diff-viewer.schema.json +0 -61
  503. package/src/components/diff-viewer/diff-viewer.schema.ts +0 -70
  504. package/src/components/diff-viewer/diff-viewer.svelte +0 -400
  505. package/src/components/diff-viewer/diff-viewer.types.ts +0 -56
  506. package/src/components/diff-viewer/front-matter-header.svelte +0 -137
  507. package/src/components/diff-viewer/index.ts +0 -5
  508. package/src/components/markdown-editor/editor-skeleton.svelte +0 -85
  509. package/src/components/markdown-editor/editor-toolbar/editor-toolbar.svelte +0 -318
  510. package/src/components/markdown-editor/editor-toolbar/index.ts +0 -18
  511. package/src/components/markdown-editor/editor-toolbar/link-popover.svelte +0 -314
  512. package/src/components/markdown-editor/editor-toolbar/toolbar-button.svelte +0 -97
  513. package/src/components/markdown-editor/editor-toolbar/toolbar-dropdown.svelte +0 -106
  514. package/src/components/markdown-editor/editor-toolbar/toolbar-separator.svelte +0 -30
  515. package/src/components/markdown-editor/editor-toolbar/types.ts +0 -15
  516. package/src/components/markdown-editor/index.ts +0 -10
  517. package/src/components/markdown-editor/markdown-editor.examples.json +0 -19
  518. package/src/components/markdown-editor/markdown-editor.schema.json +0 -111
  519. package/src/components/markdown-editor/markdown-editor.schema.ts +0 -122
  520. package/src/components/markdown-editor/markdown-editor.svelte +0 -872
  521. package/src/components/markdown-editor/markdown-editor.types.ts +0 -124
  522. package/src/components/markdown-editor/markdown-editor.variables.json +0 -1
  523. package/src/components/markdown-editor/markdown-editor.variables.ts +0 -3
  524. package/src/components/markdown-editor/prosemirror.css +0 -76
  525. package/src/components/review-editor/comment-composer.svelte +0 -271
  526. package/src/components/review-editor/comment-list.svelte +0 -311
  527. package/src/components/review-editor/comment-sidebar.svelte +0 -449
  528. package/src/components/review-editor/export-actions.svelte +0 -188
  529. package/src/components/review-editor/focus-navigation.ts +0 -220
  530. package/src/components/review-editor/front-matter-fields.svelte +0 -159
  531. package/src/components/review-editor/index.ts +0 -59
  532. package/src/components/review-editor/live-region.svelte +0 -109
  533. package/src/components/review-editor/review-editor-anchors.svelte.ts +0 -219
  534. package/src/components/review-editor/review-editor-controls.svelte +0 -201
  535. package/src/components/review-editor/review-editor-exports.ts +0 -145
  536. package/src/components/review-editor/review-editor-front-matter.ts +0 -237
  537. package/src/components/review-editor/review-editor-impl.svelte +0 -1509
  538. package/src/components/review-editor/review-editor-selection-geometry.ts +0 -31
  539. package/src/components/review-editor/review-editor-selection-types.ts +0 -68
  540. package/src/components/review-editor/review-editor-selection.svelte.ts +0 -292
  541. package/src/components/review-editor/review-editor-state.svelte.ts +0 -117
  542. package/src/components/review-editor/review-editor-threads.svelte.ts +0 -435
  543. package/src/components/review-editor/review-editor.css +0 -273
  544. package/src/components/review-editor/review-editor.examples.json +0 -19
  545. package/src/components/review-editor/review-editor.schema.json +0 -83
  546. package/src/components/review-editor/review-editor.schema.ts +0 -88
  547. package/src/components/review-editor/review-editor.svelte +0 -18
  548. package/src/components/review-editor/review-editor.types.ts +0 -92
  549. package/src/components/review-editor/review-editor.variables.json +0 -1
  550. package/src/components/review-editor/review-editor.variables.ts +0 -3
  551. package/src/components/review-editor/thread-popover.svelte +0 -261
  552. /package/dist/components/{review-editor/review-editor.css.d.ts → json-editor/json-editor.css.d.ts} +0 -0
  553. /package/dist/components/{diff-viewer/diff-viewer.schema.d.ts → json-editor/json-editor.schema.d.ts} +0 -0
  554. /package/dist/components/{diff-viewer/diff-viewer.variables.d.ts → json-editor/json-editor.variables.d.ts} +0 -0
  555. /package/src/components/{diff-viewer/diff-viewer.variables.json → json-editor/json-editor.variables.json} +0 -0
  556. /package/src/components/{diff-viewer/diff-viewer.variables.ts → json-editor/json-editor.variables.ts} +0 -0
@@ -1,615 +0,0 @@
1
- /**
2
- * ProseMirror plugin for inline autocomplete of `{{…}}` template placeholder tokens.
3
- *
4
- * Shows a popup suggestion menu as the user types inside `{{…}}` tokens in the
5
- * WYSIWYG editor. Supports both static candidates and async lookup with debouncing.
6
- *
7
- * The plugin integrates with Milkdown via `$prose` and communicates state changes
8
- * through ProseMirror meta transactions on its plugin key.
9
- *
10
- * DEP-583: WYSIWYG placeholder completion for saved-prompt template authoring.
11
- */
12
- import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
13
- import { createLazyProsePlugin } from './milkdown-plugin-runtime.js';
14
- import { textOffsetToBlockDocumentPosition } from './template-position-utilities.js';
15
- // ─────────────────────────────────────────────────────────────────────────────
16
- // Constants
17
- // ─────────────────────────────────────────────────────────────────────────────
18
- /** @internal Exported for testing only. */
19
- export const MAXIMUM_VISIBLE_SUGGESTIONS = 8;
20
- /** Default minimum query length before showing suggestions. */
21
- const DEFAULT_MINIMUM_QUERY_LENGTH = 1;
22
- /** Default debounce interval for async lookup calls (ms). */
23
- const DEFAULT_LOOKUP_DEBOUNCE_MS = 150;
24
- /**
25
- * Pattern for valid placeholder path prefixes.
26
- * Allows letters, digits, underscores, and dots (partial paths like "input.na").
27
- */
28
- const VALID_QUERY_PATTERN = /^[a-zA-Z0-9_.]*$/;
29
- // ─────────────────────────────────────────────────────────────────────────────
30
- // Plugin key (exported for external state inspection)
31
- // ─────────────────────────────────────────────────────────────────────────────
32
- /** Plugin key for the template completion plugin. */
33
- export const templateCompletionPluginKey = new PluginKey('template-completion');
34
- /** @internal Exported for testing only. */
35
- export const INACTIVE_STATE = {
36
- active: false,
37
- query: '',
38
- suggestions: [],
39
- activeIndex: 0,
40
- tokenFrom: 0,
41
- cursorPos: 0,
42
- };
43
- function isRecord(value) {
44
- return value !== null && typeof value === 'object' && !Array.isArray(value);
45
- }
46
- function isCompletionMeta(value) {
47
- if (!isRecord(value))
48
- return false;
49
- if (value['type'] === 'close')
50
- return true;
51
- if (value['type'] === 'navigate')
52
- return typeof value['index'] === 'number';
53
- if (value['type'] === 'asyncResults')
54
- return Array.isArray(value['candidates']);
55
- return false;
56
- }
57
- // ─────────────────────────────────────────────────────────────────────────────
58
- // Query detection
59
- // ─────────────────────────────────────────────────────────────────────────────
60
- /**
61
- * Detect whether the cursor is inside an in-progress `{{…}}` token.
62
- *
63
- * Uses `doc.textBetween` to derive pre-cursor text so that inline atom nodes
64
- * (hard_break, images, etc.) are correctly excluded from the text coordinate
65
- * space. This prevents `$from.parentOffset` — which counts atom nodeSize —
66
- * from diverging from the plain-text index into `textContent`.
67
- *
68
- * @internal Exported for testing only.
69
- *
70
- * @returns An object with the query text and token start position, or `null`
71
- * if the cursor is not inside an open placeholder token.
72
- */
73
- export function detectTokenQuery(state) {
74
- const { $from } = state.selection;
75
- const cursorPos = state.selection.from;
76
- // Must be a cursor (collapsed selection)
77
- if (state.selection.from !== state.selection.to)
78
- return null;
79
- // Get the parent text block
80
- const parentNode = $from.parent;
81
- if (!parentNode.isTextblock)
82
- return null;
83
- const blockContentStart = $from.start();
84
- const blockContentEnd = $from.end();
85
- // Use textBetween to collect the block's text correctly. Unlike
86
- // `parentNode.textContent.slice(0, $from.parentOffset)`, this approach
87
- // treats inline atoms (hard_break, images) as having zero text length,
88
- // keeping the text-offset coordinate system consistent with textContent.
89
- const textBeforeCursor = state.doc.textBetween(blockContentStart, cursorPos);
90
- const fullText = state.doc.textBetween(blockContentStart, blockContentEnd);
91
- // Find the last occurrence of `{{` before the cursor
92
- const openIndex = textBeforeCursor.lastIndexOf('{{');
93
- if (openIndex === -1)
94
- return null;
95
- // Check for a closing `}}` between `{{` and the cursor
96
- const textBetween = textBeforeCursor.slice(openIndex + 2);
97
- if (textBetween.includes('}}'))
98
- return null;
99
- // Also check if the full block text has `}}` right at/after cursor position
100
- // that would indicate a completed token
101
- const textAfterOpen = fullText.slice(openIndex + 2);
102
- const closingIndex = textAfterOpen.indexOf('}}');
103
- if (closingIndex !== -1 && closingIndex < textBeforeCursor.length - openIndex - 2) {
104
- // The `}}` is before the cursor in the text, so the token is complete
105
- return null;
106
- }
107
- // Extract and trim the query
108
- const rawQuery = textBeforeCursor.slice(openIndex + 2);
109
- const query = rawQuery.trim();
110
- // Validate query characters
111
- if (!VALID_QUERY_PATTERN.test(query))
112
- return null;
113
- // Convert the text-coordinate `openIndex` to an absolute document position
114
- // by walking the block's children, counting text characters to skip atoms.
115
- const tokenFrom = textOffsetToBlockDocumentPosition(parentNode, blockContentStart, openIndex);
116
- return { query, tokenFrom, cursorPos };
117
- }
118
- // ─────────────────────────────────────────────────────────────────────────────
119
- // Filtering and sorting
120
- // ─────────────────────────────────────────────────────────────────────────────
121
- /**
122
- * Filter candidates by case-insensitive prefix match and sort lexicographically.
123
- *
124
- * @internal Exported for testing only.
125
- *
126
- * @param candidates - All available candidates.
127
- * @param query - The query to match against candidate paths.
128
- * @returns Filtered and sorted candidates, limited to {@link MAXIMUM_VISIBLE_SUGGESTIONS}.
129
- */
130
- export function filterAndSortCandidates(candidates, query) {
131
- const lowerQuery = query.toLowerCase();
132
- return candidates
133
- .filter((candidate) => candidate.path.toLowerCase().startsWith(lowerQuery))
134
- .toSorted((a, b) => a.path.localeCompare(b.path))
135
- .slice(0, MAXIMUM_VISIBLE_SUGGESTIONS);
136
- }
137
- /**
138
- * Merge static and async candidates, deduplicating by path.
139
- *
140
- * Static candidates take priority when paths overlap.
141
- *
142
- * @internal Exported for testing only.
143
- *
144
- * @param staticCandidates - Candidates from the static configuration.
145
- * @param asyncCandidates - Candidates from the async lookup.
146
- * @returns Merged candidate array with duplicates removed.
147
- */
148
- export function mergeCandidates(staticCandidates, asyncCandidates) {
149
- const seen = new Set(staticCandidates.map((candidate) => candidate.path));
150
- const merged = [...staticCandidates];
151
- for (const candidate of asyncCandidates) {
152
- if (!seen.has(candidate.path)) {
153
- seen.add(candidate.path);
154
- merged.push(candidate);
155
- }
156
- }
157
- return merged;
158
- }
159
- // ─────────────────────────────────────────────────────────────────────────────
160
- // Suggestion acceptance
161
- // ─────────────────────────────────────────────────────────────────────────────
162
- /**
163
- * Find the end position of the complete `{{…}}` token starting at `tokenFrom`.
164
- *
165
- * Scans forward from `tokenFrom + 2` (past the opening `{{`) to find the first
166
- * `}}` within the document, stopping at the end of the current text block.
167
- *
168
- * The closing `}}` position is computed by walking the block's inline children
169
- * rather than treating the text-string index of `}}` as a document-position
170
- * offset. When inline atom nodes (such as `hard_break`) exist between
171
- * `tokenFrom` and `}}`, the text string is shorter than the document-position
172
- * span because atoms contribute zero text characters but occupy document
173
- * positions. Using the raw text index as a doc offset would return a position
174
- * that is too low, causing `acceptSuggestion` to leave trailing characters
175
- * behind.
176
- *
177
- * @param state - The current ProseMirror editor state.
178
- * @param tokenFrom - The document position where `{{` starts.
179
- * @returns The document position immediately after the closing `}}`, or `null`
180
- * if no closing `}}` is found within the current block.
181
- *
182
- * @internal Exported for testing only.
183
- */
184
- export function findTokenEnd(state, tokenFrom) {
185
- const $tokenFrom = state.doc.resolve(tokenFrom);
186
- const blockContentStart = $tokenFrom.start();
187
- const blockEnd = $tokenFrom.end();
188
- const parentNode = $tokenFrom.parent;
189
- const contentStart = tokenFrom + 2; // skip past `{{`
190
- if (contentStart >= blockEnd)
191
- return null;
192
- // textBetween treats atom nodes as empty strings, so the returned string
193
- // may be shorter than the document-position span when atoms are present.
194
- // We use this only to locate the `}}` in text space.
195
- const textFromContentStart = state.doc.textBetween(contentStart, blockEnd);
196
- const closingIndex = textFromContentStart.indexOf('}}');
197
- if (closingIndex === -1)
198
- return null;
199
- // closingIndex is a text-string index within [contentStart, blockEnd].
200
- // Convert it to an absolute document position by expressing it as a
201
- // text-coordinate offset from blockContentStart, then using the shared
202
- // walker that correctly accounts for atom-node document sizes.
203
- const textUpToContentStart = state.doc.textBetween(blockContentStart, contentStart);
204
- const closingTextOffset = textUpToContentStart.length + closingIndex;
205
- const closingDocPos = textOffsetToBlockDocumentPosition(parentNode, blockContentStart, closingTextOffset);
206
- // closingDocPos is the position of the first `}`. The closing `}}` occupies
207
- // two text characters (no atoms), so the end of the token is +2.
208
- return closingDocPos + 2;
209
- }
210
- /**
211
- * Accept a suggestion by replacing the entire `{{…}}` token with the completed placeholder.
212
- *
213
- * Finds the full extent of the token (from `{{` to the matching `}}`, if present)
214
- * and replaces it with `{{path}}`, then positions the cursor after the closing braces.
215
- * When the caret is in the middle of an existing token (e.g., `{{input.n|ame}}`),
216
- * the entire token including the suffix is replaced, preventing partial-suffix corruption.
217
- *
218
- * @param view - The ProseMirror editor view.
219
- * @param suggestion - The candidate to accept.
220
- * @param tokenFrom - The document position where `{{` starts.
221
- */
222
- function acceptSuggestion(view, suggestion, tokenFrom) {
223
- const replacementText = `{{${suggestion.path}}}`;
224
- const { state } = view;
225
- const cursorPos = state.selection.from;
226
- // Scan forward from the token start to find the full `{{…}}` extent.
227
- // This handles the case where the cursor is in the middle of an existing
228
- // token (e.g., `{{input.n|ame}}`), replacing the whole token rather than
229
- // leaving the suffix behind.
230
- const fullTokenEnd = findTokenEnd(state, tokenFrom);
231
- const tokenTo = fullTokenEnd ?? cursorPos;
232
- const transaction = state.tr
233
- .replaceWith(tokenFrom, tokenTo, state.schema.text(replacementText))
234
- .setMeta(templateCompletionPluginKey, { type: 'close' });
235
- // Place cursor after the replacement text
236
- const newCursorPos = tokenFrom + replacementText.length;
237
- transaction.setSelection(TextSelection.create(transaction.doc, newCursorPos));
238
- view.dispatch(transaction);
239
- }
240
- // ─────────────────────────────────────────────────────────────────────────────
241
- // DOM popup
242
- // ─────────────────────────────────────────────────────────────────────────────
243
- /**
244
- * Create the popup container element for the suggestion menu.
245
- *
246
- * @returns A positioned, hidden `<div>` with `role="listbox"`.
247
- */
248
- function createPopupElement() {
249
- const popup = document.createElement('div');
250
- popup.className = 'template-completion-popup';
251
- popup.setAttribute('role', 'listbox');
252
- popup.style.position = 'absolute';
253
- popup.style.zIndex = '50';
254
- popup.style.display = 'none';
255
- return popup;
256
- }
257
- /**
258
- * Render suggestion items into the popup element.
259
- *
260
- * Each suggestion is a `<div role="option">` containing the path and optional
261
- * description. Click handlers accept the clicked suggestion.
262
- *
263
- * @param popup - The popup container element.
264
- * @param completionState - Current completion state with suggestions and active index.
265
- * @param view - The ProseMirror editor view (for dispatching acceptance).
266
- */
267
- function renderSuggestions(popup, completionState, view) {
268
- // Clear existing children
269
- popup.textContent = '';
270
- const { suggestions, activeIndex, tokenFrom } = completionState;
271
- for (let index = 0; index < suggestions.length; index++) {
272
- const candidate = suggestions[index];
273
- if (!candidate)
274
- continue;
275
- const item = document.createElement('div');
276
- item.setAttribute('role', 'option');
277
- item.setAttribute('aria-selected', String(index === activeIndex));
278
- item.className = 'template-completion-item';
279
- if (index === activeIndex) {
280
- item.classList.add('template-completion-item--active');
281
- }
282
- // Path label
283
- const pathLabel = document.createElement('span');
284
- pathLabel.className = 'template-completion-item-path';
285
- pathLabel.textContent = candidate.path;
286
- item.appendChild(pathLabel);
287
- // Description and value kind (secondary text)
288
- if (candidate.description || candidate.valueKind !== 'unknown') {
289
- const secondary = document.createElement('span');
290
- secondary.className = 'template-completion-item-description';
291
- const parts = [];
292
- if (candidate.valueKind && candidate.valueKind !== 'unknown') {
293
- parts.push(candidate.valueKind);
294
- }
295
- if (candidate.description) {
296
- parts.push(candidate.description);
297
- }
298
- secondary.textContent = parts.join(' — ');
299
- item.appendChild(secondary);
300
- }
301
- // Click handler to accept this suggestion
302
- item.addEventListener('mousedown', (event) => {
303
- // Prevent the editor from losing focus
304
- event.preventDefault();
305
- event.stopPropagation();
306
- acceptSuggestion(view, candidate, tokenFrom);
307
- });
308
- popup.appendChild(item);
309
- }
310
- }
311
- /**
312
- * Position the popup element near the cursor using ProseMirror coordinates.
313
- *
314
- * Places the popup below the cursor line, aligned to the cursor's horizontal position.
315
- *
316
- * @param popup - The popup container element.
317
- * @param view - The ProseMirror editor view.
318
- * @param cursorPos - The document position to anchor the popup to.
319
- */
320
- function positionPopup(popup, view, cursorPos) {
321
- const coordinates = view.coordsAtPos(cursorPos);
322
- const parentElement = popup.parentElement;
323
- if (!parentElement)
324
- return;
325
- const parentRect = parentElement.getBoundingClientRect();
326
- popup.style.left = `${coordinates.left - parentRect.left}px`;
327
- popup.style.top = `${coordinates.bottom - parentRect.top + 4}px`;
328
- }
329
- // ─────────────────────────────────────────────────────────────────────────────
330
- // State computation
331
- // ─────────────────────────────────────────────────────────────────────────────
332
- /**
333
- * Compute the next completion state from a transaction.
334
- *
335
- * Handles meta-driven updates (close, navigate, asyncResults) and recomputes
336
- * the token query and suggestions on each document/selection change.
337
- *
338
- * @internal Exported for testing only.
339
- *
340
- * @param previousState - The completion state before this transaction.
341
- * @param transaction - The ProseMirror transaction being applied.
342
- * @param editorState - The new ProseMirror editor state after the transaction.
343
- * @param configuration - The current placeholder completion configuration.
344
- * @returns The updated completion state.
345
- */
346
- export function computeCompletionState(previousState, transaction, editorState, configuration) {
347
- // If disabled, always return inactive
348
- if (!configuration)
349
- return INACTIVE_STATE;
350
- // Check for meta-driven updates
351
- const rawMeta = transaction.getMeta(templateCompletionPluginKey);
352
- const meta = isCompletionMeta(rawMeta) ? rawMeta : undefined;
353
- if (meta) {
354
- if (meta.type === 'close') {
355
- return INACTIVE_STATE;
356
- }
357
- if (meta.type === 'navigate') {
358
- return { ...previousState, activeIndex: meta.index };
359
- }
360
- if (meta.type === 'asyncResults') {
361
- // Merge async results with static candidates, re-filter, and re-sort
362
- const merged = mergeCandidates(configuration.candidates, meta.candidates);
363
- const suggestions = filterAndSortCandidates(merged, previousState.query);
364
- const activeIndex = Math.min(previousState.activeIndex, Math.max(0, suggestions.length - 1));
365
- if (suggestions.length === 0) {
366
- return INACTIVE_STATE;
367
- }
368
- return { ...previousState, suggestions, activeIndex };
369
- }
370
- }
371
- // Detect if the cursor is inside an open `{{…}}` token
372
- const detected = detectTokenQuery(editorState);
373
- if (!detected) {
374
- return INACTIVE_STATE;
375
- }
376
- const { query, tokenFrom, cursorPos } = detected;
377
- const minimumQueryLength = configuration.minimumQueryLength ?? DEFAULT_MINIMUM_QUERY_LENGTH;
378
- // Query too short — close menu
379
- if (query.length < minimumQueryLength) {
380
- return INACTIVE_STATE;
381
- }
382
- // Filter and sort candidates
383
- const suggestions = filterAndSortCandidates(configuration.candidates, query);
384
- if (suggestions.length === 0) {
385
- // Keep menu active with empty suggestions if async lookup is configured
386
- // (async results may arrive later). Otherwise, close.
387
- if (!configuration.lookupCandidates) {
388
- return INACTIVE_STATE;
389
- }
390
- return {
391
- active: true,
392
- query,
393
- suggestions: [],
394
- activeIndex: 0,
395
- tokenFrom,
396
- cursorPos,
397
- };
398
- }
399
- // Preserve active index when query hasn't changed, reset otherwise
400
- const activeIndex = previousState.active && previousState.query === query
401
- ? Math.min(previousState.activeIndex, suggestions.length - 1)
402
- : 0;
403
- return {
404
- active: true,
405
- query,
406
- suggestions,
407
- activeIndex,
408
- tokenFrom,
409
- cursorPos,
410
- };
411
- }
412
- // ─────────────────────────────────────────────────────────────────────────────
413
- // Plugin factory
414
- // ─────────────────────────────────────────────────────────────────────────────
415
- /**
416
- * Create a Milkdown plugin that provides inline autocomplete for `{{…}}` template tokens.
417
- *
418
- * The plugin watches the cursor position, detects when it is inside an in-progress
419
- * placeholder token, filters available candidates, and shows a positioned popup with
420
- * suggestions. Keyboard navigation (ArrowUp/Down, Enter, Tab, Escape) and mouse
421
- * clicks interact with the popup.
422
- *
423
- * The factory accepts a getter function so the configuration can change at runtime
424
- * (e.g., when the candidate set is recomputed from a new JSON Schema) without
425
- * recreating the plugin.
426
- *
427
- * @param getConfiguration - Returns the current completion configuration, or
428
- * `undefined` to disable the popup entirely.
429
- * @returns A Milkdown-compatible plugin created via `$prose`.
430
- *
431
- * @example
432
- * ```typescript
433
- * const plugin = createTemplateCompletionPlugin(() => ({
434
- * candidates: [
435
- * { path: 'input.name', description: 'User name', valueKind: 'string' },
436
- * { path: 'input.age', description: 'User age', valueKind: 'number' },
437
- * ],
438
- * }));
439
- * ```
440
- */
441
- export function createTemplateCompletionPlugin(getConfiguration) {
442
- return createLazyProsePlugin(() => {
443
- return new Plugin({
444
- key: templateCompletionPluginKey,
445
- // ─────────────────────────────────────────────────────────────────────
446
- // State field: compute completion state on each transaction
447
- // ─────────────────────────────────────────────────────────────────────
448
- state: {
449
- init() {
450
- return INACTIVE_STATE;
451
- },
452
- apply(transaction, previousState, _oldEditorState, newEditorState) {
453
- return computeCompletionState(previousState, transaction, newEditorState, getConfiguration());
454
- },
455
- },
456
- // ─────────────────────────────────────────────────────────────────────
457
- // Props: keyboard interception when the menu is open
458
- // ─────────────────────────────────────────────────────────────────────
459
- props: {
460
- handleKeyDown(view, event) {
461
- const pluginState = templateCompletionPluginKey.getState(view.state);
462
- if (!pluginState?.active) {
463
- // Menu is not open — let all keys pass through
464
- return false;
465
- }
466
- const { suggestions, activeIndex, tokenFrom } = pluginState;
467
- switch (event.key) {
468
- case 'ArrowDown': {
469
- if (suggestions.length === 0)
470
- return false;
471
- const nextIndex = (activeIndex + 1) % suggestions.length;
472
- view.dispatch(view.state.tr.setMeta(templateCompletionPluginKey, {
473
- type: 'navigate',
474
- index: nextIndex,
475
- }));
476
- event.preventDefault();
477
- return true;
478
- }
479
- case 'ArrowUp': {
480
- if (suggestions.length === 0)
481
- return false;
482
- const previousIndex = (activeIndex - 1 + suggestions.length) % suggestions.length;
483
- view.dispatch(view.state.tr.setMeta(templateCompletionPluginKey, {
484
- type: 'navigate',
485
- index: previousIndex,
486
- }));
487
- event.preventDefault();
488
- return true;
489
- }
490
- case 'Enter': {
491
- if (suggestions.length === 0)
492
- return false;
493
- const selected = suggestions[activeIndex];
494
- if (selected) {
495
- acceptSuggestion(view, selected, tokenFrom);
496
- event.preventDefault();
497
- return true;
498
- }
499
- return false;
500
- }
501
- case 'Tab': {
502
- // Accept active suggestion when menu is open with suggestions.
503
- // When menu is NOT open, this returns false above (before the switch).
504
- if (suggestions.length === 0)
505
- return false;
506
- const tabSelected = suggestions[activeIndex];
507
- if (tabSelected) {
508
- acceptSuggestion(view, tabSelected, tokenFrom);
509
- event.preventDefault();
510
- return true;
511
- }
512
- return false;
513
- }
514
- case 'Escape': {
515
- view.dispatch(view.state.tr.setMeta(templateCompletionPluginKey, {
516
- type: 'close',
517
- }));
518
- event.preventDefault();
519
- return true;
520
- }
521
- default:
522
- return false;
523
- }
524
- },
525
- },
526
- // ─────────────────────────────────────────────────────────────────────
527
- // View: manage DOM popup and async lookup lifecycle
528
- // ─────────────────────────────────────────────────────────────────────
529
- view(editorView) {
530
- // Create the popup element and append it to the editor's parent
531
- const popup = createPopupElement();
532
- const parentElement = editorView.dom.parentElement ?? document.body;
533
- parentElement.appendChild(popup);
534
- // Async lookup state
535
- let currentAbortController = null;
536
- let debounceTimeout = null;
537
- /**
538
- * Update popup visibility, content, and position based on current state.
539
- */
540
- function updatePopup(view) {
541
- const pluginState = templateCompletionPluginKey.getState(view.state);
542
- if (!pluginState?.active || pluginState.suggestions.length === 0) {
543
- popup.style.display = 'none';
544
- return;
545
- }
546
- popup.style.display = '';
547
- renderSuggestions(popup, pluginState, view);
548
- positionPopup(popup, view, pluginState.cursorPos);
549
- }
550
- /**
551
- * Cancel any pending async lookup.
552
- */
553
- function cancelAsyncLookup() {
554
- currentAbortController?.abort();
555
- currentAbortController = null;
556
- if (debounceTimeout !== null) {
557
- clearTimeout(debounceTimeout);
558
- debounceTimeout = null;
559
- }
560
- }
561
- // Initial render
562
- updatePopup(editorView);
563
- return {
564
- update(view, previousEditorState) {
565
- const pluginState = templateCompletionPluginKey.getState(view.state);
566
- const previousPluginState = templateCompletionPluginKey.getState(previousEditorState);
567
- // If menu closed, cancel any pending async lookup
568
- if (!pluginState?.active) {
569
- cancelAsyncLookup();
570
- updatePopup(view);
571
- return;
572
- }
573
- // If the query changed, trigger a new async lookup (if configured)
574
- if (pluginState.active && pluginState.query !== previousPluginState?.query) {
575
- cancelAsyncLookup();
576
- const configuration = getConfiguration();
577
- if (configuration?.lookupCandidates) {
578
- const abortController = new AbortController();
579
- currentAbortController = abortController;
580
- const lookupDebounceMs = configuration.lookupDebounceMs ?? DEFAULT_LOOKUP_DEBOUNCE_MS;
581
- debounceTimeout = setTimeout(async () => {
582
- debounceTimeout = null;
583
- try {
584
- const asyncResults = await configuration.lookupCandidates(pluginState.query, abortController.signal);
585
- // Abort controller may have been replaced since the lookup started
586
- if (abortController.signal.aborted)
587
- return;
588
- // Dispatch async results into the plugin state
589
- view.dispatch(view.state.tr.setMeta(templateCompletionPluginKey, {
590
- type: 'asyncResults',
591
- candidates: asyncResults,
592
- }));
593
- }
594
- catch {
595
- // Ignore errors from aborted requests or lookup failures.
596
- // The popup will continue showing static results (if any).
597
- }
598
- }, lookupDebounceMs);
599
- }
600
- }
601
- // Update popup rendering
602
- updatePopup(view);
603
- },
604
- destroy() {
605
- cancelAsyncLookup();
606
- // Remove the popup from the DOM
607
- if (popup.parentElement) {
608
- popup.parentElement.removeChild(popup);
609
- }
610
- },
611
- };
612
- },
613
- });
614
- });
615
- }