@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
@@ -1,4 +1,4 @@
1
- import { type TagDef } from '../../affine-shared/services/index.js';
1
+ import { type ChromeWording, type TagDef } from '../../affine-shared/services/index.js';
2
2
  import { LifeCycleWatcher, type BlockStdScope, type FrameworkId } from '../../std/index.js';
3
3
  import type { RoleDefs, RoleId } from '../../std/gfx/index.js';
4
4
  import { GfxPrimitiveElementModel } from '../../std/gfx/index.js';
@@ -92,6 +92,14 @@ export interface ReadingRelationSideLabel {
92
92
  /** The framework's own English wording, for a host that ships no catalogue. */
93
93
  labelFallback: string;
94
94
  }
95
+ /**
96
+ * One wording a framework declares for the frame field of the panel: key plus
97
+ * its own English, so a host with no catalogue still reads a real phrase.
98
+ */
99
+ export interface ReadingFrameWording {
100
+ labelKey: string;
101
+ labelFallback: string;
102
+ }
95
103
  /**
96
104
  * The typed edge a reading walks, and the two words the framework reads it
97
105
  * with.
@@ -185,13 +193,41 @@ export interface ReadingProfile {
185
193
  * reads them in, so the first is the question the artefact answers first.
186
194
  */
187
195
  alsoRelations?: readonly ReadingRelationDef[];
188
- /** The frame the phase is read from. */
196
+ /**
197
+ * The frame the subject's ZONE is read from — Wardley's evolution phase, a
198
+ * Core Domain Chart's quadrant, a BPMN pool's lane.
199
+ */
189
200
  frame?: {
190
201
  backgroundRole: RoleId;
191
202
  /** The declaration itself, carried as data exactly like `roles` is. */
192
203
  background: FrameworkBackgroundDef;
193
- /** Which plot axis the zones are laid along. */
194
- axis: 'x' | 'y';
204
+ /**
205
+ * The plot axis the zones are laid ALONG, for a frame read in one
206
+ * dimension: Wardley's phases are columns of the evolution axis, so only
207
+ * the `x` position matters and a component in the top or bottom margin of
208
+ * the plot still has a phase.
209
+ *
210
+ * Absent, the frame is read in TWO dimensions: the subject is in the zone
211
+ * whose rectangle holds its centre — a quadrant, a lane — and nowhere when
212
+ * none does. A 2D frame has no transition band.
213
+ */
214
+ axis?: 'x' | 'y';
215
+ /**
216
+ * The panel's heading for the field — "Evolution phase", "Zone", "Lane".
217
+ * The framework's own word, like a relation's sides: the panel used to
218
+ * hard-code Wardley's, which a chart or a pool would have worn too.
219
+ *
220
+ * Optional because a 0.43 profile has no such field and a minor release
221
+ * never breaks a host: absent, the panel reads
222
+ * {@link READING_FRAME_DEFAULT_WORDING}, which is what 0.43 showed for
223
+ * every frame (`readingFrameWording`).
224
+ */
225
+ label?: ReadingFrameWording;
226
+ /**
227
+ * What the field says when the subject sits in no zone of any frame.
228
+ * Optional for the reason {@link label} is, with the same default.
229
+ */
230
+ none?: ReadingFrameWording;
195
231
  };
196
232
  /**
197
233
  * Which properties of the PIVOT RECORD the reading may compare itself
@@ -207,6 +243,21 @@ export interface ReadingProfile {
207
243
  phase?: string;
208
244
  };
209
245
  }
246
+ /** The default frame wording, as the rows the key manifest walks. */
247
+ export declare const READING_FRAME_WORDINGS: readonly ChromeWording[];
248
+ /** The default frame wording, as a profile's `frame.label` / `frame.none`. */
249
+ export declare const READING_FRAME_DEFAULT_WORDING: Readonly<{
250
+ label: ReadingFrameWording;
251
+ none: ReadingFrameWording;
252
+ }>;
253
+ /**
254
+ * The two wordings the panel reads a frame with: the framework's own where it
255
+ * declares them, {@link READING_FRAME_DEFAULT_WORDING} where it does not.
256
+ */
257
+ export declare function readingFrameWording(frame: NonNullable<ReadingProfile['frame']>): {
258
+ label: ReadingFrameWording;
259
+ none: ReadingFrameWording;
260
+ };
210
261
  /** Where the other end of a typed edge sits, relative to the subject. */
