@ecsplico/editor 3.6.0 → 4.1.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 (593) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/adapters/direct-ai.d.ts +4 -4
  3. package/dist/adapters/direct-ai.js +2 -2
  4. package/dist/adapters/direct-ai.js.map +1 -1
  5. package/dist/adapters/document-state.d.ts +1 -1
  6. package/dist/adapters/document-state.js.map +1 -1
  7. package/dist/adapters/forge.d.ts +2 -2
  8. package/dist/adapters/forge.js.map +1 -1
  9. package/dist/adapters/nitro.d.ts +11 -3
  10. package/dist/adapters/nitro.js +3 -1
  11. package/dist/adapters/nitro.js.map +1 -1
  12. package/dist/adapters/shared.d.ts +6 -6
  13. package/dist/adapters/shared.js.map +1 -1
  14. package/dist/code/CodeSurface.vue.d.ts +3 -3
  15. package/dist/config/index.d.ts +14 -14
  16. package/dist/config/index.js +8 -8
  17. package/dist/config/index.js.map +1 -1
  18. package/dist/core/backend-types.d.ts +3 -3
  19. package/dist/core/backend-types.js.map +1 -1
  20. package/dist/core/backend.d.ts +4 -4
  21. package/dist/core/backend.js.map +1 -1
  22. package/dist/core/block-convert.d.ts +1 -1
  23. package/dist/core/block-convert.js +5 -5
  24. package/dist/core/block-convert.js.map +1 -1
  25. package/dist/core/block-transfer.d.ts +8 -4
  26. package/dist/core/block-transfer.js +23 -14
  27. package/dist/core/block-transfer.js.map +1 -1
  28. package/dist/core/capabilities.d.ts +113 -0
  29. package/dist/core/capabilities.js +155 -0
  30. package/dist/core/capabilities.js.map +1 -0
  31. package/dist/core/command-types.d.ts +1 -1
  32. package/dist/core/context.js.map +1 -1
  33. package/dist/core/convert.d.ts +5 -5
  34. package/dist/core/convert.js +5 -5
  35. package/dist/core/convert.js.map +1 -1
  36. package/dist/core/core-feature.js +1 -1
  37. package/dist/core/define-editor.d.ts +2 -2
  38. package/dist/core/define-editor.js +34 -6
  39. package/dist/core/define-editor.js.map +1 -1
  40. package/dist/core/derivation.d.ts +119 -0
  41. package/dist/core/derivation.js +187 -0
  42. package/dist/core/derivation.js.map +1 -0
  43. package/dist/core/derive.d.ts +61 -0
  44. package/dist/core/derive.js +69 -0
  45. package/dist/core/derive.js.map +1 -0
  46. package/dist/core/extension-points.d.ts +16 -0
  47. package/dist/core/feature-context.d.ts +5 -1
  48. package/dist/core/feature-context.js +10 -3
  49. package/dist/core/feature-context.js.map +1 -1
  50. package/dist/core/feature.d.ts +41 -19
  51. package/dist/core/feature.js.map +1 -1
  52. package/dist/core/fences.js +1 -1
  53. package/dist/core/fences.js.map +1 -1
  54. package/dist/core/index.d.ts +6 -2
  55. package/dist/core/index.js +5 -1
  56. package/dist/core/pipeline.d.ts +14 -5
  57. package/dist/core/pipeline.js +19 -7
  58. package/dist/core/pipeline.js.map +1 -1
  59. package/dist/core/properties.d.ts +22 -0
  60. package/dist/core/properties.js +17 -0
  61. package/dist/core/properties.js.map +1 -0
  62. package/dist/core/schema/block-ids.js +5 -5
  63. package/dist/core/schema/block-ids.js.map +1 -1
  64. package/dist/core/schema/index.d.ts +2 -1
  65. package/dist/core/schema/index.js +2 -1
  66. package/dist/core/schema/index.js.map +1 -1
  67. package/dist/core/schema/opaque-fence.d.ts +4 -4
  68. package/dist/core/schema/opaque-fence.js +7 -7
  69. package/dist/core/schema/opaque-fence.js.map +1 -1
  70. package/dist/core/schema/persisted-names.d.ts +58 -0
  71. package/dist/core/schema/persisted-names.js +96 -0
  72. package/dist/core/schema/persisted-names.js.map +1 -0
  73. package/dist/core/toolbar-items.js +1 -1
  74. package/dist/core/toolbar-items.js.map +1 -1
  75. package/dist/core/util.js +5 -1
  76. package/dist/core/util.js.map +1 -1
  77. package/dist/document/DocumentSurface.vue.d.ts +3 -3
  78. package/dist/features/ai/agent-ops.js +1 -1
  79. package/dist/features/ai/ai-review.js +1 -1
  80. package/dist/features/ai/assistant.d.ts +4 -4
  81. package/dist/features/ai/assistant.js +1 -1
  82. package/dist/features/ai/assistant.js.map +1 -1
  83. package/dist/features/ai/components/AiSelectionMenu.js +1 -1
  84. package/dist/features/ai/components/AiSelectionMenu.js.map +1 -1
  85. package/dist/features/ai/components/ModelQuickSwitch.js +7 -7
  86. package/dist/features/ai/components/ModelQuickSwitch.js.map +1 -1
  87. package/dist/features/ai/components/ModelQuickSwitch.vue.d.ts +4 -4
  88. package/dist/features/ai/components/SettingsAiTab.js +8 -8
  89. package/dist/features/ai/components/SettingsAiTab.js.map +1 -1
  90. package/dist/features/ai/components/SettingsModelProfiles.js +1 -1
  91. package/dist/features/ai/components/SettingsModelProfiles.js.map +1 -1
  92. package/dist/features/ai/document-chat-model.d.ts +2 -2
  93. package/dist/features/ai/document-chat-model.js +5 -5
  94. package/dist/features/ai/document-chat-model.js.map +1 -1
  95. package/dist/features/ai/document-chat.js +2 -2
  96. package/dist/features/ai/document-chat.js.map +1 -1
  97. package/dist/features/ai/feature.d.ts +2 -2
  98. package/dist/features/ai/feature.js +2 -2
  99. package/dist/features/ai/feature.js.map +1 -1
  100. package/dist/features/ai/ghost-autocomplete.d.ts +4 -4
  101. package/dist/features/ai/ghost-autocomplete.js +1 -1
  102. package/dist/features/ai/ghost-autocomplete.js.map +1 -1
  103. package/dist/features/ai/index.d.ts +3 -3
  104. package/dist/features/ai/index.js +2 -2
  105. package/dist/features/ai/model-profiles.d.ts +9 -9
  106. package/dist/features/ai/model-profiles.js +13 -13
  107. package/dist/features/ai/model-profiles.js.map +1 -1
  108. package/dist/features/ai/protocol/agent-ops.d.ts +2 -2
  109. package/dist/features/ai/protocol/agent-ops.js +1 -1
  110. package/dist/features/ai/protocol/agent-ops.js.map +1 -1
  111. package/dist/features/ai/protocol/block-lines.d.ts +7 -7
  112. package/dist/features/ai/protocol/block-lines.js +10 -10
  113. package/dist/features/ai/protocol/block-lines.js.map +1 -1
  114. package/dist/features/ai/protocol/chat.d.ts +5 -5
  115. package/dist/features/ai/protocol/chat.js +12 -12
  116. package/dist/features/ai/protocol/chat.js.map +1 -1
  117. package/dist/features/ai/protocol/generate.d.ts +1 -1
  118. package/dist/features/ai/protocol/generate.js +1 -1
  119. package/dist/features/ai/protocol/generate.js.map +1 -1
  120. package/dist/features/ai/protocol/index.d.ts +3 -3
  121. package/dist/features/ai/protocol/index.js +2 -2
  122. package/dist/features/ai/protocol/models.d.ts +3 -3
  123. package/dist/features/ai/protocol/models.js +3 -3
  124. package/dist/features/ai/protocol/models.js.map +1 -1
  125. package/dist/features/ai/protocol/schemas.d.ts +1 -1
  126. package/dist/features/ai/protocol/schemas.js +1 -1
  127. package/dist/features/ai/protocol/schemas.js.map +1 -1
  128. package/dist/features/ai/protocol/tasks.d.ts +5 -5
  129. package/dist/features/ai/protocol/tasks.js +12 -12
  130. package/dist/features/ai/protocol/tasks.js.map +1 -1
  131. package/dist/features/ai/react/AiSelectionMenu.js.map +1 -1
  132. package/dist/features/ai/react/ModelQuickSwitch.d.ts +4 -4
  133. package/dist/features/ai/react/ModelQuickSwitch.js +6 -6
  134. package/dist/features/ai/react/ModelQuickSwitch.js.map +1 -1
  135. package/dist/features/ai/react/SettingsAiTab.d.ts +1 -1
  136. package/dist/features/ai/react/SettingsAiTab.js +8 -8
  137. package/dist/features/ai/react/SettingsAiTab.js.map +1 -1
  138. package/dist/features/ai/react/SettingsModelProfiles.d.ts +1 -1
  139. package/dist/features/ai/react/SettingsModelProfiles.js +1 -1
  140. package/dist/features/ai/react/SettingsModelProfiles.js.map +1 -1
  141. package/dist/features/ai/react/use-ai-assistant.d.ts +1 -1
  142. package/dist/features/ai/react/use-ai-assistant.js +1 -1
  143. package/dist/features/ai/react/use-ai-assistant.js.map +1 -1
  144. package/dist/features/ai/react/use-model-profiles.d.ts +5 -5
  145. package/dist/features/ai/react/use-model-profiles.js +2 -2
  146. package/dist/features/ai/react/use-model-profiles.js.map +1 -1
  147. package/dist/features/ai/use-ai-assistant.d.ts +1 -1
  148. package/dist/features/ai/use-ai-assistant.js +1 -1
  149. package/dist/features/ai/use-ai-assistant.js.map +1 -1
  150. package/dist/features/ai/use-model-profiles.d.ts +4 -4
  151. package/dist/features/ai/use-model-profiles.js +2 -2
  152. package/dist/features/ai/use-model-profiles.js.map +1 -1
  153. package/dist/features/block-ui/block-actions.d.ts +8 -4
  154. package/dist/features/block-ui/block-actions.js +38 -22
  155. package/dist/features/block-ui/block-actions.js.map +1 -1
  156. package/dist/features/block-ui/block-target.d.ts +29 -0
  157. package/dist/features/block-ui/block-target.js +63 -0
  158. package/dist/features/block-ui/block-target.js.map +1 -0
  159. package/dist/features/block-ui/components/BlockHandles.js +3 -3
  160. package/dist/features/block-ui/components/BlockHandles.js.map +1 -1
  161. package/dist/features/block-ui/components/BlockUi.js +11 -23
  162. package/dist/features/block-ui/components/BlockUi.js.map +1 -1
  163. package/dist/features/block-ui/feature.d.ts +3 -2
  164. package/dist/features/block-ui/feature.js +3 -2
  165. package/dist/features/block-ui/feature.js.map +1 -1
  166. package/dist/features/block-ui/handle-geometry.js +12 -23
  167. package/dist/features/block-ui/handle-geometry.js.map +1 -1
  168. package/dist/features/block-ui/index.d.ts +2 -1
  169. package/dist/features/block-ui/index.js +2 -1
  170. package/dist/features/block-ui/react/BlockHandles.d.ts +1 -1
  171. package/dist/features/block-ui/react/BlockHandles.js +4 -4
  172. package/dist/features/block-ui/react/BlockHandles.js.map +1 -1
  173. package/dist/features/block-ui/react/BlockUi.js +13 -25
  174. package/dist/features/block-ui/react/BlockUi.js.map +1 -1
  175. package/dist/features/comments/model.js +1 -1
  176. package/dist/features/composites/accepted-children.d.ts +5 -4
  177. package/dist/features/composites/accepted-children.js +26 -26
  178. package/dist/features/composites/accepted-children.js.map +1 -1
  179. package/dist/features/composites/ai-brief.d.ts +4 -4
  180. package/dist/features/composites/ai-brief.js +14 -12
  181. package/dist/features/composites/ai-brief.js.map +1 -1
  182. package/dist/features/composites/anchors.d.ts +1 -1
  183. package/dist/features/composites/anchors.js.map +1 -1
  184. package/dist/features/composites/baskets.d.ts +1 -1
  185. package/dist/features/composites/baskets.js.map +1 -1
  186. package/dist/features/composites/bibliography-command.d.ts +1 -1
  187. package/dist/features/composites/bibliography-form.js +1 -1
  188. package/dist/features/composites/bibliography-form.js.map +1 -1
  189. package/dist/features/composites/bibliography.js.map +1 -1
  190. package/dist/features/composites/block-types-json.d.ts +38 -0
  191. package/dist/features/composites/block-types-json.js +122 -0
  192. package/dist/features/composites/block-types-json.js.map +1 -0
  193. package/dist/features/composites/block-types.d.ts +119 -0
  194. package/dist/features/composites/block-types.js +343 -0
  195. package/dist/features/composites/block-types.js.map +1 -0
  196. package/dist/features/composites/capabilities.js +109 -0
  197. package/dist/features/composites/capabilities.js.map +1 -0
  198. package/dist/features/composites/components/BibliographyEditor.js +5 -5
  199. package/dist/features/composites/components/BibliographyEditor.js.map +1 -1
  200. package/dist/features/composites/components/CompositeBasketMenu.js +2 -2
  201. package/dist/features/composites/components/CompositeBasketMenu.js.map +1 -1
  202. package/dist/features/composites/components/CompositeChrome.js +18 -8
  203. package/dist/features/composites/components/CompositeChrome.js.map +1 -1
  204. package/dist/features/composites/components/CompositeChrome.vue.d.ts +1 -1
  205. package/dist/features/composites/components/CompositeDetails.js +11 -10
  206. package/dist/features/composites/components/CompositeDetails.js.map +1 -1
  207. package/dist/features/composites/components/CompositeDetails.vue.d.ts +1 -1
  208. package/dist/features/composites/components/CompositeFieldEditor.js +7 -7
  209. package/dist/features/composites/components/CompositeFieldEditor.js.map +1 -1
  210. package/dist/features/composites/components/CompositeFieldEditor.vue.d.ts +5 -5
  211. package/dist/features/composites/components/CompositeInspector.js +136 -113
  212. package/dist/features/composites/components/CompositeInspector.js.map +1 -1
  213. package/dist/features/composites/components/CompositeInspector.vue.d.ts +3 -3
  214. package/dist/features/composites/components/CompositeStatusMenu.js +2 -2
  215. package/dist/features/composites/components/CompositeStatusMenu.js.map +1 -1
  216. package/dist/features/composites/components/CompositeSummaryEditor.js +1 -1
  217. package/dist/features/composites/components/CompositeSummaryEditor.js.map +1 -1
  218. package/dist/features/composites/components/CompositeSummaryEditor.vue.d.ts +1 -1
  219. package/dist/features/composites/components/CompositeTable.js +2 -2
  220. package/dist/features/composites/components/CompositeTable.js.map +1 -1
  221. package/dist/features/composites/components/CompositeTagsEditor.js +1 -1
  222. package/dist/features/composites/components/CompositeTagsEditor.js.map +1 -1
  223. package/dist/features/composites/components/CompositeTagsEditor.vue.d.ts +1 -1
  224. package/dist/features/composites/components/CompositeView.js +19 -17
  225. package/dist/features/composites/components/CompositeView.js.map +1 -1
  226. package/dist/features/composites/components/DerivationBadge.js +15 -6
  227. package/dist/features/composites/components/DerivationBadge.js.map +1 -1
  228. package/dist/features/composites/components/FocusChip.js +1 -1
  229. package/dist/features/composites/components/FocusChip.js.map +1 -1
  230. package/dist/features/composites/components/FocusChip.vue.d.ts +1 -1
  231. package/dist/features/composites/components/ReferenceFieldSelect.js +3 -3
  232. package/dist/features/composites/components/ReferenceFieldSelect.js.map +1 -1
  233. package/dist/features/composites/components/ReferenceView.js +1 -1
  234. package/dist/features/composites/components/ReferenceView.js.map +1 -1
  235. package/dist/features/composites/components/SettingsEditingTab.js +18 -18
  236. package/dist/features/composites/components/SettingsEditingTab.js.map +1 -1
  237. package/dist/features/composites/components/SettingsEditingTab.vue.d.ts +3 -3
  238. package/dist/features/composites/convert.d.ts +4 -4
  239. package/dist/features/composites/convert.js +27 -28
  240. package/dist/features/composites/convert.js.map +1 -1
  241. package/dist/features/composites/derived-chrome.js +34 -28
  242. package/dist/features/composites/derived-chrome.js.map +1 -1
  243. package/dist/features/composites/editing-settings-keys.js +6 -6
  244. package/dist/features/composites/editing-settings-keys.js.map +1 -1
  245. package/dist/features/composites/feature.d.ts +10 -10
  246. package/dist/features/composites/feature.js +58 -46
  247. package/dist/features/composites/feature.js.map +1 -1
  248. package/dist/features/composites/fences.d.ts +3 -3
  249. package/dist/features/composites/fences.js +18 -13
  250. package/dist/features/composites/fences.js.map +1 -1
  251. package/dist/features/composites/focus.d.ts +10 -10
  252. package/dist/features/composites/focus.js +11 -11
  253. package/dist/features/composites/focus.js.map +1 -1
  254. package/dist/features/composites/heading-composites.d.ts +5 -5
  255. package/dist/features/composites/heading-composites.js +13 -16
  256. package/dist/features/composites/heading-composites.js.map +1 -1
  257. package/dist/features/composites/index.d.ts +20 -18
  258. package/dist/features/composites/index.js +9 -7
  259. package/dist/features/composites/inspector-model.d.ts +45 -22
  260. package/dist/features/composites/inspector-model.js +53 -14
  261. package/dist/features/composites/inspector-model.js.map +1 -1
  262. package/dist/features/composites/legacy.d.ts +5 -4
  263. package/dist/features/composites/legacy.js +16 -23
  264. package/dist/features/composites/legacy.js.map +1 -1
  265. package/dist/features/composites/markdown-export.js +3 -3
  266. package/dist/features/composites/markdown-export.js.map +1 -1
  267. package/dist/features/composites/merge.d.ts +8 -8
  268. package/dist/features/composites/merge.js +23 -22
  269. package/dist/features/composites/merge.js.map +1 -1
  270. package/dist/features/composites/meta-display.js +5 -5
  271. package/dist/features/composites/meta-display.js.map +1 -1
  272. package/dist/features/composites/meta-keys.d.ts +5 -5
  273. package/dist/features/composites/meta-keys.js +8 -8
  274. package/dist/features/composites/meta-keys.js.map +1 -1
  275. package/dist/features/composites/node-views.d.ts +3 -3
  276. package/dist/features/composites/node-views.js +2 -2
  277. package/dist/features/composites/node-views.js.map +1 -1
  278. package/dist/features/composites/nodes.d.ts +13 -13
  279. package/dist/features/composites/nodes.js +100 -77
  280. package/dist/features/composites/nodes.js.map +1 -1
  281. package/dist/features/composites/outline.d.ts +15 -12
  282. package/dist/features/composites/outline.js +24 -21
  283. package/dist/features/composites/outline.js.map +1 -1
  284. package/dist/features/composites/properties.d.ts +51 -0
  285. package/dist/features/composites/properties.js +89 -0
  286. package/dist/features/composites/properties.js.map +1 -0
  287. package/dist/features/composites/react/BibliographyEditor.js +5 -5
  288. package/dist/features/composites/react/BibliographyEditor.js.map +1 -1
  289. package/dist/features/composites/react/CompositeBasketMenu.js +2 -2
  290. package/dist/features/composites/react/CompositeBasketMenu.js.map +1 -1
  291. package/dist/features/composites/react/CompositeChrome.d.ts +1 -1
  292. package/dist/features/composites/react/CompositeChrome.js +15 -6
  293. package/dist/features/composites/react/CompositeChrome.js.map +1 -1
  294. package/dist/features/composites/react/CompositeDetails.d.ts +1 -1
  295. package/dist/features/composites/react/CompositeDetails.js +11 -10
  296. package/dist/features/composites/react/CompositeDetails.js.map +1 -1
  297. package/dist/features/composites/react/CompositeFieldEditor.d.ts +5 -5
  298. package/dist/features/composites/react/CompositeFieldEditor.js +6 -6
  299. package/dist/features/composites/react/CompositeFieldEditor.js.map +1 -1
  300. package/dist/features/composites/react/CompositeInspector.d.ts +3 -3
  301. package/dist/features/composites/react/CompositeInspector.js +142 -128
  302. package/dist/features/composites/react/CompositeInspector.js.map +1 -1
  303. package/dist/features/composites/react/CompositeStatusMenu.js +2 -2
  304. package/dist/features/composites/react/CompositeStatusMenu.js.map +1 -1
  305. package/dist/features/composites/react/CompositeSummaryEditor.d.ts +1 -1
  306. package/dist/features/composites/react/CompositeSummaryEditor.js +1 -1
  307. package/dist/features/composites/react/CompositeSummaryEditor.js.map +1 -1
  308. package/dist/features/composites/react/CompositeTable.d.ts +1 -1
  309. package/dist/features/composites/react/CompositeTable.js +3 -3
  310. package/dist/features/composites/react/CompositeTable.js.map +1 -1
  311. package/dist/features/composites/react/CompositeTagsEditor.d.ts +1 -1
  312. package/dist/features/composites/react/CompositeTagsEditor.js +1 -1
  313. package/dist/features/composites/react/CompositeTagsEditor.js.map +1 -1
  314. package/dist/features/composites/react/CompositeView.js +17 -15
  315. package/dist/features/composites/react/CompositeView.js.map +1 -1
  316. package/dist/features/composites/react/DerivationBadge.js +13 -4
  317. package/dist/features/composites/react/DerivationBadge.js.map +1 -1
  318. package/dist/features/composites/react/FocusChip.d.ts +1 -1
  319. package/dist/features/composites/react/FocusChip.js +1 -1
  320. package/dist/features/composites/react/FocusChip.js.map +1 -1
  321. package/dist/features/composites/react/ReferenceFieldSelect.js +3 -3
  322. package/dist/features/composites/react/ReferenceFieldSelect.js.map +1 -1
  323. package/dist/features/composites/react/ReferenceView.d.ts +1 -1
  324. package/dist/features/composites/react/ReferenceView.js +1 -1
  325. package/dist/features/composites/react/ReferenceView.js.map +1 -1
  326. package/dist/features/composites/react/SettingsEditingTab.d.ts +4 -4
  327. package/dist/features/composites/react/SettingsEditingTab.js +20 -20
  328. package/dist/features/composites/react/SettingsEditingTab.js.map +1 -1
  329. package/dist/features/composites/react.js +1 -1
  330. package/dist/features/composites/react.js.map +1 -1
  331. package/dist/features/composites/reference-ai.js +1 -1
  332. package/dist/features/composites/reference-ai.js.map +1 -1
  333. package/dist/features/composites/reference-label.d.ts +3 -3
  334. package/dist/features/composites/reference-label.js +6 -6
  335. package/dist/features/composites/reference-label.js.map +1 -1
  336. package/dist/features/composites/reference-suggestion.d.ts +1 -1
  337. package/dist/features/composites/reference-suggestion.js +3 -3
  338. package/dist/features/composites/reference-suggestion.js.map +1 -1
  339. package/dist/features/composites/reference-text.d.ts +2 -2
  340. package/dist/features/composites/reference-text.js +4 -4
  341. package/dist/features/composites/reference-text.js.map +1 -1
  342. package/dist/features/composites/reference.d.ts +3 -3
  343. package/dist/features/composites/reference.js +1 -1
  344. package/dist/features/composites/reference.js.map +1 -1
  345. package/dist/features/composites/reveal-source.d.ts +3 -3
  346. package/dist/features/composites/reveal-source.js +6 -6
  347. package/dist/features/composites/reveal-source.js.map +1 -1
  348. package/dist/features/composites/rows-model.d.ts +2 -2
  349. package/dist/features/composites/rows-model.js +4 -3
  350. package/dist/features/composites/rows-model.js.map +1 -1
  351. package/dist/features/composites/rows.d.ts +16 -28
  352. package/dist/features/composites/rows.js +20 -54
  353. package/dist/features/composites/rows.js.map +1 -1
  354. package/dist/features/composites/schema.d.ts +12 -11
  355. package/dist/features/composites/schema.js +10 -9
  356. package/dist/features/composites/schema.js.map +1 -1
  357. package/dist/features/composites/source.d.ts +20 -0
  358. package/dist/features/composites/source.js +40 -0
  359. package/dist/features/composites/source.js.map +1 -0
  360. package/dist/features/composites/split.d.ts +11 -11
  361. package/dist/features/composites/split.js +20 -20
  362. package/dist/features/composites/split.js.map +1 -1
  363. package/dist/features/composites/structure-mode.js +3 -3
  364. package/dist/features/composites/structure-mode.js.map +1 -1
  365. package/dist/features/composites/table-model.js +2 -2
  366. package/dist/features/composites/table-model.js.map +1 -1
  367. package/dist/features/composites/use-composite-inspector.js +3 -1
  368. package/dist/features/composites/use-composite-inspector.js.map +1 -1
  369. package/dist/features/composites/use-composite-rows.d.ts +2 -2
  370. package/dist/features/composites/use-composite-rows.js.map +1 -1
  371. package/dist/features/composites/vue.js +1 -1
  372. package/dist/features/composites/vue.js.map +1 -1
  373. package/dist/features/image-studio/components/ImageStudioDialog.js +150 -87
  374. package/dist/features/image-studio/components/ImageStudioDialog.js.map +1 -1
  375. package/dist/features/image-studio/components/ImageStudioDialog.vue.d.ts +5 -1
  376. package/dist/features/image-studio/components/ImageStudioLibraryPanel.js +186 -0
  377. package/dist/features/image-studio/components/ImageStudioLibraryPanel.js.map +1 -0
  378. package/dist/features/image-studio/components/ImageStudioLibraryTile.js +134 -0
  379. package/dist/features/image-studio/components/ImageStudioLibraryTile.js.map +1 -0
  380. package/dist/features/image-studio/components/ImageStudioView.js.map +1 -1
  381. package/dist/features/image-studio/feature.d.ts +1 -1
  382. package/dist/features/image-studio/feature.js +1 -1
  383. package/dist/features/image-studio/feature.js.map +1 -1
  384. package/dist/features/image-studio/index.d.ts +3 -2
  385. package/dist/features/image-studio/index.js +2 -2
  386. package/dist/features/image-studio/library.d.ts +35 -0
  387. package/dist/features/image-studio/node-core.d.ts +3 -3
  388. package/dist/features/image-studio/node-core.js +1 -1
  389. package/dist/features/image-studio/node-core.js.map +1 -1
  390. package/dist/features/image-studio/node-store.d.ts +1 -1
  391. package/dist/features/image-studio/node-store.js +1 -1
  392. package/dist/features/image-studio/node-store.js.map +1 -1
  393. package/dist/features/image-studio/react/ImageStudioDialog.d.ts +1 -1
  394. package/dist/features/image-studio/react/ImageStudioDialog.js +46 -5
  395. package/dist/features/image-studio/react/ImageStudioDialog.js.map +1 -1
  396. package/dist/features/image-studio/react/ImageStudioLibraryPanel.js +141 -0
  397. package/dist/features/image-studio/react/ImageStudioLibraryPanel.js.map +1 -0
  398. package/dist/features/image-studio/react/ImageStudioLibraryTile.js +105 -0
  399. package/dist/features/image-studio/react/ImageStudioLibraryTile.js.map +1 -0
  400. package/dist/features/image-studio/react/ImageStudioView.js +1 -1
  401. package/dist/features/image-studio/react/ImageStudioView.js.map +1 -1
  402. package/dist/features/image-studio/react/store.d.ts +8 -3
  403. package/dist/features/image-studio/react/store.js.map +1 -1
  404. package/dist/features/image-studio/react.d.ts +4 -3
  405. package/dist/features/image-studio/react.js +3 -3
  406. package/dist/features/image-studio/react.js.map +1 -1
  407. package/dist/features/image-studio/schema.d.ts +1 -1
  408. package/dist/features/image-studio/schema.js +1 -1
  409. package/dist/features/image-studio/schema.js.map +1 -1
  410. package/dist/features/image-studio/state.d.ts +8 -3
  411. package/dist/features/image-studio/state.js +11 -3
  412. package/dist/features/image-studio/state.js.map +1 -1
  413. package/dist/features/image-studio/store.d.ts +8 -3
  414. package/dist/features/image-studio/vue.d.ts +4 -3
  415. package/dist/features/image-studio/vue.js +3 -3
  416. package/dist/features/image-studio/vue.js.map +1 -1
  417. package/dist/features/mentions/tag.js +2 -1
  418. package/dist/features/mentions/tag.js.map +1 -1
  419. package/dist/features/themes/components/SettingsAppearanceTab.js +1 -1
  420. package/dist/features/themes/components/SettingsAppearanceTab.js.map +1 -1
  421. package/dist/features/themes/feature.d.ts +1 -1
  422. package/dist/features/themes/feature.js.map +1 -1
  423. package/dist/features/themes/react/SettingsAppearanceTab.d.ts +1 -1
  424. package/dist/features/themes/react/SettingsAppearanceTab.js +1 -1
  425. package/dist/features/themes/react/SettingsAppearanceTab.js.map +1 -1
  426. package/dist/features/themes/theme-runtime.js +1 -1
  427. package/dist/features/themes/theme-runtime.js.map +1 -1
  428. package/dist/features/transcript/TranscriptSegmentView.js +1 -1
  429. package/dist/features/transcript/TranscriptSegmentView.js.map +1 -1
  430. package/dist/features/transcript/react/TranscriptSegmentView.js +1 -1
  431. package/dist/features/transcript/react/TranscriptSegmentView.js.map +1 -1
  432. package/dist/features/transcript/segment-node.js.map +1 -1
  433. package/dist/features/transfer/feature.js +1 -1
  434. package/dist/features/transfer/feature.js.map +1 -1
  435. package/dist/features/transfer/transforms.d.ts +4 -4
  436. package/dist/features/transfer/transforms.js +12 -12
  437. package/dist/features/transfer/transforms.js.map +1 -1
  438. package/dist/i18n/de/ai.js +4 -4
  439. package/dist/i18n/de/ai.js.map +1 -1
  440. package/dist/i18n/de/authors.js +1 -1
  441. package/dist/i18n/de/authors.js.map +1 -1
  442. package/dist/i18n/de/comments.js +1 -1
  443. package/dist/i18n/de/comments.js.map +1 -1
  444. package/dist/i18n/de/composites.js +62 -59
  445. package/dist/i18n/de/composites.js.map +1 -1
  446. package/dist/i18n/de/image-studio.js +11 -2
  447. package/dist/i18n/de/image-studio.js.map +1 -1
  448. package/dist/i18n/de/integrations.js +20 -20
  449. package/dist/i18n/de/integrations.js.map +1 -1
  450. package/dist/i18n/de/markdown.js +1 -1
  451. package/dist/i18n/de/markdown.js.map +1 -1
  452. package/dist/i18n/de/palette.js +1 -1
  453. package/dist/i18n/de/palette.js.map +1 -1
  454. package/dist/i18n/de/themes.js +3 -3
  455. package/dist/i18n/de/themes.js.map +1 -1
  456. package/dist/i18n/de/transfer.js +2 -2
  457. package/dist/i18n/de/transfer.js.map +1 -1
  458. package/dist/i18n/de/tree.js +6 -6
  459. package/dist/i18n/de/tree.js.map +1 -1
  460. package/dist/i18n/de.d.ts +110 -98
  461. package/dist/i18n/en/ai.js +2 -2
  462. package/dist/i18n/en/ai.js.map +1 -1
  463. package/dist/i18n/en/composites.js +64 -61
  464. package/dist/i18n/en/composites.js.map +1 -1
  465. package/dist/i18n/en/image-studio.js +9 -0
  466. package/dist/i18n/en/image-studio.js.map +1 -1
  467. package/dist/i18n/en/integrations.js +9 -9
  468. package/dist/i18n/en/integrations.js.map +1 -1
  469. package/dist/i18n/en/markdown.js +1 -1
  470. package/dist/i18n/en/markdown.js.map +1 -1
  471. package/dist/i18n/en/palette.js +1 -1
  472. package/dist/i18n/en/palette.js.map +1 -1
  473. package/dist/i18n/en/themes.js +4 -4
  474. package/dist/i18n/en/themes.js.map +1 -1
  475. package/dist/i18n/en/tree.js +5 -5
  476. package/dist/i18n/en/tree.js.map +1 -1
  477. package/dist/index.d.ts +4 -1
  478. package/dist/integrations/composite-ai/bibliography-fetch.d.ts +6 -6
  479. package/dist/integrations/composite-ai/bibliography-fetch.js +19 -19
  480. package/dist/integrations/composite-ai/bibliography-fetch.js.map +1 -1
  481. package/dist/integrations/composite-ai/composite-fill.d.ts +4 -4
  482. package/dist/integrations/composite-ai/composite-fill.js +5 -5
  483. package/dist/integrations/composite-ai/composite-fill.js.map +1 -1
  484. package/dist/integrations/composite-ai/composite-summary.d.ts +2 -2
  485. package/dist/integrations/composite-ai/composite-summary.js +5 -5
  486. package/dist/integrations/composite-ai/composite-summary.js.map +1 -1
  487. package/dist/integrations/composite-ai/derive.d.ts +17 -17
  488. package/dist/integrations/composite-ai/derive.js +27 -26
  489. package/dist/integrations/composite-ai/derive.js.map +1 -1
  490. package/dist/integrations/composite-ai/index.d.ts +14 -15
  491. package/dist/integrations/composite-ai/index.js +98 -77
  492. package/dist/integrations/composite-ai/index.js.map +1 -1
  493. package/dist/integrations/composite-ai/outline-sanitize.d.ts +1 -1
  494. package/dist/integrations/composite-ai/outline-sanitize.js +1 -1
  495. package/dist/integrations/composite-ai/outline-sanitize.js.map +1 -1
  496. package/dist/integrations/composite-ai/rendition.d.ts +9 -9
  497. package/dist/integrations/composite-ai/rendition.js +27 -27
  498. package/dist/integrations/composite-ai/rendition.js.map +1 -1
  499. package/dist/integrations/composite-ai/split.d.ts +8 -8
  500. package/dist/integrations/composite-ai/split.js +12 -12
  501. package/dist/integrations/composite-ai/split.js.map +1 -1
  502. package/dist/integrations/composite-ai/transfer-transforms.d.ts +2 -2
  503. package/dist/integrations/composite-ai/transfer-transforms.js +11 -11
  504. package/dist/integrations/composite-ai/transfer-transforms.js.map +1 -1
  505. package/dist/integrations/composite-media/index.d.ts +4 -3
  506. package/dist/integrations/composite-media/index.js +20 -14
  507. package/dist/integrations/composite-media/index.js.map +1 -1
  508. package/dist/markdown/MarkdownSurface.vue.d.ts +7 -7
  509. package/dist/markdown/document.js +1 -1
  510. package/dist/markdown/document.js.map +1 -1
  511. package/dist/nuxt/module.d.ts +48 -24
  512. package/dist/nuxt/module.js.map +1 -1
  513. package/dist/nuxt/runtime/server/plugins/editor-server.js +3 -2
  514. package/dist/nuxt/runtime/server/plugins/editor-server.js.map +1 -1
  515. package/dist/presets/compose.d.ts +6 -6
  516. package/dist/presets/compose.js +7 -4
  517. package/dist/presets/compose.js.map +1 -1
  518. package/dist/react/AdvancedEditor.d.ts +2 -2
  519. package/dist/react/AdvancedEditor.js +1 -1
  520. package/dist/react/AdvancedEditor.js.map +1 -1
  521. package/dist/react/compose.d.ts +1 -1
  522. package/dist/react/compose.js +1 -1
  523. package/dist/react/compose.js.map +1 -1
  524. package/dist/react/composed-surface.d.ts +5 -5
  525. package/dist/react/composed-surface.js +2 -2
  526. package/dist/react/composed-surface.js.map +1 -1
  527. package/dist/server/ai.d.ts +7 -7
  528. package/dist/server/ai.js +1 -1
  529. package/dist/server/ai.js.map +1 -1
  530. package/dist/server/auth.d.ts +1 -1
  531. package/dist/server/collab-state.d.ts +1 -1
  532. package/dist/server/collab-state.js.map +1 -1
  533. package/dist/server/collab.d.ts +4 -4
  534. package/dist/server/collab.js +22 -17
  535. package/dist/server/collab.js.map +1 -1
  536. package/dist/server/handlers/ai.d.ts +9 -6
  537. package/dist/server/handlers/ai.js +13 -17
  538. package/dist/server/handlers/ai.js.map +1 -1
  539. package/dist/server/handlers/context.d.ts +4 -0
  540. package/dist/server/handlers/context.js.map +1 -1
  541. package/dist/server/handlers/editor.d.ts +33 -32
  542. package/dist/server/handlers/editor.js +13 -8
  543. package/dist/server/handlers/editor.js.map +1 -1
  544. package/dist/server/handlers/images.d.ts +1 -1
  545. package/dist/server/handlers/images.js +1 -1
  546. package/dist/server/handlers/images.js.map +1 -1
  547. package/dist/server/host.d.ts +4 -0
  548. package/dist/server/host.js +10 -2
  549. package/dist/server/host.js.map +1 -1
  550. package/dist/server/index.d.ts +3 -3
  551. package/dist/server/ports.d.ts +8 -8
  552. package/dist/server/ports.js.map +1 -1
  553. package/dist/settings/index.d.ts +20 -19
  554. package/dist/settings/index.js +25 -24
  555. package/dist/settings/index.js.map +1 -1
  556. package/dist/settings/migrate.d.ts +18 -0
  557. package/dist/settings/migrate.js +46 -0
  558. package/dist/settings/migrate.js.map +1 -0
  559. package/dist/settings/values.d.ts +12 -12
  560. package/dist/settings/values.js +11 -11
  561. package/dist/settings/values.js.map +1 -1
  562. package/dist/styles/composites.css +10 -10
  563. package/dist/tree/DocumentTree.js +12 -5
  564. package/dist/tree/DocumentTree.js.map +1 -1
  565. package/dist/tree/drop-rules.js +5 -5
  566. package/dist/tree/drop-rules.js.map +1 -1
  567. package/dist/tree/react/DocumentTree.js +14 -5
  568. package/dist/tree/react/DocumentTree.js.map +1 -1
  569. package/dist/tree/tree-host.js +5 -5
  570. package/dist/tree/tree-host.js.map +1 -1
  571. package/dist/tree/tree-items.js +34 -28
  572. package/dist/tree/tree-items.js.map +1 -1
  573. package/dist/tree/tree-model.js +16 -16
  574. package/dist/tree/tree-model.js.map +1 -1
  575. package/dist/tree/tree-rows.js +2 -2
  576. package/dist/tree/tree-rows.js.map +1 -1
  577. package/dist/tree/tree-view-model.d.ts +2 -2
  578. package/dist/tree/tree-view-model.js.map +1 -1
  579. package/dist/vue/AdvancedEditor.js +2 -2
  580. package/dist/vue/AdvancedEditor.js.map +1 -1
  581. package/dist/vue/AdvancedEditor.vue.d.ts +10 -10
  582. package/dist/vue/SimpleEditor.vue.d.ts +4 -4
  583. package/dist/vue/components/EditorSurface.vue.d.ts +4 -4
  584. package/dist/vue/compose.d.ts +1 -1
  585. package/dist/vue/compose.js +1 -1
  586. package/dist/vue/compose.js.map +1 -1
  587. package/package.json +1 -1
  588. package/dist/features/composites/derivation.d.ts +0 -62
  589. package/dist/features/composites/derivation.js +0 -102
  590. package/dist/features/composites/derivation.js.map +0 -1
  591. package/dist/features/composites/kinds.d.ts +0 -89
  592. package/dist/features/composites/kinds.js +0 -285
  593. package/dist/features/composites/kinds.js.map +0 -1
