@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
@@ -11,6 +11,10 @@ export type BaseElementProps = {
11
11
  index: string;
12
12
  seed: number;
13
13
  lockedBySelf?: boolean;
14
+ /** See {@link GfxPrimitiveElementModel.hiddenForEveryone}. */
15
+ hiddenForEveryone?: true;
16
+ /** See {@link GfxPrimitiveElementModel.layer}. */
17
+ layer?: string;
14
18
  /** See {@link GfxPrimitiveElementModel.pivotDocId}. */
15
19
  pivotDocId?: string;
16
20
  /** See {@link GfxPrimitiveElementModel.role}. */
@@ -252,6 +256,29 @@ export declare abstract class GfxPrimitiveElementModel<Props extends BaseElement
252
256
  */
253
257
  accessor externalXYWH: SerializedXYWH | undefined;
254
258
  accessor hidden: boolean;
259
+ /**
260
+ * "Hide for everyone" (ADR 0031 §7): stored, synced, and NOT {@link hidden},
261
+ * which mindmap collapse owns and clears on expand — expanding a branch must
262
+ * never unhide what somebody hid for everyone.
263
+ *
264
+ * `true` or absent, never `false`: unhiding goes through {@link clearField},
265
+ * which removes the key, so a document goes back to byte-identical. Declared
266
+ * on the BASE class for the reason {@link role} is: an element re-created
267
+ * from props (paste, duplicate, template) reaches the Y.Map only through
268
+ * declared keys. Read by the paint and pick predicate
269
+ * (`GfxController.hiddenForEveryone`), never by `grid.search`: rules,
270
+ * legends and semantic exports still count a hidden element.
271
+ */
272
+ accessor hiddenForEveryone: true | undefined;
273
+ /**
274
+ * The user layer this element belongs to (ADR 0031 §3): a key of the
275
+ * surface's `layers`, or `undefined` for the default layer — never the
276
+ * string `'@default'`. A dangling id reads as the default layer and is never
277
+ * dropped. Ignored while the element is inside a group or a mindmap: the
278
+ * outermost one's `layer` decides. Declared on the BASE class for the reason
279
+ * {@link role} is. Clearing goes through {@link clearField}.
280
+ */
281
+ accessor layer: string | undefined;
255
282
  accessor index: string;
256
283
  /**
257
284
  * Minimal link target attached to the element. At most one is set.
@@ -590,6 +617,13 @@ export declare abstract class GfxGroupLikeElementModel<Props extends BaseElement
590
617
  */
591
618
  setChildIds(value: string[], fromLocal: boolean): void;
592
619
  }
