@formicoidea/labre-core 0.31.0 → 0.32.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 (483) hide show
  1. package/dist/_pkgs/affine-block-callout/callout-block.d.ts +6 -0
  2. package/dist/_pkgs/affine-block-callout/callout-block.js +25 -3
  3. package/dist/_pkgs/affine-block-callout/callout-keymap.js +59 -19
  4. package/dist/_pkgs/affine-block-callout/commands/callout-to-paragraph.d.ts +20 -0
  5. package/dist/_pkgs/affine-block-callout/commands/callout-to-paragraph.js +60 -0
  6. package/dist/_pkgs/affine-block-callout/commands/split-callout.d.ts +17 -0
  7. package/dist/_pkgs/affine-block-callout/commands/split-callout.js +42 -0
  8. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +9 -6
  9. package/dist/_pkgs/affine-block-callout/emoji-margin.d.ts +9 -0
  10. package/dist/_pkgs/affine-block-callout/emoji-margin.js +36 -0
  11. package/dist/_pkgs/affine-block-callout/emoji-menu.d.ts +5 -1
  12. package/dist/_pkgs/affine-block-callout/emoji-menu.js +5 -0
  13. package/dist/_pkgs/affine-block-code/code-block.d.ts +14 -0
  14. package/dist/_pkgs/affine-block-code/code-block.js +44 -6
  15. package/dist/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.d.ts +2 -0
  16. package/dist/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.js +23 -14
  17. package/dist/_pkgs/affine-block-code/code-toolbar/components/more-menu.d.ts +16 -0
  18. package/dist/_pkgs/affine-block-code/code-toolbar/components/more-menu.js +93 -0
  19. package/dist/_pkgs/affine-block-code/code-toolbar/config.js +52 -5
  20. package/dist/_pkgs/affine-block-code/effects.d.ts +2 -0
  21. package/dist/_pkgs/affine-block-code/effects.js +2 -0
  22. package/dist/_pkgs/affine-block-code/highlight/affine-code-unit.js +6 -1
  23. package/dist/_pkgs/affine-block-code/index.d.ts +1 -0
  24. package/dist/_pkgs/affine-block-code/index.js +1 -0
  25. package/dist/_pkgs/affine-block-code/line-numbers.d.ts +25 -0
  26. package/dist/_pkgs/affine-block-code/line-numbers.js +27 -0
  27. package/dist/_pkgs/affine-block-code/styles.js +31 -0
  28. package/dist/_pkgs/affine-block-data-view/data-view-block.js +1 -0
  29. package/dist/_pkgs/affine-block-database/components/title/index.js +4 -1
  30. package/dist/_pkgs/affine-block-database/configs/slash-menu.js +28 -1
  31. package/dist/_pkgs/affine-block-database/database-block.js +13 -0
  32. package/dist/_pkgs/affine-block-database/properties/paste-url.d.ts +24 -0
  33. package/dist/_pkgs/affine-block-database/properties/paste-url.js +98 -0
  34. package/dist/_pkgs/affine-block-database/properties/rich-text/cell-renderer.js +9 -19
  35. package/dist/_pkgs/affine-block-database/properties/title/text.js +20 -25
  36. package/dist/_pkgs/affine-block-database/views/index.js +1 -0
  37. package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +10 -0
  38. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +3 -0
  39. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.js +48 -1
  40. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/font-size.d.ts +17 -0
  41. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/font-size.js +24 -0
  42. package/dist/_pkgs/affine-block-embed-doc/common/doc-trashed.d.ts +9 -0
  43. package/dist/_pkgs/affine-block-embed-doc/common/doc-trashed.js +10 -0
  44. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +8 -4
  45. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.d.ts +4 -0
  46. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +22 -3
  47. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +13 -0
  48. package/dist/_pkgs/affine-block-frame/frame-manager.js +32 -2
  49. package/dist/_pkgs/affine-block-latex/styles.js +6 -1
  50. package/dist/_pkgs/affine-block-note/note-edgeless-block.d.ts +9 -0
  51. package/dist/_pkgs/affine-block-note/note-edgeless-block.js +29 -1
  52. package/dist/_pkgs/affine-block-root/commands/pivot-commands.d.ts +37 -0
  53. package/dist/_pkgs/affine-block-root/commands/pivot-commands.js +168 -0
  54. package/dist/_pkgs/affine-block-root/commands/reading-commands.d.ts +23 -0
  55. package/dist/_pkgs/affine-block-root/commands/reading-commands.js +107 -0
  56. package/dist/_pkgs/affine-block-root/commands/tag-commands.d.ts +47 -0
  57. package/dist/_pkgs/affine-block-root/commands/tag-commands.js +159 -0
  58. package/dist/_pkgs/affine-block-root/configs/toolbar.d.ts +1 -0
  59. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.js +9 -2
  60. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/render-linked-doc.js +1 -1
  61. package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +26 -1
  62. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +11 -2
  63. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-service.js +14 -0
  64. package/dist/_pkgs/affine-block-root/edgeless/index.d.ts +1 -0
  65. package/dist/_pkgs/affine-block-root/edgeless/index.js +1 -0
  66. package/dist/_pkgs/affine-block-root/edgeless/reserved-keys.d.ts +21 -0
  67. package/dist/_pkgs/affine-block-root/edgeless/reserved-keys.js +34 -0
  68. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +7 -1
  69. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +11 -2
  70. package/dist/_pkgs/affine-block-root/index.d.ts +4 -1
  71. package/dist/_pkgs/affine-block-root/index.js +4 -1
  72. package/dist/_pkgs/affine-block-root/keyboard/commands.d.ts +2 -0
  73. package/dist/_pkgs/affine-block-root/keyboard/commands.js +147 -0
  74. package/dist/_pkgs/affine-block-root/view.js +13 -4
  75. package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.js +0 -1
  76. package/dist/_pkgs/affine-block-surface/effects.js +6 -0
  77. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +5 -2
  78. package/dist/_pkgs/affine-block-surface/element-model/index.js +4 -2
  79. package/dist/_pkgs/affine-block-surface/extensions/audit.d.ts +107 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/audit.js +472 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.d.ts +14 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +27 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/editor-anchored-panel.d.ts +133 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/editor-anchored-panel.js +326 -0
  85. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +13 -0
  86. package/dist/_pkgs/affine-block-surface/extensions/index.js +13 -0
  87. package/dist/_pkgs/affine-block-surface/extensions/map-quality-widget.d.ts +146 -0
  88. package/dist/_pkgs/affine-block-surface/extensions/map-quality-widget.js +528 -0
  89. package/dist/_pkgs/affine-block-surface/extensions/map-quality.d.ts +109 -0
  90. package/dist/_pkgs/affine-block-surface/extensions/map-quality.js +84 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.d.ts +15 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.js +158 -0
  93. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +145 -0
  94. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +590 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +494 -0
  96. package/dist/_pkgs/affine-block-surface/extensions/reading.js +767 -0
  97. package/dist/_pkgs/affine-block-surface/extensions/spotlight.d.ts +45 -0
  98. package/dist/_pkgs/affine-block-surface/extensions/spotlight.js +177 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/tags-toolbar.d.ts +10 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/tags-toolbar.js +295 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/validation-toolbar.d.ts +27 -0
  102. package/dist/_pkgs/affine-block-surface/extensions/validation-toolbar.js +361 -0
  103. package/dist/_pkgs/affine-block-surface/extensions/validation.d.ts +1340 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/validation.js +3009 -0
  105. package/dist/_pkgs/affine-block-surface/extensions/violation-detail-widget.d.ts +286 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/violation-detail-widget.js +907 -0
  107. package/dist/_pkgs/affine-block-surface/extensions/violation-timeline.d.ts +80 -0
  108. package/dist/_pkgs/affine-block-surface/extensions/violation-timeline.js +123 -0
  109. package/dist/_pkgs/affine-block-surface/framework-background/def.d.ts +321 -0
  110. package/dist/_pkgs/affine-block-surface/framework-background/def.js +81 -0
  111. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +188 -0
  112. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +284 -0
  113. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +5 -0
  114. package/dist/_pkgs/affine-block-surface/framework-background/index.js +5 -0
  115. package/dist/_pkgs/affine-block-surface/framework-background/interaction.d.ts +12 -0
  116. package/dist/_pkgs/affine-block-surface/framework-background/interaction.js +24 -0
  117. package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +59 -0
  118. package/dist/_pkgs/affine-block-surface/framework-background/labels.js +117 -0
  119. package/dist/_pkgs/affine-block-surface/framework-background/renderer.d.ts +8 -0
  120. package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +238 -0
  121. package/dist/_pkgs/affine-block-surface/index.d.ts +1 -0
  122. package/dist/_pkgs/affine-block-surface/index.js +1 -0
  123. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.d.ts +69 -3
  124. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +333 -44
  125. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +18 -2
  126. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +8 -0
  127. package/dist/_pkgs/affine-block-surface/utils/font.js +9 -3
  128. package/dist/_pkgs/affine-block-surface/view.d.ts +17 -0
  129. package/dist/_pkgs/affine-block-surface/view.js +57 -2
  130. package/dist/_pkgs/affine-block-table/selection-controller.d.ts +6 -0
  131. package/dist/_pkgs/affine-block-table/selection-controller.js +24 -1
  132. package/dist/_pkgs/affine-block-table/table-block.js +8 -2
  133. package/dist/_pkgs/affine-block-table/table-cell.js +5 -6
  134. package/dist/_pkgs/affine-block-table/table-keymap.d.ts +18 -0
  135. package/dist/_pkgs/affine-block-table/table-keymap.js +41 -0
  136. package/dist/_pkgs/affine-block-table/utils.d.ts +7 -0
  137. package/dist/_pkgs/affine-block-table/utils.js +12 -0
  138. package/dist/_pkgs/affine-block-table/view.js +2 -0
  139. package/dist/_pkgs/affine-components/caption/captioned-block-component.js +2 -1
  140. package/dist/_pkgs/affine-components/context-menu/button.d.ts +7 -0
  141. package/dist/_pkgs/affine-components/context-menu/button.js +7 -2
  142. package/dist/_pkgs/affine-components/context-menu/input.d.ts +4 -0
  143. package/dist/_pkgs/affine-components/context-menu/input.js +12 -0
  144. package/dist/_pkgs/affine-components/context-menu/menu-all.d.ts +2 -0
  145. package/dist/_pkgs/affine-components/context-menu/menu-renderer.js +8 -1
  146. package/dist/_pkgs/affine-components/context-menu/sub-menu.js +3 -0
  147. package/dist/_pkgs/affine-components/highlight-dropdown-menu/highlight-duotone-icon.js +8 -8
  148. package/dist/_pkgs/affine-components/highlight-dropdown-menu/text-duotone-icon.js +11 -11
  149. package/dist/_pkgs/affine-components/icon-picker/affine-icon-picker-panel.d.ts +28 -0
  150. package/dist/_pkgs/affine-components/icon-picker/affine-icon-picker-panel.js +231 -0
  151. package/dist/_pkgs/affine-components/icon-picker/emoji-data.d.ts +40 -0
  152. package/dist/_pkgs/affine-components/icon-picker/emoji-data.js +99 -0
  153. package/dist/_pkgs/affine-components/icon-picker/emoji-picker-panel.d.ts +32 -0
  154. package/dist/_pkgs/affine-components/icon-picker/emoji-picker-panel.js +276 -0
  155. package/dist/_pkgs/affine-components/icon-picker/icon-data.d.ts +34 -0
  156. package/dist/_pkgs/affine-components/icon-picker/icon-data.js +83 -0
  157. package/dist/_pkgs/affine-components/icon-picker/icon-picker.d.ts +39 -0
  158. package/dist/_pkgs/affine-components/icon-picker/icon-picker.js +233 -0
  159. package/dist/_pkgs/affine-components/icon-picker/index.d.ts +8 -0
  160. package/dist/_pkgs/affine-components/icon-picker/index.js +15 -0
  161. package/dist/_pkgs/affine-components/icon-picker/recent-store.d.ts +8 -0
  162. package/dist/_pkgs/affine-components/icon-picker/recent-store.js +41 -0
  163. package/dist/_pkgs/affine-components/icon-picker/styles.d.ts +5 -0
  164. package/dist/_pkgs/affine-components/icon-picker/styles.js +166 -0
  165. package/dist/_pkgs/affine-components/icon-picker/types.d.ts +22 -0
  166. package/dist/_pkgs/affine-components/icon-picker/types.js +10 -0
  167. package/dist/_pkgs/affine-components/icons/text.js +426 -426
  168. package/dist/_pkgs/affine-components/open-doc-dropdown-menu/dropdown-menu.d.ts +1 -0
  169. package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
  170. package/dist/_pkgs/affine-components/toolbar/menu-button.js +1 -0
  171. package/dist/_pkgs/affine-components/toolbar/toolbar.js +11 -10
  172. package/dist/_pkgs/affine-foundation/view.js +11 -2
  173. package/dist/_pkgs/affine-gfx-brush/index.d.ts +1 -0
  174. package/dist/_pkgs/affine-gfx-brush/index.js +1 -0
  175. package/dist/_pkgs/affine-gfx-brush/renderer/dom/brush.d.ts +1 -0
  176. package/dist/_pkgs/affine-gfx-brush/renderer/dom/brush.js +11 -0
  177. package/dist/_pkgs/affine-gfx-brush/renderer/dom/highlighter.d.ts +1 -0
  178. package/dist/_pkgs/affine-gfx-brush/renderer/dom/highlighter.js +11 -0
  179. package/dist/_pkgs/affine-gfx-brush/renderer/dom/index.d.ts +2 -0
  180. package/dist/_pkgs/affine-gfx-brush/renderer/dom/index.js +2 -0
  181. package/dist/_pkgs/affine-gfx-brush/renderer/dom/shared.d.ts +14 -0
  182. package/dist/_pkgs/affine-gfx-brush/renderer/dom/shared.js +54 -0
  183. package/dist/_pkgs/affine-gfx-brush/renderer/index.d.ts +1 -0
  184. package/dist/_pkgs/affine-gfx-brush/renderer/index.js +4 -0
  185. package/dist/_pkgs/affine-gfx-brush/view.d.ts +14 -0
  186. package/dist/_pkgs/affine-gfx-brush/view.js +29 -3
  187. package/dist/_pkgs/affine-gfx-connector/connector-manager.js +32 -6
  188. package/dist/_pkgs/affine-gfx-connector/connector-tool.d.ts +7 -0
  189. package/dist/_pkgs/affine-gfx-connector/connector-tool.js +2 -1
  190. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +123 -0
  191. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +281 -0
  192. package/dist/_pkgs/affine-gfx-connector/direction/direction-widget.d.ts +65 -0
  193. package/dist/_pkgs/affine-gfx-connector/direction/direction-widget.js +395 -0
  194. package/dist/_pkgs/affine-gfx-connector/direction/index.d.ts +4 -0
  195. package/dist/_pkgs/affine-gfx-connector/direction/index.js +4 -0
  196. package/dist/_pkgs/affine-gfx-connector/direction/invert-direction.d.ts +72 -0
  197. package/dist/_pkgs/affine-gfx-connector/direction/invert-direction.js +187 -0
  198. package/dist/_pkgs/affine-gfx-connector/direction/typed-edge.d.ts +69 -0
  199. package/dist/_pkgs/affine-gfx-connector/direction/typed-edge.js +66 -0
  200. package/dist/_pkgs/affine-gfx-connector/effects.d.ts +2 -0
  201. package/dist/_pkgs/affine-gfx-connector/effects.js +2 -0
  202. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +78 -41
  203. package/dist/_pkgs/affine-gfx-connector/index.d.ts +1 -0
  204. package/dist/_pkgs/affine-gfx-connector/index.js +1 -0
  205. package/dist/_pkgs/affine-gfx-connector/toolbar/config.d.ts +50 -0
  206. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +67 -1
  207. package/dist/_pkgs/affine-gfx-connector/view.js +16 -0
  208. package/dist/_pkgs/affine-gfx-group/command/group-api.js +150 -62
  209. package/dist/_pkgs/affine-gfx-group/text/edgeless-group-title-editor.js +4 -1
  210. package/dist/_pkgs/affine-gfx-pointer/tools/pan-tool.d.ts +16 -0
  211. package/dist/_pkgs/affine-gfx-pointer/tools/pan-tool.js +102 -32
  212. package/dist/_pkgs/affine-gfx-shape/commands.d.ts +2 -0
  213. package/dist/_pkgs/affine-gfx-shape/commands.js +33 -0
  214. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape-dom/index.js +48 -19
  215. package/dist/_pkgs/affine-gfx-shape/index.d.ts +1 -1
  216. package/dist/_pkgs/affine-gfx-shape/index.js +1 -1
  217. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.d.ts +26 -0
  218. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +124 -13
  219. package/dist/_pkgs/affine-gfx-shape/view.js +3 -3
  220. package/dist/_pkgs/affine-gfx-template/toolbar/template-tool-button.d.ts +2 -0
  221. package/dist/_pkgs/affine-gfx-template/toolbar/template-tool-button.js +18 -1
  222. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +9 -5
  223. package/dist/_pkgs/affine-inline-latex/command.js +46 -26
  224. package/dist/_pkgs/affine-inline-latex/latex-node/latex-node.d.ts +10 -0
  225. package/dist/_pkgs/affine-inline-latex/latex-node/latex-node.js +23 -0
  226. package/dist/_pkgs/affine-inline-link/link-node/affine-link.js +4 -1
  227. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  228. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +29 -1
  229. package/dist/_pkgs/affine-model/blocks/code/code-model.d.ts +1 -0
  230. package/dist/_pkgs/affine-model/blocks/code/code-model.js +1 -0
  231. package/dist/_pkgs/affine-model/elements/connector/connector.js +24 -0
  232. package/dist/_pkgs/affine-model/elements/edgy/board.d.ts +32 -0
  233. package/dist/_pkgs/affine-model/elements/edgy/board.js +112 -0
  234. package/dist/_pkgs/affine-model/elements/edgy/facets.d.ts +12 -0
  235. package/dist/_pkgs/affine-model/elements/edgy/facets.js +25 -1
  236. package/dist/_pkgs/affine-model/elements/edgy/index.d.ts +1 -0
  237. package/dist/_pkgs/affine-model/elements/edgy/index.js +1 -0
  238. package/dist/_pkgs/affine-model/elements/framework-background/background.d.ts +42 -0
  239. package/dist/_pkgs/affine-model/elements/framework-background/background.js +42 -0
  240. package/dist/_pkgs/affine-model/elements/framework-background/index.d.ts +1 -0
  241. package/dist/_pkgs/affine-model/elements/framework-background/index.js +1 -0
  242. package/dist/_pkgs/affine-model/elements/index.d.ts +3 -1
  243. package/dist/_pkgs/affine-model/elements/index.js +1 -0
  244. package/dist/_pkgs/affine-model/elements/mindmap/mindmap.js +8 -3
  245. package/dist/_pkgs/affine-model/elements/mindmap/style.d.ts +10 -0
  246. package/dist/_pkgs/affine-model/elements/mindmap/style.js +8 -0
  247. package/dist/_pkgs/affine-model/elements/wardley/wardley.d.ts +21 -29
  248. package/dist/_pkgs/affine-model/elements/wardley/wardley.js +41 -48
  249. package/dist/_pkgs/affine-shared/adapters/markdown/delta-converter.d.ts +6 -1
  250. package/dist/_pkgs/affine-shared/adapters/markdown/delta-converter.js +160 -2
  251. package/dist/_pkgs/affine-shared/adapters/markdown/markdown.js +5 -1
  252. package/dist/_pkgs/affine-shared/adapters/types/delta-converter.d.ts +1 -0
  253. package/dist/_pkgs/affine-shared/adapters/utils/color.d.ts +24 -0
  254. package/dist/_pkgs/affine-shared/adapters/utils/color.js +280 -0
  255. package/dist/_pkgs/affine-shared/adapters/utils/index.d.ts +1 -0
  256. package/dist/_pkgs/affine-shared/adapters/utils/index.js +1 -0
  257. package/dist/_pkgs/affine-shared/commands/block-crud/get-selected-blocks.js +10 -2
  258. package/dist/_pkgs/affine-shared/services/audit-service.d.ts +300 -0
  259. package/dist/_pkgs/affine-shared/services/audit-service.js +228 -0
  260. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +7 -0
  261. package/dist/_pkgs/affine-shared/services/edit-props-store.js +11 -0
  262. package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +26 -1
  263. package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.js +124 -7
  264. package/dist/_pkgs/affine-shared/services/index.d.ts +5 -0
  265. package/dist/_pkgs/affine-shared/services/index.js +5 -0
  266. package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.d.ts +129 -0
  267. package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.js +311 -0
  268. package/dist/_pkgs/affine-shared/services/pivot-properties-service.d.ts +217 -0
  269. package/dist/_pkgs/affine-shared/services/pivot-properties-service.js +114 -0
  270. package/dist/_pkgs/affine-shared/services/telemetry-service/code-block.d.ts +1 -1
  271. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +182 -0
  272. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  273. package/dist/_pkgs/affine-shared/services/telemetry-service/types.d.ts +6 -1
  274. package/dist/_pkgs/affine-shared/services/toolbar-service/action.d.ts +10 -0
  275. package/dist/_pkgs/affine-shared/services/toolbar-service/index.d.ts +1 -0
  276. package/dist/_pkgs/affine-shared/services/toolbar-service/index.js +1 -0
  277. package/dist/_pkgs/affine-shared/services/toolbar-service/layout.d.ts +134 -0
  278. package/dist/_pkgs/affine-shared/services/toolbar-service/layout.js +146 -0
  279. package/dist/_pkgs/affine-shared/services/translation-service/index.d.ts +68 -0
  280. package/dist/_pkgs/affine-shared/services/translation-service/index.js +39 -0
  281. package/dist/_pkgs/affine-shared/services/universe-tag-defs-service.d.ts +155 -0
  282. package/dist/_pkgs/affine-shared/services/universe-tag-defs-service.js +254 -0
  283. package/dist/_pkgs/affine-shared/utils/dom/point-to-range.d.ts +4 -0
  284. package/dist/_pkgs/affine-shared/utils/dom/point-to-range.js +58 -2
  285. package/dist/_pkgs/affine-shared/utils/dom/viewport.d.ts +60 -0
  286. package/dist/_pkgs/affine-shared/utils/dom/viewport.js +58 -0
  287. package/dist/_pkgs/affine-shared/utils/print-to-pdf.d.ts +21 -0
  288. package/dist/_pkgs/affine-shared/utils/print-to-pdf.js +166 -32
  289. package/dist/_pkgs/affine-shared/utils/zod-schema.d.ts +7 -0
  290. package/dist/_pkgs/affine-shared/utils/zod-schema.js +27 -1
  291. package/dist/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.d.ts +19 -10
  292. package/dist/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.js +122 -23
  293. package/dist/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.d.ts +2 -0
  294. package/dist/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.js +25 -4
  295. package/dist/_pkgs/affine-widget-edgeless-selected-rect/auto-complete-panel.js +10 -5
  296. package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.d.ts +15 -1
  297. package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.js +37 -32
  298. package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-element-link.js +5 -4
  299. package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-selected-rect.js +19 -9
  300. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.d.ts +16 -2
  301. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +19 -2
  302. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +1 -0
  303. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +1 -0
  304. package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.d.ts +38 -0
  305. package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.js +99 -0
  306. package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +4 -1
  307. package/dist/_pkgs/affine-widget-keyboard-toolbar/icons.js +98 -98
  308. package/dist/_pkgs/affine-widget-linked-doc/linked-doc-popover.js +2 -15
  309. package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.d.ts +10 -1
  310. package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.js +133 -6
  311. package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.d.ts +10 -0
  312. package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.js +120 -3
  313. package/dist/_pkgs/affine-widget-linked-doc/utils.d.ts +12 -0
  314. package/dist/_pkgs/affine-widget-linked-doc/utils.js +33 -0
  315. package/dist/_pkgs/affine-widget-remote-selection/edgeless/index.js +6 -4
  316. package/dist/_pkgs/affine-widget-slash-menu/slash-menu-popover.js +8 -4
  317. package/dist/_pkgs/affine-widget-slash-menu/utils.d.ts +9 -0
  318. package/dist/_pkgs/affine-widget-slash-menu/utils.js +24 -0
  319. package/dist/_pkgs/affine-widget-toolbar/toolbar.d.ts +6 -0
  320. package/dist/_pkgs/affine-widget-toolbar/toolbar.js +34 -6
  321. package/dist/_pkgs/affine-widget-toolbar/utils.d.ts +146 -3
  322. package/dist/_pkgs/affine-widget-toolbar/utils.js +738 -56
  323. package/dist/_pkgs/data-view/core/common/property-menu.js +3 -16
  324. package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +4 -0
  325. package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +28 -1
  326. package/dist/_pkgs/data-view/core/data-view.d.ts +3 -1
  327. package/dist/_pkgs/data-view/core/data-view.js +25 -3
  328. package/dist/_pkgs/data-view/core/detail/field.js +2 -2
  329. package/dist/_pkgs/data-view/core/detail/selection.d.ts +4 -2
  330. package/dist/_pkgs/data-view/core/detail/selection.js +23 -7
  331. package/dist/_pkgs/data-view/core/effect.js +2 -0
  332. package/dist/_pkgs/data-view/core/filter/eval.js +36 -23
  333. package/dist/_pkgs/data-view/core/filter/filter-fn/matcher.d.ts +7 -0
  334. package/dist/_pkgs/data-view/core/filter/filter-fn/matcher.js +12 -0
  335. package/dist/_pkgs/data-view/core/group-by/compare-date-keys.d.ts +11 -0
  336. package/dist/_pkgs/data-view/core/group-by/compare-date-keys.js +55 -0
  337. package/dist/_pkgs/data-view/core/group-by/define.d.ts +6 -0
  338. package/dist/_pkgs/data-view/core/group-by/define.js +114 -0
  339. package/dist/_pkgs/data-view/core/group-by/matcher.d.ts +7 -0
  340. package/dist/_pkgs/data-view/core/group-by/matcher.js +13 -0
  341. package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +11 -11
  342. package/dist/_pkgs/data-view/core/group-by/renderer/date-group.d.ts +9 -0
  343. package/dist/_pkgs/data-view/core/group-by/renderer/date-group.js +97 -0
  344. package/dist/_pkgs/data-view/core/group-by/setting.js +86 -7
  345. package/dist/_pkgs/data-view/core/group-by/trait.d.ts +34 -0
  346. package/dist/_pkgs/data-view/core/group-by/trait.js +106 -10
  347. package/dist/_pkgs/data-view/core/utils/menu-title.js +17 -17
  348. package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +3 -1
  349. package/dist/_pkgs/data-view/property-presets/number/define.js +2 -1
  350. package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +3 -1
  351. package/dist/_pkgs/data-view/view-presets/calendar/calendar-view-manager.d.ts +70 -0
  352. package/dist/_pkgs/data-view/view-presets/calendar/calendar-view-manager.js +449 -0
  353. package/dist/_pkgs/data-view/view-presets/calendar/define.d.ts +10 -0
  354. package/dist/_pkgs/data-view/view-presets/calendar/define.js +27 -0
  355. package/dist/_pkgs/data-view/view-presets/calendar/effect.d.ts +1 -0
  356. package/dist/_pkgs/data-view/view-presets/calendar/effect.js +4 -0
  357. package/dist/_pkgs/data-view/view-presets/calendar/index.d.ts +6 -0
  358. package/dist/_pkgs/data-view/view-presets/calendar/index.js +6 -0
  359. package/dist/_pkgs/data-view/view-presets/calendar/layout.d.ts +37 -0
  360. package/dist/_pkgs/data-view/view-presets/calendar/layout.js +138 -0
  361. package/dist/_pkgs/data-view/view-presets/calendar/pc/actions.d.ts +7 -0
  362. package/dist/_pkgs/data-view/view-presets/calendar/pc/actions.js +68 -0
  363. package/dist/_pkgs/data-view/view-presets/calendar/pc/dnd.d.ts +32 -0
  364. package/dist/_pkgs/data-view/view-presets/calendar/pc/dnd.js +159 -0
  365. package/dist/_pkgs/data-view/view-presets/calendar/pc/effect.d.ts +1 -0
  366. package/dist/_pkgs/data-view/view-presets/calendar/pc/effect.js +7 -0
  367. package/dist/_pkgs/data-view/view-presets/calendar/pc/hit-test.d.ts +1 -0
  368. package/dist/_pkgs/data-view/view-presets/calendar/pc/hit-test.js +28 -0
  369. package/dist/_pkgs/data-view/view-presets/calendar/pc/styles.d.ts +1 -0
  370. package/dist/_pkgs/data-view/view-presets/calendar/pc/styles.js +707 -0
  371. package/dist/_pkgs/data-view/view-presets/calendar/pc/view.d.ts +89 -0
  372. package/dist/_pkgs/data-view/view-presets/calendar/pc/view.js +837 -0
  373. package/dist/_pkgs/data-view/view-presets/calendar/renderer.d.ts +2 -0
  374. package/dist/_pkgs/data-view/view-presets/calendar/renderer.js +8 -0
  375. package/dist/_pkgs/data-view/view-presets/calendar/source.d.ts +8 -0
  376. package/dist/_pkgs/data-view/view-presets/calendar/source.js +3 -0
  377. package/dist/_pkgs/data-view/view-presets/calendar/types.d.ts +79 -0
  378. package/dist/_pkgs/data-view/view-presets/calendar/types.js +1 -0
  379. package/dist/_pkgs/data-view/view-presets/convert.js +28 -0
  380. package/dist/_pkgs/data-view/view-presets/effect.js +2 -0
  381. package/dist/_pkgs/data-view/view-presets/index.d.ts +2 -0
  382. package/dist/_pkgs/data-view/view-presets/index.js +3 -0
  383. package/dist/_pkgs/data-view/view-presets/kanban/kanban-view-manager.js +3 -1
  384. package/dist/_pkgs/data-view/view-presets/kanban/mobile/cell.js +2 -2
  385. package/dist/_pkgs/data-view/view-presets/table/collapsed-state.d.ts +18 -0
  386. package/dist/_pkgs/data-view/view-presets/table/collapsed-state.js +36 -0
  387. package/dist/_pkgs/data-view/view-presets/table/mobile/cell.js +2 -2
  388. package/dist/_pkgs/data-view/view-presets/table/mobile/group.d.ts +11 -0
  389. package/dist/_pkgs/data-view/view-presets/table/mobile/group.js +87 -4
  390. package/dist/_pkgs/data-view/view-presets/table/pc/cell.d.ts +3 -0
  391. package/dist/_pkgs/data-view/view-presets/table/pc/cell.js +11 -2
  392. package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.d.ts +1 -0
  393. package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.js +39 -33
  394. package/dist/_pkgs/data-view/view-presets/table/pc/group.d.ts +10 -0
  395. package/dist/_pkgs/data-view/view-presets/table/pc/group.js +84 -5
  396. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.d.ts +1 -0
  397. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.js +39 -33
  398. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/group-title.js +18 -18
  399. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.d.ts +3 -0
  400. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.js +8 -0
  401. package/dist/_pkgs/data-view/view-presets/table/table-view-manager.js +3 -1
  402. package/dist/_pkgs/data-view/view-presets/table/utils.d.ts +3 -0
  403. package/dist/_pkgs/data-view/view-presets/table/utils.js +16 -1
  404. package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.js +3 -1
  405. package/dist/_pkgs/global/gfx/curve.js +4 -3
  406. package/dist/_pkgs/std/clipboard/clipboard.js +13 -3
  407. package/dist/_pkgs/std/clipboard/utils.d.ts +5 -0
  408. package/dist/_pkgs/std/clipboard/utils.js +7 -0
  409. package/dist/_pkgs/std/event/dispatcher.js +27 -1
  410. package/dist/_pkgs/std/event/keymap.js +16 -6
  411. package/dist/_pkgs/std/extension/command-registry.d.ts +321 -0
  412. package/dist/_pkgs/std/extension/command-registry.js +233 -0
  413. package/dist/_pkgs/std/extension/dnd/index.d.ts +1 -1
  414. package/dist/_pkgs/std/extension/index.d.ts +2 -0
  415. package/dist/_pkgs/std/extension/index.js +2 -0
  416. package/dist/_pkgs/std/extension/translation-manifest.d.ts +49 -0
  417. package/dist/_pkgs/std/extension/translation-manifest.js +71 -0
  418. package/dist/_pkgs/std/gfx/index.d.ts +7 -3
  419. package/dist/_pkgs/std/gfx/index.js +6 -2
  420. package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.js +6 -1
  421. package/dist/_pkgs/std/gfx/interactivity/manager.d.ts +8 -0
  422. package/dist/_pkgs/std/gfx/interactivity/manager.js +18 -0
  423. package/dist/_pkgs/std/gfx/layer.d.ts +1 -1
  424. package/dist/_pkgs/std/gfx/layer.js +1 -2
  425. package/dist/_pkgs/std/gfx/model/surface/decorators/field.js +9 -0
  426. package/dist/_pkgs/std/gfx/model/surface/decorators/index.d.ts +2 -2
  427. package/dist/_pkgs/std/gfx/model/surface/decorators/index.js +2 -2
  428. package/dist/_pkgs/std/gfx/model/surface/decorators/local.d.ts +14 -0
  429. package/dist/_pkgs/std/gfx/model/surface/decorators/local.js +22 -0
  430. package/dist/_pkgs/std/gfx/model/surface/decorators/observer.d.ts +2 -0
  431. package/dist/_pkgs/std/gfx/model/surface/decorators/observer.js +40 -1
  432. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +282 -0
  433. package/dist/_pkgs/std/gfx/model/surface/element-model.js +436 -25
  434. package/dist/_pkgs/std/gfx/model/surface/pivot.d.ts +48 -0
  435. package/dist/_pkgs/std/gfx/model/surface/pivot.js +34 -0
  436. package/dist/_pkgs/std/gfx/model/surface/role.d.ts +153 -0
  437. package/dist/_pkgs/std/gfx/model/surface/role.js +115 -0
  438. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +70 -0
  439. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +304 -17
  440. package/dist/_pkgs/std/gfx/model/surface/tags.d.ts +77 -0
  441. package/dist/_pkgs/std/gfx/model/surface/tags.js +246 -0
  442. package/dist/_pkgs/std/gfx/perf.d.ts +10 -0
  443. package/dist/_pkgs/std/gfx/perf.js +30 -0
  444. package/dist/_pkgs/std/gfx/tool/tool-controller.d.ts +13 -0
  445. package/dist/_pkgs/std/gfx/tool/tool-controller.js +26 -0
  446. package/dist/_pkgs/std/gfx/viewport.d.ts +12 -0
  447. package/dist/_pkgs/std/gfx/viewport.js +19 -1
  448. package/dist/_pkgs/std/inline/services/event.d.ts +2 -0
  449. package/dist/_pkgs/std/inline/services/event.js +96 -21
  450. package/dist/_pkgs/std/utils/layer.js +2 -6
  451. package/dist/_pkgs/std/utils/tree.d.ts +14 -0
  452. package/dist/_pkgs/std/utils/tree.js +59 -8
  453. package/dist/_pkgs/std/view/element/gfx-block-component.js +23 -13
  454. package/dist/_pkgs/store/extension/workspace/workspace-meta.d.ts +10 -0
  455. package/dist/_pkgs/store/model/block/flat-sync-controller.js +2 -12
  456. package/dist/_pkgs/store/model/store/crud.js +7 -4
  457. package/dist/_pkgs/store/reactive/flat-native-y/index.d.ts +1 -1
  458. package/dist/_pkgs/store/reactive/flat-native-y/index.js +24 -2
  459. package/dist/commands.d.ts +58 -0
  460. package/dist/commands.js +66 -0
  461. package/dist/extensions/command-telemetry.d.ts +21 -0
  462. package/dist/extensions/command-telemetry.js +89 -0
  463. package/dist/extensions/store.d.ts +9 -4
  464. package/dist/extensions/store.js +27 -24
  465. package/dist/extensions/view.d.ts +9 -4
  466. package/dist/extensions/view.js +23 -8
  467. package/dist/flags.d.ts +98 -21
  468. package/dist/flags.js +103 -22
  469. package/dist/frameworks.d.ts +45 -0
  470. package/dist/frameworks.js +154 -0
  471. package/dist/schemas.d.ts +8 -5
  472. package/dist/schemas.js +28 -32
  473. package/dist/shortcuts.d.ts +16 -16
  474. package/dist/shortcuts.js +8 -36
  475. package/dist/translations.d.ts +56 -0
  476. package/dist/translations.js +112 -0
  477. package/package.json +16 -4
  478. package/dist/_pkgs/affine-block-root/keyboard/shortcuts.d.ts +0 -8
  479. package/dist/_pkgs/affine-block-root/keyboard/shortcuts.js +0 -48
  480. package/dist/_pkgs/affine-gfx-shape/shortcuts.d.ts +0 -6
  481. package/dist/_pkgs/affine-gfx-shape/shortcuts.js +0 -28
  482. package/dist/_pkgs/data-view/core/utils/cache.d.ts +0 -5
  483. package/dist/_pkgs/data-view/core/utils/cache.js +0 -28