@@ -1,30 +1,31 @@
1
+ import { blockIdOf, findBlockById, newBlockId } from "../../core/schema/block-ids.js";
2
+ import { capabilitiesOf } from "../../core/capabilities.js";
1
3
  import { parseBlocks } from "../../core/pipeline.js";
2
4
  import { guardsAccept } from "../../core/commands.js";
3
- import { blockIdOf, findBlockById, newBlockId } from "../../core/schema/block-ids.js";
5
+ import { DERIVATION_KEY, derivationOf } from "../../core/derivation.js";
4
6
  import { sha256Hex } from "../../core/hash.js";
5
- import { compositeKind } from "../../features/composites/kinds.js";
6
- import { DERIVATION_KEY } from "../../features/composites/meta-keys.js";
7
- import { bodyMarkdown, derivationOf } from "../../features/composites/derivation.js";
8
- import { compositeJSON, compositeKindsOf } from "../../features/composites/nodes.js";
7
+ import { aiBriefOf, blockTypeOf } from "../../features/composites/block-types.js";
8
+ import { blockTypesOf, compositeJSON } from "../../features/composites/nodes.js";
9
+ import { bodyMarkdown } from "../../features/composites/source.js";
9
10
  import { notifyAiRateLimited } from "../../features/ai/rate-limit.js";