211
262
  export type ReadingRelationSide = 'consumer' | 'supplier';
212
263
  /**
@@ -271,12 +322,24 @@ export interface ReadingRelation {
271
322
  */
272
323
  contradictsGeometry: boolean;
273
324
  }
274
- /** Where the subject sits along the frame's phase axis. */
325
+ /**
326
+ * The zone of the frame the subject sits in: a phase along an axis, or a
327
+ * region of the plane (see `ReadingProfile.frame.axis`).
328
+ */
275
329
  export interface ReadingPhase {
276
- /** The declared zone id, e.g. `product`. */
330
+ /** The zone id, e.g. `product`, or `lane:<id>` for an instance zone. */
277
331
  zoneId: string;
332
+ /** The declared zone's vocabulary, absent on a zone the board never names. */
278
333
  labelKey?: string;
279
334
  labelFallback?: string;
335
+ /**
336
+ * The words the USER wrote for this zone, which is what the board paints in
337
+ * place of the vocabulary: a renamed zone label stored on the frame (the
338
+ * declaration's `label.prop`), or a lane's name. Wins over
339
+ * {@link labelKey} exactly as it does on the canvas (`backgroundLabelText`),
340
+ * so the panel and the board never name one zone two ways.
341
+ */
342
+ name?: string;
280
343
  /**
281
344
  * The subject sits in the band around a zone transition — Wardley's zone of
282
345
  * punctuated equilibrium, declared by the background as
@@ -331,6 +394,19 @@ export interface ElementReading {
331
394
  /** `undefined` with no nature, no convention for it, or no name to judge. */
332
395
  naming: ReadingNaming | undefined;
333
396
  }
397
+ /**
398
+ * The subject's NAME.
399
+ *
400
+ * Its own text first, then — because a framework artefact on this canvas is a
401
+ * composite — the text of the sibling carrying the profile's label role. That
402
+ * is the same fact `tags-toolbar.ts` works around from the other direction: one
403
+ * click selects the group, the role lives on the circle, and the name lives on
404
+ * a free text beside it.
405
+ *
406
+ * Exported for the selection pane, which names its rows the same way (ADR 0031
407
+ * §12): one rule for "what is this element called", not two.
408
+ */
409
+ export declare function readName(element: GfxPrimitiveElementModel, profile: Pick<ReadingProfile, 'labelRole' | 'roles'>): string;
334
410
  /** What the reading needs to know that is not in the document. */