620
+ /**
621
+ * Whether `model` itself carries the stored "hide for everyone" (ADR 0031 §7):
622
+ * the `@field()` on an element, the `prop:` on a gfx block. Not reactive, and
623
+ * not inherited — a member of a hidden group answers `false` here; the paint
624
+ * and pick predicate (`GfxLocalVisibility.isHidden`) walks the ancestors.
625
+ */
626
+ export declare function isStoredHiddenForEveryone(model: unknown): boolean;
593
627
  export declare function syncElementFromY(model: GfxPrimitiveElementModel, callback: (payload: {
594
628
  props: Record<string, unknown>;
595
629
  oldValues: Record<string, unknown>;
@@ -105,6 +105,12 @@ let GfxPrimitiveElementModel = (() => {
105
105
  let _hidden_decorators;
106
106
  let _hidden_initializers = [];
107
107
  let _hidden_extraInitializers = [];
108
+ let _hiddenForEveryone_decorators;
109
+ let _hiddenForEveryone_initializers = [];
110
+ let _hiddenForEveryone_extraInitializers = [];
111
+ let _layer_decorators;
112
+ let _layer_initializers = [];
113
+ let _layer_extraInitializers = [];
108
114
  let _index_decorators;
109
115
  let _index_initializers = [];
110
116
  let _index_extraInitializers = [];
@@ -155,6 +161,8 @@ let GfxPrimitiveElementModel = (() => {
155
161
  instance['_local'].delete('externalBound');
156
162
  }), local()];
157
163
  _hidden_decorators = [field(false)];
164
+ _hiddenForEveryone_decorators = [field()];
165
+ _layer_decorators = [field()];
158
166
  _index_decorators = [field()];
159
167
  _externalLink_decorators = [field()];
160
168
  _linkedDocId_decorators = [field()];
@@ -172,6 +180,8 @@ let GfxPrimitiveElementModel = (() => {
172
180
  __esDecorate(this, null, _display_decorators, { kind: "accessor", name: "display", static: false, private: false, access: { has: obj => "display" in obj, get: obj => obj.display, set: (obj, value) => { obj.display = value; } }, metadata: _metadata }, _display_initializers, _display_extraInitializers);
173
181
  __esDecorate(this, null, _externalXYWH_decorators, { kind: "accessor", name: "externalXYWH", static: false, private: false, access: { has: obj => "externalXYWH" in obj, get: obj => obj.externalXYWH, set: (obj, value) => { obj.externalXYWH = value; } }, metadata: _metadata }, _externalXYWH_initializers, _externalXYWH_extraInitializers);
174
182
  __esDecorate(this, null, _hidden_decorators, { kind: "accessor", name: "hidden", static: false, private: false, access: { has: obj => "hidden" in obj, get: obj => obj.hidden, set: (obj, value) => { obj.hidden = value; } }, metadata: _metadata }, _hidden_initializers, _hidden_extraInitializers);
183
+ __esDecorate(this, null, _hiddenForEveryone_decorators, { kind: "accessor", name: "hiddenForEveryone", static: false, private: false, access: { has: obj => "hiddenForEveryone" in obj, get: obj => obj.hiddenForEveryone, set: (obj, value) => { obj.hiddenForEveryone = value; } }, metadata: _metadata }, _hiddenForEveryone_initializers, _hiddenForEveryone_extraInitializers);
184
+ __esDecorate(this, null, _layer_decorators, { kind: "accessor", name: "layer", static: false, private: false, access: { has: obj => "layer" in obj, get: obj => obj.layer, set: (obj, value) => { obj.layer = value; } }, metadata: _metadata }, _layer_initializers, _layer_extraInitializers);
175
185
  __esDecorate(this, null, _index_decorators, { kind: "accessor", name: "index", static: false, private: false, access: { has: obj => "index" in obj, get: obj => obj.index, set: (obj, value) => { obj.index = value; } }, metadata: _metadata }, _index_initializers, _index_extraInitializers);
176
186
  __esDecorate(this, null, _externalLink_decorators, { kind: "accessor", name: "externalLink", static: false, private: false, access: { has: obj => "externalLink" in obj, get: obj => obj.externalLink, set: (obj, value) => { obj.externalLink = value; } }, metadata: _metadata }, _externalLink_initializers, _externalLink_extraInitializers);
177
187
  __esDecorate(this, null, _linkedDocId_decorators, { kind: "accessor", name: "linkedDocId", static: false, private: false, access: { has: obj => "linkedDocId" in obj, get: obj => obj.linkedDocId, set: (obj, value) => { obj.linkedDocId = value; } }, metadata: _metadata }, _linkedDocId_initializers, _linkedDocId_extraInitializers);
@@ -261,7 +271,9 @@ let GfxPrimitiveElementModel = (() => {
261
271
  this.#display_accessor_storage = __runInitializers(this, _display_initializers, true);
262
272
  this.#externalXYWH_accessor_storage = (__runInitializers(this, _display_extraInitializers), __runInitializers(this, _externalXYWH_initializers, undefined));
263
273
  this.#hidden_accessor_storage = (__runInitializers(this, _externalXYWH_extraInitializers), __runInitializers(this, _hidden_initializers, false));
264
- this.#index_accessor_storage = (__runInitializers(this, _hidden_extraInitializers), __runInitializers(this, _index_initializers, void 0));
274
+ this.#hiddenForEveryone_accessor_storage = (__runInitializers(this, _hidden_extraInitializers), __runInitializers(this, _hiddenForEveryone_initializers, undefined));
275
+ this.#layer_accessor_storage = (__runInitializers(this, _hiddenForEveryone_extraInitializers), __runInitializers(this, _layer_initializers, undefined));
276
+ this.#index_accessor_storage = (__runInitializers(this, _layer_extraInitializers), __runInitializers(this, _index_initializers, void 0));
265
277
  this.#externalLink_accessor_storage = (__runInitializers(this, _index_extraInitializers), __runInitializers(this, _externalLink_initializers, undefined));
266
278
  this.#linkedDocId_accessor_storage = (__runInitializers(this, _externalLink_extraInitializers), __runInitializers(this, _linkedDocId_initializers, undefined));
267
279
  this.#pivotDocId_accessor_storage = (__runInitializers(this, _linkedDocId_extraInitializers), __runInitializers(this, _pivotDocId_initializers, undefined));
@@ -463,6 +475,33 @@ let GfxPrimitiveElementModel = (() => {
463
475
  #hidden_accessor_storage;
464
476
  get hidden() { return this.#hidden_accessor_storage; }
465
477
  set hidden(value) { this.#hidden_accessor_storage = value; }
478
+ #hiddenForEveryone_accessor_storage;
479
+ /**
480
+ * "Hide for everyone" (ADR 0031 §7): stored, synced, and NOT {@link hidden},
481
+ * which mindmap collapse owns and clears on expand — expanding a branch must
482
+ * never unhide what somebody hid for everyone.
483
+ *
484
+ * `true` or absent, never `false`: unhiding goes through {@link clearField},
485
+ * which removes the key, so a document goes back to byte-identical. Declared
486
+ * on the BASE class for the reason {@link role} is: an element re-created
487
+ * from props (paste, duplicate, template) reaches the Y.Map only through
488
+ * declared keys. Read by the paint and pick predicate
489
+ * (`GfxController.hiddenForEveryone`), never by `grid.search`: rules,
490
+ * legends and semantic exports still count a hidden element.
491
+ */
492
+ get hiddenForEveryone() { return this.#hiddenForEveryone_accessor_storage; }
493
+ set hiddenForEveryone(value) { this.#hiddenForEveryone_accessor_storage = value; }
494
+ #layer_accessor_storage;
495
+ /**
496
+ * The user layer this element belongs to (ADR 0031 §3): a key of the
497
+ * surface's `layers`, or `undefined` for the default layer — never the
498
+ * string `'@default'`. A dangling id reads as the default layer and is never
499
+ * dropped. Ignored while the element is inside a group or a mindmap: the
500
+ * outermost one's `layer` decides. Declared on the BASE class for the reason
501
+ * {@link role} is. Clearing goes through {@link clearField}.
502
+ */
503
+ get layer() { return this.#layer_accessor_storage; }
504
+ set layer(value) { this.#layer_accessor_storage = value; }
466
505
  #index_accessor_storage;
467
506
  get index() { return this.#index_accessor_storage; }
468
507
  set index(value) { this.#index_accessor_storage = value; }
@@ -844,6 +883,12 @@ export class GfxGroupLikeElementModel extends GfxPrimitiveElementModel {
844
883
  if (child instanceof GfxPrimitiveElementModel && child.hidden) {
845
884
  return;
846
885
  }
886
+ // A member hidden for everyone is not painted, so it does not stretch
887
+ // the group's box either (ADR 0031 §9). A local hide does: the bound is
888
+ // computed once for every viewer.
889
+ if (isStoredHiddenForEveryone(child)) {
890
+ return;
891
+ }
847
892
  bound = bound ? bound.unite(child.elementBound) : child.elementBound;
848
893
  });
849
894
  return bound ?? new Bound(0, 0, 0, 0);
@@ -902,6 +947,25 @@ export class GfxGroupLikeElementModel extends GfxPrimitiveElementModel {
902
947
  });
903
948
  }
904
949
  }
950
+ /**
951
+ * Whether `model` itself carries the stored "hide for everyone" (ADR 0031 §7):
952
+ * the `@field()` on an element, the `prop:` on a gfx block. Not reactive, and
953
+ * not inherited — a member of a hidden group answers `false` here; the paint
954
+ * and pick predicate (`GfxLocalVisibility.isHidden`) walks the ancestors.
955
+ */
956
+ export function isStoredHiddenForEveryone(model) {
957
+ if (model instanceof GfxPrimitiveElementModel) {
958
+ return model.hiddenForEveryone === true;
959
+ }
960
+ try {
961
+ const props = model.props;
962
+ return props?.hiddenForEveryone === true;
963
+ }
964
+ catch {
965
+ // A block model outside a flat store has no `props` to read.
966
+ return false;
967
+ }
968
+ }
905
969
  export function syncElementFromY(model, callback) {
906
970
  const disposables = {};
907
971
  const observer = (event, transaction) => {
@@ -77,12 +77,17 @@ export interface EdgeDirectionDef {
77
77
  gestureHintFallback?: string;
78
78
  /**
79
79
  * CSS colour of the chip the reveal draws this verb in (M2). Absent — which
80
- * is every role but one — keeps the house affordance blue the mechanism has
81
- * always used, so declaring nothing repaints nothing.
80
+ * is every role today — leaves the chip on the chrome's accent token, so
81
+ * every typed edge of every framework wears one blue and follows a host
82
+ * re-skin with the rest of the chrome.
82
83
  *
83
- * A colour belongs to the ROLE rather than to the widget because the chip is
84
- * per-relation: the PO may want one framework's central relation to stand out
85
- * without every other framework's edges changing with it. The chip's text is
84
+ * An extension point, deliberately unused. One role took it (PR #203) so its
85
+ * framework's central relation would stand out, and the result on a map
86
+ * carrying two typed relations was two different blues, with nothing
87
+ * comparing them. Reversed on the PO recette of 23/09/2026; the field stays
88
+ * because a framework may one day have a real reason to claim its own, and
89
+ * `affine/all/src/__tests__/direction-chip-accent.unit.spec.ts` is what makes
90
+ * that a reviewed decision rather than a silent one. The chip's text is
86
91
  * white, so a colour declared here must be dark enough to carry it.
87
92
  */
88
93
  chipColor?: string;
@@ -7,6 +7,7 @@ import { type GfxGroupCompatibleInterface } from '../base.js';
7
7
  import type { GfxGroupModel, GfxModel } from '../model.js';
8
8
  import { type GfxPrimitiveElementModel } from './element-model.js';
9
9
  import type { GfxLocalElementModel } from './local-element-model.js';
10
+ import { type SurfaceLayerRecord, SurfaceUserLayers } from './user-layers.js';
10
11
  /**
11
12
  * Used for text field
12
13
  */
@@ -17,6 +18,20 @@ export declare const SURFACE_TEXT_UNIQ_IDENTIFIER = "affine:surface:text";
17
18
  export declare const SURFACE_YMAP_UNIQ_IDENTIFIER = "affine:surface:ymap";
18
19
  export type SurfaceBlockProps = {
19
20
  elements: Boxed<Y.Map<Y.Map<unknown>>>;
21
+ /**
22
+ * The canvas grid, saved for everyone by "Save for everyone" (ADR 0031
23
+ * §2, §11). Absent = nobody decided: the viewer's override, the host
24
+ * default and the library default decide, in that order. Declared with an
25
+ * `undefined` default so loading a document writes nothing.
26
+ */
27
+ showGrid?: boolean;
28
+ /**
29
+ * User layers by id (ADR 0031 §2). Absent until the first layer is
30
+ * created; every write sets ONE record or ONE field of a record, never the
31
+ * whole prop, so two peers' edits merge key by key. Declared with an
32
+ * `undefined` default so loading a document writes nothing.
33
+ */
34
+ layers?: Record<string, SurfaceLayerRecord>;
20
35
  };
21
36
  export interface ElementUpdatedData {
22
37
  id: string;
@@ -84,6 +99,12 @@ export declare class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
84
99
  local: boolean;
85
100
  }>;
86
101
  elementUpdated: Subject<ElementUpdatedData>;
102
+ /**
103
+ * The user layers of this surface, resolved for stacking (ADR 0031 §4).
104
+ * Read by `compare`; `userLayers.ranks` is `null` while the document has no
105
+ * layer, and then nothing else here is ever asked.
106
+ */
107
+ readonly userLayers: SurfaceUserLayers;
87
108
  /**
88
109
  * An element was found damaged — see {@link damagedElements}. Pushed at the
89
110
  * same moment the console line is written, so a subscriber that arrives
@@ -183,6 +204,12 @@ export declare class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
183
204
  private _watchChildrenChange;
184
205
  protected _extendElement(ctorMap: Record<string, Constructor<GfxPrimitiveElementModel, ConstructorParameters<typeof GfxPrimitiveElementModel>>>): void;
185
206
  protected _init(): void;
207
+ /**
208
+ * Keeps {@link userLayers}' caches honest (ADR 0031 §4): the ranks follow
209
+ * the `layers` prop, the effective layers follow every `layer` write, every
210
+ * regroup and every element added or removed.
211
+ */
212
+ private _watchUserLayers;
186
213
  getConstructor(type: string): Constructor<GfxPrimitiveElementModel<import("./element-model.js").BaseElementProps>, [options: {
187
214
  id: string;
188
215
  yMap: Y.Map<unknown>;
@@ -9,6 +9,7 @@ import { createDecoratorState } from './decorators/common.js';
9
9
  import { getFieldPropsSet, getLocalPropsSet, initializeObservers, initializeWatchers, } from './decorators/index.js';
10
10
  import { GfxGroupLikeElementModel, syncElementFromY, } from './element-model.js';
11
11
  import { tagsPropToY } from './tags.js';
12
+ import { registerSurfaceOfStore, SurfaceUserLayers, } from './user-layers.js';
12
13
  /**
13
14
  * Used for text field
14
15
  */
@@ -188,6 +189,8 @@ export class SurfaceBlockModel extends BlockModel {
188
189
  'xywh',
189
190
  'rotate',
190
191
  'hidden',
192
+ // ADR 0031 §9: a member hidden for everyone leaves the group's bound.
193
+ 'hiddenForEveryone',
191
194
  ]); }
192
195
  /**
193
196
  * The elements this surface built from a Y.Map that was missing a key it
@@ -234,6 +237,12 @@ export class SurfaceBlockModel extends BlockModel {
234
237
  this.elementAdded = new Subject();
235
238
  this.elementRemoved = new Subject();
236
239
  this.elementUpdated = new Subject();
240
+ /**
241
+ * The user layers of this surface, resolved for stacking (ADR 0031 §4).
242
+ * Read by `compare`; `userLayers.ranks` is `null` while the document has no
243
+ * layer, and then nothing else here is ever asked.
244
+ */
245
+ this.userLayers = new SurfaceUserLayers(this);
237
246
  /**
238
247
  * An element was found damaged — see {@link damagedElements}. Pushed at the
239
248
  * same moment the console line is written, so a subscriber that arrives
@@ -657,6 +666,40 @@ export class SurfaceBlockModel extends BlockModel {
657
666
  this._initElementModels();
658
667
  this._watchGroupRelationChange();
659
668
  this._watchChildrenChange();
669
+ this._watchUserLayers();
670
+ }
671
+ /**
672
+ * Keeps {@link userLayers}' caches honest (ADR 0031 §4): the ranks follow
673
+ * the `layers` prop, the effective layers follow every `layer` write, every
674
+ * regroup and every element added or removed.
675
+ */
676
+ _watchUserLayers() {
677
+ registerSurfaceOfStore(this.store, this);
678
+ const membership = () => this.userLayers.invalidateMembership();
679
+ const subscriptions = [
680
+ this.propsUpdated.subscribe(({ key }) => {
681
+ if (key === 'layers')
682
+ this.userLayers.invalidateRanks();
683
+ }),
684
+ this.elementAdded.subscribe(membership),
685
+ this.elementRemoved.subscribe(membership),
686
+ this.elementUpdated.subscribe(({ props, oldValues }) => {
687
+ if ('layer' in props ||
688
+ 'layer' in oldValues ||
689
+ 'childIds' in props ||
690
+ 'childIds' in oldValues) {
691
+ membership();
692
+ }
693
+ }),
694
+ this.store.slots.blockUpdated.subscribe(payload => {
695
+ if (payload.type !== 'update' || payload.props.key === 'layer') {
696
+ membership();
697
+ }
698
+ }),
699
+ ];
700
+ this.deleted.subscribe(() => {
701
+ subscriptions.forEach(subscription => subscription.unsubscribe());
702
+ });
660
703
  }
661
704
  getConstructor(type) {
662
705
  return this._elementCtorMap[type];
@@ -0,0 +1,68 @@
1
+ import type { Store } from '../../../../store/index.js';
2
+ import type { GfxModel } from '../model.js';
3
+ import type { SurfaceBlockModel } from './surface-model.js';
4
+ /**
5
+ * The layer every element belongs to while it names none (ADR 0031 §2, §3).
6
+ * A `@` cannot appear in a nanoid, so it never collides with a real layer id;
7
+ * it has no record while the surface has no `layers`, and is written as
8
+ * `undefined` on an element, never as this string.
9
+ */
10
+ export declare const DEFAULT_LAYER_ID = "@default";
11
+ /** One user layer, stored on the surface under its id (ADR 0031 §2). */
12
+ export type SurfaceLayerRecord = {
13
+ /** Seeded through the translation seam at creation; content from then on. */
14
+ name: string;
15
+ /** Fractional key, bottom → top; the same alphabet as an element's `index`. */
16
+ index: string;
17
+ /** "Hide for everyone" on the whole layer. Absent = visible. */
18
+ hidden?: true;
19
+ };
20
+ /**
21
+ * What a model names as its own layer: an element's `layer` field, a gfx
22
+ * block's `layer` prop. `undefined` = the default layer.
23
+ */
24
+ export declare function ownLayerOf(model: unknown): string | undefined;
25
+ /**
26
+ * The model whose `layer` decides `model`'s (ADR 0031 §5): its outermost
27
+ * group-like ELEMENT ancestor (a group, a mindmap), else `model` itself. A
28
+ * group lives in one layer, stored once on its outermost group, so this is
29
+ * what {@link SurfaceUserLayers.effectiveLayerOf} reads and what a "move to
30
+ * layer" writes on. Frames are blocks and do not count. `groups` walks the
31
+ * model's surface, which throws on a detached model: that one carries itself.
32
+ */
33
+ export declare function layerCarrierOf(model: GfxModel): GfxModel;
34
+ /**
35
+ * The user layers of one surface, resolved for the comparator (ADR 0031 §4).
36
+ *
37
+ * Two caches, both thrown away by a revision bump rather than kept in step:
38
+ *
39
+ * - the rank of every layer id (its record's `index`), rebuilt when the
40
+ * `layers` prop changes — `null` while the surface has no layer, which is
41
+ * the fast path: `compare` then never asks for an effective layer at all;
42
+ * - each model's EFFECTIVE layer, rebuilt when anything that decides it
43
+ * changes: a `layer` write, a regroup, an element added or removed.
44
+ *
45
+ * The effective layer is the `layer` of the model's outermost group-like
46
+ * ELEMENT ancestor (a group, a mindmap), else its own; a dangling id or none
47
+ * is {@link DEFAULT_LAYER_ID}. Frames are not counted: a frame is a slide,
48
+ * and a background layer under a content layer inside one frame is the point
49
+ * of layers. Nothing here writes: a dangling id is read as the default and
50
+ * left as it is.
51
+ */
52
+ export declare class SurfaceUserLayers {
53
+ private readonly _surface;
54
+ private _ranks;
55
+ private _revision;
56
+ private readonly _effective;
57
+ constructor(_surface: SurfaceBlockModel);
58
+ /** Every layer id with its rank key, or `null` when there is no layer. */
59
+ get ranks(): ReadonlyMap<string, string> | null;
60
+ /** The `layers` record changed: ranks and effective layers are stale. */
61
+ invalidateRanks(): void;
62
+ /** Something that decides an effective layer changed. */
63
+ invalidateMembership(): void;
64
+ /** The layer `model` stacks and shows with. */
65
+ effectiveLayerOf(model: GfxModel): string;
66
+ }
67
+ export declare function registerSurfaceOfStore(store: Store, surface: SurfaceBlockModel): void;
68
+ export declare function userLayersOf(model: unknown): SurfaceUserLayers | null;
@@ -0,0 +1,127 @@
1
+ import { GfxPrimitiveElementModel } from './element-model.js';
2
+ /**
3
+ * The layer every element belongs to while it names none (ADR 0031 §2, §3).
4
+ * A `@` cannot appear in a nanoid, so it never collides with a real layer id;
5
+ * it has no record while the surface has no `layers`, and is written as
6
+ * `undefined` on an element, never as this string.
7
+ */
8
+ export const DEFAULT_LAYER_ID = '@default';
9
+ /**
10
+ * What a model names as its own layer: an element's `layer` field, a gfx
11
+ * block's `layer` prop. `undefined` = the default layer.
12
+ */
13
+ export function ownLayerOf(model) {
14
+ if (model instanceof GfxPrimitiveElementModel)
15
+ return model.layer;
16
+ try {
17
+ const props = model.props;
18
+ return typeof props?.layer === 'string' ? props.layer : undefined;
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
24
+ /**
25
+ * The model whose `layer` decides `model`'s (ADR 0031 §5): its outermost
26
+ * group-like ELEMENT ancestor (a group, a mindmap), else `model` itself. A
27
+ * group lives in one layer, stored once on its outermost group, so this is
28
+ * what {@link SurfaceUserLayers.effectiveLayerOf} reads and what a "move to
29
+ * layer" writes on. Frames are blocks and do not count. `groups` walks the
30
+ * model's surface, which throws on a detached model: that one carries itself.
31
+ */
32
+ export function layerCarrierOf(model) {
33
+ let groups = [];
34
+ try {
35
+ groups = model.groups ?? [];
36
+ }
37
+ catch {
38
+ groups = [];
39
+ }
40
+ for (let i = groups.length - 1; i >= 0; i--) {
41
+ if (groups[i] instanceof GfxPrimitiveElementModel) {
42
+ return groups[i];
43
+ }
44
+ }
45
+ return model;
46
+ }
47
+ /**
48
+ * The user layers of one surface, resolved for the comparator (ADR 0031 §4).
49
+ *
50
+ * Two caches, both thrown away by a revision bump rather than kept in step:
51
+ *
52
+ * - the rank of every layer id (its record's `index`), rebuilt when the
53
+ * `layers` prop changes — `null` while the surface has no layer, which is
54
+ * the fast path: `compare` then never asks for an effective layer at all;
55
+ * - each model's EFFECTIVE layer, rebuilt when anything that decides it
56
+ * changes: a `layer` write, a regroup, an element added or removed.
57
+ *
58
+ * The effective layer is the `layer` of the model's outermost group-like
59
+ * ELEMENT ancestor (a group, a mindmap), else its own; a dangling id or none
60
+ * is {@link DEFAULT_LAYER_ID}. Frames are not counted: a frame is a slide,
61
+ * and a background layer under a content layer inside one frame is the point
62
+ * of layers. Nothing here writes: a dangling id is read as the default and
63
+ * left as it is.
64
+ */
65
+ export class SurfaceUserLayers {
66
+ constructor(_surface) {
67
+ this._surface = _surface;
68
+ this._ranks = undefined;
69
+ this._revision = 0;
70
+ this._effective = new WeakMap();
71
+ }
72
+ /** Every layer id with its rank key, or `null` when there is no layer. */
73
+ get ranks() {
74
+ if (this._ranks === undefined) {
75
+ const layers = this._surface.props.layers;
76
+ if (!layers || Object.keys(layers).length === 0) {
77
+ this._ranks = null;
78
+ }
79
+ else {
80
+ const ranks = new Map();
81
+ for (const [id, record] of Object.entries(layers)) {
82
+ if (record && typeof record.index === 'string') {
83
+ ranks.set(id, record.index);
84
+ }
85
+ }
86
+ this._ranks = ranks.size ? ranks : null;
87
+ }
88
+ }
89
+ return this._ranks;
90
+ }
91
+ /** The `layers` record changed: ranks and effective layers are stale. */
92
+ invalidateRanks() {
93
+ this._ranks = undefined;
94
+ this._revision++;
95
+ }
96
+ /** Something that decides an effective layer changed. */
97
+ invalidateMembership() {
98
+ this._revision++;
99
+ }
100
+ /** The layer `model` stacks and shows with. */
101
+ effectiveLayerOf(model) {
102
+ const cached = this._effective.get(model);
103
+ if (cached && cached.revision === this._revision)
104
+ return cached.layer;
105
+ const named = ownLayerOf(layerCarrierOf(model));
106
+ const ranks = this.ranks;
107
+ const layer = named !== undefined && ranks?.has(named) ? named : DEFAULT_LAYER_ID;
108
+ this._effective.set(model, { revision: this._revision, layer });
109
+ return layer;
110
+ }
111
+ }
112
+ /**
113
+ * Which surface a model's layers are read from. An element knows its
114
+ * surface; a gfx block knows its store, and the surface registers itself for
115
+ * its store when it initialises, so the comparator never queries the store.
116
+ */
117
+ const SURFACE_OF_STORE = new WeakMap();
118
+ export function registerSurfaceOfStore(store, surface) {
119
+ SURFACE_OF_STORE.set(store, surface);
120
+ }
121
+ export function userLayersOf(model) {
122
+ if (model instanceof GfxPrimitiveElementModel) {
123
+ return model.surface?.userLayers ?? null;
124
+ }
125
+ const store = model.store;
126
+ return store ? (SURFACE_OF_STORE.get(store)?.userLayers ?? null) : null;
127
+ }
@@ -8,6 +8,16 @@ export declare function getLayerEndZIndex(layers: Layer[], layerIndex: number):
8
8
  export declare function updateLayersZIndex(layers: Layer[], startIdx: number): void;
9
9
  export declare function getElementIndex(indexable: GfxModel): string;
10
10
  export declare function ungroupIndex(index: string): string;
11
+ /**
12
+ * Insert `element` after every element that sorts before it or ties with it.
13
+ *
14
+ * The array is kept sorted by `compare`, so that predicate holds on a prefix
15
+ * and the position is found by bisection. The linear scan it replaces asked
16
+ * `compare` (which walks both elements' group chains) of every element on
17
+ * every insert: a paste of N elements was N² comparisons. Where an index is
18
+ * shared by two unrelated subtrees `compare` is not transitive and both pick
19
+ * a tied position, not always the same one (layer-ordered-insert.unit.spec).
20
+ */
11
21
  export declare function insertToOrderedArray(array: GfxModel[], element: GfxModel): void;
12
22
  export declare function removeFromOrderedArray(array: GfxModel[], element: GfxModel): void;
13
23
  export declare enum SortOrder {
@@ -1,6 +1,7 @@
1
1
  import { isGfxGroupCompatibleModel, } from '../gfx/model/base.js';
2
2
  import {} from '../gfx/model/gfx-block-model.js';
3
3
  import { GfxLocalElementModel } from '../gfx/model/surface/local-element-model.js';
4
+ import { userLayersOf } from '../gfx/model/surface/user-layers.js';
4
5
  export function getLayerEndZIndex(layers, layerIndex) {
5
6
  const layer = layers[layerIndex];
6
7
  return layer ? layer.zIndex + layer.elements.length - 1 : 0;
@@ -28,13 +29,29 @@ export function getElementIndex(indexable) {
28
29
  export function ungroupIndex(index) {
29
30
  return index.split('-')[0];
30
31
  }
32
+ /**
33
+ * Insert `element` after every element that sorts before it or ties with it.
34
+ *
35
+ * The array is kept sorted by `compare`, so that predicate holds on a prefix
36
+ * and the position is found by bisection. The linear scan it replaces asked
37
+ * `compare` (which walks both elements' group chains) of every element on
38
+ * every insert: a paste of N elements was N² comparisons. Where an index is
39
+ * shared by two unrelated subtrees `compare` is not transitive and both pick
40
+ * a tied position, not always the same one (layer-ordered-insert.unit.spec).
41
+ */
31
42
  export function insertToOrderedArray(array, element) {
32
- let idx = 0;
33
- while (idx < array.length &&
34
- [SortOrder.BEFORE, SortOrder.SAME].includes(compare(array[idx], element))) {
35
- ++idx;
43
+ let low = 0;
44
+ let high = array.length;
45
+ while (low < high) {
46
+ const mid = (low + high) >>> 1;
47
+ if (compare(array[mid], element) === SortOrder.AFTER) {
48
+ high = mid;
49
+ }
50
+ else {
51
+ low = mid + 1;
52
+ }
36
53
  }
37
- array.splice(idx, 0, element);
54
+ array.splice(low, 0, element);
38
55
  }
39
56
  export function removeFromOrderedArray(array, element) {
40
57
  const idx = array.indexOf(element);
@@ -74,10 +91,40 @@ function compareLocal(a, b) {
74
91
  if (isALocal && isBLocal && a.creator && a.creator === b.creator) {
75
92
  return compareIndex(a.index, b.index);
76
93
  }
77
- return {
78
- a: isALocal && a.creator ? a.creator : a,
79
- b: isBLocal && b.creator ? b.creator : b,
80
- };
94
+ const left = isALocal && a.creator ? a.creator : a;
95
+ const right = isBLocal && b.creator ? b.creator : b;
96
+ // ADR 0031 §4: user layer rank first, then everything below unchanged.
97
+ const byLayer = compareUserLayer(left, right);
98
+ if (byLayer !== SortOrder.SAME)
99
+ return byLayer;
100
+ return { a: left, b: right };
101
+ }
102
+ /**
103
+ * The first step of {@link compare} (ADR 0031 §4): two models in different
104
+ * user layers stack by their layers' `index`; anything else is `SAME`, and
105
+ * today's comparator decides.
106
+ *
107
+ * The fast path is the first `return`: a surface with no `layers` answers
108
+ * `null` ranks after one cached read, so a document without user layers
109
+ * sorts with exactly the code that sorted it before layers existed. A local
110
+ * element without a creator has no layer and keeps today's order — above the
111
+ * content, as overlays always were.
112
+ */
113
+ function compareUserLayer(a, b) {
114
+ if (a instanceof GfxLocalElementModel || b instanceof GfxLocalElementModel) {
115
+ return SortOrder.SAME;
116
+ }
117
+ const layers = userLayersOf(a);
118
+ const ranks = layers?.ranks;
119
+ if (!layers || !ranks)
120
+ return SortOrder.SAME;
121
+ const aLayer = layers.effectiveLayerOf(a);
122
+ const bLayer = layers.effectiveLayerOf(b);
123
+ if (aLayer === bLayer)
124
+ return SortOrder.SAME;
125
+ // A default layer with no record (the loser of a first-layer race, ADR
126
+ // 0031 open point 6) stacks at the bottom: `''` precedes every key.
127
+ return compareIndex(ranks.get(aLayer) ?? '', ranks.get(bLayer) ?? '');
81
128
  }
82
129
  /**
83
130
  * A comparator function for sorting elements in the surface.
@@ -91,15 +138,19 @@ export function compare(a, b) {
91
138
  }
92
139
  a = result.a;
93
140
  b = result.b;
94
- if (isGfxGroupCompatibleModel(a) && b.groups.includes(a)) {
141
+ // Each `groups` read walks the group chain through `getGroup`, a scan of
142
+ // every container on the surface: read each side once.
143
+ const aGroups = a.groups;
144
+ const bGroups = b.groups;
145
+ if (isGfxGroupCompatibleModel(a) &&
146
+ bGroups.includes(a)) {
95
147
  return SortOrder.BEFORE;
96
148
  }
97
- else if (isGfxGroupCompatibleModel(b) && a.groups.includes(b)) {
149
+ else if (isGfxGroupCompatibleModel(b) &&
150
+ aGroups.includes(b)) {
98
151
  return SortOrder.AFTER;
99
152
  }
100
153
  else {
101
- const aGroups = a.groups;
102
- const bGroups = b.groups;
103
154
  let i = 1;
104
155
  let aGroup = aGroups.at(-i);
105
156
  let bGroup = bGroups.at(-i);