@formicoidea/labre-core 0.43.1 → 0.46.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 (300) 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-callout-into.d.ts +43 -0
  4. package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.js +109 -0
  5. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
  6. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
  7. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
  8. package/dist/_pkgs/affine-block-callout/configs/toolbar.d.ts +65 -0
  9. package/dist/_pkgs/affine-block-callout/configs/toolbar.js +178 -0
  10. package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
  11. package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
  12. package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
  13. package/dist/_pkgs/affine-block-callout/translations.js +4 -2
  14. package/dist/_pkgs/affine-block-callout/view.js +10 -1
  15. package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
  16. package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
  17. package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
  18. package/dist/_pkgs/affine-block-code/code-block.js +11 -2
  19. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
  20. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  21. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  22. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  23. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  24. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  25. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  26. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  27. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  28. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  29. package/dist/_pkgs/affine-block-frame/commands.d.ts +27 -0
  30. package/dist/_pkgs/affine-block-frame/commands.js +49 -0
  31. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +16 -6
  32. package/dist/_pkgs/affine-block-frame/frame-manager.js +58 -22
  33. package/dist/_pkgs/affine-block-frame/frame-order.d.ts +43 -0
  34. package/dist/_pkgs/affine-block-frame/frame-order.js +93 -0
  35. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  36. package/dist/_pkgs/affine-block-frame/index.d.ts +2 -0
  37. package/dist/_pkgs/affine-block-frame/index.js +2 -0
  38. package/dist/_pkgs/affine-block-frame/present/frame-order-menu.d.ts +10 -2
  39. package/dist/_pkgs/affine-block-frame/present/frame-order-menu.js +32 -18
  40. package/dist/_pkgs/affine-block-frame/view.js +6 -0
  41. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  42. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  43. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  44. package/dist/_pkgs/affine-block-note/configs/toolbar.d.ts +19 -0
  45. package/dist/_pkgs/affine-block-note/configs/toolbar.js +38 -23
  46. package/dist/_pkgs/affine-block-note/translations.d.ts +2 -1
  47. package/dist/_pkgs/affine-block-note/translations.js +14 -6
  48. package/dist/_pkgs/affine-block-root/configs/toolbar.js +48 -3
  49. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  50. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  51. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  52. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  53. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  54. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  55. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  56. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  57. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  58. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  59. package/dist/_pkgs/affine-block-root/translations.d.ts +7 -2
  60. package/dist/_pkgs/affine-block-root/translations.js +10 -13
  61. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  62. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  63. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  64. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  65. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  66. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  67. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  68. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  69. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  70. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  71. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  72. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  73. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  74. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  75. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  76. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  77. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  78. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  80. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  81. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  83. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  84. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  85. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  86. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  87. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  88. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  89. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  90. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  91. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  92. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  93. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +91 -0
  94. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +285 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +80 -0
  96. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +355 -0
  97. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  98. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  102. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +86 -15
  103. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  105. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  107. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  108. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  109. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  110. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  111. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  112. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  113. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  114. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  115. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  116. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  117. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  118. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  119. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  120. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  121. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  122. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  123. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  124. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  125. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  126. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  127. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  128. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  129. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  130. package/dist/_pkgs/affine-components/context-menu/button.js +14 -0
  131. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  132. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  133. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  134. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  135. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  136. package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
  137. package/dist/_pkgs/affine-foundation/view.d.ts +8 -8
  138. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  139. package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.d.ts +34 -2
  140. package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.js +194 -81
  141. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.d.ts +7 -4
  142. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +9 -24
  143. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  144. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  145. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +2 -0
  146. package/dist/_pkgs/affine-fragment-frame-panel/index.js +2 -0
  147. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  148. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  149. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +3 -2
  150. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +1 -1
  151. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  152. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  153. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  154. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +1 -1
  155. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  156. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  157. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  158. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +2 -1
  159. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  160. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  161. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  162. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  163. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +53 -2
  164. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  165. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  166. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  167. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  168. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  169. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  170. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  171. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  172. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  173. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  174. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  175. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  176. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  177. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  178. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  179. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  180. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  181. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  182. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  183. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  184. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  185. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  186. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  187. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  188. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  189. package/dist/_pkgs/affine-model/consts/text.d.ts +26 -0
  190. package/dist/_pkgs/affine-model/consts/text.js +25 -0
  191. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  192. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  193. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  194. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  195. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  196. package/dist/_pkgs/affine-model/utils/types.d.ts +2 -2
  197. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  198. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  199. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  200. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  201. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  202. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  203. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  204. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  205. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  206. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +31 -4
  207. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  208. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  209. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  210. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  211. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +2 -2
  212. package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +3 -3
  213. package/dist/_pkgs/affine-shared/services/index.d.ts +4 -1
  214. package/dist/_pkgs/affine-shared/services/index.js +4 -1
  215. package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-storage.d.ts +4 -4
  216. package/dist/_pkgs/affine-shared/services/outline-panel-service.d.ts +31 -0
  217. package/dist/_pkgs/affine-shared/services/outline-panel-service.js +17 -0
  218. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  219. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  220. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  221. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  222. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +16 -0
  223. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +28 -0
  224. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  225. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  226. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  227. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  228. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  229. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  230. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  231. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  232. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  233. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  234. package/dist/_pkgs/affine-shared/utils/index.d.ts +3 -0
  235. package/dist/_pkgs/affine-shared/utils/index.js +3 -0
  236. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  237. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  238. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  239. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  240. package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.d.ts +85 -0
  241. package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.js +162 -0
  242. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +10 -3
  243. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  244. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  245. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  246. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  247. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  248. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +62 -0
  249. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +94 -0
  250. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  251. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  252. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  253. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  254. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  255. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  256. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +186 -0
  257. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1417 -0
  258. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +52 -0
  259. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +161 -1
  260. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  261. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  262. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  263. package/dist/_pkgs/std/gfx/controller.js +22 -2
  264. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  265. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  266. package/dist/_pkgs/std/gfx/index.js +3 -1
  267. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  268. package/dist/_pkgs/std/gfx/layer.js +73 -5
  269. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  270. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  271. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  272. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  273. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  274. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  275. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  276. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  277. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  278. package/dist/_pkgs/std/scope/std-scope.d.ts +1 -1
  279. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  280. package/dist/_pkgs/std/utils/layer.js +64 -13
  281. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  282. package/dist/commands.js +6 -1
  283. package/dist/host-panels.d.ts +90 -0
  284. package/dist/host-panels.js +111 -0
  285. package/dist/translations.js +10 -6
  286. package/package.json +13 -2
  287. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  288. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  289. package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.d.ts +0 -27
  290. package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.js +0 -96
  291. package/dist/_pkgs/affine-shared/services/sidebar-service.d.ts +0 -8
  292. package/dist/_pkgs/affine-shared/services/sidebar-service.js +0 -7
  293. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  294. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  295. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  296. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  297. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  298. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  299. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  300. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -0,0 +1,76 @@
