@formicoidea/labre-core 0.41.0 → 0.43.1

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 (343) hide show
  1. package/LICENSE +384 -0
  2. package/dist/_pkgs/affine-block-bookmark/bookmark-block.js +2 -2
  3. package/dist/_pkgs/affine-block-data-view/configs/tooltips.js +1 -1
  4. package/dist/_pkgs/affine-block-database/configs/tooltips.js +1 -1
  5. package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +4 -2
  6. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.js +7 -1
  7. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.d.ts +39 -0
  8. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.js +39 -0
  9. package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +4 -1
  10. package/dist/_pkgs/affine-block-embed/embed-github-block/embed-github-block.js +2 -1
  11. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.d.ts +14 -1
  12. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.js +21 -2
  13. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +2 -0
  14. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +2 -1
  15. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +41 -11
  16. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.d.ts +16 -0
  17. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.js +17 -1
  18. package/dist/_pkgs/affine-block-embed/embed-iframe-block/utils.d.ts +8 -0
  19. package/dist/_pkgs/affine-block-embed/embed-iframe-block/utils.js +19 -0
  20. package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +4 -1
  21. package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +4 -1
  22. package/dist/_pkgs/affine-block-embed/index.d.ts +1 -0
  23. package/dist/_pkgs/affine-block-embed/index.js +1 -0
  24. package/dist/_pkgs/affine-block-embed/translations.d.ts +8 -0
  25. package/dist/_pkgs/affine-block-embed/translations.js +28 -0
  26. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +4 -2
  27. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +2 -2
  28. package/dist/_pkgs/affine-block-frame/frame-manager.js +6 -3
  29. package/dist/_pkgs/affine-block-frame/frame-tool.js +1 -1
  30. package/dist/_pkgs/affine-block-frame/frame-toolbar.js +6 -1
  31. package/dist/_pkgs/affine-block-list/list-keymap.js +7 -0
  32. package/dist/_pkgs/affine-block-list/utils/get-list-icon.js +3 -1
  33. package/dist/_pkgs/affine-block-note/configs/tooltips.js +1 -1
  34. package/dist/_pkgs/affine-block-note/note-keymap.js +7 -1
  35. package/dist/_pkgs/affine-block-paragraph/paragraph-keymap.js +7 -1
  36. package/dist/_pkgs/affine-block-root/adapters/html.js +2 -2
  37. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.d.ts +2 -0
  38. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +155 -0
  39. package/dist/_pkgs/affine-block-root/commands/pivot-commands.js +1 -8
  40. package/dist/_pkgs/affine-block-root/commands/tag-commands.js +1 -8
  41. package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.d.ts +9 -0
  42. package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +51 -0
  43. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +22 -0
  44. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +46 -0
  45. package/dist/_pkgs/affine-block-root/edgeless/utils/pinch-zoom.d.ts +21 -0
  46. package/dist/_pkgs/affine-block-root/edgeless/utils/pinch-zoom.js +24 -0
  47. package/dist/_pkgs/affine-block-root/edgeless/utils/query.js +8 -0
  48. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  49. package/dist/_pkgs/affine-block-root/index.js +1 -0
  50. package/dist/_pkgs/affine-block-root/keyboard/keymap.js +1 -16
  51. package/dist/_pkgs/affine-block-root/view.js +2 -0
  52. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +21 -3
  53. package/dist/_pkgs/affine-block-surface/element-model/index.js +14 -2
  54. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +23 -0
  55. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +89 -0
  56. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +7 -0
  57. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +5 -0
  58. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +41 -0
  59. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +70 -0
  60. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +49 -0
  61. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +257 -0
  62. package/dist/_pkgs/affine-block-surface/extensions/export-svg/tagged-path.d.ts +16 -0
  63. package/dist/_pkgs/affine-block-surface/extensions/export-svg/tagged-path.js +24 -0
  64. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +24 -0
  65. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +66 -0
  66. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +4 -0
  67. package/dist/_pkgs/affine-block-surface/extensions/index.js +4 -0
  68. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.d.ts +66 -4
  69. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +253 -11
  70. package/dist/_pkgs/affine-block-surface/extensions/interchange.d.ts +18 -0
  71. package/dist/_pkgs/affine-block-surface/extensions/legend-toolbar.d.ts +81 -0
  72. package/dist/_pkgs/affine-block-surface/extensions/legend-toolbar.js +81 -0
  73. package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +144 -0
  74. package/dist/_pkgs/affine-block-surface/extensions/legend.js +495 -0
  75. package/dist/_pkgs/affine-block-surface/extensions/morph-toolbar.js +4 -0
  76. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +17 -3
  77. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +35 -13
  78. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +61 -1
  79. package/dist/_pkgs/affine-block-surface/extensions/reading.js +85 -39
  80. package/dist/_pkgs/affine-block-surface/extensions/record-action.d.ts +66 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/record-action.js +145 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +3 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +23 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +1 -1
  85. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +12 -4
  86. package/dist/_pkgs/affine-block-surface/extensions/validation.d.ts +253 -28
  87. package/dist/_pkgs/affine-block-surface/extensions/validation.js +489 -41
  88. package/dist/_pkgs/affine-block-surface/framework-background/background-view.d.ts +115 -0
  89. package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +185 -0
  90. package/dist/_pkgs/affine-block-surface/framework-background/fit.d.ts +36 -0
  91. package/dist/_pkgs/affine-block-surface/framework-background/fit.js +30 -0
  92. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +2 -0
  93. package/dist/_pkgs/affine-block-surface/framework-background/index.js +2 -0
  94. package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +16 -1
  95. package/dist/_pkgs/affine-block-surface/framework-background/labels.js +31 -21
  96. package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +29 -5
  97. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +6 -4
  98. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +56 -8
  99. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.d.ts +12 -0
  100. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +15 -0
  101. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +2 -7
  102. package/dist/_pkgs/affine-block-surface/view.js +8 -1
  103. package/dist/_pkgs/affine-block-surface-ref/configs/slash-menu.js +1 -1
  104. package/dist/_pkgs/affine-block-surface-ref/configs/tooltips.js +2 -2
  105. package/dist/_pkgs/affine-components/color-picker/button.d.ts +56 -1
  106. package/dist/_pkgs/affine-components/color-picker/button.js +168 -23
  107. package/dist/_pkgs/affine-components/color-picker/framework-palette.d.ts +106 -0
  108. package/dist/_pkgs/affine-components/color-picker/framework-palette.js +177 -0
  109. package/dist/_pkgs/affine-components/color-picker/index.d.ts +2 -0
  110. package/dist/_pkgs/affine-components/color-picker/index.js +2 -0
  111. package/dist/_pkgs/affine-components/color-picker/palette-carousel.d.ts +85 -0
  112. package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +445 -0
  113. package/dist/_pkgs/affine-components/color-picker/styles.js +1 -1
  114. package/dist/_pkgs/affine-components/context-menu/button.js +3 -1
  115. package/dist/_pkgs/affine-components/edgeless-shape-color-picker/color-picker.d.ts +31 -1
  116. package/dist/_pkgs/affine-components/edgeless-shape-color-picker/color-picker.js +189 -63
  117. package/dist/_pkgs/affine-components/icons/ai.js +3 -3
  118. package/dist/_pkgs/affine-components/icons/list.js +7 -1
  119. package/dist/_pkgs/affine-components/resource/resource.js +29 -16
  120. package/dist/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.js +6 -1
  121. package/dist/_pkgs/affine-components/toolbar/index.d.ts +1 -1
  122. package/dist/_pkgs/affine-components/toolbar/index.js +1 -1
  123. package/dist/_pkgs/affine-components/toolbar/menu-button.d.ts +7 -0
  124. package/dist/_pkgs/affine-components/toolbar/menu-button.js +30 -0
  125. package/dist/_pkgs/affine-components/toolbar/picker-menu.d.ts +16 -1
  126. package/dist/_pkgs/affine-components/toolbar/picker-menu.js +2 -2
  127. package/dist/_pkgs/affine-components/toolbar/toolbar.d.ts +1 -0
  128. package/dist/_pkgs/affine-components/toolbar/toolbar.js +67 -0
  129. package/dist/_pkgs/affine-components/translations.d.ts +8 -0
  130. package/dist/_pkgs/affine-components/translations.js +17 -0
  131. package/dist/_pkgs/affine-foundation/view.js +2 -1
  132. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.js +1 -1
  133. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +1 -1
  134. package/dist/_pkgs/affine-gfx-brush/element-renderer.js +2 -2
  135. package/dist/_pkgs/affine-gfx-brush/toolbar/components/eraser/icons.js +1 -1
  136. package/dist/_pkgs/affine-gfx-brush/toolbar/configs/brush.js +6 -1
  137. package/dist/_pkgs/affine-gfx-brush/toolbar/configs/highlighter.js +6 -1
  138. package/dist/_pkgs/affine-gfx-connector/connector-manager.d.ts +9 -1
  139. package/dist/_pkgs/affine-gfx-connector/connector-manager.js +61 -0
  140. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +11 -2
  141. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +11 -2
  142. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.d.ts +7 -1
  143. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +87 -17
  144. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +78 -17
  145. package/dist/_pkgs/affine-gfx-connector/element-renderer/utils.d.ts +24 -2
  146. package/dist/_pkgs/affine-gfx-connector/element-renderer/utils.js +31 -8
  147. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.d.ts +124 -3
  148. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +219 -56
  149. package/dist/_pkgs/affine-gfx-connector/text/text.d.ts +13 -4
  150. package/dist/_pkgs/affine-gfx-connector/text/text.js +13 -44
  151. package/dist/_pkgs/affine-gfx-connector/toolbar/config.d.ts +56 -0
  152. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +94 -10
  153. package/dist/_pkgs/affine-gfx-connector/toolbar/hollow-endpoint-icons.d.ts +8 -0
  154. package/dist/_pkgs/affine-gfx-connector/toolbar/hollow-endpoint-icons.js +118 -0
  155. package/dist/_pkgs/affine-gfx-connector/translations.d.ts +3 -0
  156. package/dist/_pkgs/affine-gfx-connector/translations.js +23 -0
  157. package/dist/_pkgs/affine-gfx-connector/view/view.d.ts +37 -1
  158. package/dist/_pkgs/affine-gfx-connector/view/view.js +97 -8
  159. package/dist/_pkgs/affine-gfx-group/command/group-api.js +1 -1
  160. package/dist/_pkgs/affine-gfx-group/store.js +0 -2
  161. package/dist/_pkgs/affine-gfx-group/translations.d.ts +9 -10
  162. package/dist/_pkgs/affine-gfx-group/translations.js +9 -13
  163. package/dist/_pkgs/affine-gfx-mindmap/indicator-overlay/index.js +6 -2
  164. package/dist/_pkgs/affine-gfx-mindmap/templates/index.js +1 -1
  165. package/dist/_pkgs/affine-gfx-mindmap/toolbar/basket-elements.js +1 -1
  166. package/dist/_pkgs/affine-gfx-mindmap/toolbar/config.js +4 -2
  167. package/dist/_pkgs/affine-gfx-mindmap/toolbar/utils/import-mindmap.js +2 -2
  168. package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +7 -1
  169. package/dist/_pkgs/affine-gfx-mindmap/translations.js +11 -1
  170. package/dist/_pkgs/affine-gfx-shape/element-renderer/highlighter.js +2 -2
  171. package/dist/_pkgs/affine-gfx-shape/overlay/polygon-drawing-overlay.d.ts +6 -0
  172. package/dist/_pkgs/affine-gfx-shape/overlay/polygon-drawing-overlay.js +30 -1
  173. package/dist/_pkgs/affine-gfx-shape/polygon-tool.d.ts +20 -1
  174. package/dist/_pkgs/affine-gfx-shape/polygon-tool.js +9 -1
  175. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +10 -3
  176. package/dist/_pkgs/affine-gfx-shape/toolbar/palette-color-action.js +11 -1
  177. package/dist/_pkgs/affine-gfx-shape/translations.d.ts +7 -0
  178. package/dist/_pkgs/affine-gfx-shape/translations.js +11 -0
  179. package/dist/_pkgs/affine-gfx-template/builtin/other.js +14 -8
  180. package/dist/_pkgs/affine-gfx-template/snapshot-from-action.js +32 -119
  181. package/dist/_pkgs/affine-gfx-template/toolbar/template-loading.js +1 -1
  182. package/dist/_pkgs/affine-gfx-template/toolbar/template-type.d.ts +1 -1
  183. package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
  184. package/dist/_pkgs/affine-gfx-template/translations.js +38 -0
  185. package/dist/_pkgs/affine-gfx-text/dblclick-add-edgeless-text.d.ts +13 -1
  186. package/dist/_pkgs/affine-gfx-text/dblclick-add-edgeless-text.js +19 -4
  187. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.d.ts +41 -0
  188. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +60 -4
  189. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +8 -1
  190. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +14 -2
  191. package/dist/_pkgs/affine-gfx-text/translations.d.ts +9 -0
  192. package/dist/_pkgs/affine-gfx-text/translations.js +14 -1
  193. package/dist/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.js +2 -1
  194. package/dist/_pkgs/affine-inline-preset/markdown.js +5 -1
  195. package/dist/_pkgs/affine-model/consts/connector.d.ts +28 -2
  196. package/dist/_pkgs/affine-model/consts/connector.js +26 -0
  197. package/dist/_pkgs/affine-model/consts/text.d.ts +15 -2
  198. package/dist/_pkgs/affine-model/consts/text.js +25 -1
  199. package/dist/_pkgs/affine-model/elements/bpmn/pool.js +1 -1
  200. package/dist/_pkgs/affine-model/elements/brush/brush.js +1 -1
  201. package/dist/_pkgs/affine-model/elements/c4/board.js +1 -1
  202. package/dist/_pkgs/affine-model/elements/c4/boundary.js +1 -1
  203. package/dist/_pkgs/affine-model/elements/connector/connector.d.ts +135 -0
  204. package/dist/_pkgs/affine-model/elements/connector/connector.js +246 -5
  205. package/dist/_pkgs/affine-model/elements/connector/end-label.d.ts +83 -0
  206. package/dist/_pkgs/affine-model/elements/connector/end-label.js +119 -0
  207. package/dist/_pkgs/affine-model/elements/connector/index.d.ts +1 -0
  208. package/dist/_pkgs/affine-model/elements/connector/index.js +1 -0
  209. package/dist/_pkgs/affine-model/elements/context-map/context-map.js +1 -1
  210. package/dist/_pkgs/affine-model/elements/core-domain/core-domain.d.ts +28 -0
  211. package/dist/_pkgs/affine-model/elements/core-domain/core-domain.js +129 -2
  212. package/dist/_pkgs/affine-model/elements/cynefin/cynefin.d.ts +8 -0
  213. package/dist/_pkgs/affine-model/elements/cynefin/cynefin.js +45 -2
  214. package/dist/_pkgs/affine-model/elements/edgy/board.js +1 -1
  215. package/dist/_pkgs/affine-model/elements/edgy/facets.js +1 -1
  216. package/dist/_pkgs/affine-model/elements/estuarine/estuarine.d.ts +6 -0
  217. package/dist/_pkgs/affine-model/elements/estuarine/estuarine.js +36 -2
  218. package/dist/_pkgs/affine-model/elements/event-storming/event-storming.d.ts +18 -7
  219. package/dist/_pkgs/affine-model/elements/event-storming/event-storming.js +23 -8
  220. package/dist/_pkgs/affine-model/elements/framework-background/background.d.ts +16 -0
  221. package/dist/_pkgs/affine-model/elements/framework-background/background.js +18 -0
  222. package/dist/_pkgs/affine-model/elements/highlighter/highlighter.js +1 -1
  223. package/dist/_pkgs/affine-model/elements/index.d.ts +8 -0
  224. package/dist/_pkgs/affine-model/elements/index.js +1 -0
  225. package/dist/_pkgs/affine-model/elements/shape/shape.js +1 -1
  226. package/dist/_pkgs/affine-model/elements/text/text.js +1 -1
  227. package/dist/_pkgs/affine-model/elements/uml/band.d.ts +39 -0
  228. package/dist/_pkgs/affine-model/elements/uml/band.js +31 -0
  229. package/dist/_pkgs/affine-model/elements/uml/diagram.d.ts +158 -0
  230. package/dist/_pkgs/affine-model/elements/uml/diagram.js +229 -0
  231. package/dist/_pkgs/affine-model/elements/uml/fragment.d.ts +161 -0
  232. package/dist/_pkgs/affine-model/elements/uml/fragment.js +205 -0
  233. package/dist/_pkgs/affine-model/elements/uml/index.d.ts +8 -0
  234. package/dist/_pkgs/affine-model/elements/uml/index.js +8 -0
  235. package/dist/_pkgs/affine-model/elements/uml/lifeline.d.ts +77 -0
  236. package/dist/_pkgs/affine-model/elements/uml/lifeline.js +89 -0
  237. package/dist/_pkgs/affine-model/elements/uml/node.d.ts +142 -0
  238. package/dist/_pkgs/affine-model/elements/uml/node.js +190 -0
  239. package/dist/_pkgs/affine-model/elements/uml/partition.d.ts +106 -0
  240. package/dist/_pkgs/affine-model/elements/uml/partition.js +172 -0
  241. package/dist/_pkgs/affine-model/elements/uml/region.d.ts +75 -0
  242. package/dist/_pkgs/affine-model/elements/uml/region.js +150 -0
  243. package/dist/_pkgs/affine-model/elements/uml/subject.d.ts +37 -0
  244. package/dist/_pkgs/affine-model/elements/uml/subject.js +108 -0
  245. package/dist/_pkgs/affine-model/elements/wardley/wardley.js +1 -1
  246. package/dist/_pkgs/affine-shared/services/embed-iframe/embed-iframe-config.d.ts +1 -0
  247. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +18 -0
  248. package/dist/_pkgs/affine-shared/services/font-loader/config.js +82 -50
  249. package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.js +1 -9
  250. package/dist/_pkgs/affine-shared/services/telemetry-service/document-damage-watcher.d.ts +53 -0
  251. package/dist/_pkgs/affine-shared/services/telemetry-service/document-damage-watcher.js +95 -0
  252. package/dist/_pkgs/affine-shared/services/telemetry-service/index.d.ts +1 -0
  253. package/dist/_pkgs/affine-shared/services/telemetry-service/index.js +1 -0
  254. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +26 -1
  255. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  256. package/dist/_pkgs/affine-shared/services/theme-service.d.ts +19 -0
  257. package/dist/_pkgs/affine-shared/services/theme-service.js +24 -0
  258. package/dist/_pkgs/affine-shared/services/toolbar-service/command-action.d.ts +34 -0
  259. package/dist/_pkgs/affine-shared/services/toolbar-service/command-action.js +63 -0
  260. package/dist/_pkgs/affine-shared/services/toolbar-service/index.d.ts +1 -0
  261. package/dist/_pkgs/affine-shared/services/toolbar-service/index.js +1 -0
  262. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +97 -7
  263. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +178 -7
  264. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  265. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  266. package/dist/_pkgs/affine-shared/styles/motion.d.ts +14 -0
  267. package/dist/_pkgs/affine-shared/styles/motion.js +38 -0
  268. package/dist/_pkgs/affine-shared/utils/event.d.ts +10 -0
  269. package/dist/_pkgs/affine-shared/utils/event.js +20 -0
  270. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +16 -0
  271. package/dist/_pkgs/affine-shared/utils/file/filesys.js +25 -0
  272. package/dist/_pkgs/affine-shared/utils/index.d.ts +1 -0
  273. package/dist/_pkgs/affine-shared/utils/index.js +1 -0
  274. package/dist/_pkgs/affine-shared/utils/link-preview-refresh.d.ts +12 -0
  275. package/dist/_pkgs/affine-shared/utils/link-preview-refresh.js +13 -0
  276. package/dist/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.js +2 -2
  277. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +5 -1
  278. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.d.ts +12 -4
  279. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +27 -4
  280. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/types.d.ts +15 -0
  281. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.d.ts +1 -1
  282. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.js +7 -2
  283. package/dist/_pkgs/affine-widget-edgeless-toolbar/create-popper.js +13 -0
  284. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +2 -0
  285. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +2 -0
  286. package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.d.ts +80 -0
  287. package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.js +270 -81
  288. package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/senior-menu-selection.d.ts +15 -0
  289. package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/senior-menu-selection.js +15 -0
  290. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.d.ts +18 -0
  291. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.js +52 -6
  292. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-weight-and-style-panel.js +8 -1
  293. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-ghost-overlay.d.ts +42 -0
  294. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-ghost-overlay.js +100 -0
  295. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-placement-tool.d.ts +100 -0
  296. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-placement-tool.js +274 -0
  297. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/index.d.ts +3 -0
  298. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/index.js +3 -0
  299. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/translate-created.d.ts +25 -0
  300. package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/translate-created.js +67 -0
  301. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +6 -0
  302. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +10 -0
  303. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +5 -0
  304. package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +2 -1
  305. package/dist/_pkgs/affine-widget-slash-menu/translations.d.ts +16 -0
  306. package/dist/_pkgs/affine-widget-slash-menu/translations.js +23 -1
  307. package/dist/_pkgs/affine-widget-toolbar/utils.js +57 -14
  308. package/dist/_pkgs/data-view/core/detail/field.js +2 -1
  309. package/dist/_pkgs/data-view/core/filter/literal/define.js +3 -1
  310. package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +1 -1
  311. package/dist/_pkgs/data-view/property-presets/checkbox/cell-renderer.js +8 -2
  312. package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +1 -1
  313. package/dist/_pkgs/data-view/view-presets/kanban/pc/controller/drag.js +2 -1
  314. package/dist/_pkgs/data-view/view-presets/table/pc/controller/drag.js +2 -1
  315. package/dist/_pkgs/data-view/view-presets/table/pc/controller/selection.js +1 -1
  316. package/dist/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.js +2 -1
  317. package/dist/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.js +3 -1
  318. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.js +2 -1
  319. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.js +1 -1
  320. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.js +2 -1
  321. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.js +3 -1
  322. package/dist/_pkgs/global/gfx/xywh.js +7 -0
  323. package/dist/_pkgs/std/extension/command-registry.d.ts +158 -1
  324. package/dist/_pkgs/std/extension/command-registry.js +22 -0
  325. package/dist/_pkgs/std/gfx/index.d.ts +1 -1
  326. package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.d.ts +12 -0
  327. package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.js +20 -1
  328. package/dist/_pkgs/std/gfx/interactivity/manager.d.ts +10 -0
  329. package/dist/_pkgs/std/gfx/interactivity/manager.js +12 -0
  330. package/dist/_pkgs/std/gfx/model/surface/element-model.js +12 -7
  331. package/dist/_pkgs/std/gfx/model/surface/role.d.ts +10 -5
  332. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +56 -0
  333. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +84 -3
  334. package/dist/_pkgs/std/gfx/view/view.d.ts +11 -2
  335. package/dist/_pkgs/std/gfx/view/view.js +16 -2
  336. package/dist/commands.d.ts +6 -0
  337. package/dist/commands.js +10 -2
  338. package/dist/frameworks.d.ts +9 -0
  339. package/dist/frameworks.js +19 -0
  340. package/dist/translations.js +21 -0
  341. package/package.json +13 -4
  342. package/dist/_pkgs/affine-gfx-group/group-watcher.d.ts +0 -1
  343. package/dist/_pkgs/affine-gfx-group/group-watcher.js +0 -20