10
11
  import { generateCompositeBody } from "./composite-fill.js";
11
12
  import { Fragment } from "@tiptap/pm/model";
12
13
  //#region src/integrations/composite-ai/derive.ts
13
- /** Kinds a Baustein can be derived into: the ones with an `ai` configuration (their brief drives the generation). */
14
- const derivableKindsOf = (editor) => compositeKindsOf(editor).filter((kind) => kind.ai !== void 0);
15
- /** Whether the Baustein `node` can be the source of a derivation: a composite with a block id (the derivation points at it by id). */
16
- const isDerivableSource = (editor, node) => node.type.name === "composite" && blockIdOf(node) !== null && derivableKindsOf(editor).length > 0;
17
- /** Whether a Baustein of `kindId` may be inserted right after the Baustein at `pos` (the same guards as creating it there). */
14
+ /** Block types a Typed block can be derived into: the ones with the `ai-brief` capability (their brief drives the generation). */
15
+ const derivableBlockTypesOf = (editor) => blockTypesOf(editor).filter((blockType) => aiBriefOf(blockType) !== void 0);
16
+ /** Whether the Typed block `node` can be the source of a derivation: a container block with a block id (the derivation points at it by id). */
17
+ const isDerivableSource = (editor, node) => capabilitiesOf(editor, node).has("container") && blockIdOf(node) !== null && derivableBlockTypesOf(editor).length > 0;
18
+ /** Whether a Typed block of `kindId` may be inserted right after the Typed block at `pos` (the same guards as creating it there). */
18
19
  function canDeriveAfter(editor, pos, kindId) {
19
20
  const source = editor.state.doc.nodeAt(pos);
20
21
  if (!source) return false;
21
22
  const $at = editor.state.doc.resolve(pos + source.nodeSize);
22
23
  return guardsAccept(editor, $at, {
23
- type: "composite",
24
- attrs: { kind: kindId }
24
+ type: "typedBlock",
25
+ attrs: { blockType: kindId }
25
26
  });
26
27
  }