1
+ import type { BlockStdScope } from '../../../std/index.js';
2
+ import { type GfxModel, type SurfaceBlockModel, type SurfaceLayerRecord } from '../../../std/gfx/index.js';
3
+ /** The layer records, bottom first. Empty while the surface has none. */
4
+ export declare function userLayersBottomUp(surface: SurfaceBlockModel | null): {
5
+ id: string;
6
+ record: SurfaceLayerRecord;
7
+ }[];
8
+ /**
9
+ * The name a layer row shows: its record's, or — for the default layer while
10
+ * it has no record — the name the first-layer creation would write ("Layer
11
+ * 1", ADR 0031 amendments). `null` for an id that is no layer.
12
+ *
13
+ * Reading it writes nothing: the default layer is shown from the start and
14
+ * recorded only by a gesture that needs the record.
15
+ */
16
+ export declare function userLayerName(std: BlockStdScope, id: string): string | null;
17
+ /**
18
+ * Create a user layer on top of the others and make it this viewer's active
19
+ * layer. Answers its id, or `null` when nothing was written.
20
+ *
21
+ * The FIRST creation writes two records in one transaction: `'@default'`,
22
+ * named through the seam ("Layer 1"), and the new one above it. That one
23
+ * write sets the whole `layers` prop, so two peers doing it at the same
24
+ * moment keep one record set (ADR 0031 open point 6, accepted for v1): the
25
+ * other peer's members fall back to the default layer, nothing is dropped.
26
+ */
27
+ export declare function createUserLayer(std: BlockStdScope, name?: string): string | null;
28
+ /**
29
+ * Rename a layer: one field of one record. Empty or unchanged writes nothing.
30
+ *
31
+ * The default layer with no record yet is renamed by recording it, named
32
+ * (ADR 0031 amendments): "unchanged" is then against the seed name it shows.
33
+ */
34
+ export declare function renameUserLayer(std: BlockStdScope, id: string, name: string): boolean;
35
+ /**
36
+ * Move a layer so it sits directly ABOVE `above` — `null` puts it at the
37
+ * bottom. One field (`index`) of one record; a reorder racing a peer's
38
+ * rename of the same layer merges.
39
+ */
40
+ export declare function reorderUserLayer(std: BlockStdScope, id: string, above: string | null): boolean;
41
+ /**
42
+ * Hide whole layers for EVERYONE, or show them again (ADR 0031 §7, stage
43
+ * 7): `hidden: true` on each record — one write per layer, never one per
44
+ * member — and the key REMOVED on show, never `false`. Answers how many
45
+ * records were written.
46
+ *
47
+ * Hiding the default layer while it has no record records it, hidden, with
48
+ * its seed name (ADR 0031 amendments); showing it has nothing to write.
49
+ */
50
+ export declare function setUserLayersHiddenForEveryone(std: BlockStdScope, ids: readonly string[], hidden: boolean): number;
51
+ /**
52
+ * Delete a user layer WITH its members, in one undo step (ADR 0031 §10).
53
+ * Answers how many models went with it, or `null` when nothing was written.
54
+ *
55
+ * The read-only refusal comes first, then one `captureSync()`, then one
56
+ * transaction: every top-level model whose effective layer is this one (a
57
+ * group or a mindmap takes its descendants with it), then the record. A
58
+ * connector of ANOTHER layer whose ends were here stays, loose, as when its
59
+ * ends are deleted any other way — the members are removed one by one, not
60
+ * through the "delete with connectors" path of the toolbar. A frame of this
61
+ * layer goes; what it holds from other layers stays. `'@default'` cannot be
62
+ * deleted.
63
+ */
64
+ export declare function deleteUserLayer(std: BlockStdScope, id: string): number | null;
65
+ /**
66
+ * Write `layer` on one model — set it, or REMOVE the key for the default
67
+ * layer (never the string `'@default'`). Inside the caller's transaction.
68
+ */
69
+ export declare function writeModelLayer(std: BlockStdScope, model: GfxModel, layer: string): void;
70
+ /**
71
+ * Move models to the layer `layerId`. Answers how many models were written —
72
+ * a grouped model moves its outermost group, so that may be fewer than asked.
73
+ * An unknown layer id writes nothing. The default layer always exists, record
74
+ * or not: moving there removes the `layer` key, a dangling id included.
75
+ */
76
+ export declare function moveModelsToUserLayer(std: BlockStdScope, ids: readonly string[], layerId: string): number;
@@ -0,0 +1,299 @@
1
+ import { translateKey } from '../../../affine-shared/services/index.js';
2
+ import { DEFAULT_LAYER_ID, GfxBlockElementModel, GfxControllerIdentifier, GfxPrimitiveElementModel, layerCarrierOf, ownLayerOf, } from '../../../std/gfx/index.js';
3
+ import { nanoid } from '../../../store/index.js';
4
+ import { generateKeyBetween } from 'fractional-indexing';
5
+ import { CanvasActiveLayer } from './active-layer.js';
6
+ import { LAYER_SEED_NAME } from './translations.js';
7
+ /**
8
+ * The user layers' writes (ADR 0031 §2, §5, stage 6). Every one of them:
9
+ *
10
+ * - refuses on a read-only document before reading anything else;
11
+ * - writes nothing when nothing would change;
12
+ * - takes ONE `captureSync()` first, so one gesture is one undo step;
13
+ * - writes ONE record, or ONE field of a record — never the whole `layers`
14
+ * prop, except the very first creation, which has no record to write into.
15
+ * That is what lets two peers' edits of two layers merge key by key.
16
+ *
17
+ * Reached through the `canvas.layer.*` commands, so a host's own pane gets
18
+ * the same guards by calling `runCommand`.
19
+ */
20
+ function surfaceOf(std) {
21
+ return std.get(GfxControllerIdentifier).surface;
22
+ }
23
+ /** The layer records, bottom first. Empty while the surface has none. */
24
+ export function userLayersBottomUp(surface) {
25
+ const layers = surface?.props.layers;
26
+ if (!layers)
27
+ return [];
28
+ return Object.entries(layers)
29
+ .filter(([, record]) => record && typeof record.index === 'string')
30
+ .map(([id, record]) => ({ id, record }))
31
+ .sort((a, b) => a.record.index === b.record.index
32
+ ? a.id < b.id
33
+ ? -1
34
+ : 1
35
+ : a.record.index < b.record.index
36
+ ? -1
37
+ : 1);
38
+ }
39
+ /** The seed a new layer is named with, resolved through the seam. */
40
+ function seedName(std, n) {
41
+ return translateKey(std, ...LAYER_SEED_NAME, { n });
42
+ }
43
+ /**
44
+ * The name a layer row shows: its record's, or — for the default layer while
45
+ * it has no record — the name the first-layer creation would write ("Layer
46
+ * 1", ADR 0031 amendments). `null` for an id that is no layer.
47
+ *
48
+ * Reading it writes nothing: the default layer is shown from the start and
49
+ * recorded only by a gesture that needs the record.
50
+ */
51
+ export function userLayerName(std, id) {
52
+ const record = surfaceOf(std)?.props.layers?.[id];
53
+ if (record)
54
+ return record.name;
55
+ return id === DEFAULT_LAYER_ID ? seedName(std, 1) : null;
56
+ }
57
+ /**
58
+ * Record the default layer, inside the caller's transaction: the whole
59
+ * `layers` prop while it is absent — as the first creation does — else the
60
+ * one `'@default'` key, below every other layer. The seed name unless the
61
+ * gesture says otherwise.
62
+ */
63
+ function recordDefaultLayer(std, surface, fields = {}) {
64
+ const bottom = userLayersBottomUp(surface)[0]?.record.index ?? null;
65
+ const record = {
66
+ name: seedName(std, 1),
67
+ index: generateKeyBetween(null, bottom),
68
+ ...fields,
69
+ };
70
+ if (!surface.props.layers) {
71
+ surface.props.layers = { [DEFAULT_LAYER_ID]: record };
72
+ }
73
+ else {
74
+ surface.props.layers[DEFAULT_LAYER_ID] = record;
75
+ }
76
+ }
77
+ /**
78
+ * Create a user layer on top of the others and make it this viewer's active
79
+ * layer. Answers its id, or `null` when nothing was written.
80
+ *
81
+ * The FIRST creation writes two records in one transaction: `'@default'`,
82
+ * named through the seam ("Layer 1"), and the new one above it. That one
83
+ * write sets the whole `layers` prop, so two peers doing it at the same
84
+ * moment keep one record set (ADR 0031 open point 6, accepted for v1): the
85
+ * other peer's members fall back to the default layer, nothing is dropped.
86
+ */
87
+ export function createUserLayer(std, name) {
88
+ if (std.store.readonly)
89
+ return null;
90
+ const surface = surfaceOf(std);
91
+ if (!surface)
92
+ return null;
93
+ const existing = userLayersBottomUp(surface);
94
+ const id = nanoid();
95
+ const seed = (n) => seedName(std, n);
96
+ std.store.captureSync();
97
+ std.store.transact(() => {
98
+ if (!existing.length) {
99
+ const bottom = generateKeyBetween(null, null);
100
+ surface.props.layers = {
101
+ [DEFAULT_LAYER_ID]: { name: seed(1), index: bottom },
102
+ [id]: {
103
+ name: name?.trim() || seed(2),
104
+ index: generateKeyBetween(bottom, null),
105
+ },
106
+ };
107
+ return;
108
+ }
109
+ const top = existing[existing.length - 1].record.index;
110
+ surface.props.layers[id] = {
111
+ name: name?.trim() || seed(existing.length + 1),
112
+ index: generateKeyBetween(top, null),
113
+ };
114
+ });
115
+ std.getOptional(CanvasActiveLayer)?.choose(id);
116
+ return id;
117
+ }
118
+ /**
119
+ * Rename a layer: one field of one record. Empty or unchanged writes nothing.
120
+ *
121
+ * The default layer with no record yet is renamed by recording it, named
122
+ * (ADR 0031 amendments): "unchanged" is then against the seed name it shows.
123
+ */
124
+ export function renameUserLayer(std, id, name) {
125
+ if (std.store.readonly)
126
+ return false;
127
+ const surface = surfaceOf(std);
128
+ const record = surface?.props.layers?.[id];
129
+ const shown = userLayerName(std, id);
130
+ const next = name.trim();
131
+ if (!surface || shown === null || !next || next === shown)
132
+ return false;
133
+ std.store.captureSync();
134
+ // Inside the store's transaction, not the props proxy's own: the proxy
135
+ // writes with its own origin, which the undo manager does not track.
136
+ std.store.transact(() => {
137
+ if (record)
138
+ record.name = next;
139
+ else
140
+ recordDefaultLayer(std, surface, { name: next });
141
+ });
142
+ return true;
143
+ }
144
+ /**
145
+ * Move a layer so it sits directly ABOVE `above` — `null` puts it at the
146
+ * bottom. One field (`index`) of one record; a reorder racing a peer's
147
+ * rename of the same layer merges.
148
+ */
149
+ export function reorderUserLayer(std, id, above) {
150
+ if (std.store.readonly || id === above)
151
+ return false;
152
+ const layers = userLayersBottomUp(surfaceOf(std));
153
+ const moving = layers.find(layer => layer.id === id);
154
+ if (!moving)
155
+ return false;
156
+ const others = layers.filter(layer => layer.id !== id);
157
+ let position = 0;
158
+ if (above !== null) {
159
+ const target = others.findIndex(layer => layer.id === above);
160
+ if (target === -1)
161
+ return false;
162
+ position = target + 1;
163
+ }
164
+ const current = layers.indexOf(moving);
165
+ if ((layers[current - 1]?.id ?? null) === above)
166
+ return false;
167
+ const lower = others[position - 1]?.record.index ?? null;
168
+ const upper = others[position]?.record.index ?? null;
169
+ if (lower !== null && upper !== null && lower >= upper)
170
+ return false;
171
+ std.store.captureSync();
172
+ std.store.transact(() => {
173
+ moving.record.index = generateKeyBetween(lower, upper);
174
+ });
175
+ return true;
176
+ }
177
+ /**
178
+ * Hide whole layers for EVERYONE, or show them again (ADR 0031 §7, stage
179
+ * 7): `hidden: true` on each record — one write per layer, never one per
180
+ * member — and the key REMOVED on show, never `false`. Answers how many
181
+ * records were written.
182
+ *
183
+ * Hiding the default layer while it has no record records it, hidden, with
184
+ * its seed name (ADR 0031 amendments); showing it has nothing to write.
185
+ */
186
+ export function setUserLayersHiddenForEveryone(std, ids, hidden) {
187
+ if (std.store.readonly)
188
+ return 0;
189
+ const surface = surfaceOf(std);
190
+ if (!surface)
191
+ return 0;
192
+ const layers = surface.props.layers;
193
+ const targets = ids
194
+ .map(id => layers?.[id])
195
+ .filter((record) => !!record && (record.hidden === true) !== hidden);
196
+ const recordDefault = hidden && ids.includes(DEFAULT_LAYER_ID) && !layers?.[DEFAULT_LAYER_ID];
197
+ if (!targets.length && !recordDefault)
198
+ return 0;
199
+ std.store.captureSync();
200
+ std.store.transact(() => {
201
+ for (const record of targets) {
202
+ if (hidden) {
203
+ record.hidden = true;
204
+ }
205
+ else {
206
+ delete record.hidden;
207
+ }
208
+ }
209
+ if (recordDefault)
210
+ recordDefaultLayer(std, surface, { hidden: true });
211
+ });
212
+ return targets.length + (recordDefault ? 1 : 0);
213
+ }
214
+ /**
215
+ * Delete a user layer WITH its members, in one undo step (ADR 0031 §10).
216
+ * Answers how many models went with it, or `null` when nothing was written.
217
+ *
218
+ * The read-only refusal comes first, then one `captureSync()`, then one
219
+ * transaction: every top-level model whose effective layer is this one (a
220
+ * group or a mindmap takes its descendants with it), then the record. A
221
+ * connector of ANOTHER layer whose ends were here stays, loose, as when its
222
+ * ends are deleted any other way — the members are removed one by one, not
223
+ * through the "delete with connectors" path of the toolbar. A frame of this
224
+ * layer goes; what it holds from other layers stays. `'@default'` cannot be
225
+ * deleted.
226
+ */
227
+ export function deleteUserLayer(std, id) {
228
+ if (std.store.readonly)
229
+ return null;
230
+ if (id === DEFAULT_LAYER_ID)
231
+ return null;
232
+ const surface = surfaceOf(std);
233
+ const layers = surface?.props.layers;
234
+ if (!surface || !layers?.[id])
235
+ return null;
236
+ const gfx = std.get(GfxControllerIdentifier);
237
+ const members = gfx.gfxElements.filter(model => surface.userLayers.effectiveLayerOf(model) === id);
238
+ const carriers = members.filter(model => layerCarrierOf(model) === model);
239
+ std.store.captureSync();
240
+ std.store.transact(() => {
241
+ for (const model of carriers) {
242
+ if (gfx.getElementById(model.id))
243
+ gfx.deleteElement(model);
244
+ }
245
+ delete layers[id];
246
+ });
247
+ std.store.captureSync();
248
+ return members.length;
249
+ }
250
+ /**
251
+ * Write `layer` on one model — set it, or REMOVE the key for the default
252
+ * layer (never the string `'@default'`). Inside the caller's transaction.
253
+ */
254
+ export function writeModelLayer(std, model, layer) {
255
+ if (layer === DEFAULT_LAYER_ID) {
256
+ if (model instanceof GfxPrimitiveElementModel) {
257
+ model.clearField('layer');
258
+ }
259
+ else if (model instanceof GfxBlockElementModel) {
260
+ delete model.props.layer;
261
+ }
262
+ return;
263
+ }
264
+ std.get(GfxControllerIdentifier).updateElement(model, { layer });
265
+ }
266
+ /**
267
+ * Move models to the layer `layerId`. Answers how many models were written —
268
+ * a grouped model moves its outermost group, so that may be fewer than asked.
269
+ * An unknown layer id writes nothing. The default layer always exists, record
270
+ * or not: moving there removes the `layer` key, a dangling id included.
271
+ */
272
+ export function moveModelsToUserLayer(std, ids, layerId) {
273
+ if (std.store.readonly)
274
+ return 0;
275
+ const surface = surfaceOf(std);
276
+ if (!surface)
277
+ return 0;
278
+ if (layerId !== DEFAULT_LAYER_ID && !surface.props.layers?.[layerId]) {
279
+ return 0;
280
+ }
281
+ const gfx = std.get(GfxControllerIdentifier);
282
+ const carriers = new Set();
283
+ for (const id of ids) {
284
+ const model = gfx.getElementById(id);
285
+ if (model instanceof GfxPrimitiveElementModel ||
286
+ model instanceof GfxBlockElementModel) {
287
+ carriers.add(layerCarrierOf(model));
288
+ }
289
+ }
290
+ const targets = [...carriers].filter(model => (ownLayerOf(model) ?? DEFAULT_LAYER_ID) !== layerId);
291
+ if (!targets.length)
292
+ return 0;
293
+ std.store.captureSync();
294
+ std.store.transact(() => {
295
+ for (const model of targets)
296
+ writeModelLayer(std, model, layerId);
297
+ });
298
+ return targets.length;
299
+ }
@@ -0,0 +1,20 @@
1
+ import { LifeCycleWatcher } from '../../../std/index.js';
2
+ /**
3
+ * The layer new elements land in, for THIS viewer (ADR 0031 §6): the one
4
+ * selected in the selection pane, or the default layer.
5
+ *
6
+ * Per viewer and per session — never stored, in the document or anywhere
7
+ * else: a reload starts on the default layer. A layer deleted or never
8
+ * created on this surface resolves to the default layer, so a stale choice
9
+ * cannot send new elements to a dangling id.
10
+ */
11
+ export declare class CanvasActiveLayer extends LifeCycleWatcher {
12
+ static key: string;
13
+ /** The chosen layer id, as chosen; read {@link resolve} for the effective one. */
14
+ readonly chosen$: import("@preact/signals-core").Signal<string>;
15
+ private get _surface();
16
+ /** The layer a new element lands in: the chosen one if it still exists. */
17
+ resolve(): string;
18
+ /** Make `id` the active layer for this viewer. */
19
+ choose(id: string): void;
20
+ }
@@ -0,0 +1,34 @@
1
+ import { LifeCycleWatcher } from '../../../std/index.js';
2
+ import { DEFAULT_LAYER_ID, GfxControllerIdentifier, } from '../../../std/gfx/index.js';
3
+ import { signal } from '@preact/signals-core';
4
+ /**
5
+ * The layer new elements land in, for THIS viewer (ADR 0031 §6): the one
6
+ * selected in the selection pane, or the default layer.
7
+ *
8
+ * Per viewer and per session — never stored, in the document or anywhere
9
+ * else: a reload starts on the default layer. A layer deleted or never
10
+ * created on this surface resolves to the default layer, so a stale choice
11
+ * cannot send new elements to a dangling id.
12
+ */
13
+ export class CanvasActiveLayer extends LifeCycleWatcher {
14
+ constructor() {
15
+ super(...arguments);
16
+ /** The chosen layer id, as chosen; read {@link resolve} for the effective one. */
17
+ this.chosen$ = signal(DEFAULT_LAYER_ID);
18
+ }
19
+ static { this.key = 'canvas-active-layer'; }
20
+ get _surface() {
21
+ return this.std.get(GfxControllerIdentifier).surface;
22
+ }
23
+ /** The layer a new element lands in: the chosen one if it still exists. */
24
+ resolve() {
25
+ const chosen = this.chosen$.value;
26
+ if (chosen === DEFAULT_LAYER_ID)
27
+ return DEFAULT_LAYER_ID;
28
+ return this._surface?.props.layers?.[chosen] ? chosen : DEFAULT_LAYER_ID;
29
+ }
30
+ /** Make `id` the active layer for this viewer. */
31
+ choose(id) {
32
+ this.chosen$.value = id;
33
+ }
34
+ }
@@ -0,0 +1,67 @@
1
+ import type { AnyCommandDescriptor, BlockStdScope } from '../../../std/index.js';
2
+ import { z } from 'zod';
3
+ /**
4
+ * The user layers' commands (ADR 0031 §12), `owner: 'core'`, on the palette
5
+ * and the agent. The library's pane runs them through `runCommand`, and so
6
+ * does a host's: the read-only refusal and the undo step live in the
7
+ * actions, once.
8
+ *
9
+ * Each self-emits `CanvasLayerChanged` (see the telemetry README) when it
10
+ * wrote something — ids and counts only, never a layer name.
11
+ */
12
+ export type CanvasLayerAction = 'create' | 'rename' | 'reorder' | 'delete' | 'move-elements';
13
+ export declare function reportLayerChange(std: BlockStdScope, action: CanvasLayerAction, memberCount?: number): void;
14
+ export declare const createLayerParams: z.ZodObject<{
15
+ /** Omitted: the seeded name, "Layer n". */
16
+ name: z.ZodOptional<z.ZodString>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ name?: string | undefined;
19
+ }, {
20
+ name?: string | undefined;
21
+ }>;
22
+ export type CreateLayerParams = z.infer<typeof createLayerParams>;
23
+ export declare const renameLayerParams: z.ZodObject<{
24
+ id: z.ZodString;
25
+ name: z.ZodString;
26
+ }, "strip", z.ZodTypeAny, {
27
+ name: string;
28
+ id: string;
29
+ }, {
30
+ name: string;
31
+ id: string;
32
+ }>;
33
+ export type RenameLayerParams = z.infer<typeof renameLayerParams>;
34
+ export declare const reorderLayerParams: z.ZodObject<{
35
+ id: z.ZodString;
36
+ /** The layer it lands directly ABOVE; `null` puts it at the bottom. */
37
+ above: z.ZodNullable<z.ZodString>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ id: string;
40
+ above: string | null;
41
+ }, {
42
+ id: string;
43
+ above: string | null;
44
+ }>;
45
+ export type ReorderLayerParams = z.infer<typeof reorderLayerParams>;
46
+ export declare const moveElementsToLayerParams: z.ZodObject<{
47
+ /** Omitted: the current canvas selection. */
48
+ ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
49
+ layerId: z.ZodString;
50
+ }, "strip", z.ZodTypeAny, {
51
+ layerId: string;
52
+ ids?: string[] | undefined;
53
+ }, {
54
+ layerId: string;
55
+ ids?: string[] | undefined;
56
+ }>;
57
+ export type MoveElementsToLayerParams = z.infer<typeof moveElementsToLayerParams>;
58
+ export declare const deleteLayerParams: z.ZodObject<{
59
+ /** The layer to delete; `'@default'` is refused. */
60
+ id: z.ZodString;
61
+ }, "strip", z.ZodTypeAny, {
62
+ id: string;
63
+ }, {
64
+ id: string;
65
+ }>;
66
+ export type DeleteLayerParams = z.infer<typeof deleteLayerParams>;
67
+ export declare const userLayerCommands: AnyCommandDescriptor[];
@@ -0,0 +1,172 @@
1
+ import { TelemetryProvider } from '../../../affine-shared/services/index.js';
2
+ import { DEFAULT_LAYER_ID, GfxControllerIdentifier } from '../../../std/gfx/index.js';
3
+ import { z } from 'zod';
4
+ import { createUserLayer, deleteUserLayer, moveModelsToUserLayer, renameUserLayer, reorderUserLayer, userLayersBottomUp, } from './actions.js';
5
+ export function reportLayerChange(std, action, memberCount) {
6
+ const layerCount = userLayersBottomUp(std.get(GfxControllerIdentifier).surface).length;
7
+ std.getOptional(TelemetryProvider)?.track('CanvasLayerChanged', {
8
+ page: 'whiteboard editor',
9
+ action,
10
+ layerCount,
11
+ ...(memberCount === undefined ? {} : { memberCount }),
12
+ });
13
+ }
14
+ export const createLayerParams = z.object({
15
+ /** Omitted: the seeded name, "Layer n". */
16
+ name: z.string().optional(),
17
+ });
18
+ const createLayer = {
19
+ id: 'canvas.layer.create',
20
+ owner: 'core',
21
+ kind: 'action',
22
+ labelKey: 'com.labre.command.canvas.layer.create',
23
+ labelFallback: 'New layer',
24
+ descriptionKey: 'com.labre.command.canvas.layer.create.description',
25
+ descriptionFallback: 'Add a layer on top of the others. New elements go into it until you choose another.',
26
+ keywords: ['layer', 'calque'],
27
+ surfaces: ['palette', 'agent'],
28
+ scope: 'edgeless',
29
+ defaultKeys: { mac: [], other: [] },
30
+ availability: 'editable',
31
+ params: createLayerParams,
32
+ run: (std, _invocation, params) => {
33
+ const parsed = createLayerParams.safeParse(params ?? {});
34
+ if (!parsed.success)
35
+ return;
36
+ if (createUserLayer(std, parsed.data.name) === null)
37
+ return;
38
+ reportLayerChange(std, 'create');
39
+ },
40
+ };
41
+ export const renameLayerParams = z.object({
42
+ id: z.string().min(1),
43
+ name: z.string(),
44
+ });
45
+ const renameLayer = {
46
+ id: 'canvas.layer.rename',
47
+ owner: 'core',
48
+ kind: 'action',
49
+ labelKey: 'com.labre.command.canvas.layer.rename',
50
+ labelFallback: 'Rename layer',
51
+ descriptionKey: 'com.labre.command.canvas.layer.rename.description',
52
+ descriptionFallback: 'Give a layer a new name.',
53
+ surfaces: ['agent'],
54
+ scope: 'edgeless',
55
+ defaultKeys: { mac: [], other: [] },
56
+ availability: 'editable',
57
+ params: renameLayerParams,
58
+ run: (std, _invocation, params) => {
59
+ const parsed = renameLayerParams.safeParse(params);
60
+ if (!parsed.success) {
61
+ console.error('canvas.layer.rename: invalid params', parsed.error);
62
+ return;
63
+ }
64
+ if (!renameUserLayer(std, parsed.data.id, parsed.data.name))
65
+ return;
66
+ reportLayerChange(std, 'rename');
67
+ },
68
+ };
69
+ export const reorderLayerParams = z.object({
70
+ id: z.string().min(1),
71
+ /** The layer it lands directly ABOVE; `null` puts it at the bottom. */
72
+ above: z.string().min(1).nullable(),
73
+ });
74
+ const reorderLayer = {
75
+ id: 'canvas.layer.reorder',
76
+ owner: 'core',
77
+ kind: 'action',
78
+ labelKey: 'com.labre.command.canvas.layer.reorder',
79
+ labelFallback: 'Move layer',
80
+ descriptionKey: 'com.labre.command.canvas.layer.reorder.description',
81
+ descriptionFallback: 'Place a layer directly above another one: everything in it stacks there.',
82
+ surfaces: ['agent'],
83
+ scope: 'edgeless',
84
+ defaultKeys: { mac: [], other: [] },
85
+ availability: 'editable',
86
+ params: reorderLayerParams,
87
+ run: (std, _invocation, params) => {
88
+ const parsed = reorderLayerParams.safeParse(params);
89
+ if (!parsed.success) {
90
+ console.error('canvas.layer.reorder: invalid params', parsed.error);
91
+ return;
92
+ }
93
+ if (!reorderUserLayer(std, parsed.data.id, parsed.data.above))
94
+ return;
95
+ reportLayerChange(std, 'reorder');
96
+ },
97
+ };
98
+ export const moveElementsToLayerParams = z.object({
99
+ /** Omitted: the current canvas selection. */
100
+ ids: z.array(z.string()).optional(),
101
+ layerId: z.string().min(1),
102
+ });
103
+ const moveElementsToLayer = {
104
+ id: 'canvas.layer.moveElements',
105
+ owner: 'core',
106
+ kind: 'action',
107
+ labelKey: 'com.labre.command.canvas.layer.move-elements',
108
+ labelFallback: 'Move to layer',
109
+ descriptionKey: 'com.labre.command.canvas.layer.move-elements.description',
110
+ descriptionFallback: 'Move the selected elements to another layer. A grouped element moves with its group.',
111
+ surfaces: ['agent'],
112
+ scope: 'edgeless',
113
+ defaultKeys: { mac: [], other: [] },
114
+ availability: 'editable',
115
+ params: moveElementsToLayerParams,
116
+ run: (std, _invocation, params) => {
117
+ const parsed = moveElementsToLayerParams.safeParse(params);
118
+ if (!parsed.success) {
119
+ console.error('canvas.layer.moveElements: invalid params', parsed.error);
120
+ return;
121
+ }
122
+ const ids = parsed.data.ids ?? std.get(GfxControllerIdentifier).selection.selectedIds;
123
+ const count = moveModelsToUserLayer(std, ids, parsed.data.layerId);
124
+ if (!count)
125
+ return;
126
+ reportLayerChange(std, 'move-elements', count);
127
+ },
128
+ };
129
+ export const deleteLayerParams = z.object({
130
+ /** The layer to delete; `'@default'` is refused. */
131
+ id: z.string().min(1),
132
+ });
133
+ /**
134
+ * Delete a layer and everything in it, in one undo step (ADR 0031 §10). The
135
+ * default layer cannot be deleted, which is what keeps a canvas at one layer
136
+ * at least (ADR 0031 amendments): with the default layer alone — recorded or
137
+ * not — there is nothing to delete, so `when` withdraws the command rather
138
+ * than letting it fail.
139
+ */
140
+ const deleteLayer = {
141
+ id: 'canvas.layer.delete',
142
+ owner: 'core',
143
+ kind: 'action',
144
+ labelKey: 'com.labre.command.canvas.layer.delete',
145
+ labelFallback: 'Delete layer',
146
+ descriptionKey: 'com.labre.command.canvas.layer.delete.description',
147
+ descriptionFallback: 'Delete a layer and every element in it. One undo brings them all back.',
148
+ surfaces: ['agent'],
149
+ scope: 'edgeless',
150
+ defaultKeys: { mac: [], other: [] },
151
+ availability: 'editable',
152
+ when: std => userLayersBottomUp(std.get(GfxControllerIdentifier).surface).some(layer => layer.id !== DEFAULT_LAYER_ID),
153
+ params: deleteLayerParams,
154
+ run: (std, _invocation, params) => {
155
+ const parsed = deleteLayerParams.safeParse(params);
156
+ if (!parsed.success) {
157
+ console.error('canvas.layer.delete: invalid params', parsed.error);
158
+ return;
159
+ }
160
+ const removed = deleteUserLayer(std, parsed.data.id);
161
+ if (removed === null)
162
+ return;
163
+ reportLayerChange(std, 'delete', removed);
164
+ },
165
+ };
166
+ export const userLayerCommands = [
167
+ createLayer,
168
+ renameLayer,
169
+ reorderLayer,
170
+ moveElementsToLayer,
171
+ deleteLayer,
172
+ ];