@formicoidea/labre-core 0.42.0 → 0.45.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 (367) hide show
  1. package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
  2. package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
  3. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
  4. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
  5. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
  6. package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
  7. package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
  8. package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
  9. package/dist/_pkgs/affine-block-callout/translations.js +4 -2
  10. package/dist/_pkgs/affine-block-callout/view.js +3 -0
  11. package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
  12. package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
  13. package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
  14. package/dist/_pkgs/affine-block-code/code-block.js +11 -2
  15. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
  16. package/dist/_pkgs/affine-block-data-view/configs/tooltips.js +1 -1
  17. package/dist/_pkgs/affine-block-database/configs/tooltips.js +1 -1
  18. package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +4 -2
  19. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  20. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  21. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  22. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  23. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.d.ts +39 -0
  24. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.js +39 -0
  25. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  26. package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +2 -0
  27. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.d.ts +14 -1
  28. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.js +21 -2
  29. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  30. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.d.ts +0 -2
  31. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +2 -5
  32. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +1 -1
  33. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +14 -6
  34. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.d.ts +16 -0
  35. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.js +17 -1
  36. package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +2 -0
  37. package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +2 -0
  38. package/dist/_pkgs/affine-block-embed/index.d.ts +1 -0
  39. package/dist/_pkgs/affine-block-embed/index.js +1 -0
  40. package/dist/_pkgs/affine-block-embed/translations.d.ts +8 -0
  41. package/dist/_pkgs/affine-block-embed/translations.js +28 -0
  42. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  43. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +4 -2
  44. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  45. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  46. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +2 -2
  47. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
  48. package/dist/_pkgs/affine-block-frame/frame-manager.js +53 -19
  49. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  50. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  51. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  52. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  53. package/dist/_pkgs/affine-block-list/utils/get-list-icon.js +3 -1
  54. package/dist/_pkgs/affine-block-note/configs/tooltips.js +1 -1
  55. package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
  56. package/dist/_pkgs/affine-block-note/translations.js +0 -5
  57. package/dist/_pkgs/affine-block-root/adapters/html.js +2 -2
  58. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.d.ts +2 -0
  59. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +155 -0
  60. package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
  61. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  62. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  63. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  64. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  65. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  66. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  67. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  68. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  69. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  70. package/dist/_pkgs/affine-block-root/index.js +1 -0
  71. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  72. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  73. package/dist/_pkgs/affine-block-root/view.js +2 -0
  74. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  75. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  76. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  77. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  78. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  85. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  86. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  87. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  88. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  89. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  90. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  93. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  94. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  96. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  97. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  98. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  102. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +13 -1
  103. package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +8 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/legend.js +59 -3
  105. package/dist/_pkgs/affine-block-surface/extensions/morph-toolbar.js +4 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  107. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  108. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  109. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  110. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
  111. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
  112. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
  113. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
  114. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  115. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  116. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  117. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  118. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +3 -0
  119. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +23 -0
  120. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  121. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +98 -19
  122. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  123. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  124. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  125. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  126. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  127. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  128. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  129. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  130. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  131. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  132. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  133. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  134. package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +1 -1
  135. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  136. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  137. package/dist/_pkgs/affine-block-surface/framework-background/fit.d.ts +36 -0
  138. package/dist/_pkgs/affine-block-surface/framework-background/fit.js +30 -0
  139. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +1 -0
  140. package/dist/_pkgs/affine-block-surface/framework-background/index.js +1 -0
  141. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  142. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  143. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  144. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  145. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  146. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +2 -7
  147. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  148. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  149. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  150. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  151. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  152. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  153. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  154. package/dist/_pkgs/affine-block-surface-ref/configs/tooltips.js +2 -2
  155. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  156. package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +5 -0
  157. package/dist/_pkgs/affine-components/color-picker/styles.js +1 -1
  158. package/dist/_pkgs/affine-components/context-menu/button.js +17 -1
  159. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  160. package/dist/_pkgs/affine-components/icons/ai.js +3 -3
  161. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  162. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  163. package/dist/_pkgs/affine-components/icons/list.js +7 -1
  164. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  165. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  166. package/dist/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.js +6 -1
  167. package/dist/_pkgs/affine-components/toolbar/index.d.ts +1 -1
  168. package/dist/_pkgs/affine-components/toolbar/index.js +1 -1
  169. package/dist/_pkgs/affine-components/toolbar/menu-button.d.ts +7 -0
  170. package/dist/_pkgs/affine-components/toolbar/menu-button.js +30 -0
  171. package/dist/_pkgs/affine-components/toolbar/picker-menu.d.ts +16 -1
  172. package/dist/_pkgs/affine-components/toolbar/picker-menu.js +2 -2
  173. package/dist/_pkgs/affine-components/toolbar/toolbar.d.ts +1 -0
  174. package/dist/_pkgs/affine-components/toolbar/toolbar.js +67 -0
  175. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  176. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.js +1 -1
  177. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +3 -3
  178. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  179. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  180. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  181. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  182. package/dist/_pkgs/affine-gfx-brush/toolbar/components/eraser/icons.js +1 -1
  183. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +11 -2
  184. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +11 -2
  185. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  186. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  187. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +6 -4
  188. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +24 -8
  189. package/dist/_pkgs/affine-gfx-connector/translations.d.ts +3 -0
  190. package/dist/_pkgs/affine-gfx-connector/translations.js +23 -0
  191. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  192. package/dist/_pkgs/affine-gfx-mindmap/indicator-overlay/index.js +6 -2
  193. package/dist/_pkgs/affine-gfx-mindmap/toolbar/config.js +4 -2
  194. package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +6 -0
  195. package/dist/_pkgs/affine-gfx-mindmap/translations.js +10 -0
  196. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  197. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  198. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +5 -3
  199. package/dist/_pkgs/affine-gfx-shape/translations.d.ts +7 -0
  200. package/dist/_pkgs/affine-gfx-shape/translations.js +11 -0
  201. package/dist/_pkgs/affine-gfx-template/builtin/other.js +13 -7
  202. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  203. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  204. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  205. package/dist/_pkgs/affine-gfx-template/toolbar/template-loading.js +1 -1
  206. package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
  207. package/dist/_pkgs/affine-gfx-template/translations.js +38 -0
  208. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +5 -3
  209. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  210. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  211. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  212. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  213. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +56 -3
  214. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  215. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  216. package/dist/_pkgs/affine-gfx-text/translations.d.ts +8 -0
  217. package/dist/_pkgs/affine-gfx-text/translations.js +12 -0
  218. package/dist/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.js +2 -1
  219. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  220. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  221. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  222. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  223. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  224. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  225. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  226. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  227. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  228. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  229. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  230. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  231. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  232. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  233. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  234. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  235. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  236. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  237. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  238. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  239. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  240. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  241. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  242. package/dist/_pkgs/affine-model/consts/text.d.ts +41 -2
  243. package/dist/_pkgs/affine-model/consts/text.js +50 -1
  244. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  245. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  246. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  247. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  248. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  249. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  250. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  251. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  252. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  253. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  254. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  255. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  256. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  257. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  258. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
  259. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  260. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  261. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  262. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  263. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +13 -2
  264. package/dist/_pkgs/affine-shared/services/font-loader/config.js +43 -54
  265. package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
  266. package/dist/_pkgs/affine-shared/services/index.js +3 -0
  267. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  268. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  269. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  270. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  271. package/dist/_pkgs/affine-shared/services/theme-service.d.ts +19 -0
  272. package/dist/_pkgs/affine-shared/services/theme-service.js +24 -0
  273. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +25 -0
  274. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +90 -0
  275. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  276. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  277. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  278. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  279. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  280. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  281. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  282. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  283. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  284. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  285. package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
  286. package/dist/_pkgs/affine-shared/utils/index.js +2 -0
  287. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  288. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  289. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  290. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  291. package/dist/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.js +2 -2
  292. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +15 -4
  293. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  294. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/types.d.ts +15 -0
  295. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.d.ts +1 -1
  296. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.js +7 -2
  297. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  298. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  299. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  300. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  301. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.d.ts +18 -0
  302. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.js +52 -6
  303. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
  304. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
  305. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  306. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  307. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  308. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  309. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  310. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  311. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
  312. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
  313. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +58 -0
  314. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +171 -1
  315. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  316. package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +2 -1
  317. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  318. package/dist/_pkgs/affine-widget-slash-menu/translations.d.ts +16 -0
  319. package/dist/_pkgs/affine-widget-slash-menu/translations.js +23 -1
  320. package/dist/_pkgs/affine-widget-toolbar/utils.js +57 -14
  321. package/dist/_pkgs/data-view/core/detail/field.js +2 -1
  322. package/dist/_pkgs/data-view/core/filter/literal/define.js +3 -1
  323. package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +1 -1
  324. package/dist/_pkgs/data-view/property-presets/checkbox/cell-renderer.js +8 -2
  325. package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +1 -1
  326. package/dist/_pkgs/data-view/view-presets/kanban/pc/controller/drag.js +2 -1
  327. package/dist/_pkgs/data-view/view-presets/table/pc/controller/drag.js +2 -1
  328. package/dist/_pkgs/data-view/view-presets/table/pc/controller/selection.js +1 -1
  329. package/dist/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.js +2 -1
  330. package/dist/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.js +3 -1
  331. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.js +2 -1
  332. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.js +1 -1
  333. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.js +2 -1
  334. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.js +3 -1
  335. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  336. package/dist/_pkgs/std/gfx/controller.js +22 -2
  337. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  338. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  339. package/dist/_pkgs/std/gfx/index.js +3 -1
  340. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  341. package/dist/_pkgs/std/gfx/layer.js +73 -5
  342. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  343. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  344. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  345. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  346. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  347. package/dist/_pkgs/std/gfx/model/surface/role.d.ts +10 -5
  348. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  349. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  350. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  351. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  352. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  353. package/dist/_pkgs/std/utils/layer.js +64 -13
  354. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  355. package/dist/commands.js +6 -2
  356. package/dist/translations.js +15 -6
  357. package/package.json +13 -2
  358. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  359. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  360. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  361. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  362. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  363. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  364. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  365. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  366. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  367. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -0,0 +1,248 @@
