@formicoidea/labre-core 0.43.1 → 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 (263) 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-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  17. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  18. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  19. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  20. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  21. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  22. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  23. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  24. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  25. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
  26. package/dist/_pkgs/affine-block-frame/frame-manager.js +48 -17
  27. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  28. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  29. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  30. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  31. package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
  32. package/dist/_pkgs/affine-block-note/translations.js +0 -5
  33. package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
  34. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  35. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  36. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  37. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  38. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  39. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  40. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  41. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  42. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  43. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  44. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  45. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  46. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  47. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  48. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  49. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  50. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  51. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  52. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  53. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  54. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  55. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  56. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  57. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  58. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  59. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  60. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  61. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  62. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  63. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  64. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  65. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  66. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  67. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  68. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  69. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  70. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  71. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  72. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  73. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  74. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  75. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  76. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
  77. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
  78. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  85. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +86 -15
  86. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  87. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  88. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  89. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  90. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  93. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  94. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  96. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  97. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  98. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  99. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  100. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  101. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  102. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  103. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  104. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  105. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  106. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  107. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  108. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  109. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  110. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  111. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  112. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  113. package/dist/_pkgs/affine-components/context-menu/button.js +14 -0
  114. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  115. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  116. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  117. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  118. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  119. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  120. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +2 -2
  121. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  122. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  123. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  124. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  125. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  126. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  127. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +3 -2
  128. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +1 -1
  129. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  130. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  131. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  132. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +1 -1
  133. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  134. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  135. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  136. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +2 -1
  137. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  138. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  139. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  140. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  141. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +53 -2
  142. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  143. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  144. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  145. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  146. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  147. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  148. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  149. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  150. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  151. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  152. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  153. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  154. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  155. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  156. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  157. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  158. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  159. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  160. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  161. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  162. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  163. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  164. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  165. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  166. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  167. package/dist/_pkgs/affine-model/consts/text.d.ts +26 -0
  168. package/dist/_pkgs/affine-model/consts/text.js +25 -0
  169. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  170. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  171. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  172. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  173. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  174. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  175. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  176. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  177. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  178. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  179. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  180. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  181. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  182. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  183. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
  184. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  185. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  186. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  187. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  188. package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
  189. package/dist/_pkgs/affine-shared/services/index.js +3 -0
  190. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  191. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  192. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  193. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  194. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +5 -0
  195. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +9 -0
  196. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  197. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  198. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  199. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  200. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  201. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  202. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  203. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  204. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  205. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  206. package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
  207. package/dist/_pkgs/affine-shared/utils/index.js +2 -0
  208. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  209. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  210. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  211. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  212. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +10 -3
  213. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  214. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  215. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  216. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  217. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  218. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
  219. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
  220. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  221. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  222. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  223. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  224. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  225. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  226. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
  227. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
  228. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +52 -0
  229. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +161 -1
  230. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  231. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  232. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  233. package/dist/_pkgs/std/gfx/controller.js +22 -2
  234. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  235. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  236. package/dist/_pkgs/std/gfx/index.js +3 -1
  237. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  238. package/dist/_pkgs/std/gfx/layer.js +73 -5
  239. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  240. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  241. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  242. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  243. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  244. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  245. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  246. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  247. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  248. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  249. package/dist/_pkgs/std/utils/layer.js +64 -13
  250. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  251. package/dist/commands.js +4 -1
  252. package/dist/translations.js +10 -6
  253. package/package.json +9 -2
  254. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  255. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  256. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  257. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  258. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  259. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  260. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  261. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  262. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  263. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -0,0 +1,88 @@