27
- /** Drops the derived Baustein `id` again, unless its body got content meanwhile (the user may have started writing in it). */
28
+ /** Drops the derived Typed block `id` again, unless its body got content meanwhile (the user may have started writing in it). */
28
29
  function discardDerived(editor, id) {
29
30
  const found = editor.isDestroyed ? null : findBlockById(editor.state.doc, id);
30
31
  if (!found) return;
@@ -33,12 +34,12 @@ function discardDerived(editor, id) {
33
34
  }
34
35
  /**
35
36
  * The write-back half of every derivation: parses the streamed `markdown` through the block pipeline and replaces the
36
- * body of the (still empty) derived Baustein `id` with it, in one transaction together with the hash of exactly that
37
- * body as `outputHash` (kept next to the `derivation` the Baustein already carries, else `options.derivation`; a Baustein
37
+ * body of the (still empty) derived Typed block `id` with it, in one transaction together with the hash of exactly that
38
+ * body as `outputHash` (kept next to the `derivation` the Typed block already carries, else `options.derivation`; a Typed block
38
39
  * with neither only gets its body), so one
39
- * undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Baustein
40
- * that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Baustein is revealed and
41
- * `options.done` shown as success notice. The Baustein is found again by its block id, so edits while the model ran do
40
+ * undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Typed block
41
+ * that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Typed block is revealed and
42
+ * `options.done` shown as success notice. The Typed block is found again by its block id, so edits while the model ran do
42
43
  * not misplace the result. Returns whether the body was written.
43
44
  */
44
45
  function writeDerivedBody(editor, id, markdown, options) {
@@ -86,20 +87,20 @@ function writeDerivedBody(editor, id, markdown, options) {
86
87
  return true;
87
88
  }
88
89
  /**
89
- * „Ableiten (KI) → <Art>“: inserts a sibling Baustein of kind `kindId` right after the Baustein at `pos`, titled
90
+ * „Ableiten (KI) → <Art>“: inserts a sibling Typed block of Block type `kindId` right after the Typed block at `pos`, titled
90
91
  * „<Art>: <Quelle>“, whose `meta.derivation` points back at the source block (`from.block`, method `ai:<kindId>`, the
91
92
  * Markdown hash of the source's body as `inputHash`), generates its body from the source (`generateCompositeBody`; the
92
93
  * `aiBlockData` of composites hands the model the source's Markdown) and writes the result directly into the new
93
- * Baustein — no review, the new Baustein is the proposal. The hash of the written body becomes `outputHash`, so a later
94
- * edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Baustein is found again by its
94
+ * Typed block — no review, the new Typed block is the proposal. The hash of the written body becomes `outputHash`, so a later
95
+ * edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Typed block is found again by its
95
96
  * block id after every await, so edits while the model runs do not misplace the result. When the run fails or yields
96
- * nothing the still-empty Baustein is removed again. Notices go through `notify`, in the language of `t`.
97
+ * nothing the still-empty Typed block is removed again. Notices go through `notify`, in the language of `t`.
97
98
  */
98
99
  async function deriveComposite(editor, pos, kindId, ai, modelRef, notify, t) {
99
100
  const source = editor.state.doc.nodeAt(pos);
100
101
  const sourceId = source && blockIdOf(source);
101
- const kind = compositeKindsOf(editor).find((candidate) => candidate.id === kindId);
102
- if (source?.type.name !== "composite" || !sourceId || !kind?.ai) return;
102
+ const kind = blockTypesOf(editor).find((candidate) => candidate.id === kindId);
103
+ if (source?.type.name !== "typedBlock" || !sourceId || !kind || !aiBriefOf(kind)) return;
103
104
  if (!canDeriveAfter(editor, pos, kindId)) {
104
105
  notify({
105
106
  title: t("integrations.compositeDerive.notAccepted"),
@@ -107,7 +108,7 @@ async function deriveComposite(editor, pos, kindId, ai, modelRef, notify, t) {
107
108
  });
108
109
  return;
109
110
  }
110
- const sourceKind = compositeKind(compositeKindsOf(editor), String(source.attrs.kind));
111
+ const sourceKind = blockTypeOf(blockTypesOf(editor), String(source.attrs.blockType));
111
112
  const derivation = {
112
113
  from: { block: sourceId },
113
114
  method: `ai:${kindId}`,
@@ -190,6 +191,6 @@ async function deriveComposite(editor, pos, kindId, ai, modelRef, notify, t) {
190
191
  }
191
192
  }
192
193
  //#endregion
193
- export { canDeriveAfter, derivableKindsOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody };
194
+ export { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody };
194
195
 
195
196
  //# sourceMappingURL=derive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"derive.js","names":[],"sources":["../../../src/integrations/composite-ai/derive.ts"],"sourcesContent":["import type { Editor, JSONContent } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport type { EditorBackend } from '../../core/backend'\nimport { guardsAccept, parseBlocks, sha256Hex } from '../../core'\nimport type { Notifier } from '../../core/notify'\nimport { blockIdOf, findBlockById, newBlockId } from '../../core/schema'\nimport type { Translate } from '../../i18n'\nimport { type ModelRef, notifyAiRateLimited } from '../../features/ai'\nimport { bodyMarkdown, COMPOSITE_CHROME_COUNT, compositeJSON, compositeKind, compositeKindsOf, DERIVATION_KEY, type Derivation, derivationOf } from '../../features/composites/schema'\nimport { generateCompositeBody } from './composite-fill'\n\n/** Kinds a Baustein can be derived into: the ones with an `ai` configuration (their brief drives the generation). */\nexport const derivableKindsOf = (editor: Editor) => compositeKindsOf(editor).filter(kind => kind.ai !== undefined)\n\n/** Whether the Baustein `node` can be the source of a derivation: a composite with a block id (the derivation points at it by id). */\nexport const isDerivableSource = (editor: Editor, node: PMNode) => node.type.name === 'composite' && blockIdOf(node) !== null && derivableKindsOf(editor).length > 0\n\n/** Whether a Baustein of `kindId` may be inserted right after the Baustein at `pos` (the same guards as creating it there). */\nexport function canDeriveAfter(editor: Editor, pos: number, kindId: string): boolean {\n const source = editor.state.doc.nodeAt(pos)\n if (!source) return false\n const $at = editor.state.doc.resolve(pos + source.nodeSize)\n return guardsAccept(editor, $at, { type: 'composite', attrs: { kind: kindId } })\n}\n\n/** Drops the derived Baustein `id` again, unless its body got content meanwhile (the user may have started writing in it). */\nexport function discardDerived(editor: Editor, id: string): void {\n const found = editor.isDestroyed ? null : findBlockById(editor.state.doc, id)\n if (!found) return\n const body = Array.from({ length: found.node.childCount - COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(COMPOSITE_CHROME_COUNT + index))\n if (body.some(child => child.textContent.trim() || child.type.name !== 'paragraph')) return\n editor.view.dispatch(editor.state.tr.delete(found.pos, found.pos + found.node.nodeSize))\n}\n\n/**\n * The write-back half of every derivation: parses the streamed `markdown` through the block pipeline and replaces the\n * body of the (still empty) derived Baustein `id` with it, in one transaction together with the hash of exactly that\n * body as `outputHash` (kept next to the `derivation` the Baustein already carries, else `options.derivation`; a Baustein\n * with neither only gets its body), so one\n * undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Baustein\n * that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Baustein is revealed and\n * `options.done` shown as success notice. The Baustein is found again by its block id, so edits while the model ran do\n * not misplace the result. Returns whether the body was written.\n */\nexport function writeDerivedBody(editor: Editor, id: string, markdown: string, options: { derivation?: Derivation, discard: () => void, notify: Notifier, t: Translate, done: string }): boolean {\n const { derivation, discard, notify, t, done } = options\n const blocks = markdown.trim() ? parseBlocks(editor, markdown).blocks.map(block => editor.schema.nodeFromJSON(block)) : []\n if (!blocks.length) {\n discard()\n notify({ title: t('integrations.compositeDerive.empty.title'), description: t('integrations.compositeDerive.empty.description'), kind: 'error' })\n return false\n }\n const found = findBlockById(editor.state.doc, id)\n if (!found || !found.node.canReplace(COMPOSITE_CHROME_COUNT, found.node.childCount, Fragment.from(blocks))) {\n notify({ title: t('integrations.compositeDerive.gone.title'), description: t('integrations.compositeDerive.gone.description'), kind: 'error' })\n return false\n }\n\n // One transaction: body and the hash of exactly that body, so one undo step removes both.\n const chromeSize = Array.from({ length: COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(index).nodeSize).reduce((sum, size) => sum + size, 0)\n const tr = editor.state.tr.replaceWith(found.pos + 1 + chromeSize, found.pos + found.node.nodeSize - 1, blocks)\n const written = findBlockById(tr.doc, id)!\n const stored = derivationOf(written.node) ?? derivation\n if (stored) {\n tr.setNodeMarkup(written.pos, undefined, {\n ...written.node.attrs,\n meta: { ...written.node.attrs.meta, [DERIVATION_KEY]: { ...stored, outputHash: sha256Hex(bodyMarkdown(editor, written.node)) } },\n })\n }\n editor.view.dispatch(tr)\n editor.commands.revealBlock(id)\n notify({ title: done, kind: 'success', icon: 'i-lucide-git-branch' })\n return true\n}\n\n/**\n * „Ableiten (KI) → <Art>“: inserts a sibling Baustein of kind `kindId` right after the Baustein at `pos`, titled\n * „<Art>: <Quelle>“, whose `meta.derivation` points back at the source block (`from.block`, method `ai:<kindId>`, the\n * Markdown hash of the source's body as `inputHash`), generates its body from the source (`generateCompositeBody`; the\n * `aiBlockData` of composites hands the model the source's Markdown) and writes the result directly into the new\n * Baustein — no review, the new Baustein is the proposal. The hash of the written body becomes `outputHash`, so a later\n * edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Baustein is found again by its\n * block id after every await, so edits while the model runs do not misplace the result. When the run fails or yields\n * nothing the still-empty Baustein is removed again. Notices go through `notify`, in the language of `t`.\n */\nexport async function deriveComposite(editor: Editor, pos: number, kindId: string, ai: NonNullable<EditorBackend['ai']>, modelRef: (slot: 'generate') => ModelRef, notify: Notifier, t: Translate): Promise<void> {\n const source = editor.state.doc.nodeAt(pos)\n const sourceId = source && blockIdOf(source)\n const kind = compositeKindsOf(editor).find(candidate => candidate.id === kindId)\n if (source?.type.name !== 'composite' || !sourceId || !kind?.ai) return\n if (!canDeriveAfter(editor, pos, kindId)) {\n notify({ title: t('integrations.compositeDerive.notAccepted'), kind: 'error' })\n return\n }\n\n const sourceKind = compositeKind(compositeKindsOf(editor), String(source.attrs.kind))\n const derivation: Derivation = {\n from: { block: sourceId },\n method: `ai:${kindId}`,\n createdAt: new Date().toISOString(),\n inputHash: sha256Hex(bodyMarkdown(editor, source)),\n outputHash: '',\n }\n const id = newBlockId()\n const json = compositeJSON(kindId)\n const [title, ...rest] = json.content as JSONContent[]\n const text = `${kind.label}: ${source.child(0).textContent.trim() || sourceKind.label}`\n const created: JSONContent = {\n ...json,\n attrs: { ...json.attrs, id, meta: { [DERIVATION_KEY]: derivation } },\n content: [{ ...title!, content: [{ type: 'text', text }] }, ...rest],\n }\n editor.view.dispatch(editor.state.tr.insert(pos + source.nodeSize, editor.schema.nodeFromJSON(created)))\n\n const toastId = `derive-${id}`\n const controller = new AbortController()\n const abort = () => controller.abort()\n editor.on('destroy', abort)\n notify({ id: toastId, title: t('integrations.compositeDerive.running', { kind: kind.label }), kind: 'info', icon: 'i-lucide-loader-circle', duration: 0 })\n\n const discard = () => discardDerived(editor, id)\n\n try {\n const target = findBlockById(editor.state.doc, id)\n const result = target ? await generateCompositeBody(editor, target.pos, ai, modelRef, t, controller.signal) : null\n if (!result || result.status === 'aborted' || editor.isDestroyed) {\n if (!editor.isDestroyed) discard()\n return\n }\n if (result.status === 'rate-limited') {\n discard()\n notifyAiRateLimited(notify, t)\n return\n }\n if (result.status === 'data-error') {\n discard()\n notify({ title: t('integrations.compositeFill.dataMissing'), description: result.message, kind: 'error' })\n return\n }\n if (result.status === 'error') {\n discard()\n notify({ title: t('integrations.compositeDerive.failed'), description: result.message, kind: 'error' })\n return\n }\n\n writeDerivedBody(editor, id, result.output, { derivation, discard, notify, t, done: t('integrations.compositeDerive.done', { kind: kind.label }) })\n }\n finally {\n notify.dismiss?.(toastId)\n editor.off('destroy', abort)\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,oBAAoB,WAAmB,iBAAiB,MAAM,CAAC,CAAC,QAAO,SAAQ,KAAK,OAAO,KAAA,CAAS;;AAGjH,MAAa,qBAAqB,QAAgB,SAAiB,KAAK,KAAK,SAAS,eAAe,UAAU,IAAI,MAAM,QAAQ,iBAAiB,MAAM,CAAC,CAAC,SAAS;;AAGnK,SAAgB,eAAe,QAAgB,KAAa,QAAyB;CACnF,MAAM,SAAS,OAAO,MAAM,IAAI,OAAO,GAAG;CAC1C,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,MAAM,OAAO,MAAM,IAAI,QAAQ,MAAM,OAAO,QAAQ;CAC1D,OAAO,aAAa,QAAQ,KAAK;EAAE,MAAM;EAAa,OAAO,EAAE,MAAM,OAAO;CAAE,CAAC;AACjF;;AAGA,SAAgB,eAAe,QAAgB,IAAkB;CAC/D,MAAM,QAAQ,OAAO,cAAc,OAAO,cAAc,OAAO,MAAM,KAAK,EAAE;CAC5E,IAAI,CAAC,OAAO;CAEZ,IADa,MAAM,KAAK,EAAE,QAAQ,MAAM,KAAK,aAAA,EAAoC,IAAI,GAAG,UAAU,MAAM,KAAK,MAAA,IAA+B,KAAK,CAC1I,CAAC,CAAC,MAAK,UAAS,MAAM,YAAY,KAAK,KAAK,MAAM,KAAK,SAAS,WAAW,GAAG;CACrF,OAAO,KAAK,SAAS,OAAO,MAAM,GAAG,OAAO,MAAM,KAAK,MAAM,MAAM,MAAM,KAAK,QAAQ,CAAC;AACzF;;;;;;;;;;;AAYA,SAAgB,iBAAiB,QAAgB,IAAY,UAAkB,SAAkH;CAC/L,MAAM,EAAE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from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport type { EditorBackend } from '../../core/backend'\nimport { capabilitiesOf, DERIVATION_KEY, type Derivation, derivationOf, guardsAccept, parseBlocks, sha256Hex } from '../../core'\nimport type { Notifier } from '../../core/notify'\nimport { blockIdOf, findBlockById, newBlockId } from '../../core/schema'\nimport type { Translate } from '../../i18n'\nimport { type ModelRef, notifyAiRateLimited } from '../../features/ai'\nimport { aiBriefOf, blockTypeOf, blockTypesOf, bodyMarkdown, COMPOSITE_CHROME_COUNT, compositeJSON } from '../../features/composites/schema'\nimport { generateCompositeBody } from './composite-fill'\n\n/** Block types a Typed block can be derived into: the ones with the `ai-brief` capability (their brief drives the generation). */\nexport const derivableBlockTypesOf = (editor: Editor) => blockTypesOf(editor).filter(blockType => aiBriefOf(blockType) !== undefined)\n\n/** Whether the Typed block `node` can be the source of a derivation: a container block with a block id (the derivation points at it by id). */\nexport const isDerivableSource = (editor: Editor, node: PMNode) => capabilitiesOf(editor, node).has('container') && blockIdOf(node) !== null && derivableBlockTypesOf(editor).length > 0\n\n/** Whether a Typed block of `kindId` may be inserted right after the Typed block at `pos` (the same guards as creating it there). */\nexport function canDeriveAfter(editor: Editor, pos: number, kindId: string): boolean {\n const source = editor.state.doc.nodeAt(pos)\n if (!source) return false\n const $at = editor.state.doc.resolve(pos + source.nodeSize)\n return guardsAccept(editor, $at, { type: 'typedBlock', attrs: { blockType: kindId } })\n}\n\n/** Drops the derived Typed block `id` again, unless its body got content meanwhile (the user may have started writing in it). */\nexport function discardDerived(editor: Editor, id: string): void {\n const found = editor.isDestroyed ? null : findBlockById(editor.state.doc, id)\n if (!found) return\n const body = Array.from({ length: found.node.childCount - COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(COMPOSITE_CHROME_COUNT + index))\n if (body.some(child => child.textContent.trim() || child.type.name !== 'paragraph')) return\n editor.view.dispatch(editor.state.tr.delete(found.pos, found.pos + found.node.nodeSize))\n}\n\n/**\n * The write-back half of every derivation: parses the streamed `markdown` through the block pipeline and replaces the\n * body of the (still empty) derived Typed block `id` with it, in one transaction together with the hash of exactly that\n * body as `outputHash` (kept next to the `derivation` the Typed block already carries, else `options.derivation`; a Typed block\n * with neither only gets its body), so one\n * undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Typed block\n * that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Typed block is revealed and\n * `options.done` shown as success notice. The Typed block is found again by its block id, so edits while the model ran do\n * not misplace the result. Returns whether the body was written.\n */\nexport function writeDerivedBody(editor: Editor, id: string, markdown: string, options: { derivation?: Derivation, discard: () => void, notify: Notifier, t: Translate, done: string }): boolean {\n const { derivation, discard, notify, t, done } = options\n const blocks = markdown.trim() ? parseBlocks(editor, markdown).blocks.map(block => editor.schema.nodeFromJSON(block)) : []\n if (!blocks.length) {\n discard()\n notify({ title: t('integrations.compositeDerive.empty.title'), description: t('integrations.compositeDerive.empty.description'), kind: 'error' })\n return false\n }\n const found = findBlockById(editor.state.doc, id)\n if (!found || !found.node.canReplace(COMPOSITE_CHROME_COUNT, found.node.childCount, Fragment.from(blocks))) {\n notify({ title: t('integrations.compositeDerive.gone.title'), description: t('integrations.compositeDerive.gone.description'), kind: 'error' })\n return false\n }\n\n // One transaction: body and the hash of exactly that body, so one undo step removes both.\n const chromeSize = Array.from({ length: COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(index).nodeSize).reduce((sum, size) => sum + size, 0)\n const tr = editor.state.tr.replaceWith(found.pos + 1 + chromeSize, found.pos + found.node.nodeSize - 1, blocks)\n const written = findBlockById(tr.doc, id)!\n const stored = derivationOf(written.node) ?? derivation\n if (stored) {\n tr.setNodeMarkup(written.pos, undefined, {\n ...written.node.attrs,\n meta: { ...written.node.attrs.meta, [DERIVATION_KEY]: { ...stored, outputHash: sha256Hex(bodyMarkdown(editor, written.node)) } },\n })\n }\n editor.view.dispatch(tr)\n editor.commands.revealBlock(id)\n notify({ title: done, kind: 'success', icon: 'i-lucide-git-branch' })\n return true\n}\n\n/**\n * „Ableiten (KI) → <Art>“: inserts a sibling Typed block of Block type `kindId` right after the Typed block at `pos`, titled\n * „<Art>: <Quelle>“, whose `meta.derivation` points back at the source block (`from.block`, method `ai:<kindId>`, the\n * Markdown hash of the source's body as `inputHash`), generates its body from the source (`generateCompositeBody`; the\n * `aiBlockData` of composites hands the model the source's Markdown) and writes the result directly into the new\n * Typed block — no review, the new Typed block is the proposal. The hash of the written body becomes `outputHash`, so a later\n * edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Typed block is found again by its\n * block id after every await, so edits while the model runs do not misplace the result. When the run fails or yields\n * nothing the still-empty Typed block is removed again. Notices go through `notify`, in the language of `t`.\n */\nexport async function deriveComposite(editor: Editor, pos: number, kindId: string, ai: NonNullable<EditorBackend['ai']>, modelRef: (slot: 'generate') => ModelRef, notify: Notifier, t: Translate): Promise<void> {\n const source = editor.state.doc.nodeAt(pos)\n const sourceId = source && blockIdOf(source)\n const kind = blockTypesOf(editor).find(candidate => candidate.id === kindId)\n if (source?.type.name !== 'typedBlock' || !sourceId || !kind || !aiBriefOf(kind)) return\n if (!canDeriveAfter(editor, pos, kindId)) {\n notify({ title: t('integrations.compositeDerive.notAccepted'), kind: 'error' })\n return\n }\n\n const sourceKind = blockTypeOf(blockTypesOf(editor), String(source.attrs.blockType))\n const derivation: Derivation = {\n from: { block: sourceId },\n method: `ai:${kindId}`,\n createdAt: new Date().toISOString(),\n inputHash: sha256Hex(bodyMarkdown(editor, source)),\n outputHash: '',\n }\n const id = newBlockId()\n const json = compositeJSON(kindId)\n const [title, ...rest] = json.content as JSONContent[]\n const text = `${kind.label}: ${source.child(0).textContent.trim() || sourceKind.label}`\n const created: JSONContent = {\n ...json,\n attrs: { ...json.attrs, id, meta: { [DERIVATION_KEY]: derivation } },\n content: [{ ...title!, content: [{ type: 'text', text }] }, ...rest],\n }\n editor.view.dispatch(editor.state.tr.insert(pos + source.nodeSize, editor.schema.nodeFromJSON(created)))\n\n const toastId = `derive-${id}`\n const controller = new AbortController()\n const abort = () => controller.abort()\n editor.on('destroy', abort)\n notify({ id: toastId, title: t('integrations.compositeDerive.running', { kind: kind.label }), kind: 'info', icon: 'i-lucide-loader-circle', duration: 0 })\n\n const discard = () => discardDerived(editor, id)\n\n try {\n const target = findBlockById(editor.state.doc, id)\n const result = target ? await generateCompositeBody(editor, target.pos, ai, modelRef, t, controller.signal) : null\n if (!result || result.status === 'aborted' || editor.isDestroyed) {\n if (!editor.isDestroyed) discard()\n return\n }\n if (result.status === 'rate-limited') {\n discard()\n notifyAiRateLimited(notify, t)\n return\n }\n if (result.status === 'data-error') {\n discard()\n notify({ title: t('integrations.compositeFill.dataMissing'), description: result.message, kind: 'error' })\n return\n }\n if (result.status === 'error') {\n discard()\n notify({ title: t('integrations.compositeDerive.failed'), description: result.message, kind: 'error' })\n return\n }\n\n writeDerivedBody(editor, id, result.output, { derivation, discard, notify, t, done: t('integrations.compositeDerive.done', { kind: kind.label }) })\n }\n finally {\n notify.dismiss?.(toastId)\n editor.off('destroy', abort)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,yBAAyB,WAAmB,aAAa,MAAM,CAAC,CAAC,QAAO,cAAa,UAAU,SAAS,MAAM,KAAA,CAAS;;AAGpI,MAAa,qBAAqB,QAAgB,SAAiB,eAAe,QAAQ,IAAI,CAAC,CAAC,IAAI,WAAW,KAAK,UAAU,IAAI,MAAM,QAAQ,sBAAsB,MAAM,CAAC,CAAC,SAAS;;AAGvL,SAAgB,eAAe,QAAgB,KAAa,QAAyB;CACnF,MAAM,SAAS,OAAO,MAAM,IAAI,OAAO,GAAG;CAC1C,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,MAAM,OAAO,MAAM,IAAI,QAAQ,MAAM,OAAO,QAAQ;CAC1D,OAAO,aAAa,QAAQ,KAAK;EAAE,MAAM;EAAc,OAAO,EAAE,WAAW,OAAO;CAAE,CAAC;AACvF;;AAGA,SAA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AE,OAAO,EAAE,wCAAwC;IAAG,aAAa,OAAO;IAAS,MAAM;GAAQ,CAAC;GACzG;EACF;EACA,IAAI,OAAO,WAAW,SAAS;GAC7B,QAAQ;GACR,OAAO;IAAE,OAAO,EAAE,qCAAqC;IAAG,aAAa,OAAO;IAAS,MAAM;GAAQ,CAAC;GACtG;EACF;EAEA,iBAAiB,QAAQ,IAAI,OAAO,QAAQ;GAAE;GAAY;GAAS;GAAQ;GAAG,MAAM,EAAE,qCAAqC,EAAE,MAAM,KAAK,MAAM,CAAC;EAAE,CAAC;CACpJ,UACQ;EACN,OAAO,UAAU,OAAO;EACxB,OAAO,IAAI,WAAW,KAAK;CAC7B;AACF"}
@@ -5,27 +5,26 @@ import { bulletsTransform, summaryTransform, transferRequest } from "./transfer-
5
5
  import { CompositeBodyResult, fillComposite, generateCompositeBody } from "./composite-fill.js";
6
6
  import { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from "./composite-summary.js";
7
7
  import { RenditionOptions, canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from "./rendition.js";
8
- import { canDeriveAfter, derivableKindsOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from "./derive.js";
8
+ import { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from "./derive.js";
9
9
  import { canFetchBibliography, doiOf, fetchBibliography } from "./bibliography-fetch.js";
10
10
  import { OutlineEntry, OutlineHeading, applyOutline, collectHeadings, parseOutlineResponse, sanitizeOutline } from "./outline-sanitize.js";
11
11
  import { bodyUnchanged, splitByInsertedHeadings, splitCompositeWithAi } from "./split.js";
12
12
  //#region src/integrations/composite-ai/index.d.ts
13
13
  /**
14
- * AI on composites (requires `composites`, `ai`, `media`): the „Baustein füllen (KI)“ block action (on composites of
15
- * kinds with an `ai` configuration: brief + document → task `fill-block`, the result opens the diff review over the
16
- * body), the „Zusammenfassung erzeugen“ block action (streams a
17
- * summary of a composite's body into its description), the „Lesefassung erzeugen“ / „Neu erzeugen (ersetzen)“
18
- * actions of source-holding Bausteine (`ai.extract`: a rendition child with the transcript, full text or description of
19
- * the source; a recording needs the app's public AI configuration to enable transcription),
20
- * and the composite-structure form of AI results: with `composite` structure an AI result that
21
- * has a heading is inserted as a `section` composite fence, otherwise (and in flat structure) the base AI heading
22
- * is used. It is the preset's single `formatAiResult` contributor. The base AI feature and the composites feature do
23
- * not know it. Framework-free: notices go through the surface's `ctx.notify`, the model through the app's
24
- * `modelProfiles(ctx.app)`. Also „Mit KI in (Unter-)Bausteine teilen“ (block actions on composites: the model inserts
25
- * headings, the body is split at them) and „Gliederung bereinigen (KI)“ (⌘K command and block action on headings:
26
- * repairs the heading outline of the whole document).
14
+ * AI on Typed blocks (requires `composites`, `ai`, `media`): the „Block füllen (KI)“ block action (on Typed blocks of Block
15
+ * types with the `ai-brief` capability: brief + document → task `fill-block`, the result opens the diff review over the
16
+ * body), the „Zusammenfassung erzeugen (KI)“ block action (streams a summary of a Typed block's body into its description),
17
+ * the „Create readable rendition“ / „Regenerate (replace)“ actions of Typed blocks of a Block type with a Source (`ai.extract`:
18
+ * a rendition child with the transcript, full text or description of the Source; a recording needs the app's public AI
19
+ * configuration to enable transcription), „Ableiten (KI)“ (a Derived block of another Block type), the bibliography fetch,
20
+ * and the formatting of AI results in `structured` structure: an AI result that has a heading is inserted as a `section`
21
+ * Typed block fence; otherwise, and in `flat` structure, the base AI heading is used. It is the preset's single
22
+ * `formatAiResult` contributor. The base AI feature and the composites feature do not know it. Framework-free: notices go
23
+ * through the surface's `ctx.notify`, the model through the app's `modelProfiles(ctx.app)`. Also „Mit KI in Unterblöcke teilen“ /
24
+ * „Mit KI in Blöcke teilen“ (block actions on Typed blocks: the model inserts headings, the body is split at them) and
25
+ * „Gliederung bereinigen (KI)“ (⌘K command and block action on headings: repairs the heading outline of the whole document).
27
26
  */
28
27
  export declare function compositeAiFeature(): EditorFeature<never>;
29
28
  //#endregion
30
- export { COMPOSITE_BODY_START, type CompositeBodyResult, type OutlineEntry, type OutlineHeading, type RenditionOptions, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeSourceText, createRendition, derivableKindsOf, deriveComposite, discardDerived, doiOf, fetchBibliography, fillComposite, generateCompositeBody, isDerivableSource, parseOutlineResponse, regenerateRendition, sanitizeOutline, splitByInsertedHeadings, splitCompositeWithAi, summarizeComposite, summaryTransform, transferRequest, writeDerivedBody };
29
+ export { COMPOSITE_BODY_START, type CompositeBodyResult, type OutlineEntry, type OutlineHeading, type RenditionOptions, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeSourceText, createRendition, derivableBlockTypesOf, deriveComposite, discardDerived, doiOf, fetchBibliography, fillComposite, generateCompositeBody, isDerivableSource, parseOutlineResponse, regenerateRendition, sanitizeOutline, splitByInsertedHeadings, splitCompositeWithAi, summarizeComposite, summaryTransform, transferRequest, writeDerivedBody };
31
30
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,10 @@
1
1
  import { withHeading } from "../../features/ai/protocol/tasks.js";
2
2
  import { ABILITY } from "../../core/schema/abilities.js";
3
- import { compositeKind } from "../../features/composites/kinds.js";
4
3
  import { compositeFence } from "../../features/composites/fences.js";
5
- import { compositeKindsOf } from "../../features/composites/nodes.js";
6
4
  import { modelProfiles } from "../../features/ai/model-profiles.js";
7
5
  import { structureOf } from "../../features/composites/structure.js";
8
6
  import { fillComposite, generateCompositeBody } from "./composite-fill.js";
9
- import { canDeriveAfter, derivableKindsOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from "./derive.js";
7
+ import { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from "./derive.js";
10
8
  import { canFetchBibliography, doiOf, fetchBibliography } from "./bibliography-fetch.js";
11
9
  import { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from "./composite-summary.js";
12
10
  import { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from "./rendition.js";
@@ -27,109 +25,132 @@ function bibliographyFetchExtensions(ctx) {
27
25
  } })
28
26
  })];
29
27
  }
30
- function compositeAiActions(ctx) {
31
- const ai = ctx.backend.ai;
32
- if (!ai) return [];
28
+ /** Runs `fn` with the AI backend; nothing to run without it (`composeEditor` omits the integration in that case, `available` hides the method). */
29
+ const withAi = (fn) => (ctx) => {
30
+ const ai = ctx.ctx.backend.ai;
31
+ if (ai) fn(ctx, ai);
32
+ };
33
+ const hasAi = ({ ctx }) => !!ctx.backend.ai;
34
+ /**
35
+ * The derive methods of this integration: AI fill (`ai:<type>` content for a Typed block of a Block type with a brief), summary,
36
+ * AI derivation into another Block type, bibliography fetch, and the rendition of a source (transcription, text extraction, description)
37
+ * with its regeneration. Each declares the capability the original needs; the block actions of the same ids are generated from them.
38
+ */
39
+ function compositeAiDeriveMethods() {
33
40
  return [
34
41
  {
35
42
  id: "composite-fill",
36
- label: ctx.t("integrations.compositeFill.action"),
43
+ label: (ctx) => ctx.t("integrations.compositeFill.action"),
37
44
  icon: "i-lucide-wand-sparkles",
38
45
  ability: ABILITY.aiGenerate,
39
46
  order: 25,
40
- isVisible: ({ editor, node }) => node.type.name === "composite" && compositeKind(compositeKindsOf(editor), String(node.attrs.kind)).ai !== void 0,
41
- run: ({ editor, pos }) => {
47
+ requires: ["ai-brief"],
48
+ available: hasAi,
49
+ run: withAi(({ editor, pos, ctx }, ai) => {
42
50
  fillComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
43
- }
51
+ })
44
52
  },
45
53
  {
46
54
  id: "composite-summarize",
47
- label: ctx.t("integrations.compositeSummary.action"),
55
+ label: (ctx) => ctx.t("integrations.compositeSummary.action"),
48
56
  icon: "i-lucide-text-quote",
49
57
  ability: ABILITY.compositeSummarize,
50
58
  order: 30,
51
- isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,
52
- run: ({ editor, pos }) => {
59
+ requires: ["container", "title"],
60
+ available: (ctx) => hasAi(ctx) && compositeSourceText(ctx.node).trim().length > 0,
61
+ run: withAi(({ editor, pos, ctx }, ai) => {
53
62
  summarizeComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
54
- }
63
+ })
55
64
  },
56
65
  {
57
66
  id: "composite-derive",
58
- label: ctx.t("integrations.compositeDerive.action"),
67
+ label: (ctx) => ctx.t("integrations.compositeDerive.action"),
59
68
  icon: "i-lucide-git-branch",
60
69
  ability: ABILITY.compositeDerive,
61
70
  order: 452,
62
- isVisible: ({ editor, node }) => isDerivableSource(editor, node),
63
- menu: ({ editor, pos }) => derivableKindsOf(editor).map((kind) => ({
64
- label: kind.label,
65
- icon: kind.icon,
66
- disabled: !canDeriveAfter(editor, pos, kind.id),
67
- onSelect: () => {
68
- deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
69
- }
70
- }))
71
+ requires: ["container", "title"],
72
+ available: (ctx) => hasAi(ctx) && isDerivableSource(ctx.editor, ctx.node),
73
+ menu: ({ editor, pos, ctx }) => {
74
+ const ai = ctx.backend.ai;
75
+ if (!ai) return [];
76
+ return derivableBlockTypesOf(editor).map((kind) => ({
77
+ label: kind.label,
78
+ icon: kind.icon,
79
+ disabled: !canDeriveAfter(editor, pos, kind.id),
80
+ onSelect: () => {
81
+ deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
82
+ }
83
+ }));
84
+ }
71
85
  },
72
86
  {
73
87
  id: "bibliography-fetch",
74
- label: ctx.t("integrations.bibliographyFetch.action"),
88
+ label: (ctx) => ctx.t("integrations.bibliographyFetch.action"),
75
89
  icon: "i-lucide-book-marked",
76
90
  ability: ABILITY.compositeDerive,
77
91
  order: 453,
78
- isVisible: ({ editor, node }) => canFetchBibliography(editor, node),
79
- run: ({ editor, pos }) => {
92
+ requires: ["bibliography"],
93
+ available: (ctx) => hasAi(ctx) && canFetchBibliography(ctx.editor, ctx.node),
94
+ run: withAi(({ editor, pos, ctx }, ai) => {
80
95
  fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId);
81
- }
96
+ })
82
97
  },
83
98
  {
84
99
  id: "rendition-create",
85
- label: ctx.t("integrations.rendition.action"),
100
+ label: (ctx) => ctx.t("integrations.rendition.action"),
86
101
  icon: "i-lucide-captions",
87
102
  ability: ABILITY.compositeDerive,
88
103
  order: 450,
89
- isVisible: ({ editor, node }) => canCreateRendition(editor, node, !!ctx.ai?.transcription),
90
- run: ({ editor, pos }) => {
104
+ requires: ["source"],
105
+ available: (ctx) => hasAi(ctx) && canCreateRendition(ctx.editor, ctx.node, !!ctx.ctx.ai?.transcription),
106
+ run: withAi(({ editor, pos, ctx }, ai) => {
91
107
  createRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
92
- }
108
+ })
93
109
  },
94
110
  {
95
111
  id: "rendition-regenerate",
96
- label: ctx.t("integrations.rendition.regenerate"),
112
+ label: (ctx) => ctx.t("integrations.rendition.regenerate"),
97
113
  icon: "i-lucide-refresh-cw",
98
114
  ability: ABILITY.compositeDerive,
99
115
  order: 451,
100
- isVisible: ({ editor, node, pos }) => canRegenerateRendition(editor, node, pos, !!ctx.ai?.transcription),
101
- run: ({ editor, pos }) => {
116
+ requires: ["derived"],
117
+ available: (ctx) => hasAi(ctx) && canRegenerateRendition(ctx.editor, ctx.node, ctx.pos, !!ctx.ctx.ai?.transcription),
118
+ run: withAi(({ editor, pos, ctx }, ai) => {
102
119
  regenerateRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
103
- }
104
- },
105
- ...["children", "siblings"].map((mode) => ({
106
- id: `composite-split-ai-${mode}`,
107
- label: ctx.t(`integrations.compositeSplit.ai.${mode}`),
108
- icon: "i-lucide-sparkles",
109
- ability: ABILITY.aiGenerate,
110
- order: mode === "children" ? 454 : 455,
111
- isVisible: ({ node }) => node.type.name === "composite" && compositeSourceText(node).trim().length > 0,
112
- run: ({ editor, pos }) => {
113
- const { blocks } = ctx.settings.get();
114
- splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, {
115
- targetChars: blocks.splitTargetChars,
116
- defaultKind: blocks.defaultKind
117
- });
118
- }
119
- })),
120
- {
121
- id: "outline-sanitize",
122
- label: ctx.t("integrations.outlineSanitize.label"),
123
- icon: "i-lucide-list-tree",
124
- ability: ABILITY.aiGenerate,
125
- order: 456,
126
- isVisible: ({ node }) => node.type.name === "heading",
127
- run: ({ editor }) => {
128
- sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
129
- }
120
+ })
130
121
  }
131
122
  ];
132
123
  }
124
+ function compositeAiActions(ctx) {
125
+ const ai = ctx.backend.ai;
126
+ if (!ai) return [];
127
+ return [...["children", "siblings"].map((mode) => ({
128
+ id: `composite-split-ai-${mode}`,
129
+ label: ctx.t(`integrations.compositeSplit.ai.${mode}`),
130
+ icon: "i-lucide-sparkles",
131
+ ability: ABILITY.aiGenerate,
132
+ order: mode === "children" ? 454 : 455,
133
+ requires: ["container", "title"],
134
+ isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,
135
+ run: ({ editor, pos }) => {
136
+ const { blocks } = ctx.settings.get();
137
+ splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, {
138
+ targetChars: blocks.splitTargetChars,
139
+ defaultBlockType: blocks.defaultBlockType
140
+ });
141
+ }
142
+ })), {
143
+ id: "outline-sanitize",
144
+ label: ctx.t("integrations.outlineSanitize.label"),
145
+ icon: "i-lucide-list-tree",
146
+ ability: ABILITY.aiGenerate,
147
+ order: 456,
148
+ isVisible: ({ node }) => node.type.name === "heading",
149
+ run: ({ editor }) => {
150
+ sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
151
+ }
152
+ }];
153
+ }
133
154
  /** The ⌘K entry „Gliederung bereinigen (KI)“ (no toolbar button); absent without the AI capability. */
134
155
  function compositeAiCommands(ctx) {
135
156
  const ai = ctx.backend.ai;
@@ -145,19 +166,18 @@ function compositeAiCommands(ctx) {
145
166
  }];
146
167
  }
147
168
  /**
148
- * AI on composites (requires `composites`, `ai`, `media`): the „Baustein füllen (KI)“ block action (on composites of
149
- * kinds with an `ai` configuration: brief + document → task `fill-block`, the result opens the diff review over the
150
- * body), the „Zusammenfassung erzeugen“ block action (streams a
151
- * summary of a composite's body into its description), the „Lesefassung erzeugen“ / „Neu erzeugen (ersetzen)“
152
- * actions of source-holding Bausteine (`ai.extract`: a rendition child with the transcript, full text or description of
153
- * the source; a recording needs the app's public AI configuration to enable transcription),
154
- * and the composite-structure form of AI results: with `composite` structure an AI result that
155
- * has a heading is inserted as a `section` composite fence, otherwise (and in flat structure) the base AI heading
156
- * is used. It is the preset's single `formatAiResult` contributor. The base AI feature and the composites feature do
157
- * not know it. Framework-free: notices go through the surface's `ctx.notify`, the model through the app's
158
- * `modelProfiles(ctx.app)`. Also „Mit KI in (Unter-)Bausteine teilen“ (block actions on composites: the model inserts
159
- * headings, the body is split at them) and „Gliederung bereinigen (KI)“ (⌘K command and block action on headings:
160
- * repairs the heading outline of the whole document).
169
+ * AI on Typed blocks (requires `composites`, `ai`, `media`): the „Block füllen (KI)“ block action (on Typed blocks of Block
170
+ * types with the `ai-brief` capability: brief + document → task `fill-block`, the result opens the diff review over the
171
+ * body), the „Zusammenfassung erzeugen (KI)“ block action (streams a summary of a Typed block's body into its description),
172
+ * the „Create readable rendition“ / „Regenerate (replace)“ actions of Typed blocks of a Block type with a Source (`ai.extract`:
173
+ * a rendition child with the transcript, full text or description of the Source; a recording needs the app's public AI
174
+ * configuration to enable transcription), „Ableiten (KI)“ (a Derived block of another Block type), the bibliography fetch,
175
+ * and the formatting of AI results in `structured` structure: an AI result that has a heading is inserted as a `section`
176
+ * Typed block fence; otherwise, and in `flat` structure, the base AI heading is used. It is the preset's single
177
+ * `formatAiResult` contributor. The base AI feature and the composites feature do not know it. Framework-free: notices go
178
+ * through the surface's `ctx.notify`, the model through the app's `modelProfiles(ctx.app)`. Also „Mit KI in Unterblöcke teilen“ /
179
+ * „Mit KI in Blöcke teilen“ (block actions on Typed blocks: the model inserts headings, the body is split at them) and
180
+ * „Gliederung bereinigen (KI)“ (⌘K command and block action on headings: repairs the heading outline of the whole document).
161
181
  */
162
182
  function compositeAiFeature() {
163
183
  return {
@@ -169,16 +189,17 @@ function compositeAiFeature() {
169
189
  "media"
170
190
  ],
171
191
  blockActions: compositeAiActions,
192
+ deriveMethods: compositeAiDeriveMethods(),
172
193
  extensions: bibliographyFetchExtensions,
173
194
  commands: compositeAiCommands,
174
195
  formatAiResult: (editor, markdown, heading) => {
175
196
  if (!heading) return markdown;
176
197
  const text = withHeading(heading, markdown);
177
- return structureOf(editor) === "composite" ? compositeFence("section", {}, text) : text;
198
+ return structureOf(editor) === "structured" ? compositeFence("section", {}, text) : text;
178
199
  }
179
200
  };
180
201
  }
181
202
  //#endregion
182
- export { COMPOSITE_BODY_START, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeAiFeature, compositeSourceText, createRendition, derivableKindsOf, deriveComposite, discardDerived, doiOf, fetchBibliography, fillComposite, generateCompositeBody, isDerivableSource, parseOutlineResponse, regenerateRendition, sanitizeOutline, splitByInsertedHeadings, splitCompositeWithAi, summarizeComposite, summaryTransform, transferRequest, writeDerivedBody };
203
+ export { COMPOSITE_BODY_START, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeAiFeature, compositeSourceText, createRendition, derivableBlockTypesOf, deriveComposite, discardDerived, doiOf, fetchBibliography, fillComposite, generateCompositeBody, isDerivableSource, parseOutlineResponse, regenerateRendition, sanitizeOutline, splitByInsertedHeadings, splitCompositeWithAi, summarizeComposite, summaryTransform, transferRequest, writeDerivedBody };
183
204
 
184
205
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/integrations/composite-ai/index.ts"],"sourcesContent":["import { type AnyExtension, Extension } from '@tiptap/core'\nimport type { BlockAction, CommandDef, EditorFeature, FeatureContext } from '../../core'\nimport { ABILITY } from '../../core/schema'\nimport { modelProfiles, withHeading } from '../../features/ai'\nimport { structureOf } from '../../features/composites'\nimport '../../features/composites/bibliography-command'\nimport { compositeFence, compositeKind, compositeKindsOf } from '../../features/composites/schema'\nimport { fillComposite } from './composite-fill'\nimport { canDeriveAfter, derivableKindsOf, deriveComposite, isDerivableSource } from './derive'\nimport { canFetchBibliography, fetchBibliography } from './bibliography-fetch'\nimport { compositeSourceText, summarizeComposite } from './composite-summary'\nimport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from './rendition'\nimport { sanitizeOutline } from './outline-sanitize'\nimport { splitCompositeWithAi } from './split'\n\nexport { bulletsTransform, summaryTransform, transferRequest } from './transfer-transforms'\n\nexport { type CompositeBodyResult, fillComposite, generateCompositeBody } from './composite-fill'\nexport { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from './composite-summary'\nexport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition, type RenditionOptions } from './rendition'\nexport { canDeriveAfter, derivableKindsOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from './derive'\nexport { canFetchBibliography, doiOf, fetchBibliography } from './bibliography-fetch'\nexport { applyOutline, collectHeadings, type OutlineEntry, type OutlineHeading, parseOutlineResponse, sanitizeOutline } from './outline-sanitize'\nexport { bodyUnchanged, splitByInsertedHeadings, splitCompositeWithAi } from './split'\n\n/** The editor command `fetchCompositeBibliography` (declared by composites) behind the bibliography editor's „DOI abrufen“ button; absent without the AI capability. */\nfunction bibliographyFetchExtensions(ctx: FeatureContext): AnyExtension[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [Extension.create({\n name: 'compositeBibliographyFetch',\n addCommands: () => ({\n fetchCompositeBibliography: (pos: number) => ({ editor }) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n return true\n },\n }),\n })]\n}\n\nfunction compositeAiActions(ctx: FeatureContext): BlockAction[] {\n const ai = ctx.backend.ai\n // Without the AI capability there is nothing to run (`composeEditor` omits the integration in that case).\n if (!ai) return []\n return [\n {\n id: 'composite-fill',\n label: ctx.t('integrations.compositeFill.action'),\n icon: 'i-lucide-wand-sparkles',\n ability: ABILITY.aiGenerate,\n order: 25,\n isVisible: ({ editor, node }) => node.type.name === 'composite' && compositeKind(compositeKindsOf(editor), String(node.attrs.kind)).ai !== undefined,\n run: ({ editor, pos }) => {\n void fillComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n {\n id: 'composite-summarize',\n label: ctx.t('integrations.compositeSummary.action'),\n icon: 'i-lucide-text-quote',\n ability: ABILITY.compositeSummarize,\n order: 30,\n isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,\n run: ({ editor, pos }) => {\n void summarizeComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n {\n id: 'composite-derive',\n label: ctx.t('integrations.compositeDerive.action'),\n icon: 'i-lucide-git-branch',\n ability: ABILITY.compositeDerive,\n order: 452,\n isVisible: ({ editor, node }) => isDerivableSource(editor, node),\n menu: ({ editor, pos }) => derivableKindsOf(editor).map(kind => ({\n label: kind.label,\n icon: kind.icon,\n disabled: !canDeriveAfter(editor, pos, kind.id),\n onSelect: () => {\n void deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n })),\n },\n {\n id: 'bibliography-fetch',\n label: ctx.t('integrations.bibliographyFetch.action'),\n icon: 'i-lucide-book-marked',\n ability: ABILITY.compositeDerive,\n order: 453,\n isVisible: ({ editor, node }) => canFetchBibliography(editor, node),\n run: ({ editor, pos }) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n },\n },\n {\n id: 'rendition-create',\n label: ctx.t('integrations.rendition.action'),\n icon: 'i-lucide-captions',\n ability: ABILITY.compositeDerive,\n order: 450,\n isVisible: ({ editor, node }) => canCreateRendition(editor, node, !!ctx.ai?.transcription),\n run: ({ editor, pos }) => {\n void createRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n {\n id: 'rendition-regenerate',\n label: ctx.t('integrations.rendition.regenerate'),\n icon: 'i-lucide-refresh-cw',\n ability: ABILITY.compositeDerive,\n order: 451,\n isVisible: ({ editor, node, pos }) => canRegenerateRendition(editor, node, pos, !!ctx.ai?.transcription),\n run: ({ editor, pos }) => {\n regenerateRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n ...(['children', 'siblings'] as const).map((mode): BlockAction => ({\n id: `composite-split-ai-${mode}`,\n label: ctx.t(`integrations.compositeSplit.ai.${mode}`),\n icon: 'i-lucide-sparkles',\n ability: ABILITY.aiGenerate,\n order: mode === 'children' ? 454 : 455,\n isVisible: ({ node }) => node.type.name === 'composite' && compositeSourceText(node).trim().length > 0,\n run: ({ editor, pos }) => {\n const { blocks } = ctx.settings.get()\n void splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, { targetChars: blocks.splitTargetChars, defaultKind: blocks.defaultKind })\n },\n })),\n {\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n ability: ABILITY.aiGenerate,\n order: 456,\n isVisible: ({ node }) => node.type.name === 'heading',\n run: ({ editor }) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n ]\n}\n\n/** The ⌘K entry „Gliederung bereinigen (KI)“ (no toolbar button); absent without the AI capability. */\nfunction compositeAiCommands(ctx: FeatureContext): CommandDef<never>[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [{\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n toolbar: false,\n run: (editor) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n }]\n}\n\n/**\n * AI on composites (requires `composites`, `ai`, `media`): the „Baustein füllen (KI)“ block action (on composites of\n * kinds with an `ai` configuration: brief + document → task `fill-block`, the result opens the diff review over the\n * body), the „Zusammenfassung erzeugen“ block action (streams a\n * summary of a composite's body into its description), the „Lesefassung erzeugen“ / „Neu erzeugen (ersetzen)“\n * actions of source-holding Bausteine (`ai.extract`: a rendition child with the transcript, full text or description of\n * the source; a recording needs the app's public AI configuration to enable transcription),\n * and the composite-structure form of AI results: with `composite` structure an AI result that\n * has a heading is inserted as a `section` composite fence, otherwise (and in flat structure) the base AI heading\n * is used. It is the preset's single `formatAiResult` contributor. The base AI feature and the composites feature do\n * not know it. Framework-free: notices go through the surface's `ctx.notify`, the model through the app's\n * `modelProfiles(ctx.app)`. Also „Mit KI in (Unter-)Bausteine teilen“ (block actions on composites: the model inserts\n * headings, the body is split at them) and „Gliederung bereinigen (KI)“ (⌘K command and block action on headings:\n * repairs the heading outline of the whole document).\n */\nexport function compositeAiFeature(): EditorFeature<never> {\n return {\n id: 'composite-ai',\n dimension: 'ai',\n requires: ['composites', 'ai', 'media'],\n blockActions: compositeAiActions,\n extensions: bibliographyFetchExtensions,\n commands: compositeAiCommands,\n formatAiResult: (editor, markdown, heading) => {\n if (!heading) return markdown\n const text = withHeading(heading, markdown)\n return structureOf(editor) === 'composite' ? compositeFence('section', {}, text) : text\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAS,4BAA4B,KAAqC;CACxE,MAAM,KAAK,IAAI,Q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C,IAAI,CAAC,SAAS,OAAO;GACrB,MAAM,OAAO,YAAY,SAAS,QAAQ;GAC1C,OAAO,YAAY,MAAM,MAAM,cAAc,eAAe,WAAW,CAAC,GAAG,IAAI,IAAI;EACrF;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/integrations/composite-ai/index.ts"],"sourcesContent":["import { type AnyExtension, Extension } from '@tiptap/core'\nimport type { BlockAction, CommandDef, DeriveContext, DeriveMethod, EditorBackend, EditorFeature, FeatureContext } from '../../core'\nimport { ABILITY } from '../../core/schema'\nimport { modelProfiles, withHeading } from '../../features/ai'\nimport { structureOf } from '../../features/composites'\nimport '../../features/composites/bibliography-command'\nimport { compositeFence } from '../../features/composites/schema'\nimport { fillComposite } from './composite-fill'\nimport { canDeriveAfter, derivableBlockTypesOf, deriveComposite, isDerivableSource } from './derive'\nimport { canFetchBibliography, fetchBibliography } from './bibliography-fetch'\nimport { compositeSourceText, summarizeComposite } from './composite-summary'\nimport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from './rendition'\nimport { sanitizeOutline } from './outline-sanitize'\nimport { splitCompositeWithAi } from './split'\n\nexport { bulletsTransform, summaryTransform, transferRequest } from './transfer-transforms'\n\nexport { type CompositeBodyResult, fillComposite, generateCompositeBody } from './composite-fill'\nexport { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from './composite-summary'\nexport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition, type RenditionOptions } from './rendition'\nexport { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from './derive'\nexport { canFetchBibliography, doiOf, fetchBibliography } from './bibliography-fetch'\nexport { applyOutline, collectHeadings, type OutlineEntry, type OutlineHeading, parseOutlineResponse, sanitizeOutline } from './outline-sanitize'\nexport { bodyUnchanged, splitByInsertedHeadings, splitCompositeWithAi } from './split'\n\n/** The editor command `fetchCompositeBibliography` (declared by composites) behind the bibliography editor's „DOI abrufen“ button; absent without the AI capability. */\nfunction bibliographyFetchExtensions(ctx: FeatureContext): AnyExtension[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [Extension.create({\n name: 'compositeBibliographyFetch',\n addCommands: () => ({\n fetchCompositeBibliography: (pos: number) => ({ editor }) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n return true\n },\n }),\n })]\n}\n\n/** Runs `fn` with the AI backend; nothing to run without it (`composeEditor` omits the integration in that case, `available` hides the method). */\nconst withAi = (fn: (ctx: DeriveContext, ai: NonNullable<EditorBackend['ai']>) => void) => (ctx: DeriveContext): void => {\n const ai = ctx.ctx.backend.ai\n if (ai) fn(ctx, ai)\n}\n\nconst hasAi = ({ ctx }: DeriveContext): boolean => !!ctx.backend.ai\n\n/**\n * The derive methods of this integration: AI fill (`ai:<type>` content for a Typed block of a Block type with a brief), summary,\n * AI derivation into another Block type, bibliography fetch, and the rendition of a source (transcription, text extraction, description)\n * with its regeneration. Each declares the capability the original needs; the block actions of the same ids are generated from them.\n */\nfunction compositeAiDeriveMethods(): DeriveMethod[] {\n return [\n {\n id: 'composite-fill',\n label: ctx => ctx.t('integrations.compositeFill.action'),\n icon: 'i-lucide-wand-sparkles',\n ability: ABILITY.aiGenerate,\n order: 25,\n requires: ['ai-brief'],\n available: hasAi,\n run: withAi(({ editor, pos, ctx }, ai) => {\n void fillComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n {\n id: 'composite-summarize',\n label: ctx => ctx.t('integrations.compositeSummary.action'),\n icon: 'i-lucide-text-quote',\n ability: ABILITY.compositeSummarize,\n order: 30,\n requires: ['container', 'title'],\n available: ctx => hasAi(ctx) && compositeSourceText(ctx.node).trim().length > 0,\n run: withAi(({ editor, pos, ctx }, ai) => {\n void summarizeComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n {\n id: 'composite-derive',\n label: ctx => ctx.t('integrations.compositeDerive.action'),\n icon: 'i-lucide-git-branch',\n ability: ABILITY.compositeDerive,\n order: 452,\n requires: ['container', 'title'],\n available: ctx => hasAi(ctx) && isDerivableSource(ctx.editor, ctx.node),\n menu: ({ editor, pos, ctx }) => {\n const ai = ctx.backend.ai\n if (!ai) return []\n return derivableBlockTypesOf(editor).map(kind => ({\n label: kind.label,\n icon: kind.icon,\n disabled: !canDeriveAfter(editor, pos, kind.id),\n onSelect: () => {\n void deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n }))\n },\n },\n {\n id: 'bibliography-fetch',\n label: ctx => ctx.t('integrations.bibliographyFetch.action'),\n icon: 'i-lucide-book-marked',\n ability: ABILITY.compositeDerive,\n order: 453,\n requires: ['bibliography'],\n available: ctx => hasAi(ctx) && canFetchBibliography(ctx.editor, ctx.node),\n run: withAi(({ editor, pos, ctx }, ai) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n }),\n },\n {\n id: 'rendition-create',\n label: ctx => ctx.t('integrations.rendition.action'),\n icon: 'i-lucide-captions',\n ability: ABILITY.compositeDerive,\n order: 450,\n requires: ['source'],\n available: ctx => hasAi(ctx) && canCreateRendition(ctx.editor, ctx.node, !!ctx.ctx.ai?.transcription),\n run: withAi(({ editor, pos, ctx }, ai) => {\n void createRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n {\n id: 'rendition-regenerate',\n label: ctx => ctx.t('integrations.rendition.regenerate'),\n icon: 'i-lucide-refresh-cw',\n ability: ABILITY.compositeDerive,\n order: 451,\n requires: ['derived'],\n available: ctx => hasAi(ctx) && canRegenerateRendition(ctx.editor, ctx.node, ctx.pos, !!ctx.ctx.ai?.transcription),\n run: withAi(({ editor, pos, ctx }, ai) => {\n regenerateRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n ]\n}\n\nfunction compositeAiActions(ctx: FeatureContext): BlockAction[] {\n const ai = ctx.backend.ai\n // Without the AI capability there is nothing to run (`composeEditor` omits the integration in that case).\n if (!ai) return []\n return [\n ...(['children', 'siblings'] as const).map((mode): BlockAction => ({\n id: `composite-split-ai-${mode}`,\n label: ctx.t(`integrations.compositeSplit.ai.${mode}`),\n icon: 'i-lucide-sparkles',\n ability: ABILITY.aiGenerate,\n order: mode === 'children' ? 454 : 455,\n requires: ['container', 'title'],\n isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,\n run: ({ editor, pos }) => {\n const { blocks } = ctx.settings.get()\n void splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, { targetChars: blocks.splitTargetChars, defaultBlockType: blocks.defaultBlockType })\n },\n })),\n {\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n ability: ABILITY.aiGenerate,\n order: 456,\n isVisible: ({ node }) => node.type.name === 'heading',\n run: ({ editor }) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n ]\n}\n\n/** The ⌘K entry „Gliederung bereinigen (KI)“ (no toolbar button); absent without the AI capability. */\nfunction compositeAiCommands(ctx: FeatureContext): CommandDef<never>[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [{\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n toolbar: false,\n run: (editor) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n }]\n}\n\n/**\n * AI on Typed blocks (requires `composites`, `ai`, `media`): the „Block füllen (KI)“ block action (on Typed blocks of Block\n * types with the `ai-brief` capability: brief + document → task `fill-block`, the result opens the diff review over the\n * body), the „Zusammenfassung erzeugen (KI)“ block action (streams a summary of a Typed block's body into its description),\n * the „Create readable rendition“ / „Regenerate (replace)“ actions of Typed blocks of a Block type with a Source (`ai.extract`:\n * a rendition child with the transcript, full text or description of the Source; a recording needs the app's public AI\n * configuration to enable transcription), „Ableiten (KI)“ (a Derived block of another Block type), the bibliography fetch,\n * and the formatting of AI results in `structured` structure: an AI result that has a heading is inserted as a `section`\n * Typed block fence; otherwise, and in `flat` structure, the base AI heading is used. It is the preset's single\n * `formatAiResult` contributor. The base AI feature and the composites feature do not know it. Framework-free: notices go\n * through the surface's `ctx.notify`, the model through the app's `modelProfiles(ctx.app)`. Also „Mit KI in Unterblöcke teilen“ /\n * „Mit KI in Blöcke teilen“ (block actions on Typed blocks: the model inserts headings, the body is split at them) and\n * „Gliederung bereinigen (KI)“ (⌘K command and block action on headings: repairs the heading outline of the whole document).\n */\nexport function compositeAiFeature(): EditorFeature<never> {\n return {\n id: 'composite-ai',\n dimension: 'ai',\n requires: ['composites', 'ai', 'media'],\n blockActions: compositeAiActions,\n deriveMethods: compositeAiDeriveMethods(),\n extensions: bibliographyFetchExtensions,\n commands: compositeAiCommands,\n formatAiResult: (editor, markdown, heading) => {\n if (!heading) return markdown\n const text = withHeading(heading, markdown)\n return structureOf(editor) === 'structured' ? compositeFence('section', {}, text) : text\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,SAAS,4BAA4B,KAAqC;CACxE,MAAM,KAAK,IAAI,QAAQ;CACvB,IAAI,CAAC,IAAI,OAAO,CAAC;CACjB,OAAO,CAAC,UAAU,OAAO;EACvB,MAAM;EACN,oBAAoB,EAClB,6BAA6B,SAAiB,EAAE,aAAa;GAC3D,kBAAuB,QAAQ,KAAK,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,GAAG,IAAI,UAAU;GAC1G,OAAO;EACT,EACF;CACF,CAAC,CAAC;AACJ;;AAGA,MAAM,UAAU,QAA4E,QAA6B;CACvH,MAAM,KAAK,IAAI,IAAI,QAAQ;CAC3B,IAAI,IAAI,GAAG,KAAK,EA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AI,QAAQ,IAAI,CAAC;EACrF;CACF,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,qBAA2C;CACzD,OAAO;EACL,IAAI;EACJ,WAAW;EACX,UAAU;GAAC;GAAc;GAAM;EAAO;EACtC,cAAc;EACd,eAAe,yBAAyB;EACxC,YAAY;EACZ,UAAU;EACV,iBAAiB,QAAQ,UAAU,YAAY;GAC7C,IAAI,CAAC,SAAS,OAAO;GACrB,MAAM,OAAO,YAAY,SAAS,QAAQ;GAC1C,OAAO,YAAY,MAAM,MAAM,eAAe,eAAe,WAAW,CAAC,GAAG,IAAI,IAAI;EACtF;CACF;AACF"}
@@ -38,7 +38,7 @@ export declare function parseOutlineResponse(text: string, headings: readonly {
38
38
  */
39
39
  export declare function applyOutline(tr: Transaction, headings: readonly OutlineHeading[], outline: readonly OutlineEntry[]): number;
40
40
  /**
41
- * „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` slot) and
41
+ * „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` Model role) and
42
42
  * applies the model's repaired outline (levels without gaps, numbering and trailing punctuation gone, empty headings
43
43
  * merged into the next) in one transaction. A malformed answer, or a document whose headings changed while the model
44
44
  * ran, writes nothing and shows a notice. Notices go through `notify`, in the language of `t`.
@@ -75,7 +75,7 @@ function applyOutline(tr, headings, outline) {
75
75
  return changed;
76
76
  }
77
77
  /**
78
- * „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` slot) and
78
+ * „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` Model role) and
79
79
  * applies the model's repaired outline (levels without gaps, numbering and trailing punctuation gone, empty headings
80
80
  * merged into the next) in one transaction. A malformed answer, or a document whose headings changed while the model
81
81
  * ran, writes nothing and shows a notice. Notices go through `notify`, in the language of `t`.