1
+ import { FrameBlockModel, GroupElementModel, MindmapElementModel, } from '../../../affine-model/index.js';
2
+ import { compareLayer, GfxBlockElementModel, GfxControllerIdentifier, GfxPrimitiveElementModel, isStoredHiddenForEveryone, } from '../../../std/gfx/index.js';
3
+ import { generateKeyBetween } from 'fractional-indexing';
4
+ import * as Y from 'yjs';
5
+ /**
6
+ * The selection pane's writes (ADR 0031, stage 2). Every one of them:
7
+ *
8
+ * - refuses on a read-only document before reading anything else;
9
+ * - writes nothing when nothing would change — an unchanged write is an empty
10
+ * undo step, and an undo that "does nothing" reads as a broken undo;
11
+ * - takes ONE `captureSync()` first, so one gesture in the pane is one undo
12
+ * step, whatever it touched;
13
+ * - writes through `gfx.updateElement`, which is `surface.updateElement` for an
14
+ * element and `store.updateBlock` for a block — never a `Y.Map` directly.
15
+ *
16
+ * They are reached through the `canvas.element.*` / `canvas.group.rename`
17
+ * commands, so a host's own pane gets the same guards by calling `runCommand`.
18
+ */
19
+ function gfxModel(std, id) {
20
+ const model = std.get(GfxControllerIdentifier).getElementById(id);
21
+ return model instanceof GfxPrimitiveElementModel ||
22
+ model instanceof GfxBlockElementModel
23
+ ? model
24
+ : null;
25
+ }
26
+ /**
27
+ * The models a reorder compares against: those sharing the moved model's RAW
28
+ * `group` — a group, a mindmap, a frame, or none.
29
+ *
30
+ * Raw and not the pane's container on purpose: an `index` only orders a model
31
+ * among the models its group-like ancestor stacks together (`compare` puts a
32
+ * frame's members right above the frame), so a key computed against a wider
33
+ * list could be written and still not move the row.
34
+ */
35
+ function stackSiblings(std, model) {
36
+ const group = model.group;
37
+ const gfx = std.get(GfxControllerIdentifier);
38
+ // With user layers a model is restacked within its layer (ADR 0031 §4):
39
+ // a key computed against another layer's neighbours would not move it.
40
+ const userLayers = gfx.surface?.userLayers;
41
+ const layer = userLayers?.ranks ? userLayers.effectiveLayerOf(model) : null;
42
+ return gfx.gfxElements
43
+ .filter(other => other.group === group &&
44
+ (layer === null || userLayers.effectiveLayerOf(other) === layer))
45
+ .sort(compareLayer);
46
+ }
47
+ /**
48
+ * Move `id` so it sits directly ABOVE `above` in the stack — `null` puts it at
49
+ * the bottom of its stack. Answers whether anything was written.
50
+ *
51
+ * The drop target of a drag in a top-first list: dropping a row just over row
52
+ * X means "directly above X". The new `index` is a key between the two
53
+ * neighbours (the same `fractional-indexing` keys `LayerManager` generates), so
54
+ * one field of one model is written and nothing else moves.
55
+ *
56
+ * Refused, with nothing written: a read-only document; a mindmap node (it has
57
+ * no index of its own — the whole mindmap moves as one, as the toolbar's
58
+ * reorder already says); an `above` that is not stacked with `id`; and a
59
+ * target that is where the model already is.
60
+ */
61
+ export function reorderPaneElement(std, id, above) {
62
+ if (std.store.readonly)
63
+ return false;
64
+ const model = gfxModel(std, id);
65
+ if (!model || id === above)
66
+ return false;
67
+ if (model.group instanceof MindmapElementModel)
68
+ return false;
69
+ const siblings = stackSiblings(std, model);
70
+ const others = siblings.filter(other => other !== model);
71
+ let position = 0;
72
+ if (above !== null) {
73
+ const target = others.findIndex(other => other.id === above);
74
+ if (target === -1)
75
+ return false;
76
+ position = target + 1;
77
+ }
78
+ // Already there: the model's current lower neighbour is the target.
79
+ const current = siblings.indexOf(model);
80
+ const lowerNow = current > 0 ? siblings[current - 1] : null;
81
+ if ((lowerNow?.id ?? null) === above)
82
+ return false;
83
+ const lower = others[position - 1]?.index ?? null;
84
+ const upper = others[position]?.index ?? null;
85
+ // Two equal keys cannot be split. `generateIndex` never produces them, so
86
+ // this only guards a hand-made document; refusing beats throwing in a drop.
87
+ if (lower !== null && upper !== null && lower >= upper)
88
+ return false;
89
+ const index = generateKeyBetween(lower, upper);
90
+ std.store.captureSync();
91
+ std.get(GfxControllerIdentifier).updateElement(model, { index });
92
+ return true;
93
+ }
94
+ /**
95
+ * Lock or unlock each model ON ITS OWN. Answers whether anything was written.
96
+ *
97
+ * Deliberately not the contextual toolbar's lock: that one, given several
98
+ * elements, wraps them into a new group and locks the group — a structural
99
+ * edit a row's padlock must never make. Here each row keeps its place in the
100
+ * tree; only `lockedBySelf` changes, and only where it differs.
101
+ */
102
+ export function setPaneElementsLocked(std, ids, locked) {
103
+ if (std.store.readonly)
104
+ return false;
105
+ const targets = ids
106
+ .map(id => gfxModel(std, id))
107
+ .filter((model) => model !== null && (model.lockedBySelf === true) !== locked);
108
+ if (!targets.length)
109
+ return false;
110
+ const gfx = std.get(GfxControllerIdentifier);
111
+ std.store.captureSync();
112
+ std.store.transact(() => {
113
+ for (const model of targets) {
114
+ gfx.updateElement(model, { lockedBySelf: locked });
115
+ }
116
+ });
117
+ return true;
118
+ }
119
+ /**
120
+ * Hide models for EVERYONE, or show them again (ADR 0031 §7). Answers how
121
+ * many models were written.
122
+ *
123
+ * Writes the stored `hiddenForEveryone` — never `hidden`, which mindmap
124
+ * collapse owns. Hiding writes `true`; showing REMOVES the key (`clearField`
125
+ * on an element, the props proxy's delete on a block), never stores `false`,
126
+ * so an unhidden document is byte-identical to one never hidden. Models
127
+ * already in the asked state are skipped, so a gesture that changes nothing
128
+ * writes nothing and pushes no undo step; the rest go in one transaction
129
+ * after one `captureSync()`.
130
+ */
131
+ export function setPaneElementsHiddenForEveryone(std, ids, hidden) {
132
+ if (std.store.readonly)
133
+ return 0;
134
+ const targets = ids
135
+ .map(id => gfxModel(std, id))
136
+ .filter((model) => model !== null && isStoredHiddenForEveryone(model) !== hidden);
137
+ if (!targets.length)
138
+ return 0;
139
+ const gfx = std.get(GfxControllerIdentifier);
140
+ std.store.captureSync();
141
+ std.store.transact(() => {
142
+ for (const model of targets) {
143
+ if (hidden) {
144
+ gfx.updateElement(model, { hiddenForEveryone: true });
145
+ }
146
+ else if (model instanceof GfxPrimitiveElementModel) {
147
+ model.clearField('hiddenForEveryone');
148
+ }
149
+ else {
150
+ // The props proxy deletes the `prop:` key (ADR 0031 §7).
151
+ delete model.props.hiddenForEveryone;
152
+ }
153
+ }
154
+ });
155
+ return targets.length;
156
+ }
157
+ /**
158
+ * Rename a group through its existing stored `title`. Answers whether
159
+ * anything was written. An empty or unchanged title writes nothing.
160
+ */
161
+ export function renamePaneGroup(std, id, title) {
162
+ if (std.store.readonly)
163
+ return false;
164
+ const model = gfxModel(std, id);
165
+ if (!(model instanceof GroupElementModel))
166
+ return false;
167
+ const next = title.trim();
168
+ if (!next || next === model.title.toString())
169
+ return false;
170
+ std.store.captureSync();
171
+ std
172
+ .get(GfxControllerIdentifier)
173
+ .updateElement(model, { title: new Y.Text(next) });
174
+ return true;
175
+ }
176
+ /**
177
+ * Rename a frame through its existing stored `title`, edited in place — the
178
+ * `Text` the frame's own title editor binds to, never a replaced one, so an
179
+ * open title editor keeps its binding. Answers whether anything was written.
180
+ * An empty or unchanged title writes nothing.
181
+ */
182
+ export function renamePaneFrame(std, id, title) {
183
+ if (std.store.readonly)
184
+ return false;
185
+ const model = gfxModel(std, id);
186
+ if (!(model instanceof FrameBlockModel))
187
+ return false;
188
+ const next = title.trim();
189
+ const text = model.props.title;
190
+ if (!next || next === text.toString())
191
+ return false;
192
+ std.store.captureSync();
193
+ text.replace(0, text.length, next);
194
+ return true;
195
+ }
196
+ /** The frames on the canvas, top first — what the pane's filter offers. */
197
+ export function selectionPaneFilterTargets(std) {
198
+ return std
199
+ .get(GfxControllerIdentifier)
200
+ .gfxElements.filter(model => model instanceof FrameBlockModel)
201
+ .sort((a, b) => compareLayer(b, a))
202
+ .map(model => ({ id: model.id, kind: 'frame' }));
203
+ }
204
+ /**
205
+ * The ids a frame filter keeps: the frame itself — a row like any other, so
206
+ * the list keeps showing what it is filtered by (ADR 0031, amendments) — its
207
+ * `childElementIds` and their descendants. `null` for an id that is not a
208
+ * frame.
209
+ */
210
+ export function selectionPaneFilterMembers(std, targetId) {
211
+ const target = std.get(GfxControllerIdentifier).getElementById(targetId);
212
+ if (!(target instanceof FrameBlockModel))
213
+ return null;
214
+ const ids = new Set([target.id]);
215
+ for (const child of target.childElements) {
216
+ ids.add(child.id);
217
+ if ('descendantElements' in child) {
218
+ for (const descendant of child
219
+ .descendantElements) {
220
+ ids.add(descendant.id);
221
+ }
222
+ }
223
+ }
224
+ return ids;
225
+ }
226
+ /**
227
+ * The tree narrowed to `members`: a row is kept when it is a member or holds
228
+ * one, so a group reaching into a frame stays as the path to its member.
229
+ *
230
+ * A LAYER row is always kept, its children narrowed (ADR 0031, amendments): a
231
+ * layer is where new elements land and where a drop goes, not something a
232
+ * frame holds, and a layer created under a filter that hid it read as a
233
+ * "New layer" button doing nothing.
234
+ */
235
+ export function filterSelectionPaneTree(nodes, members) {
236
+ const kept = [];
237
+ for (const node of nodes) {
238
+ const children = node.children
239
+ ? filterSelectionPaneTree(node.children, members)
240
+ : undefined;
241
+ if (node.kind === 'layer' ||
242
+ members.has(node.id) ||
243
+ (children && children.length)) {
244
+ kept.push(children ? { ...node, children } : node);
245
+ }
246
+ }
247
+ return kept;
248
+ }
@@ -0,0 +1,82 @@
1
+ import type { AnyCommandDescriptor } from '../../../std/index.js';
2
+ import { z } from 'zod';
3
+ export declare const reorderElementParams: z.ZodObject<{
4
+ /** The element or gfx block to move. */
5
+ id: z.ZodString;
6
+ /**
7
+ * The model it lands directly ABOVE, stacked with it; `null` puts it at the
8
+ * bottom of its stack.
9
+ */
10
+ above: z.ZodNullable<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: string;
13
+ above: string | null;
14
+ }, {
15
+ id: string;
16
+ above: string | null;
17
+ }>;
18
+ export type ReorderElementParams = z.infer<typeof reorderElementParams>;
19
+ export declare const lockElementsParams: z.ZodObject<{
20
+ /**
21
+ * The models to act on. Omitted: the current canvas selection. Each one is
22
+ * locked ON ITS OWN — never wrapped into a group.
23
+ */
24
+ ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ ids?: string[] | undefined;
27
+ }, {
28
+ ids?: string[] | undefined;
29
+ }>;
30
+ export type LockElementsParams = z.infer<typeof lockElementsParams>;
31
+ export declare const renameGroupParams: z.ZodObject<{
32
+ id: z.ZodString;
33
+ title: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ id: string;
36
+ title: string;
37
+ }, {
38
+ id: string;
39
+ title: string;
40
+ }>;
41
+ export type RenameGroupParams = z.infer<typeof renameGroupParams>;
42
+ export declare const hideLocalParams: z.ZodObject<{
43
+ /** The models to act on. Omitted: the current canvas selection. */
44
+ ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
45
+ /**
46
+ * Whole user layers to act on instead (ADR 0031 stage 7). When given,
47
+ * `ids` and the selection are ignored.
48
+ */
49
+ layerIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
50
+ /** `false` shows them again. Omitted: hide. */
51
+ hidden: z.ZodOptional<z.ZodBoolean>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ hidden?: boolean | undefined;
54
+ ids?: string[] | undefined;
55
+ layerIds?: string[] | undefined;
56
+ }, {
57
+ hidden?: boolean | undefined;
58
+ ids?: string[] | undefined;
59
+ layerIds?: string[] | undefined;
60
+ }>;
61
+ export type HideLocalParams = z.infer<typeof hideLocalParams>;
62
+ export declare const hideForEveryoneParams: z.ZodObject<{
63
+ /** The models to act on. Omitted: the current canvas selection. */
64
+ ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
65
+ /**
66
+ * Whole user layers to act on instead: `hidden: true` on each record, one
67
+ * write per layer, never one per member (ADR 0031 §7).
68
+ */
69
+ layerIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
70
+ /** `false` shows them again, for everyone. Omitted: hide. */
71
+ hidden: z.ZodOptional<z.ZodBoolean>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ hidden?: boolean | undefined;
74
+ ids?: string[] | undefined;
75
+ layerIds?: string[] | undefined;
76
+ }, {
77
+ hidden?: boolean | undefined;
78
+ ids?: string[] | undefined;
79
+ layerIds?: string[] | undefined;
80
+ }>;
81
+ export type HideForEveryoneParams = z.infer<typeof hideForEveryoneParams>;
82
+ export declare const selectionPaneCommands: AnyCommandDescriptor[];
@@ -0,0 +1,342 @@
1
+ import { CanvasLocalVisibility, SelectionPaneProvider, TelemetryProvider, } from '../../../affine-shared/services/index.js';
2
+ import { GfxControllerIdentifier } from '../../../std/gfx/index.js';
3
+ import { z } from 'zod';
4
+ import { renamePaneFrame, renamePaneGroup, reorderPaneElement, setPaneElementsHiddenForEveryone, setPaneElementsLocked, } from './actions.js';
5
+ import { setUserLayersHiddenForEveryone } from '../user-layers/actions.js';
6
+ import { SelectionPaneModel } from './tree.js';
7
+ /**
8
+ * The selection pane's commands (ADR 0031, stage 2), `owner: 'core'`: the pane
9
+ * belongs to no framework, and `'core'` owners are exempt from the id-prefix
10
+ * rule (ADR 0008).
11
+ *
12
+ * The pane's own rows invoke the parameterised ones through `runCommand`, and
13
+ * so does a host's pane: the read-only refusal lives in the action, once.
14
+ */
15
+ /** How the user reached the pane, as `SelectionPaneOpened` reports it. */
16
+ function openedFrom(invocation) {
17
+ if (invocation.surface === 'shortcut')
18
+ return 'shortcut';
19
+ if (invocation.source === 'toolbar:general')
20
+ return 'toolbar';
21
+ // The palette and the agent both invoke the command by name.
22
+ return 'palette';
23
+ }
24
+ const paneService = (std) => std.getOptional(SelectionPaneProvider);
25
+ /**
26
+ * Open the pane, or put the library's own panel away when it is the one on
27
+ * screen.
28
+ *
29
+ * Toggling needs a state the two-verb seam does not carry, so it reads the
30
+ * library panel's own (`SelectionPaneModel.open$`). A host that replaced the
31
+ * panel keeps its open state to itself: for it, the toggle always opens, and
32
+ * closing is the host's own control.
33
+ *
34
+ * Emits `SelectionPaneOpened` from its body, and only when it opens — see the
35
+ * telemetry README for why this command self-emits like `doc.copyLink`.
36
+ *
37
+ * Opening writes nothing, so no read-only guard: the pane is how a reader finds
38
+ * what is on a canvas they cannot edit.
39
+ */
40
+ const toggleSelectionPane = {
41
+ id: 'canvas.selectionPane.toggle',
42
+ owner: 'core',
43
+ kind: 'action',
44
+ labelKey: 'com.labre.command.canvas.selection-pane.toggle',
45
+ labelFallback: 'Selection pane',
46
+ descriptionKey: 'com.labre.command.canvas.selection-pane.toggle.description',
47
+ descriptionFallback: 'List the elements of the canvas by stacking order, to select, lock, rename or reorder them.',
48
+ keywords: ['layers', 'objects', 'z-order', 'stack'],
49
+ surfaces: ['palette', 'agent'],
50
+ scope: 'edgeless',
51
+ defaultKeys: { mac: [], other: [] },
52
+ // `null` from `SelectionPaneExtension(null)` switches the pane off; the
53
+ // command then disappears rather than opening nothing.
54
+ when: std => !!paneService(std),
55
+ run: (std, invocation) => {
56
+ const service = paneService(std);
57
+ if (!service)
58
+ return;
59
+ const model = std.getOptional(SelectionPaneModel);
60
+ if (model?.open$.peek()) {
61
+ service.close();
62
+ return;
63
+ }
64
+ service.open();
65
+ std.getOptional(TelemetryProvider)?.track('SelectionPaneOpened', {
66
+ page: 'whiteboard editor',
67
+ source: openedFrom(invocation),
68
+ });
69
+ },
70
+ };
71
+ export const reorderElementParams = z.object({
72
+ /** The element or gfx block to move. */
73
+ id: z.string().min(1),
74
+ /**
75
+ * The model it lands directly ABOVE, stacked with it; `null` puts it at the
76
+ * bottom of its stack.
77
+ */
78
+ above: z.string().min(1).nullable(),
79
+ });
80
+ const reorderElement = {
81
+ id: 'canvas.element.reorder',
82
+ owner: 'core',
83
+ kind: 'action',
84
+ labelKey: 'com.labre.command.canvas.element.reorder',
85
+ labelFallback: 'Move in the stack',
86
+ descriptionKey: 'com.labre.command.canvas.element.reorder.description',
87
+ descriptionFallback: 'Place an element directly above another one in the stacking order.',
88
+ // Agent only: without an explicit target there is nothing to say where.
89
+ surfaces: ['agent'],
90
+ scope: 'edgeless',
91
+ defaultKeys: { mac: [], other: [] },
92
+ availability: 'editable',
93
+ params: reorderElementParams,
94
+ run: (std, _invocation, params) => {
95
+ const parsed = reorderElementParams.safeParse(params);
96
+ if (!parsed.success) {
97
+ console.error('canvas.element.reorder: invalid params', parsed.error);
98
+ return;
99
+ }
100
+ reorderPaneElement(std, parsed.data.id, parsed.data.above);
101
+ },
102
+ };
103
+ export const lockElementsParams = z.object({
104
+ /**
105
+ * The models to act on. Omitted: the current canvas selection. Each one is
106
+ * locked ON ITS OWN — never wrapped into a group.
107
+ */
108
+ ids: z.array(z.string()).optional(),
109
+ });
110
+ function lockTargets(std, params) {
111
+ const parsed = lockElementsParams.safeParse(params ?? {});
112
+ if (!parsed.success)
113
+ return [];
114
+ return (parsed.data.ids ?? std.get(GfxControllerIdentifier).selection.selectedIds);
115
+ }
116
+ function lockCommand(locked) {
117
+ const verb = locked ? 'lock' : 'unlock';
118
+ return {
119
+ id: `canvas.element.${verb}`,
120
+ owner: 'core',
121
+ kind: 'action',
122
+ labelKey: `com.labre.command.canvas.element.${verb}`,
123
+ labelFallback: locked ? 'Lock each element' : 'Unlock each element',
124
+ descriptionKey: `com.labre.command.canvas.element.${verb}.description`,
125
+ descriptionFallback: locked
126
+ ? 'Lock every selected element on its own, without grouping them.'
127
+ : 'Unlock every selected element on its own.',
128
+ surfaces: ['palette', 'agent'],
129
+ scope: 'edgeless',
130
+ defaultKeys: { mac: [], other: [] },
131
+ availability: 'editable',
132
+ when: std => std.get(GfxControllerIdentifier).selection.selectedIds.length > 0,
133
+ params: lockElementsParams,
134
+ run: (std, _invocation, params) => {
135
+ setPaneElementsLocked(std, lockTargets(std, params), locked);
136
+ },
137
+ };
138
+ }
139
+ export const renameGroupParams = z.object({
140
+ id: z.string().min(1),
141
+ title: z.string(),
142
+ });
143
+ const renameGroup = {
144
+ id: 'canvas.group.rename',
145
+ owner: 'core',
146
+ kind: 'action',
147
+ labelKey: 'com.labre.command.canvas.group.rename',
148
+ labelFallback: 'Rename group',
149
+ descriptionKey: 'com.labre.command.canvas.group.rename.description',
150
+ descriptionFallback: 'Give a group a new title.',
151
+ surfaces: ['agent'],
152
+ scope: 'edgeless',
153
+ defaultKeys: { mac: [], other: [] },
154
+ availability: 'editable',
155
+ params: renameGroupParams,
156
+ run: (std, _invocation, params) => {
157
+ const parsed = renameGroupParams.safeParse(params);
158
+ if (!parsed.success) {
159
+ console.error('canvas.group.rename: invalid params', parsed.error);
160
+ return;
161
+ }
162
+ renamePaneGroup(std, parsed.data.id, parsed.data.title);
163
+ },
164
+ };
165
+ /**
166
+ * A frame's row is renamed in place like a group's (ADR 0031, amendments:
167
+ * frames are rows). Its own command rather than `canvas.group.rename` widened:
168
+ * the agent reads a command's wording, and a frame is not a group.
169
+ */
170
+ const renameFrame = {
171
+ id: 'canvas.frame.rename',
172
+ owner: 'core',
173
+ kind: 'action',
174
+ labelKey: 'com.labre.command.canvas.frame.rename',
175
+ labelFallback: 'Rename frame',
176
+ descriptionKey: 'com.labre.command.canvas.frame.rename.description',
177
+ descriptionFallback: 'Give a frame a new title.',
178
+ surfaces: ['agent'],
179
+ scope: 'edgeless',
180
+ defaultKeys: { mac: [], other: [] },
181
+ availability: 'editable',
182
+ params: renameGroupParams,
183
+ run: (std, _invocation, params) => {
184
+ const parsed = renameGroupParams.safeParse(params);
185
+ if (!parsed.success) {
186
+ console.error('canvas.frame.rename: invalid params', parsed.error);
187
+ return;
188
+ }
189
+ renamePaneFrame(std, parsed.data.id, parsed.data.title);
190
+ },
191
+ };
192
+ export const hideLocalParams = z.object({
193
+ /** The models to act on. Omitted: the current canvas selection. */
194
+ ids: z.array(z.string()).optional(),
195
+ /**
196
+ * Whole user layers to act on instead (ADR 0031 stage 7). When given,
197
+ * `ids` and the selection are ignored.
198
+ */
199
+ layerIds: z.array(z.string()).optional(),
200
+ /** `false` shows them again. Omitted: hide. */
201
+ hidden: z.boolean().optional(),
202
+ });
203
+ function reportVisibility(std, hidden, count, scope = 'local', target = 'element') {
204
+ if (!count)
205
+ return;
206
+ std.getOptional(TelemetryProvider)?.track('CanvasVisibilityChanged', {
207
+ page: 'whiteboard editor',
208
+ target,
209
+ scope,
210
+ hidden,
211
+ count,
212
+ });
213
+ }
214
+ /**
215
+ * Hide elements for THIS viewer only (ADR 0031 §8) — or, with
216
+ * `hidden: false`, show them again; the pane's eye is both.
217
+ *
218
+ * Nothing is written to the document, so there is no read-only guard: a
219
+ * reader may hide what is in their way. Self-emits `CanvasVisibilityChanged`
220
+ * with the number of elements the gesture actually changed.
221
+ */
222
+ const hideLocal = {
223
+ id: 'canvas.visibility.hideLocal',
224
+ owner: 'core',
225
+ kind: 'action',
226
+ labelKey: 'com.labre.command.canvas.visibility.hide-local',
227
+ labelFallback: 'Hide for me',
228
+ descriptionKey: 'com.labre.command.canvas.visibility.hide-local.description',
229
+ descriptionFallback: 'Hide the selected elements on your screen only. Nothing changes for anyone else.',
230
+ surfaces: ['palette', 'agent'],
231
+ scope: 'edgeless',
232
+ defaultKeys: { mac: [], other: [] },
233
+ availability: 'selection',
234
+ when: std => !!std.getOptional(CanvasLocalVisibility),
235
+ params: hideLocalParams,
236
+ run: (std, _invocation, params) => {
237
+ const visibility = std.getOptional(CanvasLocalVisibility);
238
+ const parsed = hideLocalParams.safeParse(params ?? {});
239
+ if (!visibility || !parsed.success)
240
+ return;
241
+ if (parsed.data.layerIds) {
242
+ const hidden = parsed.data.hidden ?? true;
243
+ const layers = parsed.data.layerIds;
244
+ const count = hidden
245
+ ? visibility.hideLayers(layers)
246
+ : visibility.showLayers(layers);
247
+ reportVisibility(std, hidden, count, 'local', 'layer');
248
+ return;
249
+ }
250
+ const ids = parsed.data.ids ?? std.get(GfxControllerIdentifier).selection.selectedIds;
251
+ const hidden = parsed.data.hidden ?? true;
252
+ const count = hidden ? visibility.hide(ids) : visibility.show(ids);
253
+ reportVisibility(std, hidden, count);
254
+ },
255
+ };
256
+ export const hideForEveryoneParams = z.object({
257
+ /** The models to act on. Omitted: the current canvas selection. */
258
+ ids: z.array(z.string()).optional(),
259
+ /**
260
+ * Whole user layers to act on instead: `hidden: true` on each record, one
261
+ * write per layer, never one per member (ADR 0031 §7).
262
+ */
263
+ layerIds: z.array(z.string()).optional(),
264
+ /** `false` shows them again, for everyone. Omitted: hide. */
265
+ hidden: z.boolean().optional(),
266
+ });
267
+ /**
268
+ * Hide elements for EVERYONE (ADR 0031 §7) — or, with `hidden: false`, show
269
+ * them again for everyone. Written to the document and synced: every viewer,
270
+ * every peer, stops painting and picking them, while rules, legends and
271
+ * semantic exports keep counting them (§9). Refused on a read-only document
272
+ * (`availability`, and again in the action). Self-emits
273
+ * `CanvasVisibilityChanged` with `scope: 'everyone'` and the count actually
274
+ * written.
275
+ */
276
+ const hideForEveryone = {
277
+ id: 'canvas.visibility.hideForEveryone',
278
+ owner: 'core',
279
+ kind: 'action',
280
+ labelKey: 'com.labre.command.canvas.visibility.hide-for-everyone',
281
+ labelFallback: 'Hide for everyone',
282
+ descriptionKey: 'com.labre.command.canvas.visibility.hide-for-everyone.description',
283
+ descriptionFallback: 'Hide the selected elements for everyone who opens this document. They stay in the document and in the selection pane.',
284
+ surfaces: ['palette', 'agent'],
285
+ scope: 'edgeless',
286
+ defaultKeys: { mac: [], other: [] },
287
+ availability: 'editable',
288
+ when: std => std.get(GfxControllerIdentifier).selection.selectedIds.length > 0,
289
+ params: hideForEveryoneParams,
290
+ run: (std, _invocation, params) => {
291
+ const parsed = hideForEveryoneParams.safeParse(params ?? {});
292
+ if (!parsed.success)
293
+ return;
294
+ if (parsed.data.layerIds) {
295
+ const hidden = parsed.data.hidden ?? true;
296
+ const count = setUserLayersHiddenForEveryone(std, parsed.data.layerIds, hidden);
297
+ reportVisibility(std, hidden, count, 'everyone', 'layer');
298
+ return;
299
+ }
300
+ const ids = parsed.data.ids ?? std.get(GfxControllerIdentifier).selection.selectedIds;
301
+ const hidden = parsed.data.hidden ?? true;
302
+ const count = setPaneElementsHiddenForEveryone(std, ids, hidden);
303
+ reportVisibility(std, hidden, count, 'everyone');
304
+ },
305
+ };
306
+ /**
307
+ * Show everything this viewer hid. Stays in the palette whatever the pane
308
+ * seam says: with `SelectionPaneExtension(null)` it is the one way back.
309
+ */
310
+ const showAll = {
311
+ id: 'canvas.visibility.showAll',
312
+ owner: 'core',
313
+ kind: 'action',
314
+ labelKey: 'com.labre.command.canvas.visibility.show-all',
315
+ labelFallback: 'Show hidden elements',
316
+ descriptionKey: 'com.labre.command.canvas.visibility.show-all.description',
317
+ descriptionFallback: 'Show again every element and layer you hid on your screen.',
318
+ surfaces: ['palette', 'agent'],
319
+ scope: 'edgeless',
320
+ defaultKeys: { mac: [], other: [] },
321
+ when: std => {
322
+ const visibility = std.getOptional(CanvasLocalVisibility);
323
+ return ((visibility?.hiddenIds$.peek().size ?? 0) > 0 ||
324
+ (visibility?.hiddenLayerIds$.peek().size ?? 0) > 0);
325
+ },
326
+ run: std => {
327
+ const visibility = std.getOptional(CanvasLocalVisibility);
328
+ reportVisibility(std, false, visibility?.showAll() ?? 0);
329
+ reportVisibility(std, false, visibility?.showAllLayers() ?? 0, 'local', 'layer');
330
+ },
331
+ };
332
+ export const selectionPaneCommands = [
333
+ toggleSelectionPane,
334
+ reorderElement,
335
+ lockCommand(true),
336
+ lockCommand(false),
337
+ renameGroup,
338
+ renameFrame,
339
+ hideLocal,
340
+ hideForEveryone,
341
+ showAll,
342
+ ];
@@ -0,0 +1,3 @@
1
+ export { filterSelectionPaneTree, renamePaneFrame, renamePaneGroup, reorderPaneElement, type SelectionPaneFilterTarget, selectionPaneFilterMembers, selectionPaneFilterTargets, setPaneElementsHiddenForEveryone, setPaneElementsLocked, } from './actions.js';
2
+ export { type HideForEveryoneParams, hideForEveryoneParams, type HideLocalParams, hideLocalParams, type LockElementsParams, lockElementsParams, type RenameGroupParams, renameGroupParams, type ReorderElementParams, reorderElementParams, selectionPaneCommands, } from './commands.js';
3
+ export { buildSelectionPaneTree, DEFAULT_LAYER_ID, paneContainerOf, paneLayersOf, type SelectionPaneLayers, type SelectionPaneNode, SelectionPaneModel, selectionPaneTree, } from './tree.js';
@@ -0,0 +1,3 @@
1
+ export { filterSelectionPaneTree, renamePaneFrame, renamePaneGroup, reorderPaneElement, selectionPaneFilterMembers, selectionPaneFilterTargets, setPaneElementsHiddenForEveryone, setPaneElementsLocked, } from './actions.js';
2
+ export { hideForEveryoneParams, hideLocalParams, lockElementsParams, renameGroupParams, reorderElementParams, selectionPaneCommands, } from './commands.js';
3
+ export { buildSelectionPaneTree, DEFAULT_LAYER_ID, paneContainerOf, paneLayersOf, SelectionPaneModel, selectionPaneTree, } from './tree.js';