@@ -0,0 +1,155 @@
1
+ /**
2
+ * `doc.copyLink` — put the current document's URL on the clipboard, anchored on
3
+ * whatever is selected.
4
+ *
5
+ * The library does not know what a document's address looks like: routing is
6
+ * the host's, and the seam for it — `GenerateDocUrlProvider` — has shipped
7
+ * since AFFiNE with **no consumer at all** on either side. This command is the
8
+ * consumer, and the counterpart of the paste path that already turns a host URL
9
+ * back into an inline reference (`ParseDocUrlProvider`, read by
10
+ * `adapters/middlewares/paste.ts`). Copy here, paste there, and the round trip
11
+ * closes without the library ever spelling a URL.
12
+ *
13
+ * It lives in the registry rather than in the host chrome because ADR 0008
14
+ * makes a command the single source for its keystroke, its palette entry and
15
+ * its Settings › Shortcuts row. A host-side button would be reachable from none
16
+ * of the three, and would not fire while the focus is inside the editor.
17
+ *
18
+ * Default chord `Mod-Alt-l` (product decision, PR #401 — the gesture users
19
+ * already know from Notion). NOT `Mod-l`: `Ctrl+L` / `Cmd+L` is the browser's
20
+ * address bar and never reaches the page, so a default on it would silently do
21
+ * nothing on the web. `scope: 'global'` so it fires in page mode and on the
22
+ * canvas alike.
23
+ *
24
+ * **`navigator.clipboard` can be absent, not merely refusing.** The Clipboard
25
+ * API is a secure-context feature: over plain `http://` on anything but
26
+ * `localhost`, and in a cross-origin iframe with no `clipboard-write`
27
+ * permission, the `clipboard` property is `undefined` altogether — so reaching
28
+ * for `writeText` throws a synchronous `TypeError` out of `run` rather than
29
+ * returning a promise to reject. That is checked before anything is announced:
30
+ * no copy, no toast, no telemetry, one `console.error` saying why. Announcing a
31
+ * copy that never happened is the one failure mode worse than doing nothing.
32
+ *
33
+ * A clipboard that EXISTS and then rejects (permission denied at the moment of
34
+ * writing) is a different case and is left as it is: the promise is caught, and
35
+ * the toast has already been shown — the same optimistic behaviour the inline
36
+ * link toolbar has always had, kept deliberately so the two copy-a-link
37
+ * gestures do not answer differently.
38
+ */
39
+ import { DocModeProvider, GenerateDocUrlProvider, NotificationProvider, TOAST_LINK_COPIED, TelemetryProvider, translateKey, } from '../../affine-shared/services/index.js';
40
+ import { BlockSelection, SurfaceSelection, } from '../../std/index.js';
41
+ /**
42
+ * Where the link points INSIDE the document, read off the live selection.
43
+ *
44
+ * `mode` is not decoration: the reader of these params
45
+ * (`extractSearchParams`, `adapters/middlewares/paste.ts`) only looks at
46
+ * `blockIds` / `elementIds` once it has found a valid `mode` in the query
47
+ * string, so an anchor emitted without one is dropped on the way back in. When
48
+ * no `DocModeProvider` is registered the anchor is therefore left out entirely
49
+ * rather than written in a form nothing can read — the link still opens the
50
+ * document, which is the honest degradation.
51
+ *
52
+ * Canvas before prose: a surface selection and a block selection can coexist in
53
+ * the store (selecting a note on the canvas leaves the page's own selection
54
+ * behind), and on the canvas the element IS what the user pointed at.
55
+ *
56
+ * A caret is deliberately NOT an anchor. `TextSelection` exists the whole time
57
+ * somebody is typing, so reading it would mean every copy silently points at a
58
+ * paragraph instead of the document — the opposite of what an unsolicited
59
+ * keystroke should do.
60
+ */
61
+ function anchorOf(std) {
62
+ const mode = std.getOptional(DocModeProvider)?.getEditorMode();
63
+ if (!mode)
64
+ return undefined;
65
+ const elementIds = std.selection
66
+ .filter(SurfaceSelection)
67
+ .flatMap(selection => selection.elements);
68
+ if (elementIds.length)
69
+ return { mode, elementIds };
70
+ const blockIds = std.selection
71
+ .filter(BlockSelection)
72
+ .map(selection => selection.blockId);
73
+ if (blockIds.length)
74
+ return { mode, blockIds };
75
+ return { mode };
76
+ }
77
+ /**
78
+ * The seam, or nothing. Read through `getOptional` like every other host seam,
79
+ * and reported as UNAVAILABLE rather than as a silent no-op: a palette entry
80
+ * that copies nothing and a shortcut that does nothing are both worse than an
81
+ * entry that is not there (`docs/integrate/04-host-seams.md`, step 2 of "How to
82
+ * add a seam").
83
+ */
84
+ const canCopyDocLink = (std) => !!std.getOptional(GenerateDocUrlProvider);
85
+ const copyDocLink = {
86
+ id: 'doc.copyLink',
87
+ owner: 'core',
88
+ kind: 'action',
89
+ // `com.labre.command.*` like the other keyless-by-intent core commands, not
90
+ // `com.labre.keyboardShortcuts.*`: this one is a capability that happens to
91
+ // carry a default chord, and the shortcut namespace would file it as a
92
+ // keymap row for a translator.
93
+ labelKey: 'com.labre.command.doc.copy-link',
94
+ labelFallback: 'Copy document link',
95
+ descriptionKey: 'com.labre.command.doc.copy-link.description',
96
+ descriptionFallback: 'Copy a link to this document, anchored on the selection, so it can be ' +
97
+ 'pasted into a text as a reference.',
98
+ keywords: ['link', 'url', 'share', 'reference'],
99
+ surfaces: ['palette', 'agent'],
100
+ scope: 'global',
101
+ defaultKeys: { mac: ['Mod-Alt-l'], other: ['Mod-Alt-l'] },
102
+ // Copying an address is legitimate in a read-only document, so nothing here
103
+ // is gated on `editable`; the only precondition is the seam, which is not
104
+ // expressible in the serializable union and therefore rides on `when`.
105
+ availability: 'always',
106
+ when: canCopyDocLink,
107
+ run: (std, invocation) => {
108
+ // The load-bearing half of the gate: `runCommand` consults neither
109
+ // `availability` nor `when`, so the palette and the agent reach `run`
110
+ // directly — the same arbitration `tag.set` records.
111
+ const generator = std.getOptional(GenerateDocUrlProvider);
112
+ if (!generator)
113
+ return;
114
+ const params = anchorOf(std);
115
+ const url = generator.generateDocUrl(std.store.id, params);
116
+ // A host may decline — an unsaved document, one it does not route. Nothing
117
+ // is copied and nothing is announced.
118
+ if (!url)
119
+ return;
120
+ // Not a promise rejection: outside a secure context the property itself is
121
+ // `undefined`, so this would be a synchronous `TypeError` thrown out of
122
+ // `run` — and `runCommand` only catches what a returned promise rejects
123
+ // with, so it would surface as an unhandled error taking the keystroke
124
+ // down with it. Nothing announced, one line saying why.
125
+ if (!navigator.clipboard) {
126
+ console.error('doc.copyLink: no clipboard API — a secure context (https, or ' +
127
+ 'localhost) is required, and an iframe needs `clipboard-write`.');
128
+ return;
129
+ }
130
+ navigator.clipboard.writeText(url).catch(console.error);
131
+ std
132
+ .getOptional(NotificationProvider)
133
+ ?.toast(translateKey(std, ...TOAST_LINK_COPIED));
134
+ // Self-emitted rather than declared through `CommandDescriptor.telemetry`:
135
+ // that field routes the bottleneck's reporter onto the three framework
136
+ // CREATION events and requires a `FrameworkId`, and this command creates
137
+ // nothing and belongs to no framework. `CopiedLink` is the event the two
138
+ // other copy-a-link sites already emit (the inline link toolbar, the
139
+ // iframe embed toolbar); reusing it keeps "links copied" one series.
140
+ // Ids never cross: the document id and the anchored ids stay here.
141
+ std.getOptional(TelemetryProvider)?.track('CopiedLink', {
142
+ page: params?.mode === 'edgeless' ? 'whiteboard editor' : 'doc editor',
143
+ segment: 'editor',
144
+ module: invocation.surface,
145
+ control: invocation.source,
146
+ type: params?.elementIds?.length
147
+ ? 'element'
148
+ : params?.blockIds?.length
149
+ ? 'block'
150
+ : 'document',
151
+ result: 'success',
152
+ });
153
+ },
154
+ };
155
+ export const copyLinkCommands = [copyDocLink];
@@ -8,7 +8,7 @@
8
8
  * makes the command usable by the agent surface with no UI at all.