1
+ import type { Store } from '../../store/index.js';
2
+ import { type ReadonlySignal } from '@preact/signals-core';
3
+ import type { GfxLocalElementModel } from './model/surface/local-element-model.js';
4
+ import type { GfxModel } from './model/model.js';
5
+ import type { SurfaceBlockModel } from './model/surface/surface-model.js';
6
+ /**
7
+ * The ids of the elements and gfx blocks hidden for everyone (ADR 0031 §7) —
8
+ * the SHARED half of the paint and pick predicate, kept as a set so the
9
+ * renderers ask one `has` per element and pay nothing when nobody hid
10
+ * anything.
11
+ *
12
+ * Built from the document once per surface, then kept current by the
13
+ * surface's element events and the store's block events, local or remote
14
+ * alike: a peer's "hide for everyone" reaches this viewer the moment its
15
+ * update does. Registered by `GfxController` into its
16
+ * {@link GfxLocalVisibility}, beside the viewer's own local hide, so every
17
+ * site that already skips what this viewer hid skips this too — and
18
+ * `grid.search`, which reads neither, keeps counting both.
19
+ */
20
+ export declare class GfxHiddenForEveryone {
21
+ private readonly _ids$;
22
+ private readonly _layerIds$;
23
+ private _unwatch;
24
+ /** Every id carrying the stored `hiddenForEveryone`. */
25
+ get ids$(): ReadonlySignal<ReadonlySet<string>>;
26
+ /**
27
+ * Every user layer hidden for everyone — `hidden: true` on its record (ADR
28
+ * 0031 §7): one write for a whole layer, never one per member.
29
+ */
30
+ get layerIds$(): ReadonlySignal<ReadonlySet<string>>;
31
+ /** Follow `surface` and `store`; `null` stops following. */
32
+ watch(store: Store, surface: SurfaceBlockModel | null): void;
33
+ dispose(): void;
34
+ }
35
+ /**
36
+ * What THIS viewer does not see on the canvas — the per-editor predicate hook
37
+ * of ADR 0031 §8.
38
+ *
39
+ * `std` knows nothing about why an element is hidden for one viewer; the
40
+ * affine layer (`CanvasLocalVisibility`) registers a signal of ids and owns
41
+ * their persistence. `GfxController` registers one more source, the ids
42
+ * hidden for everyone ({@link GfxHiddenForEveryone}): the shared half of the
43
+ * same predicate, so the sites below skip both with one question. Layers
44
+ * have their own sources (`registerLayers`), local and shared alike: a model
45
+ * whose EFFECTIVE layer is hidden is hidden. This class answers the one
46
+ * question the gfx plumbing asks — "does this viewer see that model?" — at the places a viewer's eye
47
+ * and hand reach the canvas: the renderers, the DOM block views, pointer
48
+ * picking and the marquee.
49
+ *
50
+ * It is deliberately NOT consulted by `GridManager.search`: that answer is
51
+ * shared with rules, legends and semantic exports, and one viewer's local
52
+ * hide must never change what another viewer's rules say about the same
53
+ * document.
54
+ *
55
+ * Reactive: `isHidden` reads a signal, so an effect or a `computed` that asks
56
+ * re-runs when the set changes (the DOM block views rely on it). With nothing
57
+ * registered, or nothing hidden, every answer is `false` after one size check.
58
+ */
59
+ export declare class GfxLocalVisibility {
60
+ private readonly _sources$;
61
+ /** Every id hidden for this viewer, across every registered source. */
62
+ readonly hiddenIds$: ReadonlySignal<ReadonlySet<string>>;
63
+ private readonly _layerSources$;
64
+ /** Every user layer hidden for this viewer, across every layer source. */
65
+ readonly hiddenLayerIds$: ReadonlySignal<ReadonlySet<string>>;
66
+ /** Add a source of hidden ids. Returns its disposer. */
67
+ register(source: ReadonlySignal<ReadonlySet<string>>): () => void;
68
+ /** Add a source of hidden LAYER ids (ADR 0031, stage 7). Returns its disposer. */
69
+ registerLayers(source: ReadonlySignal<ReadonlySet<string>>): () => void;
70
+ /**
71
+ * Is `model` hidden for this viewer — itself, or through a group-like
72
+ * ELEMENT ancestor (a group, a mindmap)?
73
+ *
74
+ * Frames are not walked, although they are group-compatible: a frame is a
75
+ * slide, and hiding the frame hides the frame, not what it holds (ADR 0031
76
+ * §5). A model no surface holds has no ancestors to ask about.
77
+ */
78
+ isHidden(model: GfxModel | GfxLocalElementModel): boolean;
79
+ /**
80
+ * Whether `model`'s EFFECTIVE layer is one of `layers` — the outermost
81
+ * group's layer, so a whole group hides with its layer. A hidden frame's
82
+ * layer hides the frame, not what it holds (ADR 0031 §5). Local elements
83
+ * belong to no layer. A surface with no `layers` record still has the
84
+ * default layer, shown and hideable before it is recorded (ADR 0031
85
+ * amendments): every model is then in it.
86
+ */
87
+ private _inHiddenLayer;
88
+ }
@@ -0,0 +1,217 @@
1
+ import { computed, signal } from '@preact/signals-core';
2
+ import { GfxBlockElementModel } from './model/gfx-block-model.js';
3
+ import { GfxPrimitiveElementModel, isStoredHiddenForEveryone, } from './model/surface/element-model.js';
4
+ import { userLayersOf } from './model/surface/user-layers.js';
5
+ const NOTHING_HIDDEN = new Set();
6
+ /**
7
+ * The ids of the elements and gfx blocks hidden for everyone (ADR 0031 §7) —
8
+ * the SHARED half of the paint and pick predicate, kept as a set so the
9
+ * renderers ask one `has` per element and pay nothing when nobody hid
10
+ * anything.
11
+ *
12
+ * Built from the document once per surface, then kept current by the
13
+ * surface's element events and the store's block events, local or remote
14
+ * alike: a peer's "hide for everyone" reaches this viewer the moment its
15
+ * update does. Registered by `GfxController` into its
16
+ * {@link GfxLocalVisibility}, beside the viewer's own local hide, so every
17
+ * site that already skips what this viewer hid skips this too — and
18
+ * `grid.search`, which reads neither, keeps counting both.
19
+ */
20
+ export class GfxHiddenForEveryone {
21
+ constructor() {
22
+ this._ids$ = signal(NOTHING_HIDDEN);
23
+ this._layerIds$ = signal(NOTHING_HIDDEN);
24
+ this._unwatch = null;
25
+ }
26
+ /** Every id carrying the stored `hiddenForEveryone`. */
27
+ get ids$() {
28
+ return this._ids$;
29
+ }
30
+ /**
31
+ * Every user layer hidden for everyone — `hidden: true` on its record (ADR
32
+ * 0031 §7): one write for a whole layer, never one per member.
33
+ */
34
+ get layerIds$() {
35
+ return this._layerIds$;
36
+ }
37
+ /** Follow `surface` and `store`; `null` stops following. */
38
+ watch(store, surface) {
39
+ this.dispose();
40
+ if (!surface)
41
+ return;
42
+ const initial = new Set();
43
+ for (const element of surface.elementModels) {
44
+ if (isStoredHiddenForEveryone(element))
45
+ initial.add(element.id);
46
+ }
47
+ for (const model of store.getAllModels()) {
48
+ if (model instanceof GfxBlockElementModel &&
49
+ isStoredHiddenForEveryone(model)) {
50
+ initial.add(model.id);
51
+ }
52
+ }
53
+ this._ids$.value = initial.size ? initial : NOTHING_HIDDEN;
54
+ const readLayers = () => {
55
+ const hidden = new Set();
56
+ for (const [id, record] of Object.entries(surface.props.layers ?? {})) {
57
+ if (record?.hidden === true)
58
+ hidden.add(id);
59
+ }
60
+ const current = this._layerIds$.peek();
61
+ if (hidden.size === current.size &&
62
+ [...hidden].every(id => current.has(id))) {
63
+ return;
64
+ }
65
+ this._layerIds$.value = hidden.size ? hidden : NOTHING_HIDDEN;
66
+ };
67
+ readLayers();
68
+ const recheck = (id, model) => {
69
+ const hidden = model !== null && isStoredHiddenForEveryone(model);
70
+ const current = this._ids$.peek();
71
+ if (current.has(id) === hidden)
72
+ return;
73
+ const next = new Set(current);
74
+ if (hidden)
75
+ next.add(id);
76
+ else
77
+ next.delete(id);
78
+ this._ids$.value = next.size ? next : NOTHING_HIDDEN;
79
+ };
80
+ const subscriptions = [
81
+ surface.propsUpdated.subscribe(({ key }) => {
82
+ if (key === 'layers')
83
+ readLayers();
84
+ }),
85
+ surface.elementAdded.subscribe(({ id }) => recheck(id, surface.getElementById(id))),
86
+ surface.elementUpdated.subscribe(({ id }) => recheck(id, surface.getElementById(id))),
87
+ surface.elementRemoved.subscribe(({ id }) => recheck(id, null)),
88
+ store.slots.blockUpdated.subscribe(payload => {
89
+ if (payload.type === 'delete') {
90
+ recheck(payload.id, null);
91
+ return;
92
+ }
93
+ if (payload.type === 'update' &&
94
+ payload.props.key !== 'hiddenForEveryone') {
95
+ return;
96
+ }
97
+ recheck(payload.id, store.getBlock(payload.id)?.model ?? null);
98
+ }),
99
+ ];
100
+ this._unwatch = () => subscriptions.forEach(sub => sub.unsubscribe());
101
+ }
102
+ dispose() {
103
+ this._unwatch?.();
104
+ this._unwatch = null;
105
+ this._ids$.value = NOTHING_HIDDEN;
106
+ this._layerIds$.value = NOTHING_HIDDEN;
107
+ }
108
+ }
109
+ /**
110
+ * What THIS viewer does not see on the canvas — the per-editor predicate hook
111
+ * of ADR 0031 §8.
112
+ *
113
+ * `std` knows nothing about why an element is hidden for one viewer; the
114
+ * affine layer (`CanvasLocalVisibility`) registers a signal of ids and owns
115
+ * their persistence. `GfxController` registers one more source, the ids
116
+ * hidden for everyone ({@link GfxHiddenForEveryone}): the shared half of the
117
+ * same predicate, so the sites below skip both with one question. Layers
118
+ * have their own sources (`registerLayers`), local and shared alike: a model
119
+ * whose EFFECTIVE layer is hidden is hidden. This class answers the one
120
+ * question the gfx plumbing asks — "does this viewer see that model?" — at the places a viewer's eye
121
+ * and hand reach the canvas: the renderers, the DOM block views, pointer
122
+ * picking and the marquee.
123
+ *
124
+ * It is deliberately NOT consulted by `GridManager.search`: that answer is
125
+ * shared with rules, legends and semantic exports, and one viewer's local
126
+ * hide must never change what another viewer's rules say about the same
127
+ * document.
128
+ *
129
+ * Reactive: `isHidden` reads a signal, so an effect or a `computed` that asks
130
+ * re-runs when the set changes (the DOM block views rely on it). With nothing
131
+ * registered, or nothing hidden, every answer is `false` after one size check.
132
+ */
133
+ export class GfxLocalVisibility {
134
+ constructor() {
135
+ this._sources$ = signal([]);
136
+ /** Every id hidden for this viewer, across every registered source. */
137
+ this.hiddenIds$ = computed(() => unionOf(this._sources$.value));
138
+ this._layerSources$ = signal([]);
139
+ /** Every user layer hidden for this viewer, across every layer source. */
140
+ this.hiddenLayerIds$ = computed(() => unionOf(this._layerSources$.value));
141
+ }
142
+ /** Add a source of hidden ids. Returns its disposer. */
143
+ register(source) {
144
+ this._sources$.value = [...this._sources$.peek(), source];
145
+ return () => {
146
+ this._sources$.value = this._sources$
147
+ .peek()
148
+ .filter(existing => existing !== source);
149
+ };
150
+ }
151
+ /** Add a source of hidden LAYER ids (ADR 0031, stage 7). Returns its disposer. */
152
+ registerLayers(source) {
153
+ this._layerSources$.value = [...this._layerSources$.peek(), source];
154
+ return () => {
155
+ this._layerSources$.value = this._layerSources$
156
+ .peek()
157
+ .filter(existing => existing !== source);
158
+ };
159
+ }
160
+ /**
161
+ * Is `model` hidden for this viewer — itself, or through a group-like
162
+ * ELEMENT ancestor (a group, a mindmap)?
163
+ *
164
+ * Frames are not walked, although they are group-compatible: a frame is a
165
+ * slide, and hiding the frame hides the frame, not what it holds (ADR 0031
166
+ * §5). A model no surface holds has no ancestors to ask about.
167
+ */
168
+ isHidden(model) {
169
+ const hiddenLayers = this.hiddenLayerIds$.value;
170
+ if (hiddenLayers.size > 0 && this._inHiddenLayer(model, hiddenLayers)) {
171
+ return true;
172
+ }
173
+ const hidden = this.hiddenIds$.value;
174
+ if (hidden.size === 0)
175
+ return false;
176
+ if (hidden.has(model.id))
177
+ return true;
178
+ let ancestors;
179
+ try {
180
+ ancestors = model.groups ?? [];
181
+ }
182
+ catch {
183
+ return false;
184
+ }
185
+ return ancestors.some(ancestor => ancestor instanceof GfxPrimitiveElementModel && hidden.has(ancestor.id));
186
+ }
187
+ /**
188
+ * Whether `model`'s EFFECTIVE layer is one of `layers` — the outermost
189
+ * group's layer, so a whole group hides with its layer. A hidden frame's
190
+ * layer hides the frame, not what it holds (ADR 0031 §5). Local elements
191
+ * belong to no layer. A surface with no `layers` record still has the
192
+ * default layer, shown and hideable before it is recorded (ADR 0031
193
+ * amendments): every model is then in it.
194
+ */
195
+ _inHiddenLayer(model, layers) {
196
+ const userLayers = userLayersOf(model);
197
+ if (!userLayers)
198
+ return false;
199
+ if (!(model instanceof GfxPrimitiveElementModel) &&
200
+ !(model instanceof GfxBlockElementModel)) {
201
+ return false;
202
+ }
203
+ return layers.has(userLayers.effectiveLayerOf(model));
204
+ }
205
+ }
206
+ function unionOf(sources) {
207
+ if (sources.length === 0)
208
+ return NOTHING_HIDDEN;
209
+ if (sources.length === 1)
210
+ return sources[0].value;
211
+ const union = new Set();
212
+ for (const source of sources) {
213
+ for (const id of source.value)
214
+ union.add(id);
215
+ }
216
+ return union;
217
+ }
@@ -13,6 +13,19 @@ export type GfxCompatibleProps = {
13
13
  xywh: SerializedXYWH;
14
14
  index: string;
15
15
  lockedBySelf?: boolean;
16
+ /**
17
+ * "Hide for everyone" (ADR 0031 §7). `true` or absent, never `false`:
18
+ * unhiding deletes the `prop:` key through the props proxy, so the block
19
+ * goes back to byte-identical. Every gfx block schema declares it with an
20
+ * `undefined` default, the way it declares `lockedBySelf`.
21
+ */
22
+ hiddenForEveryone?: true;
23
+ /**
24
+ * The user layer this block belongs to (ADR 0031 §3); `undefined` = the
25
+ * default layer. Declared by every gfx block schema with an `undefined`
26
+ * default, like `hiddenForEveryone`.
27
+ */
28
+ layer?: string;
16
29
  };
17
30
  /**
18
31
  * This type include the common props for the graphic block model.
@@ -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) => {
@@ -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];