@@ -0,0 +1,395 @@
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
35
+ import { translateKey } from '../../affine-shared/services/index.js';
36
+ import { WidgetComponent, WidgetViewExtension } from '../../std/index.js';
37
+ import { GfxControllerIdentifier } from '../../std/gfx/index.js';
38
+ import { effect } from '@preact/signals-core';
39
+ import { css, html, nothing, unsafeCSS } from 'lit';
40
+ import { state } from 'lit/decorators.js';
41
+ import { styleMap } from 'lit/directives/style-map.js';
42
+ import { literal, unsafeStatic } from 'lit/static-html.js';
43
+ import { EDGE_DIRECTION_COLOR, EdgeDirectionManager, labelAnchorOf, } from './direction-reveal.js';
44
+ import { edgeVerbOf } from './typed-edge.js';
45
+ export const EDGE_DIRECTION_WIDGET = 'affine-edge-direction-widget';
46
+ /**
47
+ * Screen pixels between the bottom of the viewport and the armed-tool hint —
48
+ * clear of the edgeless toolbar, which is the one thing that lives down there.
49
+ * The hint hangs UPWARDS from that line (see the rule below), so the whole box
50
+ * is above the strip and not merely its top edge.
51
+ */
52
+ const HINT_BOTTOM_GAP = 96;
53
+ /** How wide the hint may get before the sentence wraps. */
54
+ const HINT_MAX_WIDTH = 420;
55
+ /** One line of hint, box included — the room it needs above its anchor line. */
56
+ const HINT_MIN_HEIGHT = 48;
57
+ /**
58
+ * **Under every toolbar** — the reverse of the reading panel's choice, for the
59
+ * reverse reason (PO recette of 02/08/2026, point 4).
60
+ *
61
+ * What this widget draws belongs to the CANVAS: a label glued to a link, in
62
+ * model units, turning and scaling with the map. The toolbars overhang the
63
+ * canvas, so a canvas mark that paints over the senior menu — which is what the
64
+ * PO photographed — is a layering mistake and not a matter of taste. The
65
+ * reading panel is the opposite case: a piece of UI the user is reading, which
66
+ * the toolbars may wait underneath.
67
+ *
68
+ * `0`, not `2`, and both numbers are about siblings rather than about depth.
69
+ * `.widgets-container` has `contain: layout`, so it is a stacking context and
70
+ * every widget host competes inside it: `edgeless-toolbar-widget` takes
71
+ * `z-index: 1` (its senior menu and sub-menus are appended inside its own
72
+ * subtree, so they ride on that 1), and `editor-toolbar` — the contextual one —
73
+ * takes `--affine-z-index-popover`, which the theme sets to 1000. `2` cleared
74
+ * the first of those and that is exactly the bug. `0` is under both, and still
75
+ * over the canvas: the container as a whole paints above `.edgeless-container`,
76
+ * which is its earlier sibling OUTSIDE it.
77
+ */
78
+ const EDGE_DIRECTION_Z_INDEX = 0;
79
+ /**
80
+ * The PROSE of `docs/adr/0010`'s M1 and M2, on the pattern
81
+ * `violation-detail-widget` established one directory away — and, since the
82
+ * chevron was folded into the label, the whole of what M2 draws.
83
+ *
84
+ * Two things, both of them WORDS and therefore both of them here rather than on
85
+ * the canvas (a tooltip rendered at a quarter size is not a smaller tooltip, it
86
+ * is an unreadable one):
87
+ *
88
+ * - **M2** — while a typed edge is hovered or selected, the role's VERB laid
89
+ * along the link: `depends on`, in a box that ends in a point aimed at the
90
+ * provider. Since the PO acceptance of 02/08/2026 this is the only mark the
91
+ * reveal draws; the canvas chevron it used to sit on top of is folded into
92
+ * that point (see `direction-reveal.ts`). Since the second pass of the same
93
+ * recette it is the verb ALONE: the full sentence was longer than the links
94
+ * it was laid on, so it covered the very components it named — and those
95
+ * names are already drawn at both ends of the line.
96
+ * - **M1** — while a tool that draws a typed edge is armed, the sentence that
97
+ * tells the user which way to drag. That is what turns the direction their
98
+ * gesture writes into a statement they made.
99
+ *
100
+ * It knows no framework: the verb is a key declared by a ROLE
101
+ * (`EdgeDirectionDef`) and resolved through the host's catalogue.
102
+ */
103
+ let EdgeDirectionWidget = (() => {
104
+ let _classSuper = WidgetComponent;
105
+ let __revealed_decorators;
106
+ let __revealed_initializers = [];
107
+ let __revealed_extraInitializers = [];
108
+ let __hint_decorators;
109
+ let __hint_initializers = [];
110
+ let __hint_extraInitializers = [];
111
+ return class EdgeDirectionWidget extends _classSuper {
112
+ static {
113
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
114
+ __revealed_decorators = [state()];
115
+ __hint_decorators = [state()];
116
+ __esDecorate(this, null, __revealed_decorators, { kind: "accessor", name: "_revealed", static: false, private: false, access: { has: obj => "_revealed" in obj, get: obj => obj._revealed, set: (obj, value) => { obj._revealed = value; } }, metadata: _metadata }, __revealed_initializers, __revealed_extraInitializers);
117
+ __esDecorate(this, null, __hint_decorators, { kind: "accessor", name: "_hint", static: false, private: false, access: { has: obj => "_hint" in obj, get: obj => obj._hint, set: (obj, value) => { obj._hint = value; } }, metadata: _metadata }, __hint_initializers, __hint_extraInitializers);
118
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
119
+ }
120
+ static { this.styles = css `
121
+ :host {
122
+ position: absolute;
123
+ top: 0;
124
+ left: 0;
125
+ z-index: ${unsafeCSS(EDGE_DIRECTION_Z_INDEX)};
126
+ pointer-events: none;
127
+ }
128
+
129
+ /*
130
+ * The verb, laid along its link.
131
+ *
132
+ * Every length below is in MODEL units: render() multiplies the whole box
133
+ * by the viewport zoom, so the label keeps its proportion to the line it
134
+ * names instead of swelling into a banner when the user zooms out. That is
135
+ * the same rule the chevron it replaces obeyed, and the same one the
136
+ * validation marks obey.
137
+ *
138
+ * Filled rather than outlined, because the box is a SHAPE now: an arrow's
139
+ * point has no border to speak of, and a hairline diagonal at 40 % zoom is
140
+ * a smudge. Solid house blue with white text reads in both themes and
141
+ * cannot be mistaken for the map's own ink.
142
+ */
143
+ .edge-direction-label {
144
+ --edge-direction-point: 9px;
145
+ position: absolute;
146
+ box-sizing: border-box;
147
+ padding: 2px 8px;
148
+ border-radius: 3px;
149
+ background: ${unsafeCSS(EDGE_DIRECTION_COLOR)};
150
+ color: #fff;
151
+ font-family: var(--affine-font-family);
152
+ font-size: 12px;
153
+ font-weight: 500;
154
+ line-height: 1.4;
155
+ white-space: nowrap;
156
+ /* The box turns and scales about its own centre, which render() has
157
+ already put on the middle of the path. */
158
+ transform-origin: center center;
159
+ /* Strictly an annotation: it must never take a click away from the edge
160
+ it is describing. */
161
+ pointer-events: none;
162
+ }
163
+
164
+ /*
165
+ * Which END of the box is the point — never which end of the WORDS.
166
+ * data-arrow=end is the ordinary case: the link runs left-to-right on
167
+ * screen, so the target is past the last word. data-arrow=start is the same
168
+ * box on a link running the other way, turned 180° to stay readable: the
169
+ * target is now behind the first word, so the point moves there and the
170
+ * verb is left alone, spelled the way it is read.
171
+ */
172
+ .edge-direction-label[data-arrow='end'] {
173
+ padding-right: calc(8px + var(--edge-direction-point));
174
+ clip-path: polygon(
175
+ 0 0,
176
+ calc(100% - var(--edge-direction-point)) 0,
177
+ 100% 50%,
178
+ calc(100% - var(--edge-direction-point)) 100%,
179
+ 0 100%
180
+ );
181
+ }
182
+
183
+ .edge-direction-label[data-arrow='start'] {
184
+ padding-left: calc(8px + var(--edge-direction-point));
185
+ clip-path: polygon(
186
+ var(--edge-direction-point) 0,
187
+ 100% 0,
188
+ 100% 100%,
189
+ var(--edge-direction-point) 100%,
190
+ 0 50%
191
+ );
192
+ }
193
+
194
+ /*
195
+ * Positioned in SCREEN pixels from the widget host, which sits at the
196
+ * viewport's origin: left and top are handed in by render() off
197
+ * gfx.viewport, exactly like the validation badge's are.
198
+ *
199
+ * It cannot be positioned against the host itself. That host is a
200
+ * zero-sized absolutely positioned box (the house pattern for a widget that
201
+ * must not intercept the canvas), so bottom: 96px put the banner 96 px
202
+ * ABOVE the viewport's top edge, and left: 50% of a zero width put it on
203
+ * the left border — off screen twice over.
204
+ */
205
+ .edge-direction-hint {
206
+ position: absolute;
207
+ /*
208
+ * Hangs UPWARDS from the line render() computes, rather than downwards
209
+ * from it. The widget now paints UNDER the toolbars (see
210
+ * EDGE_DIRECTION_Z_INDEX), so a box whose lower third crossed the
211
+ * 80px-tall toolbar strip would have that third clipped away by it — and
212
+ * the clipped third is where a two-line hint puts its second line.
213
+ * HINT_BOTTOM_GAP is the strip's clearance, so anchoring the box's
214
+ * BOTTOM there puts the whole of it in the clear whatever it says.
215
+ */
216
+ transform: translate(-50%, -100%);
217
+ /*
218
+ * width, not max-width alone. An absolutely positioned box shrinks to fit
219
+ * its CONTAINING BLOCK, and this one's containing block is the zero-sized
220
+ * widget host — so the banner collapsed to its longest word (95 px) and
221
+ * grew five lines tall, which is how it ended up below the bottom edge it
222
+ * was supposed to sit above. max-content sizes it to the sentence; the cap
223
+ * comes from render(), which knows how wide the viewport is.
224
+ */
225
+ width: max-content;
226
+ /* So the viewport-derived max-width caps the BOX, padding and border
227
+ included — the number render() computes is a screen budget, not a
228
+ content budget. */
229
+ box-sizing: border-box;
230
+ padding: 6px 12px;
231
+ border-radius: 8px;
232
+ border: 1px solid var(--affine-border-color);
233
+ background: var(--affine-background-overlay-panel-color, #fff);
234
+ box-shadow: var(--affine-shadow-1);
235
+ color: var(--affine-text-secondary-color);
236
+ font-family: var(--affine-font-family);
237
+ font-size: 13px;
238
+ line-height: 1.4;
239
+ text-align: center;
240
+ pointer-events: none;
241
+ }
242
+ `; }
243
+ #_revealed_accessor_storage = __runInitializers(this, __revealed_initializers, []);
244
+ get _revealed() { return this.#_revealed_accessor_storage; }
245
+ set _revealed(value) { this.#_revealed_accessor_storage = value; }
246
+ #_hint_accessor_storage = (__runInitializers(this, __revealed_extraInitializers), __runInitializers(this, __hint_initializers, null));
247
+ get _hint() { return this.#_hint_accessor_storage; }
248
+ set _hint(value) { this.#_hint_accessor_storage = value; }
249
+ get gfx() {
250
+ return this.std.get(GfxControllerIdentifier);
251
+ }
252
+ get _manager() {
253
+ return this.std.getOptional(EdgeDirectionManager) ?? null;
254
+ }
255
+ /**
256
+ * Idempotent wiring, called from both `firstUpdated` and a later
257
+ * `connectedCallback`: `WithDisposable` throws its group away on disconnect
258
+ * while lit runs `firstUpdated` once, so wiring done only there never comes
259
+ * back if the widget is detached and re-attached.
260
+ */
261
+ _wire() {
262
+ const manager = this._manager;
263
+ if (!manager)
264
+ return;
265
+ this._disposables.add(effect(() => {
266
+ const next = manager.revealed$.value;
267
+ if (next.length === 0 && this._revealed.length === 0)
268
+ return;
269
+ this._revealed = next;
270
+ }));
271
+ this._disposables.add(effect(() => {
272
+ this._hint = manager.armedHint$.value;
273
+ }));
274
+ this._disposables.add(this.gfx.viewport.viewportUpdated.subscribe(() => {
275
+ // The label is pinned to a model point AND scaled by the zoom, so a pan
276
+ // or a zoom moves it — and the hint is pinned to the viewport's own
277
+ // size, so a RESIZE moves that one. Both are on screen only while
278
+ // something is revealed
279
+ // or a tool is armed, so a quiet board re-renders nothing.
280
+ if (this._revealed.length > 0 || this._hint !== null) {
281
+ this.requestUpdate();
282
+ }
283
+ }));
284
+ const surface = this.gfx.surface;
285
+ if (surface) {
286
+ const subscription = surface.elementUpdated.subscribe(() => {
287
+ // An endpoint re-drag reroutes the path under the label. Cheap: lit
288
+ // batches this into one render per frame, and it only runs while
289
+ // something is actually revealed.
290
+ if (this._revealed.length > 0)
291
+ this.requestUpdate();
292
+ });
293
+ this._disposables.add(() => subscription.unsubscribe());
294
+ }
295
+ }
296
+ connectedCallback() {
297
+ super.connectedCallback();
298
+ if (this.hasUpdated)
299
+ this._wire();
300
+ }
301
+ firstUpdated() {
302
+ this._wire();
303
+ }
304
+ /**
305
+ * The word a revealed edge is labelled with, in the framework's own words —
306
+ * the role's verb, said in the host's language.
307
+ *
308
+ * `''` when the role declares neither verb nor label, in which case the
309
+ * caller draws nothing at all.
310
+ */
311
+ _verbFor(edge) {
312
+ const verb = edgeVerbOf(edge);
313
+ return verb ? translateKey(this.std, verb.key, verb.fallback) : '';
314
+ }
315
+ _renderLabel(edgeId) {
316
+ const manager = this._manager;
317
+ const edge = manager
318
+ ?.revealedEdges()
319
+ .find(candidate => candidate.model.id === edgeId);
320
+ if (!edge)
321
+ return nothing;
322
+ const anchor = labelAnchorOf(edge.model);
323
+ if (!anchor)
324
+ return nothing;
325
+ const verb = this._verbFor(edge);
326
+ if (!verb)
327
+ return nothing;
328
+ const { viewport } = this.gfx;
329
+ const [x, y] = viewport.toViewCoord(anchor.at[0], anchor.at[1]);
330
+ // Two decimals: below what a reader can see on a 12 px box, and it keeps
331
+ // the attribute readable in devtools instead of `45.00000000000001deg`.
332
+ const degrees = ((anchor.angle * 180) / Math.PI).toFixed(2);
333
+ return html `<div
334
+ class="edge-direction-label"
335
+ data-testid="edge-direction-label"
336
+ data-edge-id=${edgeId}
337
+ data-arrow=${anchor.flipped ? 'start' : 'end'}
338
+ title=${edge.role.labelKey
339
+ ? translateKey(this.std, edge.role.labelKey, edge.role.labelFallback)
340
+ : verb}
341
+ style=${styleMap({
342
+ left: `${x}px`,
343
+ top: `${y}px`,
344
+ // Read right to left, as CSS composes it: scale by the zoom and turn
345
+ // onto the line, both about the box's centre, and only THEN slide that
346
+ // centre onto the anchor. The lengths in the class are model units, so
347
+ // `scale` is what makes them model units on screen.
348
+ transform: `translate(-50%, -50%) rotate(${degrees}deg) scale(${viewport.zoom})`,
349
+ })}
350
+ >
351
+ ${verb}
352
+ </div>`;
353
+ }
354
+ /**
355
+ * The armed tool's hint, centred near the bottom of the EDITOR VIEWPORT —
356
+ * above the toolbar, where the user's eyes already are while they aim.
357
+ *
358
+ * The viewport rect is the only frame available to a widget host that is a
359
+ * zero-sized box at its origin, and it is the one the other canvas
360
+ * affordances measure against (`violation-detail-widget` flips its bubble
361
+ * against `viewport.width` / `viewport.height` the same way).
362
+ */
363
+ _renderHint(hint) {
364
+ const { viewport } = this.gfx;
365
+ return html `<div
366
+ class="edge-direction-hint"
367
+ data-testid="edge-direction-hint"
368
+ style=${styleMap({
369
+ left: `${viewport.width / 2}px`,
370
+ // The BOTTOM of the box, since the rule above hangs it upwards. The
371
+ // floor is what keeps a very short editor pushing the banner down
372
+ // rather than off its top edge, which is what `0` would now do.
373
+ top: `${Math.max(HINT_MIN_HEIGHT, viewport.height - HINT_BOTTOM_GAP)}px`,
374
+ // The cap a percentage cannot express here: the containing block is the
375
+ // zero-sized host, so the only honest width bound is the viewport's.
376
+ maxWidth: `${Math.max(120, Math.min(HINT_MAX_WIDTH, viewport.width - 32))}px`,
377
+ })}
378
+ >
379
+ ${translateKey(this.std, hint.key, hint.fallback)}
380
+ </div>`;
381
+ }
382
+ render() {
383
+ if (this._revealed.length === 0 && this._hint === null)
384
+ return nothing;
385
+ return html `${this._revealed.map(id => this._renderLabel(id))}
386
+ ${this._hint ? this._renderHint(this._hint) : nothing}`;
387
+ }
388
+ constructor() {
389
+ super(...arguments);
390
+ __runInitializers(this, __hint_extraInitializers);
391
+ }
392
+ };
393
+ })();
394
+ export { EdgeDirectionWidget };
395
+ export const edgeDirectionWidget = WidgetViewExtension('affine:page', EDGE_DIRECTION_WIDGET, literal `${unsafeStatic(EDGE_DIRECTION_WIDGET)}`);
@@ -0,0 +1,4 @@
1
+ export { EDGE_DIRECTION_COLOR, EdgeDirectionManager, type EdgeLabelAnchor, labelAnchorOf, } from './direction-reveal.js';
2
+ export { EDGE_DIRECTION_WIDGET, EdgeDirectionWidget, edgeDirectionWidget, } from './direction-widget.js';
3
+ export { edgeDirectionCommands, INVERT_EDGE_DIRECTION, invertEdge, invertEdgeDirectionParams, invertibleEdges, type InvertEdgeDirectionParams, } from './invert-direction.js';
4
+ export { asTypedEdge, edgeIsBound, type EdgeVerb, edgeVerbOf, roleVocabularies, type TypedEdge, } from './typed-edge.js';
@@ -0,0 +1,4 @@
1
+ export { EDGE_DIRECTION_COLOR, EdgeDirectionManager, labelAnchorOf, } from './direction-reveal.js';
2
+ export { EDGE_DIRECTION_WIDGET, EdgeDirectionWidget, edgeDirectionWidget, } from './direction-widget.js';
3
+ export { edgeDirectionCommands, INVERT_EDGE_DIRECTION, invertEdge, invertEdgeDirectionParams, invertibleEdges, } from './invert-direction.js';
4
+ export { asTypedEdge, edgeIsBound, edgeVerbOf, roleVocabularies, } from './typed-edge.js';
@@ -0,0 +1,72 @@
1
+ import type { ConnectorElementModel } from '../../affine-model/index.js';
2
+ import type { AnyCommandDescriptor, BlockStdScope } from '../../std/index.js';
3
+ import { z } from 'zod';
4
+ import { type TypedEdge } from './typed-edge.js';
5
+ /**
6
+ * **M3 of `docs/adr/0010` — "let them fix it".**
7
+ *
8
+ * `edge.invert-direction` swaps `source` ↔ `target` on a selected typed edge,
9
+ * and swaps `frontEndpointStyle` ↔ `rearEndpointStyle` with them, in ONE undo
10
+ * step. It is the only supported inversion, and it is what makes the direction
11
+ * a typed edge persists a statement the user can take back rather than a
12
+ * by-product of which end their finger landed on first.
13
+ *
14
+ * ## What it deliberately does NOT touch
15
+ *
16
+ * `curveControlPoint` is an ABSOLUTE pass-through point at t = 0.5, and the
17
+ * tangent formulas are symmetric under a `P0` ↔ `P3` exchange
18
+ * (`connector-manager.ts`), so swapping the ends leaves exactly the same curve
19
+ * on screen. "Mirroring" it would visibly move the curve — that would be a bug,
20
+ * not a fix, and a unit test pins the rendered path against the day somebody
21
+ * tidies this up.
22
+ *
23
+ * ## Why it writes through the surface and not through `EdgelessCRUDIdentifier`
24
+ *
25
+ * `crud.updateElement` calls `recordLastProps`, which would make the swapped
26
+ * endpoint styles the DEFAULT for every connector drawn afterwards — the exact
27
+ * defect `b.flip-direction` has today. An inversion is a statement about one
28
+ * relation, never a style preference.
29
+ */
30
+ export declare const invertEdgeDirectionParams: z.ZodObject<{
31
+ /**
32
+ * Explicit targets, for a host or an agent acting on something other than the
33
+ * live selection. **Omitted** — the key absent — the command acts on the
34
+ * current canvas selection. An EMPTY array means "these zero elements": the
35
+ * command does nothing and does not fall back to the selection.
36
+ */
37
+ elementIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ elementIds?: string[] | undefined;
40
+ }, {
41
+ elementIds?: string[] | undefined;
42
+ }>;
43
+ export type InvertEdgeDirectionParams = z.infer<typeof invertEdgeDirectionParams>;
44
+ /**
45
+ * The typed edges this gesture would rewrite.
46
+ *
47
+ * Typed edges and nothing else: on a generalist connector `source` and `target`
48
+ * carry no claim, so there is no relation to invert and the two ends are
49
+ * already interchangeable labels. Reversing one would be a gesture with no
50
+ * meaning attached.
51
+ *
52
+ * BOUND typed edges, at that. An edge with a free end relates nothing, so
53
+ * swapping its ends moves no relation and shows nothing on screen — the line
54
+ * does not budge, and the reveal (M2) and W4 both look straight past it. An
55
+ * entry that offers to reverse it is an entry that does nothing when clicked,
56
+ * which is worse than an absent one.
57
+ */
58
+ export declare function invertibleEdges(std: BlockStdScope, elementIds?: string[]): TypedEdge[];
59
+ /**
60
+ * Swap the two ends of one typed edge. Pure model write, no capture, no
61
+ * telemetry — exported so a unit test can assert the involution without an
62
+ * editor around it.
63
+ */
64
+ export declare function invertEdge(model: ConnectorElementModel): void;
65
+ /** The registered id, so a toolbar entry can invoke it rather than copy it. */
66
+ export declare const INVERT_EDGE_DIRECTION = "edge.invert-direction";
67
+ /**
68
+ * The registry's element type erases the parameter contract, and `run`
69
+ * re-validates with the zod schema rather than trusting the static type — what
70
+ * an agent-invocable command has to do anyway.
71
+ */
72
+ export declare const edgeDirectionCommands: AnyCommandDescriptor[];
@@ -0,0 +1,187 @@
1
+ import { TelemetryProvider } from '../../affine-shared/services/index.js';
2
+ import { GfxControllerIdentifier } from '../../std/gfx/index.js';
3
+ import { z } from 'zod';
4
+ import { asTypedEdge, edgeIsBound, roleVocabularies, } from './typed-edge.js';
5
+ /**
6
+ * **M3 of `docs/adr/0010` — "let them fix it".**
7
+ *
8
+ * `edge.invert-direction` swaps `source` ↔ `target` on a selected typed edge,
9
+ * and swaps `frontEndpointStyle` ↔ `rearEndpointStyle` with them, in ONE undo
10
+ * step. It is the only supported inversion, and it is what makes the direction
11
+ * a typed edge persists a statement the user can take back rather than a
12
+ * by-product of which end their finger landed on first.
13
+ *
14
+ * ## What it deliberately does NOT touch
15
+ *
16
+ * `curveControlPoint` is an ABSOLUTE pass-through point at t = 0.5, and the
17
+ * tangent formulas are symmetric under a `P0` ↔ `P3` exchange
18
+ * (`connector-manager.ts`), so swapping the ends leaves exactly the same curve
19
+ * on screen. "Mirroring" it would visibly move the curve — that would be a bug,
20
+ * not a fix, and a unit test pins the rendered path against the day somebody
21
+ * tidies this up.
22
+ *
23
+ * ## Why it writes through the surface and not through `EdgelessCRUDIdentifier`
24
+ *
25
+ * `crud.updateElement` calls `recordLastProps`, which would make the swapped
26
+ * endpoint styles the DEFAULT for every connector drawn afterwards — the exact
27
+ * defect `b.flip-direction` has today. An inversion is a statement about one
28
+ * relation, never a style preference.
29
+ */
30
+ export const invertEdgeDirectionParams = z.object({
31
+ /**
32
+ * Explicit targets, for a host or an agent acting on something other than the
33
+ * live selection. **Omitted** — the key absent — the command acts on the
34
+ * current canvas selection. An EMPTY array means "these zero elements": the
35
+ * command does nothing and does not fall back to the selection.
36
+ */
37
+ elementIds: z.array(z.string()).optional(),
38
+ });
39
+ /** Whether this document may be written to at all. */
40
+ const isInvertible = (std) => !std.store.readonly;
41
+ /**
42
+ * The typed edges this gesture would rewrite.
43
+ *
44
+ * Typed edges and nothing else: on a generalist connector `source` and `target`
45
+ * carry no claim, so there is no relation to invert and the two ends are
46
+ * already interchangeable labels. Reversing one would be a gesture with no
47
+ * meaning attached.
48
+ *
49
+ * BOUND typed edges, at that. An edge with a free end relates nothing, so
50
+ * swapping its ends moves no relation and shows nothing on screen — the line
51
+ * does not budge, and the reveal (M2) and W4 both look straight past it. An
52
+ * entry that offers to reverse it is an entry that does nothing when clicked,
53
+ * which is worse than an absent one.
54
+ */
55
+ export function invertibleEdges(std, elementIds) {
56
+ const gfx = std.get(GfxControllerIdentifier);
57
+ const vocabularies = roleVocabularies(std);
58
+ if (vocabularies.length === 0)
59
+ return [];
60
+ const models = elementIds
61
+ ? elementIds.map(id => gfx.surface?.getElementById(id))
62
+ : gfx.selection.selectedElements;
63
+ const edges = [];
64
+ for (const model of models) {
65
+ const edge = asTypedEdge(vocabularies, model);
66
+ if (edge && edgeIsBound(edge.model) && !edge.model.isLocked()) {
67
+ edges.push(edge);
68
+ }
69
+ }
70
+ return edges;
71
+ }
72
+ /**
73
+ * A plain copy of one endpoint. The stored value comes out of a `Y.Map` and is
74
+ * about to be written into the OTHER slot of the same element, so it is copied
75
+ * key by key rather than moved: the two accessors must never end up sharing one
76
+ * object, and an absent key must stay absent instead of becoming `undefined`.
77
+ */
78
+ function copyConnection(connection) {
79
+ const copy = {};
80
+ if (connection?.id !== undefined)
81
+ copy.id = connection.id;
82
+ if (connection?.position !== undefined) {
83
+ copy.position = [connection.position[0], connection.position[1]];
84
+ }
85
+ return copy;
86
+ }
87
+ /**
88
+ * Swap the two ends of one typed edge. Pure model write, no capture, no
89
+ * telemetry — exported so a unit test can assert the involution without an
90
+ * editor around it.
91
+ */
92
+ export function invertEdge(model) {
93
+ const source = copyConnection(model.source);
94
+ const target = copyConnection(model.target);
95
+ model.surface.updateElement(model.id, {
96
+ source: target,
97
+ target: source,
98
+ // The mark follows the relation. Leaving the styles behind would move the
99
+ // only visible sign of the direction away from the end that now carries it
100
+ // — the picture and the data would disagree, which is precisely what
101
+ // `b.flip-direction` does on a typed edge.
102
+ frontEndpointStyle: model.rearEndpointStyle,
103
+ rearEndpointStyle: model.frontEndpointStyle,
104
+ });
105
+ }
106
+ /** The registered id, so a toolbar entry can invoke it rather than copy it. */
107
+ export const INVERT_EDGE_DIRECTION = 'edge.invert-direction';
108
+ const invertEdgeDirection = {
109
+ id: INVERT_EDGE_DIRECTION,
110
+ owner: 'core',
111
+ kind: 'action',
112
+ // NOT under `com.labre.keyboardShortcuts.*`: like `pivot.bind`, this one is
113
+ // keyless by intent and lives on the contextual toolbar, in the palette and
114
+ // in the agent — filing it under "keyboard shortcuts" would mislead a
115
+ // translator.
116
+ labelKey: 'com.labre.command.edge.invert-direction',
117
+ labelFallback: 'Reverse direction',
118
+ descriptionKey: 'com.labre.command.edge.invert-direction.description',
119
+ descriptionFallback: 'Swap the two ends of this relation: what was the subject becomes the object.',
120
+ surfaces: ['contextual-toolbar', 'palette', 'agent'],
121
+ scope: 'edgeless',
122
+ // Keyless by intent — still bindable from Settings › Shortcuts, which is what
123
+ // `toShortcutDescriptor` being total buys.
124
+ defaultKeys: { mac: [], other: [] },
125
+ availability: 'selection',
126
+ // Narrows `'selection'`, never contradicts it: a read-only document and a
127
+ // selection holding no typed edge both have nothing to invert. Read-only
128
+ // rides here rather than on `availability` for the reason `pivot.bind`
129
+ // documents — the union does not compose, and `'selection'` is the
130
+ // precondition a catalogue has to show.
131
+ when: std => isInvertible(std) && invertibleEdges(std).length > 0,
132
+ params: invertEdgeDirectionParams,
133
+ run: (std, invocation, params) => {
134
+ // `params ?? {}`, and the `??` is load-bearing: every in-library call site
135
+ // invokes this command with NO arguments — the contextual toolbar, the
136
+ // palette and `toShortcutDescriptor`'s handler all call
137
+ // `runCommand(std, command, invocation)` — and `safeParse(undefined)` fails
138
+ // on the OBJECT itself, not on a field. Parsing the argument as it arrives
139
+ // made the command a silent no-op everywhere except a caller that passed
140
+ // `elementIds` explicitly, which was exactly the one shape the first tests
141
+ // exercised. The schema's own optionality is what makes `{}` valid, so this
142
+ // reads "no arguments" rather than "invalid arguments".
143
+ const parsed = invertEdgeDirectionParams.safeParse(params ?? {});
144
+ if (!parsed.success) {
145
+ console.error('edge.invert-direction: invalid params', parsed.error.issues);
146
+ return;
147
+ }
148
+ // The load-bearing half of the read-only gate: `when` is consulted by the
149
+ // SURFACES, and `runCommand` consults neither it nor `availability` — the
150
+ // palette and the agent reach `run` directly.
151
+ if (!isInvertible(std))
152
+ return;
153
+ const edges = invertibleEdges(std, parsed.data.elementIds);
154
+ if (edges.length === 0)
155
+ return;
156
+ // BEFORE the writes, not after: `Store.transact` is not an undo boundary,
157
+ // and without this an inversion issued within 500 ms of a drag would be
158
+ // undone TOGETHER with the drag. One capture for the whole gesture is also
159
+ // what makes several selected edges reverse in a single undo step.
160
+ std.store.captureSync();
161
+ for (const { model } of edges)
162
+ invertEdge(model);
163
+ // The ONE emission for this gesture, and not through `runCommand`'s
164
+ // bottleneck: that emitter maps a static `{ framework, element }` onto the
165
+ // three CREATION events, and an inversion creates nothing.
166
+ const roles = new Set(edges.map(edge => edge.role.id));
167
+ const role = roles.size === 1 ? [...roles][0] : undefined;
168
+ std.getOptional(TelemetryProvider)?.track('EdgeDirectionInverted', {
169
+ page: 'whiteboard editor',
170
+ ...(role !== undefined ? { role } : {}),
171
+ ...(role !== undefined
172
+ ? { framework: role.split(':')[0] }
173
+ : {}),
174
+ elementCount: edges.length,
175
+ control: invocation.source,
176
+ module: invocation.surface,
177
+ });
178
+ },
179
+ };
180
+ /**
181
+ * The registry's element type erases the parameter contract, and `run`
182
+ * re-validates with the zod schema rather than trusting the static type — what
183
+ * an agent-invocable command has to do anyway.
184
+ */
185
+ export const edgeDirectionCommands = [
186
+ invertEdgeDirection,
187
+ ];