9
9
  */
10
10
  import { TelemetryProvider } from '../../affine-shared/services/index.js';
11
- import { FRAMEWORK_IDS, } from '../../std/index.js';
11
+ import { frameworkOfRole, } from '../../std/index.js';
12
12
  import { GfxControllerIdentifier, GfxPrimitiveElementModel, } from '../../std/gfx/index.js';
13
13
  import { z } from 'zod';
14
14
  const PIVOT_DOC_ID = 'pivotDocId';
@@ -58,13 +58,6 @@ function pivotTargets(std, elementIds) {
58
58
  * which is bad in a different way.
59
59
  */
60
60
  const isBindable = (std) => !std.store.readonly;
61
- /** `'wardley:component'` → `'wardley'`, when that names a real framework. */
62
- function frameworkOfRole(role) {
63
- const namespace = role?.split(':')[0];
64
- return FRAMEWORK_IDS.includes(namespace ?? '')
65
- ? namespace
66
- : undefined;
67
- }
68
61
  /** The single value shared by every target, or `undefined` if they disagree. */
69
62
  function unanimous(values) {
70
63
  const distinct = new Set(values);
@@ -14,7 +14,7 @@
14
14
  * tags with no `pivotDocId`, and a `pivotDocId` with no `role`.
15
15
  */
16
16
  import { TelemetryProvider } from '../../affine-shared/services/index.js';
17
- import { FRAMEWORK_IDS, } from '../../std/index.js';
17
+ import { frameworkOfRole, } from '../../std/index.js';
18
18
  import { GfxControllerIdentifier, GfxPrimitiveElementModel, setElementTag, } from '../../std/gfx/index.js';
19
19
  import { z } from 'zod';
20
20
  /**
@@ -69,13 +69,6 @@ function tagTargets(std, elementIds) {
69
69
  * guard of their own.
70
70
  */
71
71
  const isQualifiable = (std) => !std.store.readonly;
72
- /** `'wardley:component'` → `'wardley'`, when that names a real framework. */
73
- function frameworkOfRole(role) {
74
- const namespace = role?.split(':')[0];
75
- return FRAMEWORK_IDS.includes(namespace ?? '')
76
- ? namespace
77
- : undefined;
78
- }
79
72
  /** The single value shared by every target, or `undefined` if they disagree. */
80
73
  function unanimous(values) {
81
74
  const distinct = new Set(values);
@@ -18,6 +18,15 @@ export declare class EdgelessPageKeyboardManager extends PageKeyboardManager {
18
18
  toolbarLocked: import("rxjs").Subject<boolean>;
19
19
  };
20
20
  get std(): import("../../std/index.js").BlockStdScope;
21
+ /**
22
+ * The framework sub-menu the toolbar has open, when it has one open.
23
+ *
24
+ * Asked of the widget rather than of a service because the popover is not a
25
+ * tool: it is a transient element the toolbar parks in `activePopper`, and
26
+ * only the generic command menu answers to the keys below — a colour picker
27
+ * or a note sub-menu sitting in the same slot keeps its own behaviour.
28
+ */
29
+ private get _seniorMenu();
21
30
  constructor(rootComponent: EdgelessRootBlockComponent);
22
31
  private _bindToggleHand;
23
32
  private _delete;
@@ -14,6 +14,7 @@ import { TextTool } from '../../affine-gfx-text/index.js';
14
14
  import { ConnectorElementModel, EdgelessTextBlockModel, GroupElementModel, LayoutType, MindmapElementModel, NoteBlockModel, NoteDisplayMode, } from '../../affine-model/index.js';
15
15
  import { BLOCK_NAME_TEXT, EditPropsStore, TelemetryProvider, translateKey, } from '../../affine-shared/services/index.js';
16
16
  import { matchModels } from '../../affine-shared/utils/index.js';
17
+ import { cycleArmedArtefact, EDGELESS_TOOLBAR_WIDGET, EdgelessCommandMenu, } from '../../affine-widget-edgeless-toolbar/index.js';
17
18
  import { IS_MAC } from '../../global/env/index.js';
18
19
  import { Bound, getCommonBound } from '../../global/gfx/index.js';
19
20
  import { SurfaceSelection, TextSelection } from '../../std/index.js';
@@ -33,6 +34,23 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
33
34
  get std() {
34
35
  return this.rootComponent.std;
35
36
  }
37
+ /**
38
+ * The framework sub-menu the toolbar has open, when it has one open.
39
+ *
40
+ * Asked of the widget rather than of a service because the popover is not a
41
+ * tool: it is a transient element the toolbar parks in `activePopper`, and
42
+ * only the generic command menu answers to the keys below — a colour picker
43
+ * or a note sub-menu sitting in the same slot keeps its own behaviour.
44
+ */
45
+ get _seniorMenu() {
46
+ // A keystroke aimed at a canvas text editor belongs to that editor, open
47
+ // menu or not — the same condition the shape cycling below already has.
48
+ if (this.rootComponent.service.selection.editing)
49
+ return null;
50
+ const toolbar = this.rootComponent.widgetComponents[EDGELESS_TOOLBAR_WIDGET];
51
+ const element = toolbar?.activePopper?.element;
52
+ return element instanceof EdgelessCommandMenu ? element : null;
53
+ }
36
54
  constructor(rootComponent) {
37
55
  super(rootComponent);
38
56
  this.rootComponent = rootComponent;
@@ -157,8 +175,24 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
157
175
  .catch(console.error);
158
176
  },
159
177
  'Shift-s': () => {
178
+ // Over an open senior menu the very same keystroke steps backwards
179
+ // through the artefacts it offers — the shape tool's "previous
180
+ // variant", applied to the row a framework opened. With an artefact
181
+ // armed the menu walks the TOOL instead, so the ghost moves with the
182
+ // highlight.
183
+ const menu = this._seniorMenu;
184
+ if (menu) {
185
+ menu.cycle(-1);
186
+ return;
187
+ }
160
188
  if (this.rootComponent.service.locked)
161
189
  return;
190
+ // The same walk with no menu open: the framework's row is what the
191
+ // armed artefact belongs to, whether or not it is on screen.
192
+ if (!this.rootComponent.service.selection.editing &&
193
+ cycleArmedArtefact(rootComponent.gfx, -1)) {
194
+ return;
195
+ }
162
196
  const controller = rootComponent.gfx.tool.currentTool$.peek();
163
197
  if (this.rootComponent.service.selection.editing ||
164
198
  !(controller instanceof ShapeTool)) {
@@ -265,9 +299,22 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
265
299
  this._move('ArrowDown');
266
300
  },
267
301
  ArrowLeft: () => {
302
+ // Same highlight as Shift+S, spelled the way a row of buttons is
303
+ // normally walked. The guard also keeps the arrows from nudging the
304
+ // selection behind a menu the user is reading.
305
+ const menu = this._seniorMenu;
306
+ if (menu) {
307
+ menu.cycle(-1);
308
+ return;
309
+ }
268
310
  this._move('ArrowLeft');
269
311
  },
270
312
  ArrowRight: () => {
313
+ const menu = this._seniorMenu;
314
+ if (menu) {
315
+ menu.cycle(1);
316
+ return;
317
+ }
271
318
  this._move('ArrowRight');
272
319
  },
273
320
  'Shift-ArrowUp': () => {
@@ -283,6 +330,10 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
283
330
  this._move('ArrowRight', true);
284
331
  },
285
332
  Enter: () => {
333
+ // A highlighted sub-menu button consumes Enter; with nothing
334
+ // highlighted the menu takes nothing and the canvas keeps its own.
335
+ if (this._seniorMenu?.activate())
336
+ return;
286
337
  const { service } = rootComponent;
287
338
  const selection = service.selection;
288
339
  const elements = selection.selectedElements;
@@ -23,6 +23,28 @@ export declare class EdgelessRootBlockComponent extends BlockComponent<RootBlock
23
23
  private _initResizeEffect;
24
24
  private _initSlotEffects;
25
25
  private _initViewport;
26
+ /**
27
+ * A pinch (or ctrl+wheel) that the capture handler below has already turned
28
+ * into a canvas zoom. The dispatcher's own handler still receives the event
29
+ * when nothing swallowed it, and must not zoom a second time.
30
+ */
31
+ private readonly _pinchZoomed;
32
+ /**
33
+ * Ctrl+wheel and trackpad pinch zoom the CANVAS, never the browser page.
34
+ *
35
+ * What stops a browser from page-zooming is `preventDefault()`, and the only
36
+ * handler that calls it hangs off the event dispatcher — a bubble-phase
37
+ * listener on the editor host. Two kinds of overlay keep it from ever
38
+ * running: popups portalled out to `document.body` (the event never reaches
39
+ * the host), and in-host overlays that stop the wheel on purpose so they
40
+ * scroll instead of the board (the element toolbar, the validation bubble,
41
+ * the artefact catalogue…). Under either one the page zoomed.
42
+ *
43
+ * One capture-phase listener on `document` sees the gesture before all of
44
+ * them, and it is deliberately narrow: pinches only — a plain wheel still
45
+ * belongs to whatever is under the pointer — and only inside this editor.
46
+ */
47
+ private readonly _onDocumentPinch;
26
48
  private _initWheelEvent;
27
49
  bindHotKey(keymap: Record<string, UIEventHandler>, options?: {
28
50
  global?: boolean;
@@ -49,6 +49,7 @@ import { css, html } from 'lit';
49
49
  import { query } from 'lit/decorators.js';
50
50
  import { repeat } from 'lit/directives/repeat.js';
51
51
  import { EdgelessPageKeyboardManager } from './edgeless-keyboard.js';
52
+ import { pinchZoomAction } from './utils/pinch-zoom.js';
52
53
  import { isCanvasElement } from './utils/query.js';
53
54
  let EdgelessRootBlockComponent = (() => {
54
55
  let _classSuper = BlockComponent;
@@ -268,11 +269,20 @@ let EdgelessRootBlockComponent = (() => {
268
269
  });
269
270
  }
270
271
  _initWheelEvent() {
272
+ this._disposables.addFromEvent(document, 'wheel', this._onDocumentPinch, {
273
+ passive: false,
274
+ capture: true,
275
+ });
271
276
  this._disposables.add(this.std.event.add('wheel', ctx => {
272
277
  const config = this.std.getOptional(EditorSettingProvider)?.setting$;
273
278
  const state = ctx.get('defaultState');
274
279
  const e = state.event;
275
280
  const edgelessScrollZoom = config?.peek().edgelessScrollZoom ?? false;
281
+ // Already zoomed, on the way down: the default action is cancelled too.
282
+ if (this._pinchZoomed.has(e)) {
283
+ e.stopPropagation();
284
+ return;
285
+ }
276
286
  e.preventDefault();
277
287
  const { viewport } = this.gfx;
278
288
  if (viewport.locked)
@@ -436,6 +446,42 @@ let EdgelessRootBlockComponent = (() => {
436
446
  }, this);
437
447
  this._resizeObserver = null;
438
448
  this.keyboardManager = null;
449
+ /**
450
+ * A pinch (or ctrl+wheel) that the capture handler below has already turned
451
+ * into a canvas zoom. The dispatcher's own handler still receives the event
452
+ * when nothing swallowed it, and must not zoom a second time.
453
+ */
454
+ this._pinchZoomed = new WeakSet();
455
+ /**
456
+ * Ctrl+wheel and trackpad pinch zoom the CANVAS, never the browser page.
457
+ *
458
+ * What stops a browser from page-zooming is `preventDefault()`, and the only
459
+ * handler that calls it hangs off the event dispatcher — a bubble-phase
460
+ * listener on the editor host. Two kinds of overlay keep it from ever
461
+ * running: popups portalled out to `document.body` (the event never reaches
462
+ * the host), and in-host overlays that stop the wheel on purpose so they
463
+ * scroll instead of the board (the element toolbar, the validation bubble,
464
+ * the artefact catalogue…). Under either one the page zoomed.
465
+ *
466
+ * One capture-phase listener on `document` sees the gesture before all of
467
+ * them, and it is deliberately narrow: pinches only — a plain wheel still
468
+ * belongs to whatever is under the pointer — and only inside this editor.
469
+ */
470
+ this._onDocumentPinch = (e) => {
471
+ const action = pinchZoomAction(e, this.std.host);
472
+ if (action === 'ignore')
473
+ return;
474
+ e.preventDefault();
475
+ if (action === 'swallow')
476
+ return;
477
+ const { viewport } = this.gfx;
478
+ if (viewport.locked)
479
+ return;
480
+ const rect = this.getBoundingClientRect();
481
+ const [baseX, baseY] = viewport.toModelCoord(e.clientX - rect.x, e.clientY - rect.y);
482
+ viewport.setZoom(normalizeWheelDeltaY(e.deltaY, viewport.zoom), new Point(baseX, baseY), true);
483
+ this._pinchZoomed.add(e);
484
+ };
439
485
  this.#backgroundElm_accessor_storage = __runInitializers(this, _backgroundElm_initializers, null);
440
486
  this.#gfxViewportElm_accessor_storage = (__runInitializers(this, _backgroundElm_extraInitializers), __runInitializers(this, _gfxViewportElm_initializers, void 0));
441
487
  this.#mountElm_accessor_storage = (__runInitializers(this, _gfxViewportElm_extraInitializers), __runInitializers(this, _mountElm_initializers, null));
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The class `createSimplePortal` stamps on every portal root it appends to
3
+ * `document.body` — the only thing a popup rendered OUTSIDE the editor host
4
+ * still has in common with the editor that opened it.
5
+ */
6
+ export declare const PORTAL_CLASS = "blocksuite-portal";
7
+ /**
8
+ * What the edgeless board owes a wheel event seen on `document`, in capture:
9
+ *
10
+ * - `ignore`: not a pinch, or not this editor's business — the page keeps it.
11
+ * - `swallow`: a pinch inside a popup the editor portalled out to
12
+ * `document.body`. The browser must not page-zoom, but the board must not
13
+ * move either: zooming under an anchored popup leaves it pointing at nothing.
14
+ * - `zoom`: a pinch inside the editor — the canvas zooms.
15
+ */
16
+ export type PinchZoomAction = 'ignore' | 'swallow' | 'zoom';
17
+ /**
18
+ * The whole decision, readable from the event and the host alone so it can be
19
+ * tested without a live editor.
20
+ */
21
+ export declare function pinchZoomAction(event: WheelEvent, host: EventTarget): PinchZoomAction;
@@ -0,0 +1,24 @@
1
+ import { isTouchPadPinchEvent } from '../../../affine-shared/utils/index.js';
2
+ /**
3
+ * The class `createSimplePortal` stamps on every portal root it appends to
4
+ * `document.body` — the only thing a popup rendered OUTSIDE the editor host
5
+ * still has in common with the editor that opened it.
6
+ */
7
+ export const PORTAL_CLASS = 'blocksuite-portal';
8
+ /**
9
+ * The whole decision, readable from the event and the host alone so it can be
10
+ * tested without a live editor.
11
+ */
12
+ export function pinchZoomAction(event, host) {
13
+ // A plain wheel still belongs to whatever is under the pointer: an
14
+ // overflowing toolbar, a bubble, a panel. Only the zoom gesture is claimed.
15
+ if (!isTouchPadPinchEvent(event))
16
+ return 'ignore';
17
+ const path = event.composedPath();
18
+ if (path.includes(host))
19
+ return 'zoom';
20
+ if (path.some(node => node instanceof Element && node.classList.contains(PORTAL_CLASS))) {
21
+ return 'swallow';
22
+ }
23
+ return 'ignore';
24
+ }
@@ -43,6 +43,14 @@ export function getCursorMode(edgelessTool) {
43
43
  return drawingCursor;
44
44
  case 'eraser':
45
45
  case 'shape':
46
+ // The polygon tool is armed long before it draws anything — the first
47
+ // click only places a corner — so the cursor is the only thing that says
48
+ // the next click lands on the canvas rather than selecting.
49
+ case 'polygon':
50
+ // An armed framework artefact: the ghost says WHAT lands, the crosshair
51
+ // says WHERE — and it is all there is for an artefact with nothing drawable
52
+ // to preview (a lone connector).
53
+ case 'artefact-placement':
46
54
  case 'connector':
47
55
  case 'frame':
48
56
  case 'affine:note':
@@ -1,5 +1,6 @@
1
1
  export * from './adapters/index.js';
2
2
  export * from './clipboard/index.js';
3
+ export * from './commands/copy-link-commands.js';
3
4
  export * from './commands/pivot-commands.js';
4
5
  export * from './commands/reading-commands.js';
5
6
  export * from './commands/tag-commands.js';
@@ -1,5 +1,6 @@
1
1
  export * from './adapters/index.js';
2
2
  export * from './clipboard/index.js';
3
+ export * from './commands/copy-link-commands.js';
3
4
  export * from './commands/pivot-commands.js';
4
5
  export * from './commands/reading-commands.js';
5
6
  export * from './commands/tag-commands.js';
@@ -1,20 +1,5 @@
1
+ import { isNativeFocusableTarget } from '../../affine-shared/utils/index.js';
1
2
  import { KeymapExtension } from '../../std/index.js';
2
- const NATIVE_FOCUSABLE_SELECTOR = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
3
- /**
4
- * The editor host swallows Tab and Shift-Tab so that indentation stays under
5
- * the control of the block-scoped handlers. That would however trap the focus
6
- * on the native controls the editor renders (the collapse button of headings
7
- * and lists, for instance), which then could neither be reached nor left with
8
- * the keyboard. When the event originates from such a control — and not from
9
- * editable text — the native tabbing behaviour is let through.
10
- */
11
- const isNativeFocusableTarget = (target) => {
12
- if (!(target instanceof Element))
13
- return false;
14
- if (target instanceof HTMLElement && target.isContentEditable)
15
- return false;
16
- return !!target.closest(NATIVE_FOCUSABLE_SELECTOR);
17
- };
18
3
  export const fallbackKeymap = KeymapExtension(() => {
19
4
  return {
20
5
  Tab: ctx => {
@@ -4,6 +4,7 @@ import { ToolbarModuleExtension, ViewportElementExtension, } from '../affine-sha
4
4
  import { BlockFlavourIdentifier, BlockViewExtension, FlavourExtension, CommandExtension, ShortcutKeymapExtension, } from '../std/index.js';
5
5
  import { literal } from 'lit/static-html.js';
6
6
  import { PageClipboard, ReadOnlyClipboard } from './clipboard/index.js';
7
+ import { copyLinkCommands } from './commands/copy-link-commands.js';
7
8
  import { pivotCommands } from './commands/pivot-commands.js';
8
9
  import { readingCommands } from './commands/reading-commands.js';
9
10
  import { tagCommands } from './commands/tag-commands.js';
@@ -70,6 +71,7 @@ export class RootViewExtension extends ViewExtensionProvider {
70
71
  ...pivotCommands,
71
72
  ...tagCommands,
72
73
  ...readingCommands,
74
+ ...copyLinkCommands,
73
75
  ]),
74
76
  ShortcutKeymapExtension('global'),
75
77
  ToolbarModuleExtension({
@@ -1,4 +1,4 @@
1
- import { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, TextElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel } from '../../affine-model/index.js';
1
+ import { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, TextElementModel, UmlDiagramElementModel, UmlFragmentElementModel, UmlNodeElementModel, UmlPartitionElementModel, UmlRegionElementModel, UmlSubjectElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel } from '../../affine-model/index.js';
2
2
  import { SurfaceElementModel } from './base.js';
3
3
  export declare const elementsCtorMap: {
4
4
  group: typeof GroupElementModel;
@@ -23,8 +23,14 @@ export declare const elementsCtorMap: {
23
23
  c4Node: typeof C4NodeElementModel;
24
24
  c4Board: typeof C4BoardElementModel;
25
25
  c4Boundary: typeof C4BoundaryElementModel;
26
+ umlNode: typeof UmlNodeElementModel;
27
+ umlDiagram: typeof UmlDiagramElementModel;
28
+ umlSubject: typeof UmlSubjectElementModel;
29
+ umlPartition: typeof UmlPartitionElementModel;
30
+ umlRegion: typeof UmlRegionElementModel;
31
+ umlFragment: typeof UmlFragmentElementModel;
26
32
  };
27
- export { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, SurfaceElementModel, TextElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel, };
33
+ export { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, SurfaceElementModel, TextElementModel, UmlDiagramElementModel, UmlFragmentElementModel, UmlNodeElementModel, UmlPartitionElementModel, UmlRegionElementModel, UmlSubjectElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel, };
28
34
  export declare enum CanvasElementType {
29
35
  BRUSH = "brush",
30
36
  CONNECTOR = "connector",
@@ -47,7 +53,13 @@ export declare enum CanvasElementType {
47
53
  BPMNPOOL = "bpmnPool",
48
54
  C4NODE = "c4Node",
49
55
  C4BOARD = "c4Board",
50
- C4BOUNDARY = "c4Boundary"
56
+ C4BOUNDARY = "c4Boundary",
57
+ UMLNODE = "umlNode",
58
+ UMLDIAGRAM = "umlDiagram",
59
+ UMLSUBJECT = "umlSubject",
60
+ UMLPARTITION = "umlPartition",
61
+ UMLREGION = "umlRegion",
62
+ UMLFRAGMENT = "umlFragment"
51
63
  }
52
64
  export type ElementModelMap = {
53
65
  ['shape']: ShapeElementModel;
@@ -72,5 +84,11 @@ export type ElementModelMap = {
72
84
  ['c4Node']: C4NodeElementModel;
73
85
  ['c4Board']: C4BoardElementModel;
74
86
  ['c4Boundary']: C4BoundaryElementModel;
87
+ ['umlNode']: UmlNodeElementModel;
88
+ ['umlDiagram']: UmlDiagramElementModel;
89
+ ['umlSubject']: UmlSubjectElementModel;
90
+ ['umlPartition']: UmlPartitionElementModel;
91
+ ['umlRegion']: UmlRegionElementModel;
92
+ ['umlFragment']: UmlFragmentElementModel;
75
93
  };
76
94
  export declare function isCanvasElementType(type: string): type is CanvasElementType;
@@ -1,4 +1,4 @@
1
- import { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, TextElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel, } from '../../affine-model/index.js';
1
+ import { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, TextElementModel, UmlDiagramElementModel, UmlFragmentElementModel, UmlNodeElementModel, UmlPartitionElementModel, UmlRegionElementModel, UmlSubjectElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel, } from '../../affine-model/index.js';
2
2
  import { SurfaceElementModel } from './base.js';
3
3
  export const elementsCtorMap = {
4
4
  group: GroupElementModel,
@@ -23,8 +23,14 @@ export const elementsCtorMap = {
23
23
  c4Node: C4NodeElementModel,
24
24
  c4Board: C4BoardElementModel,
25
25
  c4Boundary: C4BoundaryElementModel,
26
+ umlNode: UmlNodeElementModel,
27
+ umlDiagram: UmlDiagramElementModel,
28
+ umlSubject: UmlSubjectElementModel,
29
+ umlPartition: UmlPartitionElementModel,
30
+ umlRegion: UmlRegionElementModel,
31
+ umlFragment: UmlFragmentElementModel,
26
32
  };
27
- export { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, SurfaceElementModel, TextElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel, };
33
+ export { BpmnNodeElementModel, BpmnPoolElementModel, BrushElementModel, C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, ContextMapBoardElementModel, CoreDomainChartElementModel, CynefinElementModel, EdgyBoardElementModel, EdgyFacetsElementModel, EdgyNodeElementModel, EstuarineElementModel, EventStormingBoardElementModel, GroupElementModel, HighlighterElementModel, MindmapElementModel, ShapeElementModel, SurfaceElementModel, TextElementModel, UmlDiagramElementModel, UmlFragmentElementModel, UmlNodeElementModel, UmlPartitionElementModel, UmlRegionElementModel, UmlSubjectElementModel, WardleyBackgroundElementModel, WardleyNodeElementModel, };
28
34
  export var CanvasElementType;
29
35
  (function (CanvasElementType) {
30
36
  CanvasElementType["BRUSH"] = "brush";
@@ -49,6 +55,12 @@ export var CanvasElementType;
49
55
  CanvasElementType["C4NODE"] = "c4Node";
50
56
  CanvasElementType["C4BOARD"] = "c4Board";
51
57
  CanvasElementType["C4BOUNDARY"] = "c4Boundary";
58
+ CanvasElementType["UMLNODE"] = "umlNode";
59
+ CanvasElementType["UMLDIAGRAM"] = "umlDiagram";
60
+ CanvasElementType["UMLSUBJECT"] = "umlSubject";
61
+ CanvasElementType["UMLPARTITION"] = "umlPartition";
62
+ CanvasElementType["UMLREGION"] = "umlRegion";
63
+ CanvasElementType["UMLFRAGMENT"] = "umlFragment";
52
64
  })(CanvasElementType || (CanvasElementType = {}));
53
65
  export function isCanvasElementType(type) {
54
66
  return type.toLocaleUpperCase() in CanvasElementType;
@@ -0,0 +1,23 @@
1
+ import { FrameworkBackgroundElementModel } from '../../../affine-model/index.js';
2
+ import type { AnyCommandDescriptor, BlockStdScope } from '../../../std/index.js';
3
+ /**
4
+ * The framework boards in the current canvas selection.
5
+ *
6
+ * `FrameworkBackgroundElementModel` is the whole test, and that is the point of
7
+ * this command: eleven board kinds today — a Wardley map, a BPMN pool, a C4
8
+ * board and its boundaries, the three DDD boards, Cynefin, Estuarine, the two
9
+ * EDGY ones — and whatever a framework adds next, because a board IS the class
10
+ * and nothing about SVG is per framework (ADR 0025).
11
+ */
12
+ export declare function selectedBoards(std: BlockStdScope): FrameworkBackgroundElementModel[];
13
+ /**
14
+ * Render the selected board and hand it to the browser.
15
+ *
16
+ * ponytail: ONE board per click, the first of the selection. Browsers throttle
17
+ * (and Safari silently drops) programmatic downloads fired in a burst, so a
18
+ * selection of three boards would yield one file, two files or three depending
19
+ * on the browser — a result nobody can read off the gesture. One board, one
20
+ * file, every time.
21
+ */
22
+ export declare function exportBoardSvg(std: BlockStdScope): void;
23
+ export declare const exportSvgCommands: AnyCommandDescriptor[];