335
411
  export interface ReadingOptions {
336
412
  /**
@@ -8,7 +8,49 @@ import { effect, signal } from '@preact/signals-core';
8
8
  // reading is a one-way read of pure declaration data that must never pull a
9
9
  // canvas in.
10
10
  import { backgroundPlot, } from '../framework-background/def.js';
11
- import { backgroundTransitionBands, containingFrame, } from '../framework-background/facts.js';
11
+ import { backgroundPlotRatios, backgroundTransitionBands, backgroundZoneAt, backgroundZones, containingFrame, } from '../framework-background/facts.js';
12
+ /**
13
+ * The frame wording of a profile that declares none — the heading and the
14
+ * empty state 0.43 showed for every frame, before a framework could name its
15
+ * own.
16
+ *
17
+ * Owned by the ENGINE rather than by Wardley, whose words they also are,
18
+ * because a host profile written against 0.43 reads with them too: declared in
19
+ * a framework bundle, they would vanish from a host that does not install it.
20
+ * Wardley's profile declares no wording and inherits these.
21
+ *
22
+ * Spelled as `[key, English]` rows, the form the key manifest walks and its
23
+ * drift check pairs with this declaration, then read as a profile's wording.
24
+ */
25
+ const READING_FRAME_DEFAULT_LABEL = [
26
+ 'com.labre.reading.field.phase',
27
+ 'Evolution phase',
28
+ ];
29
+ const READING_FRAME_DEFAULT_NONE = [
30
+ 'com.labre.reading.phase.none',
31
+ 'Not on a framework background — no phase to read.',
32
+ ];
33
+ /** The default frame wording, as the rows the key manifest walks. */
34
+ export const READING_FRAME_WORDINGS = [
35
+ READING_FRAME_DEFAULT_LABEL,
36
+ READING_FRAME_DEFAULT_NONE,
37
+ ];
38
+ const asFrameWording = ([labelKey, labelFallback,]) => ({ labelKey, labelFallback });
39
+ /** The default frame wording, as a profile's `frame.label` / `frame.none`. */
40
+ export const READING_FRAME_DEFAULT_WORDING = {
41
+ label: asFrameWording(READING_FRAME_DEFAULT_LABEL),
42
+ none: asFrameWording(READING_FRAME_DEFAULT_NONE),
43
+ };
44
+ /**
45
+ * The two wordings the panel reads a frame with: the framework's own where it
46
+ * declares them, {@link READING_FRAME_DEFAULT_WORDING} where it does not.
47
+ */
48
+ export function readingFrameWording(frame) {
49
+ return {
50
+ label: frame.label ?? READING_FRAME_DEFAULT_WORDING.label,
51
+ none: frame.none ?? READING_FRAME_DEFAULT_WORDING.none,
52
+ };
53
+ }
12
54
  /**
13
55
  * Every relation table a profile declares, in reading order.
14
56
  *
@@ -102,8 +144,11 @@ function groupMembers(element) {
102
144
  * is the same fact `tags-toolbar.ts` works around from the other direction: one
103
145
  * click selects the group, the role lives on the circle, and the name lives on
104
146
  * a free text beside it.
147
+ *
148
+ * Exported for the selection pane, which names its rows the same way (ADR 0031
149
+ * §12): one rule for "what is this element called", not two.
105
150
  */
106
- function readName(element, profile) {
151
+ export function readName(element, profile) {
107
152
  const own = ownText(element);
108
153
  if (own)
109
154
  return own;
@@ -168,13 +213,37 @@ function frameOf(element, elements, profile) {
168
213
  roleIsA(candidate.role, frame.backgroundRole, profile.roles)), candidate => candidate.elementBound);
169
214
  }
170
215
  /**
171
- * The phase, read from the position and the frame's DECLARED zones.
216
+ * How a zone is named, as the BOARD names it: the user's own words first — a
217
+ * renamed label stored on the frame, a lane's name — then the vocabulary.
172
218
  *
173
- * Two facts, both taken from the declaration and never from a number in this
174
- * file: which zone the subject's centre falls in, and whether it is inside the
175
- * band around a transition. The second is the "zone of punctuated equilibrium"
176
- * — the frontier is a region, not a coordinate — and a component sitting in one
177
- * is a different statement from a component sitting in a phase.
219
+ * The same precedence `backgroundLabelText` paints with, minus the translation:
220
+ * the reading carries the key and the panel resolves it, so the record and the
221
+ * drift comparison keep working on the vocabulary.
222
+ */
223
+ function zoneWording(zone, model) {
224
+ const label = zone.label;
225
+ const stored = label?.prop !== undefined ? model[label.prop] : undefined;
226
+ const name = stored !== undefined && stored !== null ? String(stored) : zone.name;
227
+ return {
228
+ ...(label?.labelKey !== undefined ? { labelKey: label.labelKey } : {}),
229
+ ...(label?.fallback !== undefined ? { labelFallback: label.fallback } : {}),
230
+ ...(name !== undefined ? { name } : {}),
231
+ };
232
+ }
233
+ /**
234
+ * The zone, read from the position and the zones the frame INSTANCE has
235
+ * ({@link backgroundZones}: the framework's in the instance's variant, then the
236
+ * instance's own).
237
+ *
238
+ * Along an axis (Wardley), two facts, both taken from the declaration and never
239
+ * from a number in this file: which zone the subject's centre falls in, and
240
+ * whether it is inside the band around a transition. The second is the "zone of
241
+ * punctuated equilibrium" — the frontier is a region, not a coordinate — and a
242
+ * component sitting in one is a different statement from a component sitting in
243
+ * a phase.
244
+ *
245
+ * In the plane (no `axis`: a Core Domain Chart, a BPMN pool), the zone whose
246
+ * rectangle holds the centre, through the helper the audit uses, and no band.
178
247
  */
179
248
  function readPhase(element, elements, profile) {
180
249
  const frame = profile.frame;
@@ -185,11 +254,25 @@ function readPhase(element, elements, profile) {
185
254
  return undefined;
186
255
  const def = frame.background;
187
256
  const bound = background.elementBound;
257
+ const model = background;
258
+ const zones = backgroundZones(def, model);
259
+ const axis = frame.axis;
260
+ if (axis === undefined) {
261
+ const at = backgroundPlotRatios(def, bound, element.elementBound);
262
+ const zone = at === null ? undefined : backgroundZoneAt(zones, at);
263
+ if (!zone)
264
+ return undefined;
265
+ return {
266
+ zoneId: zone.id,
267
+ ...zoneWording(zone, model),
268
+ inTransitionBand: false,
269
+ };
270
+ }
188
271
  const plot = backgroundPlot(def, bound.w, bound.h);
189
272
  const [cx, cy] = centreOf(element.elementBound);
190
- const along = frame.axis === 'x' ? cx : cy;
191
- const origin = frame.axis === 'x' ? bound.x + plot.x0 : bound.y + plot.y0;
192
- const span = frame.axis === 'x' ? plot.width : plot.height;
273
+ const along = axis === 'x' ? cx : cy;
274
+ const origin = axis === 'x' ? bound.x + plot.x0 : bound.y + plot.y0;
275
+ const span = axis === 'x' ? plot.width : plot.height;
193
276
  if (!(span > 0))
194
277
  return undefined;
195
278
  const ratio = (along - origin) / span;
@@ -198,25 +281,20 @@ function readPhase(element, elements, profile) {
198
281
  // phase it is visibly not in.
199
282
  if (ratio < 0 || ratio > 1)
200
283
  return undefined;
201
- const zone = (def.zones ?? []).find(({ rect }) => {
202
- const start = frame.axis === 'x' ? rect.x : rect.y;
203
- const size = frame.axis === 'x' ? rect.w : rect.h;
284
+ const zone = zones.find(({ rect }) => {
285
+ const start = axis === 'x' ? rect.x : rect.y;
286
+ const size = axis === 'x' ? rect.w : rect.h;
204
287
  // Half-open, so a component exactly on a divider reads as the phase it is
205
288
  // entering — the same side the band below reports as the frontier.
206
289
  return ratio >= start && (ratio < start + size || start + size >= 1);
207
290
  });
208
291
  if (!zone)
209
292
  return undefined;
210
- const bands = backgroundTransitionBands(def, bound)[frame.axis];
293
+ const bands = backgroundTransitionBands(def, bound)[axis];
211
294
  const band = bands.find(({ min, max }) => along >= min && along <= max);
212
295
  return {
213
296
  zoneId: zone.id,
214
- ...(zone.label?.labelKey !== undefined
215
- ? { labelKey: zone.label.labelKey }
216
- : {}),
217
- ...(zone.label?.fallback !== undefined
218
- ? { labelFallback: zone.label.fallback }
219
- : {}),
297
+ ...zoneWording(zone, model),
220
298
  inTransitionBand: band !== undefined,
221
299
  ...(band !== undefined ? { bandId: band.id } : {}),
222
300
  };
@@ -0,0 +1,80 @@
1
+ import type { BlockStdScope } from '../../../std/index.js';
2
+ import type { SelectionPaneNode } from './tree.js';
3
+ /**
4
+ * Move `id` so it sits directly ABOVE `above` in the stack — `null` puts it at
5
+ * the bottom of its stack. Answers whether anything was written.
6
+ *
7
+ * The drop target of a drag in a top-first list: dropping a row just over row
8
+ * X means "directly above X". The new `index` is a key between the two
9
+ * neighbours (the same `fractional-indexing` keys `LayerManager` generates), so
10
+ * one field of one model is written and nothing else moves.
11
+ *
12
+ * Refused, with nothing written: a read-only document; a mindmap node (it has
13
+ * no index of its own — the whole mindmap moves as one, as the toolbar's
14
+ * reorder already says); an `above` that is not stacked with `id`; and a
15
+ * target that is where the model already is.
16
+ */
17
+ export declare function reorderPaneElement(std: BlockStdScope, id: string, above: string | null): boolean;
18
+ /**
19
+ * Lock or unlock each model ON ITS OWN. Answers whether anything was written.
20
+ *
21
+ * Deliberately not the contextual toolbar's lock: that one, given several
22
+ * elements, wraps them into a new group and locks the group — a structural
23
+ * edit a row's padlock must never make. Here each row keeps its place in the
24
+ * tree; only `lockedBySelf` changes, and only where it differs.
25
+ */
26
+ export declare function setPaneElementsLocked(std: BlockStdScope, ids: readonly string[], locked: boolean): boolean;
27
+ /**
28
+ * Hide models for EVERYONE, or show them again (ADR 0031 §7). Answers how
29
+ * many models were written.
30
+ *
31
+ * Writes the stored `hiddenForEveryone` — never `hidden`, which mindmap
32
+ * collapse owns. Hiding writes `true`; showing REMOVES the key (`clearField`
33
+ * on an element, the props proxy's delete on a block), never stores `false`,
34
+ * so an unhidden document is byte-identical to one never hidden. Models
35
+ * already in the asked state are skipped, so a gesture that changes nothing
36
+ * writes nothing and pushes no undo step; the rest go in one transaction
37
+ * after one `captureSync()`.
38
+ */
39
+ export declare function setPaneElementsHiddenForEveryone(std: BlockStdScope, ids: readonly string[], hidden: boolean): number;
40
+ /**
41
+ * Rename a group through its existing stored `title`. Answers whether
42
+ * anything was written. An empty or unchanged title writes nothing.
43
+ */
44
+ export declare function renamePaneGroup(std: BlockStdScope, id: string, title: string): boolean;
45
+ /**
46
+ * Rename a frame through its existing stored `title`, edited in place — the
47
+ * `Text` the frame's own title editor binds to, never a replaced one, so an
48
+ * open title editor keeps its binding. Answers whether anything was written.
49
+ * An empty or unchanged title writes nothing.
50
+ */
51
+ export declare function renamePaneFrame(std: BlockStdScope, id: string, title: string): boolean;
52
+ /** Something the pane can be filtered by: a frame, and only a frame. */
53
+ export interface SelectionPaneFilterTarget {
54
+ id: string;
55
+ /**
56
+ * Always `'frame'`. A framework board was offered too until the product
57
+ * owner's review narrowed the filter to frames (ADR 0031, amendments); the
58
+ * field stays so a host reading it has nothing to change.
59
+ */
60
+ kind: 'frame';
61
+ }
62
+ /** The frames on the canvas, top first — what the pane's filter offers. */
63
+ export declare function selectionPaneFilterTargets(std: BlockStdScope): SelectionPaneFilterTarget[];
64
+ /**
65
+ * The ids a frame filter keeps: the frame itself — a row like any other, so
66
+ * the list keeps showing what it is filtered by (ADR 0031, amendments) — its
67
+ * `childElementIds` and their descendants. `null` for an id that is not a
68
+ * frame.
69
+ */
70
+ export declare function selectionPaneFilterMembers(std: BlockStdScope, targetId: string): Set<string> | null;
71
+ /**
72
+ * The tree narrowed to `members`: a row is kept when it is a member or holds
73
+ * one, so a group reaching into a frame stays as the path to its member.
74
+ *
75
+ * A LAYER row is always kept, its children narrowed (ADR 0031, amendments): a
76
+ * layer is where new elements land and where a drop goes, not something a
77
+ * frame holds, and a layer created under a filter that hid it read as a
78
+ * "New layer" button doing nothing.
79
+ */
80
+ export declare function filterSelectionPaneTree(nodes: readonly SelectionPaneNode[], members: ReadonlySet<string>): SelectionPaneNode[];
@@ -0,0 +1,248 @@
1
+ import { FrameBlockModel, GroupElementModel, MindmapElementModel, } from '../../../affine-model/index.js';
2
+ import { compareLayer, GfxBlockElementModel, GfxControllerIdentifier, GfxPrimitiveElementModel, isStoredHiddenForEveryone, } from '../../../std/gfx/index.js';
3
+ import { generateKeyBetween } from 'fractional-indexing';
4
+ import * as Y from 'yjs';
5
+ /**
6
+ * The selection pane's writes (ADR 0031, stage 2). Every one of them:
7
+ *
8
+ * - refuses on a read-only document before reading anything else;
9
+ * - writes nothing when nothing would change — an unchanged write is an empty
10
+ * undo step, and an undo that "does nothing" reads as a broken undo;
11
+ * - takes ONE `captureSync()` first, so one gesture in the pane is one undo
12
+ * step, whatever it touched;
13
+ * - writes through `gfx.updateElement`, which is `surface.updateElement` for an
14
+ * element and `store.updateBlock` for a block — never a `Y.Map` directly.
15
+ *
16
+ * They are reached through the `canvas.element.*` / `canvas.group.rename`
17
+ * commands, so a host's own pane gets the same guards by calling `runCommand`.
18
+ */
19
+ function gfxModel(std, id) {
20
+ const model = std.get(GfxControllerIdentifier).getElementById(id);
21
+ return model instanceof GfxPrimitiveElementModel ||
22
+ model instanceof GfxBlockElementModel
23
+ ? model
24
+ : null;
25
+ }
26
+ /**
27
+ * The models a reorder compares against: those sharing the moved model's RAW
28
+ * `group` — a group, a mindmap, a frame, or none.
29
+ *
30
+ * Raw and not the pane's container on purpose: an `index` only orders a model
31
+ * among the models its group-like ancestor stacks together (`compare` puts a
32
+ * frame's members right above the frame), so a key computed against a wider
33
+ * list could be written and still not move the row.
34
+ */
35
+ function stackSiblings(std, model) {
36
+ const group = model.group;
37
+ const gfx = std.get(GfxControllerIdentifier);
38
+ // With user layers a model is restacked within its layer (ADR 0031 §4):
39
+ // a key computed against another layer's neighbours would not move it.
40
+ const userLayers = gfx.surface?.userLayers;
41
+ const layer = userLayers?.ranks ? userLayers.effectiveLayerOf(model) : null;
42
+ return gfx.gfxElements
43
+ .filter(other => other.group === group &&
44
+ (layer === null || userLayers.effectiveLayerOf(other) === layer))
45
+ .sort(compareLayer);
46
+ }
47
+ /**
48
+ * Move `id` so it sits directly ABOVE `above` in the stack — `null` puts it at
49
+ * the bottom of its stack. Answers whether anything was written.
50
+ *
51
+ * The drop target of a drag in a top-first list: dropping a row just over row
52
+ * X means "directly above X". The new `index` is a key between the two
53
+ * neighbours (the same `fractional-indexing` keys `LayerManager` generates), so
54
+ * one field of one model is written and nothing else moves.
55
+ *
56
+ * Refused, with nothing written: a read-only document; a mindmap node (it has
57
+ * no index of its own — the whole mindmap moves as one, as the toolbar's
58
+ * reorder already says); an `above` that is not stacked with `id`; and a
59
+ * target that is where the model already is.
60
+ */
61
+ export function reorderPaneElement(std, id, above) {
62
+ if (std.store.readonly)
63
+ return false;
64
+ const model = gfxModel(std, id);
65
+ if (!model || id === above)
66
+ return false;
67
+ if (model.group instanceof MindmapElementModel)
68
+ return false;
69
+ const siblings = stackSiblings(std, model);
70
+ const others = siblings.filter(other => other !== model);
71
+ let position = 0;
72
+ if (above !== null) {
73
+ const target = others.findIndex(other => other.id === above);
74
+ if (target === -1)
75
+ return false;
76
+ position = target + 1;
77
+ }
78
+ // Already there: the model's current lower neighbour is the target.
79
+ const current = siblings.indexOf(model);
80
+ const lowerNow = current > 0 ? siblings[current - 1] : null;
81
+ if ((lowerNow?.id ?? null) === above)
82
+ return false;
83
+ const lower = others[position - 1]?.index ?? null;
84
+ const upper = others[position]?.index ?? null;
85
+ // Two equal keys cannot be split. `generateIndex` never produces them, so
86
+ // this only guards a hand-made document; refusing beats throwing in a drop.
87
+ if (lower !== null && upper !== null && lower >= upper)
88
+ return false;
89
+ const index = generateKeyBetween(lower, upper);
90
+ std.store.captureSync();
91
+ std.get(GfxControllerIdentifier).updateElement(model, { index });
92
+ return true;
93
+ }
94
+ /**
95
+ * Lock or unlock each model ON ITS OWN. Answers whether anything was written.
96
+ *
97
+ * Deliberately not the contextual toolbar's lock: that one, given several
98
+ * elements, wraps them into a new group and locks the group — a structural
99
+ * edit a row's padlock must never make. Here each row keeps its place in the
100
+ * tree; only `lockedBySelf` changes, and only where it differs.
101
+ */
102
+ export function setPaneElementsLocked(std, ids, locked) {
103
+ if (std.store.readonly)
104
+ return false;
105
+ const targets = ids
106
+ .map(id => gfxModel(std, id))
107
+ .filter((model) => model !== null && (model.lockedBySelf === true) !== locked);
108
+ if (!targets.length)
109
+ return false;
110
+ const gfx = std.get(GfxControllerIdentifier);
111
+ std.store.captureSync();
112
+ std.store.transact(() => {
113
+ for (const model of targets) {
114
+ gfx.updateElement(model, { lockedBySelf: locked });
115
+ }
116
+ });
117
+ return true;
118
+ }
119
+ /**
120
+ * Hide models for EVERYONE, or show them again (ADR 0031 §7). Answers how
121
+ * many models were written.
122
+ *
123
+ * Writes the stored `hiddenForEveryone` — never `hidden`, which mindmap
124
+ * collapse owns. Hiding writes `true`; showing REMOVES the key (`clearField`
125
+ * on an element, the props proxy's delete on a block), never stores `false`,
126
+ * so an unhidden document is byte-identical to one never hidden. Models
127
+ * already in the asked state are skipped, so a gesture that changes nothing
128
+ * writes nothing and pushes no undo step; the rest go in one transaction
129
+ * after one `captureSync()`.
130
+ */
131
+ export function setPaneElementsHiddenForEveryone(std, ids, hidden) {
132
+ if (std.store.readonly)
133
+ return 0;
134
+ const targets = ids
135
+ .map(id => gfxModel(std, id))
136
+ .filter((model) => model !== null && isStoredHiddenForEveryone(model) !== hidden);
137
+ if (!targets.length)
138
+ return 0;
139
+ const gfx = std.get(GfxControllerIdentifier);
140
+ std.store.captureSync();
141
+ std.store.transact(() => {
142
+ for (const model of targets) {
143
+ if (hidden) {
144
+ gfx.updateElement(model, { hiddenForEveryone: true });
145
+ }
146
+ else if (model instanceof GfxPrimitiveElementModel) {
147
+ model.clearField('hiddenForEveryone');
148
+ }
149
+ else {
150
+ // The props proxy deletes the `prop:` key (ADR 0031 §7).
151
+ delete model.props.hiddenForEveryone;
152
+ }
153
+ }
154
+ });
155
+ return targets.length;
156
+ }
157
+ /**
158
+ * Rename a group through its existing stored `title`. Answers whether
159
+ * anything was written. An empty or unchanged title writes nothing.
160
+ */
161
+ export function renamePaneGroup(std, id, title) {
162
+ if (std.store.readonly)
163
+ return false;
164
+ const model = gfxModel(std, id);
165
+ if (!(model instanceof GroupElementModel))
166
+ return false;
167
+ const next = title.trim();
168
+ if (!next || next === model.title.toString())
169
+ return false;
170
+ std.store.captureSync();
171
+ std
172
+ .get(GfxControllerIdentifier)
173
+ .updateElement(model, { title: new Y.Text(next) });
174
+ return true;
175
+ }
176
+ /**
177
+ * Rename a frame through its existing stored `title`, edited in place — the
178
+ * `Text` the frame's own title editor binds to, never a replaced one, so an
179
+ * open title editor keeps its binding. Answers whether anything was written.
180
+ * An empty or unchanged title writes nothing.
181
+ */
182
+ export function renamePaneFrame(std, id, title) {
183
+ if (std.store.readonly)
184
+ return false;
185
+ const model = gfxModel(std, id);
186
+ if (!(model instanceof FrameBlockModel))
187
+ return false;
188
+ const next = title.trim();
189
+ const text = model.props.title;
190
+ if (!next || next === text.toString())
191
+ return false;
192
+ std.store.captureSync();
193
+ text.replace(0, text.length, next);
194
+ return true;
195
+ }
196
+ /** The frames on the canvas, top first — what the pane's filter offers. */
197
+ export function selectionPaneFilterTargets(std) {
198
+ return std
199
+ .get(GfxControllerIdentifier)
200
+ .gfxElements.filter(model => model instanceof FrameBlockModel)
201
+ .sort((a, b) => compareLayer(b, a))
202
+ .map(model => ({ id: model.id, kind: 'frame' }));
203
+ }
204
+ /**
205
+ * The ids a frame filter keeps: the frame itself — a row like any other, so
206
+ * the list keeps showing what it is filtered by (ADR 0031, amendments) — its
207
+ * `childElementIds` and their descendants. `null` for an id that is not a
208
+ * frame.
209
+ */
210
+ export function selectionPaneFilterMembers(std, targetId) {
211
+ const target = std.get(GfxControllerIdentifier).getElementById(targetId);
212
+ if (!(target instanceof FrameBlockModel))
213
+ return null;
214
+ const ids = new Set([target.id]);
215
+ for (const child of target.childElements) {
216
+ ids.add(child.id);
217
+ if ('descendantElements' in child) {
218
+ for (const descendant of child
219
+ .descendantElements) {
220
+ ids.add(descendant.id);
221
+ }
222
+ }
223
+ }
224
+ return ids;
225
+ }
226
+ /**
227
+ * The tree narrowed to `members`: a row is kept when it is a member or holds
228
+ * one, so a group reaching into a frame stays as the path to its member.
229
+ *
230
+ * A LAYER row is always kept, its children narrowed (ADR 0031, amendments): a
231
+ * layer is where new elements land and where a drop goes, not something a
232
+ * frame holds, and a layer created under a filter that hid it read as a
233
+ * "New layer" button doing nothing.
234
+ */
235
+ export function filterSelectionPaneTree(nodes, members) {
236
+ const kept = [];
237
+ for (const node of nodes) {
238
+ const children = node.children
239
+ ? filterSelectionPaneTree(node.children, members)
240
+ : undefined;
241
+ if (node.kind === 'layer' ||
242
+ members.has(node.id) ||
243
+ (children && children.length)) {
244
+ kept.push(children ? { ...node, children } : node);
245
+ }
246
+ }
247
+ return kept;
248
+ }